@@ -496,11 +496,10 @@ let lift_ss_inv2 (f: ss_inv -> ss_inv -> 'a) : inv -> inv -> 'a =
496496
497497let lift_hs_ss_inv (f : ss_inv -> hs_inv -> 'a ) : inv -> inv -> 'a =
498498 let f inv1 inv2 = match inv1, inv2 with
499- | Inv_ss ss1 , Inv_hs ss2 -> f ss1 ss2
500- | _ -> failwith " expected only single sided invariants" in
499+ | Inv_ss ss_inv , Inv_hs hs_inv -> f ss_inv hs_inv
500+ | _ -> failwith " expected single sided invariants and hoare invariant " in
501501 f
502502
503-
504503let lift_ss_inv3 (f : ss_inv -> ss_inv -> ss_inv -> 'a ) : inv -> inv -> inv -> 'a =
505504 let f inv1 inv2 inv3 = match inv1, inv2, inv3 with
506505 | Inv_ss ss1 , Inv_ss ss2 , Inv_ss ss3 -> f ss1 ss2 ss3
@@ -537,15 +536,15 @@ let map_inv (fn: form list -> form) (inv: inv list): inv =
537536 Inv_ts (map_ts_inv fn (List. map (function
538537 Inv_ts ts -> assert (ts.ml = ts'.ml && ts.mr = ts'.mr); ts
539538 | _ -> failwith " expected all invariants to have same kind" ) inv))
540- | _ -> failwith " Patch Inv_hs "
539+ | _ -> failwith " Exceptions are not supported "
541540
542541let map_inv1 (fn : form -> form ) (inv : inv ): inv =
543542 match inv with
544543 | Inv_ss ss ->
545544 Inv_ss (map_ss_inv1 fn ss)
546545 | Inv_ts ts ->
547- Inv_ts (map_ts_inv1 fn ts)
548- | _ -> failwith " Patch Inv_hs2 "
546+ Inv_ts (map_ts_inv1 fn ts)
547+ | _ -> failwith " Exceptions are not supported "
549548
550549let map_inv2 (fn : form -> form -> form ) (inv1 : inv ) (inv2 : inv ): inv =
551550 match inv1, inv2 with
@@ -604,9 +603,9 @@ let map2_poe f (p1,m1,d1) (p2,m2,d2) =
604603 | _ , _ -> failwith " missing entry in exception map"
605604 in
606605 let m = DMap. merge aux m1 m2 in
607- match d2, d1 with
606+ match d1, d2 with
608607 | None , None -> (p, m, None )
609- | Some d2 , Some d1 -> (p, m, Some (f d2 d1 ))
608+ | Some d1 , Some d2 -> (p, m, Some (f d1 d2 ))
610609 | _ , _ -> failwith " missing default exception"
611610
612611let map_hs_inv2
@@ -642,12 +641,38 @@ let iter_poe f (p, m,d) =
642641
643642let iter2_poe f (p1 ,m1 ,d1 ) (p2 ,m2 ,d2 ) =
644643 f p1 p2;
645- DMap. iter (fun e1 p1 -> f (DMap. find e1 m2) p1) m1;
644+ let aux _ a b =
645+ match a, b with
646+ | Some a , Some b -> Some (a,b)
647+ | _ , _ -> failwith " missing entry in exception map"
648+ in
649+ let m = DMap. merge aux m1 m2 in
650+ DMap. iter (fun _ (p1 ,p2 ) -> f p1 p2) m;
646651 match d2, d1 with
647652 | None , None -> ()
648- | Some d2 , Some d1 -> f d2 d1
653+ | Some d1 , Some d2 -> f d1 d2
649654 | _ , _ -> failwith " missing default exception"
650655
656+ let merge2_poe_list f (poe1 ,d1 ) (poe2 ,d2 ) =
657+ let get_default d =
658+ match d with
659+ | Some d -> d
660+ | None -> failwith " no default exception"
661+ in
662+ let aux _ a b =
663+ match a,b with
664+ | Some a , Some b -> Some (f b a)
665+ | Some a , None -> Some (f (get_default d2) a)
666+ | None , Some b -> Some (f b (get_default d1))
667+ | None , None -> assert false
668+ in
669+ let epost = DMap. merge aux poe1 poe2 in
670+ let poe = List. map snd ( DMap. bindings epost) in
671+ match d2, d1 with
672+ | None , _ -> poe
673+ | Some d2 , Some d1 -> f d2 d1 :: poe
674+ | _ , _ -> failwith " no default exception"
675+
651676(* ----------------------------------------------------------------- *)
652677(* Accessors for program logic *)
653678(* ----------------------------------------------------------------- *)
0 commit comments