de.learnlib.api.oracle.LassoOracle Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of learnlib-api Show documentation
Show all versions of learnlib-api Show documentation
Infrastructure and core interfaces of LearnLib
/* Copyright (C) 2013-2020 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.api.oracle;
import java.util.Collection;
import de.learnlib.api.query.DefaultQuery;
import de.learnlib.api.query.OmegaQuery;
import net.automatalib.automata.concepts.Output;
import net.automatalib.modelchecking.Lasso;
import net.automatalib.modelchecking.Lasso.DFALasso;
import net.automatalib.modelchecking.Lasso.MealyLasso;
import net.automatalib.words.Word;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
* An automaton oracle for lassos.
*
* @see AutomatonOracle
*
* @param the type of Lasso.
* @param the type of input.
* @param the type of output.
*
* @author Jeroen Meijer
*/
public interface LassoOracle, I, D> {
/**
* Processes the given omega query.
*
* @param prefix
* the prefix
* @param loop
* the loop
* @param repeat
* the maximum number of times the loop may be repeated
*
* @return the omega query.
*/
OmegaQuery processInput(Word prefix, Word loop, int repeat);
/**
* Returns whether the given input and output is a counter example for the given hypothesis.
*
* @param hypothesis
* the hypothesis
* @param inputs
* the input sequence
* @param output
* the output corresponding to the input.
*
* @return whether the given input and output is a counter example.
*/
boolean isCounterExample(Output hypothesis, Iterable extends I> inputs, D output);
default @Nullable DefaultQuery findCounterExample(L hypothesis, Collection extends I> inputs) {
final Word prefix = hypothesis.getPrefix();
final Word loop = hypothesis.getLoop();
final int repeat = hypothesis.getUnfolds();
final OmegaQuery omegaQuery = processInput(prefix, loop, repeat);
if (omegaQuery.isUltimatelyPeriodic()) {
@SuppressWarnings("nullness") // when we are a counterexample, the output is valid
final DefaultQuery ce = omegaQuery.asDefaultQuery();
if (isCounterExample(hypothesis.getAutomaton(), ce.getInput(), ce.getOutput())) {
return ce;
}
}
return null;
}
interface DFALassoOracle extends LassoOracle, I, Boolean> {}
interface MealyLassoOracle extends LassoOracle, I, Word> {}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy