Skip to content
Snippets Groups Projects
Commit b19195ad authored by Patrick Baudin's avatar Patrick Baudin
Browse files

[Wp] generic sequent simplifier: applies simplify+assume succesively on...

[Wp] generic sequent simplifier: applies simplify+assume succesively on eacterms of a the conjective hypothesis
parent 7a5a0eef
No related branches found
No related tags found
No related merge requests found
...@@ -880,28 +880,47 @@ and letify_case sigma ~target ~export seq = ...@@ -880,28 +880,47 @@ and letify_case sigma ~target ~export seq =
(* --- External Simplifier --- *) (* --- External Simplifier --- *)
(* -------------------------------------------------------------------------- *) (* -------------------------------------------------------------------------- *)
(* Simplify an expression. *)
let simplify_exp solvers e = let simplify_exp solvers e =
List.fold_left (fun e s -> s#simplify_exp e) e solvers List.fold_left (fun e s -> s#simplify_exp e) e solvers
(* Simplify the goal.
In any case must return a stronger formula. *)
let simplify_goal solvers p = let simplify_goal solvers p =
List.fold_left (fun p s -> s#simplify_goal p) p solvers List.fold_left (fun p s -> s#simplify_goal p) p solvers
(** Simplify an hypothesis before assuming it.
In any case must return a weaker formula. *)
let simplify_hyp solvers p = let simplify_hyp solvers p =
List.fold_left (fun p s -> s#simplify_hyp p) p solvers List.fold_left (fun p s -> s#simplify_hyp p) p solvers
(* Simplify a branch condition.
In any case must return an equivalent formula. *)
let simplify_branch solvers p = let simplify_branch solvers p =
List.fold_left (fun p s -> s#simplify_branch p) p solvers List.fold_left (fun p s -> s#simplify_branch p) p solvers
let apply_hyp modified solvers h = let apply_hyp modified solvers h =
let simple p = let weaken_and_then_assume p =
let p' = simplify_hyp solvers p in let p' = simplify_hyp solvers p in
if not (Lang.F.eqp p p') then modified := true; if not (Lang.F.eqp p p') then modified := true;
List.iter (fun s -> s#assume p') solvers; p' List.iter (fun s -> s#assume p') solvers; p'
in in
let weaken_hyp p = match F.p_expr p with
| And ps ->
let unmodified,qs = List.fold_left (fun (unmodified,qs) p ->
let p' = weaken_and_then_assume p in
(unmodified && (Lang.F.eqp p p')), (p'::qs))
(true,[]) ps
in if unmodified then p else p_conj qs
| _ -> weaken_and_then_assume p
in
match h.condition with match h.condition with
| State s -> update_cond h (State (Mstate.apply (simplify_exp solvers) s)) | State s -> update_cond h (State (Mstate.apply (simplify_exp solvers) s))
| Init p -> update_cond h (Init (simple p)) | Init p -> update_cond h (Init (weaken_hyp p))
| Type p -> update_cond h (Type (simple p)) | Type p -> update_cond h (Type (weaken_hyp p))
| Have p -> update_cond h (Have (simple p)) | Have p -> update_cond h (Have (weaken_hyp p))
| When p -> update_cond h (When (simple p)) | When p -> update_cond h (When (weaken_hyp p))
| Core p -> update_cond h (Core (simple p)) | Core p -> update_cond h (Core (weaken_hyp p))
| Branch(p,_,_) -> List.iter (fun s -> s#target p) solvers; h | Branch(p,_,_) -> List.iter (fun s -> s#target p) solvers; h
| Either _ -> h | Either _ -> h
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment