Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
This artifact provides various common utility operations for analyzing and manipulating
automata and graphs, such as traversal, minimization and copying.
/* Copyright (C) 2013-2019 TU Dortmund
* This file is part of AutomataLib, http://www.automatalib.net/.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.automatalib.util.automata.equivalence;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Queue;
import javax.annotation.ParametersAreNonnullByDefault;
import com.google.common.collect.AbstractIterator;
import net.automatalib.automata.UniversalDeterministicAutomaton;
import net.automatalib.util.automata.Automata;
import net.automatalib.words.Word;
/**
* Operations for calculating characterizing sets.
*
* A characterizing set for a whole automaton is a set W of words such that for every two states
* s1 and s2, there exists a word w ∈ W such that w exposes a
* difference between s1 and s2 (i.e., either covers a transition with differing
* property (or not defined in only one case), or reaching a successor state with differing properties), or there exists
* no such word at all.
*
* A characterizing set for a single state s is a set W of words such that for every state t, there
* exists a word w ∈ W such that w exposes a difference between s and t, or there
* exists no such word at all.
*
* @author Malte Isberner
*/
@ParametersAreNonnullByDefault
public final class CharacterizingSets {
private CharacterizingSets() {
}
/**
* Computes a characterizing set for the given automaton.
*
* @param automaton
* the automaton for which to determine the characterizing set.
* @param inputs
* the input alphabets to consider
* @param result
* the collection in which to store the characterizing words
*/
public static void findCharacterizingSet(UniversalDeterministicAutomaton automaton,
Collection extends I> inputs,
Collection super Word> result) {
findIncrementalCharacterizingSet(automaton, inputs, Collections.emptyList(), result);
}
/**
* Computes a characterizing set for a specified state in the given automaton.
*
* @param automaton
* the automaton containing the state
* @param inputs
* the input alphabets to consider
* @param state
* the state for which to determine the characterizing set
* @param result
* the collection in which to store the characterizing words
*/
public static void findCharacterizingSet(UniversalDeterministicAutomaton automaton,
Collection extends I> inputs,
S state,
Collection super Word> result) {
Object prop = automaton.getStateProperty(state);
List currentBlock = new ArrayList<>();
boolean multipleStateProps = false;
for (S s : automaton) {
if (Objects.equals(s, state)) {
continue;
}
Object sProp = automaton.getStateProperty(s);
if (!Objects.equals(sProp, prop)) {
multipleStateProps = true;
} else {
currentBlock.add(s);
}
}
if (multipleStateProps) {
result.add(Word.epsilon());
}
while (!currentBlock.isEmpty()) {
Iterator it = currentBlock.iterator();
Word suffix = null;
while (it.hasNext() && suffix == null) {
S s = it.next();
suffix = Automata.findSeparatingWord(automaton, state, s, inputs);
}
if (suffix == null) {
return;
}
result.add(suffix);
List