• 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

71.43
/oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/DisproveFirstOracle.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.PropertyOracle;
27
import de.learnlib.api.oracle.PropertyOracle.DFAPropertyOracle;
28
import de.learnlib.api.oracle.PropertyOracle.MealyPropertyOracle;
29
import de.learnlib.api.query.DefaultQuery;
30
import de.learnlib.buildtool.refinement.annotation.GenerateRefinement;
31
import de.learnlib.buildtool.refinement.annotation.Generic;
32
import de.learnlib.buildtool.refinement.annotation.Interface;
33
import de.learnlib.buildtool.refinement.annotation.Map;
34
import net.automatalib.automata.concepts.Output;
35
import net.automatalib.automata.fsa.DFA;
36
import net.automatalib.automata.transducers.MealyMachine;
37
import net.automatalib.words.Word;
38
import org.checkerframework.checker.nullness.qual.Nullable;
39

40
/**
41
 * The strategy of this black-box oracle is to first try to disprove all properties before finding a counter example to
42
 * the given hypothesis.
43
 * <p>
44
 * One may favor this implementation if refining a hypothesis is expensive compared to trying to disprove properties.
45
 *
46
 * @param <A>
47
 *         the automaton type
48
 * @param <I>
49
 *         the input type
50
 * @param <D>
51
 *         the output type
52
 *
53
 * @see CExFirstOracle
54
 */
55
@GenerateRefinement(name = "DFADisproveFirstOracle",
2✔
56
                    generics = "I",
57
                    parentGenerics = {@Generic(clazz = DFA.class, generics = {"?", "I"}),
58
                                      @Generic("I"),
59
                                      @Generic(clazz = Boolean.class)},
60
                    parameterMapping = @Map(from = PropertyOracle.class,
61
                                            to = DFAPropertyOracle.class,
62
                                            withGenerics = {"I", "?"}),
63
                    interfaces = @Interface(clazz = DFABlackBoxOracle.class, generics = "I"))
64
@GenerateRefinement(name = "MealyDisproveFirstOracle",
65
                    generics = {"I", "O"},
66
                    parentGenerics = {@Generic(clazz = MealyMachine.class, generics = {"?", "I", "?", "O"}),
67
                                      @Generic("I"),
68
                                      @Generic(clazz = Word.class, generics = "O")},
69
                    parameterMapping = @Map(from = PropertyOracle.class,
70
                                            to = MealyPropertyOracle.class,
71
                                            withGenerics = {"I", "O", "?"}),
72
                    interfaces = @Interface(clazz = MealyBlackBoxOracle.class, generics = {"I", "O"}))
73
public class DisproveFirstOracle<A extends Output<I, D>, I, D> implements BlackBoxOracle<A, I, D> {
74

75
    private final List<PropertyOracle<I, ? super A, ?, D>> propertyOracles;
76

77
    public DisproveFirstOracle() {
78
        this(Collections.emptyList());
×
79
    }
×
80

81
    public DisproveFirstOracle(PropertyOracle<I, ? super A, ?, D> propertyOracle) {
82
        this(Collections.singleton(propertyOracle));
×
83
    }
×
84

85
    public DisproveFirstOracle(Collection<? extends PropertyOracle<I, ? super A, ?, D>> propertyOracles) {
2✔
86
        this.propertyOracles = new ArrayList<>(propertyOracles);
2✔
87
    }
2✔
88

89
    @Override
90
    public List<PropertyOracle<I, ? super A, ?, D>> getPropertyOracles() {
91
        return propertyOracles;
2✔
92
    }
93

94
    @Override
95
    public @Nullable DefaultQuery<I, D> findCounterExample(A hypothesis, Collection<? extends I> inputs) {
96
        for (PropertyOracle<I, ? super A, ?, D> po : propertyOracles) {
2✔
97
            if (!po.isDisproved()) {
2✔
98
                po.disprove(hypothesis, inputs);
2✔
99
            }
100
        }
2✔
101

102
        for (PropertyOracle<I, ? super A, ?, D> po : propertyOracles) {
2✔
103
            if (!po.isDisproved()) {
2✔
104
                final DefaultQuery<I, D> ce = po.doFindCounterExample(hypothesis, inputs);
2✔
105
                if (ce != null) {
2✔
106
                    assert isCounterExample(hypothesis, ce.getInput(), ce.getOutput());
2✔
107
                    return ce;
2✔
108
                }
109
            }
110
        }
×
111

112
        return null;
×
113
    }
114
}
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