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

LearnLib / automatalib / 19995144613

06 Dec 2025 10:24PM UTC coverage: 92.834% (+0.04%) from 92.796%
19995144613

push

github

mtf90
simplify procedural implementations

since the output semantics now better handle partial systems, get rid of explicit sink management

42 of 45 new or added lines in 5 files covered. (93.33%)

4 existing lines in 4 files now uncovered.

17191 of 18518 relevant lines covered (92.83%)

1.72 hits per line

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

95.0
/api/src/main/java/net/automatalib/automaton/transducer/SubsequentialTransducer.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.transducer;
17

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

21
import net.automatalib.automaton.UniversalDeterministicAutomaton;
22
import net.automatalib.automaton.concept.DeterministicSuffixOutputAutomaton;
23
import net.automatalib.automaton.fsa.DFA;
24
import net.automatalib.automaton.graph.TransitionEdge;
25
import net.automatalib.automaton.graph.TransitionEdge.Property;
26
import net.automatalib.automaton.graph.UniversalAutomatonGraphView;
27
import net.automatalib.automaton.visualization.SSTVisualizationHelper;
28
import net.automatalib.graph.UniversalGraph;
29
import net.automatalib.ts.concept.DeterministicOutputTS;
30
import net.automatalib.ts.output.DeterministicTraceableTS;
31
import net.automatalib.visualization.VisualizationHelper;
32
import net.automatalib.word.Word;
33

34
/**
35
 * A subsequential transducer (or SST) is an {@link DeterministicOutputTS} whose state and transition properties are
36
 * output-{@link Word words}. Upon parsing a sequence of input symbols, each transition emits a {@link Word sequence} of
37
 * output symbols. After all inputs have been parsed, the output of the reached state will be emitted as well.
38
 * <p>
39
 * <b>Implementation detail:</b>
40
 * There exist definitions of SSTs that associate each state with an additional notion of 'acceptance' in order to
41
 * reject certain transductions. This implementation/interface denotes prefix-closed transductions, i.e. all states are
42
 * accepting. If you would like to filter out certain transduction you may use a supplementary {@link DFA} for this
43
 * decision problem.
44
 *
45
 * @param <S>
46
 *         state type
47
 * @param <I>
48
 *         input symbol type
49
 * @param <T>
50
 *         transition type
51
 * @param <O>
52
 *         output symbol type
53
 */
54
public interface SubsequentialTransducer<S, I, T, O> extends DeterministicTraceableTS<S, I, T, O>,
55
                                                             DeterministicSuffixOutputAutomaton<S, I, T, Word<O>>,
56
                                                             UniversalDeterministicAutomaton<S, I, T, Word<O>, Word<O>> {
57

58
    @Override
59
    default boolean trace(S state, Iterable<? extends I> input, List<? super O> output) {
60
        S iter = state;
1✔
61

62
        for (I sym : input) {
1✔
63
            T trans = getTransition(iter, sym);
1✔
64
            if (trans == null) {
1✔
65
                return false;
1✔
66
            }
67
            final Word<O> out = getTransitionProperty(trans);
1✔
68
            if (out != null) {
1✔
69
                output.addAll(out.asList());
1✔
70
            }
71
            iter = getSuccessor(trans);
1✔
72
        }
1✔
73

74
        if (iter == null) {
1✔
UNCOV
75
            return false;
×
76
        } else {
77
            final Word<O> out = getStateProperty(iter);
1✔
78
            if (out != null) {
1✔
79
                output.addAll(out.asList());
1✔
80
            }
81
        }
82

83
        return true;
1✔
84
    }
85

86
    @Override
87
    default UniversalGraph<S, TransitionEdge<I, T>, Word<O>, Property<I, Word<O>>> transitionGraphView(Collection<? extends I> inputs) {
88
        return new SSTGraphView<>(this, inputs);
1✔
89
    }
90

91
    class SSTGraphView<S, I, T, O, A extends SubsequentialTransducer<S, I, T, O>>
92
            extends UniversalAutomatonGraphView<S, I, T, Word<O>, Word<O>, A> {
93

94
        public SSTGraphView(A automaton, Collection<? extends I> inputs) {
95
            super(automaton, inputs);
1✔
96
        }
1✔
97

98
        @Override
99
        public VisualizationHelper<S, TransitionEdge<I, T>> getVisualizationHelper() {
100
            return new SSTVisualizationHelper<>(automaton);
1✔
101
        }
102
    }
103
}
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