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

LearnLib / automatalib / 12888641454

21 Jan 2025 02:04PM UTC coverage: 92.01% (+0.06%) from 91.948%
12888641454

push

github

mtf90
small performance fix for CompactDeterministic

1 of 1 new or added line in 1 file covered. (100.0%)

4 existing lines in 1 file now uncovered.

16571 of 18010 relevant lines covered (92.01%)

1.7 hits per line

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

63.64
/api/src/main/java/net/automatalib/automaton/DeterministicAutomaton.java
1
/* Copyright (C) 2013-2025 TU Dortmund University
2
 * This file is part of AutomataLib <https://automatalib.net>.
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 net.automatalib.automaton;
17

18
import java.util.function.IntFunction;
19

20
import net.automatalib.alphabet.Alphabet;
21
import net.automatalib.automaton.abstraction.DeterministicAbstractions;
22
import net.automatalib.automaton.simple.SimpleDeterministicAutomaton;
23
import net.automatalib.ts.DeterministicTransitionSystem;
24
import org.checkerframework.checker.nullness.qual.Nullable;
25

26
/**
27
 * Basic interface for a deterministic automaton. A deterministic automaton is a {@link DeterministicTransitionSystem}
28
 * with a finite number of states.
29
 *
30
 * @param <S>
31
 *         state type
32
 * @param <I>
33
 *         input symbol type
34
 * @param <T>
35
 *         transition type
36
 */
37
public interface DeterministicAutomaton<S, I, T>
38
        extends Automaton<S, I, T>, SimpleDeterministicAutomaton<S, I>, DeterministicTransitionSystem<S, I, T> {
39

40
    @Override
41
    default FullIntAbstraction<T> fullIntAbstraction(Alphabet<I> alphabet) {
42
        return fullIntAbstraction(alphabet.size(), alphabet);
1✔
43
    }
44

45
    @Override
46
    default FullIntAbstraction<T> fullIntAbstraction(int numInputs, IntFunction<? extends I> symMapping) {
47
        return new DeterministicAbstractions.FullIntAbstraction<>(stateIntAbstraction(), numInputs, symMapping);
1✔
48
    }
49

50
    @Override
51
    default StateIntAbstraction<I, T> stateIntAbstraction() {
52
        return new DeterministicAbstractions.StateIntAbstraction<>(this);
1✔
53
    }
54

55
    /**
56
     * Base interface for {@link SimpleDeterministicAutomaton.IntAbstraction integer abstractions} of a {@link
57
     * DeterministicAutomaton}.
58
     *
59
     * @param <T>
60
     *         transition type
61
     */
62
    interface IntAbstraction<T> extends SimpleDeterministicAutomaton.IntAbstraction {
63

64
        /**
65
         * Retrieves the (abstracted) successor of a transition object.
66
         *
67
         * @param transition
68
         *         the transition object
69
         *
70
         * @return the integer representing the successor of the given transition
71
         */
72
        int getIntSuccessor(T transition);
73
    }
74

75
    /**
76
     * Interface for {@link SimpleDeterministicAutomaton.StateIntAbstraction state integer abstractions} of a {@link
77
     * DeterministicAutomaton}.
78
     *
79
     * @param <I>
80
     *         input symbol type
81
     * @param <T>
82
     *         transition type
83
     */
84
    interface StateIntAbstraction<I, T> extends IntAbstraction<T>, SimpleDeterministicAutomaton.StateIntAbstraction<I> {
85

86
        @Override
87
        default int getSuccessor(int state, I input) {
UNCOV
88
            T trans = getTransition(state, input);
×
UNCOV
89
            if (trans == null) {
×
UNCOV
90
                return INVALID_STATE;
×
91
            }
UNCOV
92
            return getIntSuccessor(trans);
×
93
        }
94

95
        /**
96
         * Retrieves the outgoing transition for an (abstracted) source state and input symbol, or returns {@code null}
97
         * if the automaton has no transition for this state and input.
98
         *
99
         * @param state
100
         *         the integer representing the source state
101
         * @param input
102
         *         the input symbol
103
         *
104
         * @return the outgoing transition, or {@code null}
105
         */
106
        @Nullable T getTransition(int state, I input);
107

108
    }
109

110
    /**
111
     * Interface for {@link SimpleDeterministicAutomaton.FullIntAbstraction full integer abstractions} of a {@link
112
     * DeterministicAutomaton}.
113
     *
114
     * @param <T>
115
     *         transition type
116
     */
117
    interface FullIntAbstraction<T> extends IntAbstraction<T>, SimpleDeterministicAutomaton.FullIntAbstraction {
118

119
        @Override
120
        default int getSuccessor(int state, int input) {
121
            T trans = getTransition(state, input);
1✔
122
            if (trans == null) {
1✔
123
                return INVALID_STATE;
1✔
124
            }
125
            return getIntSuccessor(trans);
1✔
126
        }
127

128
        /**
129
         * Retrieves the outgoing transition for an (abstracted) source state and (abstracted) input symbol, or returns
130
         * {@code null} if the automaton has no transition for this state and input.
131
         *
132
         * @param state
133
         *         the integer representing the source state
134
         * @param input
135
         *         the integer representing the input symbol
136
         *
137
         * @return the outgoing transition, or {@code null}
138
         */
139
        @Nullable T getTransition(int state, int input);
140

141
    }
142
}
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