Skip to content

Commit

Permalink
Add parsing/converting/printing functionalities for AU algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
etienneandre committed Jan 26, 2024
1 parent 3167b75 commit 5c97413
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 10 deletions.
7 changes: 7 additions & 0 deletions src/bin/IMITATOR.ml
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,13 @@ match options#imitator_mode with
| AF state_predicate ->
let myalgo :> AlgoGeneric.algoGeneric = new AlgoAF.algoAF model property options state_predicate in myalgo

(************************************************************)
(* Always until *)
(************************************************************)
| AU (state_predicate_phi, state_predicate_psi) ->
let myalgo :> AlgoGeneric.algoGeneric = new AlgoAU.algoAU model property options state_predicate_phi state_predicate_psi in myalgo



(*------------------------------------------------------------*)
(* Optimized reachability *)
Expand Down
5 changes: 4 additions & 1 deletion src/lib/AbstractProperty.mli
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ type property =
(* Unavoidability *)
| AF of state_predicate


(* Always until *)
| AU of state_predicate * state_predicate


(*------------------------------------------------------------*)
(* Optimized reachability *)
(*------------------------------------------------------------*)
Expand Down
2 changes: 1 addition & 1 deletion src/lib/AlgoAU.ml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ open AlgoAUgen
(* Class definition *)
(************************************************************)
(************************************************************)
class algoAF (model : AbstractModel.abstract_model) (property : AbstractProperty.abstract_property) (options : Options.imitator_options) (state_predicate_phi : AbstractProperty.state_predicate) (state_predicate_psi : AbstractProperty.state_predicate) =
class algoAU (model : AbstractModel.abstract_model) (property : AbstractProperty.abstract_property) (options : Options.imitator_options) (state_predicate_phi : AbstractProperty.state_predicate) (state_predicate_psi : AbstractProperty.state_predicate) =
object (*(self)*) inherit algoAUgen model property options (Some state_predicate_phi) state_predicate_psi (*as super*)


Expand Down
2 changes: 1 addition & 1 deletion src/lib/AlgoAU.mli
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ open AlgoAUgen
(************************************************************)
(* Class definition *)
(************************************************************)
class algoAF : AbstractModel.abstract_model -> AbstractProperty.abstract_property -> Options.imitator_options -> AbstractProperty.state_predicate -> AbstractProperty.state_predicate ->
class algoAU : AbstractModel.abstract_model -> AbstractProperty.abstract_property -> Options.imitator_options -> AbstractProperty.state_predicate -> AbstractProperty.state_predicate ->
object inherit algoAUgen
(************************************************************)
(* Class variables *)
Expand Down
19 changes: 19 additions & 0 deletions src/lib/AlgorithmOptions.ml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ let default_state_comparison property : AbstractAlgorithm.state_comparison_opera
(*** TODO: decide heuristics ***)
-> Equality_check

(* Always until *)
| AU _
(*** TODO: decide heuristics ***)
-> Equality_check

