Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
AutomatonDiff.h
Go to the documentation of this file.
1
6#pragma once
7
8#include <ostream>
9
10#include <ext/iostream>
11#include <ext/utility>
12
13#include <compare/DiffAux.h>
15
16#include <alib/set>
17#include <alib/list>
18#include <alib/map>
19#include <alib/vector>
20
21#include "automaton/FSM/DFA.h"
22#include "automaton/FSM/NFA.h"
28#include "automaton/TA/DFTA.h"
29#include "automaton/TA/NFTA.h"
30#include "automaton/PDA/NPDA.h"
31#include "automaton/PDA/DPDA.h"
41
42namespace compare {
43
45private:
46 template<class SymbolType, class StateType>
48
49 template<class SymbolType, class StateType>
51
52 template<class SymbolType, class StateType>
54
55 template<class SymbolType, class StateType>
57
58 template<class SymbolType, class StateType>
60
61 template<class SymbolType, class StateType>
63
64 template<class SymbolType, class StateType>
66
67 template<class InputSymbolType, class PushdownStoreSymbolType, class StateType>
69
70 template<class InputSymbolType, class PushdownStoreSymbolType, class StateType>
72
73 template<class SymbolType, class StateType>
75
76 template<class SymbolType, class StateType>
78
79 template<class InputSymbolType, class PushdownStoreSymbolType, class StateType>
81
82 template<class InputSymbolType, class PushdownStoreSymbolType, class StateType>
84
85 template<class InputSymbolType, class PushdownStoreSymbolType, class StateType>
87
88 template<class InputSymbolType, class PushdownStoreSymbolType, class StateType>
90
91 template<class InputSymbolType, class PushdownStoreSymbolType, class StateType>
93
94 template<class InputSymbolType, class PushdownStoreSymbolType, class StateType>
96
97 template<class InputSymbolType, class PushdownStoreSymbolType, class StateType>
99
100 template<class InputSymbolType, class PushdownStoreSymbolType, class StateType>
102
103 template<class SymbolType, class StateType>
105public:
106 template<class T>
107 static void diff(const T & a, const T & b, ext::ostream & out );
108
109 template < class T >
110 static std::string diff ( const T & a, const T & b );
111};
112
113template<class SymbolType, class StateType>
114void AutomatonDiff::printDiff(const automaton::DFA < SymbolType, StateType > & a, const automaton::DFA < SymbolType, StateType > & b, ext::ostream & out ) {
115 out << "AutomataComparer" << std::endl;
116
117 if(a.getFinalStates() != b.getFinalStates()){
118 out << "FinalStates" << std::endl;
119
121 }
122
123 if(a.getInitialState() != b.getInitialState()) {
124 out << "Initial state" << std::endl;
125
126 out << "< " << a.getInitialState() << std::endl;
127 out << "---" << std::endl;
128 out << "> " << b.getInitialState() << std::endl;
129 }
130
131 if(a.getInputAlphabet() != b.getInputAlphabet()) {
132 out << "InputAlphabet" << std::endl;
133
135 }
136
137 if(a.getStates() != b.getStates()) {
138 out << "States" << std::endl;
139
140 DiffAux::setDiff ( out, a.getStates(), b.getStates());
141 }
142
143 if(a.getTransitions() != b.getTransitions()) {
144 out << "Transitions" << std::endl;
145
147 }
148}
149
150template<class SymbolType, class StateType>
152 out << "AutomataComparer" << std::endl;
153
154 if(a.getFinalStates() != b.getFinalStates()){
155 out << "FinalStates" << std::endl;
156
158 }
159
160 if(a.getInitialStates() != b.getInitialStates()) {
161 out << "InitialStates" << std::endl;
162
164 }
165
166 if(a.getInputAlphabet() != b.getInputAlphabet()) {
167 out << "InputAlphabet" << std::endl;
168
170 }
171
172 if(a.getStates() != b.getStates()) {
173 out << "States" << std::endl;
174
175 DiffAux::setDiff ( out, a.getStates(), b.getStates());
176 }
177
178 if(a.getTransitions() != b.getTransitions()) {
179 out << "Transitions" << std::endl;
180
182 }
183}
184
185template<class SymbolType, class StateType>
186void AutomatonDiff::printDiff(const automaton::NFA < SymbolType, StateType > & a, const automaton::NFA < SymbolType, StateType > & b, ext::ostream & out ) {
187 out << "AutomataComparer" << std::endl;
188
189 if(a.getFinalStates() != b.getFinalStates()){
190 out << "FinalStates" << std::endl;
191
193 }
194
195 if(a.getInitialState() != b.getInitialState()) {
196 out << "Initial state" << std::endl;
197
198 out << "< " << a.getInitialState() << std::endl;
199 out << "---" << std::endl;
200 out << "> " << b.getInitialState() << std::endl;
201 }
202
203 if(a.getInputAlphabet() != b.getInputAlphabet()) {
204 out << "InputAlphabet" << std::endl;
205
207 }
208
209 if(a.getStates() != b.getStates()) {
210 out << "States" << std::endl;
211
212 DiffAux::setDiff ( out, a.getStates(), b.getStates());
213 }
214
215 if(a.getTransitions() != b.getTransitions()) {
216 out << "Transitions" << std::endl;
217
219 }
220}
221
222template<class SymbolType, class StateType>
224 out << "AutomataComparer" << std::endl;
225
226 if(a.getFinalStates() != b.getFinalStates()){
227 out << "FinalStates" << std::endl;
228
230 }
231
232 if(a.getInitialState() != b.getInitialState()) {
233 out << "Initial state" << std::endl;
234
235 out << "< " << a.getInitialState() << std::endl;
236 out << "---" << std::endl;
237 out << "> " << b.getInitialState() << std::endl;
238 }
239
240 if(a.getInputAlphabet() != b.getInputAlphabet()) {
241 out << "InputAlphabet" << std::endl;
242
244 }
245
246 if(a.getStates() != b.getStates()) {
247 out << "States" << std::endl;
248
249 DiffAux::setDiff ( out, a.getStates(), b.getStates());
250 }
251
252 if(a.getTransitions() != b.getTransitions()) {
253 out << "Transitions" << std::endl;
254
256 }
257}
258
259template<class SymbolType, class StateType>
261 out << "AutomataComparer" << std::endl;
262
263 if(a.getFinalStates() != b.getFinalStates()){
264 out << "FinalStates" << std::endl;
265
267 }
268
269 if(a.getInitialState() != b.getInitialState()) {
270 out << "Initial state" << std::endl;
271
272 out << "< " << a.getInitialState() << std::endl;
273 out << "---" << std::endl;
274 out << "> " << b.getInitialState() << std::endl;
275 }
276
277 if(a.getInputAlphabet() != b.getInputAlphabet()) {
278 out << "InputAlphabet" << std::endl;
279
281 }
282
283 if(a.getStates() != b.getStates()) {
284 out << "States" << std::endl;
285
286 DiffAux::setDiff ( out, a.getStates(), b.getStates());
287 }
288
289 if(a.getTransitions() != b.getTransitions()) {
290 out << "Transitions" << std::endl;
291
293 }
294}
295
296template<class SymbolType, class StateType>
298 out << "AutomataComparer" << std::endl;
299
300 if(a.getFinalStates() != b.getFinalStates()){
301 out << "FinalStates" << std::endl;
302
304 }
305
306 if(a.getInitialState() != b.getInitialState()) {
307 out << "Initial state" << std::endl;
308
309 out << "< " << a.getInitialState() << std::endl;
310 out << "---" << std::endl;
311 out << "> " << b.getInitialState() << std::endl;
312 }
313
314 if(a.getInputAlphabet() != b.getInputAlphabet()) {
315 out << "InputAlphabet" << std::endl;
316
318 }
319
320 if(a.getStates() != b.getStates()) {
321 out << "States" << std::endl;
322
323 DiffAux::setDiff ( out, a.getStates(), b.getStates());
324 }
325
326 if(a.getTransitions() != b.getTransitions()) {
327 out << "Transitions" << std::endl;
328
330 }
331}
332
333template<class SymbolType, class StateType>
335 out << "AutomataComparer" << std::endl;
336
337 if(a.getFinalStates() != b.getFinalStates()){
338 out << "FinalStates" << std::endl;
339
341 }
342
343 if(a.getInitialState() != b.getInitialState()) {
344 out << "Initial state" << std::endl;
345
346 out << "< " << a.getInitialState() << std::endl;
347 out << "---" << std::endl;
348 out << "> " << b.getInitialState() << std::endl;
349 }
350
351 if(a.getInputAlphabet() != b.getInputAlphabet()) {
352 out << "InputAlphabet" << std::endl;
353
355 }
356
357 if(a.getStates() != b.getStates()) {
358 out << "States" << std::endl;
359
360 DiffAux::setDiff ( out, a.getStates(), b.getStates());
361 }
362
363 if(a.getTransitions() != b.getTransitions()) {
364 out << "Transitions" << std::endl;
365
367 }
368}
369
370template<class SymbolType, class StateType>
371void AutomatonDiff::printDiff(const automaton::DFTA < SymbolType, StateType > & a, const automaton::DFTA < SymbolType, StateType > & b, ext::ostream & out ) {
372 out << "AutomataComparer" << std::endl;
373
374 if(a.getFinalStates() != b.getFinalStates()){
375 out << "FinalStates" << std::endl;
376
378 }
379
380 if(a.getInputAlphabet() != b.getInputAlphabet()) {
381 out << "InputAlphabet" << std::endl;
382
384 }
385
386 if(a.getStates() != b.getStates()) {
387 out << "States" << std::endl;
388
389 DiffAux::setDiff ( out, a.getStates(), b.getStates());
390 }
391
392 if(a.getTransitions() != b.getTransitions()) {
393 out << "Transitions" << std::endl;
394
396 }
397}
398
399template<class SymbolType, class StateType>
400void AutomatonDiff::printDiff(const automaton::NFTA < SymbolType, StateType > & a, const automaton::NFTA < SymbolType, StateType > & b, ext::ostream & out ) {
401 out << "AutomataComparer" << std::endl;
402
403 if(a.getFinalStates() != b.getFinalStates()){
404 out << "FinalStates" << std::endl;
405
407 }
408
409 if(a.getInputAlphabet() != b.getInputAlphabet()) {
410 out << "InputAlphabet" << std::endl;
411
413 }
414
415 if(a.getStates() != b.getStates()) {
416 out << "States" << std::endl;
417
418 DiffAux::setDiff ( out, a.getStates(), b.getStates());
419 }
420
421 if(a.getTransitions() != b.getTransitions()) {
422 out << "Transitions" << std::endl;
423
425 }
426}
427
428template<class InputSymbolType, class PushdownStoreSymbolType, class StateType>
430 out << "AutomataComparer" << std::endl;
431
432 if(a.getFinalStates() != b.getFinalStates()){
433 out << "FinalStates" << std::endl;
434
436 }
437
438 if(a.getInitialState() != b.getInitialState()) {
439 out << "Initial state" << std::endl;
440
441 out << "< " << a.getInitialState() << std::endl;
442 out << "---" << std::endl;
443 out << "> " << b.getInitialState() << std::endl;
444 }
445
446 if(a.getInputAlphabet() != b.getInputAlphabet()) {
447 out << "InputAlphabet" << std::endl;
448
450 }
451
453 out << "StackAlphabet" << std::endl;
454
456 }
457
458 if(a.getInitialSymbol() != b.getInitialSymbol()) {
459 out << "InitialSymbol" << std::endl;
460
461 out << "< " << a.getInitialSymbol() << std::endl;
462 out << "---" << std::endl;
463 out << "> " << b.getInitialSymbol() << std::endl;
464 }
465
466 if(a.getStates() != b.getStates()) {
467 out << "States" << std::endl;
468
469 DiffAux::setDiff ( out, a.getStates(), b.getStates());
470 }
471
472 if(a.getTransitions() != b.getTransitions()) {
473 out << "Transitions" << std::endl;
474
476 }
477}
478
479template<class InputSymbolType, class PushdownStoreSymbolType, class StateType>
481 out << "AutomataComparer" << std::endl;
482
483 if(a.getFinalStates() != b.getFinalStates()){
484 out << "FinalStates" << std::endl;
485
487 }
488
489 if(a.getInitialState() != b.getInitialState()) {
490 out << "Initial state" << std::endl;
491
492 out << "< " << a.getInitialState() << std::endl;
493 out << "---" << std::endl;
494 out << "> " << b.getInitialState() << std::endl;
495 }
496
497 if(a.getInputAlphabet() != b.getInputAlphabet()) {
498 out << "InputAlphabet" << std::endl;
499
501 }
502
504 out << "StackAlphabet" << std::endl;
505
507 }
508
509 if(a.getInitialSymbol() != b.getInitialSymbol()) {
510 out << "InitialSymbol" << std::endl;
511
512 out << "< " << a.getInitialSymbol() << std::endl;
513 out << "---" << std::endl;
514 out << "> " << b.getInitialSymbol() << std::endl;
515 }
516
517 if(a.getStates() != b.getStates()) {
518 out << "States" << std::endl;
519
520 DiffAux::setDiff ( out, a.getStates(), b.getStates());
521 }
522
523 if(a.getTransitions() != b.getTransitions()) {
524 out << "Transitions" << std::endl;
525
527 }
528}
529
530template<class InputSymbolType, class PushdownStoreSymbolType, class StateType>
532 out << "AutomataComparer" << std::endl;
533
534 if(a.getFinalStates() != b.getFinalStates()){
535 out << "FinalStates" << std::endl;
536
538 }
539
540 if(a.getInitialState() != b.getInitialState()) {
541 out << "Initial state" << std::endl;
542
543 out << "< " << a.getInitialState() << std::endl;
544 out << "---" << std::endl;
545 out << "> " << b.getInitialState() << std::endl;
546 }
547
548 if(a.getInputAlphabet() != b.getInputAlphabet()) {
549 out << "InputAlphabet" << std::endl;
550
552 }
553
555 out << "StackAlphabet" << std::endl;
556
558 }
559
560 if(a.getInitialSymbol() != b.getInitialSymbol()) {
561 out << "InitialSymbol" << std::endl;
562
563 out << "< " << a.getInitialSymbol() << std::endl;
564 out << "---" << std::endl;
565 out << "> " << b.getInitialSymbol() << std::endl;
566 }
567
568 if(a.getStates() != b.getStates()) {
569 out << "States" << std::endl;
570
571 DiffAux::setDiff ( out, a.getStates(), b.getStates());
572 }
573
575 out << "PushdownStoreOperations" << std::endl;
576
578 }
579
580 if(a.getTransitions() != b.getTransitions()) {
581 out << "Transitions" << std::endl;
582
584 }
585}
586
587template<class InputSymbolType, class PushdownStoreSymbolType, class StateType>
589 out << "AutomataComparer" << std::endl;
590
591 if(a.getFinalStates() != b.getFinalStates()){
592 out << "FinalStates" << std::endl;
593
595 }
596
597 if(a.getInitialState() != b.getInitialState()) {
598 out << "Initial state" << std::endl;
599
600 out << "< " << a.getInitialState() << std::endl;
601 out << "---" << std::endl;
602 out << "> " << b.getInitialState() << std::endl;
603 }
604
605 if(a.getInputAlphabet() != b.getInputAlphabet()) {
606 out << "InputAlphabet" << std::endl;
607
609 }
610
612 out << "StackAlphabet" << std::endl;
613
615 }
616
617 if(a.getInitialSymbol() != b.getInitialSymbol()) {
618 out << "InitialSymbol" << std::endl;
619
620 out << "< " << a.getInitialSymbol() << std::endl;
621 out << "---" << std::endl;
622 out << "> " << b.getInitialSymbol() << std::endl;
623 }
624
625 if(a.getStates() != b.getStates()) {
626 out << "States" << std::endl;
627
628 DiffAux::setDiff ( out, a.getStates(), b.getStates());
629 }
630
632 out << "PushdownStoreOperations" << std::endl;
633
635 }
636
637 if(a.getTransitions() != b.getTransitions()) {
638 out << "Transitions" << std::endl;
639
641 }
642}
643
644template<class InputSymbolType, class PushdownStoreSymbolType, class StateType>
646 out << "AutomataComparer" << std::endl;
647
648 if(a.getFinalStates() != b.getFinalStates()){
649 out << "FinalStates" << std::endl;
650
652 }
653
654 if(a.getInitialState() != b.getInitialState()) {
655 out << "Initial state" << std::endl;
656
657 out << "< " << a.getInitialState() << std::endl;
658 out << "---" << std::endl;
659 out << "> " << b.getInitialState() << std::endl;
660 }
661
663 out << "CallInputAlphabet" << std::endl;
664
666 }
667
669 out << "ReturnInputAlphabet" << std::endl;
670
672 }
673
675 out << "LocalInputAlphabet" << std::endl;
676
678 }
679
681 out << "StackAlphabet" << std::endl;
682
684 }
685
687 out << "BottomOfTheStackSymbol" << std::endl;
688
689 out << "< " << a.getBottomOfTheStackSymbol() << std::endl;
690 out << "---" << std::endl;
691 out << "> " << b.getBottomOfTheStackSymbol() << std::endl;
692 }
693
694 if(a.getStates() != b.getStates()) {
695 out << "States" << std::endl;
696
697 DiffAux::setDiff ( out, a.getStates(), b.getStates());
698 }
699
701 out << "CallTransitions" << std::endl;
702
704 }
705
707 out << "ReturnTransitions" << std::endl;
708
710 }
711
713 out << "LocalTransitions" << std::endl;
714
716 }
717}
718
719template<class InputSymbolType, class PushdownStoreSymbolType, class StateType>
721 out << "AutomataComparer" << std::endl;
722
723 if(a.getFinalStates() != b.getFinalStates()){
724 out << "FinalStates" << std::endl;
725
727 }
728
729 if(a.getInitialStates() != b.getInitialStates()) {
730 out << "Initial states" << std::endl;
731
733 }
734
736 out << "CallInputAlphabet" << std::endl;
737
739 }
740
742 out << "ReturnInputAlphabet" << std::endl;
743
745 }
746
748 out << "LocalInputAlphabet" << std::endl;
749
751 }
752
754 out << "StackAlphabet" << std::endl;
755
757 }
758
760 out << "BottomOfTheStackSymbol" << std::endl;
761
762 out << "< " << a.getBottomOfTheStackSymbol() << std::endl;
763 out << "---" << std::endl;
764 out << "> " << b.getBottomOfTheStackSymbol() << std::endl;
765 }
766
767 if(a.getStates() != b.getStates()) {
768 out << "States" << std::endl;
769
770 DiffAux::setDiff ( out, a.getStates(), b.getStates());
771 }
772
774 out << "CallTransitions" << std::endl;
775
777 }
778
780 out << "ReturnTransitions" << std::endl;
781
783 }
784
786 out << "LocalTransitions" << std::endl;
787
789 }
790}
791
792template<class InputSymbolType, class PushdownStoreSymbolType, class StateType>
794 out << "AutomataComparer" << std::endl;
795
796 if(a.getFinalStates() != b.getFinalStates()){
797 out << "FinalStates" << std::endl;
798
800 }
801
802 if(a.getInitialState() != b.getInitialState()) {
803 out << "Initial state" << std::endl;
804
805 out << "< " << a.getInitialState() << std::endl;
806 out << "---" << std::endl;
807 out << "> " << b.getInitialState() << std::endl;
808 }
809
810 if(a.getInputAlphabet() != b.getInputAlphabet()) {
811 out << "InputAlphabet" << std::endl;
812
814 }
815
817 out << "StackAlphabet" << std::endl;
818
820 }
821
823 out << "BottomOfTheStackSymbol" << std::endl;
824
825 out << "< " << a.getBottomOfTheStackSymbol() << std::endl;
826 out << "---" << std::endl;
827 out << "> " << b.getBottomOfTheStackSymbol() << std::endl;
828 }
829
830 if(a.getStates() != b.getStates()) {
831 out << "States" << std::endl;
832
833 DiffAux::setDiff ( out, a.getStates(), b.getStates());
834 }
835
837 out << "CallTransitions" << std::endl;
838
840 }
841
843 out << "ReturnTransitions" << std::endl;
844
846 }
847
849 out << "LocalTransitions" << std::endl;
850
852 }
853}
854
855template<class InputSymbolType, class PushdownStoreSymbolType, class StateType>
857 out << "AutomataComparer" << std::endl;
858
859 if(a.getFinalStates() != b.getFinalStates()){
860 out << "FinalStates" << std::endl;
861
863 }
864
865 if(a.getInitialStates() != b.getInitialStates()) {
866 out << "Initial states" << std::endl;
867
869 }
870
871 if(a.getInputAlphabet() != b.getInputAlphabet()) {
872 out << "InputAlphabet" << std::endl;
873
875 }
876
878 out << "StackAlphabet" << std::endl;
879
881 }
882
884 out << "BottomOfTheStackSymbol" << std::endl;
885
886 out << "< " << a.getBottomOfTheStackSymbol() << std::endl;
887 out << "---" << std::endl;
888 out << "> " << b.getBottomOfTheStackSymbol() << std::endl;
889 }
890
891 if(a.getStates() != b.getStates()) {
892 out << "States" << std::endl;
893
894 DiffAux::setDiff ( out, a.getStates(), b.getStates());
895 }
896
898 out << "CallTransitions" << std::endl;
899
901 }
902
904 out << "ReturnTransitions" << std::endl;
905
907 }
908
910 out << "LocalTransitions" << std::endl;
911
913 }
914}
915
916template<class InputSymbolType, class PushdownStoreSymbolType, class StateType>
918 out << "AutomataComparer" << std::endl;
919
920 if(a.getFinalStates() != b.getFinalStates()){
921 out << "FinalStates" << std::endl;
922
924 }
925
926 if(a.getInitialState() != b.getInitialState()) {
927 out << "Initial state" << std::endl;
928
929 out << "< " << a.getInitialState() << std::endl;
930 out << "---" << std::endl;
931 out << "> " << b.getInitialState() << std::endl;
932 }
933
934 if(a.getInputAlphabet() != b.getInputAlphabet()) {
935 out << "InputAlphabet" << std::endl;
936
938 }
939
941 out << "StackAlphabet" << std::endl;
942
944 }
945
946 if(a.getInitialSymbol() != b.getInitialSymbol()) {
947 out << "InitialSymbol" << std::endl;
948
949 out << "< " << a.getInitialSymbol() << std::endl;
950 out << "---" << std::endl;
951 out << "> " << b.getInitialSymbol() << std::endl;
952 }
953
954 if(a.getStates() != b.getStates()) {
955 out << "States" << std::endl;
956
957 DiffAux::setDiff ( out, a.getStates(), b.getStates());
958 }
959
960 if(a.getTransitions() != b.getTransitions()) {
961 out << "Transitions" << std::endl;
962
964 }
965}
966
967template<class InputSymbolType, class PushdownStoreSymbolType, class StateType>
969 out << "AutomataComparer" << std::endl;
970
971 if(a.getFinalStates() != b.getFinalStates()){
972 out << "FinalStates" << std::endl;
973
975 }
976
977 if(a.getInitialState() != b.getInitialState()) {
978 out << "Initial state" << std::endl;
979
980 out << "< " << a.getInitialState() << std::endl;
981 out << "---" << std::endl;
982 out << "> " << b.getInitialState() << std::endl;
983 }
984
985 if(a.getInputAlphabet() != b.getInputAlphabet()) {
986 out << "InputAlphabet" << std::endl;
987
989 }
990
992 out << "StackAlphabet" << std::endl;
993
995 }
996
997 if(a.getInitialSymbol() != b.getInitialSymbol()) {
998 out << "InitialSymbol" << std::endl;
999
1000 out << "< " << a.getInitialSymbol() << std::endl;
1001 out << "---" << std::endl;
1002 out << "> " << b.getInitialSymbol() << std::endl;
1003 }
1004
1005 if(a.getStates() != b.getStates()) {
1006 out << "States" << std::endl;
1007
1008 DiffAux::setDiff ( out, a.getStates(), b.getStates());
1009 }
1010
1011 if(a.getTransitions() != b.getTransitions()) {
1012 out << "Transitions" << std::endl;
1013
1015 }
1016}
1017
1018template<class SymbolType, class StateType>
1020 out << "AutomataComparer" << std::endl;
1021
1022 if(a.getBlankSymbol() != b.getBlankSymbol()) {
1023 out << "Blank symbol" << std::endl;
1024
1025 out << "< " << a.getBlankSymbol() << std::endl;
1026 out << "---" << std::endl;
1027 out << "> " << b.getBlankSymbol() << std::endl;
1028 }
1029
1030 if(a.getFinalStates() != b.getFinalStates()){
1031 out << "FinalStates" << std::endl;
1032
1034 }
1035
1036 if(a.getInitialState() != b.getInitialState()) {
1037 out << "Initial state" << std::endl;
1038
1039 out << "< " << a.getInitialState() << std::endl;
1040 out << "---" << std::endl;
1041 out << "> " << b.getInitialState() << std::endl;
1042 }
1043
1044 if(a.getInputAlphabet() != b.getInputAlphabet()) {
1045 out << "InputAlphabet" << std::endl;
1046
1048 }
1049
1050 if(a.getStates() != b.getStates()) {
1051 out << "States" << std::endl;
1052
1053 DiffAux::setDiff ( out, a.getStates(), b.getStates());
1054 }
1055
1056 if(a.getTapeAlphabet() != b.getTapeAlphabet()) {
1057 out << "TapeAlphabet" << std::endl;
1058
1060 }
1061
1062 if(a.getTransitions() != b.getTransitions()) {
1063 out << "Transitions" << std::endl;
1064
1066 }
1067}
1068
1069template < class T>
1070void AutomatonDiff::diff(const T & a, const T & b, ext::ostream & out) {
1071 if(!AutomatonCompare::compare(a, b)) {
1072 AutomatonDiff::printDiff(a, b, out);
1073 }
1074}
1075
1076template < class T >
1077std::string AutomatonDiff::diff ( const T & a, const T & b ) {
1079 diff ( a, b, ss );
1080 return ss.str ( );
1081}
1082
1083} /* namespace compare */
1084
Compact deterministic finite automaton. Accepts regular languages. The automaton has a list of symbol...
Definition: CompactDFA.h:73
const ext::map< ext::pair< StateType, ext::vector< SymbolType > >, StateType > & getTransitions() const &
Definition: CompactDFA.h:483
const ext::set< StateType > & getFinalStates() const &
Definition: CompactDFA.h:192
const StateType & getInitialState() const &
Definition: CompactDFA.h:114
const ext::set< StateType > & getStates() const &
Definition: CompactDFA.h:143
const ext::set< SymbolType > & getInputAlphabet() const &
Definition: CompactDFA.h:241
Compact nondeterministic finite automaton. Accepts regular languages. The automaton has a list of sym...
Definition: CompactNFA.h:78
const ext::set< StateType > & getFinalStates() const &
Definition: CompactNFA.h:232
const ext::multimap< ext::pair< StateType, ext::vector< SymbolType > >, StateType > & getTransitions() const &
Definition: CompactNFA.h:555
const ext::set< StateType > & getStates() const &
Definition: CompactNFA.h:183
const StateType & getInitialState() const &
Definition: CompactNFA.h:154
const ext::set< SymbolType > & getInputAlphabet() const &
Definition: CompactNFA.h:281
Deterministic finite automaton. Accepts regular languages.
Definition: DFA.h:71
const ext::set< StateType > & getFinalStates() const &
Definition: DFA.h:183
const ext::map< ext::pair< StateType, SymbolType >, StateType > & getTransitions() const &
Definition: DFA.h:473
const StateType & getInitialState() const &
Definition: DFA.h:105
const ext::set< SymbolType > & getInputAlphabet() const &
Definition: DFA.h:232
const ext::set< StateType > & getStates() const &
Definition: DFA.h:134
Nondeterministic finite tree automaton without epsilon transitions. Accepts regular tree languages.
Definition: DFTA.h:74
const ext::map< ext::pair< common::ranked_symbol< SymbolType >, ext::vector< StateType > >, StateType > & getTransitions() const &
Definition: DFTA.h:289
const ext::set< common::ranked_symbol< SymbolType > > & getInputAlphabet() const &
Definition: DFTA.h:203
const ext::set< StateType > & getFinalStates() const &
Definition: DFTA.h:154
const ext::set< StateType > & getStates() const &
Definition: DFTA.h:105
Deterministic pushdown automaton. Accepts subset of context free languages.
Definition: DPDA.h:78
const PushdownStoreSymbolType & getInitialSymbol() const &
Definition: DPDA.h:301
const ext::set< PushdownStoreSymbolType > & getPushdownStoreAlphabet() const &
Definition: DPDA.h:243
const ext::set< InputSymbolType > & getInputAlphabet() const &
Definition: DPDA.h:330
const ext::set< StateType > & getStates() const &
Definition: DPDA.h:145
const ext::map< ext::tuple< StateType, common::symbol_or_epsilon< InputSymbolType >, ext::vector< PushdownStoreSymbolType > >, ext::pair< StateType, ext::vector< PushdownStoreSymbolType > > > & getTransitions() const &
Definition: DPDA.h:682
const ext::set< StateType > & getFinalStates() const &
Definition: DPDA.h:194
const StateType & getInitialState() const &
Definition: DPDA.h:116
Epsilon nondeterministic finite automaton. Accepts regular languages.
Definition: EpsilonNFA.h:74
const ext::set< StateType > & getStates() const &
Definition: EpsilonNFA.h:158
const ext::set< StateType > & getFinalStates() const &
Definition: EpsilonNFA.h:207
const ext::set< SymbolType > & getInputAlphabet() const &
Definition: EpsilonNFA.h:256
const ext::multimap< ext::pair< StateType, common::symbol_or_epsilon< SymbolType > >, StateType > & getTransitions() const &
Definition: EpsilonNFA.h:666
const StateType & getInitialState() const &
Definition: EpsilonNFA.h:129
Extended nondeterministic finite automaton. Accepts regular languages. The automaton has a regular ex...
Definition: ExtendedNFA.h:80
const StateType & getInitialState() const &
Definition: ExtendedNFA.h:156
const ext::set< SymbolType > & getInputAlphabet() const &
Definition: ExtendedNFA.h:283
const ext::multimap< ext::pair< StateType, regexp::UnboundedRegExpStructure< SymbolType > >, StateType > & getTransitions() const &
Definition: ExtendedNFA.h:581
const ext::set< StateType > & getStates() const &
Definition: ExtendedNFA.h:185
const ext::set< StateType > & getFinalStates() const &
Definition: ExtendedNFA.h:234
Deterministic input driven pushdown automaton. Accepts subset of context free languages.
Definition: InputDrivenDPDA.h:79
const ext::map< ext::pair< StateType, InputSymbolType >, StateType > & getTransitions() const &
Definition: InputDrivenDPDA.h:655
const ext::set< StateType > & getStates() const &
Definition: InputDrivenDPDA.h:160
const PushdownStoreSymbolType & getInitialSymbol() const &
Definition: InputDrivenDPDA.h:316
const ext::set< InputSymbolType > & getInputAlphabet() const &
Definition: InputDrivenDPDA.h:345
const ext::set< PushdownStoreSymbolType > & getPushdownStoreAlphabet() const &
Definition: InputDrivenDPDA.h:258
const ext::set< StateType > & getFinalStates() const &
Definition: InputDrivenDPDA.h:209
const ext::map< InputSymbolType, ext::pair< ext::vector< PushdownStoreSymbolType >, ext::vector< PushdownStoreSymbolType > > > & getPushdownStoreOperations() const &
Definition: InputDrivenDPDA.h:604
const StateType & getInitialState() const &
Definition: InputDrivenDPDA.h:131
Nondeterministic input driven pushdown automaton. Accepts subset of context free languages.
Definition: InputDrivenNPDA.h:79
const PushdownStoreSymbolType & getInitialSymbol() const &
Definition: InputDrivenNPDA.h:316
const ext::map< InputSymbolType, ext::pair< ext::vector< PushdownStoreSymbolType >, ext::vector< PushdownStoreSymbolType > > > & getPushdownStoreOperations() const &
Definition: InputDrivenNPDA.h:614
const ext::set< InputSymbolType > & getInputAlphabet() const &
Definition: InputDrivenNPDA.h:345
const ext::multimap< ext::pair< StateType, InputSymbolType >, StateType > & getTransitions() const &
Definition: InputDrivenNPDA.h:661
const ext::set< StateType > & getFinalStates() const &
Definition: InputDrivenNPDA.h:209
const ext::set< PushdownStoreSymbolType > & getPushdownStoreAlphabet() const &
Definition: InputDrivenNPDA.h:258
const StateType & getInitialState() const &
Definition: InputDrivenNPDA.h:131
const ext::set< StateType > & getStates() const &
Definition: InputDrivenNPDA.h:160
Nondeterministic finite automaton with multiple initial states. Accepts regular languages.
Definition: MultiInitialStateNFA.h:69
const ext::set< StateType > & getInitialStates() const &
Definition: MultiInitialStateNFA.h:117
const ext::set< StateType > & getStates() const &
Definition: MultiInitialStateNFA.h:166
const ext::multimap< ext::pair< StateType, SymbolType >, StateType > & getTransitions() const &
Definition: MultiInitialStateNFA.h:520
const ext::set< StateType > & getFinalStates() const &
Definition: MultiInitialStateNFA.h:215
const ext::set< SymbolType > & getInputAlphabet() const &
Definition: MultiInitialStateNFA.h:264
Nondeterministic finite automaton. Accepts regular languages.
Definition: NFA.h:66
const ext::set< StateType > & getStates() const &
Definition: NFA.h:136
const StateType & getInitialState() const &
Definition: NFA.h:107
const ext::set< SymbolType > & getInputAlphabet() const &
Definition: NFA.h:234
const ext::multimap< ext::pair< StateType, SymbolType >, StateType > & getTransitions() const &
Definition: NFA.h:484
const ext::set< StateType > & getFinalStates() const &
Definition: NFA.h:185
Nondeterministic finite tree automaton without epsilon transitions. Accepts regular tree languages.
Definition: NFTA.h:72
const ext::set< StateType > & getFinalStates() const &
Definition: NFTA.h:159
const ext::multimap< ext::pair< common::ranked_symbol< SymbolType >, ext::vector< StateType > >, StateType > & getTransitions() const &
Definition: NFTA.h:294
const ext::set< StateType > & getStates() const &
Definition: NFTA.h:110
const ext::set< common::ranked_symbol< SymbolType > > & getInputAlphabet() const &
Definition: NFTA.h:208
Definition: NPDA.h:74
const PushdownStoreSymbolType & getInitialSymbol() const &
Definition: NPDA.h:304
const ext::set< StateType > & getFinalStates() const &
Definition: NPDA.h:197
const StateType & getInitialState() const &
Definition: NPDA.h:119
const ext::set< StateType > & getStates() const &
Definition: NPDA.h:148
const ext::multimap< ext::tuple< StateType, common::symbol_or_epsilon< InputSymbolType >, ext::vector< PushdownStoreSymbolType > >, ext::pair< StateType, ext::vector< PushdownStoreSymbolType > > > & getTransitions() const &
Definition: NPDA.h:644
const ext::set< InputSymbolType > & getInputAlphabet() const &
Definition: NPDA.h:333
const ext::set< PushdownStoreSymbolType > & getPushdownStoreAlphabet() const &
Definition: NPDA.h:246
Deterministic single tape turing machine. Accepts recursive languages.
Definition: OneTapeDTM.h:71
const StateType & getInitialState() const &
Definition: OneTapeDTM.h:108
const ext::set< StateType > & getFinalStates() const &
Definition: OneTapeDTM.h:186
const ext::set< SymbolType > & getTapeAlphabet() const &
Definition: OneTapeDTM.h:293
const ext::map< ext::pair< StateType, SymbolType >, ext::tuple< StateType, SymbolType, Shift > > & getTransitions() const &
Definition: OneTapeDTM.h:526
const SymbolType & getBlankSymbol() const &
Definition: OneTapeDTM.h:351
const ext::set< SymbolType > & getInputAlphabet() const &
Definition: OneTapeDTM.h:235
const ext::set< StateType > & getStates() const &
Definition: OneTapeDTM.h:137
Deterministic real time height deterministic pushdown automaton. Accepts subset of context free langu...
Definition: RealTimeHeightDeterministicDPDA.h:89
const ext::set< InputSymbolType > & getInputAlphabet() const &
Definition: RealTimeHeightDeterministicDPDA.h:363
const StateType & getInitialState() const &
Definition: RealTimeHeightDeterministicDPDA.h:149
const ext::map< ext::pair< StateType, common::symbol_or_epsilon< InputSymbolType > >, ext::pair< StateType, PushdownStoreSymbolType > > & getCallTransitions() const &
Definition: RealTimeHeightDeterministicDPDA.h:1062
const ext::set< PushdownStoreSymbolType > & getPushdownStoreAlphabet() const &
Definition: RealTimeHeightDeterministicDPDA.h:276
const ext::map< ext::pair< StateType, common::symbol_or_epsilon< InputSymbolType > >, StateType > & getLocalTransitions() const &
Definition: RealTimeHeightDeterministicDPDA.h:1082
const ext::map< ext::tuple< StateType, common::symbol_or_epsilon< InputSymbolType >, PushdownStoreSymbolType >, StateType > & getReturnTransitions() const &
Definition: RealTimeHeightDeterministicDPDA.h:1072
const ext::set< StateType > & getStates() const &
Definition: RealTimeHeightDeterministicDPDA.h:178
const ext::set< StateType > & getFinalStates() const &
Definition: RealTimeHeightDeterministicDPDA.h:227
const PushdownStoreSymbolType & getBottomOfTheStackSymbol() const &
Definition: RealTimeHeightDeterministicDPDA.h:334
Nondeterministic real time height deterministic pushdown automaton. Accepts subset of context free la...
Definition: RealTimeHeightDeterministicNPDA.h:76
const ext::set< StateType > & getInitialStates() const &
Definition: RealTimeHeightDeterministicNPDA.h:175
const ext::set< PushdownStoreSymbolType > & getPushdownStoreAlphabet() const &
Definition: RealTimeHeightDeterministicNPDA.h:273
const PushdownStoreSymbolType & getBottomOfTheStackSymbol() const &
Definition: RealTimeHeightDeterministicNPDA.h:331
const ext::set< StateType > & getStates() const &
Definition: RealTimeHeightDeterministicNPDA.h:126
const ext::multimap< ext::pair< StateType, common::symbol_or_epsilon< InputSymbolType > >, StateType > & getLocalTransitions() const &
Definition: RealTimeHeightDeterministicNPDA.h:1004
const ext::multimap< ext::pair< StateType, common::symbol_or_epsilon< InputSymbolType > >, ext::pair< StateType, PushdownStoreSymbolType > > & getCallTransitions() const &
Definition: RealTimeHeightDeterministicNPDA.h:984
const ext::set< StateType > & getFinalStates() const &
Definition: RealTimeHeightDeterministicNPDA.h:224
const ext::multimap< ext::tuple< StateType, common::symbol_or_epsilon< InputSymbolType >, PushdownStoreSymbolType >, StateType > & getReturnTransitions() const &
Definition: RealTimeHeightDeterministicNPDA.h:994
const ext::set< InputSymbolType > & getInputAlphabet() const &
Definition: RealTimeHeightDeterministicNPDA.h:360
Deterministic pushdown automaton requiring a symbol pop from pushdown store on each transition use....
Definition: SinglePopDPDA.h:78
const ext::set< PushdownStoreSymbolType > & getPushdownStoreAlphabet() const &
Definition: SinglePopDPDA.h:243
const StateType & getInitialState() const &
Definition: SinglePopDPDA.h:116
const ext::set< InputSymbolType > & getInputAlphabet() const &
Definition: SinglePopDPDA.h:330
const ext::set< StateType > & getFinalStates() const &
Definition: SinglePopDPDA.h:194
const ext::set< StateType > & getStates() const &
Definition: SinglePopDPDA.h:145
const PushdownStoreSymbolType & getInitialSymbol() const &
Definition: SinglePopDPDA.h:301
const ext::map< ext::tuple< StateType, common::symbol_or_epsilon< InputSymbolType >, PushdownStoreSymbolType >, ext::pair< StateType, ext::vector< PushdownStoreSymbolType > > > & getTransitions() const &
Definition: SinglePopDPDA.h:639
Definition: SinglePopNPDA.h:72
const StateType & getInitialState() const &
Definition: SinglePopNPDA.h:110
const ext::set< InputSymbolType > & getInputAlphabet() const &
Definition: SinglePopNPDA.h:324
const ext::set< PushdownStoreSymbolType > & getPushdownStoreAlphabet() const &
Definition: SinglePopNPDA.h:237
const PushdownStoreSymbolType & getInitialSymbol() const &
Definition: SinglePopNPDA.h:295
const ext::multimap< ext::tuple< StateType, common::symbol_or_epsilon< InputSymbolType >, PushdownStoreSymbolType >, ext::pair< StateType, ext::vector< PushdownStoreSymbolType > > > & getTransitions() const &
Definition: SinglePopNPDA.h:617
const ext::set< StateType > & getStates() const &
Definition: SinglePopNPDA.h:139
const ext::set< StateType > & getFinalStates() const &
Definition: SinglePopNPDA.h:188
Deterministic visibly pushdown automaton. Accepts subset of context free languages.
Definition: VisiblyPushdownDPDA.h:86
const PushdownStoreSymbolType & getBottomOfTheStackSymbol() const &
Definition: VisiblyPushdownDPDA.h:331
const ext::set< InputSymbolType > & getCallInputAlphabet() const &
Definition: VisiblyPushdownDPDA.h:360
const ext::map< ext::tuple< StateType, InputSymbolType, PushdownStoreSymbolType >, StateType > & getReturnTransitions() const &
Definition: VisiblyPushdownDPDA.h:899
const ext::map< ext::pair< StateType, InputSymbolType >, StateType > & getLocalTransitions() const &
Definition: VisiblyPushdownDPDA.h:909
const ext::set< StateType > & getFinalStates() const &
Definition: VisiblyPushdownDPDA.h:224
const ext::set< InputSymbolType > & getLocalInputAlphabet() const &
Definition: VisiblyPushdownDPDA.h:476
const ext::map< ext::pair< StateType, InputSymbolType >, ext::pair< StateType, PushdownStoreSymbolType > > & getCallTransitions() const &
Definition: VisiblyPushdownDPDA.h:889
const ext::set< StateType > & getStates() const &
Definition: VisiblyPushdownDPDA.h:175
const ext::set< PushdownStoreSymbolType > & getPushdownStoreAlphabet() const &
Definition: VisiblyPushdownDPDA.h:273
const ext::set< InputSymbolType > & getReturnInputAlphabet() const &
Definition: VisiblyPushdownDPDA.h:418
const StateType & getInitialState() const &
Definition: VisiblyPushdownDPDA.h:146
Nondeterministic visibly pushdown automaton. Accepts subset of context free languages.
Definition: VisiblyPushdownNPDA.h:81
const PushdownStoreSymbolType & getBottomOfTheStackSymbol() const &
Definition: VisiblyPushdownNPDA.h:336
const ext::set< StateType > & getInitialStates() const &
Definition: VisiblyPushdownNPDA.h:131
const ext::set< PushdownStoreSymbolType > & getPushdownStoreAlphabet() const &
Definition: VisiblyPushdownNPDA.h:278
const ext::set< StateType > & getStates() const &
Definition: VisiblyPushdownNPDA.h:180
const ext::multimap< ext::pair< StateType, InputSymbolType >, StateType > & getLocalTransitions() const &
Definition: VisiblyPushdownNPDA.h:884
const ext::set< InputSymbolType > & getCallInputAlphabet() const &
Definition: VisiblyPushdownNPDA.h:365
const ext::set< StateType > & getFinalStates() const &
Definition: VisiblyPushdownNPDA.h:229
const ext::set< InputSymbolType > & getReturnInputAlphabet() const &
Definition: VisiblyPushdownNPDA.h:423
const ext::multimap< ext::tuple< StateType, InputSymbolType, PushdownStoreSymbolType >, StateType > & getReturnTransitions() const &
Definition: VisiblyPushdownNPDA.h:874
const ext::multimap< ext::pair< StateType, InputSymbolType >, ext::pair< StateType, PushdownStoreSymbolType > > & getCallTransitions() const &
Definition: VisiblyPushdownNPDA.h:864
const ext::set< InputSymbolType > & getLocalInputAlphabet() const &
Definition: VisiblyPushdownNPDA.h:481
static bool compare(const automaton::DFA< SymbolType, StateType > &a, const automaton::DFA< SymbolType, StateType > &b)
Definition: AutomatonCompare.h:95
Definition: AutomatonDiff.h:44
static void diff(const T &a, const T &b, ext::ostream &out)
Definition: AutomatonDiff.h:1070
static void setDiff(ext::ostream &out, const ext::set< T > &a, const ext::set< T > &b)
Definition: DiffAux.h:33
static void mapDiff(ext::ostream &out, const ext::map< T, R > &a, const ext::map< T, R > &b)
Definition: DiffAux.h:84
Definition: ostream.h:14
Definition: sstream.h:15
std::string str() const &
Definition: sstream.cpp:29
Definition: AutomatonCompare.h:29