/*-
 * APT - Analysis of Petri Nets and labeled Transition systems
 * Copyright (C) 2012-2013  Members of the project group APT
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

package uniol.apt.analysis.language;

import java.util.List;

import uniol.apt.adt.ts.TransitionSystem;
import uniol.apt.adt.automaton.FiniteAutomaton;

import static uniol.apt.adt.automaton.FiniteAutomatonUtility.*;

/**
 * Check if two labelled transition systems accept the same prefix language.
 * @author Uli Schlachter
 */
public class LanguageEquivalence {
	/**
	 * No, you should not create instances of this class.
	 */
	private LanguageEquivalence() {
	}

	/**
	 * Check if two labelled transition systems accept the same language.
	 * @param lts1 The first LTS.
	 * @param lts2 The second LTS.
	 * @return Either null or a word that is only generated by one of the LTS.
	 */
	public static Word checkLanguageEquivalence(TransitionSystem lts1, TransitionSystem lts2) {
		FiniteAutomaton automaton1 = fromPrefixLanguageLTS(lts1);
		FiniteAutomaton automaton2 = fromPrefixLanguageLTS(lts2);

		List<String> wordDifference = findWordDifference(automaton1, automaton2);
		if (wordDifference == null)
			return null;
		return new Word(wordDifference);
	}
}

// vim: ft=java:noet:sw=8:sts=8:ts=8:tw=120
