Skip to content

Commit 0d9a134

Browse files
committed
some more cleanups
* Simplify the `initialSuffixes()` and `initialPrefixes()` methods in the LStar algorithm by finalizing them in the parent class (they can be set via constructor) * Remove the `isOmegaCounterExample` method on `LassOracle`s which had very limited possibilities to make that decision (a boolean parameter). Instead this problem should be addressed in the `findCounterexample`/`processInput` methods directly.
1 parent 189c196 commit 0d9a134

File tree

9 files changed

+10
-58
lines changed

9 files changed

+10
-58
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
1717
* The `ParallelOracleBuilders` factory now offers builder methods for `SUL`s, `ObservableSUL`s, `StateLocalInputSUL`s, `MembershipOracles`s and `OmegaMembershipOracle`s to allow an easy (and correct) construction of parallel setups given one of the mentioned implementations.
1818
* Refactored the following packages/classes:
1919
* `de.learnlib.oracle.parallelism.ParallelOracleInterruptedException` -> `de.learnlib.api.oracle.parallelism.BatchInterruptedException`
20+
* The `initialPrefixes` and `initialSuffixes` methods of `AbstractExtensibleAutomatonLStar` are now `final` since these values can be provided via the constructor of the class. This allows one to simplify sub-classes.
2021

2122
### Removed
2223

2324
* Removed the `learnlib.queries.parallel.threshold` property. Learning setups that want to use parallelism now need to explicitly setup parallel oracles.
2425
* Removed `MQUtil#answerQueries{Auto,Parallel}` and `MQUtil#answerOmegaQueries{Auto,Parallel}`)
26+
* `LassoOracle#isOmegaCounterExample(boolean)` has been removed. This decision can be directly integrated into the `#findCounterExample` method which has more information available.
2527
* Updated to [AutomataLib 0.10.0](https://github.com/LearnLib/automatalib/releases/tag/automatalib-0.10.0)
2628

2729
### Fixed

algorithms/active/lstar/src/main/java/de/learnlib/algorithms/lstar/AbstractExtensibleAutomatonLStar.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ protected void refineHypothesisInternal(DefaultQuery<I, D> ceQuery) {
5959
}
6060

6161
@Override
62-
protected List<Word<I>> initialPrefixes() {
62+
protected final List<Word<I>> initialPrefixes() {
6363
return initialPrefixes;
6464
}
6565

6666
@Override
67-
protected List<Word<I>> initialSuffixes() {
67+
protected final List<Word<I>> initialSuffixes() {
6868
return initialSuffixes;
6969
}
7070

algorithms/active/lstar/src/main/java/de/learnlib/algorithms/lstar/ce/ObservationTableCEXHandlers.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ public <RI, RD> List<List<Row<RI>>> handleCounterexample(DefaultQuery<RI, RD> ce
4545
}
4646

4747
@Override
48-
public String toString() {
49-
return "ClassicLStar";
48+
public boolean needsConsistencyCheck() {
49+
return true;
5050
}
5151

5252
@Override
53-
public boolean needsConsistencyCheck() {
54-
return true;
53+
public String toString() {
54+
return "ClassicLStar";
5555
}
5656

5757
};

algorithms/active/lstar/src/main/java/de/learnlib/algorithms/lstar/dfa/ExtensibleLStarDFA.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,6 @@ public ExtensibleLStarDFA(Alphabet<I> alphabet,
7777
closingStrategy);
7878
}
7979

80-
@Override
81-
protected List<Word<I>> initialSuffixes() {
82-
return Collections.singletonList(Word.epsilon());
83-
}
84-
8580
@Override
8681
protected DFA<?, I> exposeInternalHypothesis() {
8782
return internalHyp;

algorithms/active/lstar/src/main/java/de/learnlib/algorithms/lstar/mealy/ClassicLStarMealy.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*/
1616
package de.learnlib.algorithms.lstar.mealy;
1717

18-
import java.util.ArrayList;
1918
import java.util.Collections;
2019
import java.util.List;
2120

@@ -99,16 +98,6 @@ public static <I, O> ClassicLStarMealy<I, O> createForWordOracle(Alphabet<I> alp
9998
return new ClassicLStarMealy<>(alphabet, MealyUtil.wrapWordOracle(oracle), cexHandler, closingStrategy);
10099
}
101100

102-
@Override
103-
protected List<Word<I>> initialSuffixes() {
104-
List<Word<I>> suffixes = new ArrayList<>(alphabet.size());
105-
for (int i = 0; i < alphabet.size(); i++) {
106-
I sym = alphabet.getSymbol(i);
107-
suffixes.add(Word.fromLetter(sym));
108-
}
109-
return suffixes;
110-
}
111-
112101
@Override
113102
protected MealyMachine<?, I, ?, O> exposeInternalHypothesis() {
114103
return internalHyp;
@@ -141,8 +130,6 @@ protected O transitionProperty(ObservationTable<I, @Nullable O> table, Row<I> st
141130
}
142131
return wordOut.lastSymbol();
143132
}
144-
145133
};
146134
}
147-
148135
}

algorithms/active/lstar/src/main/java/de/learnlib/algorithms/lstar/mealy/ExtensibleLStarMealy.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,6 @@ public ExtensibleLStarMealy(Alphabet<I> alphabet,
6565
closingStrategy);
6666
}
6767

