Skip to content

Commit 5f654b4

Browse files
author
Jérôme FERET
committed
project away the Boolean parameters for removed rules
1 parent 960e849 commit 5f654b4

22 files changed

Lines changed: 420 additions & 23 deletions

core/KaSa_rep/export/export.ml

Lines changed: 133 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2545,39 +2545,39 @@ functor
25452545
let state = set_errors errors state in
25462546
state, id_opt
25472547
2548-
let permanently_disable_rule_c_id_list list state =
2549-
let state, l =
2548+
let permanently_disable_rule_c_id_list list state acc =
2549+
let state, l, l' =
25502550
List.fold_left
2551-
(fun (state, l) index ->
2551+
(fun (state, l, l') index ->
25522552
let state, id_opt = working_set_id_of_rule_id index state in
25532553
match id_opt with
2554-
| None -> state, l
2555-
| Some i -> state, i :: l)
2556-
(state, []) (List.rev list)
2554+
| None -> state, l, l'
2555+
| Some i -> state, i :: l, i::l')
2556+
(state, acc, []) (List.rev list)
25572557
in
25582558
let error = get_errors state in
25592559
let error, state, _ =
2560-
toggle_working_set_boolean_parameters_in_compilation error false state l
2560+
toggle_working_set_boolean_parameters_in_compilation error false state l'
25612561
true
25622562
in
2563-
set_errors error state
2563+
set_errors error state, l
25642564
2565-
let permanently_disable_init_c_id_list list state =
2566-
let state, l =
2565+
let permanently_disable_init_c_id_list list state acc =
2566+
let state, l, l' =
25672567
List.fold_left
2568-
(fun (state, l) index ->
2568+
(fun (state, l, l') index ->
25692569
let state, id_opt = working_set_id_of_init_id index state in
25702570
match id_opt with
2571-
| None -> state, l
2572-
| Some i -> state, i :: l)
2573-
(state, []) (List.rev list)
2571+
| None -> state, l, l'
2572+
| Some i -> state, i :: l, i::l')
2573+
(state, acc,[]) (List.rev list)
25742574
in
25752575
let error = get_errors state in
25762576
let error, state, _ =
2577-
toggle_working_set_boolean_parameters_in_compilation error false state l
2577+
toggle_working_set_boolean_parameters_in_compilation error false state l'
25782578
true
25792579
in
2580-
set_errors error state
2580+
set_errors error state, l
25812581
25822582
(* Incremental analysis *)
25832583
let summarize_from_ast state =
@@ -2622,6 +2622,118 @@ functor
26222622
(Remanent_state.set_handler handler state),
26232623
state' )
26242624
2625+
2626+
(* let state, c_compil = get_c_compilation state in
2627+
let rec toggle_parameters = function
2628+
| [] ->
2629+
( error,
2630+
compilation.Ast.working_set_values,
2631+
c_compil.Cckappa_sig.working_set_valuations,
2632+
false )
2633+
| working_set_index :: indexes ->
2634+
let error, working_set_values, working_set_valuations, changed =
2635+
toggle_parameters indexes
2636+
in
2637+
let guard_int =
2638+
Ckappa_sig.int_of_working_set_index working_set_index
2639+
in
2640+
(match Mods.IntMap.find_option guard_int working_set_values with
2641+
| None ->
2642+
if permanently_disable then
2643+
error, working_set_values, working_set_valuations, changed
2644+
else (
2645+
let error, () =
2646+
Exception.warn parameters error __POS__
2647+
~message:
2648+
("Index out of bounds: there is no rule with index "
2649+
^ Ckappa_sig.string_of_working_set_index working_set_index
2650+
^ " in the working set. Or it may already have been \
2651+
permanently disabled.")
2652+
Exit ()
2653+
in
2654+
error, working_set_values, working_set_valuations, false
2655+
)
2656+
| Some old_bool ->
2657+
if old_bool = bool && not permanently_disable then
2658+
error, working_set_values, working_set_valuations, changed
2659+
else (
2660+
let working_set_values =
2661+
if permanently_disable then
2662+
Mods.IntMap.add guard_int None working_set_values
2663+
else
2664+
Mods.IntMap.add guard_int bool working_set_values
2665+
in
2666+
let error, (guard_id, _) =
2667+
Ckappa_sig.Ws_index_map_and_set.Map.find_default parameters
2668+
error
2669+
(Ckappa_sig.guard_parameter_of_int (-1), Some false)
2670+
working_set_index working_set_valuations
2671+
in
2672+
let error, working_set_valuations =
2673+
Ckappa_sig.Ws_index_map_and_set.Map.add_or_overwrite parameters
2674+
error working_set_index (guard_id, bool)
2675+
working_set_valuations
2676+
in
2677+
error, working_set_values, working_set_valuations, true
2678+
))
2679+
in
2680+
*)
2681+
let permanently_remove l state =
2682+
let state, c_compil = get_c_compilation state in
2683+
let errors = get_errors state in
2684+
let parameters = get_parameters state in
2685+
let state, kappa_handler = get_handler state in
2686+
let map = c_compil.Cckappa_sig.working_set_valuations in
2687+
let errors, l = List.fold_left
2688+
(fun (errors, l) elt ->
2689+
let errors, (id,_) = Ckappa_sig.Ws_index_map_and_set.Map.find_default parameters
2690+
errors
2691+
(Ckappa_sig.guard_parameter_of_int (-1), Some false)
2692+
elt map in
2693+
errors, (Ckappa_sig.mvbdu_var_of_guard id (Handler.get_nsites kappa_handler))::l)
2694+
(errors, []) l
2695+
in
2696+
let l = List.sort compare l in
2697+
let state =set_errors errors state in
2698+
let state =
2699+
match Remanent_state.get_reachability_result state with
2700+
| None -> state
2701+
| Some x ->
2702+
let bdu_handler = Remanent_state.get_bdu_handler state in
2703+
let errors = get_errors state in
2704+
let errors, bdu_handler, l = Ckappa_sig.Views_bdu.build_variables_list parameters bdu_handler errors l in
2705+
let state = Remanent_state.set_bdu_handler bdu_handler state in
2706+
let state = set_errors errors state in
2707+
let errors, (a,b) = Reachability.map_mvbdu
2708+
(fun parameters errors bdu_handler mvbdu -> Ckappa_sig.Views_bdu.mvbdu_definitely_remove parameters bdu_handler errors mvbdu l ) errors (snd (fst x)) (snd x) in
2709+
let state = Remanent_state.set_reachability_result ((fst (fst x),a),b) state in
2710+
set_errors errors state in
2711+
state
2712+
2713+
(* contact_map_int: Contact_map.t option option;
2714+
init_state: initial_state option;
2715+
quark_map: quark_map option;
2716+
reachability_state:
2717+
('global_static, 'static, 'dynamic) reachability_result option;
2718+
is_reachability_result_available: bool;
2719+
subviews_info: subviews_info option;
2720+
dead_rules: dead_rules option;
2721+
conditionally_dead_rules: rule_deadness_conditions option;
2722+
dead_agents: dead_agents option;
2723+
conditionally_dead_agents: agent_deadness_conditions option;
2724+
ode_flow: Ode_fragmentation_type.ode_frag option;
2725+
ctmc_flow: flow option;
2726+
errors: Exception.exceptions_caught_and_uncaught;
2727+
internal_constraint_list: internal_constraint_list option;
2728+
constraint_list: constraint_list option;
2729+
symmetric_sites: symmetric_sites Public_data.AccuracyMap.t;
2730+
separating_transitions: separating_transitions option;
2731+
transition_system_length: int list option;
2732+
global_static_information: 'global_static option;
2733+
patch: Cckappa_sig.compil option;*)
2734+
2735+
2736+
26252737
let patch ?debug ?do_not_restart_fixpoint_computation ?do_we_show_title
26262738
~called_from ?compil ?patch_file_name ~old_file_name ~summary state =
26272739
let parameters = get_parameters state in
@@ -2689,15 +2801,16 @@ functor
26892801
let state = set_errors errors state in
26902802
let state = Remanent_state.set_handler kappa_handler state in
26912803
let state = rename_pos (Diff.renaming_of_diff diff) state in
2692-
let state =
2804+
let state, acc =
26932805
permanently_disable_rule_c_id_list
26942806
(List.rev_map Ckappa_sig.rule_id_of_int
26952807
(List.rev diff.Diff.diff_rules.removed_elt))
2696-
state
2808+
state []
26972809
in
2698-
let state =
2699-
permanently_disable_init_c_id_list diff.Diff.diff_init.removed_elt state
2810+
let state, acc =
2811+
permanently_disable_init_c_id_list diff.Diff.diff_init.removed_elt state acc
27002812
in
2813+
let state = permanently_remove acc state in
27012814
let state, handler = get_handler state in
27022815
let state, cc_compil = get_c_compilation state in
27032816
let errors = get_errors state in

core/KaSa_rep/more_datastructures/map_wrapper.ml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,15 @@ module type Map_with_logs = sig
356356
val fold : (elt -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b
357357
val mapi : (elt -> 'a -> 'b) -> 'a t -> 'b t
358358
val map : ('a -> 'b) -> 'a t -> 'b t
359+
val map_with_logs:
360+
Remanent_parameters_sig.parameters -> Exception.exceptions_caught_and_uncaught -> 'rem
361+
-> (
362+
Remanent_parameters_sig.parameters ->
363+
Exception.exceptions_caught_and_uncaught -> 'rem ->
364+
'a ->
365+
Exception.exceptions_caught_and_uncaught * 'rem * 'b) -> 'a t ->
366+
Exception.exceptions_caught_and_uncaught * 'rem * 'b t
367+
359368
val for_all : (elt -> 'a -> bool) -> 'a t -> bool
360369
val filter_one : (elt -> 'a -> bool) -> 'a t -> (elt * 'a) option
361370
val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int
@@ -454,7 +463,7 @@ module Make (S_both : SetMap.S) :
454463
let find_option_without_logs _a b c d = b, S_both.Map.find_option c d
455464
let find_default_without_logs _a b c d e = b, S_both.Map.find_default c d e
456465
let add a b c d = lift S_both.Map.add_with_logs a b c d
457-
466+
458467
let overwrite parameter error c d e =
459468
let error, bool, map =
460469
lift S_both.Map.add_while_testing_freshness parameter error c d e
@@ -495,6 +504,16 @@ module Make (S_both : SetMap.S) :
495504
(fun a b c d e () -> h a b c d e, ())
496505
mapf mapg ())
497506

507+
let map_with_logs (parameter:Remanent_parameters_sig.parameters)
508+
(error:Exception_without_parameter.exceptions_caught_and_uncaught) handler f map
509+
= let ((error:Exception_without_parameter.exceptions_caught_and_uncaught),handler),map =
510+
S_both.Map.map_with_logs
511+
(fun (p:Remanent_parameters_sig.parameters) (a,b) s s_opt exn ->
512+
let a = Exception.wrap p a s s_opt exn in (a,b)) parameter (error,handler)
513+
(fun a (b,b') c ->
514+
let a,b,c = f a b b' c in (a,b),c) map
515+
in (error:Exception_without_parameter.exceptions_caught_and_uncaught), handler, map
516+
498517
let fold2_sparse a b c = lift S_both.Map.fold2_sparse_with_logs a b c
499518
let iter2_sparse a b c = lift S_both.Map.iter2_sparse_with_logs a b c
500519
let diff a b c = lift S_both.Map.diff_with_logs a b c

core/KaSa_rep/more_datastructures/map_wrapper.mli

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,15 @@ module type Map_with_logs = sig
356356
val fold : (elt -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b
357357
val mapi : (elt -> 'a -> 'b) -> 'a t -> 'b t
358358
val map : ('a -> 'b) -> 'a t -> 'b t
359+
val map_with_logs:
360+
Remanent_parameters_sig.parameters -> Exception.exceptions_caught_and_uncaught -> 'rem ->
361+
(
362+
Remanent_parameters_sig.parameters ->
363+
Exception.exceptions_caught_and_uncaught -> 'rem ->
364+
'a ->
365+
Exception.exceptions_caught_and_uncaught * 'rem * 'b) -> 'a t ->
366+
Exception.exceptions_caught_and_uncaught * 'rem * 'b t
367+
359368
val for_all : (elt -> 'a -> bool) -> 'a t -> bool
360369
val filter_one : (elt -> 'a -> bool) -> 'a t -> (elt * 'a) option
361370
val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int

core/KaSa_rep/reachability_analysis/agents_domain.ml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -984,4 +984,31 @@ module Domain = struct
984984
}
985985
in
986986
error, dynamic, static
987-
end
987+
988+
let map_store_value parameters error handler f store_value =
989+
let error, (handler, store_value) =
990+
Ckappa_sig.Agent_type_nearly_Inf_Int_storage_Imperatif.fold
991+
parameters error
992+
(fun p e k data (handler, store_value) ->
993+
let e, handler, data' = f p e handler data in
994+
let e, store_value = Ckappa_sig.Agent_type_nearly_Inf_Int_storage_Imperatif.set p e k data' store_value in
995+
e, (handler, store_value))
996+
store_value
997+
(handler, store_value)
998+
in error, handler, store_value
999+
1000+
let map_mvbdu f errors static dynamic =
1001+
let parameters = get_parameter static in
1002+
let handler = get_mvbdu_handler dynamic in
1003+
let local = dynamic.local in
1004+
let errors, handler, agents_liveness =
1005+
map_store_value parameters errors handler f local.agents_liveness in
1006+
let local = {local with agents_liveness} in
1007+
let dynamic = {dynamic with local} in
1008+
let dynamic= set_mvbdu_handler handler dynamic in
1009+
errors, (static, dynamic)
1010+
1011+
end
1012+
1013+
1014+

core/KaSa_rep/reachability_analysis/analyzer.ml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,16 @@ module type Analyzer = sig
8686

8787
val set_bdu_handler :
8888
Ckappa_sig.Views_bdu.handler -> dynamic_information -> dynamic_information
89+
90+
val map_mvbdu:
91+
(Remanent_parameters_sig.parameters
92+
-> Exception.exceptions_caught_and_uncaught -> Ckappa_sig.Views_bdu.handler -> Ckappa_sig.Views_bdu.mvbdu -> Exception.exceptions_caught_and_uncaught * Ckappa_sig.Views_bdu.handler * Ckappa_sig.Views_bdu.mvbdu) ->
93+
Exception.exceptions_caught_and_uncaught
94+
->
95+
static_information ->
96+
dynamic_information
97+
-> Exception.exceptions_caught_and_uncaught * (static_information*
98+
dynamic_information)
8999
end
90100

91101
(***************************************************************************)
@@ -442,4 +452,10 @@ module Make (Domain : Composite_domain.Composite_domain) = struct
442452
let global = Domain.get_global_dynamic_information dynamic in
443453
let global = Analyzer_headers.set_mvbdu_handler h global in
444454
Domain.set_global_dynamic_information global dynamic
455+
456+
457+
let map_mvbdu f errors static dynamic =
458+
let error, (static, dynamic) = Domain.map_mvbdu f errors static dynamic in
459+
error, ((static), dynamic)
460+
445461
end

core/KaSa_rep/reachability_analysis/analyzer.mli

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,17 @@ module type Analyzer = sig
8686

8787
val set_bdu_handler :
8888
Ckappa_sig.Views_bdu.handler -> dynamic_information -> dynamic_information
89+
90+
val map_mvbdu:
91+
(Remanent_parameters_sig.parameters
92+
-> Exception.exceptions_caught_and_uncaught -> Ckappa_sig.Views_bdu.handler -> Ckappa_sig.Views_bdu.mvbdu -> Exception.exceptions_caught_and_uncaught * Ckappa_sig.Views_bdu.handler * Ckappa_sig.Views_bdu.mvbdu) ->
93+
Exception.exceptions_caught_and_uncaught
94+
->
95+
static_information ->
96+
dynamic_information
97+
-> Exception.exceptions_caught_and_uncaught * (static_information*
98+
dynamic_information)
99+
89100
end
90101

91102
module Make : functor (Domain : Composite_domain.Composite_domain) -> Analyzer

core/KaSa_rep/reachability_analysis/analyzer_domain_sig.ml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,4 +158,14 @@ module type Domain = sig
158158
Exception.exceptions_caught_and_uncaught * Ckappa_sig.side_effects option
159159

160160
val enable_or_disable_rule : (Cckappa_sig.compil, static_information) unary
161+
162+
val map_mvbdu:
163+
(Remanent_parameters_sig.parameters
164+
-> Exception.exceptions_caught_and_uncaught -> Ckappa_sig.Views_bdu.handler -> Ckappa_sig.Views_bdu.mvbdu -> Exception.exceptions_caught_and_uncaught * Ckappa_sig.Views_bdu.handler * Ckappa_sig.Views_bdu.mvbdu) ->
165+
Exception.exceptions_caught_and_uncaught
166+
->
167+
static_information ->
168+
dynamic_information
169+
-> Exception.exceptions_caught_and_uncaught * (static_information*
170+
dynamic_information)
161171
end

core/KaSa_rep/reachability_analysis/analyzer_domain_sig.mli

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,4 +159,14 @@ module type Domain = sig
159159
Exception.exceptions_caught_and_uncaught * Ckappa_sig.side_effects option
160160

161161
val enable_or_disable_rule : (Cckappa_sig.compil, static_information) unary
162+
163+
val map_mvbdu:
164+
(Remanent_parameters_sig.parameters
165+
-> Exception.exceptions_caught_and_uncaught -> Ckappa_sig.Views_bdu.handler -> Ckappa_sig.Views_bdu.mvbdu -> Exception.exceptions_caught_and_uncaught * Ckappa_sig.Views_bdu.handler * Ckappa_sig.Views_bdu.mvbdu) ->
166+
Exception.exceptions_caught_and_uncaught
167+
->
168+
static_information ->
169+
dynamic_information
170+
-> Exception.exceptions_caught_and_uncaught * (static_information*
171+
dynamic_information)
162172
end

core/KaSa_rep/reachability_analysis/composite_domain.ml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,16 @@ module type Composite_domain = sig
9898

9999
val get_parameters : static_information -> Remanent_parameters_sig.parameters
100100
val enable_or_disable_rule : (Cckappa_sig.compil, static_information) unary
101+
102+
val map_mvbdu:
103+
(Remanent_parameters_sig.parameters
104+
-> Exception.exceptions_caught_and_uncaught -> Ckappa_sig.Views_bdu.handler -> Ckappa_sig.Views_bdu.mvbdu -> Exception.exceptions_caught_and_uncaught * Ckappa_sig.Views_bdu.handler * Ckappa_sig.Views_bdu.mvbdu) ->
105+
Exception.exceptions_caught_and_uncaught
106+
->
107+
static_information ->
108+
dynamic_information
109+
-> Exception.exceptions_caught_and_uncaught * (static_information*
110+
dynamic_information)
101111
end
102112

103113
(****************************************************************************)
@@ -678,4 +688,16 @@ module Make (Domain : Analyzer_domain_sig.Domain) = struct
678688
error, dynamic, (static_global, static_domain)
679689

680690
let get_parameters (_, static_domain) = Domain.get_parameter static_domain
691+
692+
693+
let map_mvbdu f errors static dynamic =
694+
let errors, (dstatic, domain) =
695+
Domain.map_mvbdu f errors
696+
(get_domain_static_information static)
697+
(
698+
dynamic.domain)
699+
in
700+
errors, ((fst static, dstatic),
701+
({dynamic with domain}))
702+
681703
end

0 commit comments

Comments
 (0)