(*------------------------------------------------------------*)
(* Optimized reachability *)
Expand Down Expand Up @@ -195,6 +199,12 @@ let is_state_comparison_correct (abstract_property : AbstractProperty.abstract_p
(* No inclusion allowed *)
-> state_comparison_operator = Equality_check || state_comparison_operator = No_check

(* Always until *)
| AU _
(*** TODO: decide heuristics ***)
(* No inclusion allowed *)
-> state_comparison_operator = Equality_check || state_comparison_operator = No_check

(*------------------------------------------------------------*)
(* Optimized reachability *)
(*------------------------------------------------------------*)
Expand Down Expand Up @@ -339,6 +349,10 @@ let merge_needed property =
(*** TODO: decide heuristics ***)
-> false

| AU _
(*** TODO: decide heuristics ***)
-> false

(*------------------------------------------------------------*)
(* Optimized reachability *)
(*------------------------------------------------------------*)
Expand Down Expand Up @@ -584,6 +598,8 @@ let supports_witness property =

(* Unavoidability *)
| AF _
(* Always until *)
| AU _
-> false

(*------------------------------------------------------------*)
Expand Down Expand Up @@ -780,6 +796,9 @@ let text_of_property property =
(* Unavoidability *)
| AF _ -> "unavoidability " ^ synthesis_or_witness

(* Always until *)
| AU _ -> "always until " ^ synthesis_or_witness

(*------------------------------------------------------------*)
(* Optimized reachability *)
(*------------------------------------------------------------*)
Expand Down
5 changes: 4 additions & 1 deletion src/lib/Graphics.ml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ let get_v0_option = function
| AG _
| EU _
| AF _
| AU _
| EFpmin _
| EFpmax _
| EFtmin _
Expand Down Expand Up @@ -1109,7 +1110,9 @@ let dot_of_statespace (model : AbstractModel.abstract_model) (property_option :
| Win (state_predicate)
-> [state_predicate]

| EU (state_predicate_1, state_predicate_2) -> [state_predicate_1; state_predicate_2]
| EU (state_predicate_1, state_predicate_2)
| AU (state_predicate_1, state_predicate_2)
-> [state_predicate_1; state_predicate_2]

| Cycle_through_generalized state_predicate_list
-> state_predicate_list
Expand Down
14 changes: 13 additions & 1 deletion src/lib/ModelConverter.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1892,6 +1892,7 @@ let check_property_option (useful_parsing_model_information : useful_parsing_mod

(* Until *)
| Parsed_EU (parsed_state_predicate_phi, parsed_state_predicate_psi)
| Parsed_AU (parsed_state_predicate_phi, parsed_state_predicate_psi)
->
evaluate_and
(check_parsed_state_predicate useful_parsing_model_information parsed_state_predicate_phi)
Expand Down Expand Up @@ -2222,7 +2223,7 @@ let convert_property_option (useful_parsing_model_information : useful_parsing_m
,
None

(* Until *)
(* Exists until *)
| Parsed_EU (parsed_state_predicate_phi, parsed_state_predicate_psi)
->
(* Return a property and no observer *)
Expand All @@ -2240,6 +2241,17 @@ let convert_property_option (useful_parsing_model_information : useful_parsing_m
,
None

(* Always until *)
| Parsed_AU (parsed_state_predicate_phi, parsed_state_predicate_psi)
->
(* Return a property and no observer *)
AU
(PropertyConverter.convert_state_predicate useful_parsing_model_information parsed_state_predicate_phi
,
PropertyConverter.convert_state_predicate useful_parsing_model_information parsed_state_predicate_psi)
,
None


(*------------------------------------------------------------*)
(* Optimized reachability *)
Expand Down
3 changes: 3 additions & 0 deletions src/lib/ModelPrinter.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1007,6 +1007,9 @@ let string_of_abstract_property model property =
(* Unavoidability *)
| AF state_predicate -> "AF(" ^ (string_of_state_predicate model state_predicate) ^ ")"

(* Always until *)
| AU (state_predicate_phi, state_predicate_psi) -> "A(" ^ (string_of_state_predicate model state_predicate_phi) ^ ")U(" ^ (string_of_state_predicate model state_predicate_psi) ^ ")"

(*------------------------------------------------------------*)
(* Optimized reachability *)
(*------------------------------------------------------------*)
Expand Down
7 changes: 5 additions & 2 deletions src/lib/ParsingStructure.mli
Original file line number Diff line number Diff line change
Expand Up @@ -388,13 +388,16 @@ type parsed_property_type =
(* Global invariant *)
| Parsed_AG of parsed_state_predicate

(* Until *)
(* Exists until *)
| Parsed_EU of parsed_state_predicate * parsed_state_predicate

(* Unavoidability *)
| Parsed_AF of parsed_state_predicate


(* Always until *)
| Parsed_AU of parsed_state_predicate * parsed_state_predicate


(*------------------------------------------------------------*)
(* Optimized reachability *)
(*------------------------------------------------------------*)
Expand Down
3 changes: 2 additions & 1 deletion src/lib/PropertyLexer.mll
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ rule token = parse
| "#synth" { CT_SYNTH }

(* Keywords for properties *)
| "A" { CT_A }
| "AccCycle" { CT_ACCEPTINGCYCLE }
| "AcceptingCycle" { CT_ACCEPTINGCYCLE }
| "AccLoop" { CT_ACCEPTINGCYCLE }
| "AcceptingLoop" { CT_ACCEPTINGCYCLE }
| "AF" { CT_AF }
| "AG" { CT_AG }
| "AGnot" { CT_AGnot }
| "DeadlockFree" { CT_DEADLOCKFREE }
| "BCcover" { CT_COVERCARTOGRAPHY }
| "BClearn" { CT_BCLEARN }
| "BCshuffle" { CT_BCSHUFFLE }
Expand All @@ -61,6 +61,7 @@ rule token = parse
| "BCrandomseq" { CT_BCRANDOMSEQ }
| "Cycle" { CT_INFCYCLE }
| "CycleThrough" { CT_INFCYCLETHROUGH }
| "DeadlockFree" { CT_DEADLOCKFREE }
| "EF" { CT_EF }
| "E" { CT_E }
| "EFpmax" { CT_EFpmax }
Expand Down
7 changes: 5 additions & 2 deletions src/lib/PropertyParser.mly
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ let resolve_property l =
%token COLON COMMA DOUBLEDOT SEMICOLON SYMBOL_AND SYMBOL_OR

%token
CT_ACCEPTING CT_ACCEPTINGCYCLE CT_AF CT_AG CT_AGnot CT_ALWAYS
CT_A CT_ACCEPTING CT_ACCEPTINGCYCLE CT_AF CT_AG CT_AGnot CT_ALWAYS
CT_BCBORDER CT_BCLEARN CT_BCRANDOM CT_BCRANDOMSEQ CT_BCSHUFFLE CT_BEFORE
CT_COVERCARTOGRAPHY
CT_DEADLOCKFREE
Expand Down Expand Up @@ -145,12 +145,15 @@ property:
/* Global invariant */
| CT_AG state_predicate { Parsed_AG $2 }

/* Until */
/* Exists until */
| CT_E state_predicate CT_U state_predicate { Parsed_EU ($2, $4) }

/* Unavoidability */
| CT_AF state_predicate { Parsed_AF $2 }

/* Always until */
| CT_A state_predicate CT_U state_predicate { Parsed_AU ($2, $4) }


/*------------------------------------------------------------*/
/* Optimized reachability */
Expand Down

0 comments on commit 5c97413

Please sign in to comment.