Class SampleSetEQOracle<I,​D>

  • Type Parameters:
    I - input symbol type
    D - output domain type
    All Implemented Interfaces:
    EquivalenceOracle<SuffixOutput<I,​D>,​I,​D>

    public class SampleSetEQOracle<I,​D>
    extends Object
    implements EquivalenceOracle<SuffixOutput<I,​D>,​I,​D>
    An equivalence oracle that tests a hypothesis against a fixed set of sample queries.

    Sample queries are provided through one of the add(...) or addAll(...) methods of this class. A query consists of an input word (split into a prefix and a suffix), and an expected output. During an equivalence query, for each of those queries if the respective actual suffix output of the hypothesis equals the expected output.

    This oracle will always repeatedly test queries from the sample set if they turned out to be counterexamples. However, the oracle can be configured to remove queries from the sample set if they did not serve as counterexamples.

    • Constructor Detail

      • SampleSetEQOracle

        public SampleSetEQOracle​(boolean removeUnsuccessful)
        Constructor. Initializes the oracle with an empty sample set.
        Parameters:
        removeUnsuccessful - if set to true, queries will be removed from the sample set if they did not reveal a counterexample. Otherwise, all queries from the sample set will always be tested upon each invocation of findCounterExample(SuffixOutput, Collection).
    • Method Detail

      • add

        public SampleSetEQOracle<I,​D> add​(Word<I> input,
                                                D expectedOutput)
        Adds a query word along with its expected output to the sample set.
        Parameters:
        input - the input word
        expectedOutput - the expected output for this word
        Returns:
        this, to enable chained add or addAll calls
      • addAll

        @SafeVarargs
        public final SampleSetEQOracle<I,​D> addAll​(MembershipOracle<I,​D> oracle,
                                                         Word<I>... words)
        Adds several query words to the sample set. The expected output is determined by means of the specified membership oracle.
        Parameters:
        oracle - the membership oracle used to determine expected outputs
        words - the words to be added to the sample set
        Returns:
        this, to enable chained add or addAll calls
      • addAll

        public SampleSetEQOracle<I,​D> addAll​(MembershipOracle<I,​D> oracle,
                                                   Collection<? extends Word<I>> words)
        Adds words to the sample set. The expected output is determined by means of the specified membership oracle.
        Parameters:
        oracle - the membership oracle used to determine the expected output
        words - the words to add
        Returns:
        this, to enable chained add or addAll calls
      • addAll

        @SafeVarargs
        public final SampleSetEQOracle<I,​D> addAll​(DefaultQuery<I,​D>... newTestQueries)
        Adds queries to the sample set. These must be DefaultQuerys, which allow for retrieving the corresponding (expected) output.
        Parameters:
        newTestQueries - the queries to add to the sample set
        Returns:
        this, to enable chained add or addAll calls
      • addAll

        public SampleSetEQOracle<I,​D> addAll​(Collection<? extends DefaultQuery<I,​D>> newTestQueries)
        Adds queries to the sample set. These must be DefaultQuerys, which allow for retrieving the corresponding (expected) output.
        Parameters:
        newTestQueries - the queries to add to the sample set
        Returns:
        this, to enable chained add or addAll calls
      • findCounterExample

        public @Nullable DefaultQuery<I,​D> findCounterExample​(SuffixOutput<I,​D> hypothesis,
                                                                    Collection<? extends I> inputs)
        Description copied from interface: EquivalenceOracle
        Searches for a counterexample disproving the subjected hypothesis. A counterexample is query which, when performed on the SUL, yields a different output than what was predicted by the hypothesis. If no counterexample could be found (this does not necessarily mean that none exists), null is returned.
        Specified by:
        findCounterExample in interface EquivalenceOracle<SuffixOutput<I,​D>,​I,​D>
        Parameters:
        hypothesis - the conjecture
        inputs - the set of inputs to consider, this should be a subset of the input alphabet of the provided hypothesis
        Returns:
        a query exposing different behavior, or null if no counterexample could be found. In case a non-null value is returned, the output field in the DefaultQuery contains the SUL output for the respective query.