22# Miscellaneous #
33################################################################################
44# Additional static terms to be included into the autocomplete field.
5+
56VARIABLE_AUTOCOMPLETE_EXTENSION = ["abs()" ]
67
78################################################################################
509510 ################################################################################
510511 # Requirement Automaton Patterns #
511512 ################################################################################
512- "Transition" : {
513- "pattern" : "if in location {R} then transition to {S}" ,
514- "countertraces" : {"GLOBALLY" : ["true;⌈R⌉;⌈!(R && S)⌉;true" ]},
515- "env" : {"R" : ["bool" ], "S" : ["bool" ]},
516- "group" : "Automaton" ,
517- "pattern_order" : 0 ,
518- },
519- "TransitionGET" : {
520- "pattern" : "if in location {R} then transition to {S} if guard {U} holds and event {V} and after at most {T} time units" ,
521- # TODO: this formula is nonsense, we need to transform the pattern
522- # to accomodate the formula in the sense of the paper.
523- # 1) for the simulator
524- # 2) in Ultimate
525- # For the typecheck, this is asonishingly ok (but we miss the enumeration for states,
526- # which is ... bad i think?
527- "countertraces" : {"GLOBALLY" : ["true;⌈R⌉;⌈!(R && S)⌉;true" ]},
528- "env" : {
529- "R" : ["bool" ],
530- "S" : ["bool" ],
531- "T" : ["real" ],
532- "U" : ["bool" ],
533- "V" : ["bool" ],
534- },
513+ "InitialLoc " : {
514+ "pattern" : "location {R} is an initial location" ,
515+ "countertraces" : {"GLOBALLY" : []},
516+ "env" : {"R" : ["bool" ]},
535517 "group" : "Automaton" ,
536- "pattern_order" : 0 ,
518+ "pattern_order" : - 1 ,
537519 },
520+ ####### Transisitions are generated below
538521 ################################################################################
539522 # Legacy Patterns #
540523 ################################################################################
579562 "pattern_order" : 1 ,
580563 },
581564}
565+
566+
567+
568+ def enumerate_transition_patterns (order : int , time : str = "then" , event : bool = False , guard : bool = False ):
569+ env = {"R" : ["bool" ], "S" : ["bool" ]}
570+ suffix = ""
571+ match time :
572+ case "then" : pass
573+ case "least" :
574+ time = "for at least {T}"
575+ env ["T" ] = "real"
576+ suffix += "L"
577+ case "most" :
578+ time = "for at most {T}"
579+ env ["T" ] = "real"
580+ suffix += "U"
581+ case _: raise Exception ("Invalid name for automata pattern 'then' part" )
582+ if guard :
583+ partikel = "and" if event else "if"
584+ gt = partikel + " guard {V} holds"
585+ suffix += "G"
586+ env ["V" ] = "bool"
587+ else :
588+ gt = ""
589+ if event :
590+ ct = f"if event {{U}} fires { gt } "
591+ env ["U" ] = "bool"
592+ suffix += "E"
593+ else :
594+ ct = f"is enabled { gt } "
595+
596+ p_text = f"if in location {{R}} { time } transition to {{S}} { ct } ."
597+
598+ return {"Transition" + suffix : {
599+ "pattern" : p_text ,
600+ "countertraces" : {"GLOBALLY" : []},
601+ "env" : env ,
602+ "group" : "Automaton" ,
603+ "pattern_order" : order ,
604+ }}
605+
606+ PATTERNS .update (enumerate_transition_patterns (0 ))
607+ PATTERNS .update (enumerate_transition_patterns (1 , guard = True ))
608+ PATTERNS .update (enumerate_transition_patterns (2 , time = "least" , guard = True ))
609+ PATTERNS .update (enumerate_transition_patterns (3 , time = "most" , guard = True ))
610+ PATTERNS .update (enumerate_transition_patterns (4 , time = "least" ))
611+ PATTERNS .update (enumerate_transition_patterns (5 , time = "most" ))
612+
613+ PATTERNS .update (enumerate_transition_patterns (6 , event = True ))
614+ PATTERNS .update (enumerate_transition_patterns (7 , event = True , guard = True ))
615+ PATTERNS .update (enumerate_transition_patterns (8 , event = True ,time = "least" , guard = True ))
616+ PATTERNS .update (enumerate_transition_patterns (9 , event = True ,time = "most" , guard = True ))
617+ PATTERNS .update (enumerate_transition_patterns (10 , event = True ,time = "least" ))
618+ PATTERNS .update (enumerate_transition_patterns (11 , event = True ,time = "most" ))
0 commit comments