de.learnlib.eqtests.basic.IncrementalWMethodEQOracle Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of learnlib-basic-eqtests Show documentation
Show all versions of learnlib-basic-eqtests Show documentation
A collection of basic algorithm for approximating equivalence queries
/* Copyright (C) 2014 TU Dortmund
* This file is part of LearnLib, http://www.learnlib.de/.
*
* LearnLib is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 3.0 as published by the Free Software Foundation.
*
* LearnLib is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with LearnLib; if not, see
* .
*/
package de.learnlib.eqtests.basic;
import java.util.Collection;
import java.util.Collections;
import java.util.Objects;
import de.learnlib.api.EquivalenceOracle;
import de.learnlib.api.MembershipOracle;
import de.learnlib.oracles.DefaultQuery;
import net.automatalib.automata.UniversalDeterministicAutomaton;
import net.automatalib.automata.concepts.Output;
import net.automatalib.automata.fsa.DFA;
import net.automatalib.automata.transout.MealyMachine;
import net.automatalib.util.automata.conformance.IncrementalWMethodTestsIterator;
import net.automatalib.words.Alphabet;
import net.automatalib.words.Word;
public class IncrementalWMethodEQOracle & Output, I, D>
implements EquivalenceOracle {
public static class DFAIncrementalWMethodEQOracle
extends IncrementalWMethodEQOracle, I, Boolean>
implements DFAEquivalenceOracle {
public DFAIncrementalWMethodEQOracle(Alphabet alphabet,
MembershipOracle oracle, int maxDepth) {
super(alphabet, oracle, maxDepth);
}
public DFAIncrementalWMethodEQOracle(Alphabet alphabet,
MembershipOracle oracle) {
super(alphabet, oracle);
}
}
public static class MealyIncrementalWMethodEQOracle
extends IncrementalWMethodEQOracle, I, Word>
implements MealyEquivalenceOracle {
public MealyIncrementalWMethodEQOracle(Alphabet alphabet,
MembershipOracle> oracle, int maxDepth) {
super(alphabet, oracle, maxDepth);
}
public MealyIncrementalWMethodEQOracle(Alphabet alphabet,
MembershipOracle> oracle) {
super(alphabet, oracle);
}
}
@SuppressWarnings("unused")
private final Alphabet alphabet;
private final MembershipOracle oracle;
private final IncrementalWMethodTestsIterator incrementalWMethodIt;
private int maxDepth;
public IncrementalWMethodEQOracle(Alphabet alphabet, MembershipOracle oracle) {
this(alphabet, oracle, 1);
}
public IncrementalWMethodEQOracle(Alphabet alphabet, MembershipOracle oracle, int maxDepth) {
this.alphabet = alphabet;
this.oracle = oracle;
this.incrementalWMethodIt = new IncrementalWMethodTestsIterator<>(alphabet);
this.incrementalWMethodIt.setMaxDepth(maxDepth);
this.maxDepth = maxDepth;
}
public int getMaxDepth() {
return maxDepth;
}
public void setMaxDepth(int maxDepth) {
this.maxDepth = maxDepth;
}
@Override
public DefaultQuery findCounterExample(A hypothesis,
Collection extends I> inputs) {
// FIXME: warn about inputs being ignored?
incrementalWMethodIt.update(hypothesis);
while(incrementalWMethodIt.hasNext()) {
Word testCase = incrementalWMethodIt.next();
DefaultQuery query = new DefaultQuery<>(testCase);
oracle.processQueries(Collections.singleton(query));
D hypOut = hypothesis.computeOutput(testCase);
if(!Objects.equals(query.getOutput(), hypOut)) {
// found counterexample
return query;
}
}
return null;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy