Require terminaison. Require Relations. Require term. Require List. Require equational_theory. Require rpo_extension. Require equational_extension. Require closure_extension. Require term_extension. Require dp. Require Inclusion. Require or_ext_generated. Require ZArith. Require ring_extention. Require Zwf. Require Inverse_Image. Require matrix. Require more_list_extention. Import List. Import ZArith. Set Implicit Arguments. Module algebra. Module F <:term.Signature. Inductive symb : Set := (* id_active *) | id_active : symb (* id_X *) | id_X : symb (* id_c *) | id_c : symb (* id_mark *) | id_mark : symb (* id_ok *) | id_ok : symb (* id_start *) | id_start : symb (* id_f *) | id_f : symb (* id_proper *) | id_proper : symb (* id_check *) | id_check : symb (* id_top *) | id_top : symb (* id_found *) | id_found : symb (* id_match *) | id_match : symb . Definition symb_eq_bool (f1 f2:symb) : bool := match f1,f2 with | id_active,id_active => true | id_X,id_X => true | id_c,id_c => true | id_mark,id_mark => true | id_ok,id_ok => true | id_start,id_start => true | id_f,id_f => true | id_proper,id_proper => true | id_check,id_check => true | id_top,id_top => true | id_found,id_found => true | id_match,id_match => true | _,_ => false end. (* Proof of decidability of equality over symb *) Definition symb_eq_bool_ok(f1 f2:symb) : match symb_eq_bool f1 f2 with | true => f1 = f2 | false => f1 <> f2 end. Proof. intros f1 f2. refine match f1 as u1,f2 as u2 return match symb_eq_bool u1 u2 return Prop with | true => u1 = u2 | false => u1 <> u2 end with | id_active,id_active => refl_equal _ | id_X,id_X => refl_equal _ | id_c,id_c => refl_equal _ | id_mark,id_mark => refl_equal _ | id_ok,id_ok => refl_equal _ | id_start,id_start => refl_equal _ | id_f,id_f => refl_equal _ | id_proper,id_proper => refl_equal _ | id_check,id_check => refl_equal _ | id_top,id_top => refl_equal _ | id_found,id_found => refl_equal _ | id_match,id_match => refl_equal _ | _,_ => _ end;intros abs;discriminate. Defined. Definition arity (f:symb) := match f with | id_active => term.Free 1 | id_X => term.Free 0 | id_c => term.Free 0 | id_mark => term.Free 1 | id_ok => term.Free 1 | id_start => term.Free 1 | id_f => term.Free 1 | id_proper => term.Free 1 | id_check => term.Free 1 | id_top => term.Free 1 | id_found => term.Free 1 | id_match => term.Free 2 end. Definition symb_order (f1 f2:symb) : bool := match f1,f2 with | id_active,id_active => true | id_active,id_X => false | id_active,id_c => false | id_active,id_mark => false | id_active,id_ok => false | id_active,id_start => false | id_active,id_f => false | id_active,id_proper => false | id_active,id_check => false | id_active,id_top => false | id_active,id_found => false | id_active,id_match => false | id_X,id_active => true | id_X,id_X => true | id_X,id_c => false | id_X,id_mark => false | id_X,id_ok => false | id_X,id_start => false | id_X,id_f => false | id_X,id_proper => false | id_X,id_check => false | id_X,id_top => false | id_X,id_found => false | id_X,id_match => false | id_c,id_active => true | id_c,id_X => true | id_c,id_c => true | id_c,id_mark => false | id_c,id_ok => false | id_c,id_start => false | id_c,id_f => false | id_c,id_proper => false | id_c,id_check => false | id_c,id_top => false | id_c,id_found => false | id_c,id_match => false | id_mark,id_active => true | id_mark,id_X => true | id_mark,id_c => true | id_mark,id_mark => true | id_mark,id_ok => false | id_mark,id_start => false | id_mark,id_f => false | id_mark,id_proper => false | id_mark,id_check => false | id_mark,id_top => false | id_mark,id_found => false | id_mark,id_match => false | id_ok,id_active => true | id_ok,id_X => true | id_ok,id_c => true | id_ok,id_mark => true | id_ok,id_ok => true | id_ok,id_start => false | id_ok,id_f => false | id_ok,id_proper => false | id_ok,id_check => false | id_ok,id_top => false | id_ok,id_found => false | id_ok,id_match => false | id_start,id_active => true | id_start,id_X => true | id_start,id_c => true | id_start,id_mark => true | id_start,id_ok => true | id_start,id_start => true | id_start,id_f => false | id_start,id_proper => false | id_start,id_check => false | id_start,id_top => false | id_start,id_found => false | id_start,id_match => false | id_f,id_active => true | id_f,id_X => true | id_f,id_c => true | id_f,id_mark => true | id_f,id_ok => true | id_f,id_start => true | id_f,id_f => true | id_f,id_proper => false | id_f,id_check => false | id_f,id_top => false | id_f,id_found => false | id_f,id_match => false | id_proper,id_active => true | id_proper,id_X => true | id_proper,id_c => true | id_proper,id_mark => true | id_proper,id_ok => true | id_proper,id_start => true | id_proper,id_f => true | id_proper,id_proper => true | id_proper,id_check => false | id_proper,id_top => false | id_proper,id_found => false | id_proper,id_match => false | id_check,id_active => true | id_check,id_X => true | id_check,id_c => true | id_check,id_mark => true | id_check,id_ok => true | id_check,id_start => true | id_check,id_f => true | id_check,id_proper => true | id_check,id_check => true | id_check,id_top => false | id_check,id_found => false | id_check,id_match => false | id_top,id_active => true | id_top,id_X => true | id_top,id_c => true | id_top,id_mark => true | id_top,id_ok => true | id_top,id_start => true | id_top,id_f => true | id_top,id_proper => true | id_top,id_check => true | id_top,id_top => true | id_top,id_found => false | id_top,id_match => false | id_found,id_active => true | id_found,id_X => true | id_found,id_c => true | id_found,id_mark => true | id_found,id_ok => true | id_found,id_start => true | id_found,id_f => true | id_found,id_proper => true | id_found,id_check => true | id_found,id_top => true | id_found,id_found => true | id_found,id_match => false | id_match,id_active => true | id_match,id_X => true | id_match,id_c => true | id_match,id_mark => true | id_match,id_ok => true | id_match,id_start => true | id_match,id_f => true | id_match,id_proper => true | id_match,id_check => true | id_match,id_top => true | id_match,id_found => true | id_match,id_match => true end. Module Symb. Definition A := symb. Definition eq_A := @eq A. Definition eq_proof : equivalence A eq_A. Proof. constructor. red ;reflexivity . red ;intros ;transitivity y ;assumption. red ;intros ;symmetry ;assumption. Defined. Add Relation A eq_A reflexivity proved by (@equiv_refl _ _ eq_proof) symmetry proved by (@equiv_sym _ _ eq_proof) transitivity proved by (@equiv_trans _ _ eq_proof) as EQA . Definition eq_bool := symb_eq_bool. Definition eq_bool_ok := symb_eq_bool_ok. End Symb. Export Symb. End F. Module Alg := term.Make'(F)(term_extension.IntVars). Module Alg_ext := term_extension.Make(Alg). Module EQT := equational_theory.Make(Alg). Module EQT_ext := equational_extension.Make(EQT). End algebra. Module R_xml_0_deep_rew. Inductive R_xml_0_rules : algebra.Alg.term ->algebra.Alg.term ->Prop := (* active(f(x_)) -> mark(x_) *) | R_xml_0_rule_0 : R_xml_0_rules (algebra.Alg.Term algebra.F.id_mark ((algebra.Alg.Var 1)::nil)) (algebra.Alg.Term algebra.F.id_active ((algebra.Alg.Term algebra.F.id_f ((algebra.Alg.Var 1)::nil))::nil)) (* top(active(c)) -> top(mark(c)) *) | R_xml_0_rule_1 : R_xml_0_rules (algebra.Alg.Term algebra.F.id_top ((algebra.Alg.Term algebra.F.id_mark ((algebra.Alg.Term algebra.F.id_c nil)::nil))::nil)) (algebra.Alg.Term algebra.F.id_top ((algebra.Alg.Term algebra.F.id_active ((algebra.Alg.Term algebra.F.id_c nil)::nil))::nil)) (* top(mark(x_)) -> top(check(x_)) *) | R_xml_0_rule_2 : R_xml_0_rules (algebra.Alg.Term algebra.F.id_top ((algebra.Alg.Term algebra.F.id_check ((algebra.Alg.Var 1)::nil))::nil)) (algebra.Alg.Term algebra.F.id_top ((algebra.Alg.Term algebra.F.id_mark ((algebra.Alg.Var 1)::nil))::nil)) (* check(f(x_)) -> f(check(x_)) *) | R_xml_0_rule_3 : R_xml_0_rules (algebra.Alg.Term algebra.F.id_f ((algebra.Alg.Term algebra.F.id_check ((algebra.Alg.Var 1)::nil))::nil)) (algebra.Alg.Term algebra.F.id_check ((algebra.Alg.Term algebra.F.id_f ((algebra.Alg.Var 1)::nil))::nil)) (* check(x_) -> start(match(f(X),x_)) *) | R_xml_0_rule_4 : R_xml_0_rules (algebra.Alg.Term algebra.F.id_start ((algebra.Alg.Term algebra.F.id_match ((algebra.Alg.Term algebra.F.id_f ((algebra.Alg.Term algebra.F.id_X nil)::nil)):: (algebra.Alg.Var 1)::nil))::nil)) (algebra.Alg.Term algebra.F.id_check ((algebra.Alg.Var 1)::nil)) (* match(f(x_),f(y_)) -> f(match(x_,y_)) *) | R_xml_0_rule_5 : R_xml_0_rules (algebra.Alg.Term algebra.F.id_f ((algebra.Alg.Term algebra.F.id_match ((algebra.Alg.Var 1):: (algebra.Alg.Var 2)::nil))::nil)) (algebra.Alg.Term algebra.F.id_match ((algebra.Alg.Term algebra.F.id_f ((algebra.Alg.Var 1)::nil))::(algebra.Alg.Term algebra.F.id_f ((algebra.Alg.Var 2)::nil))::nil)) (* match(X,x_) -> proper(x_) *) | R_xml_0_rule_6 : R_xml_0_rules (algebra.Alg.Term algebra.F.id_proper ((algebra.Alg.Var 1)::nil)) (algebra.Alg.Term algebra.F.id_match ((algebra.Alg.Term algebra.F.id_X nil)::(algebra.Alg.Var 1)::nil)) (* proper(c) -> ok(c) *) | R_xml_0_rule_7 : R_xml_0_rules (algebra.Alg.Term algebra.F.id_ok ((algebra.Alg.Term algebra.F.id_c nil)::nil)) (algebra.Alg.Term algebra.F.id_proper ((algebra.Alg.Term algebra.F.id_c nil)::nil)) (* proper(f(x_)) -> f(proper(x_)) *) | R_xml_0_rule_8 : R_xml_0_rules (algebra.Alg.Term algebra.F.id_f ((algebra.Alg.Term algebra.F.id_proper ((algebra.Alg.Var 1)::nil))::nil)) (algebra.Alg.Term algebra.F.id_proper ((algebra.Alg.Term algebra.F.id_f ((algebra.Alg.Var 1)::nil))::nil)) (* f(ok(x_)) -> ok(f(x_)) *) | R_xml_0_rule_9 : R_xml_0_rules (algebra.Alg.Term algebra.F.id_ok ((algebra.Alg.Term algebra.F.id_f ((algebra.Alg.Var 1)::nil))::nil)) (algebra.Alg.Term algebra.F.id_f ((algebra.Alg.Term algebra.F.id_ok ((algebra.Alg.Var 1)::nil))::nil)) (* start(ok(x_)) -> found(x_) *) | R_xml_0_rule_10 : R_xml_0_rules (algebra.Alg.Term algebra.F.id_found ((algebra.Alg.Var 1)::nil)) (algebra.Alg.Term algebra.F.id_start ((algebra.Alg.Term algebra.F.id_ok ((algebra.Alg.Var 1)::nil))::nil)) (* f(found(x_)) -> found(f(x_)) *) | R_xml_0_rule_11 : R_xml_0_rules (algebra.Alg.Term algebra.F.id_found ((algebra.Alg.Term algebra.F.id_f ((algebra.Alg.Var 1)::nil))::nil)) (algebra.Alg.Term algebra.F.id_f ((algebra.Alg.Term algebra.F.id_found ((algebra.Alg.Var 1)::nil))::nil)) (* top(found(x_)) -> top(active(x_)) *) | R_xml_0_rule_12 : R_xml_0_rules (algebra.Alg.Term algebra.F.id_top ((algebra.Alg.Term algebra.F.id_active ((algebra.Alg.Var 1)::nil))::nil)) (algebra.Alg.Term algebra.F.id_top ((algebra.Alg.Term algebra.F.id_found ((algebra.Alg.Var 1)::nil))::nil)) (* active(f(x_)) -> f(active(x_)) *) | R_xml_0_rule_13 : R_xml_0_rules (algebra.Alg.Term algebra.F.id_f ((algebra.Alg.Term algebra.F.id_active ((algebra.Alg.Var 1)::nil))::nil)) (algebra.Alg.Term algebra.F.id_active ((algebra.Alg.Term algebra.F.id_f ((algebra.Alg.Var 1)::nil))::nil)) (* f(mark(x_)) -> mark(f(x_)) *) | R_xml_0_rule_14 : R_xml_0_rules (algebra.Alg.Term algebra.F.id_mark ((algebra.Alg.Term algebra.F.id_f ((algebra.Alg.Var 1)::nil))::nil)) (algebra.Alg.Term algebra.F.id_f ((algebra.Alg.Term algebra.F.id_mark ((algebra.Alg.Var 1)::nil))::nil)) . Definition R_xml_0_rule_as_list_0 := ((algebra.Alg.Term algebra.F.id_active ((algebra.Alg.Term algebra.F.id_f ((algebra.Alg.Var 1)::nil))::nil)), (algebra.Alg.Term algebra.F.id_mark ((algebra.Alg.Var 1)::nil))):: nil. Definition R_xml_0_rule_as_list_1 := ((algebra.Alg.Term algebra.F.id_top ((algebra.Alg.Term algebra.F.id_active ((algebra.Alg.Term algebra.F.id_c nil)::nil))::nil)), (algebra.Alg.Term algebra.F.id_top ((algebra.Alg.Term algebra.F.id_mark ((algebra.Alg.Term algebra.F.id_c nil)::nil))::nil))):: R_xml_0_rule_as_list_0. Definition R_xml_0_rule_as_list_2 := ((algebra.Alg.Term algebra.F.id_top ((algebra.Alg.Term algebra.F.id_mark ((algebra.Alg.Var 1)::nil))::nil)), (algebra.Alg.Term algebra.F.id_top ((algebra.Alg.Term algebra.F.id_check ((algebra.Alg.Var 1)::nil))::nil)))::R_xml_0_rule_as_list_1. Definition R_xml_0_rule_as_list_3 := ((algebra.Alg.Term algebra.F.id_check ((algebra.Alg.Term algebra.F.id_f ((algebra.Alg.Var 1)::nil))::nil)), (algebra.Alg.Term algebra.F.id_f ((algebra.Alg.Term algebra.F.id_check ((algebra.Alg.Var 1)::nil))::nil)))::R_xml_0_rule_as_list_2. Definition R_xml_0_rule_as_list_4 := ((algebra.Alg.Term algebra.F.id_check ((algebra.Alg.Var 1)::nil)), (algebra.Alg.Term algebra.F.id_start ((algebra.Alg.Term algebra.F.id_match ((algebra.Alg.Term algebra.F.id_f ((algebra.Alg.Term algebra.F.id_X nil)::nil))::(algebra.Alg.Var 1)::nil))::nil))):: R_xml_0_rule_as_list_3. Definition R_xml_0_rule_as_list_5 := ((algebra.Alg.Term algebra.F.id_match ((algebra.Alg.Term algebra.F.id_f ((algebra.Alg.Var 1)::nil))::(algebra.Alg.Term algebra.F.id_f ((algebra.Alg.Var 2)::nil))::nil)), (algebra.Alg.Term algebra.F.id_f ((algebra.Alg.Term algebra.F.id_match ((algebra.Alg.Var 1)::(algebra.Alg.Var 2)::nil))::nil))):: R_xml_0_rule_as_list_4. Definition R_xml_0_rule_as_list_6 := ((algebra.Alg.Term algebra.F.id_match ((algebra.Alg.Term algebra.F.id_X nil)::(algebra.Alg.Var 1)::nil)), (algebra.Alg.Term algebra.F.id_proper ((algebra.Alg.Var 1)::nil))):: R_xml_0_rule_as_list_5. Definition R_xml_0_rule_as_list_7 := ((algebra.Alg.Term algebra.F.id_proper ((algebra.Alg.Term algebra.F.id_c nil)::nil)), (algebra.Alg.Term algebra.F.id_ok ((algebra.Alg.Term algebra.F.id_c nil)::nil)))::R_xml_0_rule_as_list_6. Definition R_xml_0_rule_as_list_8 := ((algebra.Alg.Term algebra.F.id_proper ((algebra.Alg.Term algebra.F.id_f ((algebra.Alg.Var 1)::nil))::nil)), (algebra.Alg.Term algebra.F.id_f ((algebra.Alg.Term algebra.F.id_proper ((algebra.Alg.Var 1)::nil))::nil)))::R_xml_0_rule_as_list_7. Definition R_xml_0_rule_as_list_9 := ((algebra.Alg.Term algebra.F.id_f ((algebra.Alg.Term algebra.F.id_ok ((algebra.Alg.Var 1)::nil))::nil)), (algebra.Alg.Term algebra.F.id_ok ((algebra.Alg.Term algebra.F.id_f ((algebra.Alg.Var 1)::nil))::nil)))::R_xml_0_rule_as_list_8. Definition R_xml_0_rule_as_list_10 := ((algebra.Alg.Term algebra.F.id_start ((algebra.Alg.Term algebra.F.id_ok ((algebra.Alg.Var 1)::nil))::nil)), (algebra.Alg.Term algebra.F.id_found ((algebra.Alg.Var 1)::nil))):: R_xml_0_rule_as_list_9. Definition R_xml_0_rule_as_list_11 := ((algebra.Alg.Term algebra.F.id_f ((algebra.Alg.Term algebra.F.id_found ((algebra.Alg.Var 1)::nil))::nil)), (algebra.Alg.Term algebra.F.id_found ((algebra.Alg.Term algebra.F.id_f ((algebra.Alg.Var 1)::nil))::nil)))::R_xml_0_rule_as_list_10. Definition R_xml_0_rule_as_list_12 := ((algebra.Alg.Term algebra.F.id_top ((algebra.Alg.Term algebra.F.id_found ((algebra.Alg.Var 1)::nil))::nil)), (algebra.Alg.Term algebra.F.id_top ((algebra.Alg.Term algebra.F.id_active ((algebra.Alg.Var 1)::nil))::nil))):: R_xml_0_rule_as_list_11. Definition R_xml_0_rule_as_list_13 := ((algebra.Alg.Term algebra.F.id_active ((algebra.Alg.Term algebra.F.id_f ((algebra.Alg.Var 1)::nil))::nil)), (algebra.Alg.Term algebra.F.id_f ((algebra.Alg.Term algebra.F.id_active ((algebra.Alg.Var 1)::nil))::nil)))::R_xml_0_rule_as_list_12. Definition R_xml_0_rule_as_list_14 := ((algebra.Alg.Term algebra.F.id_f ((algebra.Alg.Term algebra.F.id_mark ((algebra.Alg.Var 1)::nil))::nil)), (algebra.Alg.Term algebra.F.id_mark ((algebra.Alg.Term algebra.F.id_f ((algebra.Alg.Var 1)::nil))::nil)))::R_xml_0_rule_as_list_13. Definition R_xml_0_rule_as_list := R_xml_0_rule_as_list_14. Lemma R_xml_0_rules_included : forall l r, R_xml_0_rules r l <-> In (l,r) R_xml_0_rule_as_list. Proof. intros l r. constructor. intros H. case H;clear H; (apply (more_list.mem_impl_in (@eq (algebra.Alg.term*algebra.Alg.term))); [tauto|idtac]); match goal with | |- _ _ _ ?t ?l => let u := fresh "u" in (generalize (more_list.mem_bool_ok _ _ algebra.Alg_ext.eq_term_term_bool_ok t l); set (u:=more_list.mem_bool algebra.Alg_ext.eq_term_term_bool t l) in *; vm_compute in u|-;unfold u in *;clear u;intros H;refine H) end . intros H. vm_compute in H|-. rewrite <- or_ext_generated.or16_equiv in H|-. case H;clear H;intros H. injection H;intros ;subst;constructor 15. injection H;intros ;subst;constructor 14. injection H;intros ;subst;constructor 13. injection H;intros ;subst;constructor 12. injection H;intros ;subst;constructor 11. injection H;intros ;subst;constructor 10. injection H;intros ;subst;constructor 9. injection H;intros ;subst;constructor 8. injection H;intros ;subst;constructor 7. injection H;intros ;subst;constructor 6. injection H;intros ;subst;constructor 5. injection H;intros ;subst;constructor 4. injection H;intros ;subst;constructor 3. injection H;intros ;subst;constructor 2. injection H;intros ;subst;constructor 1. elim H. Qed. Lemma R_xml_0_non_var : forall x t, ~R_xml_0_rules t (algebra.EQT.T.Var x). Proof. intros x t H. inversion H. Qed. Lemma R_xml_0_reg : forall s t, (R_xml_0_rules s t) -> forall x, In x (algebra.Alg.var_list s) ->In x (algebra.Alg.var_list t). Proof. intros s t H. inversion H;intros x Hx; (apply (more_list.mem_impl_in (@eq algebra.Alg.variable));[tauto|idtac]); apply (more_list.in_impl_mem (@eq algebra.Alg.variable)) in Hx; vm_compute in Hx|-*;tauto. Qed. Inductive and_5 (x4 x5 x6 x7 x8:Prop) : Prop := | conj_5 : x4->x5->x6->x7->x8->and_5 x4 x5 x6 x7 x8 . Lemma are_constuctors_of_R_xml_0 : forall t t', (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_rules) t' t) -> and_5 (t = (algebra.Alg.Term algebra.F.id_X nil) -> t' = (algebra.Alg.Term algebra.F.id_X nil)) (t = (algebra.Alg.Term algebra.F.id_c nil) -> t' = (algebra.Alg.Term algebra.F.id_c nil)) (forall x5, t = (algebra.Alg.Term algebra.F.id_mark (x5::nil)) -> exists x4, t' = (algebra.Alg.Term algebra.F.id_mark (x4::nil))/\ (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_rules) x4 x5)) (forall x5, t = (algebra.Alg.Term algebra.F.id_ok (x5::nil)) -> exists x4, t' = (algebra.Alg.Term algebra.F.id_ok (x4::nil))/\ (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_rules) x4 x5)) (forall x5, t = (algebra.Alg.Term algebra.F.id_found (x5::nil)) -> exists x4, t' = (algebra.Alg.Term algebra.F.id_found (x4::nil))/\ (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_rules) x4 x5)). Proof. intros t t' H. induction H as [|y IH z z_to_y] using closure_extension.refl_trans_clos_ind2. constructor 1. intros H;intuition;constructor 1. intros H;intuition;constructor 1. intros x5 H;exists x5;intuition;constructor 1. intros x5 H;exists x5;intuition;constructor 1. intros x5 H;exists x5;intuition;constructor 1. inversion z_to_y as [t1 t2 H H0 H1|f l1 l2 H0 H H2];clear z_to_y;subst. inversion H as [t1 t2 sigma H2 H1 H0];clear H IH;subst;inversion H2; clear ;constructor;try (intros until 0 );clear ;intros abs; discriminate abs. destruct IH as [H_id_X H_id_c H_id_mark H_id_ok H_id_found]. constructor. clear H_id_c H_id_mark H_id_ok H_id_found;intros H;injection H;clear H; intros ;subst; repeat ( match goal with | H:closure.one_step_list (algebra.EQT.one_step _) _ _ |- _ => inversion H;clear H;subst end ). clear H_id_X H_id_mark H_id_ok H_id_found;intros H;injection H;clear H; intros ;subst; repeat ( match goal with | H:closure.one_step_list (algebra.EQT.one_step _) _ _ |- _ => inversion H;clear H;subst end ). clear H_id_X H_id_c H_id_ok H_id_found;intros x5 H;injection H;clear H; intros ;subst; repeat ( match goal with | H:closure.one_step_list (algebra.EQT.one_step _) _ _ |- _ => inversion H;clear H;subst end ). match goal with | H:algebra.EQT.one_step _ ?y x5 |- _ => destruct (H_id_mark y (refl_equal _)) as [x4];intros ;intuition; exists x4;intuition;eapply closure_extension.refl_trans_clos_R; eassumption end . clear H_id_X H_id_c H_id_mark H_id_found;intros x5 H;injection H;clear H; intros ;subst; repeat ( match goal with | H:closure.one_step_list (algebra.EQT.one_step _) _ _ |- _ => inversion H;clear H;subst end ). match goal with | H:algebra.EQT.one_step _ ?y x5 |- _ => destruct (H_id_ok y (refl_equal _)) as [x4];intros ;intuition; exists x4;intuition;eapply closure_extension.refl_trans_clos_R; eassumption end . clear H_id_X H_id_c H_id_mark H_id_ok;intros x5 H;injection H;clear H; intros ;subst; repeat ( match goal with | H:closure.one_step_list (algebra.EQT.one_step _) _ _ |- _ => inversion H;clear H;subst end ). match goal with | H:algebra.EQT.one_step _ ?y x5 |- _ => destruct (H_id_found y (refl_equal _)) as [x4];intros ;intuition; exists x4;intuition;eapply closure_extension.refl_trans_clos_R; eassumption end . Qed. Lemma id_X_is_R_xml_0_constructor : forall t t', (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_rules) t' t) -> t = (algebra.Alg.Term algebra.F.id_X nil) -> t' = (algebra.Alg.Term algebra.F.id_X nil). Proof. intros t t' H. destruct (are_constuctors_of_R_xml_0 H). assumption. Qed. Lemma id_c_is_R_xml_0_constructor : forall t t', (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_rules) t' t) -> t = (algebra.Alg.Term algebra.F.id_c nil) -> t' = (algebra.Alg.Term algebra.F.id_c nil). Proof. intros t t' H. destruct (are_constuctors_of_R_xml_0 H). assumption. Qed. Lemma id_mark_is_R_xml_0_constructor : forall t t', (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_rules) t' t) -> forall x5, t = (algebra.Alg.Term algebra.F.id_mark (x5::nil)) -> exists x4, t' = (algebra.Alg.Term algebra.F.id_mark (x4::nil))/\ (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_rules) x4 x5). Proof. intros t t' H. destruct (are_constuctors_of_R_xml_0 H). assumption. Qed. Lemma id_ok_is_R_xml_0_constructor : forall t t', (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_rules) t' t) -> forall x5, t = (algebra.Alg.Term algebra.F.id_ok (x5::nil)) -> exists x4, t' = (algebra.Alg.Term algebra.F.id_ok (x4::nil))/\ (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_rules) x4 x5). Proof. intros t t' H. destruct (are_constuctors_of_R_xml_0 H). assumption. Qed. Lemma id_found_is_R_xml_0_constructor : forall t t', (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_rules) t' t) -> forall x5, t = (algebra.Alg.Term algebra.F.id_found (x5::nil)) -> exists x4, t' = (algebra.Alg.Term algebra.F.id_found (x4::nil))/\ (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_rules) x4 x5). Proof. intros t t' H. destruct (are_constuctors_of_R_xml_0 H). assumption. Qed. Ltac impossible_star_reduction_R_xml_0 := match goal with | H:closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_rules) _ (algebra.Alg.Term algebra.F.id_X nil) |- _ => let Heq := fresh "Heq" in (set (Heq:=id_X_is_R_xml_0_constructor H (refl_equal _)) in *; (discriminate Heq)|| (clearbody Heq;try (subst);try (clear Heq);clear H; impossible_star_reduction_R_xml_0 )) | H:closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_rules) _ (algebra.Alg.Term algebra.F.id_c nil) |- _ => let Heq := fresh "Heq" in (set (Heq:=id_c_is_R_xml_0_constructor H (refl_equal _)) in *; (discriminate Heq)|| (clearbody Heq;try (subst);try (clear Heq);clear H; impossible_star_reduction_R_xml_0 )) | H:closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_rules) _ (algebra.Alg.Term algebra.F.id_mark (?x4::nil)) |- _ => let x4 := fresh "x" in (let Heq := fresh "Heq" in (let Hred1 := fresh "Hred" in (destruct (id_mark_is_R_xml_0_constructor H (refl_equal _)) as [x4 [Heq Hred1]]; (discriminate Heq)|| (injection Heq;intros ;subst;clear Heq;clear H; impossible_star_reduction_R_xml_0 )))) | H:closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_rules) _ (algebra.Alg.Term algebra.F.id_ok (?x4::nil)) |- _ => let x4 := fresh "x" in (let Heq := fresh "Heq" in (let Hred1 := fresh "Hred" in (destruct (id_ok_is_R_xml_0_constructor H (refl_equal _)) as [x4 [Heq Hred1]]; (discriminate Heq)|| (injection Heq;intros ;subst;clear Heq;clear H; impossible_star_reduction_R_xml_0 )))) | H:closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_rules) _ (algebra.Alg.Term algebra.F.id_found (?x4::nil)) |- _ => let x4 := fresh "x" in (let Heq := fresh "Heq" in (let Hred1 := fresh "Hred" in (destruct (id_found_is_R_xml_0_constructor H (refl_equal _)) as [x4 [Heq Hred1]]; (discriminate Heq)|| (injection Heq;intros ;subst;clear Heq;clear H; impossible_star_reduction_R_xml_0 )))) end . Ltac simplify_star_reduction_R_xml_0 := match goal with | H:closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_rules) _ (algebra.Alg.Term algebra.F.id_X nil) |- _ => let Heq := fresh "Heq" in (set (Heq:=id_X_is_R_xml_0_constructor H (refl_equal _)) in *; (discriminate Heq)|| (clearbody Heq;try (subst);try (clear Heq);clear H; try (simplify_star_reduction_R_xml_0 ))) | H:closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_rules) _ (algebra.Alg.Term algebra.F.id_c nil) |- _ => let Heq := fresh "Heq" in (set (Heq:=id_c_is_R_xml_0_constructor H (refl_equal _)) in *; (discriminate Heq)|| (clearbody Heq;try (subst);try (clear Heq);clear H; try (simplify_star_reduction_R_xml_0 ))) | H:closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_rules) _ (algebra.Alg.Term algebra.F.id_mark (?x4::nil)) |- _ => let x4 := fresh "x" in (let Heq := fresh "Heq" in (let Hred1 := fresh "Hred" in (destruct (id_mark_is_R_xml_0_constructor H (refl_equal _)) as [x4 [Heq Hred1]]; (discriminate Heq)|| (injection Heq;intros ;subst;clear Heq;clear H; try (simplify_star_reduction_R_xml_0 ))))) | H:closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_rules) _ (algebra.Alg.Term algebra.F.id_ok (?x4::nil)) |- _ => let x4 := fresh "x" in (let Heq := fresh "Heq" in (let Hred1 := fresh "Hred" in (destruct (id_ok_is_R_xml_0_constructor H (refl_equal _)) as [x4 [Heq Hred1]]; (discriminate Heq)|| (injection Heq;intros ;subst;clear Heq;clear H; try (simplify_star_reduction_R_xml_0 ))))) | H:closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_rules) _ (algebra.Alg.Term algebra.F.id_found (?x4::nil)) |- _ => let x4 := fresh "x" in (let Heq := fresh "Heq" in (let Hred1 := fresh "Hred" in (destruct (id_found_is_R_xml_0_constructor H (refl_equal _)) as [x4 [Heq Hred1]]; (discriminate Heq)|| (injection Heq;intros ;subst;clear Heq;clear H; try (simplify_star_reduction_R_xml_0 ))))) end . End R_xml_0_deep_rew. Module InterpGen := interp.Interp(algebra.EQT). Module ddp := dp.MakeDP(algebra.EQT). Module SymbType. Definition A := algebra.Alg.F.Symb.A. End SymbType. Module Symb_more_list := more_list_extention.Make(SymbType)(algebra.Alg.F.Symb). Module SymbSet := list_set.Make(algebra.F.Symb). Module Interp. Section S. Require Import interp. Hypothesis A : Type. Hypothesis Ale Alt Aeq : A -> A -> Prop. Hypothesis Aop : interp.ordering_pair Aeq Alt Ale. Hypothesis A0 : A. Notation Local "a <= b" := (Ale a b). Hypothesis P_id_active : A ->A. Hypothesis P_id_X : A. Hypothesis P_id_c : A. Hypothesis P_id_mark : A ->A. Hypothesis P_id_ok : A ->A. Hypothesis P_id_start : A ->A. Hypothesis P_id_f : A ->A. Hypothesis P_id_proper : A ->A. Hypothesis P_id_check : A ->A. Hypothesis P_id_top : A ->A. Hypothesis P_id_found : A ->A. Hypothesis P_id_match : A ->A ->A. Hypothesis P_id_active_monotonic : forall x4 x5, (A0 <= x5)/\ (x5 <= x4) ->P_id_active x5 <= P_id_active x4. Hypothesis P_id_mark_monotonic : forall x4 x5, (A0 <= x5)/\ (x5 <= x4) ->P_id_mark x5 <= P_id_mark x4. Hypothesis P_id_ok_monotonic : forall x4 x5, (A0 <= x5)/\ (x5 <= x4) ->P_id_ok x5 <= P_id_ok x4. Hypothesis P_id_start_monotonic : forall x4 x5, (A0 <= x5)/\ (x5 <= x4) ->P_id_start x5 <= P_id_start x4. Hypothesis P_id_f_monotonic : forall x4 x5, (A0 <= x5)/\ (x5 <= x4) ->P_id_f x5 <= P_id_f x4. Hypothesis P_id_proper_monotonic : forall x4 x5, (A0 <= x5)/\ (x5 <= x4) ->P_id_proper x5 <= P_id_proper x4. Hypothesis P_id_check_monotonic : forall x4 x5, (A0 <= x5)/\ (x5 <= x4) ->P_id_check x5 <= P_id_check x4. Hypothesis P_id_top_monotonic : forall x4 x5, (A0 <= x5)/\ (x5 <= x4) ->P_id_top x5 <= P_id_top x4. Hypothesis P_id_found_monotonic : forall x4 x5, (A0 <= x5)/\ (x5 <= x4) ->P_id_found x5 <= P_id_found x4. Hypothesis P_id_match_monotonic : forall x4 x6 x5 x7, (A0 <= x7)/\ (x7 <= x6) -> (A0 <= x5)/\ (x5 <= x4) ->P_id_match x5 x7 <= P_id_match x4 x6. Hypothesis P_id_active_bounded : forall x4, (A0 <= x4) ->A0 <= P_id_active x4. Hypothesis P_id_X_bounded : A0 <= P_id_X . Hypothesis P_id_c_bounded : A0 <= P_id_c . Hypothesis P_id_mark_bounded : forall x4, (A0 <= x4) ->A0 <= P_id_mark x4. Hypothesis P_id_ok_bounded : forall x4, (A0 <= x4) ->A0 <= P_id_ok x4. Hypothesis P_id_start_bounded : forall x4, (A0 <= x4) ->A0 <= P_id_start x4. Hypothesis P_id_f_bounded : forall x4, (A0 <= x4) ->A0 <= P_id_f x4. Hypothesis P_id_proper_bounded : forall x4, (A0 <= x4) ->A0 <= P_id_proper x4. Hypothesis P_id_check_bounded : forall x4, (A0 <= x4) ->A0 <= P_id_check x4. Hypothesis P_id_top_bounded : forall x4, (A0 <= x4) ->A0 <= P_id_top x4. Hypothesis P_id_found_bounded : forall x4, (A0 <= x4) ->A0 <= P_id_found x4. Hypothesis P_id_match_bounded : forall x4 x5, (A0 <= x4) ->(A0 <= x5) ->A0 <= P_id_match x5 x4. Fixpoint measure t { struct t } := match t with | (algebra.Alg.Term algebra.F.id_active (x4::nil)) => P_id_active (measure x4) | (algebra.Alg.Term algebra.F.id_X nil) => P_id_X | (algebra.Alg.Term algebra.F.id_c nil) => P_id_c | (algebra.Alg.Term algebra.F.id_mark (x4::nil)) => P_id_mark (measure x4) | (algebra.Alg.Term algebra.F.id_ok (x4::nil)) => P_id_ok (measure x4) | (algebra.Alg.Term algebra.F.id_start (x4::nil)) => P_id_start (measure x4) | (algebra.Alg.Term algebra.F.id_f (x4::nil)) => P_id_f (measure x4) | (algebra.Alg.Term algebra.F.id_proper (x4::nil)) => P_id_proper (measure x4) | (algebra.Alg.Term algebra.F.id_check (x4::nil)) => P_id_check (measure x4) | (algebra.Alg.Term algebra.F.id_top (x4::nil)) => P_id_top (measure x4) | (algebra.Alg.Term algebra.F.id_found (x4::nil)) => P_id_found (measure x4) | (algebra.Alg.Term algebra.F.id_match (x5::x4::nil)) => P_id_match (measure x5) (measure x4) | _ => A0 end. Lemma measure_equation : forall t, measure t = match t with | (algebra.Alg.Term algebra.F.id_active (x4::nil)) => P_id_active (measure x4) | (algebra.Alg.Term algebra.F.id_X nil) => P_id_X | (algebra.Alg.Term algebra.F.id_c nil) => P_id_c | (algebra.Alg.Term algebra.F.id_mark (x4::nil)) => P_id_mark (measure x4) | (algebra.Alg.Term algebra.F.id_ok (x4::nil)) => P_id_ok (measure x4) | (algebra.Alg.Term algebra.F.id_start (x4::nil)) => P_id_start (measure x4) | (algebra.Alg.Term algebra.F.id_f (x4::nil)) => P_id_f (measure x4) | (algebra.Alg.Term algebra.F.id_proper (x4::nil)) => P_id_proper (measure x4) | (algebra.Alg.Term algebra.F.id_check (x4::nil)) => P_id_check (measure x4) | (algebra.Alg.Term algebra.F.id_top (x4::nil)) => P_id_top (measure x4) | (algebra.Alg.Term algebra.F.id_found (x4::nil)) => P_id_found (measure x4) | (algebra.Alg.Term algebra.F.id_match (x5::x4::nil)) => P_id_match (measure x5) (measure x4) | _ => A0 end. Proof. intros t;case t;intros ;apply refl_equal. Qed. Definition Pols f : InterpGen.Pol_type A (InterpGen.get_arity f) := match f with | algebra.F.id_active => P_id_active | algebra.F.id_X => P_id_X | algebra.F.id_c => P_id_c | algebra.F.id_mark => P_id_mark | algebra.F.id_ok => P_id_ok | algebra.F.id_start => P_id_start | algebra.F.id_f => P_id_f | algebra.F.id_proper => P_id_proper | algebra.F.id_check => P_id_check | algebra.F.id_top => P_id_top | algebra.F.id_found => P_id_found | algebra.F.id_match => P_id_match end. Lemma same_measure : forall t, measure t = InterpGen.measure A0 Pols t. Proof. fix 1 . intros [a| f l]. simpl in |-*. unfold eq_rect_r, eq_rect, sym_eq in |-*. reflexivity . refine match f with | algebra.F.id_active => match l with | nil => _ | _::nil => _ | _::_::_ => _ end | algebra.F.id_X => match l with | nil => _ | _::_ => _ end | algebra.F.id_c => match l with | nil => _ | _::_ => _ end | algebra.F.id_mark => match l with | nil => _ | _::nil => _ | _::_::_ => _ end | algebra.F.id_ok => match l with | nil => _ | _::nil => _ | _::_::_ => _ end | algebra.F.id_start => match l with | nil => _ | _::nil => _ | _::_::_ => _ end | algebra.F.id_f => match l with | nil => _ | _::nil => _ | _::_::_ => _ end | algebra.F.id_proper => match l with | nil => _ | _::nil => _ | _::_::_ => _ end | algebra.F.id_check => match l with | nil => _ | _::nil => _ | _::_::_ => _ end | algebra.F.id_top => match l with | nil => _ | _::nil => _ | _::_::_ => _ end | algebra.F.id_found => match l with | nil => _ | _::nil => _ | _::_::_ => _ end | algebra.F.id_match => match l with | nil => _ | _::nil => _ | _::_::nil => _ | _::_::_::_ => _ end end;simpl in |-*;unfold eq_rect_r, eq_rect, sym_eq in |-*; try (reflexivity );f_equal ;auto. Qed. Lemma measure_bounded : forall t, A0 <= measure t. Proof. intros t. rewrite same_measure in |-*. apply (InterpGen.measure_bounded Aop). intros f. case f. vm_compute in |-*;intros ;apply P_id_active_bounded;assumption. vm_compute in |-*;intros ;apply P_id_X_bounded;assumption. vm_compute in |-*;intros ;apply P_id_c_bounded;assumption. vm_compute in |-*;intros ;apply P_id_mark_bounded;assumption. vm_compute in |-*;intros ;apply P_id_ok_bounded;assumption. vm_compute in |-*;intros ;apply P_id_start_bounded;assumption. vm_compute in |-*;intros ;apply P_id_f_bounded;assumption. vm_compute in |-*;intros ;apply P_id_proper_bounded;assumption. vm_compute in |-*;intros ;apply P_id_check_bounded;assumption. vm_compute in |-*;intros ;apply P_id_top_bounded;assumption. vm_compute in |-*;intros ;apply P_id_found_bounded;assumption. vm_compute in |-*;intros ;apply P_id_match_bounded;assumption. Qed. Ltac generate_pos_hyp := match goal with | H:context [measure ?x] |- _ => let v := fresh "v" in (let H := fresh "h" in (set (H:=measure_bounded x) in *;set (v:=measure x) in *; clearbody H;clearbody v)) | |- context [measure ?x] => let v := fresh "v" in (let H := fresh "h" in (set (H:=measure_bounded x) in *;set (v:=measure x) in *; clearbody H;clearbody v)) end . Hypothesis rules_monotonic : forall l r, (algebra.EQT.axiom R_xml_0_deep_rew.R_xml_0_rules r l) -> measure r <= measure l. Lemma measure_star_monotonic : forall l r, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) r l) ->measure r <= measure l. Proof. intros . do 2 (rewrite same_measure in |-*). apply InterpGen.measure_star_monotonic with (1:=Aop) (Pols:=Pols) (rules:=R_xml_0_deep_rew.R_xml_0_rules). intros f. case f. vm_compute in |-*;intros ;apply P_id_active_monotonic;assumption. vm_compute in |-*;apply (Aop.(le_refl)). vm_compute in |-*;apply (Aop.(le_refl)). vm_compute in |-*;intros ;apply P_id_mark_monotonic;assumption. vm_compute in |-*;intros ;apply P_id_ok_monotonic;assumption. vm_compute in |-*;intros ;apply P_id_start_monotonic;assumption. vm_compute in |-*;intros ;apply P_id_f_monotonic;assumption. vm_compute in |-*;intros ;apply P_id_proper_monotonic;assumption. vm_compute in |-*;intros ;apply P_id_check_monotonic;assumption. vm_compute in |-*;intros ;apply P_id_top_monotonic;assumption. vm_compute in |-*;intros ;apply P_id_found_monotonic;assumption. vm_compute in |-*;intros ;apply P_id_match_monotonic;assumption. intros f. case f. vm_compute in |-*;intros ;apply P_id_active_bounded;assumption. vm_compute in |-*;intros ;apply P_id_X_bounded;assumption. vm_compute in |-*;intros ;apply P_id_c_bounded;assumption. vm_compute in |-*;intros ;apply P_id_mark_bounded;assumption. vm_compute in |-*;intros ;apply P_id_ok_bounded;assumption. vm_compute in |-*;intros ;apply P_id_start_bounded;assumption. vm_compute in |-*;intros ;apply P_id_f_bounded;assumption. vm_compute in |-*;intros ;apply P_id_proper_bounded;assumption. vm_compute in |-*;intros ;apply P_id_check_bounded;assumption. vm_compute in |-*;intros ;apply P_id_top_bounded;assumption. vm_compute in |-*;intros ;apply P_id_found_bounded;assumption. vm_compute in |-*;intros ;apply P_id_match_bounded;assumption. intros . do 2 (rewrite <- same_measure in |-*). apply rules_monotonic;assumption. assumption. Qed. Hypothesis P_id_MATCH : A ->A ->A. Hypothesis P_id_TOP : A ->A. Hypothesis P_id_ACTIVE : A ->A. Hypothesis P_id_F : A ->A. Hypothesis P_id_PROPER : A ->A. Hypothesis P_id_CHECK : A ->A. Hypothesis P_id_START : A ->A. Hypothesis P_id_MATCH_monotonic : forall x4 x6 x5 x7, (A0 <= x7)/\ (x7 <= x6) -> (A0 <= x5)/\ (x5 <= x4) ->P_id_MATCH x5 x7 <= P_id_MATCH x4 x6. Hypothesis P_id_TOP_monotonic : forall x4 x5, (A0 <= x5)/\ (x5 <= x4) ->P_id_TOP x5 <= P_id_TOP x4. Hypothesis P_id_ACTIVE_monotonic : forall x4 x5, (A0 <= x5)/\ (x5 <= x4) ->P_id_ACTIVE x5 <= P_id_ACTIVE x4. Hypothesis P_id_F_monotonic : forall x4 x5, (A0 <= x5)/\ (x5 <= x4) ->P_id_F x5 <= P_id_F x4. Hypothesis P_id_PROPER_monotonic : forall x4 x5, (A0 <= x5)/\ (x5 <= x4) ->P_id_PROPER x5 <= P_id_PROPER x4. Hypothesis P_id_CHECK_monotonic : forall x4 x5, (A0 <= x5)/\ (x5 <= x4) ->P_id_CHECK x5 <= P_id_CHECK x4. Hypothesis P_id_START_monotonic : forall x4 x5, (A0 <= x5)/\ (x5 <= x4) ->P_id_START x5 <= P_id_START x4. Definition marked_measure t := match t with | (algebra.Alg.Term algebra.F.id_match (x5::x4::nil)) => P_id_MATCH (measure x5) (measure x4) | (algebra.Alg.Term algebra.F.id_top (x4::nil)) => P_id_TOP (measure x4) | (algebra.Alg.Term algebra.F.id_active (x4::nil)) => P_id_ACTIVE (measure x4) | (algebra.Alg.Term algebra.F.id_f (x4::nil)) => P_id_F (measure x4) | (algebra.Alg.Term algebra.F.id_proper (x4::nil)) => P_id_PROPER (measure x4) | (algebra.Alg.Term algebra.F.id_check (x4::nil)) => P_id_CHECK (measure x4) | (algebra.Alg.Term algebra.F.id_start (x4::nil)) => P_id_START (measure x4) | _ => measure t end. Definition Marked_pols : forall f, (algebra.EQT.defined R_xml_0_deep_rew.R_xml_0_rules f) -> InterpGen.Pol_type A (InterpGen.get_arity f). Proof. intros f H. apply ddp.defined_list_complete with (1:=R_xml_0_deep_rew.R_xml_0_rules_included) in H . apply (Symb_more_list.change_in algebra.F.symb_order) in H . set (u := (Symb_more_list.qs algebra.F.symb_order (Symb_more_list.XSet.remove_red (ddp.defined_list R_xml_0_deep_rew.R_xml_0_rule_as_list)))) in * . vm_compute in u . unfold u in * . clear u . unfold more_list.mem_bool in H . match type of H with | orb ?a ?b = true => assert (H':{a = true}+{b = true});[ revert H;case a;[left;reflexivity|simpl;intros h;right;exact h]| clear H;destruct H' as [H|H]] end . match type of H with | _ _ ?t = true => generalize (algebra.F.symb_eq_bool_ok f t); unfold algebra.Alg.eq_symb_bool in H; rewrite H;clear H;intros ;subst end . vm_compute in |-*;intros x5 x4;apply (P_id_MATCH x5 x4). match type of H with | orb ?a ?b = true => assert (H':{a = true}+{b = true});[ revert H;case a;[left;reflexivity|simpl;intros h;right;exact h]| clear H;destruct H' as [H|H]] end . match type of H with | _ _ ?t = true => generalize (algebra.F.symb_eq_bool_ok f t); unfold algebra.Alg.eq_symb_bool in H; rewrite H;clear H;intros ;subst end . vm_compute in |-*;intros x4;apply (P_id_TOP x4). match type of H with | orb ?a ?b = true => assert (H':{a = true}+{b = true});[ revert H;case a;[left;reflexivity|simpl;intros h;right;exact h]| clear H;destruct H' as [H|H]] end . match type of H with | _ _ ?t = true => generalize (algebra.F.symb_eq_bool_ok f t); unfold algebra.Alg.eq_symb_bool in H; rewrite H;clear H;intros ;subst end . vm_compute in |-*;intros x4;apply (P_id_CHECK x4). match type of H with | orb ?a ?b = true => assert (H':{a = true}+{b = true});[ revert H;case a;[left;reflexivity|simpl;intros h;right;exact h]| clear H;destruct H' as [H|H]] end . match type of H with | _ _ ?t = true => generalize (algebra.F.symb_eq_bool_ok f t); unfold algebra.Alg.eq_symb_bool in H; rewrite H;clear H;intros ;subst end . vm_compute in |-*;intros x4;apply (P_id_PROPER x4). match type of H with | orb ?a ?b = true => assert (H':{a = true}+{b = true});[ revert H;case a;[left;reflexivity|simpl;intros h;right;exact h]| clear H;destruct H' as [H|H]] end . match type of H with | _ _ ?t = true => generalize (algebra.F.symb_eq_bool_ok f t); unfold algebra.Alg.eq_symb_bool in H; rewrite H;clear H;intros ;subst end . vm_compute in |-*;intros x4;apply (P_id_F x4). match type of H with | orb ?a ?b = true => assert (H':{a = true}+{b = true});[ revert H;case a;[left;reflexivity|simpl;intros h;right;exact h]| clear H;destruct H' as [H|H]] end . match type of H with | _ _ ?t = true => generalize (algebra.F.symb_eq_bool_ok f t); unfold algebra.Alg.eq_symb_bool in H; rewrite H;clear H;intros ;subst end . vm_compute in |-*;intros x4;apply (P_id_START x4). match type of H with | orb ?a ?b = true => assert (H':{a = true}+{b = true});[ revert H;case a;[left;reflexivity|simpl;intros h;right;exact h]| clear H;destruct H' as [H|H]] end . match type of H with | _ _ ?t = true => generalize (algebra.F.symb_eq_bool_ok f t); unfold algebra.Alg.eq_symb_bool in H; rewrite H;clear H;intros ;subst end . vm_compute in |-*;intros x4;apply (P_id_ACTIVE x4). discriminate H. Defined. Lemma same_marked_measure : forall t, marked_measure t = InterpGen.marked_measure A0 Pols Marked_pols (ddp.defined_dec _ _ R_xml_0_deep_rew.R_xml_0_rules_included) t. Proof. intros [a| f l]. simpl in |-*. unfold eq_rect_r, eq_rect, sym_eq in |-*. reflexivity . refine match f with | algebra.F.id_active => match l with | nil => _ | _::nil => _ | _::_::_ => _ end | algebra.F.id_X => match l with | nil => _ | _::_ => _ end | algebra.F.id_c => match l with | nil => _ | _::_ => _ end | algebra.F.id_mark => match l with | nil => _ | _::nil => _ | _::_::_ => _ end | algebra.F.id_ok => match l with | nil => _ | _::nil => _ | _::_::_ => _ end | algebra.F.id_start => match l with | nil => _ | _::nil => _ | _::_::_ => _ end | algebra.F.id_f => match l with | nil => _ | _::nil => _ | _::_::_ => _ end | algebra.F.id_proper => match l with | nil => _ | _::nil => _ | _::_::_ => _ end | algebra.F.id_check => match l with | nil => _ | _::nil => _ | _::_::_ => _ end | algebra.F.id_top => match l with | nil => _ | _::nil => _ | _::_::_ => _ end | algebra.F.id_found => match l with | nil => _ | _::nil => _ | _::_::_ => _ end | algebra.F.id_match => match l with | nil => _ | _::nil => _ | _::_::nil => _ | _::_::_::_ => _ end end. vm_compute in |-*;reflexivity . lazy - [measure InterpGen.measure Pols] in |-* ;f_equal ; apply same_measure. vm_compute in |-*;reflexivity . vm_compute in |-*;reflexivity . vm_compute in |-*;reflexivity . vm_compute in |-*;reflexivity . vm_compute in |-*;reflexivity . vm_compute in |-*;reflexivity . lazy - [measure InterpGen.measure Pols] in |-* ;f_equal ; apply same_measure. vm_compute in |-*;reflexivity . vm_compute in |-*;reflexivity . lazy - [measure InterpGen.measure Pols] in |-* ;f_equal ; apply same_measure. vm_compute in |-*;reflexivity . vm_compute in |-*;reflexivity . lazy - [measure InterpGen.measure Pols] in |-* ;f_equal ; apply same_measure. vm_compute in |-*;reflexivity . vm_compute in |-*;reflexivity . lazy - [measure InterpGen.measure Pols] in |-* ;f_equal ; apply same_measure. vm_compute in |-*;reflexivity . vm_compute in |-*;reflexivity . lazy - [measure InterpGen.measure Pols] in |-* ;f_equal ; apply same_measure. vm_compute in |-*;reflexivity . vm_compute in |-*;reflexivity . lazy - [measure InterpGen.measure Pols] in |-* ;f_equal ; apply same_measure. vm_compute in |-*;reflexivity . vm_compute in |-*;reflexivity . lazy - [measure InterpGen.measure Pols] in |-* ;f_equal ; apply same_measure. vm_compute in |-*;reflexivity . vm_compute in |-*;reflexivity . lazy - [measure InterpGen.measure Pols] in |-* ;f_equal ; apply same_measure. vm_compute in |-*;reflexivity . vm_compute in |-*;reflexivity . vm_compute in |-*;reflexivity . lazy - [measure InterpGen.measure Pols] in |-* ;f_equal ; apply same_measure. vm_compute in |-*;reflexivity . Qed. Lemma marked_measure_equation : forall t, marked_measure t = match t with | (algebra.Alg.Term algebra.F.id_match (x5:: x4::nil)) => P_id_MATCH (measure x5) (measure x4) | (algebra.Alg.Term algebra.F.id_top (x4::nil)) => P_id_TOP (measure x4) | (algebra.Alg.Term algebra.F.id_active (x4::nil)) => P_id_ACTIVE (measure x4) | (algebra.Alg.Term algebra.F.id_f (x4::nil)) => P_id_F (measure x4) | (algebra.Alg.Term algebra.F.id_proper (x4::nil)) => P_id_PROPER (measure x4) | (algebra.Alg.Term algebra.F.id_check (x4::nil)) => P_id_CHECK (measure x4) | (algebra.Alg.Term algebra.F.id_start (x4::nil)) => P_id_START (measure x4) | _ => measure t end. Proof. reflexivity . Qed. Lemma marked_measure_star_monotonic : forall f l1 l2, (closure.refl_trans_clos (closure.one_step_list (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) ) l1 l2) -> marked_measure (algebra.Alg.Term f l1) <= marked_measure (algebra.Alg.Term f l2). Proof. intros . do 2 (rewrite same_marked_measure in |-*). apply InterpGen.marked_measure_star_monotonic with (1:=Aop) (Pols:= Pols) (rules:=R_xml_0_deep_rew.R_xml_0_rules). clear f. intros f. case f. vm_compute in |-*;intros ;apply P_id_active_monotonic;assumption. vm_compute in |-*;apply (Aop.(le_refl)). vm_compute in |-*;apply (Aop.(le_refl)). vm_compute in |-*;intros ;apply P_id_mark_monotonic;assumption. vm_compute in |-*;intros ;apply P_id_ok_monotonic;assumption. vm_compute in |-*;intros ;apply P_id_start_monotonic;assumption. vm_compute in |-*;intros ;apply P_id_f_monotonic;assumption. vm_compute in |-*;intros ;apply P_id_proper_monotonic;assumption. vm_compute in |-*;intros ;apply P_id_check_monotonic;assumption. vm_compute in |-*;intros ;apply P_id_top_monotonic;assumption. vm_compute in |-*;intros ;apply P_id_found_monotonic;assumption. vm_compute in |-*;intros ;apply P_id_match_monotonic;assumption. clear f. intros f. case f. vm_compute in |-*;intros ;apply P_id_active_bounded;assumption. vm_compute in |-*;intros ;apply P_id_X_bounded;assumption. vm_compute in |-*;intros ;apply P_id_c_bounded;assumption. vm_compute in |-*;intros ;apply P_id_mark_bounded;assumption. vm_compute in |-*;intros ;apply P_id_ok_bounded;assumption. vm_compute in |-*;intros ;apply P_id_start_bounded;assumption. vm_compute in |-*;intros ;apply P_id_f_bounded;assumption. vm_compute in |-*;intros ;apply P_id_proper_bounded;assumption. vm_compute in |-*;intros ;apply P_id_check_bounded;assumption. vm_compute in |-*;intros ;apply P_id_top_bounded;assumption. vm_compute in |-*;intros ;apply P_id_found_bounded;assumption. vm_compute in |-*;intros ;apply P_id_match_bounded;assumption. intros . do 2 (rewrite <- same_measure in |-*). apply rules_monotonic;assumption. clear f. intros f. clear H. intros H. generalize H. apply ddp.defined_list_complete with (1:=R_xml_0_deep_rew.R_xml_0_rules_included) in H . apply (Symb_more_list.change_in algebra.F.symb_order) in H . set (u := (Symb_more_list.qs algebra.F.symb_order (Symb_more_list.XSet.remove_red (ddp.defined_list R_xml_0_deep_rew.R_xml_0_rule_as_list)))) in * . vm_compute in u . unfold u in * . clear u . unfold more_list.mem_bool in H . match type of H with | orb ?a ?b = true => assert (H':{a = true}+{b = true});[ revert H;case a;[left;reflexivity|simpl;intros h;right;exact h]| clear H;destruct H' as [H|H]] end . match type of H with | _ _ ?t = true => generalize (algebra.F.symb_eq_bool_ok f t); unfold algebra.Alg.eq_symb_bool in H; rewrite H;clear H;intros ;subst end . vm_compute in |-*;intros ;apply P_id_MATCH_monotonic;assumption. match type of H with | orb ?a ?b = true => assert (H':{a = true}+{b = true});[ revert H;case a;[left;reflexivity|simpl;intros h;right;exact h]| clear H;destruct H' as [H|H]] end . match type of H with | _ _ ?t = true => generalize (algebra.F.symb_eq_bool_ok f t); unfold algebra.Alg.eq_symb_bool in H; rewrite H;clear H;intros ;subst end . vm_compute in |-*;intros ;apply P_id_TOP_monotonic;assumption. match type of H with | orb ?a ?b = true => assert (H':{a = true}+{b = true});[ revert H;case a;[left;reflexivity|simpl;intros h;right;exact h]| clear H;destruct H' as [H|H]] end . match type of H with | _ _ ?t = true => generalize (algebra.F.symb_eq_bool_ok f t); unfold algebra.Alg.eq_symb_bool in H; rewrite H;clear H;intros ;subst end . vm_compute in |-*;intros ;apply P_id_CHECK_monotonic;assumption. match type of H with | orb ?a ?b = true => assert (H':{a = true}+{b = true});[ revert H;case a;[left;reflexivity|simpl;intros h;right;exact h]| clear H;destruct H' as [H|H]] end . match type of H with | _ _ ?t = true => generalize (algebra.F.symb_eq_bool_ok f t); unfold algebra.Alg.eq_symb_bool in H; rewrite H;clear H;intros ;subst end . vm_compute in |-*;intros ;apply P_id_PROPER_monotonic;assumption. match type of H with | orb ?a ?b = true => assert (H':{a = true}+{b = true});[ revert H;case a;[left;reflexivity|simpl;intros h;right;exact h]| clear H;destruct H' as [H|H]] end . match type of H with | _ _ ?t = true => generalize (algebra.F.symb_eq_bool_ok f t); unfold algebra.Alg.eq_symb_bool in H; rewrite H;clear H;intros ;subst end . vm_compute in |-*;intros ;apply P_id_F_monotonic;assumption. match type of H with | orb ?a ?b = true => assert (H':{a = true}+{b = true});[ revert H;case a;[left;reflexivity|simpl;intros h;right;exact h]| clear H;destruct H' as [H|H]] end . match type of H with | _ _ ?t = true => generalize (algebra.F.symb_eq_bool_ok f t); unfold algebra.Alg.eq_symb_bool in H; rewrite H;clear H;intros ;subst end . vm_compute in |-*;intros ;apply P_id_START_monotonic;assumption. match type of H with | orb ?a ?b = true => assert (H':{a = true}+{b = true});[ revert H;case a;[left;reflexivity|simpl;intros h;right;exact h]| clear H;destruct H' as [H|H]] end . match type of H with | _ _ ?t = true => generalize (algebra.F.symb_eq_bool_ok f t); unfold algebra.Alg.eq_symb_bool in H; rewrite H;clear H;intros ;subst end . vm_compute in |-*;intros ;apply P_id_ACTIVE_monotonic;assumption. discriminate H. assumption. Qed. End S. End Interp. Module InterpZ. Section S. Open Scope Z_scope. Hypothesis min_value : Z. Import ring_extention. Notation Local "'Alt'" := (Zwf.Zwf min_value). Notation Local "'Ale'" := Zle. Notation Local "'Aeq'" := (@eq Z). Notation Local "a <= b" := (Ale a b). Notation Local "a < b" := (Alt a b). Hypothesis P_id_active : Z ->Z. Hypothesis P_id_X : Z. Hypothesis P_id_c : Z. Hypothesis P_id_mark : Z ->Z. Hypothesis P_id_ok : Z ->Z. Hypothesis P_id_start : Z ->Z. Hypothesis P_id_f : Z ->Z. Hypothesis P_id_proper : Z ->Z. Hypothesis P_id_check : Z ->Z. Hypothesis P_id_top : Z ->Z. Hypothesis P_id_found : Z ->Z. Hypothesis P_id_match : Z ->Z ->Z. Hypothesis P_id_active_monotonic : forall x4 x5, (min_value <= x5)/\ (x5 <= x4) ->P_id_active x5 <= P_id_active x4. Hypothesis P_id_mark_monotonic : forall x4 x5, (min_value <= x5)/\ (x5 <= x4) ->P_id_mark x5 <= P_id_mark x4. Hypothesis P_id_ok_monotonic : forall x4 x5, (min_value <= x5)/\ (x5 <= x4) ->P_id_ok x5 <= P_id_ok x4. Hypothesis P_id_start_monotonic : forall x4 x5, (min_value <= x5)/\ (x5 <= x4) ->P_id_start x5 <= P_id_start x4. Hypothesis P_id_f_monotonic : forall x4 x5, (min_value <= x5)/\ (x5 <= x4) ->P_id_f x5 <= P_id_f x4. Hypothesis P_id_proper_monotonic : forall x4 x5, (min_value <= x5)/\ (x5 <= x4) ->P_id_proper x5 <= P_id_proper x4. Hypothesis P_id_check_monotonic : forall x4 x5, (min_value <= x5)/\ (x5 <= x4) ->P_id_check x5 <= P_id_check x4. Hypothesis P_id_top_monotonic : forall x4 x5, (min_value <= x5)/\ (x5 <= x4) ->P_id_top x5 <= P_id_top x4. Hypothesis P_id_found_monotonic : forall x4 x5, (min_value <= x5)/\ (x5 <= x4) ->P_id_found x5 <= P_id_found x4. Hypothesis P_id_match_monotonic : forall x4 x6 x5 x7, (min_value <= x7)/\ (x7 <= x6) -> (min_value <= x5)/\ (x5 <= x4) ->P_id_match x5 x7 <= P_id_match x4 x6. Hypothesis P_id_active_bounded : forall x4, (min_value <= x4) ->min_value <= P_id_active x4. Hypothesis P_id_X_bounded : min_value <= P_id_X . Hypothesis P_id_c_bounded : min_value <= P_id_c . Hypothesis P_id_mark_bounded : forall x4, (min_value <= x4) ->min_value <= P_id_mark x4. Hypothesis P_id_ok_bounded : forall x4, (min_value <= x4) ->min_value <= P_id_ok x4. Hypothesis P_id_start_bounded : forall x4, (min_value <= x4) ->min_value <= P_id_start x4. Hypothesis P_id_f_bounded : forall x4, (min_value <= x4) ->min_value <= P_id_f x4. Hypothesis P_id_proper_bounded : forall x4, (min_value <= x4) ->min_value <= P_id_proper x4. Hypothesis P_id_check_bounded : forall x4, (min_value <= x4) ->min_value <= P_id_check x4. Hypothesis P_id_top_bounded : forall x4, (min_value <= x4) ->min_value <= P_id_top x4. Hypothesis P_id_found_bounded : forall x4, (min_value <= x4) ->min_value <= P_id_found x4. Hypothesis P_id_match_bounded : forall x4 x5, (min_value <= x4) ->(min_value <= x5) ->min_value <= P_id_match x5 x4. Definition measure := Interp.measure min_value P_id_active P_id_X P_id_c P_id_mark P_id_ok P_id_start P_id_f P_id_proper P_id_check P_id_top P_id_found P_id_match . Lemma measure_equation : forall t, measure t = match t with | (algebra.Alg.Term algebra.F.id_active (x4::nil)) => P_id_active (measure x4) | (algebra.Alg.Term algebra.F.id_X nil) => P_id_X | (algebra.Alg.Term algebra.F.id_c nil) => P_id_c | (algebra.Alg.Term algebra.F.id_mark (x4::nil)) => P_id_mark (measure x4) | (algebra.Alg.Term algebra.F.id_ok (x4::nil)) => P_id_ok (measure x4) | (algebra.Alg.Term algebra.F.id_start (x4::nil)) => P_id_start (measure x4) | (algebra.Alg.Term algebra.F.id_f (x4::nil)) => P_id_f (measure x4) | (algebra.Alg.Term algebra.F.id_proper (x4::nil)) => P_id_proper (measure x4) | (algebra.Alg.Term algebra.F.id_check (x4::nil)) => P_id_check (measure x4) | (algebra.Alg.Term algebra.F.id_top (x4::nil)) => P_id_top (measure x4) | (algebra.Alg.Term algebra.F.id_found (x4::nil)) => P_id_found (measure x4) | (algebra.Alg.Term algebra.F.id_match (x5::x4::nil)) => P_id_match (measure x5) (measure x4) | _ => min_value end. Proof. intros t;case t;intros ;apply refl_equal. Qed. Lemma measure_bounded : forall t, min_value <= measure t. Proof. unfold measure in |-*. apply Interp.measure_bounded with Alt Aeq; (apply interp.o_Z)|| (cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;auto with zarith). Qed. Ltac generate_pos_hyp := match goal with | H:context [measure ?x] |- _ => let v := fresh "v" in (let H := fresh "h" in (set (H:=measure_bounded x) in *;set (v:=measure x) in *; clearbody H;clearbody v)) | |- context [measure ?x] => let v := fresh "v" in (let H := fresh "h" in (set (H:=measure_bounded x) in *;set (v:=measure x) in *; clearbody H;clearbody v)) end . Hypothesis rules_monotonic : forall l r, (algebra.EQT.axiom R_xml_0_deep_rew.R_xml_0_rules r l) -> measure r <= measure l. Lemma measure_star_monotonic : forall l r, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) r l) ->measure r <= measure l. Proof. unfold measure in *. apply Interp.measure_star_monotonic with Alt Aeq. (apply interp.o_Z)|| (cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;auto with zarith). intros ;apply P_id_active_monotonic;assumption. intros ;apply P_id_mark_monotonic;assumption. intros ;apply P_id_ok_monotonic;assumption. intros ;apply P_id_start_monotonic;assumption. intros ;apply P_id_f_monotonic;assumption. intros ;apply P_id_proper_monotonic;assumption. intros ;apply P_id_check_monotonic;assumption. intros ;apply P_id_top_monotonic;assumption. intros ;apply P_id_found_monotonic;assumption. intros ;apply P_id_match_monotonic;assumption. intros ;apply P_id_active_bounded;assumption. intros ;apply P_id_X_bounded;assumption. intros ;apply P_id_c_bounded;assumption. intros ;apply P_id_mark_bounded;assumption. intros ;apply P_id_ok_bounded;assumption. intros ;apply P_id_start_bounded;assumption. intros ;apply P_id_f_bounded;assumption. intros ;apply P_id_proper_bounded;assumption. intros ;apply P_id_check_bounded;assumption. intros ;apply P_id_top_bounded;assumption. intros ;apply P_id_found_bounded;assumption. intros ;apply P_id_match_bounded;assumption. apply rules_monotonic. Qed. Hypothesis P_id_MATCH : Z ->Z ->Z. Hypothesis P_id_TOP : Z ->Z. Hypothesis P_id_ACTIVE : Z ->Z. Hypothesis P_id_F : Z ->Z. Hypothesis P_id_PROPER : Z ->Z. Hypothesis P_id_CHECK : Z ->Z. Hypothesis P_id_START : Z ->Z. Hypothesis P_id_MATCH_monotonic : forall x4 x6 x5 x7, (min_value <= x7)/\ (x7 <= x6) -> (min_value <= x5)/\ (x5 <= x4) ->P_id_MATCH x5 x7 <= P_id_MATCH x4 x6. Hypothesis P_id_TOP_monotonic : forall x4 x5, (min_value <= x5)/\ (x5 <= x4) ->P_id_TOP x5 <= P_id_TOP x4. Hypothesis P_id_ACTIVE_monotonic : forall x4 x5, (min_value <= x5)/\ (x5 <= x4) ->P_id_ACTIVE x5 <= P_id_ACTIVE x4. Hypothesis P_id_F_monotonic : forall x4 x5, (min_value <= x5)/\ (x5 <= x4) ->P_id_F x5 <= P_id_F x4. Hypothesis P_id_PROPER_monotonic : forall x4 x5, (min_value <= x5)/\ (x5 <= x4) ->P_id_PROPER x5 <= P_id_PROPER x4. Hypothesis P_id_CHECK_monotonic : forall x4 x5, (min_value <= x5)/\ (x5 <= x4) ->P_id_CHECK x5 <= P_id_CHECK x4. Hypothesis P_id_START_monotonic : forall x4 x5, (min_value <= x5)/\ (x5 <= x4) ->P_id_START x5 <= P_id_START x4. Definition marked_measure := Interp.marked_measure min_value P_id_active P_id_X P_id_c P_id_mark P_id_ok P_id_start P_id_f P_id_proper P_id_check P_id_top P_id_found P_id_match P_id_MATCH P_id_TOP P_id_ACTIVE P_id_F P_id_PROPER P_id_CHECK P_id_START. Lemma marked_measure_equation : forall t, marked_measure t = match t with | (algebra.Alg.Term algebra.F.id_match (x5:: x4::nil)) => P_id_MATCH (measure x5) (measure x4) | (algebra.Alg.Term algebra.F.id_top (x4::nil)) => P_id_TOP (measure x4) | (algebra.Alg.Term algebra.F.id_active (x4::nil)) => P_id_ACTIVE (measure x4) | (algebra.Alg.Term algebra.F.id_f (x4::nil)) => P_id_F (measure x4) | (algebra.Alg.Term algebra.F.id_proper (x4::nil)) => P_id_PROPER (measure x4) | (algebra.Alg.Term algebra.F.id_check (x4::nil)) => P_id_CHECK (measure x4) | (algebra.Alg.Term algebra.F.id_start (x4::nil)) => P_id_START (measure x4) | _ => measure t end. Proof. reflexivity . Qed. Lemma marked_measure_star_monotonic : forall f l1 l2, (closure.refl_trans_clos (closure.one_step_list (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) ) l1 l2) -> marked_measure (algebra.Alg.Term f l1) <= marked_measure (algebra.Alg.Term f l2). Proof. unfold marked_measure in *. apply Interp.marked_measure_star_monotonic with Alt Aeq. (apply interp.o_Z)|| (cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;auto with zarith). intros ;apply P_id_active_monotonic;assumption. intros ;apply P_id_mark_monotonic;assumption. intros ;apply P_id_ok_monotonic;assumption. intros ;apply P_id_start_monotonic;assumption. intros ;apply P_id_f_monotonic;assumption. intros ;apply P_id_proper_monotonic;assumption. intros ;apply P_id_check_monotonic;assumption. intros ;apply P_id_top_monotonic;assumption. intros ;apply P_id_found_monotonic;assumption. intros ;apply P_id_match_monotonic;assumption. intros ;apply P_id_active_bounded;assumption. intros ;apply P_id_X_bounded;assumption. intros ;apply P_id_c_bounded;assumption. intros ;apply P_id_mark_bounded;assumption. intros ;apply P_id_ok_bounded;assumption. intros ;apply P_id_start_bounded;assumption. intros ;apply P_id_f_bounded;assumption. intros ;apply P_id_proper_bounded;assumption. intros ;apply P_id_check_bounded;assumption. intros ;apply P_id_top_bounded;assumption. intros ;apply P_id_found_bounded;assumption. intros ;apply P_id_match_bounded;assumption. apply rules_monotonic. intros ;apply P_id_MATCH_monotonic;assumption. intros ;apply P_id_TOP_monotonic;assumption. intros ;apply P_id_ACTIVE_monotonic;assumption. intros ;apply P_id_F_monotonic;assumption. intros ;apply P_id_PROPER_monotonic;assumption. intros ;apply P_id_CHECK_monotonic;assumption. intros ;apply P_id_START_monotonic;assumption. Qed. End S. End InterpZ. Module WF_R_xml_0_deep_rew. Inductive DP_R_xml_0 : algebra.Alg.term ->algebra.Alg.term ->Prop := (* *) | DP_R_xml_0_0 : forall x4, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) (algebra.Alg.Term algebra.F.id_active ((algebra.Alg.Term algebra.F.id_c nil)::nil)) x4) -> DP_R_xml_0 (algebra.Alg.Term algebra.F.id_top ((algebra.Alg.Term algebra.F.id_mark ((algebra.Alg.Term algebra.F.id_c nil)::nil))::nil)) (algebra.Alg.Term algebra.F.id_top (x4::nil)) (* *) | DP_R_xml_0_1 : forall x4 x1, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) (algebra.Alg.Term algebra.F.id_mark (x1::nil)) x4) -> DP_R_xml_0 (algebra.Alg.Term algebra.F.id_top ((algebra.Alg.Term algebra.F.id_check (x1::nil))::nil)) (algebra.Alg.Term algebra.F.id_top (x4::nil)) (* *) | DP_R_xml_0_2 : forall x4 x1, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) (algebra.Alg.Term algebra.F.id_mark (x1::nil)) x4) -> DP_R_xml_0 (algebra.Alg.Term algebra.F.id_check (x1::nil)) (algebra.Alg.Term algebra.F.id_top (x4::nil)) (* *) | DP_R_xml_0_3 : forall x4 x1, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) (algebra.Alg.Term algebra.F.id_f (x1::nil)) x4) -> DP_R_xml_0 (algebra.Alg.Term algebra.F.id_f ((algebra.Alg.Term algebra.F.id_check (x1::nil))::nil)) (algebra.Alg.Term algebra.F.id_check (x4::nil)) (* *) | DP_R_xml_0_4 : forall x4 x1, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) (algebra.Alg.Term algebra.F.id_f (x1::nil)) x4) -> DP_R_xml_0 (algebra.Alg.Term algebra.F.id_check (x1::nil)) (algebra.Alg.Term algebra.F.id_check (x4::nil)) (* *) | DP_R_xml_0_5 : forall x4 x1, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) x1 x4) -> DP_R_xml_0 (algebra.Alg.Term algebra.F.id_start ((algebra.Alg.Term algebra.F.id_match ((algebra.Alg.Term algebra.F.id_f ((algebra.Alg.Term algebra.F.id_X nil)::nil)):: x1::nil))::nil)) (algebra.Alg.Term algebra.F.id_check (x4::nil)) (* *) | DP_R_xml_0_6 : forall x4 x1, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) x1 x4) -> DP_R_xml_0 (algebra.Alg.Term algebra.F.id_match ((algebra.Alg.Term algebra.F.id_f ((algebra.Alg.Term algebra.F.id_X nil)::nil))::x1::nil)) (algebra.Alg.Term algebra.F.id_check (x4::nil)) (* *) | DP_R_xml_0_7 : forall x4 x1, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) x1 x4) -> DP_R_xml_0 (algebra.Alg.Term algebra.F.id_f ((algebra.Alg.Term algebra.F.id_X nil)::nil)) (algebra.Alg.Term algebra.F.id_check (x4::nil)) (* *) | DP_R_xml_0_8 : forall x4 x2 x1 x5, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) (algebra.Alg.Term algebra.F.id_f (x1::nil)) x5) -> (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) (algebra.Alg.Term algebra.F.id_f (x2::nil)) x4) -> DP_R_xml_0 (algebra.Alg.Term algebra.F.id_f ((algebra.Alg.Term algebra.F.id_match (x1::x2::nil))::nil)) (algebra.Alg.Term algebra.F.id_match (x5::x4::nil)) (* *) | DP_R_xml_0_9 : forall x4 x2 x1 x5, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) (algebra.Alg.Term algebra.F.id_f (x1::nil)) x5) -> (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) (algebra.Alg.Term algebra.F.id_f (x2::nil)) x4) -> DP_R_xml_0 (algebra.Alg.Term algebra.F.id_match (x1::x2::nil)) (algebra.Alg.Term algebra.F.id_match (x5::x4::nil)) (* *) | DP_R_xml_0_10 : forall x4 x1 x5, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) (algebra.Alg.Term algebra.F.id_X nil) x5) -> (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) x1 x4) -> DP_R_xml_0 (algebra.Alg.Term algebra.F.id_proper (x1::nil)) (algebra.Alg.Term algebra.F.id_match (x5::x4::nil)) (* *) | DP_R_xml_0_11 : forall x4 x1, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) (algebra.Alg.Term algebra.F.id_f (x1::nil)) x4) -> DP_R_xml_0 (algebra.Alg.Term algebra.F.id_f ((algebra.Alg.Term algebra.F.id_proper (x1::nil))::nil)) (algebra.Alg.Term algebra.F.id_proper (x4::nil)) (* *) | DP_R_xml_0_12 : forall x4 x1, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) (algebra.Alg.Term algebra.F.id_f (x1::nil)) x4) -> DP_R_xml_0 (algebra.Alg.Term algebra.F.id_proper (x1::nil)) (algebra.Alg.Term algebra.F.id_proper (x4::nil)) (* *) | DP_R_xml_0_13 : forall x4 x1, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) (algebra.Alg.Term algebra.F.id_ok (x1::nil)) x4) -> DP_R_xml_0 (algebra.Alg.Term algebra.F.id_f (x1::nil)) (algebra.Alg.Term algebra.F.id_f (x4::nil)) (* *) | DP_R_xml_0_14 : forall x4 x1, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) (algebra.Alg.Term algebra.F.id_found (x1::nil)) x4) -> DP_R_xml_0 (algebra.Alg.Term algebra.F.id_f (x1::nil)) (algebra.Alg.Term algebra.F.id_f (x4::nil)) (* *) | DP_R_xml_0_15 : forall x4 x1, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) (algebra.Alg.Term algebra.F.id_found (x1::nil)) x4) -> DP_R_xml_0 (algebra.Alg.Term algebra.F.id_top ((algebra.Alg.Term algebra.F.id_active (x1::nil))::nil)) (algebra.Alg.Term algebra.F.id_top (x4::nil)) (* *) | DP_R_xml_0_16 : forall x4 x1, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) (algebra.Alg.Term algebra.F.id_found (x1::nil)) x4) -> DP_R_xml_0 (algebra.Alg.Term algebra.F.id_active (x1::nil)) (algebra.Alg.Term algebra.F.id_top (x4::nil)) (* *) | DP_R_xml_0_17 : forall x4 x1, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) (algebra.Alg.Term algebra.F.id_f (x1::nil)) x4) -> DP_R_xml_0 (algebra.Alg.Term algebra.F.id_f ((algebra.Alg.Term algebra.F.id_active (x1::nil))::nil)) (algebra.Alg.Term algebra.F.id_active (x4::nil)) (* *) | DP_R_xml_0_18 : forall x4 x1, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) (algebra.Alg.Term algebra.F.id_f (x1::nil)) x4) -> DP_R_xml_0 (algebra.Alg.Term algebra.F.id_active (x1::nil)) (algebra.Alg.Term algebra.F.id_active (x4::nil)) (* *) | DP_R_xml_0_19 : forall x4 x1, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) (algebra.Alg.Term algebra.F.id_mark (x1::nil)) x4) -> DP_R_xml_0 (algebra.Alg.Term algebra.F.id_f (x1::nil)) (algebra.Alg.Term algebra.F.id_f (x4::nil)) . Module ddp := dp.MakeDP(algebra.EQT). Lemma R_xml_0_dp_step_spec : forall x y, (ddp.dp_step R_xml_0_deep_rew.R_xml_0_rules x y) -> exists f, exists l1, exists l2, y = algebra.Alg.Term f l2/\ (closure.refl_trans_clos (closure.one_step_list (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) ) l1 l2)/\ (ddp.dp R_xml_0_deep_rew.R_xml_0_rules x (algebra.Alg.Term f l1)). Proof. intros x y H. induction H. inversion H. subst. destruct t0. refine ((False_ind) _ _). refine (R_xml_0_deep_rew.R_xml_0_non_var H0). simpl in H|-*. exists a. exists ((List.map) (algebra.Alg.apply_subst sigma) l). exists ((List.map) (algebra.Alg.apply_subst sigma) l). repeat (constructor). assumption. exists f. exists l2. exists l1. constructor. constructor. constructor. constructor. rewrite <- closure.rwr_list_trans_clos_one_step_list. assumption. assumption. Qed. Ltac included_dp_tac H := injection H;clear H;intros;subst; repeat (match goal with | H: closure.refl_trans_clos (closure.one_step_list _) (_::_) _ |- _=> let x := fresh "x" in let l := fresh "l" in let h1 := fresh "h" in let h2 := fresh "h" in let h3 := fresh "h" in destruct (@algebra.EQT_ext.one_step_list_star_decompose_cons _ _ _ _ H) as [x [l[h1[h2 h3]]]];clear H;subst | H: closure.refl_trans_clos (closure.one_step_list _) nil _ |- _ => rewrite (@algebra.EQT_ext.one_step_list_star_decompose_nil _ _ H) in *;clear H end );simpl; econstructor eassumption . Ltac dp_concl_tac h2 h cont_tac t := match t with | False => let h' := fresh "a" in (set (h':=t) in *;cont_tac h'; repeat ( let e := type of h in (match e with | ?t => unfold t in h|-; (case h; [abstract (clear h;intros h;injection h; clear h;intros ;subst; included_dp_tac h2)| clear h;intros h;clear t]) | ?t => unfold t in h|-;elim h end ) )) | or ?a ?b => let cont_tac h' := let h'' := fresh "a" in (set (h'':=or a h') in *;cont_tac h'') in (dp_concl_tac h2 h cont_tac b) end . Module WF_DP_R_xml_0. Inductive DP_R_xml_0_scc_1 : algebra.Alg.term ->algebra.Alg.term ->Prop := (* *) | DP_R_xml_0_scc_1_0 : forall x4 x1, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) (algebra.Alg.Term algebra.F.id_found (x1::nil)) x4) -> DP_R_xml_0_scc_1 (algebra.Alg.Term algebra.F.id_f (x1::nil)) (algebra.Alg.Term algebra.F.id_f (x4::nil)) (* *) | DP_R_xml_0_scc_1_1 : forall x4 x1, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) (algebra.Alg.Term algebra.F.id_ok (x1::nil)) x4) -> DP_R_xml_0_scc_1 (algebra.Alg.Term algebra.F.id_f (x1::nil)) (algebra.Alg.Term algebra.F.id_f (x4::nil)) (* *) | DP_R_xml_0_scc_1_2 : forall x4 x1, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) (algebra.Alg.Term algebra.F.id_mark (x1::nil)) x4) -> DP_R_xml_0_scc_1 (algebra.Alg.Term algebra.F.id_f (x1::nil)) (algebra.Alg.Term algebra.F.id_f (x4::nil)) . Module WF_DP_R_xml_0_scc_1. Inductive DP_R_xml_0_scc_1_large : algebra.Alg.term ->algebra.Alg.term ->Prop := (* *) | DP_R_xml_0_scc_1_large_0 : forall x4 x1, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) (algebra.Alg.Term algebra.F.id_found (x1::nil)) x4) -> DP_R_xml_0_scc_1_large (algebra.Alg.Term algebra.F.id_f (x1::nil)) (algebra.Alg.Term algebra.F.id_f (x4::nil)) . Inductive DP_R_xml_0_scc_1_strict : algebra.Alg.term ->algebra.Alg.term ->Prop := (* *) | DP_R_xml_0_scc_1_strict_0 : forall x4 x1, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) (algebra.Alg.Term algebra.F.id_ok (x1::nil)) x4) -> DP_R_xml_0_scc_1_strict (algebra.Alg.Term algebra.F.id_f (x1::nil)) (algebra.Alg.Term algebra.F.id_f (x4::nil)) (* *) | DP_R_xml_0_scc_1_strict_1 : forall x4 x1, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) (algebra.Alg.Term algebra.F.id_mark (x1::nil)) x4) -> DP_R_xml_0_scc_1_strict (algebra.Alg.Term algebra.F.id_f (x1::nil)) (algebra.Alg.Term algebra.F.id_f (x4::nil)) . Module WF_DP_R_xml_0_scc_1_large. Open Scope Z_scope. Import ring_extention. Notation Local "a <= b" := (Zle a b). Notation Local "a < b" := (Zlt a b). Definition P_id_active (x4:Z) := 1* x4. Definition P_id_X := 0. Definition P_id_c := 0. Definition P_id_mark (x4:Z) := 1* x4. Definition P_id_ok (x4:Z) := 2* x4. Definition P_id_start (x4:Z) := 1 + 1* x4. Definition P_id_f (x4:Z) := 1* x4. Definition P_id_proper (x4:Z) := 0. Definition P_id_check (x4:Z) := 2 + 1* x4. Definition P_id_top (x4:Z) := 0. Definition P_id_found (x4:Z) := 1 + 1* x4. Definition P_id_match (x4:Z) (x5:Z) := 0. Lemma P_id_active_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_active x5 <= P_id_active x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_mark_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_mark x5 <= P_id_mark x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_ok_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_ok x5 <= P_id_ok x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_start_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_start x5 <= P_id_start x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_f_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_f x5 <= P_id_f x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_proper_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_proper x5 <= P_id_proper x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_check_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_check x5 <= P_id_check x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_top_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_top x5 <= P_id_top x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_found_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_found x5 <= P_id_found x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_match_monotonic : forall x4 x6 x5 x7, (0 <= x7)/\ (x7 <= x6) -> (0 <= x5)/\ (x5 <= x4) ->P_id_match x5 x7 <= P_id_match x4 x6. Proof. intros x7 x6 x5 x4. intros [H_1 H_0]. intros [H_3 H_2]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_active_bounded : forall x4, (0 <= x4) ->0 <= P_id_active x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_X_bounded : 0 <= P_id_X . Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_c_bounded : 0 <= P_id_c . Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_mark_bounded : forall x4, (0 <= x4) ->0 <= P_id_mark x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_ok_bounded : forall x4, (0 <= x4) ->0 <= P_id_ok x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_start_bounded : forall x4, (0 <= x4) ->0 <= P_id_start x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_f_bounded : forall x4, (0 <= x4) ->0 <= P_id_f x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_proper_bounded : forall x4, (0 <= x4) ->0 <= P_id_proper x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_check_bounded : forall x4, (0 <= x4) ->0 <= P_id_check x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_top_bounded : forall x4, (0 <= x4) ->0 <= P_id_top x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_found_bounded : forall x4, (0 <= x4) ->0 <= P_id_found x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_match_bounded : forall x4 x5, (0 <= x4) ->(0 <= x5) ->0 <= P_id_match x5 x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Definition measure := InterpZ.measure 0 P_id_active P_id_X P_id_c P_id_mark P_id_ok P_id_start P_id_f P_id_proper P_id_check P_id_top P_id_found P_id_match. Lemma measure_equation : forall t, measure t = match t with | (algebra.Alg.Term algebra.F.id_active (x4::nil)) => P_id_active (measure x4) | (algebra.Alg.Term algebra.F.id_X nil) => P_id_X | (algebra.Alg.Term algebra.F.id_c nil) => P_id_c | (algebra.Alg.Term algebra.F.id_mark (x4::nil)) => P_id_mark (measure x4) | (algebra.Alg.Term algebra.F.id_ok (x4::nil)) => P_id_ok (measure x4) | (algebra.Alg.Term algebra.F.id_start (x4::nil)) => P_id_start (measure x4) | (algebra.Alg.Term algebra.F.id_f (x4::nil)) => P_id_f (measure x4) | (algebra.Alg.Term algebra.F.id_proper (x4::nil)) => P_id_proper (measure x4) | (algebra.Alg.Term algebra.F.id_check (x4::nil)) => P_id_check (measure x4) | (algebra.Alg.Term algebra.F.id_top (x4::nil)) => P_id_top (measure x4) | (algebra.Alg.Term algebra.F.id_found (x4::nil)) => P_id_found (measure x4) | (algebra.Alg.Term algebra.F.id_match (x5::x4::nil)) => P_id_match (measure x5) (measure x4) | _ => 0 end. Proof. intros t;case t;intros ;apply refl_equal. Qed. Lemma measure_bounded : forall t, 0 <= measure t. Proof. unfold measure in |-*. apply InterpZ.measure_bounded; cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Ltac generate_pos_hyp := match goal with | H:context [measure ?x] |- _ => let v := fresh "v" in (let H := fresh "h" in (set (H:=measure_bounded x) in *;set (v:=measure x) in *; clearbody H;clearbody v)) | |- context [measure ?x] => let v := fresh "v" in (let H := fresh "h" in (set (H:=measure_bounded x) in *;set (v:=measure x) in *; clearbody H;clearbody v)) end . Lemma rules_monotonic : forall l r, (algebra.EQT.axiom R_xml_0_deep_rew.R_xml_0_rules r l) -> measure r <= measure l. Proof. intros l r H. fold measure in |-*. inversion H;clear H;subst;inversion H0;clear H0;subst; simpl algebra.EQT.T.apply_subst in |-*; repeat ( match goal with | |- context [measure (algebra.Alg.Term ?f ?t)] => rewrite (measure_equation (algebra.Alg.Term f t)) end );repeat (generate_pos_hyp ); cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma measure_star_monotonic : forall l r, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) r l) ->measure r <= measure l. Proof. unfold measure in *. apply InterpZ.measure_star_monotonic. intros ;apply P_id_active_monotonic;assumption. intros ;apply P_id_mark_monotonic;assumption. intros ;apply P_id_ok_monotonic;assumption. intros ;apply P_id_start_monotonic;assumption. intros ;apply P_id_f_monotonic;assumption. intros ;apply P_id_proper_monotonic;assumption. intros ;apply P_id_check_monotonic;assumption. intros ;apply P_id_top_monotonic;assumption. intros ;apply P_id_found_monotonic;assumption. intros ;apply P_id_match_monotonic;assumption. intros ;apply P_id_active_bounded;assumption. intros ;apply P_id_X_bounded;assumption. intros ;apply P_id_c_bounded;assumption. intros ;apply P_id_mark_bounded;assumption. intros ;apply P_id_ok_bounded;assumption. intros ;apply P_id_start_bounded;assumption. intros ;apply P_id_f_bounded;assumption. intros ;apply P_id_proper_bounded;assumption. intros ;apply P_id_check_bounded;assumption. intros ;apply P_id_top_bounded;assumption. intros ;apply P_id_found_bounded;assumption. intros ;apply P_id_match_bounded;assumption. apply rules_monotonic. Qed. Definition P_id_MATCH (x4:Z) (x5:Z) := 0. Definition P_id_TOP (x4:Z) := 0. Definition P_id_ACTIVE (x4:Z) := 0. Definition P_id_F (x4:Z) := 1* x4. Definition P_id_PROPER (x4:Z) := 0. Definition P_id_CHECK (x4:Z) := 0. Definition P_id_START (x4:Z) := 0. Lemma P_id_MATCH_monotonic : forall x4 x6 x5 x7, (0 <= x7)/\ (x7 <= x6) -> (0 <= x5)/\ (x5 <= x4) ->P_id_MATCH x5 x7 <= P_id_MATCH x4 x6. Proof. intros x7 x6 x5 x4. intros [H_1 H_0]. intros [H_3 H_2]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_TOP_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_TOP x5 <= P_id_TOP x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_ACTIVE_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_ACTIVE x5 <= P_id_ACTIVE x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_F_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_F x5 <= P_id_F x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_PROPER_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_PROPER x5 <= P_id_PROPER x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_CHECK_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_CHECK x5 <= P_id_CHECK x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_START_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_START x5 <= P_id_START x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Definition marked_measure := InterpZ.marked_measure 0 P_id_active P_id_X P_id_c P_id_mark P_id_ok P_id_start P_id_f P_id_proper P_id_check P_id_top P_id_found P_id_match P_id_MATCH P_id_TOP P_id_ACTIVE P_id_F P_id_PROPER P_id_CHECK P_id_START. Lemma marked_measure_equation : forall t, marked_measure t = match t with | (algebra.Alg.Term algebra.F.id_match (x5:: x4::nil)) => P_id_MATCH (measure x5) (measure x4) | (algebra.Alg.Term algebra.F.id_top (x4::nil)) => P_id_TOP (measure x4) | (algebra.Alg.Term algebra.F.id_active (x4::nil)) => P_id_ACTIVE (measure x4) | (algebra.Alg.Term algebra.F.id_f (x4::nil)) => P_id_F (measure x4) | (algebra.Alg.Term algebra.F.id_proper (x4::nil)) => P_id_PROPER (measure x4) | (algebra.Alg.Term algebra.F.id_check (x4::nil)) => P_id_CHECK (measure x4) | (algebra.Alg.Term algebra.F.id_start (x4::nil)) => P_id_START (measure x4) | _ => measure t end. Proof. reflexivity . Qed. Lemma marked_measure_star_monotonic : forall f l1 l2, (closure.refl_trans_clos (closure.one_step_list (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) ) l1 l2) -> marked_measure (algebra.Alg.Term f l1) <= marked_measure (algebra.Alg.Term f l2). Proof. unfold marked_measure in *. apply InterpZ.marked_measure_star_monotonic. intros ;apply P_id_active_monotonic;assumption. intros ;apply P_id_mark_monotonic;assumption. intros ;apply P_id_ok_monotonic;assumption. intros ;apply P_id_start_monotonic;assumption. intros ;apply P_id_f_monotonic;assumption. intros ;apply P_id_proper_monotonic;assumption. intros ;apply P_id_check_monotonic;assumption. intros ;apply P_id_top_monotonic;assumption. intros ;apply P_id_found_monotonic;assumption. intros ;apply P_id_match_monotonic;assumption. intros ;apply P_id_active_bounded;assumption. intros ;apply P_id_X_bounded;assumption. intros ;apply P_id_c_bounded;assumption. intros ;apply P_id_mark_bounded;assumption. intros ;apply P_id_ok_bounded;assumption. intros ;apply P_id_start_bounded;assumption. intros ;apply P_id_f_bounded;assumption. intros ;apply P_id_proper_bounded;assumption. intros ;apply P_id_check_bounded;assumption. intros ;apply P_id_top_bounded;assumption. intros ;apply P_id_found_bounded;assumption. intros ;apply P_id_match_bounded;assumption. apply rules_monotonic. intros ;apply P_id_MATCH_monotonic;assumption. intros ;apply P_id_TOP_monotonic;assumption. intros ;apply P_id_ACTIVE_monotonic;assumption. intros ;apply P_id_F_monotonic;assumption. intros ;apply P_id_PROPER_monotonic;assumption. intros ;apply P_id_CHECK_monotonic;assumption. intros ;apply P_id_START_monotonic;assumption. Qed. Ltac rewrite_and_unfold := do 2 (rewrite marked_measure_equation); repeat ( match goal with | |- context [measure (algebra.Alg.Term ?f ?t)] => rewrite (measure_equation (algebra.Alg.Term f t)) | H:context [measure (algebra.Alg.Term ?f ?t)] |- _ => rewrite (measure_equation (algebra.Alg.Term f t)) in H|- end ). Lemma wf : well_founded WF_DP_R_xml_0_scc_1.DP_R_xml_0_scc_1_large. Proof. intros x. apply well_founded_ind with (R:=fun x y => (Zwf.Zwf 0) (marked_measure x) (marked_measure y)). apply Inverse_Image.wf_inverse_image with (B:=Z). apply Zwf.Zwf_well_founded. clear x. intros x IHx. repeat ( constructor;inversion 1;subst; full_prove_ineq algebra.Alg.Term ltac:(algebra.Alg_ext.find_replacement ) algebra.EQT_ext.one_step_list_refl_trans_clos marked_measure marked_measure_star_monotonic (Zwf.Zwf 0) (interp.o_Z 0) ltac:(fun _ => R_xml_0_deep_rew.impossible_star_reduction_R_xml_0 ) ltac:(fun _ => rewrite_and_unfold ) ltac:(fun _ => generate_pos_hyp ) ltac:(fun _ => cbv beta iota zeta delta - [Zplus Zmult Zle Zlt] in * ; try (constructor)) IHx ). Qed. End WF_DP_R_xml_0_scc_1_large. Open Scope Z_scope. Import ring_extention. Notation Local "a <= b" := (Zle a b). Notation Local "a < b" := (Zlt a b). Definition P_id_active (x4:Z) := 2* x4. Definition P_id_X := 0. Definition P_id_c := 3. Definition P_id_mark (x4:Z) := 1 + 1* x4. Definition P_id_ok (x4:Z) := 3 + 1* x4. Definition P_id_start (x4:Z) := 1* x4. Definition P_id_f (x4:Z) := 1 + 1* x4. Definition P_id_proper (x4:Z) := 3* x4. Definition P_id_check (x4:Z) := 1 + 3* x4. Definition P_id_top (x4:Z) := 0. Definition P_id_found (x4:Z) := 1* x4. Definition P_id_match (x4:Z) (x5:Z) := 1 + 3* x5. Lemma P_id_active_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_active x5 <= P_id_active x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_mark_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_mark x5 <= P_id_mark x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_ok_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_ok x5 <= P_id_ok x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_start_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_start x5 <= P_id_start x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_f_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_f x5 <= P_id_f x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_proper_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_proper x5 <= P_id_proper x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_check_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_check x5 <= P_id_check x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_top_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_top x5 <= P_id_top x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_found_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_found x5 <= P_id_found x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_match_monotonic : forall x4 x6 x5 x7, (0 <= x7)/\ (x7 <= x6) -> (0 <= x5)/\ (x5 <= x4) ->P_id_match x5 x7 <= P_id_match x4 x6. Proof. intros x7 x6 x5 x4. intros [H_1 H_0]. intros [H_3 H_2]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_active_bounded : forall x4, (0 <= x4) ->0 <= P_id_active x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_X_bounded : 0 <= P_id_X . Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_c_bounded : 0 <= P_id_c . Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_mark_bounded : forall x4, (0 <= x4) ->0 <= P_id_mark x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_ok_bounded : forall x4, (0 <= x4) ->0 <= P_id_ok x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_start_bounded : forall x4, (0 <= x4) ->0 <= P_id_start x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_f_bounded : forall x4, (0 <= x4) ->0 <= P_id_f x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_proper_bounded : forall x4, (0 <= x4) ->0 <= P_id_proper x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_check_bounded : forall x4, (0 <= x4) ->0 <= P_id_check x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_top_bounded : forall x4, (0 <= x4) ->0 <= P_id_top x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_found_bounded : forall x4, (0 <= x4) ->0 <= P_id_found x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_match_bounded : forall x4 x5, (0 <= x4) ->(0 <= x5) ->0 <= P_id_match x5 x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Definition measure := InterpZ.measure 0 P_id_active P_id_X P_id_c P_id_mark P_id_ok P_id_start P_id_f P_id_proper P_id_check P_id_top P_id_found P_id_match . Lemma measure_equation : forall t, measure t = match t with | (algebra.Alg.Term algebra.F.id_active (x4::nil)) => P_id_active (measure x4) | (algebra.Alg.Term algebra.F.id_X nil) => P_id_X | (algebra.Alg.Term algebra.F.id_c nil) => P_id_c | (algebra.Alg.Term algebra.F.id_mark (x4::nil)) => P_id_mark (measure x4) | (algebra.Alg.Term algebra.F.id_ok (x4::nil)) => P_id_ok (measure x4) | (algebra.Alg.Term algebra.F.id_start (x4::nil)) => P_id_start (measure x4) | (algebra.Alg.Term algebra.F.id_f (x4::nil)) => P_id_f (measure x4) | (algebra.Alg.Term algebra.F.id_proper (x4::nil)) => P_id_proper (measure x4) | (algebra.Alg.Term algebra.F.id_check (x4::nil)) => P_id_check (measure x4) | (algebra.Alg.Term algebra.F.id_top (x4::nil)) => P_id_top (measure x4) | (algebra.Alg.Term algebra.F.id_found (x4::nil)) => P_id_found (measure x4) | (algebra.Alg.Term algebra.F.id_match (x5::x4::nil)) => P_id_match (measure x5) (measure x4) | _ => 0 end. Proof. intros t;case t;intros ;apply refl_equal. Qed. Lemma measure_bounded : forall t, 0 <= measure t. Proof. unfold measure in |-*. apply InterpZ.measure_bounded; cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Ltac generate_pos_hyp := match goal with | H:context [measure ?x] |- _ => let v := fresh "v" in (let H := fresh "h" in (set (H:=measure_bounded x) in *;set (v:=measure x) in *; clearbody H;clearbody v)) | |- context [measure ?x] => let v := fresh "v" in (let H := fresh "h" in (set (H:=measure_bounded x) in *;set (v:=measure x) in *; clearbody H;clearbody v)) end . Lemma rules_monotonic : forall l r, (algebra.EQT.axiom R_xml_0_deep_rew.R_xml_0_rules r l) -> measure r <= measure l. Proof. intros l r H. fold measure in |-*. inversion H;clear H;subst;inversion H0;clear H0;subst; simpl algebra.EQT.T.apply_subst in |-*; repeat ( match goal with | |- context [measure (algebra.Alg.Term ?f ?t)] => rewrite (measure_equation (algebra.Alg.Term f t)) end );repeat (generate_pos_hyp ); cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma measure_star_monotonic : forall l r, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) r l) ->measure r <= measure l. Proof. unfold measure in *. apply InterpZ.measure_star_monotonic. intros ;apply P_id_active_monotonic;assumption. intros ;apply P_id_mark_monotonic;assumption. intros ;apply P_id_ok_monotonic;assumption. intros ;apply P_id_start_monotonic;assumption. intros ;apply P_id_f_monotonic;assumption. intros ;apply P_id_proper_monotonic;assumption. intros ;apply P_id_check_monotonic;assumption. intros ;apply P_id_top_monotonic;assumption. intros ;apply P_id_found_monotonic;assumption. intros ;apply P_id_match_monotonic;assumption. intros ;apply P_id_active_bounded;assumption. intros ;apply P_id_X_bounded;assumption. intros ;apply P_id_c_bounded;assumption. intros ;apply P_id_mark_bounded;assumption. intros ;apply P_id_ok_bounded;assumption. intros ;apply P_id_start_bounded;assumption. intros ;apply P_id_f_bounded;assumption. intros ;apply P_id_proper_bounded;assumption. intros ;apply P_id_check_bounded;assumption. intros ;apply P_id_top_bounded;assumption. intros ;apply P_id_found_bounded;assumption. intros ;apply P_id_match_bounded;assumption. apply rules_monotonic. Qed. Definition P_id_MATCH (x4:Z) (x5:Z) := 0. Definition P_id_TOP (x4:Z) := 0. Definition P_id_ACTIVE (x4:Z) := 0. Definition P_id_F (x4:Z) := 2* x4. Definition P_id_PROPER (x4:Z) := 0. Definition P_id_CHECK (x4:Z) := 0. Definition P_id_START (x4:Z) := 0. Lemma P_id_MATCH_monotonic : forall x4 x6 x5 x7, (0 <= x7)/\ (x7 <= x6) -> (0 <= x5)/\ (x5 <= x4) ->P_id_MATCH x5 x7 <= P_id_MATCH x4 x6. Proof. intros x7 x6 x5 x4. intros [H_1 H_0]. intros [H_3 H_2]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_TOP_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_TOP x5 <= P_id_TOP x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_ACTIVE_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_ACTIVE x5 <= P_id_ACTIVE x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_F_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_F x5 <= P_id_F x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_PROPER_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_PROPER x5 <= P_id_PROPER x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_CHECK_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_CHECK x5 <= P_id_CHECK x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_START_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_START x5 <= P_id_START x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Definition marked_measure := InterpZ.marked_measure 0 P_id_active P_id_X P_id_c P_id_mark P_id_ok P_id_start P_id_f P_id_proper P_id_check P_id_top P_id_found P_id_match P_id_MATCH P_id_TOP P_id_ACTIVE P_id_F P_id_PROPER P_id_CHECK P_id_START. Lemma marked_measure_equation : forall t, marked_measure t = match t with | (algebra.Alg.Term algebra.F.id_match (x5:: x4::nil)) => P_id_MATCH (measure x5) (measure x4) | (algebra.Alg.Term algebra.F.id_top (x4::nil)) => P_id_TOP (measure x4) | (algebra.Alg.Term algebra.F.id_active (x4::nil)) => P_id_ACTIVE (measure x4) | (algebra.Alg.Term algebra.F.id_f (x4::nil)) => P_id_F (measure x4) | (algebra.Alg.Term algebra.F.id_proper (x4::nil)) => P_id_PROPER (measure x4) | (algebra.Alg.Term algebra.F.id_check (x4::nil)) => P_id_CHECK (measure x4) | (algebra.Alg.Term algebra.F.id_start (x4::nil)) => P_id_START (measure x4) | _ => measure t end. Proof. reflexivity . Qed. Lemma marked_measure_star_monotonic : forall f l1 l2, (closure.refl_trans_clos (closure.one_step_list (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) ) l1 l2) -> marked_measure (algebra.Alg.Term f l1) <= marked_measure (algebra.Alg.Term f l2). Proof. unfold marked_measure in *. apply InterpZ.marked_measure_star_monotonic. intros ;apply P_id_active_monotonic;assumption. intros ;apply P_id_mark_monotonic;assumption. intros ;apply P_id_ok_monotonic;assumption. intros ;apply P_id_start_monotonic;assumption. intros ;apply P_id_f_monotonic;assumption. intros ;apply P_id_proper_monotonic;assumption. intros ;apply P_id_check_monotonic;assumption. intros ;apply P_id_top_monotonic;assumption. intros ;apply P_id_found_monotonic;assumption. intros ;apply P_id_match_monotonic;assumption. intros ;apply P_id_active_bounded;assumption. intros ;apply P_id_X_bounded;assumption. intros ;apply P_id_c_bounded;assumption. intros ;apply P_id_mark_bounded;assumption. intros ;apply P_id_ok_bounded;assumption. intros ;apply P_id_start_bounded;assumption. intros ;apply P_id_f_bounded;assumption. intros ;apply P_id_proper_bounded;assumption. intros ;apply P_id_check_bounded;assumption. intros ;apply P_id_top_bounded;assumption. intros ;apply P_id_found_bounded;assumption. intros ;apply P_id_match_bounded;assumption. apply rules_monotonic. intros ;apply P_id_MATCH_monotonic;assumption. intros ;apply P_id_TOP_monotonic;assumption. intros ;apply P_id_ACTIVE_monotonic;assumption. intros ;apply P_id_F_monotonic;assumption. intros ;apply P_id_PROPER_monotonic;assumption. intros ;apply P_id_CHECK_monotonic;assumption. intros ;apply P_id_START_monotonic;assumption. Qed. Ltac rewrite_and_unfold := do 2 (rewrite marked_measure_equation); repeat ( match goal with | |- context [measure (algebra.Alg.Term ?f ?t)] => rewrite (measure_equation (algebra.Alg.Term f t)) | H:context [measure (algebra.Alg.Term ?f ?t)] |- _ => rewrite (measure_equation (algebra.Alg.Term f t)) in H|- end ). Definition lt a b := (Zwf.Zwf 0) (marked_measure a) (marked_measure b). Definition le a b := marked_measure a <= marked_measure b. Lemma lt_le_compat : forall a b c, (lt a b) ->(le b c) ->lt a c. Proof. unfold lt, le in *. intros a b c. apply (interp.le_lt_compat_right (interp.o_Z 0)). Qed. Lemma wf_lt : well_founded lt. Proof. unfold lt in *. apply Inverse_Image.wf_inverse_image with (B:=Z). apply Zwf.Zwf_well_founded. Qed. Lemma DP_R_xml_0_scc_1_strict_in_lt : Relation_Definitions.inclusion _ DP_R_xml_0_scc_1_strict lt. Proof. unfold Relation_Definitions.inclusion, lt in *. intros a b H;destruct H; match goal with | |- (Zwf.Zwf 0) _ (marked_measure (algebra.Alg.Term ?f ?l)) => let l'' := algebra.Alg_ext.find_replacement l in ((apply (interp.le_lt_compat_right (interp.o_Z 0)) with (marked_measure (algebra.Alg.Term f l''));[idtac| apply marked_measure_star_monotonic; repeat (apply algebra.EQT_ext.one_step_list_refl_trans_clos); (assumption)||(constructor 1)])) end ;clear ;rewrite_and_unfold ;repeat (generate_pos_hyp ); cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma DP_R_xml_0_scc_1_large_in_le : Relation_Definitions.inclusion _ DP_R_xml_0_scc_1_large le. Proof. unfold Relation_Definitions.inclusion, le, Zwf.Zwf in *. intros a b H;destruct H; match goal with | |- _ <= marked_measure (algebra.Alg.Term ?f ?l) => let l'' := algebra.Alg_ext.find_replacement l in ((apply (interp.le_trans (interp.o_Z 0)) with (marked_measure (algebra.Alg.Term f l''));[idtac| apply marked_measure_star_monotonic; repeat (apply algebra.EQT_ext.one_step_list_refl_trans_clos); (assumption)||(constructor 1)])) end ;clear ;rewrite_and_unfold ;repeat (generate_pos_hyp ); cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Definition wf_DP_R_xml_0_scc_1_large := WF_DP_R_xml_0_scc_1_large.wf. Lemma wf : well_founded WF_DP_R_xml_0.DP_R_xml_0_scc_1. Proof. intros x. apply (well_founded_ind wf_lt). clear x. intros x. pattern x. apply (@Acc_ind _ DP_R_xml_0_scc_1_large). clear x. intros x _ IHx IHx'. constructor. intros y H. destruct H; (apply IHx';apply DP_R_xml_0_scc_1_strict_in_lt; econstructor eassumption)|| ((apply IHx;[econstructor eassumption| intros y' Hlt;apply IHx';apply lt_le_compat with (1:=Hlt) ; apply DP_R_xml_0_scc_1_large_in_le;econstructor eassumption])). apply wf_DP_R_xml_0_scc_1_large. Qed. End WF_DP_R_xml_0_scc_1. Definition wf_DP_R_xml_0_scc_1 := WF_DP_R_xml_0_scc_1.wf. Lemma acc_DP_R_xml_0_scc_1 : forall x y, (DP_R_xml_0_scc_1 x y) ->Acc WF_R_xml_0_deep_rew.DP_R_xml_0 x. Proof. intros x. pattern x. apply (@Acc_ind _ DP_R_xml_0_scc_1). intros x' _ Hrec y h. inversion h;clear h;subst; constructor;intros _y _h;inversion _h;clear _h;subst; (eapply Hrec;econstructor eassumption)|| ((R_xml_0_deep_rew.impossible_star_reduction_R_xml_0 )|| (eapply Hrec;econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))). apply wf_DP_R_xml_0_scc_1. Qed. Inductive DP_R_xml_0_non_scc_2 : algebra.Alg.term ->algebra.Alg.term ->Prop := (* *) | DP_R_xml_0_non_scc_2_0 : forall x4 x1, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) (algebra.Alg.Term algebra.F.id_f (x1::nil)) x4) -> DP_R_xml_0_non_scc_2 (algebra.Alg.Term algebra.F.id_f ((algebra.Alg.Term algebra.F.id_active (x1::nil))::nil)) (algebra.Alg.Term algebra.F.id_active (x4::nil)) . Lemma acc_DP_R_xml_0_non_scc_2 : forall x y, (DP_R_xml_0_non_scc_2 x y) ->Acc WF_R_xml_0_deep_rew.DP_R_xml_0 x. Proof. intros x y h. inversion h;clear h;subst; constructor;intros _y _h;inversion _h;clear _h;subst; (eapply acc_DP_R_xml_0_scc_1; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))|| ((R_xml_0_deep_rew.impossible_star_reduction_R_xml_0 )|| (eapply Hrec;econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))). Qed. Inductive DP_R_xml_0_scc_3 : algebra.Alg.term ->algebra.Alg.term ->Prop := (* *) | DP_R_xml_0_scc_3_0 : forall x4 x1, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) (algebra.Alg.Term algebra.F.id_f (x1::nil)) x4) -> DP_R_xml_0_scc_3 (algebra.Alg.Term algebra.F.id_active (x1::nil)) (algebra.Alg.Term algebra.F.id_active (x4::nil)) . Module WF_DP_R_xml_0_scc_3. Open Scope Z_scope. Import ring_extention. Notation Local "a <= b" := (Zle a b). Notation Local "a < b" := (Zlt a b). Definition P_id_active (x4:Z) := 1* x4. Definition P_id_X := 0. Definition P_id_c := 1. Definition P_id_mark (x4:Z) := 1* x4. Definition P_id_ok (x4:Z) := 1. Definition P_id_start (x4:Z) := 1 + 1* x4. Definition P_id_f (x4:Z) := 1 + 2* x4. Definition P_id_proper (x4:Z) := 2* x4. Definition P_id_check (x4:Z) := 1 + 3* x4. Definition P_id_top (x4:Z) := 0. Definition P_id_found (x4:Z) := 0. Definition P_id_match (x4:Z) (x5:Z) := 3* x5. Lemma P_id_active_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_active x5 <= P_id_active x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_mark_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_mark x5 <= P_id_mark x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_ok_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_ok x5 <= P_id_ok x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_start_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_start x5 <= P_id_start x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_f_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_f x5 <= P_id_f x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_proper_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_proper x5 <= P_id_proper x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_check_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_check x5 <= P_id_check x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_top_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_top x5 <= P_id_top x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_found_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_found x5 <= P_id_found x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_match_monotonic : forall x4 x6 x5 x7, (0 <= x7)/\ (x7 <= x6) -> (0 <= x5)/\ (x5 <= x4) ->P_id_match x5 x7 <= P_id_match x4 x6. Proof. intros x7 x6 x5 x4. intros [H_1 H_0]. intros [H_3 H_2]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_active_bounded : forall x4, (0 <= x4) ->0 <= P_id_active x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_X_bounded : 0 <= P_id_X . Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_c_bounded : 0 <= P_id_c . Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_mark_bounded : forall x4, (0 <= x4) ->0 <= P_id_mark x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_ok_bounded : forall x4, (0 <= x4) ->0 <= P_id_ok x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_start_bounded : forall x4, (0 <= x4) ->0 <= P_id_start x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_f_bounded : forall x4, (0 <= x4) ->0 <= P_id_f x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_proper_bounded : forall x4, (0 <= x4) ->0 <= P_id_proper x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_check_bounded : forall x4, (0 <= x4) ->0 <= P_id_check x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_top_bounded : forall x4, (0 <= x4) ->0 <= P_id_top x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_found_bounded : forall x4, (0 <= x4) ->0 <= P_id_found x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_match_bounded : forall x4 x5, (0 <= x4) ->(0 <= x5) ->0 <= P_id_match x5 x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Definition measure := InterpZ.measure 0 P_id_active P_id_X P_id_c P_id_mark P_id_ok P_id_start P_id_f P_id_proper P_id_check P_id_top P_id_found P_id_match . Lemma measure_equation : forall t, measure t = match t with | (algebra.Alg.Term algebra.F.id_active (x4::nil)) => P_id_active (measure x4) | (algebra.Alg.Term algebra.F.id_X nil) => P_id_X | (algebra.Alg.Term algebra.F.id_c nil) => P_id_c | (algebra.Alg.Term algebra.F.id_mark (x4::nil)) => P_id_mark (measure x4) | (algebra.Alg.Term algebra.F.id_ok (x4::nil)) => P_id_ok (measure x4) | (algebra.Alg.Term algebra.F.id_start (x4::nil)) => P_id_start (measure x4) | (algebra.Alg.Term algebra.F.id_f (x4::nil)) => P_id_f (measure x4) | (algebra.Alg.Term algebra.F.id_proper (x4::nil)) => P_id_proper (measure x4) | (algebra.Alg.Term algebra.F.id_check (x4::nil)) => P_id_check (measure x4) | (algebra.Alg.Term algebra.F.id_top (x4::nil)) => P_id_top (measure x4) | (algebra.Alg.Term algebra.F.id_found (x4::nil)) => P_id_found (measure x4) | (algebra.Alg.Term algebra.F.id_match (x5::x4::nil)) => P_id_match (measure x5) (measure x4) | _ => 0 end. Proof. intros t;case t;intros ;apply refl_equal. Qed. Lemma measure_bounded : forall t, 0 <= measure t. Proof. unfold measure in |-*. apply InterpZ.measure_bounded; cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Ltac generate_pos_hyp := match goal with | H:context [measure ?x] |- _ => let v := fresh "v" in (let H := fresh "h" in (set (H:=measure_bounded x) in *;set (v:=measure x) in *; clearbody H;clearbody v)) | |- context [measure ?x] => let v := fresh "v" in (let H := fresh "h" in (set (H:=measure_bounded x) in *;set (v:=measure x) in *; clearbody H;clearbody v)) end . Lemma rules_monotonic : forall l r, (algebra.EQT.axiom R_xml_0_deep_rew.R_xml_0_rules r l) -> measure r <= measure l. Proof. intros l r H. fold measure in |-*. inversion H;clear H;subst;inversion H0;clear H0;subst; simpl algebra.EQT.T.apply_subst in |-*; repeat ( match goal with | |- context [measure (algebra.Alg.Term ?f ?t)] => rewrite (measure_equation (algebra.Alg.Term f t)) end );repeat (generate_pos_hyp ); cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma measure_star_monotonic : forall l r, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) r l) ->measure r <= measure l. Proof. unfold measure in *. apply InterpZ.measure_star_monotonic. intros ;apply P_id_active_monotonic;assumption. intros ;apply P_id_mark_monotonic;assumption. intros ;apply P_id_ok_monotonic;assumption. intros ;apply P_id_start_monotonic;assumption. intros ;apply P_id_f_monotonic;assumption. intros ;apply P_id_proper_monotonic;assumption. intros ;apply P_id_check_monotonic;assumption. intros ;apply P_id_top_monotonic;assumption. intros ;apply P_id_found_monotonic;assumption. intros ;apply P_id_match_monotonic;assumption. intros ;apply P_id_active_bounded;assumption. intros ;apply P_id_X_bounded;assumption. intros ;apply P_id_c_bounded;assumption. intros ;apply P_id_mark_bounded;assumption. intros ;apply P_id_ok_bounded;assumption. intros ;apply P_id_start_bounded;assumption. intros ;apply P_id_f_bounded;assumption. intros ;apply P_id_proper_bounded;assumption. intros ;apply P_id_check_bounded;assumption. intros ;apply P_id_top_bounded;assumption. intros ;apply P_id_found_bounded;assumption. intros ;apply P_id_match_bounded;assumption. apply rules_monotonic. Qed. Definition P_id_MATCH (x4:Z) (x5:Z) := 0. Definition P_id_TOP (x4:Z) := 0. Definition P_id_ACTIVE (x4:Z) := 1* x4. Definition P_id_F (x4:Z) := 0. Definition P_id_PROPER (x4:Z) := 0. Definition P_id_CHECK (x4:Z) := 0. Definition P_id_START (x4:Z) := 0. Lemma P_id_MATCH_monotonic : forall x4 x6 x5 x7, (0 <= x7)/\ (x7 <= x6) -> (0 <= x5)/\ (x5 <= x4) ->P_id_MATCH x5 x7 <= P_id_MATCH x4 x6. Proof. intros x7 x6 x5 x4. intros [H_1 H_0]. intros [H_3 H_2]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_TOP_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_TOP x5 <= P_id_TOP x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_ACTIVE_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_ACTIVE x5 <= P_id_ACTIVE x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_F_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_F x5 <= P_id_F x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_PROPER_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_PROPER x5 <= P_id_PROPER x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_CHECK_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_CHECK x5 <= P_id_CHECK x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_START_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_START x5 <= P_id_START x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Definition marked_measure := InterpZ.marked_measure 0 P_id_active P_id_X P_id_c P_id_mark P_id_ok P_id_start P_id_f P_id_proper P_id_check P_id_top P_id_found P_id_match P_id_MATCH P_id_TOP P_id_ACTIVE P_id_F P_id_PROPER P_id_CHECK P_id_START. Lemma marked_measure_equation : forall t, marked_measure t = match t with | (algebra.Alg.Term algebra.F.id_match (x5:: x4::nil)) => P_id_MATCH (measure x5) (measure x4) | (algebra.Alg.Term algebra.F.id_top (x4::nil)) => P_id_TOP (measure x4) | (algebra.Alg.Term algebra.F.id_active (x4::nil)) => P_id_ACTIVE (measure x4) | (algebra.Alg.Term algebra.F.id_f (x4::nil)) => P_id_F (measure x4) | (algebra.Alg.Term algebra.F.id_proper (x4::nil)) => P_id_PROPER (measure x4) | (algebra.Alg.Term algebra.F.id_check (x4::nil)) => P_id_CHECK (measure x4) | (algebra.Alg.Term algebra.F.id_start (x4::nil)) => P_id_START (measure x4) | _ => measure t end. Proof. reflexivity . Qed. Lemma marked_measure_star_monotonic : forall f l1 l2, (closure.refl_trans_clos (closure.one_step_list (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) ) l1 l2) -> marked_measure (algebra.Alg.Term f l1) <= marked_measure (algebra.Alg.Term f l2). Proof. unfold marked_measure in *. apply InterpZ.marked_measure_star_monotonic. intros ;apply P_id_active_monotonic;assumption. intros ;apply P_id_mark_monotonic;assumption. intros ;apply P_id_ok_monotonic;assumption. intros ;apply P_id_start_monotonic;assumption. intros ;apply P_id_f_monotonic;assumption. intros ;apply P_id_proper_monotonic;assumption. intros ;apply P_id_check_monotonic;assumption. intros ;apply P_id_top_monotonic;assumption. intros ;apply P_id_found_monotonic;assumption. intros ;apply P_id_match_monotonic;assumption. intros ;apply P_id_active_bounded;assumption. intros ;apply P_id_X_bounded;assumption. intros ;apply P_id_c_bounded;assumption. intros ;apply P_id_mark_bounded;assumption. intros ;apply P_id_ok_bounded;assumption. intros ;apply P_id_start_bounded;assumption. intros ;apply P_id_f_bounded;assumption. intros ;apply P_id_proper_bounded;assumption. intros ;apply P_id_check_bounded;assumption. intros ;apply P_id_top_bounded;assumption. intros ;apply P_id_found_bounded;assumption. intros ;apply P_id_match_bounded;assumption. apply rules_monotonic. intros ;apply P_id_MATCH_monotonic;assumption. intros ;apply P_id_TOP_monotonic;assumption. intros ;apply P_id_ACTIVE_monotonic;assumption. intros ;apply P_id_F_monotonic;assumption. intros ;apply P_id_PROPER_monotonic;assumption. intros ;apply P_id_CHECK_monotonic;assumption. intros ;apply P_id_START_monotonic;assumption. Qed. Ltac rewrite_and_unfold := do 2 (rewrite marked_measure_equation); repeat ( match goal with | |- context [measure (algebra.Alg.Term ?f ?t)] => rewrite (measure_equation (algebra.Alg.Term f t)) | H:context [measure (algebra.Alg.Term ?f ?t)] |- _ => rewrite (measure_equation (algebra.Alg.Term f t)) in H|- end ). Lemma wf : well_founded WF_DP_R_xml_0.DP_R_xml_0_scc_3. Proof. intros x. apply well_founded_ind with (R:=fun x y => (Zwf.Zwf 0) (marked_measure x) (marked_measure y)). apply Inverse_Image.wf_inverse_image with (B:=Z). apply Zwf.Zwf_well_founded. clear x. intros x IHx. repeat ( constructor;inversion 1;subst; full_prove_ineq algebra.Alg.Term ltac:(algebra.Alg_ext.find_replacement ) algebra.EQT_ext.one_step_list_refl_trans_clos marked_measure marked_measure_star_monotonic (Zwf.Zwf 0) (interp.o_Z 0) ltac:(fun _ => R_xml_0_deep_rew.impossible_star_reduction_R_xml_0 ) ltac:(fun _ => rewrite_and_unfold ) ltac:(fun _ => generate_pos_hyp ) ltac:(fun _ => cbv beta iota zeta delta - [Zplus Zmult Zle Zlt] in * ; try (constructor)) IHx ). Qed. End WF_DP_R_xml_0_scc_3. Definition wf_DP_R_xml_0_scc_3 := WF_DP_R_xml_0_scc_3.wf. Lemma acc_DP_R_xml_0_scc_3 : forall x y, (DP_R_xml_0_scc_3 x y) ->Acc WF_R_xml_0_deep_rew.DP_R_xml_0 x. Proof. intros x. pattern x. apply (@Acc_ind _ DP_R_xml_0_scc_3). intros x' _ Hrec y h. inversion h;clear h;subst; constructor;intros _y _h;inversion _h;clear _h;subst; (eapply Hrec;econstructor eassumption)|| ((eapply acc_DP_R_xml_0_non_scc_2; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))|| ((R_xml_0_deep_rew.impossible_star_reduction_R_xml_0 )|| (eapply Hrec; econstructor (eassumption)||(algebra.Alg_ext.star_refl' )))). apply wf_DP_R_xml_0_scc_3. Qed. Inductive DP_R_xml_0_non_scc_4 : algebra.Alg.term ->algebra.Alg.term ->Prop := (* *) | DP_R_xml_0_non_scc_4_0 : forall x4 x1, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) (algebra.Alg.Term algebra.F.id_found (x1::nil)) x4) -> DP_R_xml_0_non_scc_4 (algebra.Alg.Term algebra.F.id_active (x1::nil)) (algebra.Alg.Term algebra.F.id_top (x4::nil)) . Lemma acc_DP_R_xml_0_non_scc_4 : forall x y, (DP_R_xml_0_non_scc_4 x y) ->Acc WF_R_xml_0_deep_rew.DP_R_xml_0 x. Proof. intros x y h. inversion h;clear h;subst; constructor;intros _y _h;inversion _h;clear _h;subst; (eapply acc_DP_R_xml_0_scc_3; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))|| ((eapply acc_DP_R_xml_0_non_scc_2; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))|| ((R_xml_0_deep_rew.impossible_star_reduction_R_xml_0 )|| (eapply Hrec; econstructor (eassumption)||(algebra.Alg_ext.star_refl' )))). Qed. Inductive DP_R_xml_0_non_scc_5 : algebra.Alg.term ->algebra.Alg.term ->Prop := (* *) | DP_R_xml_0_non_scc_5_0 : forall x4 x1, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) (algebra.Alg.Term algebra.F.id_f (x1::nil)) x4) -> DP_R_xml_0_non_scc_5 (algebra.Alg.Term algebra.F.id_f ((algebra.Alg.Term algebra.F.id_proper (x1::nil))::nil)) (algebra.Alg.Term algebra.F.id_proper (x4::nil)) . Lemma acc_DP_R_xml_0_non_scc_5 : forall x y, (DP_R_xml_0_non_scc_5 x y) ->Acc WF_R_xml_0_deep_rew.DP_R_xml_0 x. Proof. intros x y h. inversion h;clear h;subst; constructor;intros _y _h;inversion _h;clear _h;subst; (eapply acc_DP_R_xml_0_scc_1; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))|| ((R_xml_0_deep_rew.impossible_star_reduction_R_xml_0 )|| (eapply Hrec;econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))). Qed. Inductive DP_R_xml_0_scc_6 : algebra.Alg.term ->algebra.Alg.term ->Prop := (* *) | DP_R_xml_0_scc_6_0 : forall x4 x1, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) (algebra.Alg.Term algebra.F.id_f (x1::nil)) x4) -> DP_R_xml_0_scc_6 (algebra.Alg.Term algebra.F.id_proper (x1::nil)) (algebra.Alg.Term algebra.F.id_proper (x4::nil)) . Module WF_DP_R_xml_0_scc_6. Open Scope Z_scope. Import ring_extention. Notation Local "a <= b" := (Zle a b). Notation Local "a < b" := (Zlt a b). Definition P_id_active (x4:Z) := 1* x4. Definition P_id_X := 0. Definition P_id_c := 1. Definition P_id_mark (x4:Z) := 1* x4. Definition P_id_ok (x4:Z) := 1. Definition P_id_start (x4:Z) := 1 + 1* x4. Definition P_id_f (x4:Z) := 1 + 2* x4. Definition P_id_proper (x4:Z) := 2* x4. Definition P_id_check (x4:Z) := 1 + 3* x4. Definition P_id_top (x4:Z) := 0. Definition P_id_found (x4:Z) := 0. Definition P_id_match (x4:Z) (x5:Z) := 3* x5. Lemma P_id_active_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_active x5 <= P_id_active x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_mark_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_mark x5 <= P_id_mark x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_ok_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_ok x5 <= P_id_ok x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_start_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_start x5 <= P_id_start x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_f_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_f x5 <= P_id_f x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_proper_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_proper x5 <= P_id_proper x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_check_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_check x5 <= P_id_check x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_top_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_top x5 <= P_id_top x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_found_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_found x5 <= P_id_found x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_match_monotonic : forall x4 x6 x5 x7, (0 <= x7)/\ (x7 <= x6) -> (0 <= x5)/\ (x5 <= x4) ->P_id_match x5 x7 <= P_id_match x4 x6. Proof. intros x7 x6 x5 x4. intros [H_1 H_0]. intros [H_3 H_2]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_active_bounded : forall x4, (0 <= x4) ->0 <= P_id_active x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_X_bounded : 0 <= P_id_X . Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_c_bounded : 0 <= P_id_c . Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_mark_bounded : forall x4, (0 <= x4) ->0 <= P_id_mark x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_ok_bounded : forall x4, (0 <= x4) ->0 <= P_id_ok x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_start_bounded : forall x4, (0 <= x4) ->0 <= P_id_start x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_f_bounded : forall x4, (0 <= x4) ->0 <= P_id_f x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_proper_bounded : forall x4, (0 <= x4) ->0 <= P_id_proper x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_check_bounded : forall x4, (0 <= x4) ->0 <= P_id_check x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_top_bounded : forall x4, (0 <= x4) ->0 <= P_id_top x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_found_bounded : forall x4, (0 <= x4) ->0 <= P_id_found x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_match_bounded : forall x4 x5, (0 <= x4) ->(0 <= x5) ->0 <= P_id_match x5 x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Definition measure := InterpZ.measure 0 P_id_active P_id_X P_id_c P_id_mark P_id_ok P_id_start P_id_f P_id_proper P_id_check P_id_top P_id_found P_id_match . Lemma measure_equation : forall t, measure t = match t with | (algebra.Alg.Term algebra.F.id_active (x4::nil)) => P_id_active (measure x4) | (algebra.Alg.Term algebra.F.id_X nil) => P_id_X | (algebra.Alg.Term algebra.F.id_c nil) => P_id_c | (algebra.Alg.Term algebra.F.id_mark (x4::nil)) => P_id_mark (measure x4) | (algebra.Alg.Term algebra.F.id_ok (x4::nil)) => P_id_ok (measure x4) | (algebra.Alg.Term algebra.F.id_start (x4::nil)) => P_id_start (measure x4) | (algebra.Alg.Term algebra.F.id_f (x4::nil)) => P_id_f (measure x4) | (algebra.Alg.Term algebra.F.id_proper (x4::nil)) => P_id_proper (measure x4) | (algebra.Alg.Term algebra.F.id_check (x4::nil)) => P_id_check (measure x4) | (algebra.Alg.Term algebra.F.id_top (x4::nil)) => P_id_top (measure x4) | (algebra.Alg.Term algebra.F.id_found (x4::nil)) => P_id_found (measure x4) | (algebra.Alg.Term algebra.F.id_match (x5::x4::nil)) => P_id_match (measure x5) (measure x4) | _ => 0 end. Proof. intros t;case t;intros ;apply refl_equal. Qed. Lemma measure_bounded : forall t, 0 <= measure t. Proof. unfold measure in |-*. apply InterpZ.measure_bounded; cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Ltac generate_pos_hyp := match goal with | H:context [measure ?x] |- _ => let v := fresh "v" in (let H := fresh "h" in (set (H:=measure_bounded x) in *;set (v:=measure x) in *; clearbody H;clearbody v)) | |- context [measure ?x] => let v := fresh "v" in (let H := fresh "h" in (set (H:=measure_bounded x) in *;set (v:=measure x) in *; clearbody H;clearbody v)) end . Lemma rules_monotonic : forall l r, (algebra.EQT.axiom R_xml_0_deep_rew.R_xml_0_rules r l) -> measure r <= measure l. Proof. intros l r H. fold measure in |-*. inversion H;clear H;subst;inversion H0;clear H0;subst; simpl algebra.EQT.T.apply_subst in |-*; repeat ( match goal with | |- context [measure (algebra.Alg.Term ?f ?t)] => rewrite (measure_equation (algebra.Alg.Term f t)) end );repeat (generate_pos_hyp ); cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma measure_star_monotonic : forall l r, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) r l) ->measure r <= measure l. Proof. unfold measure in *. apply InterpZ.measure_star_monotonic. intros ;apply P_id_active_monotonic;assumption. intros ;apply P_id_mark_monotonic;assumption. intros ;apply P_id_ok_monotonic;assumption. intros ;apply P_id_start_monotonic;assumption. intros ;apply P_id_f_monotonic;assumption. intros ;apply P_id_proper_monotonic;assumption. intros ;apply P_id_check_monotonic;assumption. intros ;apply P_id_top_monotonic;assumption. intros ;apply P_id_found_monotonic;assumption. intros ;apply P_id_match_monotonic;assumption. intros ;apply P_id_active_bounded;assumption. intros ;apply P_id_X_bounded;assumption. intros ;apply P_id_c_bounded;assumption. intros ;apply P_id_mark_bounded;assumption. intros ;apply P_id_ok_bounded;assumption. intros ;apply P_id_start_bounded;assumption. intros ;apply P_id_f_bounded;assumption. intros ;apply P_id_proper_bounded;assumption. intros ;apply P_id_check_bounded;assumption. intros ;apply P_id_top_bounded;assumption. intros ;apply P_id_found_bounded;assumption. intros ;apply P_id_match_bounded;assumption. apply rules_monotonic. Qed. Definition P_id_MATCH (x4:Z) (x5:Z) := 0. Definition P_id_TOP (x4:Z) := 0. Definition P_id_ACTIVE (x4:Z) := 0. Definition P_id_F (x4:Z) := 0. Definition P_id_PROPER (x4:Z) := 1* x4. Definition P_id_CHECK (x4:Z) := 0. Definition P_id_START (x4:Z) := 0. Lemma P_id_MATCH_monotonic : forall x4 x6 x5 x7, (0 <= x7)/\ (x7 <= x6) -> (0 <= x5)/\ (x5 <= x4) ->P_id_MATCH x5 x7 <= P_id_MATCH x4 x6. Proof. intros x7 x6 x5 x4. intros [H_1 H_0]. intros [H_3 H_2]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_TOP_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_TOP x5 <= P_id_TOP x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_ACTIVE_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_ACTIVE x5 <= P_id_ACTIVE x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_F_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_F x5 <= P_id_F x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_PROPER_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_PROPER x5 <= P_id_PROPER x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_CHECK_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_CHECK x5 <= P_id_CHECK x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_START_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_START x5 <= P_id_START x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Definition marked_measure := InterpZ.marked_measure 0 P_id_active P_id_X P_id_c P_id_mark P_id_ok P_id_start P_id_f P_id_proper P_id_check P_id_top P_id_found P_id_match P_id_MATCH P_id_TOP P_id_ACTIVE P_id_F P_id_PROPER P_id_CHECK P_id_START. Lemma marked_measure_equation : forall t, marked_measure t = match t with | (algebra.Alg.Term algebra.F.id_match (x5:: x4::nil)) => P_id_MATCH (measure x5) (measure x4) | (algebra.Alg.Term algebra.F.id_top (x4::nil)) => P_id_TOP (measure x4) | (algebra.Alg.Term algebra.F.id_active (x4::nil)) => P_id_ACTIVE (measure x4) | (algebra.Alg.Term algebra.F.id_f (x4::nil)) => P_id_F (measure x4) | (algebra.Alg.Term algebra.F.id_proper (x4::nil)) => P_id_PROPER (measure x4) | (algebra.Alg.Term algebra.F.id_check (x4::nil)) => P_id_CHECK (measure x4) | (algebra.Alg.Term algebra.F.id_start (x4::nil)) => P_id_START (measure x4) | _ => measure t end. Proof. reflexivity . Qed. Lemma marked_measure_star_monotonic : forall f l1 l2, (closure.refl_trans_clos (closure.one_step_list (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) ) l1 l2) -> marked_measure (algebra.Alg.Term f l1) <= marked_measure (algebra.Alg.Term f l2). Proof. unfold marked_measure in *. apply InterpZ.marked_measure_star_monotonic. intros ;apply P_id_active_monotonic;assumption. intros ;apply P_id_mark_monotonic;assumption. intros ;apply P_id_ok_monotonic;assumption. intros ;apply P_id_start_monotonic;assumption. intros ;apply P_id_f_monotonic;assumption. intros ;apply P_id_proper_monotonic;assumption. intros ;apply P_id_check_monotonic;assumption. intros ;apply P_id_top_monotonic;assumption. intros ;apply P_id_found_monotonic;assumption. intros ;apply P_id_match_monotonic;assumption. intros ;apply P_id_active_bounded;assumption. intros ;apply P_id_X_bounded;assumption. intros ;apply P_id_c_bounded;assumption. intros ;apply P_id_mark_bounded;assumption. intros ;apply P_id_ok_bounded;assumption. intros ;apply P_id_start_bounded;assumption. intros ;apply P_id_f_bounded;assumption. intros ;apply P_id_proper_bounded;assumption. intros ;apply P_id_check_bounded;assumption. intros ;apply P_id_top_bounded;assumption. intros ;apply P_id_found_bounded;assumption. intros ;apply P_id_match_bounded;assumption. apply rules_monotonic. intros ;apply P_id_MATCH_monotonic;assumption. intros ;apply P_id_TOP_monotonic;assumption. intros ;apply P_id_ACTIVE_monotonic;assumption. intros ;apply P_id_F_monotonic;assumption. intros ;apply P_id_PROPER_monotonic;assumption. intros ;apply P_id_CHECK_monotonic;assumption. intros ;apply P_id_START_monotonic;assumption. Qed. Ltac rewrite_and_unfold := do 2 (rewrite marked_measure_equation); repeat ( match goal with | |- context [measure (algebra.Alg.Term ?f ?t)] => rewrite (measure_equation (algebra.Alg.Term f t)) | H:context [measure (algebra.Alg.Term ?f ?t)] |- _ => rewrite (measure_equation (algebra.Alg.Term f t)) in H|- end ). Lemma wf : well_founded WF_DP_R_xml_0.DP_R_xml_0_scc_6. Proof. intros x. apply well_founded_ind with (R:=fun x y => (Zwf.Zwf 0) (marked_measure x) (marked_measure y)). apply Inverse_Image.wf_inverse_image with (B:=Z). apply Zwf.Zwf_well_founded. clear x. intros x IHx. repeat ( constructor;inversion 1;subst; full_prove_ineq algebra.Alg.Term ltac:(algebra.Alg_ext.find_replacement ) algebra.EQT_ext.one_step_list_refl_trans_clos marked_measure marked_measure_star_monotonic (Zwf.Zwf 0) (interp.o_Z 0) ltac:(fun _ => R_xml_0_deep_rew.impossible_star_reduction_R_xml_0 ) ltac:(fun _ => rewrite_and_unfold ) ltac:(fun _ => generate_pos_hyp ) ltac:(fun _ => cbv beta iota zeta delta - [Zplus Zmult Zle Zlt] in * ; try (constructor)) IHx ). Qed. End WF_DP_R_xml_0_scc_6. Definition wf_DP_R_xml_0_scc_6 := WF_DP_R_xml_0_scc_6.wf. Lemma acc_DP_R_xml_0_scc_6 : forall x y, (DP_R_xml_0_scc_6 x y) ->Acc WF_R_xml_0_deep_rew.DP_R_xml_0 x. Proof. intros x. pattern x. apply (@Acc_ind _ DP_R_xml_0_scc_6). intros x' _ Hrec y h. inversion h;clear h;subst; constructor;intros _y _h;inversion _h;clear _h;subst; (eapply Hrec;econstructor eassumption)|| ((eapply acc_DP_R_xml_0_non_scc_5; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))|| ((R_xml_0_deep_rew.impossible_star_reduction_R_xml_0 )|| (eapply Hrec; econstructor (eassumption)||(algebra.Alg_ext.star_refl' )))). apply wf_DP_R_xml_0_scc_6. Qed. Inductive DP_R_xml_0_non_scc_7 : algebra.Alg.term ->algebra.Alg.term ->Prop := (* *) | DP_R_xml_0_non_scc_7_0 : forall x4 x1 x5, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) (algebra.Alg.Term algebra.F.id_X nil) x5) -> (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) x1 x4) -> DP_R_xml_0_non_scc_7 (algebra.Alg.Term algebra.F.id_proper (x1::nil)) (algebra.Alg.Term algebra.F.id_match (x5::x4::nil)) . Lemma acc_DP_R_xml_0_non_scc_7 : forall x y, (DP_R_xml_0_non_scc_7 x y) ->Acc WF_R_xml_0_deep_rew.DP_R_xml_0 x. Proof. intros x y h. inversion h;clear h;subst; constructor;intros _y _h;inversion _h;clear _h;subst; (eapply acc_DP_R_xml_0_scc_6; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))|| ((eapply acc_DP_R_xml_0_non_scc_5; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))|| ((R_xml_0_deep_rew.impossible_star_reduction_R_xml_0 )|| (eapply Hrec; econstructor (eassumption)||(algebra.Alg_ext.star_refl' )))). Qed. Inductive DP_R_xml_0_non_scc_8 : algebra.Alg.term ->algebra.Alg.term ->Prop := (* *) | DP_R_xml_0_non_scc_8_0 : forall x4 x2 x1 x5, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) (algebra.Alg.Term algebra.F.id_f (x1::nil)) x5) -> (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) (algebra.Alg.Term algebra.F.id_f (x2::nil)) x4) -> DP_R_xml_0_non_scc_8 (algebra.Alg.Term algebra.F.id_f ((algebra.Alg.Term algebra.F.id_match (x1:: x2::nil))::nil)) (algebra.Alg.Term algebra.F.id_match (x5::x4::nil)) . Lemma acc_DP_R_xml_0_non_scc_8 : forall x y, (DP_R_xml_0_non_scc_8 x y) ->Acc WF_R_xml_0_deep_rew.DP_R_xml_0 x. Proof. intros x y h. inversion h;clear h;subst; constructor;intros _y _h;inversion _h;clear _h;subst; (eapply acc_DP_R_xml_0_scc_1; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))|| ((R_xml_0_deep_rew.impossible_star_reduction_R_xml_0 )|| (eapply Hrec;econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))). Qed. Inductive DP_R_xml_0_scc_9 : algebra.Alg.term ->algebra.Alg.term ->Prop := (* *) | DP_R_xml_0_scc_9_0 : forall x4 x2 x1 x5, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) (algebra.Alg.Term algebra.F.id_f (x1::nil)) x5) -> (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) (algebra.Alg.Term algebra.F.id_f (x2::nil)) x4) -> DP_R_xml_0_scc_9 (algebra.Alg.Term algebra.F.id_match (x1::x2::nil)) (algebra.Alg.Term algebra.F.id_match (x5::x4::nil)) . Module WF_DP_R_xml_0_scc_9. Open Scope Z_scope. Import ring_extention. Notation Local "a <= b" := (Zle a b). Notation Local "a < b" := (Zlt a b). Definition P_id_active (x4:Z) := 1* x4. Definition P_id_X := 0. Definition P_id_c := 1. Definition P_id_mark (x4:Z) := 0. Definition P_id_ok (x4:Z) := 0. Definition P_id_start (x4:Z) := 0. Definition P_id_f (x4:Z) := 1 + 2* x4. Definition P_id_proper (x4:Z) := 2* x4. Definition P_id_check (x4:Z) := 2* x4. Definition P_id_top (x4:Z) := 0. Definition P_id_found (x4:Z) := 0. Definition P_id_match (x4:Z) (x5:Z) := 2* x5. Lemma P_id_active_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_active x5 <= P_id_active x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_mark_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_mark x5 <= P_id_mark x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_ok_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_ok x5 <= P_id_ok x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_start_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_start x5 <= P_id_start x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_f_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_f x5 <= P_id_f x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_proper_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_proper x5 <= P_id_proper x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_check_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_check x5 <= P_id_check x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_top_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_top x5 <= P_id_top x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_found_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_found x5 <= P_id_found x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_match_monotonic : forall x4 x6 x5 x7, (0 <= x7)/\ (x7 <= x6) -> (0 <= x5)/\ (x5 <= x4) ->P_id_match x5 x7 <= P_id_match x4 x6. Proof. intros x7 x6 x5 x4. intros [H_1 H_0]. intros [H_3 H_2]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_active_bounded : forall x4, (0 <= x4) ->0 <= P_id_active x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_X_bounded : 0 <= P_id_X . Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_c_bounded : 0 <= P_id_c . Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_mark_bounded : forall x4, (0 <= x4) ->0 <= P_id_mark x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_ok_bounded : forall x4, (0 <= x4) ->0 <= P_id_ok x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_start_bounded : forall x4, (0 <= x4) ->0 <= P_id_start x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_f_bounded : forall x4, (0 <= x4) ->0 <= P_id_f x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_proper_bounded : forall x4, (0 <= x4) ->0 <= P_id_proper x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_check_bounded : forall x4, (0 <= x4) ->0 <= P_id_check x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_top_bounded : forall x4, (0 <= x4) ->0 <= P_id_top x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_found_bounded : forall x4, (0 <= x4) ->0 <= P_id_found x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_match_bounded : forall x4 x5, (0 <= x4) ->(0 <= x5) ->0 <= P_id_match x5 x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Definition measure := InterpZ.measure 0 P_id_active P_id_X P_id_c P_id_mark P_id_ok P_id_start P_id_f P_id_proper P_id_check P_id_top P_id_found P_id_match . Lemma measure_equation : forall t, measure t = match t with | (algebra.Alg.Term algebra.F.id_active (x4::nil)) => P_id_active (measure x4) | (algebra.Alg.Term algebra.F.id_X nil) => P_id_X | (algebra.Alg.Term algebra.F.id_c nil) => P_id_c | (algebra.Alg.Term algebra.F.id_mark (x4::nil)) => P_id_mark (measure x4) | (algebra.Alg.Term algebra.F.id_ok (x4::nil)) => P_id_ok (measure x4) | (algebra.Alg.Term algebra.F.id_start (x4::nil)) => P_id_start (measure x4) | (algebra.Alg.Term algebra.F.id_f (x4::nil)) => P_id_f (measure x4) | (algebra.Alg.Term algebra.F.id_proper (x4::nil)) => P_id_proper (measure x4) | (algebra.Alg.Term algebra.F.id_check (x4::nil)) => P_id_check (measure x4) | (algebra.Alg.Term algebra.F.id_top (x4::nil)) => P_id_top (measure x4) | (algebra.Alg.Term algebra.F.id_found (x4::nil)) => P_id_found (measure x4) | (algebra.Alg.Term algebra.F.id_match (x5::x4::nil)) => P_id_match (measure x5) (measure x4) | _ => 0 end. Proof. intros t;case t;intros ;apply refl_equal. Qed. Lemma measure_bounded : forall t, 0 <= measure t. Proof. unfold measure in |-*. apply InterpZ.measure_bounded; cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Ltac generate_pos_hyp := match goal with | H:context [measure ?x] |- _ => let v := fresh "v" in (let H := fresh "h" in (set (H:=measure_bounded x) in *;set (v:=measure x) in *; clearbody H;clearbody v)) | |- context [measure ?x] => let v := fresh "v" in (let H := fresh "h" in (set (H:=measure_bounded x) in *;set (v:=measure x) in *; clearbody H;clearbody v)) end . Lemma rules_monotonic : forall l r, (algebra.EQT.axiom R_xml_0_deep_rew.R_xml_0_rules r l) -> measure r <= measure l. Proof. intros l r H. fold measure in |-*. inversion H;clear H;subst;inversion H0;clear H0;subst; simpl algebra.EQT.T.apply_subst in |-*; repeat ( match goal with | |- context [measure (algebra.Alg.Term ?f ?t)] => rewrite (measure_equation (algebra.Alg.Term f t)) end );repeat (generate_pos_hyp ); cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma measure_star_monotonic : forall l r, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) r l) ->measure r <= measure l. Proof. unfold measure in *. apply InterpZ.measure_star_monotonic. intros ;apply P_id_active_monotonic;assumption. intros ;apply P_id_mark_monotonic;assumption. intros ;apply P_id_ok_monotonic;assumption. intros ;apply P_id_start_monotonic;assumption. intros ;apply P_id_f_monotonic;assumption. intros ;apply P_id_proper_monotonic;assumption. intros ;apply P_id_check_monotonic;assumption. intros ;apply P_id_top_monotonic;assumption. intros ;apply P_id_found_monotonic;assumption. intros ;apply P_id_match_monotonic;assumption. intros ;apply P_id_active_bounded;assumption. intros ;apply P_id_X_bounded;assumption. intros ;apply P_id_c_bounded;assumption. intros ;apply P_id_mark_bounded;assumption. intros ;apply P_id_ok_bounded;assumption. intros ;apply P_id_start_bounded;assumption. intros ;apply P_id_f_bounded;assumption. intros ;apply P_id_proper_bounded;assumption. intros ;apply P_id_check_bounded;assumption. intros ;apply P_id_top_bounded;assumption. intros ;apply P_id_found_bounded;assumption. intros ;apply P_id_match_bounded;assumption. apply rules_monotonic. Qed. Definition P_id_MATCH (x4:Z) (x5:Z) := 1* x4. Definition P_id_TOP (x4:Z) := 0. Definition P_id_ACTIVE (x4:Z) := 0. Definition P_id_F (x4:Z) := 0. Definition P_id_PROPER (x4:Z) := 0. Definition P_id_CHECK (x4:Z) := 0. Definition P_id_START (x4:Z) := 0. Lemma P_id_MATCH_monotonic : forall x4 x6 x5 x7, (0 <= x7)/\ (x7 <= x6) -> (0 <= x5)/\ (x5 <= x4) ->P_id_MATCH x5 x7 <= P_id_MATCH x4 x6. Proof. intros x7 x6 x5 x4. intros [H_1 H_0]. intros [H_3 H_2]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_TOP_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_TOP x5 <= P_id_TOP x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_ACTIVE_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_ACTIVE x5 <= P_id_ACTIVE x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_F_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_F x5 <= P_id_F x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_PROPER_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_PROPER x5 <= P_id_PROPER x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_CHECK_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_CHECK x5 <= P_id_CHECK x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_START_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_START x5 <= P_id_START x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Definition marked_measure := InterpZ.marked_measure 0 P_id_active P_id_X P_id_c P_id_mark P_id_ok P_id_start P_id_f P_id_proper P_id_check P_id_top P_id_found P_id_match P_id_MATCH P_id_TOP P_id_ACTIVE P_id_F P_id_PROPER P_id_CHECK P_id_START. Lemma marked_measure_equation : forall t, marked_measure t = match t with | (algebra.Alg.Term algebra.F.id_match (x5:: x4::nil)) => P_id_MATCH (measure x5) (measure x4) | (algebra.Alg.Term algebra.F.id_top (x4::nil)) => P_id_TOP (measure x4) | (algebra.Alg.Term algebra.F.id_active (x4::nil)) => P_id_ACTIVE (measure x4) | (algebra.Alg.Term algebra.F.id_f (x4::nil)) => P_id_F (measure x4) | (algebra.Alg.Term algebra.F.id_proper (x4::nil)) => P_id_PROPER (measure x4) | (algebra.Alg.Term algebra.F.id_check (x4::nil)) => P_id_CHECK (measure x4) | (algebra.Alg.Term algebra.F.id_start (x4::nil)) => P_id_START (measure x4) | _ => measure t end. Proof. reflexivity . Qed. Lemma marked_measure_star_monotonic : forall f l1 l2, (closure.refl_trans_clos (closure.one_step_list (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) ) l1 l2) -> marked_measure (algebra.Alg.Term f l1) <= marked_measure (algebra.Alg.Term f l2). Proof. unfold marked_measure in *. apply InterpZ.marked_measure_star_monotonic. intros ;apply P_id_active_monotonic;assumption. intros ;apply P_id_mark_monotonic;assumption. intros ;apply P_id_ok_monotonic;assumption. intros ;apply P_id_start_monotonic;assumption. intros ;apply P_id_f_monotonic;assumption. intros ;apply P_id_proper_monotonic;assumption. intros ;apply P_id_check_monotonic;assumption. intros ;apply P_id_top_monotonic;assumption. intros ;apply P_id_found_monotonic;assumption. intros ;apply P_id_match_monotonic;assumption. intros ;apply P_id_active_bounded;assumption. intros ;apply P_id_X_bounded;assumption. intros ;apply P_id_c_bounded;assumption. intros ;apply P_id_mark_bounded;assumption. intros ;apply P_id_ok_bounded;assumption. intros ;apply P_id_start_bounded;assumption. intros ;apply P_id_f_bounded;assumption. intros ;apply P_id_proper_bounded;assumption. intros ;apply P_id_check_bounded;assumption. intros ;apply P_id_top_bounded;assumption. intros ;apply P_id_found_bounded;assumption. intros ;apply P_id_match_bounded;assumption. apply rules_monotonic. intros ;apply P_id_MATCH_monotonic;assumption. intros ;apply P_id_TOP_monotonic;assumption. intros ;apply P_id_ACTIVE_monotonic;assumption. intros ;apply P_id_F_monotonic;assumption. intros ;apply P_id_PROPER_monotonic;assumption. intros ;apply P_id_CHECK_monotonic;assumption. intros ;apply P_id_START_monotonic;assumption. Qed. Ltac rewrite_and_unfold := do 2 (rewrite marked_measure_equation); repeat ( match goal with | |- context [measure (algebra.Alg.Term ?f ?t)] => rewrite (measure_equation (algebra.Alg.Term f t)) | H:context [measure (algebra.Alg.Term ?f ?t)] |- _ => rewrite (measure_equation (algebra.Alg.Term f t)) in H|- end ). Lemma wf : well_founded WF_DP_R_xml_0.DP_R_xml_0_scc_9. Proof. intros x. apply well_founded_ind with (R:=fun x y => (Zwf.Zwf 0) (marked_measure x) (marked_measure y)). apply Inverse_Image.wf_inverse_image with (B:=Z). apply Zwf.Zwf_well_founded. clear x. intros x IHx. repeat ( constructor;inversion 1;subst; full_prove_ineq algebra.Alg.Term ltac:(algebra.Alg_ext.find_replacement ) algebra.EQT_ext.one_step_list_refl_trans_clos marked_measure marked_measure_star_monotonic (Zwf.Zwf 0) (interp.o_Z 0) ltac:(fun _ => R_xml_0_deep_rew.impossible_star_reduction_R_xml_0 ) ltac:(fun _ => rewrite_and_unfold ) ltac:(fun _ => generate_pos_hyp ) ltac:(fun _ => cbv beta iota zeta delta - [Zplus Zmult Zle Zlt] in * ; try (constructor)) IHx ). Qed. End WF_DP_R_xml_0_scc_9. Definition wf_DP_R_xml_0_scc_9 := WF_DP_R_xml_0_scc_9.wf. Lemma acc_DP_R_xml_0_scc_9 : forall x y, (DP_R_xml_0_scc_9 x y) ->Acc WF_R_xml_0_deep_rew.DP_R_xml_0 x. Proof. intros x. pattern x. apply (@Acc_ind _ DP_R_xml_0_scc_9). intros x' _ Hrec y h. inversion h;clear h;subst; constructor;intros _y _h;inversion _h;clear _h;subst; (eapply Hrec;econstructor eassumption)|| ((eapply acc_DP_R_xml_0_non_scc_8; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))|| ((eapply acc_DP_R_xml_0_non_scc_7; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))|| ((R_xml_0_deep_rew.impossible_star_reduction_R_xml_0 )|| (eapply Hrec; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))))). apply wf_DP_R_xml_0_scc_9. Qed. Inductive DP_R_xml_0_non_scc_10 : algebra.Alg.term ->algebra.Alg.term ->Prop := (* *) | DP_R_xml_0_non_scc_10_0 : forall x4 x1, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) x1 x4) -> DP_R_xml_0_non_scc_10 (algebra.Alg.Term algebra.F.id_f ((algebra.Alg.Term algebra.F.id_X nil)::nil)) (algebra.Alg.Term algebra.F.id_check (x4::nil)) . Lemma acc_DP_R_xml_0_non_scc_10 : forall x y, (DP_R_xml_0_non_scc_10 x y) ->Acc WF_R_xml_0_deep_rew.DP_R_xml_0 x. Proof. intros x y h. inversion h;clear h;subst; constructor;intros _y _h;inversion _h;clear _h;subst; (eapply acc_DP_R_xml_0_scc_1; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))|| ((R_xml_0_deep_rew.impossible_star_reduction_R_xml_0 )|| (eapply Hrec;econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))). Qed. Inductive DP_R_xml_0_non_scc_11 : algebra.Alg.term ->algebra.Alg.term ->Prop := (* *) | DP_R_xml_0_non_scc_11_0 : forall x4 x1, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) x1 x4) -> DP_R_xml_0_non_scc_11 (algebra.Alg.Term algebra.F.id_match ((algebra.Alg.Term algebra.F.id_f ((algebra.Alg.Term algebra.F.id_X nil)::nil)):: x1::nil)) (algebra.Alg.Term algebra.F.id_check (x4::nil)) . Lemma acc_DP_R_xml_0_non_scc_11 : forall x y, (DP_R_xml_0_non_scc_11 x y) ->Acc WF_R_xml_0_deep_rew.DP_R_xml_0 x. Proof. intros x y h. inversion h;clear h;subst; constructor;intros _y _h;inversion _h;clear _h;subst; (eapply acc_DP_R_xml_0_scc_9; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))|| ((eapply acc_DP_R_xml_0_non_scc_8; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))|| ((eapply acc_DP_R_xml_0_non_scc_7; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))|| ((R_xml_0_deep_rew.impossible_star_reduction_R_xml_0 )|| (eapply Hrec; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))))). Qed. Inductive DP_R_xml_0_non_scc_12 : algebra.Alg.term ->algebra.Alg.term ->Prop := (* *) | DP_R_xml_0_non_scc_12_0 : forall x4 x1, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) x1 x4) -> DP_R_xml_0_non_scc_12 (algebra.Alg.Term algebra.F.id_start ((algebra.Alg.Term algebra.F.id_match ((algebra.Alg.Term algebra.F.id_f ((algebra.Alg.Term algebra.F.id_X nil)::nil)):: x1::nil))::nil)) (algebra.Alg.Term algebra.F.id_check (x4::nil)) . Lemma acc_DP_R_xml_0_non_scc_12 : forall x y, (DP_R_xml_0_non_scc_12 x y) ->Acc WF_R_xml_0_deep_rew.DP_R_xml_0 x. Proof. intros x y h. inversion h;clear h;subst; constructor;intros _y _h;inversion _h;clear _h;subst; (R_xml_0_deep_rew.impossible_star_reduction_R_xml_0 )|| (eapply Hrec;econstructor (eassumption)||(algebra.Alg_ext.star_refl' )). Qed. Inductive DP_R_xml_0_non_scc_13 : algebra.Alg.term ->algebra.Alg.term ->Prop := (* *) | DP_R_xml_0_non_scc_13_0 : forall x4 x1, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) (algebra.Alg.Term algebra.F.id_f (x1::nil)) x4) -> DP_R_xml_0_non_scc_13 (algebra.Alg.Term algebra.F.id_f ((algebra.Alg.Term algebra.F.id_check (x1::nil))::nil)) (algebra.Alg.Term algebra.F.id_check (x4::nil)) . Lemma acc_DP_R_xml_0_non_scc_13 : forall x y, (DP_R_xml_0_non_scc_13 x y) ->Acc WF_R_xml_0_deep_rew.DP_R_xml_0 x. Proof. intros x y h. inversion h;clear h;subst; constructor;intros _y _h;inversion _h;clear _h;subst; (eapply acc_DP_R_xml_0_scc_1; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))|| ((R_xml_0_deep_rew.impossible_star_reduction_R_xml_0 )|| (eapply Hrec;econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))). Qed. Inductive DP_R_xml_0_scc_14 : algebra.Alg.term ->algebra.Alg.term ->Prop := (* *) | DP_R_xml_0_scc_14_0 : forall x4 x1, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) (algebra.Alg.Term algebra.F.id_f (x1::nil)) x4) -> DP_R_xml_0_scc_14 (algebra.Alg.Term algebra.F.id_check (x1::nil)) (algebra.Alg.Term algebra.F.id_check (x4::nil)) . Module WF_DP_R_xml_0_scc_14. Open Scope Z_scope. Import ring_extention. Notation Local "a <= b" := (Zle a b). Notation Local "a < b" := (Zlt a b). Definition P_id_active (x4:Z) := 1* x4. Definition P_id_X := 0. Definition P_id_c := 1. Definition P_id_mark (x4:Z) := 1* x4. Definition P_id_ok (x4:Z) := 1. Definition P_id_start (x4:Z) := 1 + 1* x4. Definition P_id_f (x4:Z) := 1 + 2* x4. Definition P_id_proper (x4:Z) := 2* x4. Definition P_id_check (x4:Z) := 1 + 3* x4. Definition P_id_top (x4:Z) := 0. Definition P_id_found (x4:Z) := 0. Definition P_id_match (x4:Z) (x5:Z) := 3* x5. Lemma P_id_active_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_active x5 <= P_id_active x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_mark_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_mark x5 <= P_id_mark x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_ok_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_ok x5 <= P_id_ok x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_start_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_start x5 <= P_id_start x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_f_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_f x5 <= P_id_f x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_proper_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_proper x5 <= P_id_proper x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_check_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_check x5 <= P_id_check x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_top_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_top x5 <= P_id_top x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_found_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_found x5 <= P_id_found x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_match_monotonic : forall x4 x6 x5 x7, (0 <= x7)/\ (x7 <= x6) -> (0 <= x5)/\ (x5 <= x4) ->P_id_match x5 x7 <= P_id_match x4 x6. Proof. intros x7 x6 x5 x4. intros [H_1 H_0]. intros [H_3 H_2]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_active_bounded : forall x4, (0 <= x4) ->0 <= P_id_active x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_X_bounded : 0 <= P_id_X . Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_c_bounded : 0 <= P_id_c . Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_mark_bounded : forall x4, (0 <= x4) ->0 <= P_id_mark x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_ok_bounded : forall x4, (0 <= x4) ->0 <= P_id_ok x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_start_bounded : forall x4, (0 <= x4) ->0 <= P_id_start x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_f_bounded : forall x4, (0 <= x4) ->0 <= P_id_f x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_proper_bounded : forall x4, (0 <= x4) ->0 <= P_id_proper x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_check_bounded : forall x4, (0 <= x4) ->0 <= P_id_check x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_top_bounded : forall x4, (0 <= x4) ->0 <= P_id_top x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_found_bounded : forall x4, (0 <= x4) ->0 <= P_id_found x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_match_bounded : forall x4 x5, (0 <= x4) ->(0 <= x5) ->0 <= P_id_match x5 x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Definition measure := InterpZ.measure 0 P_id_active P_id_X P_id_c P_id_mark P_id_ok P_id_start P_id_f P_id_proper P_id_check P_id_top P_id_found P_id_match . Lemma measure_equation : forall t, measure t = match t with | (algebra.Alg.Term algebra.F.id_active (x4::nil)) => P_id_active (measure x4) | (algebra.Alg.Term algebra.F.id_X nil) => P_id_X | (algebra.Alg.Term algebra.F.id_c nil) => P_id_c | (algebra.Alg.Term algebra.F.id_mark (x4::nil)) => P_id_mark (measure x4) | (algebra.Alg.Term algebra.F.id_ok (x4::nil)) => P_id_ok (measure x4) | (algebra.Alg.Term algebra.F.id_start (x4::nil)) => P_id_start (measure x4) | (algebra.Alg.Term algebra.F.id_f (x4::nil)) => P_id_f (measure x4) | (algebra.Alg.Term algebra.F.id_proper (x4::nil)) => P_id_proper (measure x4) | (algebra.Alg.Term algebra.F.id_check (x4::nil)) => P_id_check (measure x4) | (algebra.Alg.Term algebra.F.id_top (x4::nil)) => P_id_top (measure x4) | (algebra.Alg.Term algebra.F.id_found (x4::nil)) => P_id_found (measure x4) | (algebra.Alg.Term algebra.F.id_match (x5::x4::nil)) => P_id_match (measure x5) (measure x4) | _ => 0 end. Proof. intros t;case t;intros ;apply refl_equal. Qed. Lemma measure_bounded : forall t, 0 <= measure t. Proof. unfold measure in |-*. apply InterpZ.measure_bounded; cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Ltac generate_pos_hyp := match goal with | H:context [measure ?x] |- _ => let v := fresh "v" in (let H := fresh "h" in (set (H:=measure_bounded x) in *;set (v:=measure x) in *; clearbody H;clearbody v)) | |- context [measure ?x] => let v := fresh "v" in (let H := fresh "h" in (set (H:=measure_bounded x) in *;set (v:=measure x) in *; clearbody H;clearbody v)) end . Lemma rules_monotonic : forall l r, (algebra.EQT.axiom R_xml_0_deep_rew.R_xml_0_rules r l) -> measure r <= measure l. Proof. intros l r H. fold measure in |-*. inversion H;clear H;subst;inversion H0;clear H0;subst; simpl algebra.EQT.T.apply_subst in |-*; repeat ( match goal with | |- context [measure (algebra.Alg.Term ?f ?t)] => rewrite (measure_equation (algebra.Alg.Term f t)) end );repeat (generate_pos_hyp ); cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma measure_star_monotonic : forall l r, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) r l) ->measure r <= measure l. Proof. unfold measure in *. apply InterpZ.measure_star_monotonic. intros ;apply P_id_active_monotonic;assumption. intros ;apply P_id_mark_monotonic;assumption. intros ;apply P_id_ok_monotonic;assumption. intros ;apply P_id_start_monotonic;assumption. intros ;apply P_id_f_monotonic;assumption. intros ;apply P_id_proper_monotonic;assumption. intros ;apply P_id_check_monotonic;assumption. intros ;apply P_id_top_monotonic;assumption. intros ;apply P_id_found_monotonic;assumption. intros ;apply P_id_match_monotonic;assumption. intros ;apply P_id_active_bounded;assumption. intros ;apply P_id_X_bounded;assumption. intros ;apply P_id_c_bounded;assumption. intros ;apply P_id_mark_bounded;assumption. intros ;apply P_id_ok_bounded;assumption. intros ;apply P_id_start_bounded;assumption. intros ;apply P_id_f_bounded;assumption. intros ;apply P_id_proper_bounded;assumption. intros ;apply P_id_check_bounded;assumption. intros ;apply P_id_top_bounded;assumption. intros ;apply P_id_found_bounded;assumption. intros ;apply P_id_match_bounded;assumption. apply rules_monotonic. Qed. Definition P_id_MATCH (x4:Z) (x5:Z) := 0. Definition P_id_TOP (x4:Z) := 0. Definition P_id_ACTIVE (x4:Z) := 0. Definition P_id_F (x4:Z) := 0. Definition P_id_PROPER (x4:Z) := 0. Definition P_id_CHECK (x4:Z) := 1* x4. Definition P_id_START (x4:Z) := 0. Lemma P_id_MATCH_monotonic : forall x4 x6 x5 x7, (0 <= x7)/\ (x7 <= x6) -> (0 <= x5)/\ (x5 <= x4) ->P_id_MATCH x5 x7 <= P_id_MATCH x4 x6. Proof. intros x7 x6 x5 x4. intros [H_1 H_0]. intros [H_3 H_2]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_TOP_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_TOP x5 <= P_id_TOP x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_ACTIVE_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_ACTIVE x5 <= P_id_ACTIVE x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_F_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_F x5 <= P_id_F x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_PROPER_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_PROPER x5 <= P_id_PROPER x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_CHECK_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_CHECK x5 <= P_id_CHECK x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_START_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_START x5 <= P_id_START x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Definition marked_measure := InterpZ.marked_measure 0 P_id_active P_id_X P_id_c P_id_mark P_id_ok P_id_start P_id_f P_id_proper P_id_check P_id_top P_id_found P_id_match P_id_MATCH P_id_TOP P_id_ACTIVE P_id_F P_id_PROPER P_id_CHECK P_id_START. Lemma marked_measure_equation : forall t, marked_measure t = match t with | (algebra.Alg.Term algebra.F.id_match (x5:: x4::nil)) => P_id_MATCH (measure x5) (measure x4) | (algebra.Alg.Term algebra.F.id_top (x4::nil)) => P_id_TOP (measure x4) | (algebra.Alg.Term algebra.F.id_active (x4::nil)) => P_id_ACTIVE (measure x4) | (algebra.Alg.Term algebra.F.id_f (x4::nil)) => P_id_F (measure x4) | (algebra.Alg.Term algebra.F.id_proper (x4::nil)) => P_id_PROPER (measure x4) | (algebra.Alg.Term algebra.F.id_check (x4::nil)) => P_id_CHECK (measure x4) | (algebra.Alg.Term algebra.F.id_start (x4::nil)) => P_id_START (measure x4) | _ => measure t end. Proof. reflexivity . Qed. Lemma marked_measure_star_monotonic : forall f l1 l2, (closure.refl_trans_clos (closure.one_step_list (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) ) l1 l2) -> marked_measure (algebra.Alg.Term f l1) <= marked_measure (algebra.Alg.Term f l2). Proof. unfold marked_measure in *. apply InterpZ.marked_measure_star_monotonic. intros ;apply P_id_active_monotonic;assumption. intros ;apply P_id_mark_monotonic;assumption. intros ;apply P_id_ok_monotonic;assumption. intros ;apply P_id_start_monotonic;assumption. intros ;apply P_id_f_monotonic;assumption. intros ;apply P_id_proper_monotonic;assumption. intros ;apply P_id_check_monotonic;assumption. intros ;apply P_id_top_monotonic;assumption. intros ;apply P_id_found_monotonic;assumption. intros ;apply P_id_match_monotonic;assumption. intros ;apply P_id_active_bounded;assumption. intros ;apply P_id_X_bounded;assumption. intros ;apply P_id_c_bounded;assumption. intros ;apply P_id_mark_bounded;assumption. intros ;apply P_id_ok_bounded;assumption. intros ;apply P_id_start_bounded;assumption. intros ;apply P_id_f_bounded;assumption. intros ;apply P_id_proper_bounded;assumption. intros ;apply P_id_check_bounded;assumption. intros ;apply P_id_top_bounded;assumption. intros ;apply P_id_found_bounded;assumption. intros ;apply P_id_match_bounded;assumption. apply rules_monotonic. intros ;apply P_id_MATCH_monotonic;assumption. intros ;apply P_id_TOP_monotonic;assumption. intros ;apply P_id_ACTIVE_monotonic;assumption. intros ;apply P_id_F_monotonic;assumption. intros ;apply P_id_PROPER_monotonic;assumption. intros ;apply P_id_CHECK_monotonic;assumption. intros ;apply P_id_START_monotonic;assumption. Qed. Ltac rewrite_and_unfold := do 2 (rewrite marked_measure_equation); repeat ( match goal with | |- context [measure (algebra.Alg.Term ?f ?t)] => rewrite (measure_equation (algebra.Alg.Term f t)) | H:context [measure (algebra.Alg.Term ?f ?t)] |- _ => rewrite (measure_equation (algebra.Alg.Term f t)) in H|- end ). Lemma wf : well_founded WF_DP_R_xml_0.DP_R_xml_0_scc_14. Proof. intros x. apply well_founded_ind with (R:=fun x y => (Zwf.Zwf 0) (marked_measure x) (marked_measure y)). apply Inverse_Image.wf_inverse_image with (B:=Z). apply Zwf.Zwf_well_founded. clear x. intros x IHx. repeat ( constructor;inversion 1;subst; full_prove_ineq algebra.Alg.Term ltac:(algebra.Alg_ext.find_replacement ) algebra.EQT_ext.one_step_list_refl_trans_clos marked_measure marked_measure_star_monotonic (Zwf.Zwf 0) (interp.o_Z 0) ltac:(fun _ => R_xml_0_deep_rew.impossible_star_reduction_R_xml_0 ) ltac:(fun _ => rewrite_and_unfold ) ltac:(fun _ => generate_pos_hyp ) ltac:(fun _ => cbv beta iota zeta delta - [Zplus Zmult Zle Zlt] in * ; try (constructor)) IHx ). Qed. End WF_DP_R_xml_0_scc_14. Definition wf_DP_R_xml_0_scc_14 := WF_DP_R_xml_0_scc_14.wf. Lemma acc_DP_R_xml_0_scc_14 : forall x y, (DP_R_xml_0_scc_14 x y) ->Acc WF_R_xml_0_deep_rew.DP_R_xml_0 x. Proof. intros x. pattern x. apply (@Acc_ind _ DP_R_xml_0_scc_14). intros x' _ Hrec y h. inversion h;clear h;subst; constructor;intros _y _h;inversion _h;clear _h;subst; (eapply Hrec;econstructor eassumption)|| ((eapply acc_DP_R_xml_0_non_scc_13; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))|| ((eapply acc_DP_R_xml_0_non_scc_12; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))|| ((eapply acc_DP_R_xml_0_non_scc_11; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))|| ((eapply acc_DP_R_xml_0_non_scc_10; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))|| ((R_xml_0_deep_rew.impossible_star_reduction_R_xml_0 )|| (eapply Hrec; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))))))). apply wf_DP_R_xml_0_scc_14. Qed. Inductive DP_R_xml_0_non_scc_15 : algebra.Alg.term ->algebra.Alg.term ->Prop := (* *) | DP_R_xml_0_non_scc_15_0 : forall x4 x1, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) (algebra.Alg.Term algebra.F.id_mark (x1::nil)) x4) -> DP_R_xml_0_non_scc_15 (algebra.Alg.Term algebra.F.id_check (x1::nil)) (algebra.Alg.Term algebra.F.id_top (x4::nil)) . Lemma acc_DP_R_xml_0_non_scc_15 : forall x y, (DP_R_xml_0_non_scc_15 x y) ->Acc WF_R_xml_0_deep_rew.DP_R_xml_0 x. Proof. intros x y h. inversion h;clear h;subst; constructor;intros _y _h;inversion _h;clear _h;subst; (eapply acc_DP_R_xml_0_scc_14; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))|| ((eapply acc_DP_R_xml_0_non_scc_13; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))|| ((eapply acc_DP_R_xml_0_non_scc_12; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))|| ((eapply acc_DP_R_xml_0_non_scc_11; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))|| ((eapply acc_DP_R_xml_0_non_scc_10; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))|| ((R_xml_0_deep_rew.impossible_star_reduction_R_xml_0 )|| (eapply Hrec; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))))))). Qed. Inductive DP_R_xml_0_scc_16 : algebra.Alg.term ->algebra.Alg.term ->Prop := (* *) | DP_R_xml_0_scc_16_0 : forall x4 x1, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) (algebra.Alg.Term algebra.F.id_mark (x1::nil)) x4) -> DP_R_xml_0_scc_16 (algebra.Alg.Term algebra.F.id_top ((algebra.Alg.Term algebra.F.id_check (x1::nil))::nil)) (algebra.Alg.Term algebra.F.id_top (x4::nil)) (* *) | DP_R_xml_0_scc_16_1 : forall x4, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) (algebra.Alg.Term algebra.F.id_active ((algebra.Alg.Term algebra.F.id_c nil)::nil)) x4) -> DP_R_xml_0_scc_16 (algebra.Alg.Term algebra.F.id_top ((algebra.Alg.Term algebra.F.id_mark ((algebra.Alg.Term algebra.F.id_c nil)::nil))::nil)) (algebra.Alg.Term algebra.F.id_top (x4::nil)) (* *) | DP_R_xml_0_scc_16_2 : forall x4 x1, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) (algebra.Alg.Term algebra.F.id_found (x1::nil)) x4) -> DP_R_xml_0_scc_16 (algebra.Alg.Term algebra.F.id_top ((algebra.Alg.Term algebra.F.id_active (x1::nil))::nil)) (algebra.Alg.Term algebra.F.id_top (x4::nil)) . Module WF_DP_R_xml_0_scc_16. Inductive DP_R_xml_0_scc_16_large : algebra.Alg.term ->algebra.Alg.term ->Prop := (* *) | DP_R_xml_0_scc_16_large_0 : forall x4 x1, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) (algebra.Alg.Term algebra.F.id_mark (x1::nil)) x4) -> DP_R_xml_0_scc_16_large (algebra.Alg.Term algebra.F.id_top ((algebra.Alg.Term algebra.F.id_check (x1::nil))::nil)) (algebra.Alg.Term algebra.F.id_top (x4::nil)) (* *) | DP_R_xml_0_scc_16_large_1 : forall x4 x1, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) (algebra.Alg.Term algebra.F.id_found (x1::nil)) x4) -> DP_R_xml_0_scc_16_large (algebra.Alg.Term algebra.F.id_top ((algebra.Alg.Term algebra.F.id_active (x1::nil))::nil)) (algebra.Alg.Term algebra.F.id_top (x4::nil)) . Inductive DP_R_xml_0_scc_16_strict : algebra.Alg.term ->algebra.Alg.term ->Prop := (* *) | DP_R_xml_0_scc_16_strict_0 : forall x4, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) (algebra.Alg.Term algebra.F.id_active ((algebra.Alg.Term algebra.F.id_c nil)::nil)) x4) -> DP_R_xml_0_scc_16_strict (algebra.Alg.Term algebra.F.id_top ((algebra.Alg.Term algebra.F.id_mark ((algebra.Alg.Term algebra.F.id_c nil)::nil))::nil)) (algebra.Alg.Term algebra.F.id_top (x4::nil)) . Module WF_DP_R_xml_0_scc_16_large. Inductive DP_R_xml_0_scc_16_large_large : algebra.Alg.term ->algebra.Alg.term ->Prop := (* *) | DP_R_xml_0_scc_16_large_large_0 : forall x4 x1, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) (algebra.Alg.Term algebra.F.id_mark (x1::nil)) x4) -> DP_R_xml_0_scc_16_large_large (algebra.Alg.Term algebra.F.id_top ((algebra.Alg.Term algebra.F.id_check (x1::nil))::nil)) (algebra.Alg.Term algebra.F.id_top (x4::nil)) . Inductive DP_R_xml_0_scc_16_large_strict : algebra.Alg.term ->algebra.Alg.term ->Prop := (* *) | DP_R_xml_0_scc_16_large_strict_0 : forall x4 x1, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) (algebra.Alg.Term algebra.F.id_found (x1::nil)) x4) -> DP_R_xml_0_scc_16_large_strict (algebra.Alg.Term algebra.F.id_top ((algebra.Alg.Term algebra.F.id_active (x1::nil))::nil)) (algebra.Alg.Term algebra.F.id_top (x4::nil)) . Module WF_DP_R_xml_0_scc_16_large_large. Open Scope Z_scope. Import ring_extention. Notation Local "a <= b" := (Zle a b). Notation Local "a < b" := (Zlt a b). Definition P_id_active (x4:Z) := 1* x4. Definition P_id_X := 3. Definition P_id_c := 0. Definition P_id_mark (x4:Z) := 2 + 2* x4. Definition P_id_ok (x4:Z) := 1. Definition P_id_start (x4:Z) := 0. Definition P_id_f (x4:Z) := 2 + 2* x4. Definition P_id_proper (x4:Z) := 1 + 2* x4. Definition P_id_check (x4:Z) := 1* x4. Definition P_id_top (x4:Z) := 0. Definition P_id_found (x4:Z) := 0. Definition P_id_match (x4:Z) (x5:Z) := 3 + 3* x4 + 3* x5. Lemma P_id_active_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_active x5 <= P_id_active x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_mark_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_mark x5 <= P_id_mark x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_ok_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_ok x5 <= P_id_ok x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_start_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_start x5 <= P_id_start x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_f_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_f x5 <= P_id_f x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_proper_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_proper x5 <= P_id_proper x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_check_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_check x5 <= P_id_check x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_top_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_top x5 <= P_id_top x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_found_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_found x5 <= P_id_found x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_match_monotonic : forall x4 x6 x5 x7, (0 <= x7)/\ (x7 <= x6) -> (0 <= x5)/\ (x5 <= x4) ->P_id_match x5 x7 <= P_id_match x4 x6. Proof. intros x7 x6 x5 x4. intros [H_1 H_0]. intros [H_3 H_2]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_active_bounded : forall x4, (0 <= x4) ->0 <= P_id_active x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_X_bounded : 0 <= P_id_X . Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_c_bounded : 0 <= P_id_c . Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_mark_bounded : forall x4, (0 <= x4) ->0 <= P_id_mark x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_ok_bounded : forall x4, (0 <= x4) ->0 <= P_id_ok x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_start_bounded : forall x4, (0 <= x4) ->0 <= P_id_start x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_f_bounded : forall x4, (0 <= x4) ->0 <= P_id_f x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_proper_bounded : forall x4, (0 <= x4) ->0 <= P_id_proper x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_check_bounded : forall x4, (0 <= x4) ->0 <= P_id_check x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_top_bounded : forall x4, (0 <= x4) ->0 <= P_id_top x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_found_bounded : forall x4, (0 <= x4) ->0 <= P_id_found x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_match_bounded : forall x4 x5, (0 <= x4) ->(0 <= x5) ->0 <= P_id_match x5 x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Definition measure := InterpZ.measure 0 P_id_active P_id_X P_id_c P_id_mark P_id_ok P_id_start P_id_f P_id_proper P_id_check P_id_top P_id_found P_id_match. Lemma measure_equation : forall t, measure t = match t with | (algebra.Alg.Term algebra.F.id_active (x4::nil)) => P_id_active (measure x4) | (algebra.Alg.Term algebra.F.id_X nil) => P_id_X | (algebra.Alg.Term algebra.F.id_c nil) => P_id_c | (algebra.Alg.Term algebra.F.id_mark (x4::nil)) => P_id_mark (measure x4) | (algebra.Alg.Term algebra.F.id_ok (x4::nil)) => P_id_ok (measure x4) | (algebra.Alg.Term algebra.F.id_start (x4::nil)) => P_id_start (measure x4) | (algebra.Alg.Term algebra.F.id_f (x4::nil)) => P_id_f (measure x4) | (algebra.Alg.Term algebra.F.id_proper (x4::nil)) => P_id_proper (measure x4) | (algebra.Alg.Term algebra.F.id_check (x4::nil)) => P_id_check (measure x4) | (algebra.Alg.Term algebra.F.id_top (x4::nil)) => P_id_top (measure x4) | (algebra.Alg.Term algebra.F.id_found (x4::nil)) => P_id_found (measure x4) | (algebra.Alg.Term algebra.F.id_match (x5::x4::nil)) => P_id_match (measure x5) (measure x4) | _ => 0 end. Proof. intros t;case t;intros ;apply refl_equal. Qed. Lemma measure_bounded : forall t, 0 <= measure t. Proof. unfold measure in |-*. apply InterpZ.measure_bounded; cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Ltac generate_pos_hyp := match goal with | H:context [measure ?x] |- _ => let v := fresh "v" in (let H := fresh "h" in (set (H:=measure_bounded x) in *;set (v:=measure x) in *; clearbody H;clearbody v)) | |- context [measure ?x] => let v := fresh "v" in (let H := fresh "h" in (set (H:=measure_bounded x) in *;set (v:=measure x) in *; clearbody H;clearbody v)) end . Lemma rules_monotonic : forall l r, (algebra.EQT.axiom R_xml_0_deep_rew.R_xml_0_rules r l) -> measure r <= measure l. Proof. intros l r H. fold measure in |-*. inversion H;clear H;subst;inversion H0;clear H0;subst; simpl algebra.EQT.T.apply_subst in |-*; repeat ( match goal with | |- context [measure (algebra.Alg.Term ?f ?t)] => rewrite (measure_equation (algebra.Alg.Term f t)) end );repeat (generate_pos_hyp ); cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma measure_star_monotonic : forall l r, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) r l) ->measure r <= measure l. Proof. unfold measure in *. apply InterpZ.measure_star_monotonic. intros ;apply P_id_active_monotonic;assumption. intros ;apply P_id_mark_monotonic;assumption. intros ;apply P_id_ok_monotonic;assumption. intros ;apply P_id_start_monotonic;assumption. intros ;apply P_id_f_monotonic;assumption. intros ;apply P_id_proper_monotonic;assumption. intros ;apply P_id_check_monotonic;assumption. intros ;apply P_id_top_monotonic;assumption. intros ;apply P_id_found_monotonic;assumption. intros ;apply P_id_match_monotonic;assumption. intros ;apply P_id_active_bounded;assumption. intros ;apply P_id_X_bounded;assumption. intros ;apply P_id_c_bounded;assumption. intros ;apply P_id_mark_bounded;assumption. intros ;apply P_id_ok_bounded;assumption. intros ;apply P_id_start_bounded;assumption. intros ;apply P_id_f_bounded;assumption. intros ;apply P_id_proper_bounded;assumption. intros ;apply P_id_check_bounded;assumption. intros ;apply P_id_top_bounded;assumption. intros ;apply P_id_found_bounded;assumption. intros ;apply P_id_match_bounded;assumption. apply rules_monotonic. Qed. Definition P_id_MATCH (x4:Z) (x5:Z) := 0. Definition P_id_TOP (x4:Z) := 3* x4. Definition P_id_ACTIVE (x4:Z) := 0. Definition P_id_F (x4:Z) := 0. Definition P_id_PROPER (x4:Z) := 0. Definition P_id_CHECK (x4:Z) := 0. Definition P_id_START (x4:Z) := 0. Lemma P_id_MATCH_monotonic : forall x4 x6 x5 x7, (0 <= x7)/\ (x7 <= x6) -> (0 <= x5)/\ (x5 <= x4) ->P_id_MATCH x5 x7 <= P_id_MATCH x4 x6. Proof. intros x7 x6 x5 x4. intros [H_1 H_0]. intros [H_3 H_2]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_TOP_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_TOP x5 <= P_id_TOP x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_ACTIVE_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_ACTIVE x5 <= P_id_ACTIVE x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_F_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_F x5 <= P_id_F x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_PROPER_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_PROPER x5 <= P_id_PROPER x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_CHECK_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_CHECK x5 <= P_id_CHECK x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_START_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_START x5 <= P_id_START x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Definition marked_measure := InterpZ.marked_measure 0 P_id_active P_id_X P_id_c P_id_mark P_id_ok P_id_start P_id_f P_id_proper P_id_check P_id_top P_id_found P_id_match P_id_MATCH P_id_TOP P_id_ACTIVE P_id_F P_id_PROPER P_id_CHECK P_id_START. Lemma marked_measure_equation : forall t, marked_measure t = match t with | (algebra.Alg.Term algebra.F.id_match (x5:: x4::nil)) => P_id_MATCH (measure x5) (measure x4) | (algebra.Alg.Term algebra.F.id_top (x4::nil)) => P_id_TOP (measure x4) | (algebra.Alg.Term algebra.F.id_active (x4::nil)) => P_id_ACTIVE (measure x4) | (algebra.Alg.Term algebra.F.id_f (x4::nil)) => P_id_F (measure x4) | (algebra.Alg.Term algebra.F.id_proper (x4::nil)) => P_id_PROPER (measure x4) | (algebra.Alg.Term algebra.F.id_check (x4::nil)) => P_id_CHECK (measure x4) | (algebra.Alg.Term algebra.F.id_start (x4::nil)) => P_id_START (measure x4) | _ => measure t end. Proof. reflexivity . Qed. Lemma marked_measure_star_monotonic : forall f l1 l2, (closure.refl_trans_clos (closure.one_step_list (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) ) l1 l2) -> marked_measure (algebra.Alg.Term f l1) <= marked_measure (algebra.Alg.Term f l2). Proof. unfold marked_measure in *. apply InterpZ.marked_measure_star_monotonic. intros ;apply P_id_active_monotonic;assumption. intros ;apply P_id_mark_monotonic;assumption. intros ;apply P_id_ok_monotonic;assumption. intros ;apply P_id_start_monotonic;assumption. intros ;apply P_id_f_monotonic;assumption. intros ;apply P_id_proper_monotonic;assumption. intros ;apply P_id_check_monotonic;assumption. intros ;apply P_id_top_monotonic;assumption. intros ;apply P_id_found_monotonic;assumption. intros ;apply P_id_match_monotonic;assumption. intros ;apply P_id_active_bounded;assumption. intros ;apply P_id_X_bounded;assumption. intros ;apply P_id_c_bounded;assumption. intros ;apply P_id_mark_bounded;assumption. intros ;apply P_id_ok_bounded;assumption. intros ;apply P_id_start_bounded;assumption. intros ;apply P_id_f_bounded;assumption. intros ;apply P_id_proper_bounded;assumption. intros ;apply P_id_check_bounded;assumption. intros ;apply P_id_top_bounded;assumption. intros ;apply P_id_found_bounded;assumption. intros ;apply P_id_match_bounded;assumption. apply rules_monotonic. intros ;apply P_id_MATCH_monotonic;assumption. intros ;apply P_id_TOP_monotonic;assumption. intros ;apply P_id_ACTIVE_monotonic;assumption. intros ;apply P_id_F_monotonic;assumption. intros ;apply P_id_PROPER_monotonic;assumption. intros ;apply P_id_CHECK_monotonic;assumption. intros ;apply P_id_START_monotonic;assumption. Qed. Ltac rewrite_and_unfold := do 2 (rewrite marked_measure_equation); repeat ( match goal with | |- context [measure (algebra.Alg.Term ?f ?t)] => rewrite (measure_equation (algebra.Alg.Term f t)) | H:context [measure (algebra.Alg.Term ?f ?t)] |- _ => rewrite (measure_equation (algebra.Alg.Term f t)) in H|- end ). Lemma wf : well_founded WF_DP_R_xml_0_scc_16_large.DP_R_xml_0_scc_16_large_large. Proof. intros x. apply well_founded_ind with (R:=fun x y => (Zwf.Zwf 0) (marked_measure x) (marked_measure y)). apply Inverse_Image.wf_inverse_image with (B:=Z). apply Zwf.Zwf_well_founded. clear x. intros x IHx. repeat ( constructor;inversion 1;subst; full_prove_ineq algebra.Alg.Term ltac:(algebra.Alg_ext.find_replacement ) algebra.EQT_ext.one_step_list_refl_trans_clos marked_measure marked_measure_star_monotonic (Zwf.Zwf 0) (interp.o_Z 0) ltac:(fun _ => R_xml_0_deep_rew.impossible_star_reduction_R_xml_0 ) ltac:(fun _ => rewrite_and_unfold ) ltac:(fun _ => generate_pos_hyp ) ltac:(fun _ => cbv beta iota zeta delta - [Zplus Zmult Zle Zlt] in * ; try (constructor)) IHx ). Qed. End WF_DP_R_xml_0_scc_16_large_large. Open Scope Z_scope. Import ring_extention. Notation Local "a <= b" := (Zle a b). Notation Local "a < b" := (Zlt a b). Definition P_id_active (x4:Z) := 2* x4. Definition P_id_X := 0. Definition P_id_c := 0. Definition P_id_mark (x4:Z) := 1 + 2* x4. Definition P_id_ok (x4:Z) := 1* x4. Definition P_id_start (x4:Z) := 1 + 2* x4. Definition P_id_f (x4:Z) := 2 + 3* x4. Definition P_id_proper (x4:Z) := 1* x4. Definition P_id_check (x4:Z) := 1 + 2* x4. Definition P_id_top (x4:Z) := 0. Definition P_id_found (x4:Z) := 1 + 2* x4. Definition P_id_match (x4:Z) (x5:Z) := 1* x5. Lemma P_id_active_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_active x5 <= P_id_active x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_mark_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_mark x5 <= P_id_mark x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_ok_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_ok x5 <= P_id_ok x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_start_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_start x5 <= P_id_start x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_f_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_f x5 <= P_id_f x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_proper_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_proper x5 <= P_id_proper x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_check_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_check x5 <= P_id_check x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_top_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_top x5 <= P_id_top x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_found_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_found x5 <= P_id_found x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_match_monotonic : forall x4 x6 x5 x7, (0 <= x7)/\ (x7 <= x6) -> (0 <= x5)/\ (x5 <= x4) ->P_id_match x5 x7 <= P_id_match x4 x6. Proof. intros x7 x6 x5 x4. intros [H_1 H_0]. intros [H_3 H_2]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_active_bounded : forall x4, (0 <= x4) ->0 <= P_id_active x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_X_bounded : 0 <= P_id_X . Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_c_bounded : 0 <= P_id_c . Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_mark_bounded : forall x4, (0 <= x4) ->0 <= P_id_mark x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_ok_bounded : forall x4, (0 <= x4) ->0 <= P_id_ok x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_start_bounded : forall x4, (0 <= x4) ->0 <= P_id_start x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_f_bounded : forall x4, (0 <= x4) ->0 <= P_id_f x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_proper_bounded : forall x4, (0 <= x4) ->0 <= P_id_proper x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_check_bounded : forall x4, (0 <= x4) ->0 <= P_id_check x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_top_bounded : forall x4, (0 <= x4) ->0 <= P_id_top x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_found_bounded : forall x4, (0 <= x4) ->0 <= P_id_found x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_match_bounded : forall x4 x5, (0 <= x4) ->(0 <= x5) ->0 <= P_id_match x5 x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Definition measure := InterpZ.measure 0 P_id_active P_id_X P_id_c P_id_mark P_id_ok P_id_start P_id_f P_id_proper P_id_check P_id_top P_id_found P_id_match. Lemma measure_equation : forall t, measure t = match t with | (algebra.Alg.Term algebra.F.id_active (x4::nil)) => P_id_active (measure x4) | (algebra.Alg.Term algebra.F.id_X nil) => P_id_X | (algebra.Alg.Term algebra.F.id_c nil) => P_id_c | (algebra.Alg.Term algebra.F.id_mark (x4::nil)) => P_id_mark (measure x4) | (algebra.Alg.Term algebra.F.id_ok (x4::nil)) => P_id_ok (measure x4) | (algebra.Alg.Term algebra.F.id_start (x4::nil)) => P_id_start (measure x4) | (algebra.Alg.Term algebra.F.id_f (x4::nil)) => P_id_f (measure x4) | (algebra.Alg.Term algebra.F.id_proper (x4::nil)) => P_id_proper (measure x4) | (algebra.Alg.Term algebra.F.id_check (x4::nil)) => P_id_check (measure x4) | (algebra.Alg.Term algebra.F.id_top (x4::nil)) => P_id_top (measure x4) | (algebra.Alg.Term algebra.F.id_found (x4::nil)) => P_id_found (measure x4) | (algebra.Alg.Term algebra.F.id_match (x5::x4::nil)) => P_id_match (measure x5) (measure x4) | _ => 0 end. Proof. intros t;case t;intros ;apply refl_equal. Qed. Lemma measure_bounded : forall t, 0 <= measure t. Proof. unfold measure in |-*. apply InterpZ.measure_bounded; cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Ltac generate_pos_hyp := match goal with | H:context [measure ?x] |- _ => let v := fresh "v" in (let H := fresh "h" in (set (H:=measure_bounded x) in *;set (v:=measure x) in *; clearbody H;clearbody v)) | |- context [measure ?x] => let v := fresh "v" in (let H := fresh "h" in (set (H:=measure_bounded x) in *;set (v:=measure x) in *; clearbody H;clearbody v)) end . Lemma rules_monotonic : forall l r, (algebra.EQT.axiom R_xml_0_deep_rew.R_xml_0_rules r l) -> measure r <= measure l. Proof. intros l r H. fold measure in |-*. inversion H;clear H;subst;inversion H0;clear H0;subst; simpl algebra.EQT.T.apply_subst in |-*; repeat ( match goal with | |- context [measure (algebra.Alg.Term ?f ?t)] => rewrite (measure_equation (algebra.Alg.Term f t)) end );repeat (generate_pos_hyp ); cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma measure_star_monotonic : forall l r, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) r l) ->measure r <= measure l. Proof. unfold measure in *. apply InterpZ.measure_star_monotonic. intros ;apply P_id_active_monotonic;assumption. intros ;apply P_id_mark_monotonic;assumption. intros ;apply P_id_ok_monotonic;assumption. intros ;apply P_id_start_monotonic;assumption. intros ;apply P_id_f_monotonic;assumption. intros ;apply P_id_proper_monotonic;assumption. intros ;apply P_id_check_monotonic;assumption. intros ;apply P_id_top_monotonic;assumption. intros ;apply P_id_found_monotonic;assumption. intros ;apply P_id_match_monotonic;assumption. intros ;apply P_id_active_bounded;assumption. intros ;apply P_id_X_bounded;assumption. intros ;apply P_id_c_bounded;assumption. intros ;apply P_id_mark_bounded;assumption. intros ;apply P_id_ok_bounded;assumption. intros ;apply P_id_start_bounded;assumption. intros ;apply P_id_f_bounded;assumption. intros ;apply P_id_proper_bounded;assumption. intros ;apply P_id_check_bounded;assumption. intros ;apply P_id_top_bounded;assumption. intros ;apply P_id_found_bounded;assumption. intros ;apply P_id_match_bounded;assumption. apply rules_monotonic. Qed. Definition P_id_MATCH (x4:Z) (x5:Z) := 0. Definition P_id_TOP (x4:Z) := 1* x4. Definition P_id_ACTIVE (x4:Z) := 0. Definition P_id_F (x4:Z) := 0. Definition P_id_PROPER (x4:Z) := 0. Definition P_id_CHECK (x4:Z) := 0. Definition P_id_START (x4:Z) := 0. Lemma P_id_MATCH_monotonic : forall x4 x6 x5 x7, (0 <= x7)/\ (x7 <= x6) -> (0 <= x5)/\ (x5 <= x4) ->P_id_MATCH x5 x7 <= P_id_MATCH x4 x6. Proof. intros x7 x6 x5 x4. intros [H_1 H_0]. intros [H_3 H_2]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_TOP_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_TOP x5 <= P_id_TOP x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_ACTIVE_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_ACTIVE x5 <= P_id_ACTIVE x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_F_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_F x5 <= P_id_F x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_PROPER_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_PROPER x5 <= P_id_PROPER x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_CHECK_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_CHECK x5 <= P_id_CHECK x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_START_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_START x5 <= P_id_START x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Definition marked_measure := InterpZ.marked_measure 0 P_id_active P_id_X P_id_c P_id_mark P_id_ok P_id_start P_id_f P_id_proper P_id_check P_id_top P_id_found P_id_match P_id_MATCH P_id_TOP P_id_ACTIVE P_id_F P_id_PROPER P_id_CHECK P_id_START. Lemma marked_measure_equation : forall t, marked_measure t = match t with | (algebra.Alg.Term algebra.F.id_match (x5:: x4::nil)) => P_id_MATCH (measure x5) (measure x4) | (algebra.Alg.Term algebra.F.id_top (x4::nil)) => P_id_TOP (measure x4) | (algebra.Alg.Term algebra.F.id_active (x4::nil)) => P_id_ACTIVE (measure x4) | (algebra.Alg.Term algebra.F.id_f (x4::nil)) => P_id_F (measure x4) | (algebra.Alg.Term algebra.F.id_proper (x4::nil)) => P_id_PROPER (measure x4) | (algebra.Alg.Term algebra.F.id_check (x4::nil)) => P_id_CHECK (measure x4) | (algebra.Alg.Term algebra.F.id_start (x4::nil)) => P_id_START (measure x4) | _ => measure t end. Proof. reflexivity . Qed. Lemma marked_measure_star_monotonic : forall f l1 l2, (closure.refl_trans_clos (closure.one_step_list (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) ) l1 l2) -> marked_measure (algebra.Alg.Term f l1) <= marked_measure (algebra.Alg.Term f l2). Proof. unfold marked_measure in *. apply InterpZ.marked_measure_star_monotonic. intros ;apply P_id_active_monotonic;assumption. intros ;apply P_id_mark_monotonic;assumption. intros ;apply P_id_ok_monotonic;assumption. intros ;apply P_id_start_monotonic;assumption. intros ;apply P_id_f_monotonic;assumption. intros ;apply P_id_proper_monotonic;assumption. intros ;apply P_id_check_monotonic;assumption. intros ;apply P_id_top_monotonic;assumption. intros ;apply P_id_found_monotonic;assumption. intros ;apply P_id_match_monotonic;assumption. intros ;apply P_id_active_bounded;assumption. intros ;apply P_id_X_bounded;assumption. intros ;apply P_id_c_bounded;assumption. intros ;apply P_id_mark_bounded;assumption. intros ;apply P_id_ok_bounded;assumption. intros ;apply P_id_start_bounded;assumption. intros ;apply P_id_f_bounded;assumption. intros ;apply P_id_proper_bounded;assumption. intros ;apply P_id_check_bounded;assumption. intros ;apply P_id_top_bounded;assumption. intros ;apply P_id_found_bounded;assumption. intros ;apply P_id_match_bounded;assumption. apply rules_monotonic. intros ;apply P_id_MATCH_monotonic;assumption. intros ;apply P_id_TOP_monotonic;assumption. intros ;apply P_id_ACTIVE_monotonic;assumption. intros ;apply P_id_F_monotonic;assumption. intros ;apply P_id_PROPER_monotonic;assumption. intros ;apply P_id_CHECK_monotonic;assumption. intros ;apply P_id_START_monotonic;assumption. Qed. Ltac rewrite_and_unfold := do 2 (rewrite marked_measure_equation); repeat ( match goal with | |- context [measure (algebra.Alg.Term ?f ?t)] => rewrite (measure_equation (algebra.Alg.Term f t)) | H:context [measure (algebra.Alg.Term ?f ?t)] |- _ => rewrite (measure_equation (algebra.Alg.Term f t)) in H|- end ). Definition lt a b := (Zwf.Zwf 0) (marked_measure a) (marked_measure b). Definition le a b := marked_measure a <= marked_measure b. Lemma lt_le_compat : forall a b c, (lt a b) ->(le b c) ->lt a c. Proof. unfold lt, le in *. intros a b c. apply (interp.le_lt_compat_right (interp.o_Z 0)). Qed. Lemma wf_lt : well_founded lt. Proof. unfold lt in *. apply Inverse_Image.wf_inverse_image with (B:=Z). apply Zwf.Zwf_well_founded. Qed. Lemma DP_R_xml_0_scc_16_large_strict_in_lt : Relation_Definitions.inclusion _ DP_R_xml_0_scc_16_large_strict lt. Proof. unfold Relation_Definitions.inclusion, lt in *. intros a b H;destruct H; match goal with | |- (Zwf.Zwf 0) _ (marked_measure (algebra.Alg.Term ?f ?l)) => let l'' := algebra.Alg_ext.find_replacement l in ((apply (interp.le_lt_compat_right (interp.o_Z 0)) with (marked_measure (algebra.Alg.Term f l''));[idtac| apply marked_measure_star_monotonic; repeat (apply algebra.EQT_ext.one_step_list_refl_trans_clos); (assumption)||(constructor 1)])) end ;clear ;rewrite_and_unfold ;repeat (generate_pos_hyp ); cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma DP_R_xml_0_scc_16_large_large_in_le : Relation_Definitions.inclusion _ DP_R_xml_0_scc_16_large_large le. Proof. unfold Relation_Definitions.inclusion, le, Zwf.Zwf in *. intros a b H;destruct H; match goal with | |- _ <= marked_measure (algebra.Alg.Term ?f ?l) => let l'' := algebra.Alg_ext.find_replacement l in ((apply (interp.le_trans (interp.o_Z 0)) with (marked_measure (algebra.Alg.Term f l''));[idtac| apply marked_measure_star_monotonic; repeat (apply algebra.EQT_ext.one_step_list_refl_trans_clos); (assumption)||(constructor 1)])) end ;clear ;rewrite_and_unfold ;repeat (generate_pos_hyp ); cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Definition wf_DP_R_xml_0_scc_16_large_large := WF_DP_R_xml_0_scc_16_large_large.wf. Lemma wf : well_founded WF_DP_R_xml_0_scc_16.DP_R_xml_0_scc_16_large. Proof. intros x. apply (well_founded_ind wf_lt). clear x. intros x. pattern x. apply (@Acc_ind _ DP_R_xml_0_scc_16_large_large). clear x. intros x _ IHx IHx'. constructor. intros y H. destruct H; (apply IHx';apply DP_R_xml_0_scc_16_large_strict_in_lt; econstructor eassumption)|| ((apply IHx;[econstructor eassumption| intros y' Hlt;apply IHx';apply lt_le_compat with (1:=Hlt) ; apply DP_R_xml_0_scc_16_large_large_in_le;econstructor eassumption])). apply wf_DP_R_xml_0_scc_16_large_large. Qed. End WF_DP_R_xml_0_scc_16_large. Open Scope Z_scope. Import ring_extention. Notation Local "a <= b" := (Zle a b). Notation Local "a < b" := (Zlt a b). Definition P_id_active (x4:Z) := 2* x4. Definition P_id_X := 2. Definition P_id_c := 2. Definition P_id_mark (x4:Z) := 0. Definition P_id_ok (x4:Z) := 1* x4. Definition P_id_start (x4:Z) := 2* x4. Definition P_id_f (x4:Z) := 0. Definition P_id_proper (x4:Z) := 2. Definition P_id_check (x4:Z) := 0. Definition P_id_top (x4:Z) := 0. Definition P_id_found (x4:Z) := 2* x4. Definition P_id_match (x4:Z) (x5:Z) := 2* x4. Lemma P_id_active_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_active x5 <= P_id_active x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_mark_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_mark x5 <= P_id_mark x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_ok_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_ok x5 <= P_id_ok x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_start_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_start x5 <= P_id_start x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_f_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_f x5 <= P_id_f x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_proper_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_proper x5 <= P_id_proper x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_check_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_check x5 <= P_id_check x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_top_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_top x5 <= P_id_top x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_found_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_found x5 <= P_id_found x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_match_monotonic : forall x4 x6 x5 x7, (0 <= x7)/\ (x7 <= x6) -> (0 <= x5)/\ (x5 <= x4) ->P_id_match x5 x7 <= P_id_match x4 x6. Proof. intros x7 x6 x5 x4. intros [H_1 H_0]. intros [H_3 H_2]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_active_bounded : forall x4, (0 <= x4) ->0 <= P_id_active x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_X_bounded : 0 <= P_id_X . Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_c_bounded : 0 <= P_id_c . Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_mark_bounded : forall x4, (0 <= x4) ->0 <= P_id_mark x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_ok_bounded : forall x4, (0 <= x4) ->0 <= P_id_ok x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_start_bounded : forall x4, (0 <= x4) ->0 <= P_id_start x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_f_bounded : forall x4, (0 <= x4) ->0 <= P_id_f x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_proper_bounded : forall x4, (0 <= x4) ->0 <= P_id_proper x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_check_bounded : forall x4, (0 <= x4) ->0 <= P_id_check x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_top_bounded : forall x4, (0 <= x4) ->0 <= P_id_top x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_found_bounded : forall x4, (0 <= x4) ->0 <= P_id_found x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_match_bounded : forall x4 x5, (0 <= x4) ->(0 <= x5) ->0 <= P_id_match x5 x4. Proof. intros . cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Definition measure := InterpZ.measure 0 P_id_active P_id_X P_id_c P_id_mark P_id_ok P_id_start P_id_f P_id_proper P_id_check P_id_top P_id_found P_id_match . Lemma measure_equation : forall t, measure t = match t with | (algebra.Alg.Term algebra.F.id_active (x4::nil)) => P_id_active (measure x4) | (algebra.Alg.Term algebra.F.id_X nil) => P_id_X | (algebra.Alg.Term algebra.F.id_c nil) => P_id_c | (algebra.Alg.Term algebra.F.id_mark (x4::nil)) => P_id_mark (measure x4) | (algebra.Alg.Term algebra.F.id_ok (x4::nil)) => P_id_ok (measure x4) | (algebra.Alg.Term algebra.F.id_start (x4::nil)) => P_id_start (measure x4) | (algebra.Alg.Term algebra.F.id_f (x4::nil)) => P_id_f (measure x4) | (algebra.Alg.Term algebra.F.id_proper (x4::nil)) => P_id_proper (measure x4) | (algebra.Alg.Term algebra.F.id_check (x4::nil)) => P_id_check (measure x4) | (algebra.Alg.Term algebra.F.id_top (x4::nil)) => P_id_top (measure x4) | (algebra.Alg.Term algebra.F.id_found (x4::nil)) => P_id_found (measure x4) | (algebra.Alg.Term algebra.F.id_match (x5::x4::nil)) => P_id_match (measure x5) (measure x4) | _ => 0 end. Proof. intros t;case t;intros ;apply refl_equal. Qed. Lemma measure_bounded : forall t, 0 <= measure t. Proof. unfold measure in |-*. apply InterpZ.measure_bounded; cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Ltac generate_pos_hyp := match goal with | H:context [measure ?x] |- _ => let v := fresh "v" in (let H := fresh "h" in (set (H:=measure_bounded x) in *;set (v:=measure x) in *; clearbody H;clearbody v)) | |- context [measure ?x] => let v := fresh "v" in (let H := fresh "h" in (set (H:=measure_bounded x) in *;set (v:=measure x) in *; clearbody H;clearbody v)) end . Lemma rules_monotonic : forall l r, (algebra.EQT.axiom R_xml_0_deep_rew.R_xml_0_rules r l) -> measure r <= measure l. Proof. intros l r H. fold measure in |-*. inversion H;clear H;subst;inversion H0;clear H0;subst; simpl algebra.EQT.T.apply_subst in |-*; repeat ( match goal with | |- context [measure (algebra.Alg.Term ?f ?t)] => rewrite (measure_equation (algebra.Alg.Term f t)) end );repeat (generate_pos_hyp ); cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma measure_star_monotonic : forall l r, (closure.refl_trans_clos (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) r l) ->measure r <= measure l. Proof. unfold measure in *. apply InterpZ.measure_star_monotonic. intros ;apply P_id_active_monotonic;assumption. intros ;apply P_id_mark_monotonic;assumption. intros ;apply P_id_ok_monotonic;assumption. intros ;apply P_id_start_monotonic;assumption. intros ;apply P_id_f_monotonic;assumption. intros ;apply P_id_proper_monotonic;assumption. intros ;apply P_id_check_monotonic;assumption. intros ;apply P_id_top_monotonic;assumption. intros ;apply P_id_found_monotonic;assumption. intros ;apply P_id_match_monotonic;assumption. intros ;apply P_id_active_bounded;assumption. intros ;apply P_id_X_bounded;assumption. intros ;apply P_id_c_bounded;assumption. intros ;apply P_id_mark_bounded;assumption. intros ;apply P_id_ok_bounded;assumption. intros ;apply P_id_start_bounded;assumption. intros ;apply P_id_f_bounded;assumption. intros ;apply P_id_proper_bounded;assumption. intros ;apply P_id_check_bounded;assumption. intros ;apply P_id_top_bounded;assumption. intros ;apply P_id_found_bounded;assumption. intros ;apply P_id_match_bounded;assumption. apply rules_monotonic. Qed. Definition P_id_MATCH (x4:Z) (x5:Z) := 0. Definition P_id_TOP (x4:Z) := 1* x4. Definition P_id_ACTIVE (x4:Z) := 0. Definition P_id_F (x4:Z) := 0. Definition P_id_PROPER (x4:Z) := 0. Definition P_id_CHECK (x4:Z) := 0. Definition P_id_START (x4:Z) := 0. Lemma P_id_MATCH_monotonic : forall x4 x6 x5 x7, (0 <= x7)/\ (x7 <= x6) -> (0 <= x5)/\ (x5 <= x4) ->P_id_MATCH x5 x7 <= P_id_MATCH x4 x6. Proof. intros x7 x6 x5 x4. intros [H_1 H_0]. intros [H_3 H_2]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_TOP_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_TOP x5 <= P_id_TOP x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_ACTIVE_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_ACTIVE x5 <= P_id_ACTIVE x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_F_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_F x5 <= P_id_F x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_PROPER_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_PROPER x5 <= P_id_PROPER x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_CHECK_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_CHECK x5 <= P_id_CHECK x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma P_id_START_monotonic : forall x4 x5, (0 <= x5)/\ (x5 <= x4) ->P_id_START x5 <= P_id_START x4. Proof. intros x5 x4. intros [H_1 H_0]. cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Definition marked_measure := InterpZ.marked_measure 0 P_id_active P_id_X P_id_c P_id_mark P_id_ok P_id_start P_id_f P_id_proper P_id_check P_id_top P_id_found P_id_match P_id_MATCH P_id_TOP P_id_ACTIVE P_id_F P_id_PROPER P_id_CHECK P_id_START. Lemma marked_measure_equation : forall t, marked_measure t = match t with | (algebra.Alg.Term algebra.F.id_match (x5:: x4::nil)) => P_id_MATCH (measure x5) (measure x4) | (algebra.Alg.Term algebra.F.id_top (x4::nil)) => P_id_TOP (measure x4) | (algebra.Alg.Term algebra.F.id_active (x4::nil)) => P_id_ACTIVE (measure x4) | (algebra.Alg.Term algebra.F.id_f (x4::nil)) => P_id_F (measure x4) | (algebra.Alg.Term algebra.F.id_proper (x4::nil)) => P_id_PROPER (measure x4) | (algebra.Alg.Term algebra.F.id_check (x4::nil)) => P_id_CHECK (measure x4) | (algebra.Alg.Term algebra.F.id_start (x4::nil)) => P_id_START (measure x4) | _ => measure t end. Proof. reflexivity . Qed. Lemma marked_measure_star_monotonic : forall f l1 l2, (closure.refl_trans_clos (closure.one_step_list (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules) ) l1 l2) -> marked_measure (algebra.Alg.Term f l1) <= marked_measure (algebra.Alg.Term f l2). Proof. unfold marked_measure in *. apply InterpZ.marked_measure_star_monotonic. intros ;apply P_id_active_monotonic;assumption. intros ;apply P_id_mark_monotonic;assumption. intros ;apply P_id_ok_monotonic;assumption. intros ;apply P_id_start_monotonic;assumption. intros ;apply P_id_f_monotonic;assumption. intros ;apply P_id_proper_monotonic;assumption. intros ;apply P_id_check_monotonic;assumption. intros ;apply P_id_top_monotonic;assumption. intros ;apply P_id_found_monotonic;assumption. intros ;apply P_id_match_monotonic;assumption. intros ;apply P_id_active_bounded;assumption. intros ;apply P_id_X_bounded;assumption. intros ;apply P_id_c_bounded;assumption. intros ;apply P_id_mark_bounded;assumption. intros ;apply P_id_ok_bounded;assumption. intros ;apply P_id_start_bounded;assumption. intros ;apply P_id_f_bounded;assumption. intros ;apply P_id_proper_bounded;assumption. intros ;apply P_id_check_bounded;assumption. intros ;apply P_id_top_bounded;assumption. intros ;apply P_id_found_bounded;assumption. intros ;apply P_id_match_bounded;assumption. apply rules_monotonic. intros ;apply P_id_MATCH_monotonic;assumption. intros ;apply P_id_TOP_monotonic;assumption. intros ;apply P_id_ACTIVE_monotonic;assumption. intros ;apply P_id_F_monotonic;assumption. intros ;apply P_id_PROPER_monotonic;assumption. intros ;apply P_id_CHECK_monotonic;assumption. intros ;apply P_id_START_monotonic;assumption. Qed. Ltac rewrite_and_unfold := do 2 (rewrite marked_measure_equation); repeat ( match goal with | |- context [measure (algebra.Alg.Term ?f ?t)] => rewrite (measure_equation (algebra.Alg.Term f t)) | H:context [measure (algebra.Alg.Term ?f ?t)] |- _ => rewrite (measure_equation (algebra.Alg.Term f t)) in H|- end ). Definition lt a b := (Zwf.Zwf 0) (marked_measure a) (marked_measure b). Definition le a b := marked_measure a <= marked_measure b. Lemma lt_le_compat : forall a b c, (lt a b) ->(le b c) ->lt a c. Proof. unfold lt, le in *. intros a b c. apply (interp.le_lt_compat_right (interp.o_Z 0)). Qed. Lemma wf_lt : well_founded lt. Proof. unfold lt in *. apply Inverse_Image.wf_inverse_image with (B:=Z). apply Zwf.Zwf_well_founded. Qed. Lemma DP_R_xml_0_scc_16_strict_in_lt : Relation_Definitions.inclusion _ DP_R_xml_0_scc_16_strict lt. Proof. unfold Relation_Definitions.inclusion, lt in *. intros a b H;destruct H; match goal with | |- (Zwf.Zwf 0) _ (marked_measure (algebra.Alg.Term ?f ?l)) => let l'' := algebra.Alg_ext.find_replacement l in ((apply (interp.le_lt_compat_right (interp.o_Z 0)) with (marked_measure (algebra.Alg.Term f l''));[idtac| apply marked_measure_star_monotonic; repeat (apply algebra.EQT_ext.one_step_list_refl_trans_clos); (assumption)||(constructor 1)])) end ;clear ;rewrite_and_unfold ;repeat (generate_pos_hyp ); cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Lemma DP_R_xml_0_scc_16_large_in_le : Relation_Definitions.inclusion _ DP_R_xml_0_scc_16_large le. Proof. unfold Relation_Definitions.inclusion, le, Zwf.Zwf in *. intros a b H;destruct H; match goal with | |- _ <= marked_measure (algebra.Alg.Term ?f ?l) => let l'' := algebra.Alg_ext.find_replacement l in ((apply (interp.le_trans (interp.o_Z 0)) with (marked_measure (algebra.Alg.Term f l''));[idtac| apply marked_measure_star_monotonic; repeat (apply algebra.EQT_ext.one_step_list_refl_trans_clos); (assumption)||(constructor 1)])) end ;clear ;rewrite_and_unfold ;repeat (generate_pos_hyp ); cbv beta iota zeta delta - [Zle Zlt Zplus Zmult] ;intuition; (auto with zarith)||(repeat (translate_vars );prove_ineq ). Qed. Definition wf_DP_R_xml_0_scc_16_large := WF_DP_R_xml_0_scc_16_large.wf. Lemma wf : well_founded WF_DP_R_xml_0.DP_R_xml_0_scc_16. Proof. intros x. apply (well_founded_ind wf_lt). clear x. intros x. pattern x. apply (@Acc_ind _ DP_R_xml_0_scc_16_large). clear x. intros x _ IHx IHx'. constructor. intros y H. destruct H; (apply IHx';apply DP_R_xml_0_scc_16_strict_in_lt; econstructor eassumption)|| ((apply IHx;[econstructor eassumption| intros y' Hlt;apply IHx';apply lt_le_compat with (1:=Hlt) ; apply DP_R_xml_0_scc_16_large_in_le;econstructor eassumption])). apply wf_DP_R_xml_0_scc_16_large. Qed. End WF_DP_R_xml_0_scc_16. Definition wf_DP_R_xml_0_scc_16 := WF_DP_R_xml_0_scc_16.wf. Lemma acc_DP_R_xml_0_scc_16 : forall x y, (DP_R_xml_0_scc_16 x y) ->Acc WF_R_xml_0_deep_rew.DP_R_xml_0 x. Proof. intros x. pattern x. apply (@Acc_ind _ DP_R_xml_0_scc_16). intros x' _ Hrec y h. inversion h;clear h;subst; constructor;intros _y _h;inversion _h;clear _h;subst; (eapply Hrec;econstructor eassumption)|| ((eapply acc_DP_R_xml_0_non_scc_15; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))|| ((eapply acc_DP_R_xml_0_non_scc_4; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))|| ((R_xml_0_deep_rew.impossible_star_reduction_R_xml_0 )|| (eapply Hrec; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))))). apply wf_DP_R_xml_0_scc_16. Qed. Lemma wf : well_founded WF_R_xml_0_deep_rew.DP_R_xml_0. Proof. constructor;intros _y _h;inversion _h;clear _h;subst; (eapply acc_DP_R_xml_0_non_scc_15; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))|| ((eapply acc_DP_R_xml_0_non_scc_14; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))|| ((eapply acc_DP_R_xml_0_non_scc_13; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))|| ((eapply acc_DP_R_xml_0_non_scc_12; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))|| ((eapply acc_DP_R_xml_0_non_scc_11; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))|| ((eapply acc_DP_R_xml_0_non_scc_10; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))|| ((eapply acc_DP_R_xml_0_non_scc_9; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))|| ((eapply acc_DP_R_xml_0_non_scc_8; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))|| ((eapply acc_DP_R_xml_0_non_scc_7; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))|| ((eapply acc_DP_R_xml_0_non_scc_6; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))|| ((eapply acc_DP_R_xml_0_non_scc_5; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))|| ((eapply acc_DP_R_xml_0_non_scc_4; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))|| ((eapply acc_DP_R_xml_0_non_scc_3; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))|| ((eapply acc_DP_R_xml_0_non_scc_2; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))|| ((eapply acc_DP_R_xml_0_non_scc_1; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))|| ((eapply acc_DP_R_xml_0_non_scc_0; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))|| ((eapply acc_DP_R_xml_0_scc_16; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))|| ((eapply acc_DP_R_xml_0_scc_15; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))|| ((eapply acc_DP_R_xml_0_scc_14; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))|| ((eapply acc_DP_R_xml_0_scc_13; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))|| ((eapply acc_DP_R_xml_0_scc_12; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))|| ((eapply acc_DP_R_xml_0_scc_11; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))|| ((eapply acc_DP_R_xml_0_scc_10; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))|| ((eapply acc_DP_R_xml_0_scc_9; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))|| ((eapply acc_DP_R_xml_0_scc_8; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))|| ((eapply acc_DP_R_xml_0_scc_7; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))|| ((eapply acc_DP_R_xml_0_scc_6; econstructor (eassumption)||(algebra.Alg_ext.star_refl' ))|| ((eapply acc_DP_R_xml_0_scc_5; econstructor (eassumption)|| (algebra.Alg_ext.star_refl' ))|| ((eapply acc_DP_R_xml_0_scc_4; econstructor (eassumption)|| (algebra.Alg_ext.star_refl' ))|| ((eapply acc_DP_R_xml_0_scc_3; econstructor (eassumption)|| (algebra.Alg_ext.star_refl' ))|| ((eapply acc_DP_R_xml_0_scc_2; econstructor (eassumption)|| (algebra.Alg_ext.star_refl' ))|| ((eapply acc_DP_R_xml_0_scc_1; econstructor (eassumption)|| (algebra.Alg_ext.star_refl' ))|| ((eapply acc_DP_R_xml_0_scc_0; econstructor (eassumption)|| (algebra.Alg_ext.star_refl' ))|| ((R_xml_0_deep_rew.impossible_star_reduction_R_xml_0 )|| (fail)))))))))))))))))))))))))))))))))). Qed. End WF_DP_R_xml_0. Definition wf_H := WF_DP_R_xml_0.wf. Lemma wf : well_founded (algebra.EQT.one_step R_xml_0_deep_rew.R_xml_0_rules). Proof. apply ddp.dp_criterion. apply R_xml_0_deep_rew.R_xml_0_non_var. apply R_xml_0_deep_rew.R_xml_0_reg. intros ; apply (ddp.constructor_defined_dec _ _ R_xml_0_deep_rew.R_xml_0_rules_included). refine (Inclusion.wf_incl _ _ _ _ wf_H). intros x y H. destruct (R_xml_0_dp_step_spec H) as [f [l1 [l2 [H1 [H2 H3]]]]]. destruct (ddp.dp_list_complete _ _ R_xml_0_deep_rew.R_xml_0_rules_included _ _ H3) as [x' [y' [sigma [h1 [h2 h3]]]]]. clear H3. subst. vm_compute in h3|-. let e := type of h3 in (dp_concl_tac h2 h3 ltac:(fun _ => idtac) e). Qed. End WF_R_xml_0_deep_rew. (* *** Local Variables: *** *** coq-prog-name: "coqtop" *** *** coq-prog-args: ("-emacs-U" "-I" "$COCCINELLE/examples" "-I" "$COCCINELLE/term_algebra" "-I" "$COCCINELLE/term_orderings" "-I" "$COCCINELLE/basis" "-I" "$COCCINELLE/list_extensions" "-I" "$COCCINELLE/examples/cime_trace/") *** *** compile-command: "coqc -I $COCCINELLE/term_algebra -I $COCCINELLE/term_orderings -I $COCCINELLE/basis -I $COCCINELLE/list_extensions -I $COCCINELLE/examples/cime_trace/ -I $COCCINELLE/examples/ c_output/strat/tpdb-5.0___TRS___AProVE___Liveness8.trs/a3pat.v" *** *** End: *** *)