proposition: Theorem simplify'_correct : forall t p rm, interp_pos_atom p rm -> (interp_tree t rm <-> interp_tree (simplify' t p) rm).
proof: Proof. intros t p rm Hp. induction t as [| |cnj l Hl r Hr|a pos] ; try easy. simpl. destruct (simplify' l p) as [| |cnj' l' r'|a' pos']. simpl in Hl. apply <- iff_True in Hl. case cnj. intuition. apply -> iff_True. now left. apply <- iff_False in Hl. case cnj. apply -> iff_False. now intros (H,_). intuition. destruct (simplify' r p) as [| |cnj'' l'' r''|a'' pos'']. apply <- iff_True in Hr. case cnj. intuition. apply -> iff_True. now right. apply <- iff_False in Hr. case cnj. apply -> iff_False. now intros (_,H). intuition. replace (interp_tree (if cnj then Ttree true (Ttree cnj' l' r') (Ttree cnj'' l'' r'') else Ttree false (Ttree cnj' l' r') (Ttree cnj'' l'' r'')) rm) with ((if cnj then and else or) (interp_tree (Ttree cnj' l' r') rm) (interp_tree (Ttree cnj'' l'' r'') rm)) by now case cnj. case cnj ; intuition. replace (interp_tree (if cnj then Ttree true (Ttree cnj' l' r') (Tatom a'' pos'') else Ttree false (Ttree cnj' l' r') (Tatom a'' pos'')) rm) with ((if cnj then and else or) (interp_tree (Ttree cnj' l' r') rm) (interp_tree (Tatom a'' pos'') rm)) by now case cnj. case cnj ; intuition. destruct (simplify' r p) as [| |cnj'' l'' r''|a'' pos'']. apply <- iff_True in Hr. case cnj. intuition. apply -> iff_True. now right. apply <- iff_False in Hr. case cnj. apply -> iff_False. now intros (_,H). intuition. replace (interp_tree (if cnj then Ttree true (Tatom a' pos') (Ttree cnj'' l'' r'') else Ttree false (Tatom a' pos') (Ttree cnj'' l'' r'')) rm) with ((if cnj then and else or) (interp_tree (Tatom a' pos') rm) (interp_tree (Ttree cnj'' l'' r'') rm)) by now case cnj. case cnj ; intuition. replace (interp_tree (if cnj then Ttree true (Tatom a' pos') (Tatom a'' pos'') else Ttree false (Tatom a' pos') (Tatom a'' pos'')) rm) with ((if cnj then and else or) (interp_tree (Tatom a' pos') rm) (interp_tree (Tatom a'' pos'') rm)) by now case cnj. case cnj ; intuition. simpl. generalize (relate_correct p pos a rm Hp). case relate ; intros H. now apply -> iff_True. now apply -> iff_False. easy. Qed.
imports: Reals List Bool Gappa_common