• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

LearnLib / learnlib / 6433387082

06 Oct 2023 03:10PM UTC coverage: 92.296% (-0.007%) from 92.303%
6433387082

push

github

mtf90
update Falk's developer id

11573 of 12539 relevant lines covered (92.3%)

1.67 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.89
/api/src/main/java/de/learnlib/api/oracle/MembershipOracle.java
1
/* Copyright (C) 2013-2023 TU Dortmund
2
 * This file is part of LearnLib, http://www.learnlib.de/.
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *     http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
package de.learnlib.api.oracle;
17

18
import java.util.Collection;
19
import java.util.Collections;
20

21
import de.learnlib.api.oracle.parallelism.BatchProcessor;
22
import de.learnlib.api.query.DefaultQuery;
23
import de.learnlib.api.query.Query;
24
import net.automatalib.words.Word;
25

26
/**
27
 * Membership oracle interface. A membership oracle provides an elementary abstraction to a System Under Learning (SUL),
28
 * by allowing to pose {@link Query queries}: A query is a sequence of input symbols (divided into a prefix and a suffix
29
 * part, cf. {@link Query#getPrefix()} and {@link Query#getSuffix()}) in reaction to which the SUL produces a specific
30
 * observable behavior (outputting a word, acceptance/rejection etc.).
31
 *
32
 * @see DefaultQuery
33
 */
34
public interface MembershipOracle<I, D> extends QueryAnswerer<I, D>, BatchProcessor<Query<I, D>> {
35

36
    @Override
37
    default D answerQuery(Word<I> input) {
38
        return answerQuery(Word.epsilon(), input);
1✔
39
    }
40

41
    @Override
42
    default D answerQuery(Word<I> prefix, Word<I> suffix) {
43
        DefaultQuery<I, D> query = new DefaultQuery<>(prefix, suffix);
1✔
44
        processQuery(query);
1✔
45
        return query.getOutput();
1✔
46
    }
47

48
    /**
49
     * Processes a single query. When this method returns, the {@link Query#answer(Object)} method of the supplied
50
     * object will have been called with an argument reflecting the SUL response to the respective query.
51
     * <p>
52
     * The default implementation of this method will simply wrap the provided {@link Query} in a singleton {@link
53
     * Collection} using {@link Collections#singleton(Object)}. Implementations in subclasses should override this
54
     * method to circumvent the Collection object creation, if possible.
55
     *
56
     * @param query
57
     *         the query to process
58
     */
59
    default void processQuery(Query<I, D> query) {
60
        processQueries(Collections.singleton(query));
1✔
61
    }
1✔
62

63
    /**
64
     * Processes the specified collection of queries. When this method returns, each of the contained queries {@link
65
     * Query#answer(Object)} method should have been called with an argument reflecting the SUL response to the
66
     * respective query.
67
     *
68
     * @param queries
69
     *         the queries to process
70
     *
71
     * @see Query#answer(Object)
72
     */
73
    void processQueries(Collection<? extends Query<I, D>> queries);
74

75
    @Override
76
    default MembershipOracle<I, D> asOracle() {
77
        return this;
×
78
    }
79

80
    @Override
81
    default void processBatch(Collection<? extends Query<I, D>> batch) {
82
        processQueries(batch);
1✔
83
    }
1✔
84

85
    interface DFAMembershipOracle<I> extends MembershipOracle<I, Boolean> {}
86

87
    /**
88
     * A specialization of the {@link MembershipOracle} that binds the output domain to {@link Word}s of the specified
89
     * output type. Queries should be answered according to the Mealy output semantics (transition-based). This means an
90
     * input sequence of length {@code n} results in an output word of length {@code n}.
91
     *
92
     * @param <I>
93
     *         input symbol type
94
     * @param <O>
95
     *         output symbol type
96
     */
97
    interface MealyMembershipOracle<I, O> extends MembershipOracle<I, Word<O>> {}
98

99
    interface MooreMembershipOracle<I, O> extends MembershipOracle<I, Word<O>> {}
100

101
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc