• 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

57.14
/commons/counterexamples/src/main/java/de/learnlib/counterexamples/LocalSuffixFinders.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.counterexamples;
17

18
import de.learnlib.acex.analyzers.AcexAnalyzers;
19
import de.learnlib.api.AccessSequenceTransformer;
20
import de.learnlib.api.oracle.MembershipOracle;
21
import de.learnlib.api.query.Query;
22
import net.automatalib.automata.concepts.SuffixOutput;
23
import org.checkerframework.checker.nullness.qual.Nullable;
24

25
/**
26
 * A collection of suffix-based local counterexample analyzers.
27
 *
28
 * @see LocalSuffixFinder
29
 */
30
public final class LocalSuffixFinders {
31

32
    /**
33
     * Searches for a distinguishing suffixes by checking for counterexample yielding access sequence transformations in
34
     * linear ascending order.
35
     *
36
     * @see #findLinear(Query, AccessSequenceTransformer, SuffixOutput, MembershipOracle)
37
     */
38
    public static final LocalSuffixFinder<@Nullable Object, @Nullable Object> FIND_LINEAR =
1✔
39
            new AcexLocalSuffixFinder(AcexAnalyzers.LINEAR_FWD, true, "FindLinear");
40

41
    /**
42
     * Searches for a distinguishing suffixes by checking for counterexample yielding access sequence transformations in
43
     * linear descending order.
44
     *
45
     * @see #findLinearReverse(Query, AccessSequenceTransformer, SuffixOutput, MembershipOracle)
46
     */
47
    public static final LocalSuffixFinder<@Nullable Object, @Nullable Object> FIND_LINEAR_REVERSE =
1✔
48
            new AcexLocalSuffixFinder(AcexAnalyzers.LINEAR_BWD, true, "FindLinear-Reverse");
49

50
    /**
51
     * Searches for a distinguishing suffixes by checking for counterexample yielding access sequence transformations
52
     * using a binary search, as proposed by Rivest &amp; Schapire.
53
     *
54
     * @see #findRivestSchapire(Query, AccessSequenceTransformer, SuffixOutput, MembershipOracle)
55
     */
56
    public static final LocalSuffixFinder<@Nullable Object, @Nullable Object> RIVEST_SCHAPIRE =
1✔
57
            new AcexLocalSuffixFinder(AcexAnalyzers.BINARY_SEARCH_BWD, true, "RivestSchapire");
58

59
    private LocalSuffixFinders() {
60
        // prevent instantiation
61
    }
62

63
    /**
64
     * Searches for a distinguishing suffixes by checking for counterexample yielding access sequence transformations in
65
     * linear ascending order.
66
     *
67
     * @param ceQuery
68
     *         the initial counterexample query
69
     * @param asTransformer
70
     *         the access sequence transformer
71
     * @param hypOutput
72
     *         interface to the hypothesis output, for checking whether the oracle output contradicts the hypothesis
73
     * @param oracle
74
     *         interface to the SUL
75
     *
76
     * @return the index of the respective suffix, or {@code -1} if no counterexample could be found
77
     *
78
     * @see LocalSuffixFinder
79
     */
80
    public static <I, D> int findLinear(Query<I, D> ceQuery,
81
                                        AccessSequenceTransformer<I> asTransformer,
82
                                        SuffixOutput<I, D> hypOutput,
83
                                        MembershipOracle<I, D> oracle) {
84

85
        return AcexLocalSuffixFinder.findSuffixIndex(AcexAnalyzers.LINEAR_FWD,
×
86
                                                     true,
87
                                                     ceQuery,
88
                                                     asTransformer,
89
                                                     hypOutput,
90
                                                     oracle);
91
    }
92

93
    /**
94
     * Searches for a distinguishing suffixes by checking for counterexample yielding access sequence transformations in
95
     * linear descending order.
96
     *
97
     * @param ceQuery
98
     *         the initial counterexample query
99
     * @param asTransformer
100
     *         the access sequence transformer
101
     * @param hypOutput
102
     *         interface to the hypothesis output, for checking whether the oracle output contradicts the hypothesis
103
     * @param oracle
104
     *         interface to the SUL
105
     *
106
     * @return the index of the respective suffix, or {@code -1} if no counterexample could be found
107
     *
108
     * @see LocalSuffixFinder
109
     */
110
    public static <I, D> int findLinearReverse(Query<I, D> ceQuery,
111
                                               AccessSequenceTransformer<I> asTransformer,
112
                                               SuffixOutput<I, D> hypOutput,
113
                                               MembershipOracle<I, D> oracle) {
114

115
        return AcexLocalSuffixFinder.findSuffixIndex(AcexAnalyzers.LINEAR_BWD,
×
116
                                                     true,
117
                                                     ceQuery,
118
                                                     asTransformer,
119
                                                     hypOutput,
120
                                                     oracle);
121
    }
122

123
    /**
124
     * Searches for a distinguishing suffixes by checking for counterexample yielding access sequence transformations
125
     * using a binary search, as proposed by Rivest &amp; Schapire.
126
     *
127
     * @param ceQuery
128
     *         the initial counterexample query
129
     * @param asTransformer
130
     *         the access sequence transformer
131
     * @param hypOutput
132
     *         interface to the hypothesis output, for checking whether the oracle output contradicts the hypothesis
133
     * @param oracle
134
     *         interface to the SUL
135
     *
136
     * @return the index of the respective suffix, or {@code -1} if no counterexample could be found
137
     *
138
     * @see LocalSuffixFinder
139
     */
140
    public static <I, D> int findRivestSchapire(Query<I, D> ceQuery,
141
                                                AccessSequenceTransformer<I> asTransformer,
142
                                                SuffixOutput<I, D> hypOutput,
143
                                                MembershipOracle<I, D> oracle) {
144

145
        return AcexLocalSuffixFinder.findSuffixIndex(AcexAnalyzers.BINARY_SEARCH_BWD,
×
146
                                                     true,
147
                                                     ceQuery,
148
                                                     asTransformer,
149
                                                     hypOutput,
150
                                                     oracle);
151
    }
152

153
    @SuppressWarnings("unchecked")
154
    public static LocalSuffixFinder<@Nullable Object, @Nullable Object>[] values() {
155
        return new LocalSuffixFinder[] {FIND_LINEAR, FIND_LINEAR_REVERSE, RIVEST_SCHAPIRE};
1✔
156
    }
157
}
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