Core.EffectSourceEffects are a journal of all statements executed by the domains when computing a post-condition.
They are used to merge two post-conditions that diverged due to a fork-join trajectory in the abstraction DAG.
Fold over the statements in the effect
Effects are presented as binary trees. Each node of the tree is associated to a domain in the abstraction and stores the statements executed by the domain when computing a post-condition.
Note that this representation is also useful when we have an abstraction DAG (i.e. when there are shared domains) thanks to the compose (stack) operator:
A x B \___/ | C
is represented as:
o / \ x C / \ A B
mk_teffect effect left right creates an effect tree with a root containing effect and having left and right as the two sub-trees
get_right_teffect te returns the right sub-tree of te
get_log_stmts te returns the effect at the root node of te
get_left_teffect left te sets left as the left sub-tree of te
get_right_teffect right te sets right as the right sub-tree of te
map_left_teffect f te is equivalent to set_left_teffect (f (get_left_teffect te)) te
map_right_teffect f te is equivalent to set_right_teffect (f (get_right_teffect te)) te
add_stmt_to_teffect stmt teffect adds stmt to the the effects of the root no of te
val merge_teffect :
(effect -> effect) ->
(effect -> effect) ->
(effect -> effect -> effect) ->
teffect ->
teffect ->
teffectmerge_teffect f1 f2 f te1 te2 combines te1 and te2
concat_teffect old recent puts effects in old before those in recent
merge_teffect te1 te2 computes the effects of two intersected post-states
merge_teffect te1 te2 computes the effects of two joined post-states
Fold over the statements in the effects tree
Effect of a statement in terms of modified and removed variables
val generic_merge :
add:(Ast.Var.var -> 'b -> 'a -> 'a) ->
find:(Ast.Var.var -> 'a -> 'b) ->
remove:(Ast.Var.var -> 'a -> 'a) ->
?custom:(Ast.Stmt.stmt -> var_effect option) ->
('a * effect) ->
('a * effect) ->
'a * 'aGeneric merge operator. generic_merge ~add ~find ~remove ~custom (a1,e1) (a2,e2) applies a generic merge of states a1 and a2:
find and adds them to the other state using add.remove. This function handles common statements (assign,assume,add,remove,fold,expand and rename). Other statements can be handled using the custom function that returns the var_effect of a given statement.