public bool Equals(SDA <A, S> other) { var part1 = AllStackSymbols.OrderBy(s => s.ToString()).SequenceEqual(other.AllStackSymbols.OrderBy(s => s.ToString())); var part2 = Transitions.OrderBy(t => t.Id).SequenceEqual(other.Transitions.OrderBy(s => s.Id)); return(part1 && part2); }
public static DeterminisedSDA <A, S> FromSDAInNormalForm(SDA <A, S> sda) { var res = new DeterminisedSDA <A, S>(sda.AllStackSymbols); var origTransitions = sda.Transitions.GroupBy(t => new { t.SymbolIn, t.StackSymbolIn }).ToList(); foreach (var tGroup in origTransitions) { var stackSymbolsSetWritten = tGroup.Select(t => t.StackSymbolsWritten).Select(s => new StackSymbolSequence <S>(s)).ToList().Distinct().ToList(); res.AddTransition(tGroup.Key.SymbolIn, tGroup.Key.StackSymbolIn, new StackSymbolSequenceSet <S>(stackSymbolsSetWritten)); } res.CalculateShortestWordsOfStackSymbols(); return(res); }