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

LearnLib / learnlib / 6673301747

27 Oct 2023 11:46PM UTC coverage: 91.986% (-1.3%) from 93.327%
6673301747

push

github

mtf90
merge the release and sign-artifacts profiles

10984 of 11941 relevant lines covered (91.99%)

1.72 hits per line

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

62.5
/oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/CExFirstOracle.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.oracle.equivalence;
17

18
import java.util.ArrayList;
19
import java.util.Collection;
20
import java.util.Collections;
21
import java.util.List;
22

23
import de.learnlib.api.oracle.BlackBoxOracle;
24
import de.learnlib.api.oracle.BlackBoxOracle.DFABlackBoxOracle;
25
import de.learnlib.api.oracle.BlackBoxOracle.MealyBlackBoxOracle;
26
import de.learnlib.api.oracle.EquivalenceOracle.DFAEquivalenceOracle;
27
import de.learnlib.api.oracle.EquivalenceOracle.MealyEquivalenceOracle;
28
import de.learnlib.api.oracle.PropertyOracle;
29
import de.learnlib.api.oracle.PropertyOracle.DFAPropertyOracle;
30
import de.learnlib.api.oracle.PropertyOracle.MealyPropertyOracle;
31
import de.learnlib.api.query.DefaultQuery;
32
import de.learnlib.buildtool.refinement.annotation.GenerateRefinement;
33
import de.learnlib.buildtool.refinement.annotation.Generic;
34
import de.learnlib.buildtool.refinement.annotation.Interface;
35
import de.learnlib.buildtool.refinement.annotation.Map;
36
import net.automatalib.automaton.concept.Output;
37
import net.automatalib.automaton.fsa.DFA;
38
import net.automatalib.automaton.transducer.MealyMachine;
39
import net.automatalib.word.Word;
40
import org.checkerframework.checker.nullness.qual.Nullable;
41

42
/**
43
 * The strategy of this black-box oracle is to first try out a property, to see if it can be disproved. If it can not be
44
 * disproved it tries the same property to find a counter example to the hypothesis, before continuing with the next
45
 * property.
46
 * <p>
47
 * This implementation may be used when refining a hypothesis is inexpensive compared to disproving propertyOracles.
48
 *
49
 * @param <A>
50
 *         the automaton type
51
 * @param <I>
52
 *         the input type
53
 * @param <D>
54
 *         the output type
55
 *
56
 * @see DisproveFirstOracle
57
 */
58
@GenerateRefinement(name = "DFACExFirstOracle",
2✔
59
                    generics = "I",
60
                    parentGenerics = {@Generic(clazz = DFA.class, generics = {"?", "I"}),
61
                                      @Generic("I"),
62
                                      @Generic(clazz = Boolean.class)},
63
                    parameterMapping = @Map(from = PropertyOracle.class,
64
                                            to = DFAPropertyOracle.class,
65
                                            withGenerics = {"I", "?"}),
66
                    interfaces = {@Interface(clazz = DFABlackBoxOracle.class, generics = "I"),
67
                                  @Interface(clazz = DFAEquivalenceOracle.class, generics = "I")})
68
@GenerateRefinement(name = "MealyCExFirstOracle",
69
                    generics = {"I", "O"},
70
                    parentGenerics = {@Generic(clazz = MealyMachine.class, generics = {"?", "I", "?", "O"}),
71
                                      @Generic("I"),
72
                                      @Generic(clazz = Word.class, generics = "O")},
73
                    parameterMapping = @Map(from = PropertyOracle.class,
74
                                            to = MealyPropertyOracle.class,
75
                                            withGenerics = {"I", "O", "?"}),
76
                    interfaces = {@Interface(clazz = MealyBlackBoxOracle.class, generics = {"I", "O"}),
77
                                  @Interface(clazz = MealyEquivalenceOracle.class, generics = {"I", "O"})})
78
public class CExFirstOracle<A extends Output<I, D>, I, D> implements BlackBoxOracle<A, I, D> {
79

80
    private final List<PropertyOracle<I, ? super A, ?, D>> propertyOracles;
81

82
    public CExFirstOracle() {
83
        this(Collections.emptySet());
×
84
    }
×
85

86
    public CExFirstOracle(PropertyOracle<I, ? super A, ?, D> propertyOracle) {
87
        this(Collections.singleton(propertyOracle));
×
88
    }
×
89

90
    public CExFirstOracle(Collection<? extends PropertyOracle<I, ? super A, ?, D>> propertyOracles) {
2✔
91
        this.propertyOracles = new ArrayList<>(propertyOracles);
2✔
92
    }
2✔
93

94
    @Override
95
    public List<PropertyOracle<I, ? super A, ?, D>> getPropertyOracles() {
96
        return propertyOracles;
2✔
97
    }
98

99
    @Override
100
    public @Nullable DefaultQuery<I, D> findCounterExample(A hypothesis, Collection<? extends I> inputs) {
101
        for (PropertyOracle<I, ? super A, ?, D> propertyOracle : propertyOracles) {
2✔
102
            final DefaultQuery<I, D> result = propertyOracle.findCounterExample(hypothesis, inputs);
2✔
103
            if (result != null) {
2✔
104
                assert isCounterExample(hypothesis, result.getInput(), result.getOutput());
2✔
105
                return result;
2✔
106
            }
107
        }
×
108

109
        return null;
×
110
    }
111
}
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