68-
@Override
69-
protected List<Word<I>> initialSuffixes() {
70-
return initialSuffixes;
71-
}
72-
7368
@Override
7469
public CompactMealy<I, O> getHypothesisModel() {
7570
return internalHyp;

api/src/main/java/de/learnlib/api/oracle/LassoEmptinessOracle.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,6 @@
3333
*/
3434
public interface LassoEmptinessOracle<L extends Lasso<I, D>, I, D> extends EmptinessOracle<L, I, D> {
3535

36-
/**
37-
* Return that when a lasso is ultimately periodic, it could serve as a counter example.
38-
*
39-
* @param isUltimatelyPeriodic
40-
* whether the lasso is ultimately periodic
41-
*
42-
* @return true when a lasso is ultimately periodic, false otherwise.
43-
*/
44-
default boolean isOmegaCounterExample(boolean isUltimatelyPeriodic) {
45-
return isUltimatelyPeriodic;
46-
}
47-
4836
interface DFALassoEmptinessOracle<I> extends LassoEmptinessOracle<DFALasso<I>, I, Boolean> {}
4937

5038
interface MealyLassoEmptinessOracle<I, O> extends LassoEmptinessOracle<MealyLasso<I, O>, I, Word<O>> {}

api/src/main/java/de/learnlib/api/oracle/LassoOracle.java

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,25 +67,15 @@ public interface LassoOracle<L extends Lasso<I, D>, I, D> {
6767
*/
6868
boolean isCounterExample(Output<I, D> hypothesis, Iterable<? extends I> inputs, D output);
6969

70-
/**
71-
* Returns whether a lasso that is ultimately periodic could serve as a counter example.
72-
*
73-
* @param isUltimatelyPeriodic
74-
* whether the lasso is ultimately periodic
75-
*
76-
* @return true when lasso that is ultimately periodic could serve as a counter example, false otherwise.
77-
*/
78-
boolean isOmegaCounterExample(boolean isUltimatelyPeriodic);
79-
8070
default @Nullable DefaultQuery<I, D> findCounterExample(L hypothesis, Collection<? extends I> inputs) {
8171
final Word<I> prefix = hypothesis.getPrefix();
8272
final Word<I> loop = hypothesis.getLoop();
8373
final int repeat = hypothesis.getUnfolds();
8474

8575
final OmegaQuery<I, D> omegaQuery = processInput(prefix, loop, repeat);
8676

87-
if (isOmegaCounterExample(omegaQuery.isUltimatelyPeriodic())) {
88-
@SuppressWarnings("assignment.type.incompatible") // when we are a counterexample, the output is valid
77+
if (omegaQuery.isUltimatelyPeriodic()) {
78+
@SuppressWarnings("nullness") // when we are a counterexample, the output is valid
8979
final DefaultQuery<I, D> ce = omegaQuery.asDefaultQuery();
9080

9181
if (isCounterExample(hypothesis.getAutomaton(), ce.getInput(), ce.getOutput())) {

oracles/emptiness-oracles/src/main/java/de/learnlib/oracle/emptiness/LassoEmptinessOracleImpl.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,4 @@ public boolean isCounterExample(Output<I, D> hypothesis, Iterable<? extends I> i
9494
public @Nullable DefaultQuery<I, D> findCounterExample(L hypothesis, Collection<? extends I> inputs) {
9595
return LassoOracle.super.findCounterExample(hypothesis, inputs);
9696
}
97-
98-
@Override
99-
public boolean isOmegaCounterExample(boolean isUltimatelyPeriodic) {
100-
return LassoEmptinessOracle.super.isOmegaCounterExample(isUltimatelyPeriodic);
101-
}
10297
}

0 commit comments

Comments
 (0)