Skip to content

Constraints sdts refactoring #96

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
a80c68f
remove transition guards, remove generics from datavalue
fhowar Feb 21, 2025
e03b523
remove guardexpression
fhowar Feb 21, 2025
f151896
simplify constraint solver utils
fhowar Feb 21, 2025
3cf1f58
maven compiler level 16
fhowar Feb 21, 2025
077ffed
many small clean ups and remove Relation
fhowar Feb 21, 2025
06ed217
remove unused code and extract merge from SDTGuard
fhowar Feb 21, 2025
afe8ed6
spotless
fhowar Feb 21, 2025
086dfae
simplified SDTGuards
fhowar Feb 25, 2025
573a850
increase java version
fhowar Feb 25, 2025
9a84382
spotless
fhowar Feb 25, 2025
951edfd
Update ci.yml
fhowar Feb 25, 2025
2ed7ee1
remove SymbolicDecisionTree interface
fhowar Feb 26, 2025
b7c9dbb
spotless
fhowar Feb 26, 2025
5c80382
Make code base work with Java 17
kostis Feb 26, 2025
2200498
improve classanalyzer tests
fhowar Feb 26, 2025
e7c288d
Remove or comment out some leftover prints
kostis Feb 27, 2025
7d4384f
add bijection class and new sdt equivalence implementation
FredrikTaquist Mar 10, 2025
21bf79e
add class missing in previous commit
FredrikTaquist Mar 10, 2025
7e4016d
fix mappings and valuations
fhowar Mar 11, 2025
316490a
Add org.checkerframework:checker-qual to pom.xml
kostis Mar 17, 2025
ffa909e
removed piv
fhowar Mar 20, 2025
a295918
Fix spelling error in SDTLogicOracle.java
kostis Mar 20, 2025
66f63ed
Fix spelling error in RegisterAssignment.java
kostis Mar 20, 2025
d5b2aa9
fixed some bugs
fhowar Mar 20, 2025
fc107f7
memorables as set
fhowar Mar 21, 2025
45ed014
two more small bugs
fhowar Mar 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>

<!-- Dependency versions appear alphabetically below -->
<checker-qual.version>3.49.1</checker-qual.version>
<commons-lang.version>3.17.0</commons-lang.version>
<guava.version>33.4.0-jre</guava.version>
<jakarta-xml.version>4.0.2</jakarta-xml.version>
Expand Down Expand Up @@ -119,6 +120,24 @@
</descriptorRefs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<release>17</release>
<showWarnings>true</showWarnings>
<compilerArgs>
<arg>--enable-preview</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>--enable-preview</argLine>
</configuration>
</plugin>
</plugins>
</build>

