Skip to content

Commit

Permalink
Re-integrate the work on procedural systems (#93)
Browse files Browse the repository at this point in the history
* initial import of SBAs and SPMMs

* cleanups / refactorings

* refactorings

* adjust to Automatalib refactorings

* add procedural W-method oracles

* make SBA/SPMM learner add non-continuable symbols lazily

* make counterexample analysis parameterizable

* add adapters for OML and DHC

* Only use DHC for testing

Since the adapter does not provide any functionality, skip redundant adapter class.

* adjust to AutomataLib refactorings

* add documentation

* add some assertions for convenience

* add SBA-based palindrome learning example

* cleanup (mostly docs)

* cleanups + some more tests
  • Loading branch information
mtf90 authored Sep 26, 2023
1 parent 9ea440e commit d077145
Show file tree
Hide file tree
Showing 75 changed files with 4,674 additions and 374 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

* Added the OSTIA passive learning algorithm, thanks to [Aleksander Mendoza-Drosik](https://github.com/aleksander-mendoza).
* Added the OML (optimal-MAT-learner) active learning algorithm, thanks to [Falk Howar](https://github.com/fhowar).
* Added a new learning algorithm for systems of procedural automata (SPAs).
* Added a new learning algorithm for procedural systems (SPAs, SBAs, SPMMs).
* Added Moore versions of the learners `DT`, `TTT`, `LStar`, thanks to [Mohamad Bayram](https://github.com/mohbayram).
* Migrated the AAAR algorithm from the old closed-source LearnLib.

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Kearns & Vazirani | `DFA` `Mealy`
L* (incl. variants) | `DFA` `Mealy` `Moore`
NL* | `NFA`
OML | `DFA` `Mealy`
SPA | `SPA`
Procedural | `SPA` `SBA` `SPMM`
TTT | `DFA` `Mealy` `Moore` `VPDA`


Expand Down
2 changes: 1 addition & 1 deletion algorithms/active/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ limitations under the License.
<module>lstar</module>
<module>nlstar</module>
<module>oml</module>
<module>spa</module>
<module>procedural</module>
<module>ttt</module>
<module>ttt-vpda</module>
</modules>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ limitations under the License.
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>learnlib-spa</artifactId>
<artifactId>learnlib-procedural</artifactId>

<name>LearnLib :: Algorithms :: SPA</name>
<name>LearnLib :: Algorithms :: Procedural</name>
<description>
An active learning algorithm for systems of procedural automata. Contains the base learning framework as well as adapters for orchestrating various regular learners of LearnLib to the context-free learning setup.
Active learning algorithms for procedural systems. Currently, contains learners for SPAs, SBAs, and SPMMs including adapters for integrating various regular learners of LearnLib in the context-free learning setup.
</description>

<dependencies>
Expand All @@ -48,11 +48,11 @@ limitations under the License.
</dependency>
<dependency>
<groupId>de.learnlib</groupId>
<artifactId>learnlib-discrimination-tree</artifactId>
<artifactId>learnlib-datastructure-ot</artifactId>
</dependency>
<dependency>
<groupId>de.learnlib</groupId>
<artifactId>learnlib-datastructure-ot</artifactId>
<artifactId>learnlib-discrimination-tree</artifactId>
</dependency>
<dependency>
<groupId>de.learnlib</groupId>
Expand All @@ -62,6 +62,10 @@ limitations under the License.
<groupId>de.learnlib</groupId>
<artifactId>learnlib-lstar</artifactId>
</dependency>
<dependency>
<groupId>de.learnlib</groupId>
<artifactId>learnlib-oml</artifactId>
</dependency>
<dependency>
<groupId>de.learnlib</groupId>
<artifactId>learnlib-ttt</artifactId>
Expand Down Expand Up @@ -100,12 +104,27 @@ limitations under the License.
<artifactId>buildergen</artifactId>
</dependency>

<dependency>
<groupId> org.checkerframework</groupId>
<artifactId>checker-qual</artifactId>
</dependency>

<!-- test -->
<dependency>
<groupId>de.learnlib</groupId>
<artifactId>learnlib-dhc</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>de.learnlib</groupId>
<artifactId>learnlib-drivers-simulator</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>de.learnlib</groupId>
<artifactId>learnlib-equivalence-oracles</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>de.learnlib.testsupport</groupId>
<artifactId>learnlib-learner-it-support</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/* Copyright (C) 2013-2023 TU Dortmund
* This file is part of LearnLib, http://www.learnlib.de/.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.learnlib.algorithms.procedural;

/**
* A utility class to annotate an input symbol with a (boolean) <i>continuable</i> flag.
*
* @param <I>
* input symbol type
*
* @author frohme
*/
public class SymbolWrapper<I> {

private final I delegate;
private final boolean continuable;

public SymbolWrapper(I delegate, boolean continuable) {
this.delegate = delegate;
this.continuable = continuable;
}

public I getDelegate() {
return delegate;
}

public boolean isContinuable() {
return continuable;
}

@Override
public String toString() {
return delegate + " (" + continuable + ')';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.learnlib.algorithms.spa.adapter;
package de.learnlib.algorithms.procedural.adapter.dfa;

import de.learnlib.algorithms.discriminationtree.dfa.DTLearnerDFA;
import de.learnlib.api.AccessSequenceTransformer;
Expand All @@ -23,16 +23,16 @@
import net.automatalib.words.Word;

/**
* Adapter for using {@link DTLearnerDFA} as a sub-procedural learner.
* Adapter for using {@link DTLearnerDFA} as a procedural learner.
*
* @param <I>
* input symbol type
*
* @author frohme
*/
public class DiscriminationTreeAdapter<I> extends DTLearnerDFA<I> implements AccessSequenceTransformer<I> {
public class DiscriminationTreeAdapterDFA<I> extends DTLearnerDFA<I> implements AccessSequenceTransformer<I> {

public DiscriminationTreeAdapter(Alphabet<I> alphabet, MembershipOracle<I, Boolean> oracle) {
public DiscriminationTreeAdapterDFA(Alphabet<I> alphabet, MembershipOracle<I, Boolean> oracle) {
super(alphabet, oracle, LocalSuffixFinders.RIVEST_SCHAPIRE, true, true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.learnlib.algorithms.spa.adapter;
package de.learnlib.algorithms.procedural.adapter.dfa;

import de.learnlib.acex.analyzers.AcexAnalyzers;
import de.learnlib.algorithms.kv.dfa.KearnsVaziraniDFA;
Expand All @@ -24,16 +24,16 @@
import net.automatalib.words.Word;

/**
* Adapter for using {@link KearnsVaziraniDFA} as a sub-procedural learner.
* Adapter for using {@link KearnsVaziraniDFA} as a procedural learner.
*
* @param <I>
* input symbol type
*
* @author frohme
*/
public class KearnsVaziraniAdapter<I> extends KearnsVaziraniDFA<I> implements AccessSequenceTransformer<I> {
public class KearnsVaziraniAdapterDFA<I> extends KearnsVaziraniDFA<I> implements AccessSequenceTransformer<I> {

public KearnsVaziraniAdapter(Alphabet<I> alphabet, MembershipOracle<I, Boolean> oracle) {
public KearnsVaziraniAdapterDFA(Alphabet<I> alphabet, MembershipOracle<I, Boolean> oracle) {
super(alphabet, oracle, true, AcexAnalyzers.BINARY_SEARCH_FWD);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.learnlib.algorithms.spa.adapter;
package de.learnlib.algorithms.procedural.adapter.dfa;

import java.util.Objects;

Expand All @@ -27,16 +27,16 @@
import net.automatalib.words.Word;

/**
* Adapter for using {@link ClassicLStarDFA} as a sub-procedural learner.
* Adapter for using {@link ClassicLStarDFA} as a procedural learner.
*
* @param <I>
* input symbol type
*
* @author frohme
*/
public class LStarBaseAdapter<I> extends ClassicLStarDFA<I> implements AccessSequenceTransformer<I>, DFALearner<I> {
public class LStarBaseAdapterDFA<I> extends ClassicLStarDFA<I> implements AccessSequenceTransformer<I>, DFALearner<I> {

public LStarBaseAdapter(Alphabet<I> alphabet, MembershipOracle<I, Boolean> oracle) {
public LStarBaseAdapterDFA(Alphabet<I> alphabet, MembershipOracle<I, Boolean> oracle) {
super(alphabet, oracle);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/* Copyright (C) 2013-2023 TU Dortmund
* This file is part of LearnLib, http://www.learnlib.de/.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.learnlib.algorithms.procedural.adapter.dfa;

import java.util.List;

import de.learnlib.algorithms.oml.ttt.dfa.OptimalTTTDFA;
import de.learnlib.algorithms.oml.ttt.pt.PTNode;
import de.learnlib.api.AccessSequenceTransformer;
import de.learnlib.api.oracle.MembershipOracle;
import net.automatalib.words.Alphabet;
import net.automatalib.words.Word;

/**
* Adapter for using {@link OptimalTTTDFA} as a procedural learner.
*
* @param <I>
* input symbol type
*
* @author frohme
*/
public class OptimalTTTAdapterDFA<I> extends OptimalTTTDFA<I> implements AccessSequenceTransformer<I> {

public OptimalTTTAdapterDFA(Alphabet<I> alphabet, MembershipOracle<I, Boolean> oracle) {
super(alphabet, oracle);
}

@Override
public Word<I> transformAccessSequence(Word<I> word) {
final List<PTNode<I, Boolean>> shortPrefixes = super.getState(word).getShortPrefixes();

assert shortPrefixes.size() == 1;

return shortPrefixes.get(0).word();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.learnlib.algorithms.spa.adapter;
package de.learnlib.algorithms.procedural.adapter.dfa;

import java.util.Objects;

Expand All @@ -27,17 +27,17 @@
import net.automatalib.words.Word;

/**
* Adapter for using {@link RivestSchapireDFA} as a sub-procedural learner.
* Adapter for using {@link RivestSchapireDFA} as a procedural learner.
*
* @param <I>
* input symbol type
*
* @author frohme
*/
public class RivestSchapireAdapter<I> extends RivestSchapireDFA<I>
public class RivestSchapireAdapterDFA<I> extends RivestSchapireDFA<I>
implements AccessSequenceTransformer<I>, DFALearner<I> {

public RivestSchapireAdapter(Alphabet<I> alphabet, MembershipOracle<I, Boolean> oracle) {
public RivestSchapireAdapterDFA(Alphabet<I> alphabet, MembershipOracle<I, Boolean> oracle) {
super(alphabet, oracle);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.learnlib.algorithms.spa.adapter;
package de.learnlib.algorithms.procedural.adapter.dfa;

import de.learnlib.acex.analyzers.AcexAnalyzers;
import de.learnlib.algorithms.ttt.base.TTTState;
Expand All @@ -24,16 +24,16 @@
import net.automatalib.words.Word;

/**
* Adapter for using {@link TTTLearnerDFA} as a sub-procedural learner.
* Adapter for using {@link TTTLearnerDFA} as a procedural learner.
*
* @param <I>
* input symbol type
*
* @author frohme
*/
public class TTTAdapter<I> extends TTTLearnerDFA<I> implements AccessSequenceTransformer<I> {
public class TTTAdapterDFA<I> extends TTTLearnerDFA<I> implements AccessSequenceTransformer<I> {

public TTTAdapter(Alphabet<I> alphabet, MembershipOracle<I, Boolean> oracle) {
public TTTAdapterDFA(Alphabet<I> alphabet, MembershipOracle<I, Boolean> oracle) {
super(alphabet, oracle, AcexAnalyzers.BINARY_SEARCH_BWD);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/* Copyright (C) 2013-2023 TU Dortmund
* This file is part of LearnLib, http://www.learnlib.de/.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.learnlib.algorithms.procedural.adapter.mealy;

import de.learnlib.algorithms.discriminationtree.mealy.DTLearnerMealy;
import de.learnlib.api.AccessSequenceTransformer;
import de.learnlib.api.oracle.MembershipOracle;
import de.learnlib.counterexamples.LocalSuffixFinders;
import net.automatalib.words.Alphabet;
import net.automatalib.words.Word;

/**
* Adapter for using {@link DTLearnerMealy} as a procedural learner.
*
* @param <I>
* input symbol type
* @param <O>
* output symbol type
*
* @author frohme
*/
public class DiscriminationTreeAdapterMealy<I, O> extends DTLearnerMealy<I, O> implements AccessSequenceTransformer<I> {

public DiscriminationTreeAdapterMealy(Alphabet<I> alphabet, MembershipOracle<I, Word<O>> oracle) {
super(alphabet, oracle, LocalSuffixFinders.RIVEST_SCHAPIRE, true);
}

@Override
public Word<I> transformAccessSequence(Word<I> word) {
return super.getHypothesisDS().transformAccessSequence(word);
}
}
Loading

0 comments on commit d077145

Please sign in to comment.