Skip to content

Commit abfb1c6

Browse files
committed
changed type of bdu to an int type whose first n numbers represent the guards and the remaining numbers represent the sites
1 parent 63e0d7e commit abfb1c6

16 files changed

+1030
-693
lines changed

core/KaSa_rep/backend/ckappa_site_graph.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,5 @@ val internal_pair_list_to_list :
4343
Ckappa_sig.c_site_name ->
4444
Site_graphs.KaSa_site_graph.agent_id ->
4545
Ckappa_sig.c_site_name ->
46-
(Ckappa_sig.c_site_name * Ckappa_sig.c_state) list list ->
46+
(Ckappa_sig.c_guard_p_then_site * Ckappa_sig.c_state) list list ->
4747
Exception.exceptions_caught_and_uncaught * Site_graphs.KaSa_site_graph.t list

core/KaSa_rep/frontend/cckappa_sig.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ type kappa_handler = {
2424
nrules: int;
2525
nvars: int;
2626
nagents: Ckappa_sig.c_agent_name;
27+
nguard_params: int;
2728
agents_dic: Ckappa_sig.agent_dic;
2829
agents_annotation:
2930
(string * Loc.t list)

core/KaSa_rep/frontend/cckappa_sig.mli

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ type kappa_handler = {
2424
nrules: int;
2525
nvars: int;
2626
nagents: Ckappa_sig.c_agent_name;
27+
nguard_params: int;
2728
agents_dic: Ckappa_sig.agent_dic;
2829
agents_annotation:
2930
(string * Loc.t list)

core/KaSa_rep/frontend/ckappa_sig.ml

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ type binding_state = Free | Lnk_type of agent_name * site_name
3434
type c_guard_parameter = int
3535
type c_site_or_guard_p = Site of c_site_name | Guard_p of c_guard_parameter
3636

37+
type c_guard_p_then_site =
38+
int (*the first n elements are guards, the last ones are sites*)
39+
3740
type mixture =
3841
| SKIP of mixture
3942
| COMMA of agent * mixture
@@ -192,8 +195,30 @@ let state_index_of_int (a : int) : c_state = a
192195
let int_of_state_index (a : c_state) : int = a
193196
let string_of_state_index (a : c_state) : string = string_of_int a
194197
let guard_parameter_of_int (a : int) : c_guard_parameter = a
198+
let guard_p_then_site_of_int (a : int) : c_guard_p_then_site = a
199+
let int_of_guard_p_then_site (a : c_guard_p_then_site) : int = a
200+
201+
let guard_p_then_site_of_site (a : c_site_name) (nr_guard_p : int) :
202+
c_guard_p_then_site =
203+
guard_parameter_of_int (int_of_site_name a + nr_guard_p)
204+
205+
let guard_p_then_site_of_guard (a : c_guard_parameter) : c_guard_p_then_site = a
206+
207+
let guard_p_then_site_of_site_or_guard_p (a : c_site_or_guard_p)
208+
(nr_guard_p : int) : c_guard_p_then_site =
209+
match a with
210+
| Site s -> guard_p_then_site_of_site s nr_guard_p
211+
| Guard_p s -> guard_p_then_site_of_guard s
212+
195213
let int_of_guard_parameter (a : c_guard_parameter) : int = a
196214

215+
let site_or_guard_p_of_guard_p_then_site (a : c_guard_p_then_site)
216+
(nr_guard_p : int) : c_site_or_guard_p =
217+
if a < nr_guard_p then
218+
Guard_p a
219+
else
220+
Site (a - nr_guard_p)
221+
197222
let string_of_state_index_option_min parameters a =
198223
match a with
199224
| Some a -> string_of_state_index a
@@ -843,6 +868,13 @@ module Site_map_and_set = Map_wrapper.Make (SetMap.Make (struct
843868
let print = Format.pp_print_int
844869
end))
845870

871+
module GuardSite_map_and_set = Map_wrapper.Make (SetMap.Make (struct
872+
type t = c_guard_p_then_site
873+
874+
let compare = compare
875+
let print = Format.pp_print_int
876+
end))
877+
846878
type c_interface = c_port Site_map_and_set.Map.t
847879

848880
type c_proper_agent = {
@@ -932,6 +964,7 @@ let next_rule_id = succ
932964
let next_agent_id = succ
933965
let next_agent_name = succ
934966
let next_site_name = succ
967+
let next_guard_or_site_name = succ
935968
let next_state_index = succ
936969
let compare_rule_id = compare
937970
let compare_agent_id = compare
@@ -1002,6 +1035,12 @@ module Agent_type_site_nearly_Inf_Int_Int_storage_Imperatif_Imperatif :
10021035
and type dimension = int * int =
10031036
Int_storage.Nearly_Inf_Int_Int_storage_Imperatif_Imperatif
10041037

1038+
module Agent_type_guard_or_site_nearly_Inf_Int_Int_storage_Imperatif_Imperatif :
1039+
Int_storage.Storage
1040+
with type key = c_agent_name * c_guard_p_then_site
1041+
and type dimension = int * int =
1042+
Int_storage.Nearly_Inf_Int_Int_storage_Imperatif_Imperatif
1043+
10051044
module Agent_type_site_quick_nearly_Inf_Int_Int_storage_Imperatif_Imperatif :
10061045
Int_storage.Storage
10071046
with type key = c_agent_name * c_site_name
@@ -1024,6 +1063,13 @@ module Site_type_quick_nearly_Inf_Int_storage_Imperatif :
10241063
Int_storage.Storage with type key = c_site_name and type dimension = int =
10251064
Int_storage.Quick_key_list (Site_type_nearly_Inf_Int_storage_Imperatif)
10261065

1066+
(*guard parameters or site: the first n indexes are the guards, and the remaining are the sites*)
1067+
module GuardPOrSite_nearly_Inf_Int_storage_Imperatif :
1068+
Int_storage.Storage
1069+
with type key = c_guard_p_then_site
1070+
and type dimension = int =
1071+
Int_storage.Nearly_inf_Imperatif
1072+
10271073
(*state*)
10281074
module State_index_nearly_Inf_Int_storage_Imperatif :
10291075
Int_storage.Storage with type key = c_state and type dimension = int =
@@ -1252,7 +1298,7 @@ end))
12521298

12531299
module Views_bdu :
12541300
Mvbdu_wrapper.Mvbdu
1255-
with type key = c_site_name
1301+
with type key = c_guard_p_then_site
12561302
and type value = c_state
12571303
with type mvbdu = Mvbdu_wrapper.Mvbdu.mvbdu =
12581304
Mvbdu_wrapper.Mvbdu

core/KaSa_rep/frontend/ckappa_sig.mli

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ type c_link_value
3434
type c_counter_name
3535
type c_guard_parameter
3636
type c_site_or_guard_p = Site of c_site_name | Guard_p of c_guard_parameter
37+
type c_guard_p_then_site
3738

3839
(****************************************************************************)
3940

@@ -55,8 +56,8 @@ val dummy_link_value : c_link_value
5556
val dummy_site_name_1 : c_site_name
5657
val dummy_site_name_minus1 : c_site_name
5758
val next_link_value : c_link_value -> c_link_value
58-
val fst_site : c_site_name
59-
val snd_site : c_site_name
59+
val fst_site : c_guard_p_then_site (*rTODO maybe add nr_guard_params?*)
60+
val snd_site : c_guard_p_then_site
6061
val dummy_state_index_1 : c_state
6162
val string_of_agent_name : c_agent_name -> string
6263
val int_of_agent_name : c_agent_name -> int
@@ -70,8 +71,19 @@ val state_index_of_int : int -> c_state
7071
val int_of_state_index : c_state -> int
7172
val string_of_state_index : c_state -> string
7273
val guard_parameter_of_int : int -> c_guard_parameter
74+
val guard_p_then_site_of_int : int -> c_guard_p_then_site
75+
val int_of_guard_p_then_site : c_guard_p_then_site -> int
76+
val guard_p_then_site_of_site : c_site_name -> int -> c_guard_p_then_site
77+
val guard_p_then_site_of_guard : c_guard_parameter -> c_guard_p_then_site
78+
79+
val guard_p_then_site_of_site_or_guard_p :
80+
c_site_or_guard_p -> int -> c_guard_p_then_site
81+
7382
val int_of_guard_parameter : c_guard_parameter -> int
7483

84+
val site_or_guard_p_of_guard_p_then_site :
85+
c_guard_p_then_site -> int -> c_site_or_guard_p
86+
7587
val string_of_state_index_option_min :
7688
Remanent_parameters_sig.parameters -> c_state option -> string
7789

@@ -91,6 +103,7 @@ val next_agent_id : c_agent_id -> c_agent_id
91103
val next_agent_name : c_agent_name -> c_agent_name
92104
val next_rule_id : c_rule_id -> c_rule_id
93105
val next_site_name : c_site_name -> c_site_name
106+
val next_guard_or_site_name : c_guard_p_then_site -> c_guard_p_then_site
94107
val next_state_index : c_state -> c_state
95108
val pred_site_name : c_site_name -> c_site_name
96109
val pred_agent_name : c_agent_name -> c_agent_name
@@ -375,6 +388,9 @@ module SiteOrGuard_map_and_set :
375388

376389
module Site_map_and_set : Map_wrapper.S_with_logs with type elt = c_site_name
377390

391+
module GuardSite_map_and_set :
392+
Map_wrapper.S_with_logs with type elt = c_guard_p_then_site
393+
378394
type c_interface = c_port Site_map_and_set.Map.t
379395

380396
type c_proper_agent = {
@@ -485,6 +501,11 @@ module Agent_type_site_nearly_Inf_Int_Int_storage_Imperatif_Imperatif :
485501
with type key = c_agent_name * c_site_name
486502
and type dimension = int * int
487503

504+
module Agent_type_guard_or_site_nearly_Inf_Int_Int_storage_Imperatif_Imperatif :
505+
Int_storage.Storage
506+
with type key = c_agent_name * c_guard_p_then_site
507+
and type dimension = int * int
508+
488509
module Agent_type_site_quick_nearly_Inf_Int_Int_storage_Imperatif_Imperatif :
489510
Int_storage.Storage
490511
with type key = c_agent_name * c_site_name
@@ -501,6 +522,11 @@ module Site_type_nearly_Inf_Int_storage_Imperatif :
501522
module Site_type_quick_nearly_Inf_Int_storage_Imperatif :
502523
Int_storage.Storage with type key = c_site_name and type dimension = int
503524

525+
module GuardPOrSite_nearly_Inf_Int_storage_Imperatif :
526+
Int_storage.Storage
527+
with type key = c_guard_p_then_site
528+
and type dimension = int
529+
504530
module State_index_nearly_Inf_Int_storage_Imperatif :
505531
Int_storage.Storage with type key = c_state and type dimension = int
506532

@@ -586,7 +612,9 @@ module AgentsSitePState_map_and_set :
586612
with type elt = c_agent_id * c_agent_name * c_site_name * pair_of_states
587613

588614
module Views_bdu :
589-
Mvbdu_wrapper.Mvbdu with type key = c_site_name and type value = c_state
615+
Mvbdu_wrapper.Mvbdu
616+
with type key = c_guard_p_then_site
617+
and type value = c_state
590618

591619
module Views_intbdu :
592620
Mvbdu_wrapper.Internalized_mvbdu

core/KaSa_rep/frontend/handler.ml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ let local_trace = false
1616
let nrules _parameter _error handler = handler.Cckappa_sig.nrules
1717
let nvars _parameter _error handler = handler.Cckappa_sig.nvars
1818
let nagents _parameter _error handler = handler.Cckappa_sig.nagents
19+
let get_nr_guard_parameters handler = handler.Cckappa_sig.nguard_params
1920

2021
let check_pos parameter ka_pos ml_pos message error error' =
2122
match ml_pos with
@@ -620,6 +621,19 @@ let string_of_site_contact_map ?(ml_pos = None) ?(ka_pos = None) ?(message = "")
620621
in
621622
error, print_site_contact_map site_type
622623

624+
let string_of_site_or_guard_contact_map ?(ml_pos = None) ?(ka_pos = None)
625+
?(message = "") parameter error handler_kappa agent_name site_or_guard_int =
626+
let nr_guard_params = get_nr_guard_parameters handler_kappa in
627+
match
628+
Ckappa_sig.site_or_guard_p_of_guard_p_then_site site_or_guard_int
629+
nr_guard_params
630+
with
631+
| Ckappa_sig.Site s ->
632+
string_of_site_contact_map ~ml_pos ~ka_pos ~message parameter error
633+
handler_kappa agent_name s
634+
| Ckappa_sig.Guard_p g ->
635+
string_of_guard g handler_kappa.Cckappa_sig.guard_parameters error
636+
623637
let print_labels parameters error handler couple =
624638
let _ = Quark_type.Labels.dump_couple parameters error handler couple in
625639
error

core/KaSa_rep/frontend/handler.mli

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,17 @@ val string_of_site_contact_map :
249249
Ckappa_sig.c_site_name ->
250250
Exception_without_parameter.exceptions_caught_and_uncaught * string
251251

252+
val string_of_site_or_guard_contact_map :
253+
?ml_pos:(string * int * int * int) option ->
254+
?ka_pos:Loc.t option ->
255+
?message:string ->
256+
Remanent_parameters_sig.parameters ->
257+
Exception_without_parameter.exceptions_caught_and_uncaught ->
258+
Cckappa_sig.kappa_handler ->
259+
Quark_type.agent_quark ->
260+
Ckappa_sig.c_guard_p_then_site ->
261+
Exception_without_parameter.exceptions_caught_and_uncaught * string
262+
252263
val string_of_site_in_natural_language :
253264
Remanent_parameters_sig.parameters ->
254265
Exception_without_parameter.exceptions_caught_and_uncaught ->

core/KaSa_rep/frontend/list_tokens.ml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ let empty_handler parameters error =
5353
Cckappa_sig.nvars = 0;
5454
Cckappa_sig.nagents = Ckappa_sig.dummy_agent_name;
5555
Cckappa_sig.nrules = 0;
56+
Cckappa_sig.nguard_params = 0;
5657
Cckappa_sig.agents_dic = Ckappa_sig.Dictionary_of_agents.init ();
5758
Cckappa_sig.agents_annotation = agent_annotation;
5859
Cckappa_sig.interface_constraints = int_constraints;
@@ -506,8 +507,16 @@ let scan_compil parameters error compil =
506507
let remanent =
507508
scan_perts scan_tested_mixture parameters remanent compil.Ast.perturbations
508509
in
509-
let remanent =
510+
let error, remanent =
510511
scan_rules scan_tested_mixture parameters remanent compil.Ast.rules
511512
in
513+
let remanent =
514+
( error,
515+
{
516+
remanent with
517+
Cckappa_sig.nguard_params =
518+
List.length remanent.Cckappa_sig.guard_parameters;
519+
} )
520+
in
512521
let remanent = reverse_agents_annotation parameters remanent in
513522
remanent

0 commit comments

Comments
 (0)