Expand All @@ -145,6 +164,12 @@
<version>${jaxb-runtime.version}</version>
<scope>runtime</scope>
</dependency>
<!-- checker framework -->
<dependency>
<groupId>org.checkerframework</groupId>
<artifactId>checker-qual</artifactId>
<version>${checker-qual.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down Expand Up @@ -199,6 +224,10 @@
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
</dependency>
<dependency>
<groupId>org.checkerframework</groupId>
<artifactId>checker-qual</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
Expand Down
17 changes: 10 additions & 7 deletions src/main/java/de/learnlib/ralib/automata/Assignment.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,13 @@
*/
package de.learnlib.ralib.automata;

import java.util.List;
import java.util.Map.Entry;

import de.learnlib.ralib.data.Constants;
import de.learnlib.ralib.data.ParValuation;
import de.learnlib.ralib.data.SymbolicDataValue;
import de.learnlib.ralib.data.*;
import de.learnlib.ralib.data.SymbolicDataValue.Constant;
import de.learnlib.ralib.data.SymbolicDataValue.Parameter;
import de.learnlib.ralib.data.SymbolicDataValue.Register;
import de.learnlib.ralib.data.VarMapping;
import de.learnlib.ralib.data.VarValuation;

/**
* A parallel assignment for registers.
Expand All @@ -40,8 +37,14 @@ public Assignment(VarMapping<Register, ? extends SymbolicDataValue> assignment)
this.assignment = assignment;
}

public VarValuation compute(VarValuation registers, ParValuation parameters, Constants consts) {
VarValuation val = new VarValuation(registers);
public RegisterValuation compute(RegisterValuation registers, ParameterValuation parameters, Constants consts) {
RegisterValuation val = new RegisterValuation();
List<String> rNames = assignment.keySet().stream().map(k -> k.getName()).toList();
for (Entry<Register, DataValue> e : registers.entrySet()) {
if (!rNames.contains(e.getKey().getName())) {
val.put(e.getKey(), e.getValue());
}
}
for (Entry<Register, ? extends SymbolicDataValue> e : assignment) {
SymbolicDataValue valp = e.getValue();
if (valp.isRegister()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@
package de.learnlib.ralib.automata;

import de.learnlib.ralib.words.InputSymbol;
import gov.nasa.jpf.constraints.api.Expression;

/**
*
* @author falk
*/
public class InputTransition extends Transition {

public InputTransition(TransitionGuard guard, InputSymbol label, RALocation source, RALocation destination, Assignment assignment) {
public InputTransition(Expression<Boolean> guard, InputSymbol label, RALocation source, RALocation destination, Assignment assignment) {
super(label, guard, source, destination, assignment);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import java.util.Set;

import de.learnlib.ralib.data.Constants;
import de.learnlib.ralib.data.ParValuation;
import de.learnlib.ralib.data.VarValuation;
import de.learnlib.ralib.data.ParameterValuation;
import de.learnlib.ralib.data.RegisterValuation;
import de.learnlib.ralib.words.PSymbolInstance;
import de.learnlib.ralib.words.ParameterizedSymbol;
import net.automatalib.automaton.MutableDeterministic;
Expand All @@ -47,7 +47,7 @@ public class MutableRegisterAutomaton extends RegisterAutomaton

private final Set<RALocation> locations = new LinkedHashSet<>();

public MutableRegisterAutomaton(Constants consts, VarValuation initialRegisters) {
public MutableRegisterAutomaton(Constants consts, RegisterValuation initialRegisters) {
super(initialRegisters);
this.constants = consts;
}
Expand Down Expand Up @@ -87,12 +87,12 @@ public Collection<RALocation> getStates() {
}

protected List<Transition> getTransitions(Word<PSymbolInstance> dw) {
VarValuation vars = new VarValuation(getInitialRegisters());
RegisterValuation vars = RegisterValuation.copyOf(getInitialRegisters());
RALocation current = initial;
List<Transition> tseq = new ArrayList<>();
for (PSymbolInstance psi : dw) {

ParValuation pars = new ParValuation(psi);
ParameterValuation pars = ParameterValuation.fromPSymbolInstance(psi);

Collection<Transition> candidates =
current.getOut(psi.getBaseSymbol());
Expand All @@ -119,13 +119,13 @@ protected List<Transition> getTransitions(Word<PSymbolInstance> dw) {
return tseq;
}

protected List<Pair<Transition,VarValuation>> getTransitionsAndValuations(Word<PSymbolInstance> dw) {
VarValuation vars = new VarValuation(getInitialRegisters());
protected List<Pair<Transition,RegisterValuation>> getTransitionsAndValuations(Word<PSymbolInstance> dw) {
RegisterValuation vars = RegisterValuation.copyOf(getInitialRegisters());
RALocation current = initial;
List<Pair<Transition,VarValuation>> tvseq = new ArrayList<>();
List<Pair<Transition,RegisterValuation>> tvseq = new ArrayList<>();
for (PSymbolInstance psi : dw) {

ParValuation pars = new ParValuation(psi);
ParameterValuation pars = ParameterValuation.fromPSymbolInstance(psi);

Collection<Transition> candidates =
current.getOut(psi.getBaseSymbol());
Expand All @@ -139,7 +139,7 @@ protected List<Pair<Transition,VarValuation>> getTransitionsAndValuations(Word<P
if (t.isEnabled(vars, pars, constants)) {
vars = t.execute(vars, pars, constants);
current = t.getDestination();
tvseq.add(Pair.of(t, new VarValuation(vars)));
tvseq.add(Pair.of(t, RegisterValuation.copyOf(vars)));
found = true;
break;
}
Expand Down
5 changes: 1 addition & 4 deletions src/main/java/de/learnlib/ralib/automata/RALocation.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,7 @@ public boolean equals(Object obj) {
return false;
}
final RALocation other = (RALocation) obj;
if (this.id != other.id) {
return false;
}
return true;
return this.id == other.id;
}

@Override
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/de/learnlib/ralib/automata/RegisterAutomaton.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import java.util.Set;

import de.learnlib.ralib.automata.output.OutputTransition;
import de.learnlib.ralib.data.RegisterValuation;
import de.learnlib.ralib.data.SymbolicDataValue.Register;
import de.learnlib.ralib.data.VarValuation;
import de.learnlib.ralib.words.PSymbolInstance;
import de.learnlib.ralib.words.ParameterizedSymbol;
import net.automatalib.automaton.DeterministicAutomaton;
Expand All @@ -37,14 +37,14 @@
public abstract class RegisterAutomaton
implements DeterministicAutomaton<RALocation, ParameterizedSymbol, Transition> {

private final VarValuation initialRegisters;
private final RegisterValuation initialRegisters;

public RegisterAutomaton(VarValuation initialRegisters) {
public RegisterAutomaton(RegisterValuation initialRegisters) {
this.initialRegisters = initialRegisters;
}

public RegisterAutomaton() {
this(new VarValuation());
this(new RegisterValuation());
}


Expand Down Expand Up @@ -75,7 +75,7 @@ public String toString() {
/**
* @return the initialRegisters
*/
public VarValuation getInitialRegisters() {
public RegisterValuation getInitialRegisters() {
return initialRegisters;
}

Expand Down
18 changes: 10 additions & 8 deletions src/main/java/de/learnlib/ralib/automata/Transition.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
package de.learnlib.ralib.automata;

import de.learnlib.ralib.data.Constants;
import de.learnlib.ralib.data.ParValuation;
import de.learnlib.ralib.data.VarValuation;
import de.learnlib.ralib.data.ParameterValuation;
import de.learnlib.ralib.data.RegisterValuation;
import de.learnlib.ralib.smt.SMTUtil;
import de.learnlib.ralib.words.ParameterizedSymbol;
import gov.nasa.jpf.constraints.api.Expression;

/**
* Register Automaton transitions have input symbols, and assignments.
Expand All @@ -30,15 +32,15 @@ public class Transition {

protected final ParameterizedSymbol label;

protected final TransitionGuard guard;
protected final Expression<Boolean> guard;

protected final RALocation source;

protected final RALocation destination;

protected final Assignment assignment;

public Transition(ParameterizedSymbol label, TransitionGuard guard,
public Transition(ParameterizedSymbol label, Expression<Boolean> guard,
RALocation source, RALocation destination, Assignment assignment) {
this.label = label;
this.guard = guard;
Expand All @@ -47,11 +49,11 @@ public Transition(ParameterizedSymbol label, TransitionGuard guard,
this.assignment = assignment;
}

public boolean isEnabled(VarValuation registers, ParValuation parameters, Constants consts) {
return guard.isSatisfied(registers, parameters, consts);
public boolean isEnabled(RegisterValuation registers, ParameterValuation parameters, Constants consts) {
return guard.evaluateSMT(SMTUtil.compose(registers, parameters, consts));
}

public VarValuation execute(VarValuation registers, ParValuation parameters, Constants consts) {
public RegisterValuation execute(RegisterValuation registers, ParameterValuation parameters, Constants consts) {
return this.getAssignment().compute(registers, parameters, consts);
}

Expand Down Expand Up @@ -86,7 +88,7 @@ public Assignment getAssignment() {
/**
* @return the guard
*/
public TransitionGuard getGuard() {
public Expression<Boolean> getGuard() {
return guard;
}

Expand Down
74 changes: 0 additions & 74 deletions src/main/java/de/learnlib/ralib/automata/TransitionGuard.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ public interface TransitionSequenceTransformer<I> {
* @param word the input word
* @return the word representing the last passed transition
*/
public Word<I> transformTransitionSequence(Word<I> word);
Word<I> transformTransitionSequence(Word<I> word);

}
Loading
Loading