text
stringlengths
1.3k
3.62M
(* This program is free software; you can redistribute it and/or *) (* modify it under the terms of the GNU Lesser General Public License *) (* as published by the Free Software Foundation; either version 2.1 *) (* of the License, or (at your option) any later version. *) (* *) (* This program is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* GNU General Public License for more details. *) (* *) (* You should have received a copy of the GNU Lesser General Public *) (* License along with this program; if not, write to the Free *) (* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *) (* 02110-1301 USA *) (* Contribution to the Coq Library V6.3 (July 1999) *) (****************************************************************************) (* Revised and adapted to use Coq V6.1 features by the author *) (* February 1997 *) (****************************************************************************) (* script coq V5.8.3 *) (* *) (* *) (* An exercise on groups *) (* *) (* *) (* Pierre Casteran. *) (* LaBRI [[email protected]] *) (* *) (* *) (* This file presents a development in Coq of the following lemma: *) (* "Let E be a non-empty set, o an associative law on E, *) (* such that for each x:E, the functions [y:E](o x y) and *) (* [y:E](o y x) are onto. *) (* Then E is a group" *) (* *) (* See groups.ps.gz in this directory *) (* *) (****************************************************************************) (* Groups.v *) (****************************************************************************) Set Implicit Arguments. Unset Strict Implicit. Section General_definitions. Variable E : Set. Definition onto (f : E -> E) := forall y : E, {x : E | f x = y}. Variable o : E -> E -> E. Variable e : E. Variable s : E -> E. Definition associative := forall x y z : E, o x (o y z) = o (o x y) z. Definition left_neutral := forall x : E, o e x = x. Definition right_neutral := forall x : E, o x e = x. Definition left_symmetric := forall x : E, o (s x) x = e. Definition right_symmetric := forall x : E, o x (s x) = e. End General_definitions. (* what is a group on E ? *) Record group (E : Set) : Set := mkgroup {group_law : E -> E -> E; (* composition law *) group_assoc : associative group_law; group_neutral : E; (* neutral element *) group_sym : E -> E; (* symmetric *) group_l_neutral : left_neutral group_law group_neutral; group_r_neutral : right_neutral group_law group_neutral; group_l_sym : left_symmetric group_law group_neutral group_sym; group_r_sym : right_symmetric group_law group_neutral group_sym}. Section some_properties_of_groups. Variable E : Set. Variable G : group E. Let o := group_law G. Let s := group_sym G. Let e := group_neutral G. Let assoc := group_assoc G. Let l_neutral := group_l_neutral G. Let r_neutral := group_r_neutral G. Let l_sym := group_l_sym G. Let r_sym := group_r_sym G. Hint Resolve assoc l_sym l_neutral r_sym r_neutral. Hint Unfold o s e. (**************************************************) Lemma solve_equation : forall x y : E, o x y = e -> y = s x. (**************************************************) Proof. (* Goal: forall (x y : E) (_ : @eq E (o x y) e), @eq E y (s x) *) intros x y H. (* Goal: @eq E y (s x) *) transitivity (o e y). (* Goal: @eq E y (o y e) *) (* Goal: @eq E (o y e) y' *) symmetry in |- *; auto. (* Goal: @eq E (o e y) (s x) *) transitivity (o (s x) (o x y)). (* Goal: @eq E (o e y) (o (s x) (o x y)) *) (* Goal: @eq E (o (s x) (o x y)) (s x) *) transitivity (o (o (s x) x) y). (* Goal: @eq E (o e y) (o (o (s x) x) y) *) (* Goal: @eq E (o (o (s x) x) y) (o (s x) (o x y)) *) (* Goal: @eq E (o (s x) (o x y)) (s x) *) unfold o, e, s in |- *; rewrite (l_sym x); auto. (* Goal: @eq E y (o y e) *) (* Goal: @eq E (o y e) y' *) auto. (* Goal: @eq E y (o y e) *) (* Goal: @eq E (o y e) y' *) rewrite H; auto. Qed. Hint Resolve solve_equation. (***************************) Lemma ssx : forall x : E, x = s (s x). (***************************) Proof. (* Goal: @eq E y (o y e) *) (* Goal: @eq E (o y e) y' *) auto. Qed. End some_properties_of_groups. Section The_exercise_itself. Variable E : Set. Variable a : E. Variable o : E -> E -> E. Hypothesis o_assoc : associative o. Hypothesis o_onto_r : forall x : E, onto (fun y : E => o x y). Hypothesis o_onto_l : forall x : E, onto (fun y : E => o y x). Hint Resolve o_assoc o_onto_r o_onto_l. (********************************** Building the neutral element ... ************************************) (*****************************) Lemma Ea : {ea : E | o a ea = a}. (*****************************) Proof. (* Goal: @eq E y (o y e) *) (* Goal: @eq E (o y e) y' *) case (o_onto_r a a); intros x H; exists x; auto. (* Realizer (o_onto_r a a). Program_all. *) Qed. (* A right neutral element *) Definition e := let (e, _) := Ea in e. (***********************************) Lemma r_neutral : right_neutral o e. (***********************************) Proof. (* Goal: @right_neutral E o e *) unfold right_neutral, e in |- *; case Ea. (* Goal: forall (x : E) (_ : @eq E (o a x) a) (x0 : E), @eq E (o x0 x) x0 *) intros e0 eg x. (* e0 : E eg : (o a e0)=a x : E ============================ (o x e0)=x *) (* Goal: @eq E (o x e0) x *) case (o_onto_l a x); intros u eg'. (* Goal: @eq E (o y e) y' *) rewrite <- eg'. (* (o (o u a) e0)=(o u a) *) (* Goal: @eq E (o (o u a) e0) (o u a) *) rewrite <- (o_assoc u a e0). (* Goal: @eq E y (o y e) *) (* Goal: @eq E (o y e) y' *) rewrite eg; auto. Qed. Hint Resolve r_neutral. (*******************************) Lemma E'a : {e'a : E | o e'a a = a}. (*******************************) Proof. (* Goal: @eq E y (o y e) *) (* Goal: @eq E (o y e) y' *) case (o_onto_l a a); intros x H; exists x; auto. (* Realizer (o_onto_l a a). Program_all. *) Qed. Definition e' := let (e', _) := E'a in e'. (***************************************) Lemma e'_l_neutral : left_neutral o e'. (**************************************) Proof. (* Goal: @left_neutral E o e' *) unfold left_neutral, e' in |- *; case E'a. (* Goal: forall (x : E) (_ : @eq E (o x a) a) (x0 : E), @eq E (o x x0) x0 *) intros e'0 eg x. (* Goal: @eq E (o e'0 x) x *) case (o_onto_r a x); intros u eg'. (* Goal: @eq E (o y e) y' *) rewrite <- eg'. (* Goal: @eq E (o e'0 (o a u)) (o a u) *) rewrite (o_assoc e'0 a u). (* Goal: @eq E y (o y e) *) (* Goal: @eq E (o y e) y' *) rewrite eg; auto. Qed. Hint Resolve e'_l_neutral. (*******************) Lemma e_eq_e' : e = e'. (*******************) Proof. (* Goal: @eq E e e' *) transitivity (o e' e). (* Goal: @eq E y (o y e) *) (* Goal: @eq E (o y e) y' *) symmetry in |- *; auto. (* Goal: @eq E y (o y e) *) (* Goal: @eq E (o y e) y' *) auto. Qed. (*********************************) Lemma l_neutral : left_neutral o e. (*********************************) Proof. (* Goal: @eq E y (o y e) *) (* Goal: @eq E (o y e) y' *) rewrite e_eq_e'; auto. Qed. Hint Resolve l_neutral. (*********************************************************** we can now use the new element e to study the symmetrical ***********************************************************) (*********************************) Lemma lsym : forall x : E, {y : E | o y x = e}. (*********************************) Proof. (* Goal: forall x : E, @sig E (fun y : E => @eq E (o x y) e) *) intro x. (* Goal: @eq E y (o y e) *) (* Goal: @eq E (o y e) y' *) case (o_onto_l x e); intros u H; exists u; auto. Qed. Definition s (x : E) := let (y, _) return E := lsym x in y. (*********************************) Lemma l_sym : left_symmetric o e s. (*********************************) Proof. (* Goal: @left_symmetric E o e s *) unfold left_symmetric, s in |- *; intros. (* Goal: @eq E y (o y e) *) (* Goal: @eq E (o y e) y' *) case (lsym x); auto. Qed. Hint Resolve l_sym. (*********************************) Lemma rsym : forall x : E, {y : E | o x y = e}. (*********************************) Proof. (* Goal: forall x : E, @sig E (fun y : E => @eq E (o x y) e) *) intro x. (* Goal: @eq E y (o y e) *) (* Goal: @eq E (o y e) y' *) case (o_onto_r x e); intros u H; exists u; auto. Qed. (* provisional right symmetrical *) Definition s' (x : E) := let (y, _) return E := rsym x in y. (******************************) Lemma s_eq_s' : forall x : E, s x = s' x. (******************************) Proof. (* Goal: forall x : E, @eq E (s x) (s' x) *) intro x; unfold s, s' in |- *; case (rsym x); case (lsym x). (* Goal: forall (x0 : E) (_ : @eq E (o x0 x) e) (x1 : E) (_ : @eq E (o x x1) e), @eq E x0 x1 *) intros y eg y' eg'. (* Goal: @eq E y (o y e) *) (* Goal: @eq E (o y e) y' *) transitivity (o y e). auto. (* Goal: @eq E (o y e) y' *) rewrite <- eg'. (* Goal: @eq E (o y (o x y')) y' *) rewrite (o_assoc y x y'). (* Goal: @eq E y (o y e) *) (* Goal: @eq E (o y e) y' *) rewrite eg; auto. Qed. (**********************************) Lemma r_sym : right_symmetric o e s. (**********************************) Proof. (* Goal: forall x : E, @sig E (fun y : E => @eq E (o x y) e) *) unfold right_symmetric in |- *; intro x. (* Goal: @eq E (o x (s x)) e *) rewrite s_eq_s'. (* Goal: @eq E y (o y e) *) (* Goal: @eq E (o y e) y' *) unfold s' in |- *; case (rsym x); auto. Qed. Hint Resolve r_sym. (******************************) Theorem E_is_a_group : group E. (******************************) Proof. (* Goal: @eq E y (o y e) *) (* Goal: @eq E (o y e) y' *) apply mkgroup with o e s; auto. Qed. End The_exercise_itself.
(* File: NRules.v (last edited on 27/10/2000) (c) Klaus Weich *) Require Export Cons_Counter_Model. Require Export NSound. Inductive nsearch_spec_result_aux (goal : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist) : Set := | NDerivable : Derivable context (Atom goal) -> nsearch_spec_result_aux goal work ds ni ai a context | NRefutable : forall k : kripke_tree, Is_Monotone_kripke_tree k -> forces_ngamma work ds ni ai a k -> (forces_t k (Atom goal) -> False) -> nsearch_spec_result_aux goal work ds ni ai a context. Inductive nsearch_spec_result (goal : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist) : Set := NSearch_Res : forall ni1 : nested_imps, le_ni ni1 ni -> deco_sound work ds ni1 ai a -> nsearch_spec_result_aux goal work ds ni1 ai a context -> nsearch_spec_result goal work ds ni ai a context. Definition nsearch_spec (goal : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist) := deco_sound work ds ni ai a -> nsound work ds ni ai a context -> nminimal work ds ni ai a context -> nsearch_spec_result goal work ds ni ai a context. (**********************************************************************) Lemma fail : forall (i : Int) (dni : decorated_nested_imps) (ai : atomic_imps) (a : atoms) (context : flist), a_ai_disj a ai -> a_goal_disj a i -> nsearch_spec i nf_nil DNil (rev_app dni NNil) ai a context. (* Goal: nsearch_spec goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) unfold nsearch_spec in |- *. (* Goal: forall (i : Int) (dni : decorated_nested_imps) (ai : atomic_imps) (a : atoms) (context : flist) (_ : a_ai_disj a ai) (_ : a_goal_disj a i) (_ : deco_sound nf_nil DNil (rev_app dni NNil) ai a) (_ : nsound nf_nil DNil (rev_app dni NNil) ai a context) (_ : nminimal nf_nil DNil (rev_app dni NNil) ai a context), nsearch_spec_result i nf_nil DNil (rev_app dni NNil) ai a context *) intros i dni ai a context a_ai_disjunct goal_a_disj complete sound mon. (* Goal: nsearch_spec_result i nf_nil DNil (rev_app dni NNil) ai a context *) apply NSearch_Res with (rev_app dni NNil); try assumption. (* Goal: le_ni ni ni *) (* Goal: nsearch_spec_result_aux goal (@cons normal_form NFalsum work) ds ni ai a context *) apply le_ni_refl. (* Goal: nsearch_spec_result_aux i nf_nil DNil (rev_app dni NNil) ai a context *) elim (cons_counter_model i dni ai a); try assumption. (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (NAtom i) work) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom goal), False), nsearch_spec_result goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) (* Goal: eqv_ni ni ni2 *) (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) (* Goal: nminimal (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) intros k k_is_mon k_forces_ngamma k_notforces_goal. (* Goal: nsearch_spec_result_aux i nf_nil DNil (rev_app dni NNil) ai a context *) apply NRefutable with k; assumption. Qed. (**********************************************************************) Lemma rule_shift_work_ds : forall (goal i j : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist), nsearch_spec goal work ((i, j) :: ds) ni ai a context -> nsearch_spec goal (NDisj i j :: work) ds ni ai a context. (* Goal: forall (goal i j : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist) (_ : nsearch_spec goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context), nsearch_spec goal (@cons normal_form (NDisj i j) work) ds ni ai a context *) intros goal i j work ds ni ai a context premiss. (* Goal: nsearch_spec goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) unfold nsearch_spec in |- *; intros complete sound mon. (* Goal: nsearch_spec_result goal (@cons normal_form (NAtom i) work) ds ni ai a context *) elim premiss; clear premiss. (* Goal: forall (ni1 : nested_imps) (_ : le_ni ni1 ni) (_ : deco_sound (@app normal_form bs work) ds ni1 ai' a') (_ : nsearch_spec_result_aux goal (@app normal_form bs work) ds ni1 ai' a' context), nsearch_spec_result goal (@cons normal_form (NAtom i) work) ds ni ai a context *) (* Goal: deco_sound (@app normal_form bs work) ds ni ai' a' *) (* Goal: nsound (@app normal_form bs work) ds ni ai' a' context *) (* Goal: nminimal (@app normal_form bs work) ds ni ai' a' context *) intros ni1 less1 complete1 spec1. (* Goal: nsearch_spec_result goal (@cons normal_form (NAtom i) work) ds ni ai a context *) (* Goal: deco_sound work ds ni ai a' *) (* Goal: nsound work ds ni ai a' context *) (* Goal: nminimal work ds ni ai a' context *) apply NSearch_Res with ni1. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply deco_sound_shift_ds_work; assumption. (* Goal: nsearch_spec_result_aux goal (@cons normal_form (NAtom i) work) ds ni1 ai a context *) (* Goal: deco_sound (@app normal_form bs work) ds ni ai' a' *) (* Goal: nsound (@app normal_form bs work) ds ni ai' a' context *) (* Goal: nminimal (@app normal_form bs work) ds ni ai' a' context *) elim spec1; clear spec1. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) intros derivable_goal; apply NDerivable; assumption. (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom a1), False), nsearch_spec_result goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) intros k k_is_mon k_forces_ngamma k_nonforces_goal. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply NRefutable with k; try assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply forces_ngamma_shift_ds_work; assumption. (* side premisses: Elim premiss. *) (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply deco_sound_shift_work_ds; assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply nsound_shift_work_ds; assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply nminimal_shift_work_ds; assumption. Qed. Lemma rule_shift_work_ni0 : forall (goal : Int) (x : nimp) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist), nsearch_spec goal work ds (Undecorated x :: ni) ai a context -> nsearch_spec goal (NImp_NF x :: work) ds ni ai a context. (* Goal: forall (goal : Int) (x : nimp) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist) (_ : nsearch_spec goal work ds (@cons nested_imp (Undecorated x) ni) ai a context), nsearch_spec goal (@cons normal_form (NImp_NF x) work) ds ni ai a context *) intros goal x work ds ni ai a context premiss. (* Goal: nsearch_spec goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) unfold nsearch_spec in |- *; intros complete sound mon. (* Goal: nsearch_spec_result goal (@cons normal_form (NAtom i) work) ds ni ai a context *) elim premiss; clear premiss. (* Goal: forall (ni1 : nested_imps) (_ : le_ni ni1 ni) (_ : deco_sound (@app normal_form bs work) ds ni1 ai' a') (_ : nsearch_spec_result_aux goal (@app normal_form bs work) ds ni1 ai' a' context), nsearch_spec_result goal (@cons normal_form (NAtom i) work) ds ni ai a context *) (* Goal: deco_sound (@app normal_form bs work) ds ni ai' a' *) (* Goal: nsound (@app normal_form bs work) ds ni ai' a' context *) (* Goal: nminimal (@app normal_form bs work) ds ni ai' a' context *) intros ni1 less1 complete1 spec1. (* Goal: nsearch_spec_result goal (@cons normal_form (NImp_NF x) work) ds ni ai a context *) (* Goal: deco_sound work ds (@cons nested_imp (Undecorated x) ni) ai a *) (* Goal: nsound work ds (@cons nested_imp (Undecorated x) ni) ai a context *) (* Goal: nminimal work ds (@cons nested_imp (Undecorated x) ni) ai a context *) apply NSearch_Res with (tail ni1). (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) inversion_clear less1; assumption. (* Goal: deco_sound (@cons normal_form (NImp_NF x) work) ds (@tl nested_imp ni1) ai a *) (* Goal: nsearch_spec_result_aux goal (@cons normal_form (NImp_NF x) work) ds (@tl nested_imp ni1) ai a context *) (* Goal: deco_sound work ds (@cons nested_imp (Undecorated x) ni) ai a *) (* Goal: nsound work ds (@cons nested_imp (Undecorated x) ni) ai a context *) (* Goal: nminimal work ds (@cons nested_imp (Undecorated x) ni) ai a context *) generalize complete1; clear spec1 complete1. (* Goal: forall _ : forces_ngamma work ds ni1 ai a k, forces_ngamma (@cons normal_form (NImp_NF x) work) ds (@tl nested_imp ni1) ai a k *) (* Goal: deco_sound work ds (@cons nested_imp (Undecorated x) ni) ai a *) (* Goal: nsound work ds (@cons nested_imp (Undecorated x) ni) ai a context *) (* Goal: nminimal work ds (@cons nested_imp (Undecorated x) ni) ai a context *) inversion_clear less1; intros. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply deco_sound_shift_ni_work with (x := Undecorated x); assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply deco_sound_shift_ni_work with (x := Decorated x k); assumption. (* Goal: nsearch_spec_result_aux goal (@cons normal_form (NAtom i) work) ds ni1 ai a context *) (* Goal: deco_sound (@app normal_form bs work) ds ni ai' a' *) (* Goal: nsound (@app normal_form bs work) ds ni ai' a' context *) (* Goal: nminimal (@app normal_form bs work) ds ni ai' a' context *) elim spec1; clear spec1. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) intros derivable_goal; apply NDerivable; assumption. (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom a1), False), nsearch_spec_result goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) intros k k_is_mon k_forces_ngamma k_nonforces_goal. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply NRefutable with k; try assumption. (* Goal: forces_ngamma (@cons normal_form (NImp_NF x) work) ds (@tl nested_imp ni1) ai a k *) (* Goal: deco_sound work ds (@cons nested_imp (Undecorated x) ni) ai a *) (* Goal: nsound work ds (@cons nested_imp (Undecorated x) ni) ai a context *) (* Goal: nminimal work ds (@cons nested_imp (Undecorated x) ni) ai a context *) generalize k_forces_ngamma; clear complete1 k_forces_ngamma. (* Goal: forall _ : forces_ngamma work ds ni1 ai a k, forces_ngamma (@cons normal_form (NImp_NF x) work) ds (@tl nested_imp ni1) ai a k *) (* Goal: deco_sound work ds (@cons nested_imp (Undecorated x) ni) ai a *) (* Goal: nsound work ds (@cons nested_imp (Undecorated x) ni) ai a context *) (* Goal: nminimal work ds (@cons nested_imp (Undecorated x) ni) ai a context *) inversion_clear less1; intros. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply forces_ngamma_shift_ni_work with (x := Undecorated x); assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply forces_ngamma_shift_ni_work with (x := Decorated x k0); assumption. (* side premisses: Elim premiss. *) (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply deco_sound_shift_work_ni0; assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply nsound_shift_work_ni; assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply nminimal_shift_work_ni; assumption. Qed. Lemma rule_shift_work_ai_new : forall (goal i : Int) (b : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai ai' : atomic_imps) (a : atoms) (context : flist), (forall x : unit, LOOKUP unit i a x -> False) -> (forall bs : nf_list, LOOKUP nf_list i ai bs -> False) -> EQUIV_INS nf_list i (cons b) nf_nil ai ai' -> nsearch_spec goal work ds ni ai' a context -> nsearch_spec goal (AImp i b :: work) ds ni ai a context. intros goal i b work ds ni ai ai' a context notlookup_i notlookup_bs equiv_ins premiss. (* Goal: nsearch_spec goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) unfold nsearch_spec in |- *; intros complete sound mon. (* Goal: nsearch_spec_result goal (@cons normal_form (NAtom i) work) ds ni ai a context *) elim premiss; clear premiss. (* Goal: forall (ni1 : nested_imps) (_ : le_ni ni1 ni) (_ : deco_sound (@app normal_form bs work) ds ni1 ai' a') (_ : nsearch_spec_result_aux goal (@app normal_form bs work) ds ni1 ai' a' context), nsearch_spec_result goal (@cons normal_form (NAtom i) work) ds ni ai a context *) (* Goal: deco_sound (@app normal_form bs work) ds ni ai' a' *) (* Goal: nsound (@app normal_form bs work) ds ni ai' a' context *) (* Goal: nminimal (@app normal_form bs work) ds ni ai' a' context *) intros ni1 less1 complete1 spec1. (* Goal: nsearch_spec_result goal (@cons normal_form (NAtom i) work) ds ni ai a context *) (* Goal: deco_sound work ds ni ai a' *) (* Goal: nsound work ds ni ai a' context *) (* Goal: nminimal work ds ni ai a' context *) apply NSearch_Res with ni1. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply deco_sound_shift_ai_work_new with ai'; assumption. (* Goal: nsearch_spec_result_aux goal (@cons normal_form (NAtom i) work) ds ni1 ai a context *) (* Goal: deco_sound (@app normal_form bs work) ds ni ai' a' *) (* Goal: nsound (@app normal_form bs work) ds ni ai' a' context *) (* Goal: nminimal (@app normal_form bs work) ds ni ai' a' context *) elim spec1; clear spec1. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) intros derivable_goal; apply NDerivable; assumption. (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom a1), False), nsearch_spec_result goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) intros k k_is_mon k_forces_ngamma k_nonforces_goal. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply NRefutable with k; try assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply forces_ngamma_shift_ai_work_new with ai'; assumption. (* side premisses: Elim premiss. *) (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply deco_sound_shift_work_ai with i b ai; assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply nsound_shift_work_ai with i b ai; assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply nminimal_shift_work_ai_new with i b ai; assumption. Qed. Lemma rule_shift_work_ai_old : forall (goal i : Int) (b : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (bs : nf_list) (ai ai' : atomic_imps) (a : atoms) (context : flist), (forall x : unit, LOOKUP unit i a x -> False) -> LOOKUP nf_list i ai bs -> EQUIV_INS nf_list i (cons b) nf_nil ai ai' -> nsearch_spec goal work ds ni ai' a context -> nsearch_spec goal (AImp i b :: work) ds ni ai a context. intros goal i b work ds ni bs ai ai' a context notlookup_i lookup_bs equiv_ins premiss. (* Goal: nsearch_spec goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) unfold nsearch_spec in |- *; intros complete sound mon. (* Goal: nsearch_spec_result goal (@cons normal_form (NAtom i) work) ds ni ai a context *) elim premiss; clear premiss. (* Goal: forall (ni1 : nested_imps) (_ : le_ni ni1 ni) (_ : deco_sound (@app normal_form bs work) ds ni1 ai' a') (_ : nsearch_spec_result_aux goal (@app normal_form bs work) ds ni1 ai' a' context), nsearch_spec_result goal (@cons normal_form (NAtom i) work) ds ni ai a context *) (* Goal: deco_sound (@app normal_form bs work) ds ni ai' a' *) (* Goal: nsound (@app normal_form bs work) ds ni ai' a' context *) (* Goal: nminimal (@app normal_form bs work) ds ni ai' a' context *) intros ni1 less1 complete1 spec1. (* Goal: nsearch_spec_result goal (@cons normal_form (NAtom i) work) ds ni ai a context *) (* Goal: deco_sound work ds ni ai a' *) (* Goal: nsound work ds ni ai a' context *) (* Goal: nminimal work ds ni ai a' context *) apply NSearch_Res with ni1. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply deco_sound_shift_ai_work_old with bs ai'; assumption. (* Goal: nsearch_spec_result_aux goal (@cons normal_form (NAtom i) work) ds ni1 ai a context *) (* Goal: deco_sound (@app normal_form bs work) ds ni ai' a' *) (* Goal: nsound (@app normal_form bs work) ds ni ai' a' context *) (* Goal: nminimal (@app normal_form bs work) ds ni ai' a' context *) elim spec1; clear spec1. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) intros derivable_goal; apply NDerivable; assumption. (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom a1), False), nsearch_spec_result goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) intros k k_is_mon k_forces_ngamma k_nonforces_goal. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply NRefutable with k; try assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply forces_ngamma_shift_ai_work_old with bs ai'; assumption. (* side premisses: Elim premiss. *) (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply deco_sound_shift_work_ai with i b ai; assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply nsound_shift_work_ai with i b ai; assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply nminimal_shift_work_ai_old with i b bs ai; assumption. Qed. Lemma rule_shift_work_a : forall (goal i : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a a' : atoms) (context : flist), (forall bs : nf_list, LOOKUP nf_list i ai bs -> False) -> (forall d : unit, LOOKUP unit i a d -> False) -> EQUIV_INS unit i (fun _ : unit => tt) tt a a' -> nsearch_spec goal work ds ni ai a' context -> nsearch_spec goal (NAtom i :: work) ds ni ai a context. intros goal i work ds ni ai a a' context notlookup_bs notlookup_i equiv_ins premiss. (* Goal: nsearch_spec goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) unfold nsearch_spec in |- *; intros complete sound mon. (* Goal: nsearch_spec_result goal (@cons normal_form (NAtom i) work) ds ni ai a context *) elim premiss; clear premiss. (* Goal: forall (ni1 : nested_imps) (_ : le_ni ni1 ni) (_ : deco_sound (@app normal_form bs work) ds ni1 ai' a') (_ : nsearch_spec_result_aux goal (@app normal_form bs work) ds ni1 ai' a' context), nsearch_spec_result goal (@cons normal_form (NAtom i) work) ds ni ai a context *) (* Goal: deco_sound (@app normal_form bs work) ds ni ai' a' *) (* Goal: nsound (@app normal_form bs work) ds ni ai' a' context *) (* Goal: nminimal (@app normal_form bs work) ds ni ai' a' context *) intros ni1 less1 complete1 spec1. (* Goal: nsearch_spec_result goal (@cons normal_form (NAtom i) work) ds ni ai a context *) (* Goal: deco_sound work ds ni ai a' *) (* Goal: nsound work ds ni ai a' context *) (* Goal: nminimal work ds ni ai a' context *) apply NSearch_Res with ni1. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply deco_sound_shift_a_work with a'; assumption. (* Goal: nsearch_spec_result_aux goal (@cons normal_form (NAtom i) work) ds ni1 ai a context *) (* Goal: deco_sound (@app normal_form bs work) ds ni ai' a' *) (* Goal: nsound (@app normal_form bs work) ds ni ai' a' context *) (* Goal: nminimal (@app normal_form bs work) ds ni ai' a' context *) elim spec1; clear spec1. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) intros derivable_goal; apply NDerivable; assumption. (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom a1), False), nsearch_spec_result goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) intros k k_is_mon k_forces_ngamma k_nonforces_goal. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply NRefutable with k; try assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply forces_ngamma_shift_a_work with a'; assumption. (* side premisses: Elim premiss. *) (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply deco_sound_shift_work_a with i a; assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply nsound_shift_work_a with i a; assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply nminimal_shift_work_a with i a; assumption. Qed. Lemma shift_ni_dni : forall (goal : Int) (work : nf_list) (ds : disjs) (x : nimp) (k : kripke_tree) (ni : nested_imps) (dni : decorated_nested_imps) (ai : atomic_imps) (a : atoms) (context : flist), nsearch_spec goal work ds (rev_app ((x, k) :: dni) ni) ai a context -> nsearch_spec goal work ds (rev_app dni (Decorated x k :: ni)) ai a context. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) intros; assumption. Qed. (*************************************************************************) Lemma nax : forall (goal : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist), in_ngamma work ds ni ai a (NAtom goal) -> nsearch_spec goal work ds ni ai a context. (* Goal: nsearch_spec goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) unfold nsearch_spec in |- *. (* Goal: forall (goal : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist) (_ : in_ngamma work ds ni ai a (NAtom goal)) (_ : deco_sound work ds ni ai a) (_ : nsound work ds ni ai a context) (_ : nminimal work ds ni ai a context), nsearch_spec_result goal work ds ni ai a context *) intros goal work ds ni ai a context in_ngamma complete sound mon. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply NSearch_Res with ni; try assumption. (* Goal: le_ni ni ni *) (* Goal: nsearch_spec_result_aux goal (@cons normal_form NFalsum work) ds ni ai a context *) apply le_ni_refl. (* Goal: nsearch_spec_result_aux goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni6 ai a context *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (NAtom j) work) ds ni5 ai a k) (_ : forall _ : forces_t k (Atom goal), False), nsearch_spec_result_aux goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni6 ai a context *) (* Goal: eqv_ni ni ni5 *) (* Goal: eqv_ni ni4 ni *) (* Goal: deco_sound (@cons normal_form (NAtom j) work) ds ni4 ai a *) (* Goal: nsound (@cons normal_form (NAtom j) work) ds ni4 ai a (@cons form (Atom j) context) *) (* Goal: nminimal (@cons normal_form (NAtom j) work) ds ni4 ai a (@cons form (Atom j) context) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (NAtom i) work) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom goal), False), nsearch_spec_result goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) (* Goal: eqv_ni ni ni2 *) (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) (* Goal: nminimal (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) apply NDerivable. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply sound with (c := NAtom goal); assumption. Qed. (**********************************************************************) Lemma nefq : forall (goal : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist), nsearch_spec goal (NFalsum :: work) ds ni ai a context. (* Goal: nsearch_spec goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) unfold nsearch_spec in |- *. (* Goal: forall (goal : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist) (_ : deco_sound (@cons normal_form NFalsum work) ds ni ai a) (_ : nsound (@cons normal_form NFalsum work) ds ni ai a context) (_ : nminimal (@cons normal_form NFalsum work) ds ni ai a context), nsearch_spec_result goal (@cons normal_form NFalsum work) ds ni ai a context *) intros goal work ds ni ai a context complete sound mon. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply NSearch_Res with ni; try assumption. (* Goal: le_ni ni ni *) (* Goal: nsearch_spec_result_aux goal (@cons normal_form NFalsum work) ds ni ai a context *) apply le_ni_refl. (* Goal: nsearch_spec_result_aux goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni6 ai a context *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (NAtom j) work) ds ni5 ai a k) (_ : forall _ : forces_t k (Atom goal), False), nsearch_spec_result_aux goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni6 ai a context *) (* Goal: eqv_ni ni ni5 *) (* Goal: eqv_ni ni4 ni *) (* Goal: deco_sound (@cons normal_form (NAtom j) work) ds ni4 ai a *) (* Goal: nsound (@cons normal_form (NAtom j) work) ds ni4 ai a (@cons form (Atom j) context) *) (* Goal: nminimal (@cons normal_form (NAtom j) work) ds ni4 ai a (@cons form (Atom j) context) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (NAtom i) work) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom goal), False), nsearch_spec_result goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) (* Goal: eqv_ni ni ni2 *) (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) (* Goal: nminimal (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) apply NDerivable. (* Goal: Derivable context (Atom goal) *) elim (sound NFalsum). (* Goal: forall (t : proof_term) (_ : derives context t (nf2form NFalsum)), Derivable context (Atom goal) *) (* Goal: in_ngamma (@cons normal_form NFalsum work) ds ni ai a NFalsum *) intros t der_t. (* Goal: Derivable context (Atom goal) *) (* Goal: in_ngamma (@cons normal_form NFalsum work) ds ni ai a NFalsum *) apply Derivable_Intro with (Efq t (Atom goal)). (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply ByAbsurdity; assumption. (* Goal: in_ngamma (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds dni_ni ai a (AImp a1 b) *) (* Goal: nminimal (@cons normal_form (NImp_NF (NImp a0 a1 b)) (@cons normal_form (NAtom a0) work)) ds dni_ni ai a (@cons form (Atom a0) context) *) apply in_ngamma_cons_work_head. Qed. Lemma contradiction_atoms : forall (goal i : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist), LOOKUP unit i a tt -> nsearch_spec goal work ds ni ai a context -> nsearch_spec goal (NAtom i :: work) ds ni ai a context. (* Goal: forall (goal i : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist) (_ : LOOKUP unit i a tt) (_ : nsearch_spec goal work ds ni ai a context), nsearch_spec goal (@cons normal_form (NAtom i) work) ds ni ai a context *) intros goal i work ds ni ai a context in_atoms premiss. (* Goal: nsearch_spec goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) unfold nsearch_spec in |- *; intros complete sound mon. (* Goal: nsearch_spec_result goal (@cons normal_form (NAtom i) work) ds ni ai a context *) cut (EQUIV_INS unit i (fun _ => tt) tt a a). (* Goal: forall _ : EQUIV_INS unit i (fun _ : unit => tt) tt a a, nsearch_spec_result goal (@cons normal_form (NAtom i) work) ds ni ai a context *) (* Goal: EQUIV_INS unit i (fun _ : unit => tt) tt a a *) intros equiv_ins. (* Goal: nsearch_spec_result goal (@cons normal_form (NAtom i) work) ds ni ai a context *) elim premiss; clear premiss. (* Goal: forall (ni1 : nested_imps) (_ : le_ni ni1 ni) (_ : deco_sound work ds ni1 ai a) (_ : nsearch_spec_result_aux goal work ds ni1 ai a context), nsearch_spec_result goal (@cons normal_form (NAtom i) work) ds ni ai a context *) (* Goal: deco_sound work ds ni ai a *) (* Goal: nsound work ds ni ai a context *) (* Goal: nminimal work ds ni ai a context *) (* Goal: EQUIV_INS unit i (fun _ : unit => tt) tt a a *) clear mon sound complete. (* Goal: forall (ni1 : nested_imps) (_ : le_ni ni1 ni) (_ : deco_sound work ds ni1 ai a) (_ : nsearch_spec_result_aux goal work ds ni1 ai a context), nsearch_spec_result goal (@cons normal_form (NAtom i) work) ds ni ai a context *) (* Goal: deco_sound work ds ni ai a *) (* Goal: nsound work ds ni ai a context *) (* Goal: nminimal work ds ni ai a context *) (* Goal: EQUIV_INS unit i (fun _ : unit => tt) tt a a *) intros ni1 le1 complete1 spec1. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply NSearch_Res with ni1; try assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply deco_sound_shift_a_work with a; assumption. (* Goal: nsearch_spec_result_aux goal (@cons normal_form (NAtom i) work) ds ni1 ai a context *) (* Goal: deco_sound (@app normal_form bs work) ds ni ai' a' *) (* Goal: nsound (@app normal_form bs work) ds ni ai' a' context *) (* Goal: nminimal (@app normal_form bs work) ds ni ai' a' context *) elim spec1; clear spec1. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) intros der_goal; apply NDerivable; assumption. (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (NAtom i) work) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom goal), False), nsearch_spec_result goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) (* Goal: eqv_ni ni ni2 *) (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) (* Goal: nminimal (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) intros k k_is_mon k_forces_ngamma k_notforces_goal. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply NRefutable with k; try assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply forces_ngamma_shift_a_work with a; assumption. (* side premisses: (Elim spec ..) *) (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply deco_sound_shift_work_a with i a; assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply nsound_shift_work_a with i a; assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply nminimal_shift_work_a with i a; assumption. (* side premiss (Cut (EQUIV_INS ....)) *) (* Goal: EQUIV_INS unit i (fun _ : unit => tt) tt a a *) clear complete sound mon premiss context ai ni ds work goal. (* Goal: EQUIV_INS unit i (fun _ : unit => tt) tt a a *) generalize in_atoms; clear in_atoms. (* Goal: forall _ : LOOKUP unit i a tt, EQUIV_INS unit i (fun _ : unit => tt) tt a a *) elim a; clear a; intros t avl_t. (* Goal: forall _ : LOOKUP unit i (AVL_intro unit t avl_t) tt, EQUIV_INS unit i (fun _ : unit => tt) tt (AVL_intro unit t avl_t) (AVL_intro unit t avl_t) *) unfold LOOKUP in |- *. (* Goal: forall _ : lookup unit i t tt, EQUIV_INS unit i (fun _ : unit => tt) tt (AVL_intro unit t avl_t) (AVL_intro unit t avl_t) *) unfold EQUIV_INS in |- *. (* Goal: forall _ : lookup unit i t tt, equiv_ins unit i (fun _ : unit => tt) tt t t *) intros lookup. (* Goal: equiv_ins unit i (fun _ : unit => tt) tt t t *) apply equiv_ins_intro. (* Goal: forall (k : Int) (data : unit) (_ : Equal k i) (_ : AvlTrees.lookup unit k t data), AvlTrees.lookup unit k t tt *) (* Goal: forall (k : Int) (_ : Equal k i) (_ : forall (data : unit) (_ : AvlTrees.lookup unit k t data), False), AvlTrees.lookup unit k t tt *) (* Goal: forall (k : Int) (data : unit) (_ : not (Equal k i)) (_ : AvlTrees.lookup unit k t data), AvlTrees.lookup unit k t data *) (* Goal: forall (k : Int) (data : unit) (_ : not (Equal k i)) (_ : AvlTrees.lookup unit k t data), AvlTrees.lookup unit k t data *) intros k d eq_k lookup0. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) rewrite (equal_eq k i eq_k); assumption. (* Goal: forall (k : Int) (_ : Equal k i) (_ : forall (data : unit) (_ : AvlTrees.lookup unit k t data), False), AvlTrees.lookup unit k t tt *) (* Goal: forall (k : Int) (data : unit) (_ : not (Equal k i)) (_ : AvlTrees.lookup unit k t data), AvlTrees.lookup unit k t data *) (* Goal: forall (k : Int) (data : unit) (_ : not (Equal k i)) (_ : AvlTrees.lookup unit k t data), AvlTrees.lookup unit k t data *) intros k eq_k notlookup0. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) rewrite (equal_eq k i eq_k); assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) intros; assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) intros; assumption. Qed. (**************************************************************************) Lemma left_p_imp_work : forall (goal i : Int) (b : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist), forces0_t a i -> nsearch_spec goal (b :: work) ds ni ai a context -> nsearch_spec goal (AImp i b :: work) ds ni ai a context. (* Goal: forall (goal i : Int) (b : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist) (_ : forces0_t a i) (_ : nsearch_spec goal (@cons normal_form b work) ds ni ai a context), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni ai a context *) intros goal i b work ds ni ai a context forces_i premiss. (* Goal: nsearch_spec goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) unfold nsearch_spec in |- *; intros complete sound mon. (* Goal: nsearch_spec_result goal (@cons normal_form (NAtom i) work) ds ni ai a context *) elim premiss; clear premiss. (* Goal: forall (ni1 : nested_imps) (_ : le_ni ni1 ni) (_ : deco_sound (@app normal_form bs work) ds ni1 ai' a') (_ : nsearch_spec_result_aux goal (@app normal_form bs work) ds ni1 ai' a' context), nsearch_spec_result goal (@cons normal_form (NAtom i) work) ds ni ai a context *) (* Goal: deco_sound (@app normal_form bs work) ds ni ai' a' *) (* Goal: nsound (@app normal_form bs work) ds ni ai' a' context *) (* Goal: nminimal (@app normal_form bs work) ds ni ai' a' context *) intros ni1 less1 complete1 spec1. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply NSearch_Res with ni1; try assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply deco_sound_cons_work_weak with b; try assumption. (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (nf2form b)), forces_t k (nf2form (AImp i b)) *) (* Goal: nsearch_spec_result_aux goal (@cons normal_form (AImp i b) work) ds ni1 ai a context *) (* Goal: deco_sound (@cons normal_form b work) ds ni ai a *) (* Goal: nsound (@cons normal_form b work) ds ni ai a context *) (* Goal: nminimal (@cons normal_form b work) ds ni ai a context *) intros. apply forces_b__forces_a_imp_b_t with (a := Atom i) (b := nf2form b); (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) assumption. (* Goal: nsearch_spec_result_aux goal (@cons normal_form (NAtom i) work) ds ni1 ai a context *) (* Goal: deco_sound (@app normal_form bs work) ds ni ai' a' *) (* Goal: nsound (@app normal_form bs work) ds ni ai' a' context *) (* Goal: nminimal (@app normal_form bs work) ds ni ai' a' context *) elim spec1; clear spec1. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) intros derivable_goal; apply NDerivable; assumption. (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom a1), False), nsearch_spec_result goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) intros k k_is_mon k_forces_ngamma k_nonforces_goal. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply NRefutable with k; try assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply forces_ngamma_cons_work_weak with b; try assumption. (* Goal: forall _ : forces_t k (nf2form b), forces_t k (nf2form (AImp i b)) *) (* Goal: deco_sound (@cons normal_form b work) ds ni ai a *) (* Goal: nsound (@cons normal_form b work) ds ni ai a context *) (* Goal: nminimal (@cons normal_form b work) ds ni ai a context *) intros forces_b. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) simpl in |- *; apply forces_b__forces_a_imp_b_t; assumption. (* side premisses: Elim premiss. *) (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply deco_sound_cons_work_strength with (AImp i b); try assumption. (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds dni_ni ai a k), forces_t k (nf2form (NImp_NF (NImp a0 a1 b))) *) (* Goal: nminimal (@cons normal_form (NImp_NF (NImp a0 a1 b)) (@cons normal_form (NAtom a0) work)) ds dni_ni ai a (@cons form (Atom a0) context) *) intros k k_is_mon k_forces_ngamma. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply forces_a_a_imp_b__forces_b_t with (Atom i); try assumption. (* Goal: forces_t k (Atom i) *) (* Goal: forces_t k (Imp (Atom i) (nf2form b)) *) (* Goal: nsound (@cons normal_form b work) ds ni ai a context *) (* Goal: nminimal (@cons normal_form b work) ds ni ai a context *) apply k_forces_ngamma with (c := NAtom i). (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply In_Atoms; assumption. (* Goal: forces_t k (Imp (Atom i) (nf2form b)) *) (* Goal: nsound (@cons normal_form b work) ds ni ai a context *) (* Goal: nminimal (@cons normal_form b work) ds ni ai a context *) apply k_forces_ngamma with (c := AImp i b). (* Goal: in_ngamma (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds dni_ni ai a (AImp a1 b) *) (* Goal: nminimal (@cons normal_form (NImp_NF (NImp a0 a1 b)) (@cons normal_form (NAtom a0) work)) ds dni_ni ai a (@cons form (Atom a0) context) *) apply in_ngamma_cons_work_head. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply nsound_cons_work_weak with (AImp i b); try assumption. (* Goal: forall _ : Derivable context (nf2form (AImp i b)), Derivable context (nf2form b) *) (* Goal: nminimal (@cons normal_form b work) ds ni ai a context *) intros der_ab. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply derivable_a_a_imp_b__derivable_b with (Atom i); try assumption. (* Goal: Derivable context (Atom i) *) (* Goal: nminimal (@cons normal_form b work) ds ni ai a context *) apply sound with (c := NAtom i). (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply In_Atoms; assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply nminimal_cons_work_weak with (AImp i b); try assumption. (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (nf2form b)), forces_t k (nf2form (AImp i b)) *) intros k k_is_mon forces_b. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) simpl in |- *; apply forces_b__forces_a_imp_b_t; assumption. Qed. (****************************************************************) Lemma left_p_imp_ai : forall (goal i : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (bs : nf_list) (ai ai' : atomic_imps) (a a' : atoms) (context : flist), LOOKUP nf_list i ai bs -> EQUIV_DEL nf_list i ai ai' -> (forall d : unit, LOOKUP unit i a d -> False) -> EQUIV_INS unit i (fun _ : unit => tt) tt a a' -> nsearch_spec goal (bs ++ work) ds ni ai' a' context -> nsearch_spec goal (NAtom i :: work) ds ni ai a context. intros goal i work ds ni bs ai ai' a a' context lookup_bs equiv_del notlookup_i equiv_ins premiss. (* Goal: nsearch_spec goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) unfold nsearch_spec in |- *; intros complete sound mon. (* Goal: nsearch_spec_result goal (@cons normal_form (NAtom i) work) ds ni ai a context *) elim premiss; clear premiss. (* Goal: forall (ni1 : nested_imps) (_ : le_ni ni1 ni) (_ : deco_sound (@app normal_form bs work) ds ni1 ai' a') (_ : nsearch_spec_result_aux goal (@app normal_form bs work) ds ni1 ai' a' context), nsearch_spec_result goal (@cons normal_form (NAtom i) work) ds ni ai a context *) (* Goal: deco_sound (@app normal_form bs work) ds ni ai' a' *) (* Goal: nsound (@app normal_form bs work) ds ni ai' a' context *) (* Goal: nminimal (@app normal_form bs work) ds ni ai' a' context *) intros ni1 less1 complete1 spec1. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply NSearch_Res with ni1; try assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply deco_sound_shift_a_work with a'; try assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply deco_sound_shift_work_ai_weak with i bs ai'; assumption. (* Goal: nsearch_spec_result_aux goal (@cons normal_form (NAtom i) work) ds ni1 ai a context *) (* Goal: deco_sound (@app normal_form bs work) ds ni ai' a' *) (* Goal: nsound (@app normal_form bs work) ds ni ai' a' context *) (* Goal: nminimal (@app normal_form bs work) ds ni ai' a' context *) elim spec1; clear spec1. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) intros derivable_goal; apply NDerivable; assumption. (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom a1), False), nsearch_spec_result goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) intros k k_is_mon k_forces_ngamma k_nonforces_goal. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply NRefutable with k; try assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply forces_ngamma_shift_a_work with a'; try assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply forces_ngamma_shift_work_ai_weak with i bs ai'; assumption. (* side premisses: Elim premiss. *) (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply deco_sound_shift_work_ai_strength with i ai a; try assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply deco_sound_shift_work_a with i a; assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply nsound_shift_work_ai_strength with i ai a; try assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply nsound_shift_work_a with i a; assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply nminimal_shift_work_ai_weak with i ai; try assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply nminimal_shift_work_a with i a; assumption. Qed. (****************************************************************) Lemma left_disj : forall (goal : Int) (work : nf_list) (i j : Int) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist), (forall ni1 : nested_imps, le_ni ni ni1 -> nsearch_spec goal (NAtom i :: work) ds ni1 ai a (Atom i :: context)) -> (forall ni2 : nested_imps, eqv_ni ni2 ni -> nsearch_spec goal (NAtom j :: work) ds ni2 ai a (Atom j :: context)) -> nsearch_spec goal work ((i, j) :: ds) ni ai a context. (* Goal: forall (goal : Int) (work : nf_list) (i j : Int) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist) (_ : forall (ni1 : nested_imps) (_ : le_ni ni ni1), nsearch_spec goal (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context)) (_ : forall (ni2 : nested_imps) (_ : eqv_ni ni2 ni), nsearch_spec goal (@cons normal_form (NAtom j) work) ds ni2 ai a (@cons form (Atom j) context)), nsearch_spec goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) intros goal work i j ds ni ai a context left_premiss right_premiss. (* Goal: nsearch_spec goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) unfold nsearch_spec in |- *; intros complete sound mon. (* Goal: nsearch_spec_result goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) elim (filter_deco i ni). (* Goal: forall (ni1 : nested_imps) (_ : le_ni ni ni1) (_ : forall (x : nimp) (k : kripke_tree) (_ : @In nested_imp (Decorated x k) ni1), forces_t k (Atom i)), nsearch_spec_result goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) intros ni1 le1 forces_i. (* Goal: nsearch_spec_result goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) elim (left_premiss ni1 le1); clear left_premiss. (* Goal: forall (ni2 : nested_imps) (_ : le_ni ni2 ni1) (_ : deco_sound (@cons normal_form (NAtom i) work) ds ni2 ai a) (_ : nsearch_spec_result_aux goal (@cons normal_form (NAtom i) work) ds ni2 ai a (@cons form (Atom i) context)), nsearch_spec_result goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) (* Goal: nminimal (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) clear forces_i. (* Goal: forall (ni2 : nested_imps) (_ : le_ni ni2 ni1) (_ : deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni2 ai a) (_ : nsearch_spec_result_aux a1 (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni2 ai a (@cons form (Atom a0) context)), nsearch_spec_result goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) intros ni2 le2 complete2 spec2. (* Goal: nsearch_spec_result goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) (* Goal: nminimal (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) elim (inf_deco ni ni2). (* Goal: forall (ni0 : nested_imps) (_ : le_ni ni0 ni) (_ : eqv_ni ni0 ni2) (_ : forall (x : nimp) (k : kripke_tree) (_ : @In nested_imp (Decorated x k) ni0), or (@In nested_imp (Decorated x k) ni) (@In nested_imp (Decorated x k) ni2)), nsearch_spec_result goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) (* Goal: eqv_ni ni ni2 *) (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) (* Goal: nminimal (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) intros ni3 le30 le32 inf3. (* Goal: nsearch_spec_result goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) elim spec2; clear spec2. (* left_premiss yields a derivation *) (* Goal: forall _ : Derivable (@cons form (Atom i) context) (Atom goal), nsearch_spec_result goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (NAtom i) work) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom goal), False), nsearch_spec_result goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) (* Goal: eqv_ni ni ni2 *) (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) (* Goal: nminimal (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) intros der2. (* Goal: nsearch_spec_result goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (NAtom i) work) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom goal), False), nsearch_spec_result goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) (* Goal: eqv_ni ni ni2 *) (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) (* Goal: nminimal (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) elim (filter_deco j ni3). (* Goal: forall (ni1 : nested_imps) (_ : le_ni ni3 ni1) (_ : forall (x : nimp) (k : kripke_tree) (_ : @In nested_imp (Decorated x k) ni1), forces_t k (Atom j)), nsearch_spec_result goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (NAtom i) work) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom goal), False), nsearch_spec_result goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) (* Goal: eqv_ni ni ni2 *) (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) (* Goal: nminimal (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) intros ni4 le4 forces_j. (* Goal: nsearch_spec_result goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (NAtom i) work) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom goal), False), nsearch_spec_result goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) (* Goal: eqv_ni ni ni2 *) (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) (* Goal: nminimal (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) elim (right_premiss ni4); clear right_premiss. (* Goal: forall (ni1 : nested_imps) (_ : le_ni ni1 ni4) (_ : deco_sound (@cons normal_form (NAtom j) work) ds ni1 ai a) (_ : nsearch_spec_result_aux goal (@cons normal_form (NAtom j) work) ds ni1 ai a (@cons form (Atom j) context)), nsearch_spec_result goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) (* Goal: eqv_ni ni4 ni *) (* Goal: deco_sound (@cons normal_form (NAtom j) work) ds ni4 ai a *) (* Goal: nsound (@cons normal_form (NAtom j) work) ds ni4 ai a (@cons form (Atom j) context) *) (* Goal: nminimal (@cons normal_form (NAtom j) work) ds ni4 ai a (@cons form (Atom j) context) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (NAtom i) work) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom goal), False), nsearch_spec_result goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) (* Goal: eqv_ni ni ni2 *) (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) (* Goal: nminimal (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) clear forces_j inf3. (* Goal: forall (ni1 : nested_imps) (_ : le_ni ni1 (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32))) (_ : deco_sound work ds ni1 ai a) (_ : nsearch_spec_result_aux goal work ds ni1 ai a context), nsearch_spec_result goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) (* Goal: le_ni (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) (rev_app (@cons (prod nimp kripke_tree) (@pair nimp kripke_tree (NImp a0 a1 b) k) dni) ni) *) (* Goal: deco_sound work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a *) (* Goal: nsound work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a context *) (* Goal: nminimal work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a context *) (* Goal: le_ni ni3 (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) intros ni5 le5 complete5 spec5. (* Goal: nsearch_spec_result goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) (* Goal: eqv_ni ni4 ni *) (* Goal: deco_sound (@cons normal_form (NAtom j) work) ds ni4 ai a *) (* Goal: nsound (@cons normal_form (NAtom j) work) ds ni4 ai a (@cons form (Atom j) context) *) (* Goal: nminimal (@cons normal_form (NAtom j) work) ds ni4 ai a (@cons form (Atom j) context) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (NAtom i) work) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom goal), False), nsearch_spec_result goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) (* Goal: eqv_ni ni ni2 *) (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) (* Goal: nminimal (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) elim (inf_deco ni ni5). (* Goal: forall (ni0 : nested_imps) (_ : le_ni ni0 ni) (_ : eqv_ni ni0 ni5) (_ : forall (x : nimp) (k : kripke_tree) (_ : @In nested_imp (Decorated x k) ni0), or (@In nested_imp (Decorated x k) ni) (@In nested_imp (Decorated x k) ni5)), nsearch_spec_result goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) (* Goal: eqv_ni ni ni5 *) (* Goal: eqv_ni ni4 ni *) (* Goal: deco_sound (@cons normal_form (NAtom j) work) ds ni4 ai a *) (* Goal: nsound (@cons normal_form (NAtom j) work) ds ni4 ai a (@cons form (Atom j) context) *) (* Goal: nminimal (@cons normal_form (NAtom j) work) ds ni4 ai a (@cons form (Atom j) context) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (NAtom i) work) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom goal), False), nsearch_spec_result goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) (* Goal: eqv_ni ni ni2 *) (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) (* Goal: nminimal (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) intros ni6 le60 le65 inf6. (* Goal: nsearch_spec_result goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) (* Goal: eqv_ni ni ni5 *) (* Goal: eqv_ni ni4 ni *) (* Goal: deco_sound (@cons normal_form (NAtom j) work) ds ni4 ai a *) (* Goal: nsound (@cons normal_form (NAtom j) work) ds ni4 ai a (@cons form (Atom j) context) *) (* Goal: nminimal (@cons normal_form (NAtom j) work) ds ni4 ai a (@cons form (Atom j) context) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (NAtom i) work) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom goal), False), nsearch_spec_result goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) (* Goal: eqv_ni ni ni2 *) (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) (* Goal: nminimal (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) apply NSearch_Res with ni6. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply deco_sound_inf with ni ni5; try assumption. (* Goal: deco_sound work (@cons (prod Int Int) (@pair Int Int i j) ds) ni2 ai a *) (* Goal: nsearch_spec_result_aux goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni3 ai a context *) (* Goal: eqv_ni ni ni2 *) (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) (* Goal: nminimal (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) apply deco_sound_shift_work_ds. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply deco_sound_cons_work_weak with (NAtom j); try assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) intros; right; assumption. (* Goal: nsearch_spec_result_aux goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni6 ai a context *) (* Goal: eqv_ni ni ni5 *) (* Goal: eqv_ni ni4 ni *) (* Goal: deco_sound (@cons normal_form (NAtom j) work) ds ni4 ai a *) (* Goal: nsound (@cons normal_form (NAtom j) work) ds ni4 ai a (@cons form (Atom j) context) *) (* Goal: nminimal (@cons normal_form (NAtom j) work) ds ni4 ai a (@cons form (Atom j) context) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (NAtom i) work) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom goal), False), nsearch_spec_result goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) (* Goal: eqv_ni ni ni2 *) (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) (* Goal: nminimal (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) clear inf6. (* Goal: nsearch_spec_result_aux goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni6 ai a context *) (* Goal: eqv_ni ni ni5 *) (* Goal: eqv_ni ni4 ni *) (* Goal: deco_sound (@cons normal_form (NAtom j) work) ds ni4 ai a *) (* Goal: nsound (@cons normal_form (NAtom j) work) ds ni4 ai a (@cons form (Atom j) context) *) (* Goal: nminimal (@cons normal_form (NAtom j) work) ds ni4 ai a (@cons form (Atom j) context) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (NAtom i) work) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom goal), False), nsearch_spec_result goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) (* Goal: eqv_ni ni ni2 *) (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) (* Goal: nminimal (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) elim spec5; clear spec5. (* Goal: forall _ : Derivable (@cons form (Atom j) context) (Atom goal), nsearch_spec_result_aux goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni6 ai a context *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (NAtom j) work) ds ni5 ai a k) (_ : forall _ : forces_t k (Atom goal), False), nsearch_spec_result_aux goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni6 ai a context *) (* Goal: eqv_ni ni ni5 *) (* Goal: eqv_ni ni4 ni *) (* Goal: deco_sound (@cons normal_form (NAtom j) work) ds ni4 ai a *) (* Goal: nsound (@cons normal_form (NAtom j) work) ds ni4 ai a (@cons form (Atom j) context) *) (* Goal: nminimal (@cons normal_form (NAtom j) work) ds ni4 ai a (@cons form (Atom j) context) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (NAtom i) work) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom goal), False), nsearch_spec_result goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) (* Goal: eqv_ni ni ni2 *) (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) (* Goal: nminimal (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) clear complete complete2 complete5 mon le65 le60 le5 le4 le30 le32 le2 le1. (* Goal: forall _ : Derivable (@cons form (Atom j) context) (Atom goal), nsearch_spec_result_aux goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni6 ai a context *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (NAtom j) work) ds ni5 ai a k) (_ : forall _ : forces_t k (Atom goal), False), nsearch_spec_result_aux goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni6 ai a context *) (* Goal: eqv_ni ni ni5 *) (* Goal: eqv_ni ni4 ni *) (* Goal: deco_sound (@cons normal_form (NAtom j) work) ds ni4 ai a *) (* Goal: nsound (@cons normal_form (NAtom j) work) ds ni4 ai a (@cons form (Atom j) context) *) (* Goal: nminimal (@cons normal_form (NAtom j) work) ds ni4 ai a (@cons form (Atom j) context) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (NAtom i) work) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom goal), False), nsearch_spec_result goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) (* Goal: eqv_ni ni ni2 *) (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) (* Goal: nminimal (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) intros der5. (* Goal: nsearch_spec_result_aux goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni6 ai a context *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (NAtom j) work) ds ni5 ai a k) (_ : forall _ : forces_t k (Atom goal), False), nsearch_spec_result_aux goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni6 ai a context *) (* Goal: eqv_ni ni ni5 *) (* Goal: eqv_ni ni4 ni *) (* Goal: deco_sound (@cons normal_form (NAtom j) work) ds ni4 ai a *) (* Goal: nsound (@cons normal_form (NAtom j) work) ds ni4 ai a (@cons form (Atom j) context) *) (* Goal: nminimal (@cons normal_form (NAtom j) work) ds ni4 ai a (@cons form (Atom j) context) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (NAtom i) work) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom goal), False), nsearch_spec_result goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) (* Goal: eqv_ni ni ni2 *) (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) (* Goal: nminimal (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) apply NDerivable. (* Goal: Derivable context (Atom goal) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (NAtom j) work) ds ni5 ai a k) (_ : forall _ : forces_t k (Atom goal), False), nsearch_spec_result_aux goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni6 ai a context *) (* Goal: eqv_ni ni ni5 *) (* Goal: eqv_ni ni4 ni *) (* Goal: deco_sound (@cons normal_form (NAtom j) work) ds ni4 ai a *) (* Goal: nsound (@cons normal_form (NAtom j) work) ds ni4 ai a (@cons form (Atom j) context) *) (* Goal: nminimal (@cons normal_form (NAtom j) work) ds ni4 ai a (@cons form (Atom j) context) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (NAtom i) work) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom goal), False), nsearch_spec_result goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) (* Goal: eqv_ni ni ni2 *) (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) (* Goal: nminimal (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) elim der2; clear der2; intros s der_s. (* Goal: forall (t : proof_term) (_ : derives context t (nf2form NFalsum)), Derivable context (Atom goal) *) (* Goal: in_ngamma (@cons normal_form NFalsum work) ds ni ai a NFalsum *) elim der5; clear der5; intros t der_t. (* Goal: Derivable context (Atom goal) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (NAtom j) work) ds ni5 ai a k) (_ : forall _ : forces_t k (Atom goal), False), nsearch_spec_result_aux goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni6 ai a context *) (* Goal: eqv_ni ni ni5 *) (* Goal: eqv_ni ni4 ni *) (* Goal: deco_sound (@cons normal_form (NAtom j) work) ds ni4 ai a *) (* Goal: nsound (@cons normal_form (NAtom j) work) ds ni4 ai a (@cons form (Atom j) context) *) (* Goal: nminimal (@cons normal_form (NAtom j) work) ds ni4 ai a (@cons form (Atom j) context) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (NAtom i) work) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom goal), False), nsearch_spec_result goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) (* Goal: eqv_ni ni ni2 *) (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) (* Goal: nminimal (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) elim (sound (NDisj i j)); clear sound. (* Goal: forall (t : proof_term) (_ : derives context t (nf2form (NDisj i j))), Derivable context (Atom goal) *) (* Goal: in_ngamma work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a (NDisj i j) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (NAtom j) work) ds ni5 ai a k) (_ : forall _ : forces_t k (Atom goal), False), nsearch_spec_result_aux goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni6 ai a context *) (* Goal: eqv_ni ni ni5 *) (* Goal: eqv_ni ni4 ni *) (* Goal: deco_sound (@cons normal_form (NAtom j) work) ds ni4 ai a *) (* Goal: nsound (@cons normal_form (NAtom j) work) ds ni4 ai a (@cons form (Atom j) context) *) (* Goal: nminimal (@cons normal_form (NAtom j) work) ds ni4 ai a (@cons form (Atom j) context) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (NAtom i) work) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom goal), False), nsearch_spec_result goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) (* Goal: eqv_ni ni ni2 *) (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) (* Goal: nminimal (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) intros r der_r. (* Goal: Derivable context (Atom goal) *) (* Goal: in_ngamma work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a (NDisj i j) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (NAtom j) work) ds ni5 ai a k) (_ : forall _ : forces_t k (Atom goal), False), nsearch_spec_result_aux goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni6 ai a context *) (* Goal: eqv_ni ni ni5 *) (* Goal: eqv_ni ni4 ni *) (* Goal: deco_sound (@cons normal_form (NAtom j) work) ds ni4 ai a *) (* Goal: nsound (@cons normal_form (NAtom j) work) ds ni4 ai a (@cons form (Atom j) context) *) (* Goal: nminimal (@cons normal_form (NAtom j) work) ds ni4 ai a (@cons form (Atom j) context) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (NAtom i) work) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom goal), False), nsearch_spec_result goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) (* Goal: eqv_ni ni ni2 *) (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) (* Goal: nminimal (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) apply Derivable_Intro with (Cas (Atom i) (Atom j) r s t). (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply OrFElim; assumption. (* Goal: in_ngamma work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a (NDisj i j) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (NAtom j) work) ds ni5 ai a k) (_ : forall _ : forces_t k (Atom goal), False), nsearch_spec_result_aux goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni6 ai a context *) (* Goal: eqv_ni ni ni5 *) (* Goal: eqv_ni ni4 ni *) (* Goal: deco_sound (@cons normal_form (NAtom j) work) ds ni4 ai a *) (* Goal: nsound (@cons normal_form (NAtom j) work) ds ni4 ai a (@cons form (Atom j) context) *) (* Goal: nminimal (@cons normal_form (NAtom j) work) ds ni4 ai a (@cons form (Atom j) context) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (NAtom i) work) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom goal), False), nsearch_spec_result goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) (* Goal: eqv_ni ni ni2 *) (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) (* Goal: nminimal (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) apply In_Disjs with 0; apply My_NthO. (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (NAtom j) work) ds ni5 ai a k) (_ : forall _ : forces_t k (Atom goal), False), nsearch_spec_result_aux goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni6 ai a context *) (* Goal: eqv_ni ni ni5 *) (* Goal: eqv_ni ni4 ni *) (* Goal: deco_sound (@cons normal_form (NAtom j) work) ds ni4 ai a *) (* Goal: nsound (@cons normal_form (NAtom j) work) ds ni4 ai a (@cons form (Atom j) context) *) (* Goal: nminimal (@cons normal_form (NAtom j) work) ds ni4 ai a (@cons form (Atom j) context) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (NAtom i) work) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom goal), False), nsearch_spec_result goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) (* Goal: eqv_ni ni ni2 *) (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) (* Goal: nminimal (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) clear der2 mon sound. (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (NAtom i) work) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom goal), False), nsearch_spec_result goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) (* Goal: eqv_ni ni ni2 *) (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) (* Goal: nminimal (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) intros k k_is_mon k_forces_ngamma k_notforces_goal. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply NRefutable with k; try assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply forces_ngamma_eqv with ni5; try assumption. (* Goal: forces_ngamma work (@cons (prod Int Int) (@pair Int Int i j) ds) ni2 ai a k *) (* Goal: forall _ : forces_t k (Atom goal), False *) (* Goal: eqv_ni ni ni2 *) (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) (* Goal: nminimal (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) apply forces_ngamma_shift_work_ds. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply forces_ngamma_cons_work_weak with (NAtom j); try assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) intros; right; assumption. (* Goal: eqv_ni ni ni5 *) (* Goal: eqv_ni ni4 ni *) (* Goal: deco_sound (@cons normal_form (NAtom j) work) ds ni4 ai a *) (* Goal: nsound (@cons normal_form (NAtom j) work) ds ni4 ai a (@cons form (Atom j) context) *) (* Goal: nminimal (@cons normal_form (NAtom j) work) ds ni4 ai a (@cons form (Atom j) context) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (NAtom i) work) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom goal), False), nsearch_spec_result goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) (* Goal: eqv_ni ni ni2 *) (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) (* Goal: nminimal (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) apply eqv_ni_trans with ni4. (* Goal: eqv_ni ni ni4 *) (* Goal: nminimal (@cons normal_form (NAtom j) work) ds ni ai a (@cons form (Atom j) context) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (NAtom i) work) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom goal), False), nsearch_spec_result goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) (* Goal: eqv_ni ni ni2 *) (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) (* Goal: nminimal (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) apply eqv_ni_trans with ni3. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply ge_eqv; assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply le_eqv; assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply ge_eqv; assumption. (* Goal: eqv_ni ni ni4 *) (* Goal: nminimal (@cons normal_form (NAtom j) work) ds ni ai a (@cons form (Atom j) context) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (NAtom i) work) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom goal), False), nsearch_spec_result goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) (* Goal: eqv_ni ni ni2 *) (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) (* Goal: nminimal (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) apply eqv_ni_trans with ni3. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply ge_eqv; assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply le_eqv; assumption. (* side premisses: Elim right_premiss. *) (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply deco_sound_filter_deco; try assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply deco_sound_le with ni3; try assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply deco_sound_inf with ni ni2; try assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply deco_sound_cons_ds_tail with i j; assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply deco_sound_cons_work_tail with (NAtom i); assumption. (* Goal: nsound (@cons normal_form (NAtom j) work) ds ni4 ai a (@cons form (Atom j) context) *) (* Goal: nminimal (@cons normal_form (NAtom j) work) ds ni4 ai a (@cons form (Atom j) context) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (NAtom i) work) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom goal), False), nsearch_spec_result goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) (* Goal: eqv_ni ni ni2 *) (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) (* Goal: nminimal (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) clear forces_j complete2 complete inf3 mon. (* Goal: nsound (@cons normal_form (NAtom j) work) ds ni4 ai a (@cons form (Atom j) context) *) (* Goal: nminimal (@cons normal_form (NAtom j) work) ds ni4 ai a (@cons form (Atom j) context) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (NAtom i) work) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom goal), False), nsearch_spec_result goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) (* Goal: eqv_ni ni ni2 *) (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) (* Goal: nminimal (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) apply nsound_eqv with ni. (* Goal: eqv_ni ni ni4 *) (* Goal: nminimal (@cons normal_form (NAtom j) work) ds ni ai a (@cons form (Atom j) context) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (NAtom i) work) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom goal), False), nsearch_spec_result goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) (* Goal: eqv_ni ni ni2 *) (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) (* Goal: nminimal (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) apply eqv_ni_trans with ni3. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply ge_eqv; assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply le_eqv; assumption. (* Goal: nsound (@cons normal_form (NAtom j) work) ds ni ai a (@cons form (Atom j) context) *) (* Goal: nminimal (@cons normal_form (NAtom j) work) ds ni4 ai a (@cons form (Atom j) context) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (NAtom i) work) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom goal), False), nsearch_spec_result goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) (* Goal: eqv_ni ni ni2 *) (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) (* Goal: nminimal (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) apply nsound_cons_work_cons_context with (c := NAtom j). (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply nsound_cons_ds_tail with i j; assumption. (* Goal: nminimal (@cons normal_form (NAtom j) work) ds ni4 ai a (@cons form (Atom j) context) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (NAtom i) work) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom goal), False), nsearch_spec_result goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) (* Goal: eqv_ni ni ni2 *) (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) (* Goal: nminimal (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) clear forces_j complete2 complete inf3 sound. (* Goal: nminimal (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) apply nminimal_eqv with ni. (* Goal: eqv_ni ni ni4 *) (* Goal: nminimal (@cons normal_form (NAtom j) work) ds ni ai a (@cons form (Atom j) context) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (NAtom i) work) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom goal), False), nsearch_spec_result goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) (* Goal: eqv_ni ni ni2 *) (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) (* Goal: nminimal (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) apply eqv_ni_trans with ni3. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply ge_eqv; assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply le_eqv; assumption. apply nminimal_shift_ds_work_context with (c := NAtom j) (i := i) (j := j); (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) try assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) intros; right; assumption. (* left_premiss yields a counter--model *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom a1), False), nsearch_spec_result goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) clear right_premiss. (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (NAtom i) work) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom goal), False), nsearch_spec_result goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) (* Goal: eqv_ni ni ni2 *) (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) (* Goal: nminimal (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) intros k k_is_mon k_forces_ngamma k_notforces_goal. (* Goal: nsearch_spec_result goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) (* Goal: eqv_ni ni ni2 *) (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) (* Goal: nminimal (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) apply NSearch_Res with ni3. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) assumption. (* Goal: deco_sound work (@cons (prod Int Int) (@pair Int Int i j) ds) ni3 ai a *) (* Goal: nsearch_spec_result_aux goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni3 ai a context *) (* Goal: eqv_ni ni ni2 *) (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) (* Goal: nminimal (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) clear sound mon. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply deco_sound_inf with ni ni2; try assumption. (* Goal: deco_sound work (@cons (prod Int Int) (@pair Int Int i j) ds) ni2 ai a *) (* Goal: nsearch_spec_result_aux goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni3 ai a context *) (* Goal: eqv_ni ni ni2 *) (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) (* Goal: nminimal (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) apply deco_sound_shift_work_ds. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply deco_sound_cons_work_weak with (NAtom i); try assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) intros; left; assumption. (* Goal: nsearch_spec_result_aux goal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni3 ai a context *) (* Goal: eqv_ni ni ni2 *) (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) (* Goal: nminimal (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) apply NRefutable with k. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply forces_ngamma_eqv with ni2; try assumption. (* Goal: forces_ngamma work (@cons (prod Int Int) (@pair Int Int i j) ds) ni2 ai a k *) (* Goal: forall _ : forces_t k (Atom goal), False *) (* Goal: eqv_ni ni ni2 *) (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) (* Goal: nminimal (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) apply forces_ngamma_shift_work_ds. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply forces_ngamma_cons_work_weak with (NAtom i); try assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) intros; left; assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) assumption. (* side premiss: Elim inf???? *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom a1), False), nsearch_spec_result goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) clear right_premiss. (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply eqv_ni_trans with ni1. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply le_eqv; assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply ge_eqv; assumption. (* side premisses: Elim left_premiss. *) (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) (* Goal: nminimal (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) apply deco_sound_filter_deco. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) assumption. (* Goal: deco_sound work ds ni1 ai a *) (* Goal: nsound (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) (* Goal: nminimal (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) apply deco_sound_le with ni. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply deco_sound_cons_ds_tail with i j; assumption. (* Goal: nsound (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) (* Goal: nminimal (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) apply nsound_le with ni. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) assumption. (* Goal: nsound (@cons normal_form (NAtom i) work) ds ni ai a (@cons form (Atom i) context) *) (* Goal: nminimal (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) apply nsound_cons_work_cons_context with (c := NAtom i). (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply nsound_cons_ds_tail with i j; assumption. (* Goal: nminimal (@cons normal_form (NAtom i) work) ds ni1 ai a (@cons form (Atom i) context) *) apply nminimal_eqv with ni. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply le_eqv; assumption. (* Goal: nminimal (@cons normal_form (NAtom i) work) ds ni ai a (@cons form (Atom i) context) *) apply nminimal_shift_ds_work_context with (c := NAtom i) (i := i) (j := j). (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) intros; left; assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) assumption. Qed. (**********************************************************************) Lemma left_nimp : forall (goal : Int) (work : nf_list) (ds : disjs) (a0 a1 : Int) (b : normal_form) (ni : nested_imps) (dni : decorated_nested_imps) (ai : atomic_imps) (a : atoms) (context : flist), (forall ni1 : nested_imps, le_ni (rev_app dni ni) ni1 -> nsearch_spec a1 (AImp a1 b :: NAtom a0 :: work) ds ni1 ai a (Atom a0 :: context)) -> (forall ni1 : nested_imps, le_ni ni1 (rev_app dni ni) -> nsearch_spec goal (b :: work) ds ni1 ai a context) -> (forall (ni1 : nested_imps) (k : kripke_tree), le_ni ni1 (rev_app ((NImp a0 a1 b, k) :: dni) ni) -> nsearch_spec goal work ds ni1 ai a context) -> nsearch_spec goal work ds (rev_app dni (Undecorated (NImp a0 a1 b) :: ni)) ai a context. intros goal work ds a0 a1 b ni dni ai a context left_premiss right_premiss fail0. (* Goal: nsearch_spec goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) apply rev_app_lemma2 with dni ni. (* Goal: forall (dni_ni : nested_imps) (_ : @eq nested_imps dni_ni (rev_app dni ni)), nsearch_spec goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) intros dni_ni dni_ni_eq. (* Goal: nsearch_spec goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) unfold nsearch_spec in |- *. (* Goal: forall (_ : deco_sound work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a) (_ : nsound work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context) (_ : nminimal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context), nsearch_spec_result goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) intros complete sound mon. (* Goal: nsearch_spec_result goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) elim (filter_deco a0 dni_ni). (* Goal: forall (ni1 : nested_imps) (_ : le_ni dni_ni ni1) (_ : forall (x : nimp) (k : kripke_tree) (_ : @In nested_imp (Decorated x k) ni1), forces_t k (Atom a0)), nsearch_spec_result goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) intros ni1 le1 forces_a0. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) elim (left_premiss ni1); clear left_premiss; try assumption. (* Goal: forall (ni2 : nested_imps) (_ : le_ni ni2 ni1) (_ : deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni2 ai a) (_ : nsearch_spec_result_aux a1 (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni2 ai a (@cons form (Atom a0) context)), nsearch_spec_result goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) intros ni2 le2 complete2 spec2. (* Goal: nsearch_spec_result goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) elim (inf_deco dni_ni ni2). (* Goal: forall (ni0 : nested_imps) (_ : le_ni ni0 dni_ni) (_ : eqv_ni ni0 ni2) (_ : forall (x : nimp) (k : kripke_tree) (_ : @In nested_imp (Decorated x k) ni0), or (@In nested_imp (Decorated x k) dni_ni) (@In nested_imp (Decorated x k) ni2)), nsearch_spec_result goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) intros ni3 le3 eqv3 inf3. (* Goal: nsearch_spec_result goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) elim spec2; clear spec2. (* left_premiss yields a derivation *) (* Goal: forall _ : Derivable (@cons form (Atom a0) context) (Atom a1), nsearch_spec_result goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom a1), False), nsearch_spec_result goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) intros derivable_a0a1; clear fail0. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) elim right_premiss with ni3; clear right_premiss; try assumption. (* Goal: forall (ni1 : nested_imps) (_ : le_ni ni1 ni3) (_ : deco_sound (@cons normal_form b work) ds ni1 ai a) (_ : nsearch_spec_result_aux goal (@cons normal_form b work) ds ni1 ai a context), nsearch_spec_result goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) (* Goal: le_ni ni3 (rev_app dni ni) *) (* Goal: deco_sound (@cons normal_form b work) ds ni3 ai a *) (* Goal: nsound (@cons normal_form b work) ds ni3 ai a context *) (* Goal: nminimal (@cons normal_form b work) ds ni3 ai a context *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom a1), False), nsearch_spec_result goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) intros ni4 le4 complete4 spec4. (* Goal: nsearch_spec_result goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) (* Goal: le_ni ni3 (rev_app dni ni) *) (* Goal: deco_sound (@cons normal_form b work) ds ni3 ai a *) (* Goal: nsound (@cons normal_form b work) ds ni3 ai a context *) (* Goal: nminimal (@cons normal_form b work) ds ni3 ai a context *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom a1), False), nsearch_spec_result goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) elim (le_app0 ni4 (rev_app dni NNil) ni). (* Goal: forall (ni11 ni12 : nested_imps) (_ : @eq nested_imps ni4 (@app nested_imp ni11 ni12)) (_ : @eq nat (@length nested_imp ni11) (@length nested_imp (rev_app dni NNil))), nsearch_spec_result goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) (* Goal: le_ni ni4 (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: le_ni ni3 (rev_app dni ni) *) (* Goal: deco_sound (@cons normal_form b work) ds ni3 ai a *) (* Goal: nsound (@cons normal_form b work) ds ni3 ai a context *) (* Goal: nminimal (@cons normal_form b work) ds ni3 ai a context *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom a1), False), nsearch_spec_result goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) intros ni41 ni42 eq_ni4 len. (* Goal: nsearch_spec_result goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) (* Goal: le_ni ni4 (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: le_ni ni3 (rev_app dni ni) *) (* Goal: deco_sound (@cons normal_form b work) ds ni3 ai a *) (* Goal: nsound (@cons normal_form b work) ds ni3 ai a context *) (* Goal: nminimal (@cons normal_form b work) ds ni3 ai a context *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom a1), False), nsearch_spec_result goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply NSearch_Res with (ni41 ++ Undecorated (NImp a0 a1 b) :: ni42). (* Goal: eqv_ni (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) *) (* Goal: forall (i : Int) (b0 : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b0), in_ngamma work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a (AImp i b0) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a (NAtom i) *) (* Goal: nminimal work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a context *) (* Goal: le_ni ni3 (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) rewrite (rev_app_app dni (Undecorated (NImp a0 a1 b) :: ni)). (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply le_ni_app_nn; try assumption. (* Goal: forces_ngamma (@cons normal_form (NImp_NF (nested_imp2nimp (Undecorated (NImp a0 a1 b)))) work) ds (@app nested_imp ni41 ni42) ai a k *) (* Goal: le_ni ni4 (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: le_ni ni3 (rev_app dni ni) *) (* Goal: deco_sound (@cons normal_form b work) ds ni3 ai a *) (* Goal: nsound (@cons normal_form b work) ds ni3 ai a context *) (* Goal: nminimal (@cons normal_form b work) ds ni3 ai a context *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom a1), False), nsearch_spec_result goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) rewrite <- eq_ni4. (* Goal: le_ni ni3 (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) rewrite <- (rev_app_app dni ni). (* Goal: le_ni ni3 (rev_app dni ni) *) (* Goal: forall (i : Int) (b0 : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b0), in_ngamma work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a (AImp i b0) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a (NAtom i) *) (* Goal: nminimal work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a context *) (* Goal: le_ni ni3 (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) rewrite <- dni_ni_eq. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply le_ni_trans with ni3; assumption. (* Goal: deco_sound work ds (@app nested_imp ni41 (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni42)) ai a *) (* Goal: nsearch_spec_result_aux goal work ds (@app nested_imp ni41 (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni42)) ai a context *) (* Goal: le_ni ni4 (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: le_ni ni3 (rev_app dni ni) *) (* Goal: deco_sound (@cons normal_form b work) ds ni3 ai a *) (* Goal: nsound (@cons normal_form b work) ds ni3 ai a context *) (* Goal: nminimal (@cons normal_form b work) ds ni3 ai a context *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom a1), False), nsearch_spec_result goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply deco_sound_shift_work_ninni. (* Goal: forces_ngamma (@cons normal_form (NImp_NF (nested_imp2nimp (Undecorated (NImp a0 a1 b)))) work) ds (@app nested_imp ni41 ni42) ai a k *) (* Goal: le_ni ni4 (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: le_ni ni3 (rev_app dni ni) *) (* Goal: deco_sound (@cons normal_form b work) ds ni3 ai a *) (* Goal: nsound (@cons normal_form b work) ds ni3 ai a context *) (* Goal: nminimal (@cons normal_form b work) ds ni3 ai a context *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom a1), False), nsearch_spec_result goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) rewrite <- eq_ni4. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply deco_sound_cons_work_weak with b; try assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) intros; simpl in |- *; apply forces_b__forces_a_imp_b_t; assumption. (* Goal: nsearch_spec_result_aux goal work ds (@app nested_imp ni41 (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni42)) ai a context *) (* Goal: le_ni ni4 (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: le_ni ni3 (rev_app dni ni) *) (* Goal: deco_sound (@cons normal_form b work) ds ni3 ai a *) (* Goal: nsound (@cons normal_form b work) ds ni3 ai a context *) (* Goal: nminimal (@cons normal_form b work) ds ni3 ai a context *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom a1), False), nsearch_spec_result goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) elim spec4; clear spec4. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) intros der_goal; apply NDerivable; assumption. (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom a1), False), nsearch_spec_result goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) intros k k_is_mon k_forces_ngamma k_nonforces_goal. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply NRefutable with k; try assumption. (* Goal: forces_ngamma work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a k *) (* Goal: forall _ : forces_t k (Imp (Atom a0) (Atom a1)), False *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds (@app nested_imp ni31 ni32) ai a *) (* Goal: nsound work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a context *) (* Goal: nminimal work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a context *) (* Goal: le_ni ni3 (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply forces_ngamma_shift_work_ni_x_ni. (* Goal: forces_ngamma (@cons normal_form (NImp_NF (nested_imp2nimp (Undecorated (NImp a0 a1 b)))) work) ds (@app nested_imp ni41 ni42) ai a k *) (* Goal: le_ni ni4 (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: le_ni ni3 (rev_app dni ni) *) (* Goal: deco_sound (@cons normal_form b work) ds ni3 ai a *) (* Goal: nsound (@cons normal_form b work) ds ni3 ai a context *) (* Goal: nminimal (@cons normal_form b work) ds ni3 ai a context *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom a1), False), nsearch_spec_result goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) rewrite <- eq_ni4. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply forces_ngamma_cons_work_weak with b; try assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) intros; simpl in |- *; apply forces_b__forces_a_imp_b_t; assumption. (* Goal: le_ni ni3 (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) rewrite <- (rev_app_app dni ni). (* Goal: le_ni ni3 (rev_app dni ni) *) (* Goal: forall (i : Int) (b0 : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b0), in_ngamma work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a (AImp i b0) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a (NAtom i) *) (* Goal: nminimal work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a context *) (* Goal: le_ni ni3 (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) rewrite <- dni_ni_eq. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply le_ni_trans with ni3; assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) rewrite <- dni_ni_eq; assumption. (* side premiss: Elim right_premiss with ni3 dni3 *) (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply deco_sound_inf with dni_ni ni2; try assumption. (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply deco_sound_cons_work_strength with (NImp_NF (NImp a0 a1 b)). (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds dni_ni ai a k), forces_t k (nf2form (NImp_NF (NImp a0 a1 b))) *) (* Goal: nminimal (@cons normal_form (NImp_NF (NImp a0 a1 b)) (@cons normal_form (NAtom a0) work)) ds dni_ni ai a (@cons form (Atom a0) context) *) intros k k_is_mon k_forces_ngamma. apply forces_a_a_imp_b__forces_b_t with (Imp (Atom a0) (Atom a1)); (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) try assumption. apply nminimal_derivable_forces with work ds (rev_app dni (Undecorated (NImp a0 a1 b) :: ni)) ai a context; (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) try assumption. (* Goal: eqv_ni (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) *) (* Goal: forall (i : Int) (b0 : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b0), in_ngamma work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a (AImp i b0) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a (NAtom i) *) (* Goal: nminimal work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a context *) (* Goal: le_ni ni3 (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) rewrite (rev_app_app dni (Undecorated (NImp a0 a1 b) :: ni)). (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply forces_ngamma_shift_work_ni_x_ni; try assumption. (* Goal: le_ni ni3 (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) rewrite <- (rev_app_app dni ni). (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) rewrite <- dni_ni_eq; assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply derivable_a_context_b__derivable_a_imp_b; assumption. (* Goal: forces_t k (Imp (Imp (Atom a0) (Atom a1)) (nf2form b)) *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds ni2 ai a *) (* Goal: nsound (@cons normal_form b work) ds ni3 ai a context *) (* Goal: nminimal (@cons normal_form b work) ds ni3 ai a context *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom a1), False), nsearch_spec_result goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply k_forces_ngamma with (c := NImp_NF (NImp a0 a1 b)). (* Goal: in_ngamma (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds dni_ni ai a (AImp a1 b) *) (* Goal: nminimal (@cons normal_form (NImp_NF (NImp a0 a1 b)) (@cons normal_form (NAtom a0) work)) ds dni_ni ai a (@cons form (Atom a0) context) *) apply in_ngamma_cons_work_head. (* Goal: nminimal (@cons normal_form (NImp_NF (NImp a0 a1 b)) (@cons normal_form (NAtom a0) work)) ds dni_ni ai a (@cons form (Atom a0) context) *) rewrite dni_ni_eq. (* Goal: nminimal (@cons normal_form (NImp_NF (NImp a0 a1 b)) (@cons normal_form (NAtom a0) work)) ds (rev_app dni ni) ai a (@cons form (Atom a0) context) *) rewrite (rev_app_app dni ni). apply deco_sound_shift_ni_x_ni_work with (x := Undecorated (NImp a0 a1 b)); (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) try assumption. (* Goal: nminimal work ds (@app nested_imp (rev_app dni NNil) (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom a1), False), nsearch_spec_result goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) rewrite <- (rev_app_app dni (Undecorated (NImp a0 a1 b) :: ni)). (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) assumption. (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply deco_sound_cons_work_strength with (NImp_NF (NImp a0 a1 b)). (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds dni_ni ai a k), forces_t k (nf2form (NImp_NF (NImp a0 a1 b))) *) (* Goal: nminimal (@cons normal_form (NImp_NF (NImp a0 a1 b)) (@cons normal_form (NAtom a0) work)) ds dni_ni ai a (@cons form (Atom a0) context) *) intros k k_is_mon k_forces_ngamma. apply forces_a_a_imp_b__forces_b_t with (Imp (Atom a0) (Atom a1)); (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) try assumption. apply nminimal_derivable_forces with work ds (rev_app dni (Undecorated (NImp a0 a1 b) :: ni)) ai a context; (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) try assumption. (* Goal: eqv_ni (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) *) (* Goal: forall (i : Int) (b0 : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b0), in_ngamma work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a (AImp i b0) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a (NAtom i) *) (* Goal: nminimal work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a context *) (* Goal: le_ni ni3 (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) rewrite (rev_app_app dni (Undecorated (NImp a0 a1 b) :: ni)). (* Goal: forces_ngamma work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a k *) (* Goal: forall _ : forces_t k (Imp (Atom a0) (Atom a1)), False *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds (@app nested_imp ni31 ni32) ai a *) (* Goal: nsound work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a context *) (* Goal: nminimal work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a context *) (* Goal: le_ni ni3 (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply forces_ngamma_shift_work_ni_x_ni. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply forces_ngamma_eqv with ni2; try assumption. (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply eqv_ni_trans with ni1. (* Goal: le_ni ni3 (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) rewrite <- (rev_app_app dni ni). (* Goal: le_ni ni3 (rev_app dni ni) *) (* Goal: forall (i : Int) (b0 : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b0), in_ngamma work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a (AImp i b0) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a (NAtom i) *) (* Goal: nminimal work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a context *) (* Goal: le_ni ni3 (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) rewrite <- dni_ni_eq. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply le_eqv; assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply ge_eqv; assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply derivable_a_context_b__derivable_a_imp_b; assumption. (* Goal: forces_t k (Imp (Imp (Atom a0) (Atom a1)) (nf2form b)) *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds ni2 ai a *) (* Goal: nsound (@cons normal_form b work) ds ni3 ai a context *) (* Goal: nminimal (@cons normal_form b work) ds ni3 ai a context *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom a1), False), nsearch_spec_result goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply k_forces_ngamma with (c := NImp_NF (NImp a0 a1 b)). (* Goal: in_ngamma (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds dni_ni ai a (AImp a1 b) *) (* Goal: nminimal (@cons normal_form (NImp_NF (NImp a0 a1 b)) (@cons normal_form (NAtom a0) work)) ds dni_ni ai a (@cons form (Atom a0) context) *) apply in_ngamma_cons_work_head. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply deco_sound_cons_work_weak2 with (AImp a1 b) (NAtom a0); try assumption. (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (nf2form (AImp a1 b))) (_ : forces_t k (nf2form (NAtom a0))), forces_t k (nf2form (NImp_NF (NImp a0 a1 b))) *) (* Goal: nsound (@cons normal_form b work) ds ni3 ai a context *) (* Goal: nminimal (@cons normal_form b work) ds ni3 ai a context *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom a1), False), nsearch_spec_result goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) intros k k_is_mon forces_a1_b forces_a1. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) simpl in |- *; apply forces_a1_imp_b__forces_a0_imp_a1_imp_b_t; assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply nsound_ge with (rev_app dni ni); try assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) rewrite <- dni_ni_eq; assumption. (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds dni_ni ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply nsound_cons_work_weak with (NImp_NF (NImp a0 a1 b)). (* Goal: forall _ : Derivable (@cons form (Atom a0) context) (nf2form (NImp_NF (NImp a0 a1 b))), Derivable (@cons form (Atom a0) context) (nf2form (AImp a1 b)) *) (* Goal: nsound (@cons normal_form (NImp_NF (NImp a0 a1 b)) (@cons normal_form (NAtom a0) work)) ds dni_ni ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) intros der. (* Goal: Derivable context (nf2form b) *) (* Goal: nsound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds (rev_app dni ni) ai a context *) (* Goal: nminimal (@cons normal_form b work) ds ni3 ai a context *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom a1), False), nsearch_spec_result goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply derivable_a_a_imp_b__derivable_b with (Imp (Atom a0) (Atom a1)). (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply derivable_a_context_b__derivable_a_imp_b; assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) assumption. (* Goal: nminimal (@cons normal_form (NImp_NF (NImp a0 a1 b)) (@cons normal_form (NAtom a0) work)) ds (rev_app dni ni) ai a (@cons form (Atom a0) context) *) rewrite (rev_app_app dni ni). apply nsound_shift_ni_x_ni_work with (x := Undecorated (NImp a0 a1 b)); (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) try assumption. (* Goal: nminimal work ds (@app nested_imp (rev_app dni NNil) (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom a1), False), nsearch_spec_result goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) rewrite <- (rev_app_app dni (Undecorated (NImp a0 a1 b) :: ni)). (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) assumption. (* Goal: nminimal (@cons normal_form b work) ds ni3 ai a context *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom a1), False), nsearch_spec_result goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply nminimal_eqv with (rev_app dni ni). (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply ge_eqv; try assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) rewrite <- dni_ni_eq; assumption. (* Goal: nminimal (@cons normal_form b work) ds (rev_app dni ni) ai a context *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom a1), False), nsearch_spec_result goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply nminimal_cons_work_weak with (NImp_NF (NImp a0 a1 b)). (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) intros; simpl in |- *; apply forces_b__forces_a_imp_b_t; assumption. (* Goal: nminimal (@cons normal_form (NImp_NF (NImp a0 a1 b)) (@cons normal_form (NAtom a0) work)) ds (rev_app dni ni) ai a (@cons form (Atom a0) context) *) rewrite (rev_app_app dni ni). apply nminimal_shift_ni_x_ni_work with (x := Undecorated (NImp a0 a1 b)); (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) try assumption. (* Goal: nminimal work ds (@app nested_imp (rev_app dni NNil) (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom a1), False), nsearch_spec_result goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) rewrite <- (rev_app_app dni (Undecorated (NImp a0 a1 b) :: ni)). (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) assumption. (* left premiss yields a counter-model *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom a1), False), nsearch_spec_result goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) clear right_premiss. (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni2 ai a k) (_ : forall _ : forces_t k (Atom a1), False), nsearch_spec_result goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) intros k k_is_mon k_forces_ngamma k_nonforces_goal. (* Goal: nsearch_spec_result goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) elim (le_app0 ni3 (rev_app dni NNil) ni). (* Goal: forall (ni11 ni12 : nested_imps) (_ : @eq nested_imps ni3 (@app nested_imp ni11 ni12)) (_ : @eq nat (@length nested_imp ni11) (@length nested_imp (rev_app dni NNil))), nsearch_spec_result goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) (* Goal: le_ni ni3 (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) intros ni31 ni32 eq_ni3 len. (* Goal: nsearch_spec_result goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) (* Goal: le_ni ni3 (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) elim (fail0 (ni31 ++ Decorated (NImp a0 a1 b) k :: ni32) k); clear fail0. (* Goal: forall (ni1 : nested_imps) (_ : le_ni ni1 (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32))) (_ : deco_sound work ds ni1 ai a) (_ : nsearch_spec_result_aux goal work ds ni1 ai a context), nsearch_spec_result goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) (* Goal: le_ni (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) (rev_app (@cons (prod nimp kripke_tree) (@pair nimp kripke_tree (NImp a0 a1 b) k) dni) ni) *) (* Goal: deco_sound work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a *) (* Goal: nsound work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a context *) (* Goal: nminimal work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a context *) (* Goal: le_ni ni3 (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) intros ni5 le5 complete5 spec5. (* Goal: nsearch_spec_result goal work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a context *) (* Goal: le_ni (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) (rev_app (@cons (prod nimp kripke_tree) (@pair nimp kripke_tree (NImp a0 a1 b) k) dni) ni) *) (* Goal: deco_sound work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a *) (* Goal: nsound work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a context *) (* Goal: nminimal work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a context *) (* Goal: le_ni ni3 (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply NSearch_Res with ni5. (* Goal: le_ni ni5 (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) *) (* Goal: deco_sound work ds ni5 ai a *) (* Goal: nsearch_spec_result_aux goal work ds ni5 ai a context *) (* Goal: le_ni (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) (rev_app (@cons (prod nimp kripke_tree) (@pair nimp kripke_tree (NImp a0 a1 b) k) dni) ni) *) (* Goal: deco_sound work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a *) (* Goal: nsound work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a context *) (* Goal: nminimal work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a context *) (* Goal: le_ni ni3 (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply le_ni_trans with (ni31 ++ Decorated (NImp a0 a1 b) k :: ni32). (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) assumption. (* Goal: eqv_ni (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) *) (* Goal: forall (i : Int) (b0 : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b0), in_ngamma work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a (AImp i b0) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a (NAtom i) *) (* Goal: nminimal work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a context *) (* Goal: le_ni ni3 (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) rewrite (rev_app_app dni (Undecorated (NImp a0 a1 b) :: ni)). (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply le_ni_app_dn; try assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) rewrite <- eq_ni3; try assumption. (* Goal: le_ni ni3 (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) rewrite <- (rev_app_app dni ni). (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) rewrite <- dni_ni_eq; assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) assumption. (* side premisses: Elim (fail0 ... ) *) (* Goal: le_ni (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) (rev_app (@cons (prod nimp kripke_tree) (@pair nimp kripke_tree (NImp a0 a1 b) k) dni) ni) *) (* Goal: deco_sound work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a *) (* Goal: nsound work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a context *) (* Goal: nminimal work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a context *) (* Goal: le_ni ni3 (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) simpl in |- *. (* Goal: le_ni (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) (rev_app dni (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni)) *) (* Goal: deco_sound work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a *) (* Goal: nsound work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a context *) (* Goal: nminimal work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a context *) (* Goal: le_ni ni3 (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) rewrite (rev_app_app dni (Decorated (NImp a0 a1 b) k :: ni)). (* Goal: le_ni (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) (@app nested_imp (rev_app dni NNil) (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni)) *) (* Goal: deco_sound work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a *) (* Goal: nsound work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a context *) (* Goal: nminimal work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a context *) (* Goal: le_ni ni3 (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply le_ni_app_dd. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) rewrite <- eq_ni3; try assumption. (* Goal: le_ni ni3 (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) rewrite <- (rev_app_app dni ni). (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) rewrite <- dni_ni_eq; assumption. (* Goal: deco_sound work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a *) (* Goal: nsound work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a context *) (* Goal: nminimal work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a context *) (* Goal: le_ni ni3 (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply deco_sound_shift_work_nirni. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply k_deco_sound_intro; try assumption. (* Goal: forces_ngamma work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a k *) (* Goal: forall _ : forces_t k (Imp (Atom a0) (Atom a1)), False *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds (@app nested_imp ni31 ni32) ai a *) (* Goal: nsound work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a context *) (* Goal: nminimal work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a context *) (* Goal: le_ni ni3 (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply forces_ngamma_shift_work_ni_x_ni. (* Goal: nminimal (@cons normal_form (NImp_NF (nested_imp2nimp (Decorated (NImp a0 a1 b) k))) work) ds (@app nested_imp ni31 ni32) ai a context *) (* Goal: le_ni ni3 (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) rewrite <- eq_ni3. (* Goal: forces_ngamma (@cons normal_form (NImp_NF (nested_imp2nimp (Decorated (NImp a0 a1 b) k))) work) ds ni3 ai a k *) (* Goal: forall _ : forces_t k (Imp (Atom a0) (Atom a1)), False *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds (@app nested_imp ni31 ni32) ai a *) (* Goal: nsound work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a context *) (* Goal: nminimal work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a context *) (* Goal: le_ni ni3 (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply forces_ngamma_cons_work_weak2 with (AImp a1 b) (NAtom a0). (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) assumption. intros; simpl in |- *; apply forces_a1_imp_b__forces_a0_imp_a1_imp_b_t; (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply forces_ngamma_eqv with ni2; try assumption. (* Goal: forall _ : forces_t k (Imp (Atom a0) (Atom a1)), False *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds (@app nested_imp ni31 ni32) ai a *) (* Goal: nsound work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a context *) (* Goal: nminimal work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a context *) (* Goal: le_ni ni3 (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) intros forces_a0a1. (* Goal: False *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds (@app nested_imp ni31 ni32) ai a *) (* Goal: nsound work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a context *) (* Goal: nminimal work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a context *) (* Goal: le_ni ni3 (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply k_nonforces_goal. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply forces_a_a_imp_b__forces_b_t with (Atom a0); try assumption. (* Goal: forces_t k (Atom a0) *) (* Goal: forces_t k (Imp (Atom a1) (nf2form b)) *) (* Goal: nminimal (@cons normal_form (NImp_NF (NImp a0 a1 b)) (@cons normal_form (NAtom a0) work)) ds dni_ni ai a (@cons form (Atom a0) context) *) apply k_forces_ngamma with (c := NAtom a0). (* Goal: in_ngamma (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds dni_ni ai a (NAtom a0) *) (* Goal: forces_t k (Imp (Atom a1) (nf2form b)) *) (* Goal: nminimal (@cons normal_form (NImp_NF (NImp a0 a1 b)) (@cons normal_form (NAtom a0) work)) ds dni_ni ai a (@cons form (Atom a0) context) *) apply in_ngamma_cons_work_tail. (* Goal: in_ngamma (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds dni_ni ai a (AImp a1 b) *) (* Goal: nminimal (@cons normal_form (NImp_NF (NImp a0 a1 b)) (@cons normal_form (NAtom a0) work)) ds dni_ni ai a (@cons form (Atom a0) context) *) apply in_ngamma_cons_work_head. (* Goal: nminimal (@cons normal_form (NImp_NF (nested_imp2nimp (Decorated (NImp a0 a1 b) k))) work) ds (@app nested_imp ni31 ni32) ai a context *) (* Goal: le_ni ni3 (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) rewrite <- eq_ni3. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply deco_sound_inf with dni_ni ni2; try assumption. (* Goal: nminimal (@cons normal_form (NImp_NF (NImp a0 a1 b)) (@cons normal_form (NAtom a0) work)) ds dni_ni ai a (@cons form (Atom a0) context) *) rewrite dni_ni_eq. (* Goal: nminimal (@cons normal_form (NImp_NF (NImp a0 a1 b)) (@cons normal_form (NAtom a0) work)) ds (rev_app dni ni) ai a (@cons form (Atom a0) context) *) rewrite (rev_app_app dni ni). apply deco_sound_shift_ni_x_ni_work with (x := Undecorated (NImp a0 a1 b)); (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) try assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) rewrite <- (rev_app_app dni (Undecorated (NImp a0 a1 b) :: ni)); assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply deco_sound_cons_work_weak2 with (AImp a1 b) (NAtom a0); try assumption. intros; simpl in |- *; apply forces_a1_imp_b__forces_a0_imp_a1_imp_b_t; (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) assumption. (* Goal: nsound work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a context *) (* Goal: nminimal work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a context *) (* Goal: le_ni ni3 (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) unfold nsound in |- *. (* Goal: forall (c : normal_form) (_ : in_ngamma work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a c), Derivable context (nf2form c) *) (* Goal: nminimal work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a context *) (* Goal: le_ni ni3 (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) intros c in_ngamma. (* Goal: Derivable context (nf2form c) *) (* Goal: nminimal work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a context *) (* Goal: le_ni ni3 (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply sound. (* Goal: In_NGamma.in_ngamma work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a c *) (* Goal: nminimal work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a context *) (* Goal: le_ni ni3 (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) elim in_ngamma; clear in_ngamma c. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) intros n x nth; apply In_Work with n; assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) intros n i j nth; apply In_Disjs with n; assumption. (* Goal: forall (n : nat) (x : nimp) (_ : my_nth nimp n (nested_imps2nimps (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32))) x), in_ngamma work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a (NImp_NF x) *) (* Goal: forall (i : Int) (b0 : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b0), in_ngamma work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a (AImp i b0) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a (NAtom i) *) (* Goal: nminimal work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a context *) (* Goal: le_ni ni3 (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) intros n x nth; apply In_Nested_Imps with n. rewrite <- (eqv_nimps_eq (ni31 ++ Decorated (NImp a0 a1 b) k :: ni32) (rev_app dni (Undecorated (NImp a0 a1 b) :: ni))) . (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) assumption. (* Goal: eqv_ni (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) *) (* Goal: forall (i : Int) (b0 : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b0), in_ngamma work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a (AImp i b0) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a (NAtom i) *) (* Goal: nminimal work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a context *) (* Goal: le_ni ni3 (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) rewrite (rev_app_app dni (Undecorated (NImp a0 a1 b) :: ni)). (* Goal: eqv_ni (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) (@app nested_imp (rev_app dni NNil) (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) *) (* Goal: forall (i : Int) (b0 : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b0), in_ngamma work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a (AImp i b0) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a (NAtom i) *) (* Goal: nminimal work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a context *) (* Goal: le_ni ni3 (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply le_eqv. (* Goal: le_ni (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) (@app nested_imp (rev_app dni NNil) (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) *) (* Goal: forall (i : Int) (b0 : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b0), in_ngamma work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a (AImp i b0) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a (NAtom i) *) (* Goal: nminimal work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a context *) (* Goal: le_ni ni3 (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply le_ni_app_dn. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) assumption. (* Goal: nminimal (@cons normal_form (NImp_NF (nested_imp2nimp (Decorated (NImp a0 a1 b) k))) work) ds (@app nested_imp ni31 ni32) ai a context *) (* Goal: le_ni ni3 (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) rewrite <- eq_ni3. (* Goal: le_ni ni3 (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) rewrite <- (rev_app_app dni ni). (* Goal: le_ni ni3 (rev_app dni ni) *) (* Goal: forall (i : Int) (b0 : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b0), in_ngamma work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a (AImp i b0) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a (NAtom i) *) (* Goal: nminimal work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a context *) (* Goal: le_ni ni3 (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) rewrite <- dni_ni_eq. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) assumption. (* Goal: forall (i : Int) (b0 : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b0), in_ngamma work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a (AImp i b0) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) ai a (NAtom i) *) (* Goal: nminimal work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a context *) (* Goal: le_ni ni3 (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) intros i b0 n bs lookup0 nth. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply In_Atomic_Imps with n bs; assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) intros i lookup; apply In_Atoms; assumption. (* Goal: nminimal work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a context *) (* Goal: le_ni ni3 (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply nminimal_shift_work_ni_x_ni. (* Goal: nminimal (@cons normal_form (NImp_NF (nested_imp2nimp (Decorated (NImp a0 a1 b) k))) work) ds (@app nested_imp ni31 ni32) ai a context *) (* Goal: le_ni ni3 (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) rewrite <- eq_ni3. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply nminimal_eqv with dni_ni; try assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply ge_eqv; assumption. (* Goal: nminimal (@cons normal_form (NImp_NF (NImp a0 a1 b)) (@cons normal_form (NAtom a0) work)) ds dni_ni ai a (@cons form (Atom a0) context) *) rewrite dni_ni_eq. (* Goal: nminimal (@cons normal_form (NImp_NF (NImp a0 a1 b)) (@cons normal_form (NAtom a0) work)) ds (rev_app dni ni) ai a (@cons form (Atom a0) context) *) rewrite (rev_app_app dni ni). apply nminimal_shift_ni_x_ni_work with (x := Undecorated (NImp a0 a1 b)); (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) try assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) rewrite <- (rev_app_app dni (Undecorated (NImp a0 a1 b) :: ni)); assumption. (* Goal: le_ni ni3 (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) rewrite <- (rev_app_app dni ni). (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) rewrite <- dni_ni_eq; assumption. (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply eqv_ni_trans with ni1. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply le_eqv; assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply ge_eqv; assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) rewrite <- dni_ni_eq; assumption. (* side premiss: Elim left_premiss with ni1 dni1 H0 H1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) clear right_premiss fail0. (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply deco_sound_cons_work_strength with (NImp_NF (NImp a0 a1 b)). (* Goal: le_ni (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) (rev_app (@cons (prod nimp kripke_tree) (@pair nimp kripke_tree (NImp a0 a1 b) k) dni) ni) *) (* Goal: deco_sound work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a *) (* Goal: nsound work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a context *) (* Goal: nminimal work ds (@app nested_imp ni31 (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni32)) ai a context *) (* Goal: le_ni ni3 (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: eqv_ni dni_ni ni2 *) (* Goal: le_ni (rev_app dni ni) ni1 *) (* Goal: deco_sound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) intros; simpl in |- *. apply forces_a0_imp_a1_imp_b__forces_a1_imp_b_t with (Atom a0); (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) try assumption. (* Goal: forces_t k (Atom a0) *) (* Goal: forces_t k (Imp (Imp (Atom a0) (Atom a1)) (nf2form b)) *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply H0 with (c := NAtom a0). (* Goal: in_ngamma (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds dni_ni ai a (NAtom a0) *) (* Goal: forces_t k (Imp (Atom a1) (nf2form b)) *) (* Goal: nminimal (@cons normal_form (NImp_NF (NImp a0 a1 b)) (@cons normal_form (NAtom a0) work)) ds dni_ni ai a (@cons form (Atom a0) context) *) apply in_ngamma_cons_work_tail. (* Goal: in_ngamma (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds dni_ni ai a (AImp a1 b) *) (* Goal: nminimal (@cons normal_form (NImp_NF (NImp a0 a1 b)) (@cons normal_form (NAtom a0) work)) ds dni_ni ai a (@cons form (Atom a0) context) *) apply in_ngamma_cons_work_head. (* Goal: forces_t k (Imp (Imp (Atom a0) (Atom a1)) (nf2form b)) *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply H0 with (c := NImp_NF (NImp a0 a1 b)). (* Goal: in_ngamma (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds dni_ni ai a (AImp a1 b) *) (* Goal: nminimal (@cons normal_form (NImp_NF (NImp a0 a1 b)) (@cons normal_form (NAtom a0) work)) ds dni_ni ai a (@cons form (Atom a0) context) *) apply in_ngamma_cons_work_head. (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) (@cons normal_form (NAtom a0) work)) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply deco_sound_shift_ni_work with (x := Undecorated (NImp a0 a1 b)). (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply deco_sound_filter_deco; try assumption. (* Goal: forall (x : nimp) (k : kripke_tree) (_ : @In nested_imp (Decorated x k) (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni1)), forces_t k (Atom a0) *) (* Goal: deco_sound work ds (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni1) ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) intros x k in_x. (* Goal: forces_t k (Atom a0) *) (* Goal: deco_sound work ds (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni1) ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply forces_a0 with x. (* Goal: @In nested_imp (Decorated x k) ni1 *) (* Goal: deco_sound work ds (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni1) ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) inversion_clear in_x. (* Goal: @In nested_imp (Decorated x k) ni1 *) (* Goal: @In nested_imp (Decorated x k) ni1 *) (* Goal: deco_sound work ds (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni1) ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) discriminate H. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) assumption. (* Goal: deco_sound work ds (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni1) ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply deco_sound_shift_work_ni0. (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds ni1 ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply deco_sound_le with dni_ni. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) assumption. (* Goal: nminimal (@cons normal_form (NImp_NF (NImp a0 a1 b)) (@cons normal_form (NAtom a0) work)) ds dni_ni ai a (@cons form (Atom a0) context) *) rewrite dni_ni_eq. (* Goal: nminimal (@cons normal_form (NImp_NF (NImp a0 a1 b)) (@cons normal_form (NAtom a0) work)) ds (rev_app dni ni) ai a (@cons form (Atom a0) context) *) rewrite (rev_app_app dni ni). apply deco_sound_shift_ni_x_ni_work with (x := Undecorated (NImp a0 a1 b)); (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) try assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) rewrite <- (rev_app_app dni (Undecorated (NImp a0 a1 b) :: ni)); assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply nsound_le with dni_ni; try assumption. (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds dni_ni ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply nsound_cons_work_weak with (NImp_NF (NImp a0 a1 b)). (* Goal: forall _ : Derivable (@cons form (Atom a0) context) (nf2form (NImp_NF (NImp a0 a1 b))), Derivable (@cons form (Atom a0) context) (nf2form (AImp a1 b)) *) (* Goal: nsound (@cons normal_form (NImp_NF (NImp a0 a1 b)) (@cons normal_form (NAtom a0) work)) ds dni_ni ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) intros der. (* Goal: forall (t : proof_term) (_ : derives context t (nf2form NFalsum)), Derivable context (Atom goal) *) (* Goal: in_ngamma (@cons normal_form NFalsum work) ds ni ai a NFalsum *) elim der; clear der; intros t der_t. apply Derivable_Intro with (Abs (Atom a1) (App (Imp (Atom a0) (Atom a1)) (Shift t) (Abs (Atom a0) (Shift (Var 0))))). (* Goal: derives (@cons form (Atom a0) context) (Abs (Atom a1) (App (Imp (Atom a0) (Atom a1)) (Shift t) (Abs (Atom a0) (Shift (Var O))))) (nf2form (AImp a1 b)) *) (* Goal: nsound (@cons normal_form (NImp_NF (NImp a0 a1 b)) (@cons normal_form (NAtom a0) work)) ds dni_ni ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) simpl in |- *; apply ImpIntro. (* Goal: derives (@cons form (Atom a1) (@cons form (Atom a0) context)) (App (Imp (Atom a0) (Atom a1)) (Shift t) (Abs (Atom a0) (Shift (Var O)))) (nf2form b) *) (* Goal: nsound (@cons normal_form (NImp_NF (NImp a0 a1 b)) (@cons normal_form (NAtom a0) work)) ds dni_ni ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply ImpElim. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply ShiftIntro; assumption. (* Goal: derives (@cons form (Atom a1) (@cons form (Atom a0) context)) (Abs (Atom a0) (Shift (Var O))) (Imp (Atom a0) (Atom a1)) *) (* Goal: nsound (@cons normal_form (NImp_NF (NImp a0 a1 b)) (@cons normal_form (NAtom a0) work)) ds dni_ni ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply ImpIntro. (* Goal: derives (@cons form (Atom a0) (@cons form (Atom a1) (@cons form (Atom a0) context))) (Shift (Var O)) (Atom a1) *) (* Goal: nsound (@cons normal_form (NImp_NF (NImp a0 a1 b)) (@cons normal_form (NAtom a0) work)) ds dni_ni ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply ShiftIntro. (* Goal: derives (@cons form (Atom a1) (@cons form (Atom a0) context)) (Var O) (Atom a1) *) (* Goal: nsound (@cons normal_form (NImp_NF (NImp a0 a1 b)) (@cons normal_form (NAtom a0) work)) ds dni_ni ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply ByAssumption; apply My_NthO. (* Goal: nminimal (@cons normal_form (NImp_NF (NImp a0 a1 b)) (@cons normal_form (NAtom a0) work)) ds dni_ni ai a (@cons form (Atom a0) context) *) rewrite dni_ni_eq. (* Goal: nminimal (@cons normal_form (NImp_NF (NImp a0 a1 b)) (@cons normal_form (NAtom a0) work)) ds (rev_app dni ni) ai a (@cons form (Atom a0) context) *) rewrite (rev_app_app dni ni). (* Goal: nsound (@cons normal_form (NImp_NF (NImp a0 a1 b)) (@cons normal_form (NAtom a0) work)) ds (@app nested_imp (rev_app dni NNil) ni) ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply nsound_shift_ni_x_ni_work with (x := Undecorated (NImp a0 a1 b)). (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply nsound_cons_work_cons_context with (c := NAtom a0); try assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) rewrite <- (rev_app_app dni (Undecorated (NImp a0 a1 b) :: ni)); assumption. (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply nminimal_eqv with dni_ni. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply le_eqv; assumption. (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds dni_ni ai a (@cons form (Atom a0) context) *) apply nminimal_cons_work_strength with (NImp_NF (NImp a0 a1 b)). (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds dni_ni ai a k), forces_t k (nf2form (NImp_NF (NImp a0 a1 b))) *) (* Goal: nminimal (@cons normal_form (NImp_NF (NImp a0 a1 b)) (@cons normal_form (NAtom a0) work)) ds dni_ni ai a (@cons form (Atom a0) context) *) intros k k_is_mon k_forces_ngamma. simpl in |- *; apply forces_a1_imp_b__forces_a0_imp_a1_imp_b_t; (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) try assumption. (* Goal: forces_t k (Atom a0) *) (* Goal: forces_t k (Imp (Atom a1) (nf2form b)) *) (* Goal: nminimal (@cons normal_form (NImp_NF (NImp a0 a1 b)) (@cons normal_form (NAtom a0) work)) ds dni_ni ai a (@cons form (Atom a0) context) *) apply k_forces_ngamma with (c := NAtom a0). (* Goal: in_ngamma (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds dni_ni ai a (NAtom a0) *) (* Goal: forces_t k (Imp (Atom a1) (nf2form b)) *) (* Goal: nminimal (@cons normal_form (NImp_NF (NImp a0 a1 b)) (@cons normal_form (NAtom a0) work)) ds dni_ni ai a (@cons form (Atom a0) context) *) apply in_ngamma_cons_work_tail. (* Goal: in_ngamma (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds dni_ni ai a (AImp a1 b) *) (* Goal: nminimal (@cons normal_form (NImp_NF (NImp a0 a1 b)) (@cons normal_form (NAtom a0) work)) ds dni_ni ai a (@cons form (Atom a0) context) *) apply in_ngamma_cons_work_head. (* Goal: forces_t k (Imp (Atom a1) (nf2form b)) *) (* Goal: nminimal (@cons normal_form (NImp_NF (NImp a0 a1 b)) (@cons normal_form (NAtom a0) work)) ds dni_ni ai a (@cons form (Atom a0) context) *) change (forces_t k (nf2form (AImp a1 b))) in |- *. (* Goal: forces_t k (nf2form (AImp a1 b)) *) (* Goal: nminimal (@cons normal_form (NImp_NF (NImp a0 a1 b)) (@cons normal_form (NAtom a0) work)) ds dni_ni ai a (@cons form (Atom a0) context) *) apply k_forces_ngamma. (* Goal: in_ngamma (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds dni_ni ai a (AImp a1 b) *) (* Goal: nminimal (@cons normal_form (NImp_NF (NImp a0 a1 b)) (@cons normal_form (NAtom a0) work)) ds dni_ni ai a (@cons form (Atom a0) context) *) apply in_ngamma_cons_work_head. (* Goal: nminimal (@cons normal_form (NImp_NF (NImp a0 a1 b)) (@cons normal_form (NAtom a0) work)) ds dni_ni ai a (@cons form (Atom a0) context) *) rewrite dni_ni_eq. (* Goal: nminimal (@cons normal_form (NImp_NF (NImp a0 a1 b)) (@cons normal_form (NAtom a0) work)) ds (rev_app dni ni) ai a (@cons form (Atom a0) context) *) rewrite (rev_app_app dni ni). (* Goal: nminimal (@cons normal_form (NImp_NF (NImp a0 a1 b)) (@cons normal_form (NAtom a0) work)) ds (@app nested_imp (rev_app dni NNil) ni) ai a (@cons form (Atom a0) context) *) apply nminimal_shift_ni_x_ni_work with (x := Undecorated (NImp a0 a1 b)). (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) apply nminimal_cons_work_cons_context with (c := NAtom a0); try assumption. (* Goal: le_ni dni_ni ni1 *) (* Goal: deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds dni_ni ai a *) (* Goal: nsound (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) (* Goal: nminimal (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) work)) ds ni1 ai a (@cons form (Atom a0) context) *) rewrite <- (rev_app_app dni (Undecorated (NImp a0 a1 b) :: ni)); assumption. Qed.
(* File: Cons_Counter_Model.v (last edited on 27/10/2000) (c) Klaus Weich *) Require Export Disjunct. Require Export NDeco_Sound. Fixpoint n2forest (n : nested_imps) : Forest atoms := match n with | nil => Nil_Forest atoms | Undecorated _ :: n => n2forest n | Decorated _ k :: n => Cons_Forest atoms k (n2forest n) end. Remark cons_counter_model_suc : forall (x : nimp) (k : kripke_tree) (ni : nested_imps) (a : atoms), In (Decorated x k) ni -> Suc k (node atoms a (n2forest ni)). (* Goal: forall (x : nimp) (k : kripke_tree) (ni : nested_imps) (a : atoms) (_ : @In nested_imp (Decorated x k) ni), Suc k (node atoms a (n2forest ni)) *) intros x k ni a in_k. (* Goal: Suc k (node atoms a (n2forest ni)) *) unfold Suc in |- *; apply successor_trans with k. (* Goal: In_Forest atoms k (successors atoms (node atoms a (n2forest ni))) *) (* Goal: Successor atoms k k *) generalize in_k; clear in_k. (* Goal: forall (_ : forall (x : nimp) (_ : @In nested_imp (Undecorated x) ni), False) (_ : deco_sound nf_nil DNil ni ai a), Is_Monotone_kripke_tree (node atoms a (n2forest ni)) *) elim ni; clear ni. (* Goal: forall _ : In_Forest atoms k (n2forest (@nil nested_imp)), @ex nimp (fun x : nimp => @In nested_imp (Decorated x k) (@nil nested_imp)) *) (* Goal: forall (a : nested_imp) (l : list nested_imp) (_ : forall _ : In_Forest atoms k (n2forest l), @ex nimp (fun x : nimp => @In nested_imp (Decorated x k) l)) (_ : In_Forest atoms k (n2forest (@cons nested_imp a l))), @ex nimp (fun x : nimp => @In nested_imp (Decorated x k) (@cons nested_imp a l)) *) intros in_k. (* Goal: @ex nimp (fun x0 : nimp => or (@eq nested_imp (Decorated x k0) (Decorated x0 k)) (@In nested_imp (Decorated x0 k) ni)) *) inversion_clear in_k. (* Goal: forall (a0 : nested_imp) (l : list nested_imp) (_ : forall _ : @In nested_imp (Decorated x k) l, In_Forest atoms k (successors atoms (node atoms a (n2forest l)))) (_ : @In nested_imp (Decorated x k) (@cons nested_imp a0 l)), In_Forest atoms k (successors atoms (node atoms a (n2forest (@cons nested_imp a0 l)))) *) (* Goal: Successor atoms k k *) intros y ni ih in_k. (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni))) *) unfold n2forest in |- *; simpl in |- *; fold n2forest in |- *. (* Goal: @ex nimp (fun x0 : nimp => or (@eq nested_imp (Decorated x k0) (Decorated x0 k)) (@In nested_imp (Decorated x0 k) ni)) *) inversion_clear in_k. (* Goal: In_Forest atoms k match y with | Undecorated n0 => n2forest ni | Decorated n0 k => Cons_Forest atoms k (n2forest ni) end *) (* Goal: In_Forest atoms k match y with | Undecorated n0 => n2forest ni | Decorated n0 k => Cons_Forest atoms k (n2forest ni) end *) (* Goal: Successor atoms k k *) rewrite H; clear H y. (* Goal: In_Forest atoms k (Cons_Forest atoms k (n2forest ni)) *) (* Goal: In_Forest atoms k match y with | Undecorated n0 => n2forest ni | Decorated n0 k => Cons_Forest atoms k (n2forest ni) end *) (* Goal: Successor atoms k k *) apply in_forest_head. (* Goal: In_Forest atoms k match y with | Undecorated n0 => n2forest ni | Decorated n0 k => Cons_Forest atoms k (n2forest ni) end *) (* Goal: Successor atoms k k *) generalize (ih H); clear ih H. (* Goal: forall _ : In_Forest atoms k (successors atoms (node atoms a (n2forest ni))), In_Forest atoms k match y with | Undecorated n0 => n2forest ni | Decorated n0 k => Cons_Forest atoms k (n2forest ni) end *) (* Goal: Successor atoms k k *) intros ih. (* Goal: In_Forest atoms k match y with | Undecorated n0 => n2forest ni | Decorated n0 k => Cons_Forest atoms k (n2forest ni) end *) (* Goal: Successor atoms k k *) case y; clear y. (* Goal: forall _ : False, False *) (* Goal: forall (a : decorated_nested_imp) (l : list decorated_nested_imp) (_ : forall _ : @In nested_imp (Undecorated x) (rev_app l NNil), False) (_ : @In nested_imp (Undecorated x) (rev_app (@cons decorated_nested_imp a l) NNil)), False *) intros; assumption. (* Goal: forall (_ : nimp) (k0 : kripke_tree), In_Forest atoms k (Cons_Forest atoms k0 (n2forest ni)) *) (* Goal: Successor atoms k k *) intros; apply in_forest_tail; assumption. (* Goal: Successor atoms k k *) apply successor_refl. Qed. Remark in_forest_ex_a0a1b : forall (k : kripke_tree) (ni : nested_imps), In_Forest atoms k (n2forest ni) -> exists x : nimp, In (Decorated x k) ni. (* Goal: forall (k : kripke_tree) (ni : nested_imps) (_ : In_Forest atoms k (n2forest ni)), @ex nimp (fun x : nimp => @In nested_imp (Decorated x k) ni) *) intros k ni. (* Goal: forall (_ : forall (x : nimp) (_ : @In nested_imp (Undecorated x) ni), False) (_ : deco_sound nf_nil DNil ni ai a), Is_Monotone_kripke_tree (node atoms a (n2forest ni)) *) elim ni; clear ni. (* Goal: forall _ : In_Forest atoms k (n2forest (@nil nested_imp)), @ex nimp (fun x : nimp => @In nested_imp (Decorated x k) (@nil nested_imp)) *) (* Goal: forall (a : nested_imp) (l : list nested_imp) (_ : forall _ : In_Forest atoms k (n2forest l), @ex nimp (fun x : nimp => @In nested_imp (Decorated x k) l)) (_ : In_Forest atoms k (n2forest (@cons nested_imp a l))), @ex nimp (fun x : nimp => @In nested_imp (Decorated x k) (@cons nested_imp a l)) *) intros in_k. (* Goal: @ex nimp (fun x0 : nimp => or (@eq nested_imp (Decorated x k0) (Decorated x0 k)) (@In nested_imp (Decorated x0 k) ni)) *) inversion_clear in_k. (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni))) *) unfold n2forest in |- *; simpl in |- *; fold n2forest in |- *. (* Goal: forall (x : nested_imp) (_ : and (my_nth nested_imp n (rev_app dni NNil) x) (@eq nimp (nested_imp2nimp x) (NImp a0 a1 b))), False *) (* Goal: forall (k' : kripke_tree) (_ : In_Forest atoms k' (Succs (node atoms a (n2forest (rev_app dni NNil))))), forces_t k' (Imp (Imp (Atom a0) (Atom a1)) (nf2form b)) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (AImp i b)) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NAtom i)) *) (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) intros x; case x; clear x. (* Goal: forall (n : nimp) (l : list nested_imp) (_ : forall _ : In_Forest atoms k (n2forest l), @ex nimp (fun x : nimp => @In nested_imp (Decorated x k) l)) (_ : In_Forest atoms k (n2forest l)), @ex nimp (fun x : nimp => or (@eq nested_imp (Undecorated n) (Decorated x k)) (@In nested_imp (Decorated x k) l)) *) (* Goal: forall (n : nimp) (k0 : kripke_tree) (l : list nested_imp) (_ : forall _ : In_Forest atoms k (n2forest l), @ex nimp (fun x : nimp => @In nested_imp (Decorated x k) l)) (_ : In_Forest atoms k (Cons_Forest atoms k0 (n2forest l))), @ex nimp (fun x : nimp => or (@eq nested_imp (Decorated n k0) (Decorated x k)) (@In nested_imp (Decorated x k) l)) *) intros x ni ih in_k. (* Goal: @ex nimp (fun x0 : nimp => or (@eq nested_imp (Undecorated x) (Decorated x0 k)) (@In nested_imp (Decorated x0 k) ni)) *) (* Goal: forall (n : nimp) (k0 : kripke_tree) (l : list nested_imp) (_ : forall _ : In_Forest atoms k (n2forest l), @ex nimp (fun x : nimp => @In nested_imp (Decorated x k) l)) (_ : In_Forest atoms k (Cons_Forest atoms k0 (n2forest l))), @ex nimp (fun x : nimp => or (@eq nested_imp (Decorated n k0) (Decorated x k)) (@In nested_imp (Decorated x k) l)) *) elim ih; clear ih. (* Goal: forall (x0 : nimp) (_ : @In nested_imp (Decorated x0 k) ni), @ex nimp (fun x1 : nimp => or (@eq nested_imp (Undecorated x) (Decorated x1 k)) (@In nested_imp (Decorated x1 k) ni)) *) (* Goal: In_Forest atoms k (n2forest ni) *) (* Goal: forall (n : nimp) (k0 : kripke_tree) (l : list nested_imp) (_ : forall _ : In_Forest atoms k (n2forest l), @ex nimp (fun x : nimp => @In nested_imp (Decorated x k) l)) (_ : In_Forest atoms k (Cons_Forest atoms k0 (n2forest l))), @ex nimp (fun x : nimp => or (@eq nested_imp (Decorated n k0) (Decorated x k)) (@In nested_imp (Decorated x k) l)) *) intros y in_y. (* Goal: @sig nested_imp (fun y0 : nested_imp => and (my_nth nested_imp O (@cons nested_imp y ni) y0) (@eq nimp (nested_imp2nimp y0) x)) *) (* Goal: forall (n : nat) (_ : forall (ni : nested_imps) (_ : my_nth nimp n (nested_imps2nimps ni) x), @sig nested_imp (fun y : nested_imp => and (my_nth nested_imp n ni y) (@eq nimp (nested_imp2nimp y) x))) (ni : nested_imps) (_ : my_nth nimp (S n) (nested_imps2nimps ni) x), @sig nested_imp (fun y : nested_imp => and (my_nth nested_imp (S n) ni y) (@eq nimp (nested_imp2nimp y) x)) *) exists y. (* Goal: @In nested_imp (Undecorated x) (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni) *) (* Goal: deco_sound nf_nil DNil ni ai a *) (* Goal: @In nested_imp (Decorated (NImp a0 a1 b) k) (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni) *) right; assumption. (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) assumption. (* Goal: forall (n : nimp) (k0 : kripke_tree) (l : list nested_imp) (_ : forall _ : In_Forest atoms k (n2forest l), @ex nimp (fun x : nimp => @In nested_imp (Decorated x k) l)) (_ : In_Forest atoms k (Cons_Forest atoms k0 (n2forest l))), @ex nimp (fun x : nimp => or (@eq nested_imp (Decorated n k0) (Decorated x k)) (@In nested_imp (Decorated x k) l)) *) intros x k0 ni ih in_k. (* Goal: @ex nimp (fun x0 : nimp => or (@eq nested_imp (Decorated x k0) (Decorated x0 k)) (@In nested_imp (Decorated x0 k) ni)) *) inversion_clear in_k. (* Goal: @ex nimp (fun x0 : nimp => or (@eq nested_imp (Decorated x k0) (Decorated x0 k0)) (@In nested_imp (Decorated x0 k0) ni)) *) (* Goal: @ex nimp (fun x0 : nimp => or (@eq nested_imp (Decorated x k0) (Decorated x0 k)) (@In nested_imp (Decorated x0 k) ni)) *) exists x. (* Goal: @In nested_imp (Decorated (NImp a0 a1 b) k) (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni) *) left; trivial. (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) elim ih; try assumption. (* Goal: forall (x0 : nimp) (_ : @In nested_imp (Decorated x0 k) ni), @ex nimp (fun x1 : nimp => or (@eq nested_imp (Decorated x k0) (Decorated x1 k)) (@In nested_imp (Decorated x1 k) ni)) *) intros x0 in_k. (* Goal: @ex nimp (fun x0 : nimp => or (@eq nested_imp (Decorated x k0) (Decorated x0 k)) (@In nested_imp (Decorated x0 k) ni)) *) exists x0. (* Goal: @In nested_imp (Undecorated x) (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni) *) (* Goal: deco_sound nf_nil DNil ni ai a *) (* Goal: @In nested_imp (Decorated (NImp a0 a1 b) k) (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni) *) right; assumption. Qed. (**********************************************************************) Remark deco_sound_in_forest_forces : forall (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (k : kripke_tree) (c : normal_form), deco_sound work ds ni ai a -> In_Forest atoms k (n2forest ni) -> in_ngamma work ds ni ai a c -> forces_t k (nf2form c). (* Goal: forall (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (k : kripke_tree) (c : normal_form) (_ : deco_sound work ds ni ai a) (_ : In_Forest atoms k (n2forest ni)) (_ : in_ngamma work ds ni ai a c), forces_t k (nf2form c) *) intros work ds ni ai a k c complete in_k in_ngamma. (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) elim in_forest_ex_a0a1b with k ni; try assumption. (* Goal: forall (x : nested_imp) (_ : and (my_nth nested_imp n (rev_app dni NNil) x) (@eq nimp (nested_imp2nimp x) (NImp a0 a1 b))), False *) (* Goal: forall (k' : kripke_tree) (_ : In_Forest atoms k' (Succs (node atoms a (n2forest (rev_app dni NNil))))), forces_t k' (Imp (Imp (Atom a0) (Atom a1)) (nf2form b)) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (AImp i b)) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NAtom i)) *) (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) intros x; case x; clear x. (* Goal: forall (i i0 : Int) (n : normal_form) (_ : @In nested_imp (Decorated (NImp i i0 n) k) ni), forces_t k (nf2form c) *) intros a0 a1 b in_x. (* Goal: forces_t k (nf2form c) *) elim (complete k a0 a1 b in_x); clear complete. (* Goal: forall (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma nf_nil DNil (rev_app dni NNil) ai a k) (_ : forall _ : forces_t k (Imp (Atom a0) (Atom a1)), False), False *) (* Goal: @In nested_imp (Decorated (NImp a0 a1 b) k) (rev_app dni NNil) *) (* Goal: forall (k' : kripke_tree) (_ : In_Forest atoms k' (Succs (node atoms a (n2forest (rev_app dni NNil))))), forces_t k' (Imp (Imp (Atom a0) (Atom a1)) (nf2form b)) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (AImp i b)) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NAtom i)) *) (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) intros k_is_mon k_forces_ngamma k_notforces_a0a1. (* Goal: forces_t k (nf2form c) *) apply k_forces_ngamma. (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) assumption. Qed. (**********************************************************************) Remark cons_counter_model_mon : forall (ni : nested_imps) (ai : atomic_imps) (a : atoms), (forall x : nimp, In (Undecorated x) ni -> False) -> deco_sound nf_nil DNil ni ai a -> Is_Monotone_kripke_tree (node atoms a (n2forest ni)). (* Goal: forall (ni : nested_imps) (ai : atomic_imps) (a : atoms) (_ : forall (x : nimp) (_ : @In nested_imp (Undecorated x) ni), False) (_ : deco_sound nf_nil DNil ni ai a), Is_Monotone_kripke_tree (node atoms a (n2forest ni)) *) intros ni ai a. (* Goal: forall (_ : forall (x : nimp) (_ : @In nested_imp (Undecorated x) ni), False) (_ : deco_sound nf_nil DNil ni ai a), Is_Monotone_kripke_tree (node atoms a (n2forest ni)) *) elim ni; clear ni. (* Goal: forall (_ : forall (x : nimp) (_ : @In nested_imp (Undecorated x) (@nil nested_imp)), False) (_ : deco_sound nf_nil DNil (@nil nested_imp) ai a), Is_Monotone_kripke_tree (node atoms a (n2forest (@nil nested_imp))) *) (* Goal: forall (a0 : nested_imp) (l : list nested_imp) (_ : forall (_ : forall (x : nimp) (_ : @In nested_imp (Undecorated x) l), False) (_ : deco_sound nf_nil DNil l ai a), Is_Monotone_kripke_tree (node atoms a (n2forest l))) (_ : forall (x : nimp) (_ : @In nested_imp (Undecorated x) (@cons nested_imp a0 l)), False) (_ : deco_sound nf_nil DNil (@cons nested_imp a0 l) ai a), Is_Monotone_kripke_tree (node atoms a (n2forest (@cons nested_imp a0 l))) *) intros all_ref complete. (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (@nil nested_imp))) *) (* Goal: forall (a0 : nested_imp) (l : list nested_imp) (_ : forall (_ : forall (x : nimp) (_ : @In nested_imp (Undecorated x) l), False) (_ : deco_sound nf_nil DNil l ai a), Is_Monotone_kripke_tree (node atoms a (n2forest l))) (_ : forall (x : nimp) (_ : @In nested_imp (Undecorated x) (@cons nested_imp a0 l)), False) (_ : deco_sound nf_nil DNil (@cons nested_imp a0 l) ai a), Is_Monotone_kripke_tree (node atoms a (n2forest (@cons nested_imp a0 l))) *) unfold n2forest in |- *. (* Goal: forall (k' : kripke_tree) (_ : In_Forest atoms k' (Succs (node atoms a (n2forest (rev_app dni NNil))))), forces_t k' (Imp (Atom j) (nf2form b)) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NAtom i)) *) (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) simpl in |- *. (* Goal: Is_Monotone_kripke_tree (node atoms a (Cons_Forest atoms k (n2forest ni))) *) (* Goal: @In nested_imp (Decorated (NImp a0 a1 b) k) (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni) *) unfold Is_Monotone_kripke_tree in |- *. (* Goal: Is_Monotone_Tree atoms Int forces0_t (node atoms a (Cons_Forest atoms k (n2forest ni))) *) (* Goal: @In nested_imp (Decorated (NImp a0 a1 b) k) (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni) *) apply is_monotone_tree_intro. (* Goal: Is_Monotone_Forest atoms Int forces0_t a (Nil_Forest atoms) *) (* Goal: forall (a0 : nested_imp) (l : list nested_imp) (_ : forall (_ : forall (x : nimp) (_ : @In nested_imp (Undecorated x) l), False) (_ : deco_sound nf_nil DNil l ai a), Is_Monotone_kripke_tree (node atoms a (n2forest l))) (_ : forall (x : nimp) (_ : @In nested_imp (Undecorated x) (@cons nested_imp a0 l)), False) (_ : deco_sound nf_nil DNil (@cons nested_imp a0 l) ai a), Is_Monotone_kripke_tree (node atoms a (n2forest (@cons nested_imp a0 l))) *) apply is_monotone_forest_nil. (* Goal: forall (ni : nested_imps) (_ : my_nth nimp O (nested_imps2nimps ni) x), @sig nested_imp (fun y : nested_imp => and (my_nth nested_imp O ni y) (@eq nimp (nested_imp2nimp y) x)) *) (* Goal: forall (n : nat) (_ : forall (ni : nested_imps) (_ : my_nth nimp n (nested_imps2nimps ni) x), @sig nested_imp (fun y : nested_imp => and (my_nth nested_imp n ni y) (@eq nimp (nested_imp2nimp y) x))) (ni : nested_imps) (_ : my_nth nimp (S n) (nested_imps2nimps ni) x), @sig nested_imp (fun y : nested_imp => and (my_nth nested_imp (S n) ni y) (@eq nimp (nested_imp2nimp y) x)) *) intros ni; case ni; clear ni. (* Goal: forall (n : nimp) (l : list nested_imp) (_ : forall (_ : forall (x : nimp) (_ : @In nested_imp (Undecorated x) l), False) (_ : deco_sound nf_nil DNil l ai a), Is_Monotone_kripke_tree (node atoms a (n2forest l))) (_ : forall (x : nimp) (_ : @In nested_imp (Undecorated x) (@cons nested_imp (Undecorated n) l)), False) (_ : deco_sound nf_nil DNil (@cons nested_imp (Undecorated n) l) ai a), Is_Monotone_kripke_tree (node atoms a (n2forest (@cons nested_imp (Undecorated n) l))) *) (* Goal: forall (n : nimp) (k : kripke_tree) (l : list nested_imp) (_ : forall (_ : forall (x : nimp) (_ : @In nested_imp (Undecorated x) l), False) (_ : deco_sound nf_nil DNil l ai a), Is_Monotone_kripke_tree (node atoms a (n2forest l))) (_ : forall (x : nimp) (_ : @In nested_imp (Undecorated x) (@cons nested_imp (Decorated n k) l)), False) (_ : deco_sound nf_nil DNil (@cons nested_imp (Decorated n k) l) ai a), Is_Monotone_kripke_tree (node atoms a (n2forest (@cons nested_imp (Decorated n k) l))) *) intros x ni ih all_ref complete. (* Goal: forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form b) *) (* Goal: forall (k' : kripke_tree) (_ : In_Forest atoms k' (Succs (node atoms a (n2forest (rev_app dni NNil))))), forces_t k' (Imp (Atom j) (nf2form b)) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NAtom i)) *) (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) elimtype False. (* Goal: False *) (* Goal: forall (n : nimp) (k : kripke_tree) (l : list nested_imp) (_ : forall (_ : forall (x : nimp) (_ : @In nested_imp (Undecorated x) l), False) (_ : deco_sound nf_nil DNil l ai a), Is_Monotone_kripke_tree (node atoms a (n2forest l))) (_ : forall (x : nimp) (_ : @In nested_imp (Undecorated x) (@cons nested_imp (Decorated n k) l)), False) (_ : deco_sound nf_nil DNil (@cons nested_imp (Decorated n k) l) ai a), Is_Monotone_kripke_tree (node atoms a (n2forest (@cons nested_imp (Decorated n k) l))) *) apply (all_ref x). (* Goal: @In nested_imp (Decorated (NImp a0 a1 b) k) (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni) *) left; trivial. (* Goal: forall (x : nested_imp) (_ : and (my_nth nested_imp n (rev_app dni NNil) x) (@eq nimp (nested_imp2nimp x) (NImp a0 a1 b))), False *) (* Goal: forall (k' : kripke_tree) (_ : In_Forest atoms k' (Succs (node atoms a (n2forest (rev_app dni NNil))))), forces_t k' (Imp (Imp (Atom a0) (Atom a1)) (nf2form b)) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (AImp i b)) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NAtom i)) *) (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) intros x; case x; clear x. (* Goal: forall (i i0 : Int) (n : normal_form) (k : kripke_tree) (l : list nested_imp) (_ : forall (_ : forall (x : nimp) (_ : @In nested_imp (Undecorated x) l), False) (_ : deco_sound nf_nil DNil l ai a), Is_Monotone_kripke_tree (node atoms a (n2forest l))) (_ : forall (x : nimp) (_ : @In nested_imp (Undecorated x) (@cons nested_imp (Decorated (NImp i i0 n) k) l)), False) (_ : deco_sound nf_nil DNil (@cons nested_imp (Decorated (NImp i i0 n) k) l) ai a), Is_Monotone_kripke_tree (node atoms a (n2forest (@cons nested_imp (Decorated (NImp i i0 n) k) l))) *) intros a0 a1 b k ni ih all_ref complete. (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni))) *) unfold n2forest in |- *; simpl in |- *; fold n2forest in |- *. (* Goal: False *) (* Goal: forall (k' : kripke_tree) (_ : In_Forest atoms k' (Succs (node atoms a (n2forest (rev_app dni NNil))))), forces_t k' (Imp (Imp (Atom a0) (Atom a1)) (nf2form b)) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (AImp i b)) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NAtom i)) *) (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) elim (complete k a0 a1 b). (* Goal: forall (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma nf_nil DNil (rev_app dni NNil) ai a k) (_ : forall _ : forces_t k (Imp (Atom a0) (Atom a1)), False), False *) (* Goal: @In nested_imp (Decorated (NImp a0 a1 b) k) (rev_app dni NNil) *) (* Goal: forall (k' : kripke_tree) (_ : In_Forest atoms k' (Succs (node atoms a (n2forest (rev_app dni NNil))))), forces_t k' (Imp (Imp (Atom a0) (Atom a1)) (nf2form b)) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (AImp i b)) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NAtom i)) *) (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) intros k_is_mon k_forces_ngamma k_notforces_a0a1. (* Goal: Is_Monotone_kripke_tree (node atoms a (Cons_Forest atoms k (n2forest ni))) *) (* Goal: @In nested_imp (Decorated (NImp a0 a1 b) k) (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni) *) unfold Is_Monotone_kripke_tree in |- *. (* Goal: Is_Monotone_Tree atoms Int forces0_t (node atoms a (Cons_Forest atoms k (n2forest ni))) *) (* Goal: @In nested_imp (Decorated (NImp a0 a1 b) k) (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni) *) apply is_monotone_tree_intro. (* Goal: Is_Monotone_Forest atoms Int forces0_t a (Cons_Forest atoms k (n2forest ni)) *) (* Goal: @In nested_imp (Decorated (NImp a0 a1 b) k) (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni) *) apply is_monotone_forest_cons. (* Goal: forall (i : Int) (_ : forces0_t a i), forces0_t (root atoms k) i *) (* Goal: Is_Monotone_Tree atoms Int forces0_t k *) (* Goal: Is_Monotone_Forest atoms Int forces0_t a (n2forest ni) *) (* Goal: @In nested_imp (Decorated (NImp a0 a1 b) k) (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni) *) intros i forces_i. (* Goal: forces0_t (root atoms k) i *) (* Goal: Is_Monotone_Tree atoms Int forces0_t k *) (* Goal: Is_Monotone_Forest atoms Int forces0_t a (n2forest ni) *) (* Goal: @In nested_imp (Decorated (NImp a0 a1 b) k) (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni) *) change (forces_t k (Atom i)) in |- *. (* Goal: forces_t k (Atom i) *) (* Goal: Is_Monotone_Tree atoms Int forces0_t k *) (* Goal: Is_Monotone_Forest atoms Int forces0_t a (n2forest ni) *) (* Goal: @In nested_imp (Decorated (NImp a0 a1 b) k) (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni) *) apply k_forces_ngamma with (c := NAtom i). (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) apply In_Atoms; assumption. (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) assumption. (* Goal: Is_Monotone_Forest atoms Int forces0_t a (n2forest ni) *) (* Goal: @In nested_imp (Decorated (NImp a0 a1 b) k) (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni) *) cut (Is_Monotone_kripke_tree (node atoms a (n2forest ni))). (* Goal: forall _ : or (@In nested_imp (Undecorated x) (rev_app dni NNil)) (@In nested_imp (Undecorated x) (@cons nested_imp (Decorated y k) NNil)), or (@In nested_imp (Undecorated x) (rev_app dni NNil)) (@In nested_imp (Undecorated x) NNil) *) (* Goal: or (@In nested_imp (Undecorated x) (rev_app dni NNil)) (@In nested_imp (Undecorated x) (@cons nested_imp (Decorated y k) NNil)) *) intros claim. (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) inversion_clear claim; assumption. (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest ni)) *) (* Goal: @In nested_imp (Decorated (NImp a0 a1 b) k) (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni) *) apply ih; clear ih. (* Goal: forall (x : nimp) (_ : @In nested_imp (Undecorated x) (rev_app dni NNil)), False *) intros x in_x. (* Goal: False *) (* Goal: deco_sound nf_nil DNil ni ai a *) (* Goal: @In nested_imp (Decorated (NImp a0 a1 b) k) (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni) *) apply all_ref with x. (* Goal: @In nested_imp (Undecorated x) (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni) *) (* Goal: deco_sound nf_nil DNil ni ai a *) (* Goal: @In nested_imp (Decorated (NImp a0 a1 b) k) (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni) *) right; assumption. (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) apply deco_sound_cons_ni_tail with (Decorated (NImp a0 a1 b) k); assumption. (* Goal: @In nested_imp (Decorated (NImp a0 a1 b) k) (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni) *) left; trivial. Qed. (**********************************************************************) Inductive Cons_Counter_Model_Spec (goal : Int) (ni : nested_imps) (ai : atomic_imps) (a : atoms) : Set := cons_counter_model_intro : forall k : kripke_tree, Is_Monotone_kripke_tree k -> forces_ngamma nf_nil DNil ni ai a k -> (forces_t k (Atom goal) -> False) -> Cons_Counter_Model_Spec goal ni ai a. Remark all_ref_rev_app_nil : forall (dni : decorated_nested_imps) (x : nimp), In (Undecorated x) (rev_app dni NNil) -> False. (* Goal: forall (dni : decorated_nested_imps) (x : nimp) (_ : @In nested_imp (Undecorated x) (rev_app dni NNil)), False *) intros dni x. (* Goal: forall _ : @In nested_imp (Undecorated x) (rev_app dni NNil), False *) elim dni; clear dni. (* Goal: forall (k' : kripke_tree) (_ : In_Forest atoms k' (Succs (node atoms a (n2forest (rev_app dni NNil))))), forces_t k' (Imp (Atom j) (nf2form b)) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NAtom i)) *) (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) simpl in |- *. (* Goal: forall _ : False, False *) (* Goal: forall (a : decorated_nested_imp) (l : list decorated_nested_imp) (_ : forall _ : @In nested_imp (Undecorated x) (rev_app l NNil), False) (_ : @In nested_imp (Undecorated x) (rev_app (@cons decorated_nested_imp a l) NNil)), False *) intros; assumption. (* Goal: forall (a : decorated_nested_imp) (l : list decorated_nested_imp) (_ : forall _ : @In nested_imp (Undecorated x) (rev_app l NNil), False) (_ : @In nested_imp (Undecorated x) (rev_app (@cons decorated_nested_imp a l) NNil)), False *) intros a; case a; clear a. (* Goal: forall (n : nimp) (k : kripke_tree) (l : list decorated_nested_imp) (_ : forall _ : @In nested_imp (Undecorated x) (rev_app l NNil), False) (_ : @In nested_imp (Undecorated x) (rev_app (@cons decorated_nested_imp (@pair nimp kripke_tree n k) l) NNil)), False *) intros y k dni ih. (* Goal: forall (k' : kripke_tree) (_ : In_Forest atoms k' (Succs (node atoms a (n2forest (rev_app dni NNil))))), forces_t k' (Imp (Atom j) (nf2form b)) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NAtom i)) *) (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) simpl in |- *. (* Goal: forall _ : @In nested_imp (Undecorated x) (rev_app dni (@cons nested_imp (Decorated y k) NNil)), False *) rewrite (rev_app_app dni (Decorated y k :: NNil)). (* Goal: forall _ : @In nested_imp (Undecorated x) (@app nested_imp (rev_app dni NNil) (@cons nested_imp (Decorated y k) NNil)), False *) intros in_x. (* Goal: False *) apply ih. (* Goal: @In nested_imp (Undecorated x) (rev_app dni NNil) *) rewrite (rev_app_app dni NNil). (* Goal: @In nested_imp (Undecorated x) (@app nested_imp (rev_app dni NNil) NNil) *) apply in_or_app. cut (In (Undecorated x) (rev_app dni NNil) \/ In (Undecorated x) (Decorated y k :: NNil)). (* Goal: forall _ : or (@In nested_imp (Undecorated x) (rev_app dni NNil)) (@In nested_imp (Undecorated x) (@cons nested_imp (Decorated y k) NNil)), or (@In nested_imp (Undecorated x) (rev_app dni NNil)) (@In nested_imp (Undecorated x) NNil) *) (* Goal: or (@In nested_imp (Undecorated x) (rev_app dni NNil)) (@In nested_imp (Undecorated x) (@cons nested_imp (Decorated y k) NNil)) *) intros claim. (* Goal: or (@In nested_imp (Undecorated x) (rev_app dni NNil)) (@In nested_imp (Undecorated x) NNil) *) (* Goal: or (@In nested_imp (Undecorated x) (rev_app dni NNil)) (@In nested_imp (Undecorated x) (@cons nested_imp (Decorated y k) NNil)) *) elim claim; clear claim; intro claim. (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) left; assumption. (* Goal: or (@In nested_imp (Undecorated x) (rev_app dni NNil)) (@In nested_imp (Undecorated x) NNil) *) (* Goal: or (@In nested_imp (Undecorated x) (rev_app dni NNil)) (@In nested_imp (Undecorated x) (@cons nested_imp (Decorated y k) NNil)) *) right; inversion_clear claim. (* Goal: @In nested_imp (Undecorated x) NNil *) (* Goal: @In nested_imp (Undecorated x) NNil *) (* Goal: or (@In nested_imp (Undecorated x) (rev_app dni NNil)) (@In nested_imp (Undecorated x) (@cons nested_imp (Decorated y k) NNil)) *) discriminate H. (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) assumption. (* Goal: or (@In nested_imp (Undecorated x) (rev_app dni NNil)) (@In nested_imp (Undecorated x) (@cons nested_imp (Decorated y k) NNil)) *) apply in_app_or. (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) assumption. Qed. Remark nth_nimp__nth_nested_imp : forall (x : nimp) (n : nat) (ni : nested_imps), my_nth nimp n (nested_imps2nimps ni) x -> {y : nested_imp | my_nth nested_imp n ni y /\ nested_imp2nimp y = x}. (* Goal: forall (x : nimp) (n : nat) (ni : nested_imps) (_ : my_nth nimp n (nested_imps2nimps ni) x), @sig nested_imp (fun y : nested_imp => and (my_nth nested_imp n ni y) (@eq nimp (nested_imp2nimp y) x)) *) intros x n. (* Goal: forall (ni : nested_imps) (_ : my_nth nimp n (nested_imps2nimps ni) x), @sig nested_imp (fun y : nested_imp => and (my_nth nested_imp n ni y) (@eq nimp (nested_imp2nimp y) x)) *) elim n; clear n. (* Goal: forall (ni : nested_imps) (_ : my_nth nimp O (nested_imps2nimps ni) x), @sig nested_imp (fun y : nested_imp => and (my_nth nested_imp O ni y) (@eq nimp (nested_imp2nimp y) x)) *) (* Goal: forall (n : nat) (_ : forall (ni : nested_imps) (_ : my_nth nimp n (nested_imps2nimps ni) x), @sig nested_imp (fun y : nested_imp => and (my_nth nested_imp n ni y) (@eq nimp (nested_imp2nimp y) x))) (ni : nested_imps) (_ : my_nth nimp (S n) (nested_imps2nimps ni) x), @sig nested_imp (fun y : nested_imp => and (my_nth nested_imp (S n) ni y) (@eq nimp (nested_imp2nimp y) x)) *) intros ni; case ni; clear ni. (* Goal: forall _ : my_nth nimp (S n) (nested_imps2nimps (@nil nested_imp)) x, @sig nested_imp (fun y : nested_imp => and (my_nth nested_imp (S n) (@nil nested_imp) y) (@eq nimp (nested_imp2nimp y) x)) *) (* Goal: forall (n0 : nested_imp) (l : list nested_imp) (_ : my_nth nimp (S n) (nested_imps2nimps (@cons nested_imp n0 l)) x), @sig nested_imp (fun y : nested_imp => and (my_nth nested_imp (S n) (@cons nested_imp n0 l) y) (@eq nimp (nested_imp2nimp y) x)) *) intros nth; elimtype False; inversion_clear nth. (* Goal: forall (n : nested_imp) (l : list nested_imp) (_ : my_nth nimp O (nested_imps2nimps (@cons nested_imp n l)) x), @sig nested_imp (fun y : nested_imp => and (my_nth nested_imp O (@cons nested_imp n l) y) (@eq nimp (nested_imp2nimp y) x)) *) (* Goal: forall (n : nat) (_ : forall (ni : nested_imps) (_ : my_nth nimp n (nested_imps2nimps ni) x), @sig nested_imp (fun y : nested_imp => and (my_nth nested_imp n ni y) (@eq nimp (nested_imp2nimp y) x))) (ni : nested_imps) (_ : my_nth nimp (S n) (nested_imps2nimps ni) x), @sig nested_imp (fun y : nested_imp => and (my_nth nested_imp (S n) ni y) (@eq nimp (nested_imp2nimp y) x)) *) simpl in |- *; intros y ni nth. (* Goal: @sig nested_imp (fun y0 : nested_imp => and (my_nth nested_imp O (@cons nested_imp y ni) y0) (@eq nimp (nested_imp2nimp y0) x)) *) (* Goal: forall (n : nat) (_ : forall (ni : nested_imps) (_ : my_nth nimp n (nested_imps2nimps ni) x), @sig nested_imp (fun y : nested_imp => and (my_nth nested_imp n ni y) (@eq nimp (nested_imp2nimp y) x))) (ni : nested_imps) (_ : my_nth nimp (S n) (nested_imps2nimps ni) x), @sig nested_imp (fun y : nested_imp => and (my_nth nested_imp (S n) ni y) (@eq nimp (nested_imp2nimp y) x)) *) exists y. (* Goal: and (my_nth nested_imp (S n) (@cons nested_imp y ni) y') (@eq nimp (nested_imp2nimp y') x) *) (* Goal: my_nth nimp n (nested_imps2nimps ni) x *) split. (* Goal: my_nth nested_imp O (@cons nested_imp y ni) y *) (* Goal: @eq nimp (nested_imp2nimp y) x *) (* Goal: forall (n : nat) (_ : forall (ni : nested_imps) (_ : my_nth nimp n (nested_imps2nimps ni) x), @sig nested_imp (fun y : nested_imp => and (my_nth nested_imp n ni y) (@eq nimp (nested_imp2nimp y) x))) (ni : nested_imps) (_ : my_nth nimp (S n) (nested_imps2nimps ni) x), @sig nested_imp (fun y : nested_imp => and (my_nth nested_imp (S n) ni y) (@eq nimp (nested_imp2nimp y) x)) *) apply My_NthO. (* Goal: forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NDisj a0 a1)) *) (* Goal: forall (n : nat) (x : nimp) (_ : my_nth nimp n (nested_imps2nimps (rev_app dni NNil)) x), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NImp_NF x)) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (AImp i b)) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NAtom i)) *) (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) inversion_clear nth. (* Goal: @eq nimp (nested_imp2nimp y) (nested_imp2nimp y) *) (* Goal: forall (n : nat) (_ : forall (ni : nested_imps) (_ : my_nth nimp n (nested_imps2nimps ni) x), @sig nested_imp (fun y : nested_imp => and (my_nth nested_imp n ni y) (@eq nimp (nested_imp2nimp y) x))) (ni : nested_imps) (_ : my_nth nimp (S n) (nested_imps2nimps ni) x), @sig nested_imp (fun y : nested_imp => and (my_nth nested_imp (S n) ni y) (@eq nimp (nested_imp2nimp y) x)) *) trivial. (* Goal: forall (n : nat) (_ : forall (ni : nested_imps) (_ : my_nth nimp n (nested_imps2nimps ni) x), @sig nested_imp (fun y : nested_imp => and (my_nth nested_imp n ni y) (@eq nimp (nested_imp2nimp y) x))) (ni : nested_imps) (_ : my_nth nimp (S n) (nested_imps2nimps ni) x), @sig nested_imp (fun y : nested_imp => and (my_nth nested_imp (S n) ni y) (@eq nimp (nested_imp2nimp y) x)) *) intros n ih ni. (* Goal: forall _ : my_nth nimp (S n) (nested_imps2nimps ni) x, @sig nested_imp (fun y : nested_imp => and (my_nth nested_imp (S n) ni y) (@eq nimp (nested_imp2nimp y) x)) *) case ni; clear ni. (* Goal: forall _ : my_nth nimp (S n) (nested_imps2nimps (@nil nested_imp)) x, @sig nested_imp (fun y : nested_imp => and (my_nth nested_imp (S n) (@nil nested_imp) y) (@eq nimp (nested_imp2nimp y) x)) *) (* Goal: forall (n0 : nested_imp) (l : list nested_imp) (_ : my_nth nimp (S n) (nested_imps2nimps (@cons nested_imp n0 l)) x), @sig nested_imp (fun y : nested_imp => and (my_nth nested_imp (S n) (@cons nested_imp n0 l) y) (@eq nimp (nested_imp2nimp y) x)) *) intros nth; elimtype False; inversion_clear nth. (* Goal: forall (n0 : nested_imp) (l : list nested_imp) (_ : my_nth nimp (S n) (nested_imps2nimps (@cons nested_imp n0 l)) x), @sig nested_imp (fun y : nested_imp => and (my_nth nested_imp (S n) (@cons nested_imp n0 l) y) (@eq nimp (nested_imp2nimp y) x)) *) intros y ni nth. (* Goal: @sig nested_imp (fun y0 : nested_imp => and (my_nth nested_imp (S n) (@cons nested_imp y ni) y0) (@eq nimp (nested_imp2nimp y0) x)) *) elim (ih ni). (* Goal: forall (x0 : nested_imp) (_ : and (my_nth nested_imp n ni x0) (@eq nimp (nested_imp2nimp x0) x)), @sig nested_imp (fun y0 : nested_imp => and (my_nth nested_imp (S n) (@cons nested_imp y ni) y0) (@eq nimp (nested_imp2nimp y0) x)) *) (* Goal: my_nth nimp n (nested_imps2nimps ni) x *) intros y' nth'. (* Goal: @sig nested_imp (fun y0 : nested_imp => and (my_nth nested_imp (S n) (@cons nested_imp y ni) y0) (@eq nimp (nested_imp2nimp y0) x)) *) (* Goal: my_nth nimp n (nested_imps2nimps ni) x *) exists y'. (* Goal: and (my_nth nested_imp (S n) (@cons nested_imp y ni) y') (@eq nimp (nested_imp2nimp y') x) *) (* Goal: my_nth nimp n (nested_imps2nimps ni) x *) elim nth'; clear nth'; intros nth' eq. (* Goal: and (my_nth nested_imp (S n) (@cons nested_imp y ni) y') (@eq nimp (nested_imp2nimp y') x) *) (* Goal: my_nth nimp n (nested_imps2nimps ni) x *) split. (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) apply My_NthS; assumption. (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) assumption. (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) inversion_clear nth; assumption. Qed. (***********************************************************************) Lemma cons_counter_model : forall (i : Int) (dni : decorated_nested_imps) (ai : atomic_imps) (a : atoms), deco_sound nf_nil DNil (rev_app dni NNil) ai a -> a_ai_disj a ai -> a_goal_disj a i -> Cons_Counter_Model_Spec i (rev_app dni NNil) ai a. (* Goal: forall (i : Int) (dni : decorated_nested_imps) (ai : atomic_imps) (a : atoms) (_ : deco_sound nf_nil DNil (rev_app dni NNil) ai a) (_ : a_ai_disj a ai) (_ : a_goal_disj a i), Cons_Counter_Model_Spec i (rev_app dni NNil) ai a *) intros i dni ai a complete a_ai_disjunct a_goal_disj. (* Goal: Cons_Counter_Model_Spec i (rev_app dni NNil) ai a *) cut (Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil)))). (* Goal: forall _ : Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))), Cons_Counter_Model_Spec i (rev_app dni NNil) ai a *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) intro mon. (* Goal: Cons_Counter_Model_Spec i (rev_app dni NNil) ai a *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) exists (node atoms a (n2forest (rev_app dni NNil))). (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) (* Goal: forces_ngamma nf_nil DNil (rev_app dni NNil) ai a (node atoms a (n2forest (rev_app dni NNil))) *) (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) apply mon. (* Goal: forces_ngamma nf_nil DNil (rev_app dni NNil) ai a (node atoms a (n2forest (rev_app dni NNil))) *) (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) unfold forces_ngamma in |- *. (* Goal: forall (c : normal_form) (_ : in_ngamma nf_nil DNil (rev_app dni NNil) ai a c), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form c) *) (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) intros c in_c. (* Goal: forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form c) *) (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) elim in_c; clear in_c c. (* Goal: forall (n : nat) (c : normal_form) (_ : my_nth normal_form n nf_nil c), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form c) *) (* Goal: forall (n : nat) (i j : Int) (_ : my_nth disj n DNil (@pair Int Int i j)), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NDisj i j)) *) (* Goal: forall (n : nat) (x : nimp) (_ : my_nth nimp n (nested_imps2nimps (rev_app dni NNil)) x), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NImp_NF x)) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (AImp i b)) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NAtom i)) *) (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) intros n c nth. (* Goal: forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NDisj a0 a1)) *) (* Goal: forall (n : nat) (x : nimp) (_ : my_nth nimp n (nested_imps2nimps (rev_app dni NNil)) x), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NImp_NF x)) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (AImp i b)) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NAtom i)) *) (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) inversion_clear nth. (* Goal: forall (n : nat) (i j : Int) (_ : my_nth disj n DNil (@pair Int Int i j)), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NDisj i j)) *) (* Goal: forall (n : nat) (x : nimp) (_ : my_nth nimp n (nested_imps2nimps (rev_app dni NNil)) x), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NImp_NF x)) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (AImp i b)) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NAtom i)) *) (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) intros n a0 a1 nth. (* Goal: forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NDisj a0 a1)) *) (* Goal: forall (n : nat) (x : nimp) (_ : my_nth nimp n (nested_imps2nimps (rev_app dni NNil)) x), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NImp_NF x)) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (AImp i b)) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NAtom i)) *) (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) inversion_clear nth. (* Goal: forall (n : nat) (x : nimp) (_ : my_nth nimp n (nested_imps2nimps (rev_app dni NNil)) x), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NImp_NF x)) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (AImp i b)) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NAtom i)) *) (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) intros n x; case x; clear x. (* Goal: forall (i i0 : Int) (n0 : normal_form) (_ : my_nth nimp n (nested_imps2nimps (rev_app dni NNil)) (NImp i i0 n0)), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NImp_NF (NImp i i0 n0))) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (AImp i b)) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NAtom i)) *) (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) intros a0 a1 b nth. (* Goal: forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (AImp j b)) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NAtom i)) *) (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) simpl in |- *; apply forces_t_imp. (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) assumption. (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Imp (Atom a0) (Atom a1)), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form b) *) (* Goal: forall (k' : kripke_tree) (_ : In_Forest atoms k' (Succs (node atoms a (n2forest (rev_app dni NNil))))), forces_t k' (Imp (Imp (Atom a0) (Atom a1)) (nf2form b)) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (AImp i b)) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NAtom i)) *) (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) intros forces_a0a1. (* Goal: forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form b) *) (* Goal: forall (k' : kripke_tree) (_ : In_Forest atoms k' (Succs (node atoms a (n2forest (rev_app dni NNil))))), forces_t k' (Imp (Atom j) (nf2form b)) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NAtom i)) *) (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) elimtype False. (* Goal: False *) (* Goal: forall (k' : kripke_tree) (_ : In_Forest atoms k' (Succs (node atoms a (n2forest (rev_app dni NNil))))), forces_t k' (Imp (Imp (Atom a0) (Atom a1)) (nf2form b)) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (AImp i b)) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NAtom i)) *) (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) elim (nth_nimp__nth_nested_imp (NImp a0 a1 b) n (rev_app dni NNil) nth). (* Goal: forall (x : nested_imp) (_ : and (my_nth nested_imp n (rev_app dni NNil) x) (@eq nimp (nested_imp2nimp x) (NImp a0 a1 b))), False *) (* Goal: forall (k' : kripke_tree) (_ : In_Forest atoms k' (Succs (node atoms a (n2forest (rev_app dni NNil))))), forces_t k' (Imp (Imp (Atom a0) (Atom a1)) (nf2form b)) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (AImp i b)) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NAtom i)) *) (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) intros x; case x; clear x. (* Goal: forall (n0 : nimp) (_ : and (my_nth nested_imp n (rev_app dni NNil) (Undecorated n0)) (@eq nimp (nested_imp2nimp (Undecorated n0)) (NImp a0 a1 b))), False *) (* Goal: forall (n0 : nimp) (k : kripke_tree) (_ : and (my_nth nested_imp n (rev_app dni NNil) (Decorated n0 k)) (@eq nimp (nested_imp2nimp (Decorated n0 k)) (NImp a0 a1 b))), False *) (* Goal: forall (k' : kripke_tree) (_ : In_Forest atoms k' (Succs (node atoms a (n2forest (rev_app dni NNil))))), forces_t k' (Imp (Imp (Atom a0) (Atom a1)) (nf2form b)) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (AImp i b)) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NAtom i)) *) (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) intros x nth_x. (* Goal: False *) (* Goal: forall (n0 : nimp) (k : kripke_tree) (_ : and (my_nth nested_imp n (rev_app dni NNil) (Decorated n0 k)) (@eq nimp (nested_imp2nimp (Decorated n0 k)) (NImp a0 a1 b))), False *) (* Goal: forall (k' : kripke_tree) (_ : In_Forest atoms k' (Succs (node atoms a (n2forest (rev_app dni NNil))))), forces_t k' (Imp (Imp (Atom a0) (Atom a1)) (nf2form b)) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (AImp i b)) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NAtom i)) *) (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) apply all_ref_rev_app_nil with dni x. (* Goal: @In nested_imp (Decorated (NImp a0 a1 b) k) (rev_app dni NNil) *) (* Goal: forall (k' : kripke_tree) (_ : In_Forest atoms k' (Succs (node atoms a (n2forest (rev_app dni NNil))))), forces_t k' (Imp (Imp (Atom a0) (Atom a1)) (nf2form b)) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (AImp i b)) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NAtom i)) *) (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) apply nth_in with n. (* Goal: forall _ : False, False *) (* Goal: forall (a : decorated_nested_imp) (l : list decorated_nested_imp) (_ : forall _ : @In nested_imp (Undecorated x) (rev_app l NNil), False) (_ : @In nested_imp (Undecorated x) (rev_app (@cons decorated_nested_imp a l) NNil)), False *) elim nth_x; intros; assumption. (* Goal: forall (n0 : nimp) (k : kripke_tree) (_ : and (my_nth nested_imp n (rev_app dni NNil) (Decorated n0 k)) (@eq nimp (nested_imp2nimp (Decorated n0 k)) (NImp a0 a1 b))), False *) (* Goal: forall (k' : kripke_tree) (_ : In_Forest atoms k' (Succs (node atoms a (n2forest (rev_app dni NNil))))), forces_t k' (Imp (Imp (Atom a0) (Atom a1)) (nf2form b)) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (AImp i b)) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NAtom i)) *) (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) intros x k nth_x. (* Goal: False *) (* Goal: forall (k' : kripke_tree) (_ : In_Forest atoms k' (Succs (node atoms a (n2forest (rev_app dni NNil))))), forces_t k' (Imp (Imp (Atom a0) (Atom a1)) (nf2form b)) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (AImp i b)) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NAtom i)) *) (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) elim (complete k a0 a1 b). (* Goal: forall (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma nf_nil DNil (rev_app dni NNil) ai a k) (_ : forall _ : forces_t k (Imp (Atom a0) (Atom a1)), False), False *) (* Goal: @In nested_imp (Decorated (NImp a0 a1 b) k) (rev_app dni NNil) *) (* Goal: forall (k' : kripke_tree) (_ : In_Forest atoms k' (Succs (node atoms a (n2forest (rev_app dni NNil))))), forces_t k' (Imp (Imp (Atom a0) (Atom a1)) (nf2form b)) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (AImp i b)) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NAtom i)) *) (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) intros k_is_mon k_forces_ngamma k_notforces_a0a1. (* Goal: False *) (* Goal: @In nested_imp (Decorated (NImp a0 a1 b) k) (rev_app dni NNil) *) (* Goal: forall (k' : kripke_tree) (_ : In_Forest atoms k' (Succs (node atoms a (n2forest (rev_app dni NNil))))), forces_t k' (Imp (Imp (Atom a0) (Atom a1)) (nf2form b)) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (AImp i b)) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NAtom i)) *) (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) apply k_notforces_a0a1. (* Goal: forces_t k (Imp (Atom a0) (Atom a1)) *) (* Goal: @In nested_imp (Decorated (NImp a0 a1 b) k) (rev_app dni NNil) *) (* Goal: forall (k' : kripke_tree) (_ : In_Forest atoms k' (Succs (node atoms a (n2forest (rev_app dni NNil))))), forces_t k' (Imp (Imp (Atom a0) (Atom a1)) (nf2form b)) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (AImp i b)) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NAtom i)) *) (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) apply forces_t_mon with (node atoms a (n2forest (rev_app dni NNil))). (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) assumption. (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) assumption. (* Goal: Suc k (node atoms a (n2forest (rev_app dni NNil))) *) (* Goal: @In nested_imp (Decorated (NImp a0 a1 b) k) (rev_app dni NNil) *) (* Goal: forall (k' : kripke_tree) (_ : In_Forest atoms k' (Succs (node atoms a (n2forest (rev_app dni NNil))))), forces_t k' (Imp (Imp (Atom a0) (Atom a1)) (nf2form b)) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (AImp i b)) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NAtom i)) *) (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) apply cons_counter_model_suc with x. (* Goal: @In nested_imp (Decorated (NImp a0 a1 b) k) (rev_app dni NNil) *) (* Goal: forall (k' : kripke_tree) (_ : In_Forest atoms k' (Succs (node atoms a (n2forest (rev_app dni NNil))))), forces_t k' (Imp (Imp (Atom a0) (Atom a1)) (nf2form b)) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (AImp i b)) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NAtom i)) *) (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) apply nth_in with n. (* Goal: forall _ : False, False *) (* Goal: forall (a : decorated_nested_imp) (l : list decorated_nested_imp) (_ : forall _ : @In nested_imp (Undecorated x) (rev_app l NNil), False) (_ : @In nested_imp (Undecorated x) (rev_app (@cons decorated_nested_imp a l) NNil)), False *) elim nth_x; intros; assumption. (* Goal: @In nested_imp (Decorated (NImp a0 a1 b) k) (rev_app dni NNil) *) (* Goal: forall (k' : kripke_tree) (_ : In_Forest atoms k' (Succs (node atoms a (n2forest (rev_app dni NNil))))), forces_t k' (Imp (Imp (Atom a0) (Atom a1)) (nf2form b)) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (AImp i b)) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NAtom i)) *) (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) apply nth_in with n. (* Goal: my_nth nested_imp n (rev_app dni NNil) (Decorated (NImp a0 a1 b) k) *) (* Goal: forall (k' : kripke_tree) (_ : In_Forest atoms k' (Succs (node atoms a (n2forest (rev_app dni NNil))))), forces_t k' (Imp (Imp (Atom a0) (Atom a1)) (nf2form b)) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (AImp i b)) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NAtom i)) *) (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) elim nth_x; clear nth_x; intros nth_x eq. (* Goal: my_nth nested_imp n (rev_app dni NNil) (Decorated (NImp a0 a1 b) k) *) (* Goal: forall (k' : kripke_tree) (_ : In_Forest atoms k' (Succs (node atoms a (n2forest (rev_app dni NNil))))), forces_t k' (Imp (Imp (Atom a0) (Atom a1)) (nf2form b)) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (AImp i b)) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NAtom i)) *) (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) rewrite <- eq. (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) assumption. (* Goal: forall (k' : kripke_tree) (_ : In_Forest atoms k' (Succs (node atoms a (n2forest (rev_app dni NNil))))), forces_t k' (Imp (Atom j) (nf2form b)) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NAtom i)) *) (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) simpl in |- *. (* Goal: forall (k' : kripke_tree) (_ : In_Forest atoms k' (n2forest (rev_app dni NNil))), forces_t k' (Imp (Atom j) (nf2form b)) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NAtom i)) *) (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) intros k' in_k'. (* Goal: forces_t k' (Imp (Imp (Atom a0) (Atom a1)) (nf2form b)) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (AImp i b)) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NAtom i)) *) (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) change (forces_t k' (nf2form (NImp_NF (NImp a0 a1 b)))) in |- *. (* Goal: forces_t k' (nf2form (AImp j b)) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NAtom i)) *) (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) apply deco_sound_in_forest_forces with nf_nil DNil (rev_app dni NNil) ai a. (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) assumption. (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) assumption. (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) apply In_Nested_Imps with n; assumption. (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (AImp i b)) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NAtom i)) *) (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) intros j b n bs lookup_j nth. (* Goal: forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (AImp j b)) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NAtom i)) *) (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) simpl in |- *; apply forces_t_imp. (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) assumption. (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom j), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form b) *) (* Goal: forall (k' : kripke_tree) (_ : In_Forest atoms k' (Succs (node atoms a (n2forest (rev_app dni NNil))))), forces_t k' (Imp (Atom j) (nf2form b)) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NAtom i)) *) (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) intros forces_j. (* Goal: forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form b) *) (* Goal: forall (k' : kripke_tree) (_ : In_Forest atoms k' (Succs (node atoms a (n2forest (rev_app dni NNil))))), forces_t k' (Imp (Atom j) (nf2form b)) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NAtom i)) *) (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) elimtype False. (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) apply a_ai_disjunct with j bs; assumption. (* Goal: forall (k' : kripke_tree) (_ : In_Forest atoms k' (Succs (node atoms a (n2forest (rev_app dni NNil))))), forces_t k' (Imp (Atom j) (nf2form b)) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NAtom i)) *) (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) simpl in |- *. (* Goal: forall (k' : kripke_tree) (_ : In_Forest atoms k' (n2forest (rev_app dni NNil))), forces_t k' (Imp (Atom j) (nf2form b)) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NAtom i)) *) (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) intros k' in_k'. (* Goal: forces_t k' (Imp (Atom j) (nf2form b)) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NAtom i)) *) (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) change (forces_t k' (nf2form (AImp j b))) in |- *. (* Goal: forces_t k' (nf2form (AImp j b)) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NAtom i)) *) (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) apply deco_sound_in_forest_forces with nf_nil DNil (rev_app dni NNil) ai a. (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) assumption. (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) assumption. (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) apply In_Atomic_Imps with (i := j) (b := b) (n := n) (bs := bs); assumption. (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), forces_t (node atoms a (n2forest (rev_app dni NNil))) (nf2form (NAtom i)) *) (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) intros j lookup_j. (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) assumption. (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) assumption. (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) apply cons_counter_model_mon with ai; try assumption. (* Goal: forall (x : nimp) (_ : @In nested_imp (Undecorated x) (rev_app dni NNil)), False *) intros x in_x. (* Goal: forall _ : forces_t (node atoms a (n2forest (rev_app dni NNil))) (Atom i), False *) (* Goal: Is_Monotone_kripke_tree (node atoms a (n2forest (rev_app dni NNil))) *) apply all_ref_rev_app_nil with dni x; assumption. Qed.
(* File: Search.v (last edited on 27/10/2000) (c) Klaus Weich *) Require Export Rules. Require Export Weight. Definition vlist := list (list Int * form). Fixpoint vlist2list (gamma : vlist) : flist := match gamma with | nil => fnil | (l, a) :: gamma => vimp l a :: vlist2list gamma end. Fixpoint vlist2hlist (gamma : vlist) : flist := match gamma with | nil => fnil | (l, a) :: gamma => a :: vlist2hlist gamma end. Definition search_atom_invariant (n : nat) := forall (goal : Int) (gamma : vlist) (work : nf_list) (context : flist) (j : Int), weight_gamma (vlist2hlist gamma) < n -> search_spec (Atom goal) (vlist2list gamma) work context j. Lemma search_atom_aux : forall n : nat, search_atom_invariant n. (* Goal: forall (n : nat) (goal : form) (gamma : flist) (work : nf_list) (context : flist) (j : Int) (_ : lt (weight_goal goal) n), search_spec goal gamma work context j *) intros n; elim n; clear n. (* n=0 *) (* Goal: search_atom_invariant (S n) *) unfold search_atom_invariant in |- *. (* Goal: forall (goal : form) (gamma : flist) (work : nf_list) (context : flist) (j : Int) (_ : lt (weight_goal goal) O), search_spec goal gamma work context j *) (* Goal: forall (n : nat) (_ : forall (goal : form) (gamma : flist) (work : nf_list) (context : flist) (j : Int) (_ : lt (weight_goal goal) n), search_spec goal gamma work context j) (goal : form) (gamma : flist) (work : nf_list) (context : flist) (j : Int) (_ : lt (weight_goal goal) (S n)), search_spec goal gamma work context j *) intros goal gamma work context j lt_weight. (* Goal: search_spec goal gamma work context j *) (* Goal: forall (n : nat) (_ : forall (goal : form) (gamma : flist) (work : nf_list) (context : flist) (j : Int) (_ : lt (weight_goal goal) n), search_spec goal gamma work context j) (goal : form) (gamma : flist) (work : nf_list) (context : flist) (j : Int) (_ : lt (weight_goal goal) (S n)), search_spec goal gamma work context j *) elimtype False. (* Goal: False *) (* Goal: forall (n : nat) (_ : search_atom_invariant n), search_atom_invariant (S n) *) apply (lt_n_O (weight_gamma (vlist2hlist gamma))); assumption. (* n>0 *) (* Goal: forall (n : nat) (_ : search_atom_invariant n), search_atom_invariant (S n) *) intros n ih. (* Goal: search_atom_invariant (S n) *) unfold search_atom_invariant in |- *. (* Goal: forall (goal : form) (gamma : flist), search_spec goal gamma *) intros goal gamma. (* Goal: forall (work : nf_list) (context : flist) (j : Int) (_ : lt (weight_gamma (vlist2hlist gamma)) (S n)), search_spec (Atom goal) (vlist2list gamma) work context j *) case gamma; clear gamma. (* gamma=nil *) (* Goal: forall (work : nf_list) (context : flist) (j : Int) (_ : lt (weight_gamma (vlist2hlist (@nil (prod (list Int) form)))) (S n)), search_spec (Atom goal) (vlist2list (@nil (prod (list Int) form))) work context j *) (* Goal: forall (p : prod (list Int) form) (l : list (prod (list Int) form)) (work : nf_list) (context : flist) (j : Int) (_ : lt (weight_gamma (vlist2hlist (@cons (prod (list Int) form) p l))) (S n)), search_spec (Atom goal) (vlist2list (@cons (prod (list Int) form) p l)) work context j *) intros work context j lt_weight. (* Goal: search_spec (Atom goal) (vlist2list (@nil (prod (list Int) form))) work context j *) (* Goal: forall (p : prod (list Int) form) (l : list (prod (list Int) form)) (work : nf_list) (context : flist) (j : Int) (_ : lt (weight_gamma (vlist2hlist (@cons (prod (list Int) form) p l))) (S n)), search_spec (Atom goal) (vlist2list (@cons (prod (list Int) form) p l)) work context j *) unfold search_spec in |- *. (* Goal: forall (_ : below_form (Atom goal) j) (_ : below_list (vlist2list (@nil (prod (list Int) form))) j) (_ : below_list context j) (_ : sound (vlist2list (@nil (prod (list Int) form))) work context) (_ : minimal (vlist2list (@nil (prod (list Int) form))) work context), search_spec_aux (Atom goal) (vlist2list (@nil (prod (list Int) form))) work context *) (* Goal: forall (p : prod (list Int) form) (l : list (prod (list Int) form)) (work : nf_list) (context : flist) (j : Int) (_ : lt (weight_gamma (vlist2hlist (@cons (prod (list Int) form) p l))) (S n)), search_spec (Atom goal) (vlist2list (@cons (prod (list Int) form) p l)) work context j *) intros below_goal below_gamma below_context sound minimal. (* Goal: search_spec_aux (Atom goal) (vlist2list (@nil (prod (list Int) form))) work context *) (* Goal: forall (p : prod (list Int) form) (l : list (prod (list Int) form)) (work : nf_list) (context : flist) (j : Int) (_ : lt (weight_gamma (vlist2hlist (@cons (prod (list Int) form) p l))) (S n)), search_spec (Atom goal) (vlist2list (@cons (prod (list Int) form) p l)) work context j *) elim (nsearch goal work context). (* Goal: forall _ : Derivable gamma goal, search_spec goal gamma *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma gamma nf_nil k) (_ : forall _ : forces_t k goal, False), search_spec goal gamma *) (* Goal: below_form goal j *) (* Goal: below_list gamma j *) (* Goal: below_list gamma j *) (* Goal: sound gamma nf_nil gamma *) (* Goal: minimal gamma nf_nil gamma *) intros der; apply derivable; assumption. (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma work DNil NNil AI_Nil ANil k) (_ : forall _ : forces_t k (Atom goal), False), search_spec_aux (Atom goal) (vlist2list (@nil (prod (list Int) form))) work context *) (* Goal: forall (n : nat) (a : normal_form) (_ : my_nth normal_form n work a), Derivable context (nf2form a) *) (* Goal: forall (a : form) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forall (b : normal_form) (_ : @In normal_form b work), forces_t k (nf2form b)) (_ : @In form a context), forces_t k a *) (* Goal: forall (p : prod (list Int) form) (l : list (prod (list Int) form)) (work : nf_list) (context : flist) (j : Int) (_ : lt (weight_gamma (vlist2hlist (@cons (prod (list Int) form) p l))) (S n)), search_spec (Atom goal) (vlist2list (@cons (prod (list Int) form) p l)) work context j *) intros k k_is_mon k_forces_ngamma k_notforces_goal. (* Goal: search_spec goal gamma *) (* Goal: below_form goal j *) (* Goal: below_list gamma j *) (* Goal: below_list gamma j *) (* Goal: sound gamma nf_nil gamma *) (* Goal: minimal gamma nf_nil gamma *) apply refutable with k; try assumption. (* Goal: forces_gamma (vlist2list (@nil (prod (list Int) form))) work k *) (* Goal: forall (p : prod (list Int) form) (l : list (prod (list Int) form)) (work : nf_list) (context : flist) (j : Int) (_ : lt (weight_gamma (vlist2hlist (@cons (prod (list Int) form) p l))) (S n)), search_spec (Atom goal) (vlist2list (@cons (prod (list Int) form) p l)) work context j *) unfold forces_gamma in |- *. (* Goal: forall (a : form) (_ : in_gamma gamma nf_nil a), Derivable gamma a *) (* Goal: minimal gamma nf_nil gamma *) intros a in_a. (* Goal: Derivable gamma a *) (* Goal: minimal gamma nf_nil gamma *) elim in_a; clear in_a a. (* Goal: forall (n : nat) (a : form) (_ : my_nth form n (vlist2list (@nil (prod (list Int) form))) a), forces_t k a *) (* Goal: forall (n : nat) (a : normal_form) (_ : my_nth normal_form n work a), forces_t k (nf2form a) *) (* Goal: forall (n : nat) (a : normal_form) (_ : my_nth normal_form n work a), Derivable context (nf2form a) *) (* Goal: forall (a : form) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forall (b : normal_form) (_ : @In normal_form b work), forces_t k (nf2form b)) (_ : @In form a context), forces_t k a *) (* Goal: forall (p : prod (list Int) form) (l : list (prod (list Int) form)) (work : nf_list) (context : flist) (j : Int) (_ : lt (weight_gamma (vlist2hlist (@cons (prod (list Int) form) p l))) (S n)), search_spec (Atom goal) (vlist2list (@cons (prod (list Int) form) p l)) work context j *) intros m a nth; inversion_clear nth. (* Goal: forall (n : nat) (a : normal_form) (_ : my_nth normal_form n work a), forces_t k (nf2form a) *) (* Goal: forall (n : nat) (a : normal_form) (_ : my_nth normal_form n work a), Derivable context (nf2form a) *) (* Goal: forall (a : form) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forall (b : normal_form) (_ : @In normal_form b work), forces_t k (nf2form b)) (_ : @In form a context), forces_t k a *) (* Goal: forall (p : prod (list Int) form) (l : list (prod (list Int) form)) (work : nf_list) (context : flist) (j : Int) (_ : lt (weight_gamma (vlist2hlist (@cons (prod (list Int) form) p l))) (S n)), search_spec (Atom goal) (vlist2list (@cons (prod (list Int) form) p l)) work context j *) intros m a nth. (* Goal: forces_t k (nf2form a) *) (* Goal: forall (n : nat) (a : normal_form) (_ : my_nth normal_form n work a), Derivable context (nf2form a) *) (* Goal: forall (a : form) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forall (b : normal_form) (_ : @In normal_form b work), forces_t k (nf2form b)) (_ : @In form a context), forces_t k a *) (* Goal: forall (p : prod (list Int) form) (l : list (prod (list Int) form)) (work : nf_list) (context : flist) (j : Int) (_ : lt (weight_gamma (vlist2hlist (@cons (prod (list Int) form) p l))) (S n)), search_spec (Atom goal) (vlist2list (@cons (prod (list Int) form) p l)) work context j *) apply k_forces_ngamma. (* Goal: in_ngamma work DNil NNil AI_Nil ANil a *) (* Goal: forall (n : nat) (a : normal_form) (_ : my_nth normal_form n work a), Derivable context (nf2form a) *) (* Goal: forall (a : form) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forall (b : normal_form) (_ : @In normal_form b work), forces_t k (nf2form b)) (_ : @In form a context), forces_t k a *) (* Goal: forall (p : prod (list Int) form) (l : list (prod (list Int) form)) (work : nf_list) (context : flist) (j : Int) (_ : lt (weight_gamma (vlist2hlist (@cons (prod (list Int) form) p l))) (S n)), search_spec (Atom goal) (vlist2list (@cons (prod (list Int) form) p l)) work context j *) apply In_Work with m; assumption. (* side premisses: Elim (nsearch goal work context). *) (* Goal: forall (n : nat) (a : normal_form) (_ : my_nth normal_form n work a), Derivable context (nf2form a) *) (* Goal: forall (a : form) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forall (b : normal_form) (_ : @In normal_form b work), forces_t k (nf2form b)) (_ : @In form a context), forces_t k a *) (* Goal: forall (p : prod (list Int) form) (l : list (prod (list Int) form)) (work : nf_list) (context : flist) (j : Int) (_ : lt (weight_gamma (vlist2hlist (@cons (prod (list Int) form) p l))) (S n)), search_spec (Atom goal) (vlist2list (@cons (prod (list Int) form) p l)) work context j *) intros m a nth; apply sound; apply In_Work1 with m; assumption. (* Goal: forall (a : form) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forall (b : normal_form) (_ : @In normal_form b work), forces_t k (nf2form b)) (_ : @In form a context), forces_t k a *) (* Goal: forall (p : prod (list Int) form) (l : list (prod (list Int) form)) (work : nf_list) (context : flist) (j : Int) (_ : lt (weight_gamma (vlist2hlist (@cons (prod (list Int) form) p l))) (S n)), search_spec (Atom goal) (vlist2list (@cons (prod (list Int) form) p l)) work context j *) intros a k k_is_mon k_forces_work in_a. (* Goal: forces_t k a *) (* Goal: forall (p : prod (list Int) form) (l : list (prod (list Int) form)) (work : nf_list) (context : flist) (j : Int) (_ : lt (weight_gamma (vlist2hlist (@cons (prod (list Int) form) p l))) (S n)), search_spec (Atom goal) (vlist2list (@cons (prod (list Int) form) p l)) work context j *) apply minimal; try assumption. (* Goal: forces_gamma (vlist2list (@nil (prod (list Int) form))) work k *) (* Goal: forall (p : prod (list Int) form) (l : list (prod (list Int) form)) (work : nf_list) (context : flist) (j : Int) (_ : lt (weight_gamma (vlist2hlist (@cons (prod (list Int) form) p l))) (S n)), search_spec (Atom goal) (vlist2list (@cons (prod (list Int) form) p l)) work context j *) unfold forces_gamma in |- *. (* Goal: forall (a : form) (_ : in_gamma (vlist2list (@nil (prod (list Int) form))) work a), forces_t k a *) (* Goal: forall (p : prod (list Int) form) (l : list (prod (list Int) form)) (work : nf_list) (context : flist) (j : Int) (_ : lt (weight_gamma (vlist2hlist (@cons (prod (list Int) form) p l))) (S n)), search_spec (Atom goal) (vlist2list (@cons (prod (list Int) form) p l)) work context j *) intros c in_c. (* Goal: forces_t k c *) (* Goal: forall (p : prod (list Int) form) (l : list (prod (list Int) form)) (work : nf_list) (context : flist) (j : Int) (_ : lt (weight_gamma (vlist2hlist (@cons (prod (list Int) form) p l))) (S n)), search_spec (Atom goal) (vlist2list (@cons (prod (list Int) form) p l)) work context j *) elim in_c; clear in_c c. (* Goal: forall (n : nat) (a : form) (_ : my_nth form n (vlist2list (@nil (prod (list Int) form))) a), forces_t k a *) (* Goal: forall (n : nat) (a : normal_form) (_ : my_nth normal_form n work a), forces_t k (nf2form a) *) (* Goal: forall (p : prod (list Int) form) (l : list (prod (list Int) form)) (work : nf_list) (context : flist) (j : Int) (_ : lt (weight_gamma (vlist2hlist (@cons (prod (list Int) form) p l))) (S n)), search_spec (Atom goal) (vlist2list (@cons (prod (list Int) form) p l)) work context j *) intros m c nth; inversion_clear nth. (* Goal: forall (n : nat) (a : normal_form) (_ : my_nth normal_form n work a), forces_t k (nf2form a) *) (* Goal: forall (p : prod (list Int) form) (l : list (prod (list Int) form)) (work : nf_list) (context : flist) (j : Int) (_ : lt (weight_gamma (vlist2hlist (@cons (prod (list Int) form) p l))) (S n)), search_spec (Atom goal) (vlist2list (@cons (prod (list Int) form) p l)) work context j *) intros m c nth. (* Goal: forces_t k (nf2form c) *) (* Goal: forall (p : prod (list Int) form) (l : list (prod (list Int) form)) (work : nf_list) (context : flist) (j : Int) (_ : lt (weight_gamma (vlist2hlist (@cons (prod (list Int) form) p l))) (S n)), search_spec (Atom goal) (vlist2list (@cons (prod (list Int) form) p l)) work context j *) apply k_forces_work. (* Goal: @In normal_form c work *) (* Goal: forall (p : prod (list Int) form) (l : list (prod (list Int) form)) (work : nf_list) (context : flist) (j : Int) (_ : lt (weight_gamma (vlist2hlist (@cons (prod (list Int) form) p l))) (S n)), search_spec (Atom goal) (vlist2list (@cons (prod (list Int) form) p l)) work context j *) apply nth_in with m; assumption. (* gamma=(cons a gamma) *) (* Goal: forall (p : prod (list Int) form) (l : list (prod (list Int) form)) (work : nf_list) (context : flist) (j : Int) (_ : lt (weight_gamma (vlist2hlist (@cons (prod (list Int) form) p l))) (S n)), search_spec (Atom goal) (vlist2list (@cons (prod (list Int) form) p l)) work context j *) intros a gamma work context j. (* Goal: forall _ : lt (Nat.add (weight (Imp (Imp a b) c)) (weight_gamma (vlist2hlist gamma))) (S n), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp a b) c)) (vlist2list gamma)) work context j *) case a; clear a. (* Goal: forall (l : list Int) (f : form) (_ : lt (weight_gamma (vlist2hlist (@cons (prod (list Int) form) (@pair (list Int) form l f) gamma))) (S n)), search_spec (Atom goal) (vlist2list (@cons (prod (list Int) form) (@pair (list Int) form l f) gamma)) work context j *) intros l a. (* Goal: forall _ : lt (weight_gamma (vlist2hlist (@cons (prod (list Int) form) (@pair (list Int) form l a) gamma))) (S n), search_spec (Atom goal) (vlist2list (@cons (prod (list Int) form) (@pair (list Int) form l a) gamma)) work context j *) generalize l; clear l. (* Goal: @eq flist (@cons form a gamma) (vlist2list (list2vlist (@cons form a gamma))) *) simpl in |- *. (* Goal: forall (l : list Int) (_ : lt (Nat.add (weight a) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l a) (vlist2list gamma)) work context j *) elim a; clear a. (* a=Falsum *) (* Goal: forall (l : list Int) (_ : lt (Nat.add (weight Falsum) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l Falsum) (vlist2list gamma)) work context j *) (* Goal: forall (i : Int) (l : list Int) (_ : lt (Nat.add (weight (Atom i)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Atom i)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (AndF f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (AndF f f0)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (OrF f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF f f0)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp f f0)) (vlist2list gamma)) work context j *) intros l lt_weight. (* Goal: search_spec (Atom goal) (@cons form (vimp l Falsum) (vlist2list gamma)) work context j *) (* Goal: forall (i : Int) (l : list Int) (_ : lt (Nat.add (weight (Atom i)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Atom i)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (AndF f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (AndF f f0)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (OrF f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF f f0)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp f f0)) (vlist2list gamma)) work context j *) simpl in |- *; apply rule_shift_gamma_work with (a := NFalsum). (* Goal: search_spec g1 (@cons form g0 gamma) work (@cons form g0 context) j *) apply ih. (* Goal: lt (weight_goal g1) n *) apply lt_S_n; assumption. (* a=(Atom i) *) (* Goal: forall (i : Int) (l : list Int) (_ : lt (Nat.add (weight (Atom i)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Atom i)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (AndF f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (AndF f f0)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (OrF f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF f f0)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp f f0)) (vlist2list gamma)) work context j *) intros i l lt_weight. (* Goal: search_spec (Atom goal) (@cons form (vimp l (Atom i)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (AndF f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (AndF f f0)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (OrF f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF f f0)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp f f0)) (vlist2list gamma)) work context j *) apply rule_shift_gamma_work with (a := NAtom i). (* Goal: search_spec g1 (@cons form g0 gamma) work (@cons form g0 context) j *) apply ih. (* Goal: lt (weight_goal g1) n *) apply lt_S_n; assumption. (* a=(AndF a b) *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (AndF f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (AndF f f0)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (OrF f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF f f0)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp f f0)) (vlist2list gamma)) work context j *) intros a ih_a b ih_b l lt_weight. (* Goal: forall _ : lt (Nat.add (weight (OrF a b)) (weight_gamma (vlist2hlist gamma))) (S n), search_spec (Atom goal) (@cons form (vimp l (OrF a b)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp f f0)) (vlist2list gamma)) work context j *) clear ih_a ih_b. (* Goal: search_spec (Atom goal) (@cons form (vimp (@cons Int i1 l) (AndF a b)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (OrF f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF f f0)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp f f0)) (vlist2list gamma)) work context j *) case l; clear l. (* Goal: search_spec (Atom goal) (@cons form (vimp (@cons Int i1 (@nil Int)) (AndF a b)) (vlist2list gamma)) work context j *) (* Goal: forall (i : Int) (l : list Int), search_spec (Atom goal) (@cons form (vimp (@cons Int i1 (@cons Int i l)) (AndF a b)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (OrF f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF f f0)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp f f0)) (vlist2list gamma)) work context j *) apply rule_vimp_conj_gamma. (* Goal: search_spec (Atom goal) (@cons form (vimp (@nil Int) a) (@cons form (vimp (@nil Int) b) (vlist2list gamma))) work context j *) (* Goal: forall (i : Int) (l : list Int), search_spec (Atom goal) (@cons form (vimp (@cons Int i l) (AndF a b)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (OrF f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF f f0)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp f f0)) (vlist2list gamma)) work context j *) apply ih with (gamma := (nil, a) :: (nil, b) :: gamma). (* Goal: lt (weight_gamma (vlist2hlist (@cons (prod (list Int) form) (@pair (list Int) form (@cons Int j (@nil Int)) a) (@cons (prod (list Int) form) (@pair (list Int) form (@cons Int j (@nil Int)) b) gamma)))) n *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (OrF f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF f f0)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp f f0)) (vlist2list gamma)) work context j *) simpl in |- *; apply weight_gamma_weak2' with (AndF a b); try assumption. (* Goal: @eq flist (@cons form a gamma) (vlist2list (list2vlist (@cons form a gamma))) *) simpl in |- *. (* Goal: lt (weight_gamma (vlist2hlist (list2vlist gamma))) (S (weight_gamma (vlist2hlist (list2vlist gamma)))) *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (AndF f f0)) (S n)), search_spec (AndF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (OrF f f0)) (S n)), search_spec (OrF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) apply lt_n_Sn. (* Goal: forall (i : Int) (l : list Int), search_spec (Atom goal) (@cons form (vimp (@cons Int i l) (AndF a b)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (OrF f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF f f0)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp f f0)) (vlist2list gamma)) work context j *) intros i1 l. (* Goal: search_spec (Atom goal) (@cons form (vimp (@cons Int i1 l) (AndF a b)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (OrF f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF f f0)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp f f0)) (vlist2list gamma)) work context j *) case l; clear l. (* Goal: search_spec (Atom goal) (@cons form (vimp (@cons Int i1 (@nil Int)) (AndF a b)) (vlist2list gamma)) work context j *) (* Goal: forall (i : Int) (l : list Int), search_spec (Atom goal) (@cons form (vimp (@cons Int i1 (@cons Int i l)) (AndF a b)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (OrF f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF f f0)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp f f0)) (vlist2list gamma)) work context j *) apply rule_vimp_conj_gamma. (* Goal: search_spec (Atom goal) (@cons form (vimp (@cons Int i1 (@nil Int)) a) (@cons form (vimp (@cons Int i1 (@nil Int)) b) (vlist2list gamma))) work context j *) (* Goal: forall (i : Int) (l : list Int), search_spec (Atom goal) (@cons form (vimp (@cons Int i1 (@cons Int i l)) (AndF a b)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (OrF f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF f f0)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp f f0)) (vlist2list gamma)) work context j *) apply ih with (gamma := (i1 :: nil, a) :: (i1 :: nil, b) :: gamma). (* Goal: lt (weight_gamma (vlist2hlist (@cons (prod (list Int) form) (@pair (list Int) form (@cons Int j (@nil Int)) a) (@cons (prod (list Int) form) (@pair (list Int) form (@cons Int j (@nil Int)) b) gamma)))) n *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (OrF f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF f f0)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp f f0)) (vlist2list gamma)) work context j *) simpl in |- *; apply weight_gamma_weak2' with (AndF a b); try assumption. (* Goal: @eq flist (@cons form a gamma) (vlist2list (list2vlist (@cons form a gamma))) *) simpl in |- *. (* Goal: lt (weight_gamma (vlist2hlist (list2vlist gamma))) (S (weight_gamma (vlist2hlist (list2vlist gamma)))) *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (AndF f f0)) (S n)), search_spec (AndF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (OrF f f0)) (S n)), search_spec (OrF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) apply lt_n_Sn. (* Goal: forall (i : Int) (l : list Int), search_spec (Atom goal) (@cons form (vimp (@cons Int i1 (@cons Int i l)) (AndF a b)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (OrF f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF f f0)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp f f0)) (vlist2list gamma)) work context j *) intros i2 l. (* Goal: search_spec (OrF g0 g1) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) elim (int_succ j). (* Goal: forall (x : Int) (_ : Less j x), search_spec (OrF g0 g1) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) intros j1 less1. (* Goal: search_spec (Atom goal) (@cons form (vimp (@cons Int i1 (@cons Int i2 l)) (AndF a b)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (OrF f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF f f0)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp f f0)) (vlist2list gamma)) work context j *) apply rule_vimp_conj_gamma_new with j1; try assumption. (* Goal: search_spec (Atom goal) (@cons form (vimp (@cons Int j (@nil Int)) a) (@cons form (vimp (@cons Int j (@nil Int)) b) (vlist2list gamma))) (@cons normal_form (nvimp (@cons Int i1 (@cons Int i2 l)) (NAtom j)) work) (@cons form (vimp (@cons Int i1 (@cons Int i2 l)) (Atom j)) (@cons form (Imp (Atom j) (AndF a b)) context)) j1 *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (OrF f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF f f0)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp f f0)) (vlist2list gamma)) work context j *) apply ih with (gamma := (j :: nil, a) :: (j :: nil, b) :: gamma). (* Goal: lt (weight_gamma (vlist2hlist (@cons (prod (list Int) form) (@pair (list Int) form (@cons Int j (@nil Int)) a) (@cons (prod (list Int) form) (@pair (list Int) form (@cons Int j (@nil Int)) b) gamma)))) n *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (OrF f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF f f0)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp f f0)) (vlist2list gamma)) work context j *) simpl in |- *; apply weight_gamma_weak2' with (AndF a b); try assumption. (* Goal: @eq flist (@cons form a gamma) (vlist2list (list2vlist (@cons form a gamma))) *) simpl in |- *. (* Goal: lt (weight_gamma (vlist2hlist (list2vlist gamma))) (S (weight_gamma (vlist2hlist (list2vlist gamma)))) *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (AndF f f0)) (S n)), search_spec (AndF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (OrF f f0)) (S n)), search_spec (OrF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) apply lt_n_Sn. (* --------- a=(OrF a b) ---------- *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (OrF f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF f f0)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp f f0)) (vlist2list gamma)) work context j *) intros a ih_a b ih_b l. (* Goal: forall _ : lt (Nat.add (weight (OrF a b)) (weight_gamma (vlist2hlist gamma))) (S n), search_spec (Atom goal) (@cons form (vimp l (OrF a b)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp f f0)) (vlist2list gamma)) work context j *) clear ih_a ih_b. (* Goal: forall _ : lt (Nat.add (weight (Imp (Imp a b) c)) (weight_gamma (vlist2hlist gamma))) (S n), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp a b) c)) (vlist2list gamma)) work context j *) case a; clear a. (* a=Falsum *) (* Goal: forall _ : lt (weight_goal Falsum) (S n), search_spec Falsum gamma work context j *) (* Goal: forall (i : Int) (_ : lt (weight_goal (Atom i)) (S n)), search_spec (Atom i) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (AndF f f0)) (S n)), search_spec (AndF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (OrF f f0)) (S n)), search_spec (OrF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) intros lt_weight. (* Goal: search_spec (Atom goal) (@cons form (vimp l (OrF Falsum b)) (vlist2list gamma)) work context j *) (* Goal: forall (i : Int) (_ : lt (Nat.add (weight (OrF (Atom i) b)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (Atom i) b)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (OrF (AndF f f0) b)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (AndF f f0) b)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (OrF (OrF f f0) b)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (OrF f f0) b)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (OrF (Imp f f0) b)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (Imp f f0) b)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp f f0)) (vlist2list gamma)) work context j *) apply rule_vimp_falsum_or_a_gamma. (* Goal: search_spec (Atom goal) (@cons form (vimp l b) (vlist2list gamma)) work context j *) (* Goal: forall (i : Int) (_ : lt (Nat.add (weight (OrF (Atom i) b)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (Atom i) b)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (OrF (AndF f f0) b)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (AndF f f0) b)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (OrF (OrF f f0) b)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (OrF f f0) b)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (OrF (Imp f f0) b)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (Imp f f0) b)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp f f0)) (vlist2list gamma)) work context j *) apply ih with (gamma := (l, b) :: gamma). (* Goal: lt (weight_gamma (vlist2hlist (@cons (prod (list Int) form) (@pair (list Int) form l b) gamma))) n *) (* Goal: forall (i : Int) (_ : lt (Nat.add (weight (OrF (Atom i) b)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (Atom i) b)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (OrF (AndF f f0) b)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (AndF f f0) b)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (OrF (OrF f f0) b)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (OrF f f0) b)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (OrF (Imp f f0) b)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (Imp f f0) b)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp f f0)) (vlist2list gamma)) work context j *) simpl in |- *; apply weight_gamma_weak' with (OrF Falsum b); try assumption. (* Goal: @eq flist (@cons form a gamma) (vlist2list (list2vlist (@cons form a gamma))) *) simpl in |- *. (* Goal: lt (weight_gamma (vlist2hlist (list2vlist gamma))) (S (weight_gamma (vlist2hlist (list2vlist gamma)))) *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (AndF f f0)) (S n)), search_spec (AndF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (OrF f f0)) (S n)), search_spec (OrF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) apply lt_n_Sn. (* a=(Atom i0) *) (* Goal: forall (i : Int) (_ : lt (Nat.add (weight (Imp (Imp (Atom i) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) intros i0. (* Goal: forall _ : lt (Nat.add (weight (Imp (Imp (Atom i0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) case b; clear b. (* b=Falsum *) (* Goal: forall _ : lt (weight_goal Falsum) (S n), search_spec Falsum gamma work context j *) (* Goal: forall (i : Int) (_ : lt (weight_goal (Atom i)) (S n)), search_spec (Atom i) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (AndF f f0)) (S n)), search_spec (AndF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (OrF f f0)) (S n)), search_spec (OrF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) intros lt_weight. (* Goal: search_spec (Atom goal) (@cons form (vimp l (OrF (Atom i0) Falsum)) (vlist2list gamma)) work context j *) (* Goal: forall (i : Int) (_ : lt (Nat.add (weight (OrF (Atom i0) (Atom i))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (Atom i0) (Atom i))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (OrF (Atom i0) (AndF f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (Atom i0) (AndF f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (OrF (Atom i0) (OrF f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (Atom i0) (OrF f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (OrF (Atom i0) (Imp f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (Atom i0) (Imp f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (OrF (AndF f f0) b)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (AndF f f0) b)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (OrF (OrF f f0) b)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (OrF f f0) b)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (OrF (Imp f f0) b)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (Imp f f0) b)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp f f0)) (vlist2list gamma)) work context j *) apply rule_vimp_a_or_falsum_gamma. (* Goal: search_spec (Atom goal) (@cons form (vimp l (Atom i0)) (vlist2list gamma)) work context j *) (* Goal: forall (i : Int) (_ : lt (Nat.add (weight (OrF (Atom i0) (Atom i))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (Atom i0) (Atom i))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (OrF (Atom i0) (AndF f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (Atom i0) (AndF f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (OrF (Atom i0) (OrF f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (Atom i0) (OrF f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (OrF (Atom i0) (Imp f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (Atom i0) (Imp f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (OrF (AndF f f0) b)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (AndF f f0) b)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (OrF (OrF f f0) b)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (OrF f f0) b)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (OrF (Imp f f0) b)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (Imp f f0) b)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp f f0)) (vlist2list gamma)) work context j *) apply ih with (gamma := (l, Atom i0) :: gamma). apply (weight_gamma_weak' (Atom i0) (OrF (Atom i0) Falsum) (vlist2hlist gamma)); (* Goal: lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (AndF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (AndF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (OrF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) try assumption. (* Goal: @eq flist (@cons form a gamma) (vlist2list (list2vlist (@cons form a gamma))) *) simpl in |- *. (* Goal: lt (weight_gamma (vlist2hlist (list2vlist gamma))) (S (weight_gamma (vlist2hlist (list2vlist gamma)))) *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (AndF f f0)) (S n)), search_spec (AndF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (OrF f f0)) (S n)), search_spec (OrF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) apply lt_n_Sn. (* b=(Atom i1) *) (* Goal: forall (i : Int) (_ : lt (Nat.add (weight (OrF (Atom i0) (Atom i))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (Atom i0) (Atom i))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (OrF (Atom i0) (AndF f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (Atom i0) (AndF f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (OrF (Atom i0) (OrF f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (Atom i0) (OrF f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (OrF (Atom i0) (Imp f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (Atom i0) (Imp f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (OrF (AndF f f0) b)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (AndF f f0) b)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (OrF (OrF f f0) b)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (OrF f f0) b)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (OrF (Imp f f0) b)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (Imp f f0) b)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp f f0)) (vlist2list gamma)) work context j *) intros i1 lt_weight. (* Goal: search_spec (Atom goal) (@cons form (vimp l (OrF (Atom i0) (Atom i1))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (OrF (Atom i0) (AndF f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (Atom i0) (AndF f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (OrF (Atom i0) (OrF f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (Atom i0) (OrF f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (OrF (Atom i0) (Imp f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (Atom i0) (Imp f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (OrF (AndF f f0) b)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (AndF f f0) b)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (OrF (OrF f f0) b)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (OrF f f0) b)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (OrF (Imp f f0) b)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (Imp f f0) b)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp f f0)) (vlist2list gamma)) work context j *) apply rule_shift_gamma_work with (a := NDisj i0 i1). (* Goal: search_spec g1 (@cons form g0 gamma) work (@cons form g0 context) j *) apply ih. (* Goal: lt (weight_gamma (vlist2hlist gamma)) n *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Atom i1)) (AndF f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Atom i1)) (AndF f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Atom i1)) (OrF f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Atom i1)) (OrF f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Atom i1)) (Imp f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Atom i1)) (Imp f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (AndF f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (AndF f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (OrF f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (OrF f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Imp f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Imp f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) apply my_lt_weak. (* Goal: lt (weight_goal g1) n *) apply lt_S_n; assumption. (* b=(AndF b0 b1) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Imp f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Imp f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) intros b0 b1 lt_weight. (* Goal: search_spec (OrF g0 g1) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) elim (int_succ j). (* Goal: forall (x : Int) (_ : Less j x), search_spec (OrF g0 g1) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) intros j1 less1. (* Goal: search_spec (Atom goal) (@cons form (vimp l (OrF (Atom i0) (Imp b0 b1))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (OrF (AndF f f0) b)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (AndF f f0) b)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (OrF (OrF f f0) b)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (OrF f f0) b)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (OrF (Imp f f0) b)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (Imp f f0) b)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp f f0)) (vlist2list gamma)) work context j *) apply rule_vimp_atom_or_a_gamma with j1; try assumption. (* Goal: search_spec (Atom goal) (@cons form (Imp (Atom j) (AndF b0 b1)) (vlist2list gamma)) (@cons normal_form (nvimp l (NDisj i0 j)) work) (@cons form (vimp l (OrF (Atom i0) (Atom j))) (@cons form (Imp (Atom j) (AndF b0 b1)) context)) j1 *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (OrF (Atom i0) (OrF f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (Atom i0) (OrF f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (OrF (Atom i0) (Imp f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (Atom i0) (Imp f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (OrF (AndF f f0) b)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (AndF f f0) b)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (OrF (OrF f f0) b)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (OrF f f0) b)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (OrF (Imp f f0) b)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (Imp f f0) b)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp f f0)) (vlist2list gamma)) work context j *) apply ih with (gamma := (j :: nil, AndF b0 b1) :: gamma). (* Goal: lt (weight_goal g1) n *) simpl in |- *; apply lt_S_n; assumption. (* b=(OrF b0 b1) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Imp f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Imp f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) intros b0 b1 lt_weight. (* Goal: search_spec (OrF g0 g1) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) elim (int_succ j). (* Goal: forall (x : Int) (_ : Less j x), search_spec (OrF g0 g1) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) intros j1 less1. (* Goal: search_spec (Atom goal) (@cons form (vimp l (OrF (Atom i0) (Imp b0 b1))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (OrF (AndF f f0) b)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (AndF f f0) b)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (OrF (OrF f f0) b)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (OrF f f0) b)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (OrF (Imp f f0) b)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (Imp f f0) b)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp f f0)) (vlist2list gamma)) work context j *) apply rule_vimp_atom_or_a_gamma with j1; try assumption. (* Goal: search_spec (Atom goal) (@cons form (Imp (Atom j) (OrF b0 b1)) (vlist2list gamma)) (@cons normal_form (nvimp l (NDisj i0 j)) work) (@cons form (vimp l (OrF (Atom i0) (Atom j))) (@cons form (Imp (Atom j) (OrF b0 b1)) context)) j1 *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (OrF (Atom i0) (Imp f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (Atom i0) (Imp f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (OrF (AndF f f0) b)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (AndF f f0) b)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (OrF (OrF f f0) b)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (OrF f f0) b)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (OrF (Imp f f0) b)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (Imp f f0) b)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp f f0)) (vlist2list gamma)) work context j *) apply ih with (gamma := (j :: nil, OrF b0 b1) :: gamma). (* Goal: lt (weight_goal g1) n *) simpl in |- *; apply lt_S_n; assumption. (* b=(Imp b0 b1) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Imp f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Imp f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) intros b0 b1 lt_weight. (* Goal: search_spec (OrF g0 g1) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) elim (int_succ j). (* Goal: forall (x : Int) (_ : Less j x), search_spec (OrF g0 g1) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) intros j1 less1. (* Goal: search_spec (Atom goal) (@cons form (vimp l (OrF (Atom i0) (Imp b0 b1))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (OrF (AndF f f0) b)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (AndF f f0) b)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (OrF (OrF f f0) b)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (OrF f f0) b)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (OrF (Imp f f0) b)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (Imp f f0) b)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp f f0)) (vlist2list gamma)) work context j *) apply rule_vimp_atom_or_a_gamma with j1; try assumption. (* Goal: search_spec (Atom goal) (@cons form (Imp (Atom j) (Imp b0 b1)) (vlist2list gamma)) (@cons normal_form (nvimp l (NDisj i0 j)) work) (@cons form (vimp l (OrF (Atom i0) (Atom j))) (@cons form (Imp (Atom j) (Imp b0 b1)) context)) j1 *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (OrF (AndF f f0) b)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (AndF f f0) b)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (OrF (OrF f f0) b)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (OrF f f0) b)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (OrF (Imp f f0) b)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (OrF (Imp f f0) b)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp f f0)) (vlist2list gamma)) work context j *) apply ih with (gamma := (j :: nil, Imp b0 b1) :: gamma). (* Goal: lt (weight_goal g1) n *) simpl in |- *; apply lt_S_n; assumption. (* a=(AndF a0 a0) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) intros a0 a1 lt_weight. (* Goal: search_spec (OrF g0 g1) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) elim (int_succ j). (* Goal: forall (x : Int) (_ : Less j x), search_spec (OrF g0 g1) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) intros j1 less1. (* Goal: search_spec (Atom goal) (@cons form (vimp l (OrF (Imp a0 a1) b)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp f f0)) (vlist2list gamma)) work context j *) apply rule_vimp_a_or_b_gamma with j1; try assumption. apply ih with (gamma := (l, OrF (Atom j) b) :: (j :: nil, AndF a0 a1) :: gamma). apply (weight_gamma_weak2' (OrF (Atom j) b) (AndF a0 a1) (* Goal: lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (AndF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (AndF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (OrF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) (OrF (AndF a0 a1) b) (vlist2hlist gamma)); try assumption. (* Goal: lt (weight_gamma (vlist2hlist (list2vlist gamma))) (S (weight_gamma (vlist2hlist (list2vlist gamma)))) *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (AndF f f0)) (S n)), search_spec (AndF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (OrF f f0)) (S n)), search_spec (OrF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) simpl in |- *; apply lt_n_Sn. (* a=(OrF a0 a1) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) intros a0 a1 lt_weight. (* Goal: search_spec (OrF g0 g1) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) elim (int_succ j). (* Goal: forall (x : Int) (_ : Less j x), search_spec (OrF g0 g1) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) intros j1 less1. (* Goal: search_spec (Atom goal) (@cons form (vimp l (OrF (Imp a0 a1) b)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp f f0)) (vlist2list gamma)) work context j *) apply rule_vimp_a_or_b_gamma with j1; try assumption. apply ih with (gamma := (l, OrF (Atom j) b) :: (j :: nil, OrF a0 a1) :: gamma). apply (weight_gamma_weak2' (OrF (Atom j) b) (OrF a0 a1) (* Goal: lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (AndF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (AndF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (OrF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) (OrF (OrF a0 a1) b) (vlist2hlist gamma)); try assumption. (* Goal: lt (weight_gamma (vlist2hlist (list2vlist gamma))) (S (weight_gamma (vlist2hlist (list2vlist gamma)))) *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (AndF f f0)) (S n)), search_spec (AndF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (OrF f f0)) (S n)), search_spec (OrF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) simpl in |- *; apply lt_n_Sn. (* a=(Imp a0 a1) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) intros a0 a1 lt_weight. (* Goal: search_spec (OrF g0 g1) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) elim (int_succ j). (* Goal: forall (x : Int) (_ : Less j x), search_spec (OrF g0 g1) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) intros j1 less1. (* Goal: search_spec (Atom goal) (@cons form (vimp l (OrF (Imp a0 a1) b)) (vlist2list gamma)) work context j *) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp f f0)) (vlist2list gamma)) work context j *) apply rule_vimp_a_or_b_gamma with j1; try assumption. apply ih with (gamma := (l, OrF (Atom j) b) :: (j :: nil, Imp a0 a1) :: gamma). apply (weight_gamma_weak2' (OrF (Atom j) b) (Imp a0 a1) (* Goal: lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (AndF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (AndF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (OrF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) (OrF (Imp a0 a1) b) (vlist2hlist gamma)); try assumption. (* Goal: lt (weight_gamma (vlist2hlist (list2vlist gamma))) (S (weight_gamma (vlist2hlist (list2vlist gamma)))) *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (AndF f f0)) (S n)), search_spec (AndF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (OrF f f0)) (S n)), search_spec (OrF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) simpl in |- *; apply lt_n_Sn. (******************* a=(Imp a c) *****************************) (* Goal: forall (f : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f) (vlist2list gamma)) work context j) (f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight f0) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l f0) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp f f0)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp f f0)) (vlist2list gamma)) work context j *) intros a ih_a c; clear ih_a. (* Goal: forall _ : lt (Nat.add (weight (Imp (Imp a b) c)) (weight_gamma (vlist2hlist gamma))) (S n), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp a b) c)) (vlist2list gamma)) work context j *) case a; clear a. (* a=Falsum *) (* Goal: forall (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp Falsum c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp Falsum c)) (vlist2list gamma)) work context j *) (* Goal: forall (i : Int) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Atom i) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Atom i) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (AndF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (AndF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (OrF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) intros ih_c l lt_weight. (* Goal: search_spec (Atom goal) (@cons form (vimp l (Imp Falsum c)) (vlist2list gamma)) work context j *) (* Goal: forall (i : Int) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Atom i) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Atom i) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (AndF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (AndF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (OrF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) apply rule_vimp_falsum_imp_b_gamma. (* Goal: search_spec g1 (@cons form g0 gamma) work (@cons form g0 context) j *) apply ih. (* Goal: lt (weight_gamma (vlist2hlist gamma)) n *) (* Goal: forall (i : Int) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Atom i) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Atom i) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (AndF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (AndF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (OrF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) apply lt_S_n. apply le_lt_trans with (weight (Imp Falsum c) + weight_gamma (vlist2hlist gamma)); (* Goal: lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (AndF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (AndF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (OrF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) try assumption. (* Goal: @eq flist (@cons form a gamma) (vlist2list (list2vlist (@cons form a gamma))) *) simpl in |- *. (* Goal: le (S (weight_gamma (vlist2hlist gamma))) (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) *) (* Goal: forall (i : Int) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Atom i) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Atom i) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (AndF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (AndF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (OrF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) apply (plus_le_compat_r 1 (weight c) (weight_gamma (vlist2hlist gamma))). (* Goal: le (S O) (weight c) *) (* Goal: forall (i : Int) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Atom i) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Atom i) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (AndF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (AndF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (OrF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) apply weight_ge_1. (* a=(Atom i0) *) (* Goal: forall (i : Int) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Atom i) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Atom i) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (AndF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (AndF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (OrF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) intros i0 ih_c l lt_weight. (* Goal: search_spec (Atom goal) (@cons form (vimp l (Imp (Atom i0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (AndF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (AndF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (OrF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) apply rule_vimp_atom_imp_b_gamma. (* Goal: search_spec (Atom goal) (@cons form (vimp (@cons Int i0 l) c) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (AndF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (AndF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (OrF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) apply ih_c. (* Goal: lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (AndF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (AndF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (OrF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) assumption. (* a=(Imp a b) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (AndF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (AndF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (OrF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) intros a b ih_c l lt_weight; clear ih_c. (* Goal: search_spec (Atom goal) (@cons form (vimp l (Imp (AndF a b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (OrF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) apply rule_vimp_and_imp_gamma. (* Goal: search_spec (Atom goal) (@cons form (vimp l (Imp a (Imp b c))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (OrF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) apply ih with (gamma := (l, Imp a (Imp b c)) :: gamma). apply (weight_gamma_weak' (Imp a (Imp b c)) (Imp (AndF a b) c) (vlist2hlist gamma)); (* Goal: lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (AndF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (AndF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (OrF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) try assumption. (* Goal: lt (Nat.add (weight c) (S (S (S (Nat.add (S (Nat.add (weight_neg b0) (weight_neg b1))) O))))) (S (S (S (S (S (Nat.add (Nat.add (weight_neg b0) (weight_neg b1)) (weight c))))))) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Imp f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Imp f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) simpl in |- *; fold weight_neg in |- *. (* Goal: lt (Nat.add (weight_neg a) (Nat.add (weight_neg b) (S O))) (S (Nat.add (Nat.add (weight_neg a) (weight_neg b)) (S O))) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (OrF a b) (AndF f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF a b) (AndF f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (OrF a b) (OrF f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF a b) (OrF f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (OrF a b) (Imp f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF a b) (Imp f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) apply lt_plus_assoc_l. (* Goal: lt (weight_gamma (vlist2hlist (list2vlist gamma))) (S (weight_gamma (vlist2hlist (list2vlist gamma)))) *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (AndF f f0)) (S n)), search_spec (AndF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (OrF f f0)) (S n)), search_spec (OrF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) apply lt_n_Sn. (* a=(OrF a b) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) intros a b ih_c l; clear ih_c. (* Goal: forall _ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Atom i1)) c)) (weight_gamma (vlist2hlist gamma))) (S n), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Atom i1)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (AndF f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (AndF f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (OrF f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (OrF f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Imp f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Imp f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) case c; clear c. (* c=Falsum *) (* Goal: forall _ : lt (weight_goal Falsum) (S n), search_spec Falsum gamma work context j *) (* Goal: forall (i : Int) (_ : lt (weight_goal (Atom i)) (S n)), search_spec (Atom i) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (AndF f f0)) (S n)), search_spec (AndF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (OrF f f0)) (S n)), search_spec (OrF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) intros lt_weight. (* Goal: search_spec (Atom goal) (@cons form (vimp l (Imp (OrF a b) (Atom i))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (OrF a b) (AndF f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF a b) (AndF f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (OrF a b) (OrF f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF a b) (OrF f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (OrF a b) (Imp f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF a b) (Imp f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) apply rule_vimp_or_imp_gamma. (* Goal: search_spec (Atom goal) (@cons form (vimp l (Imp a Falsum)) (@cons form (vimp l (Imp b Falsum)) (vlist2list gamma))) work context j *) (* Goal: forall (i : Int) (_ : lt (Nat.add (weight (Imp (OrF a b) (Atom i))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF a b) (Atom i))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (OrF a b) (AndF f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF a b) (AndF f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (OrF a b) (OrF f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF a b) (OrF f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (OrF a b) (Imp f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF a b) (Imp f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) apply ih with (gamma := (l, Imp a Falsum) :: (l, Imp b Falsum) :: gamma). apply (weight_gamma_weak2' (Imp a Falsum) (Imp b Falsum) (* Goal: lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (AndF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (AndF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (OrF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) (Imp (OrF a b) Falsum) (vlist2hlist gamma)); try assumption. (* Goal: lt (Nat.add (weight c) (S (S (S (Nat.add (S (Nat.add (weight_neg b0) (weight_neg b1))) O))))) (S (S (S (S (S (Nat.add (Nat.add (weight_neg b0) (weight_neg b1)) (weight c))))))) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Imp f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Imp f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) simpl in |- *; fold weight_neg in |- *. (* Goal: lt (weight_gamma (vlist2hlist gamma)) n *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Atom i1)) (AndF f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Atom i1)) (AndF f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Atom i1)) (OrF f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Atom i1)) (OrF f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Atom i1)) (Imp f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Atom i1)) (Imp f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (AndF f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (AndF f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (OrF f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (OrF f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Imp f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Imp f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) apply my_lt_weak. (* Goal: lt (S (PeanoNat.Nat.add m (weight c))) (S (S (Nat.add m (weight c)))) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) apply lt_n_S. (* Goal: lt (Nat.add (Nat.add (Nat.add (weight_neg a) (S O)) (Nat.add (weight_neg b) (S O))) (Nat.add (weight_neg c0) (weight c1))) (S (S (S (Nat.add (Nat.add (weight_neg a) (weight_neg b)) (Nat.add (weight_neg c0) (weight c1)))))) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) rewrite <- (plus_Snm_nSm (weight_neg a) 0). (* Goal: @eq flist (@cons form a gamma) (vlist2list (list2vlist (@cons form a gamma))) *) simpl in |- *. (* Goal: lt (S (PeanoNat.Nat.add m (weight c))) (S (S (Nat.add m (weight c)))) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) apply lt_n_S. (* Goal: lt (Nat.add (Nat.add (Nat.add (weight_neg a) O) (Nat.add (weight_neg b) (S O))) (Nat.add (weight_neg c0) (weight c1))) (S (S (Nat.add (Nat.add (weight_neg a) (weight_neg b)) (Nat.add (weight_neg c0) (weight c1))))) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) rewrite (plus_O (weight_neg a)). (* Goal: lt (Nat.add (weight_neg a) (Nat.add (weight_neg b) (S O))) (S (Nat.add (Nat.add (weight_neg a) (weight_neg b)) (S O))) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (OrF a b) (AndF f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF a b) (AndF f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (OrF a b) (OrF f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF a b) (OrF f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (OrF a b) (Imp f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF a b) (Imp f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) apply lt_plus_assoc_l. (* Goal: lt (weight_gamma (vlist2hlist (list2vlist gamma))) (S (weight_gamma (vlist2hlist (list2vlist gamma)))) *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (AndF f f0)) (S n)), search_spec (AndF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (OrF f f0)) (S n)), search_spec (OrF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) apply lt_n_Sn. (* c=(Atom i) *) (* Goal: forall (i : Int) (_ : lt (weight_goal (Atom i)) (S n)), search_spec (Atom i) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (AndF f f0)) (S n)), search_spec (AndF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (OrF f f0)) (S n)), search_spec (OrF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) intros i lt_weight. (* Goal: search_spec (Atom goal) (@cons form (vimp l (Imp (OrF a b) (Atom i))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (OrF a b) (AndF f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF a b) (AndF f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (OrF a b) (OrF f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF a b) (OrF f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (OrF a b) (Imp f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF a b) (Imp f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) apply rule_vimp_or_imp_gamma. (* Goal: search_spec (Atom goal) (@cons form (vimp l (Imp a (Atom i))) (@cons form (vimp l (Imp b (Atom i))) (vlist2list gamma))) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (OrF a b) (AndF f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF a b) (AndF f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (OrF a b) (OrF f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF a b) (OrF f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (OrF a b) (Imp f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF a b) (Imp f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) apply ih with (gamma := (l, Imp a (Atom i)) :: (l, Imp b (Atom i)) :: gamma). apply (weight_gamma_weak2' (Imp a (Atom i)) (Imp b (Atom i)) (Imp (OrF a b) (Atom i)) (vlist2hlist gamma)); (* Goal: lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (AndF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (AndF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (OrF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) try assumption. (* Goal: lt (Nat.add (weight c) (S (S (S (Nat.add (S (Nat.add (weight_neg b0) (weight_neg b1))) O))))) (S (S (S (S (S (Nat.add (Nat.add (weight_neg b0) (weight_neg b1)) (weight c))))))) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Imp f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Imp f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) simpl in |- *; fold weight_neg in |- *. (* Goal: lt (weight_gamma (vlist2hlist gamma)) n *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Atom i1)) (AndF f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Atom i1)) (AndF f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Atom i1)) (OrF f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Atom i1)) (OrF f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Atom i1)) (Imp f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Atom i1)) (Imp f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (AndF f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (AndF f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (OrF f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (OrF f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Imp f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Imp f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) apply my_lt_weak. (* Goal: lt (S (PeanoNat.Nat.add m (weight c))) (S (S (Nat.add m (weight c)))) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) apply lt_n_S. (* Goal: lt (Nat.add (Nat.add (Nat.add (weight_neg a) (S O)) (Nat.add (weight_neg b) (S O))) (Nat.add (weight_neg c0) (weight c1))) (S (S (S (Nat.add (Nat.add (weight_neg a) (weight_neg b)) (Nat.add (weight_neg c0) (weight c1)))))) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) rewrite <- (plus_Snm_nSm (weight_neg a) 0). (* Goal: @eq flist (@cons form a gamma) (vlist2list (list2vlist (@cons form a gamma))) *) simpl in |- *. (* Goal: lt (S (PeanoNat.Nat.add m (weight c))) (S (S (Nat.add m (weight c)))) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) apply lt_n_S. (* Goal: lt (Nat.add (Nat.add (Nat.add (weight_neg a) O) (Nat.add (weight_neg b) (S O))) (Nat.add (weight_neg c0) (weight c1))) (S (S (Nat.add (Nat.add (weight_neg a) (weight_neg b)) (Nat.add (weight_neg c0) (weight c1))))) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) rewrite (plus_O (weight_neg a)). (* Goal: lt (Nat.add (weight_neg a) (Nat.add (weight_neg b) (S O))) (S (Nat.add (Nat.add (weight_neg a) (weight_neg b)) (S O))) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (OrF a b) (AndF f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF a b) (AndF f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (OrF a b) (OrF f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF a b) (OrF f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (OrF a b) (Imp f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF a b) (Imp f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) apply lt_plus_assoc_l. (* Goal: lt (weight_gamma (vlist2hlist (list2vlist gamma))) (S (weight_gamma (vlist2hlist (list2vlist gamma)))) *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (AndF f f0)) (S n)), search_spec (AndF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (OrF f f0)) (S n)), search_spec (OrF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) apply lt_n_Sn. (* c=(AndF c0 c1) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Atom i1)) (Imp f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Atom i1)) (Imp f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (AndF f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (AndF f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (OrF f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (OrF f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Imp f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Imp f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) intros c0 c1 lt_weight. (* Goal: search_spec (OrF g0 g1) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) elim (int_succ j). (* Goal: forall (x : Int) (_ : Less j x), search_spec (OrF g0 g1) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) intros j1 less1. (* Goal: lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (AndF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (AndF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (OrF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) apply rule_vimp_or_imp_gamma_new with j1; try assumption. apply ih with (gamma := (l, Imp a (Atom j)) :: (l, Imp b (Atom j)) :: (j :: nil, AndF c0 c1) :: gamma). apply (weight_gamma_weak3' (Imp a (Atom j)) (Imp b (Atom j)) (AndF c0 c1) (Imp (OrF a b) (AndF c0 c1)) (vlist2hlist gamma)); (* Goal: lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (AndF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (AndF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (OrF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) try assumption. (* Goal: lt (Nat.add (weight c) (S (S (S (Nat.add (S (Nat.add (weight_neg b0) (weight_neg b1))) O))))) (S (S (S (S (S (Nat.add (Nat.add (weight_neg b0) (weight_neg b1)) (weight c))))))) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Imp f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Imp f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) simpl in |- *; fold weight_neg in |- *. (* Goal: lt (Nat.add (Nat.add (Nat.add (weight_neg a) (S O)) (Nat.add (weight_neg b) (S O))) (Nat.add (weight_neg c0) (weight c1))) (S (S (S (Nat.add (Nat.add (weight_neg a) (weight_neg b)) (Nat.add (weight_neg c0) (weight c1)))))) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) rewrite <- (plus_Snm_nSm (weight_neg a) 0). (* Goal: @eq flist (@cons form a gamma) (vlist2list (list2vlist (@cons form a gamma))) *) simpl in |- *. (* Goal: lt (S (PeanoNat.Nat.add m (weight c))) (S (S (Nat.add m (weight c)))) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) apply lt_n_S. (* Goal: lt (Nat.add (Nat.add (Nat.add (weight_neg a) O) (Nat.add (weight_neg b) (S O))) (Nat.add (weight_neg c0) (weight c1))) (S (S (Nat.add (Nat.add (weight_neg a) (weight_neg b)) (Nat.add (weight_neg c0) (weight c1))))) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) rewrite (plus_O (weight_neg a)). (* Goal: lt (Nat.add (Nat.add (weight_neg a) (Nat.add (weight_neg b) (S O))) (Nat.add (weight_neg c0) (weight c1))) (S (S (Nat.add (Nat.add (weight_neg a) (weight_neg b)) (Nat.add (weight_neg c0) (weight c1))))) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) rewrite <- (plus_Snm_nSm (weight_neg b) 0). (* Goal: @eq flist (@cons form a gamma) (vlist2list (list2vlist (@cons form a gamma))) *) simpl in |- *. (* Goal: lt (Nat.add (Nat.add (weight_neg a) (S (Nat.add (weight_neg b) O))) (Nat.add (weight_neg c0) (weight c1))) (S (S (Nat.add (Nat.add (weight_neg a) (weight_neg b)) (Nat.add (weight_neg c0) (weight c1))))) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) rewrite (plus_O (weight_neg b)). (* Goal: lt (Nat.add (Nat.add (weight_neg a) (S (weight_neg b))) (Nat.add (weight_neg c0) (weight c1))) (S (S (Nat.add (Nat.add (weight_neg a) (weight_neg b)) (Nat.add (weight_neg c0) (weight c1))))) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) rewrite <- (plus_Snm_nSm (weight_neg a) (weight_neg b)). (* Goal: @eq flist (@cons form a gamma) (vlist2list (list2vlist (@cons form a gamma))) *) simpl in |- *. (* Goal: lt (S (PeanoNat.Nat.add m (weight c))) (S (S (Nat.add m (weight c)))) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) apply lt_n_S. (* Goal: lt (weight_gamma (vlist2hlist (list2vlist gamma))) (S (weight_gamma (vlist2hlist (list2vlist gamma)))) *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (AndF f f0)) (S n)), search_spec (AndF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (OrF f f0)) (S n)), search_spec (OrF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) apply lt_n_Sn. (* c=(OrF c0 c1) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Atom i1)) (Imp f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Atom i1)) (Imp f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (AndF f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (AndF f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (OrF f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (OrF f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Imp f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Imp f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) intros c0 c1 lt_weight. (* Goal: search_spec (OrF g0 g1) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) elim (int_succ j). (* Goal: forall (x : Int) (_ : Less j x), search_spec (OrF g0 g1) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) intros j1 less1. (* Goal: lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (AndF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (AndF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (OrF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) apply rule_vimp_or_imp_gamma_new with j1; try assumption. apply ih with (gamma := (l, Imp a (Atom j)) :: (l, Imp b (Atom j)) :: (j :: nil, OrF c0 c1) :: gamma). apply (weight_gamma_weak3' (Imp a (Atom j)) (Imp b (Atom j)) (OrF c0 c1) (Imp (OrF a b) (OrF c0 c1)) (vlist2hlist gamma)); (* Goal: lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (AndF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (AndF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (OrF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) try assumption. (* Goal: lt (Nat.add (weight c) (S (S (S (Nat.add (S (Nat.add (weight_neg b0) (weight_neg b1))) O))))) (S (S (S (S (S (Nat.add (Nat.add (weight_neg b0) (weight_neg b1)) (weight c))))))) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Imp f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Imp f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) simpl in |- *; fold weight_neg in |- *. (* Goal: lt (Nat.add (Nat.add (Nat.add (weight_neg a) (S O)) (Nat.add (weight_neg b) (S O))) (Nat.add (weight_neg c0) (weight c1))) (S (S (S (Nat.add (Nat.add (weight_neg a) (weight_neg b)) (Nat.add (weight_neg c0) (weight c1)))))) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) rewrite <- (plus_Snm_nSm (weight_neg a) 0). (* Goal: @eq flist (@cons form a gamma) (vlist2list (list2vlist (@cons form a gamma))) *) simpl in |- *. (* Goal: lt (S (PeanoNat.Nat.add m (weight c))) (S (S (Nat.add m (weight c)))) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) apply lt_n_S. (* Goal: lt (Nat.add (Nat.add (Nat.add (weight_neg a) O) (Nat.add (weight_neg b) (S O))) (Nat.add (weight_neg c0) (weight c1))) (S (S (Nat.add (Nat.add (weight_neg a) (weight_neg b)) (Nat.add (weight_neg c0) (weight c1))))) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) rewrite (plus_O (weight_neg a)). (* Goal: lt (Nat.add (Nat.add (weight_neg a) (Nat.add (weight_neg b) (S O))) (Nat.add (weight_neg c0) (weight c1))) (S (S (Nat.add (Nat.add (weight_neg a) (weight_neg b)) (Nat.add (weight_neg c0) (weight c1))))) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) rewrite <- (plus_Snm_nSm (weight_neg b) 0). (* Goal: @eq flist (@cons form a gamma) (vlist2list (list2vlist (@cons form a gamma))) *) simpl in |- *. (* Goal: lt (Nat.add (Nat.add (weight_neg a) (S (Nat.add (weight_neg b) O))) (Nat.add (weight_neg c0) (weight c1))) (S (S (Nat.add (Nat.add (weight_neg a) (weight_neg b)) (Nat.add (weight_neg c0) (weight c1))))) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) rewrite (plus_O (weight_neg b)). (* Goal: lt (Nat.add (Nat.add (weight_neg a) (S (weight_neg b))) (Nat.add (weight_neg c0) (weight c1))) (S (S (Nat.add (Nat.add (weight_neg a) (weight_neg b)) (Nat.add (weight_neg c0) (weight c1))))) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) rewrite <- (plus_Snm_nSm (weight_neg a) (weight_neg b)). (* Goal: @eq flist (@cons form a gamma) (vlist2list (list2vlist (@cons form a gamma))) *) simpl in |- *. (* Goal: lt (S (PeanoNat.Nat.add m (weight c))) (S (S (Nat.add m (weight c)))) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) apply lt_n_S. (* Goal: lt (weight_gamma (vlist2hlist (list2vlist gamma))) (S (weight_gamma (vlist2hlist (list2vlist gamma)))) *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (AndF f f0)) (S n)), search_spec (AndF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (OrF f f0)) (S n)), search_spec (OrF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) apply lt_n_Sn. (* c=(Imp c0 c1) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Atom i1)) (Imp f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Atom i1)) (Imp f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (AndF f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (AndF f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (OrF f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (OrF f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Imp f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Imp f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) intros c0 c1 lt_weight. (* Goal: search_spec (OrF g0 g1) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) elim (int_succ j). (* Goal: forall (x : Int) (_ : Less j x), search_spec (OrF g0 g1) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) intros j1 less1. (* Goal: lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (AndF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (AndF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (OrF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) apply rule_vimp_or_imp_gamma_new with j1; try assumption. apply ih with (gamma := (l, Imp a (Atom j)) :: (l, Imp b (Atom j)) :: (j :: nil, Imp c0 c1) :: gamma). apply (weight_gamma_weak3' (Imp a (Atom j)) (Imp b (Atom j)) (Imp c0 c1) (Imp (OrF a b) (Imp c0 c1)) (vlist2hlist gamma)); (* Goal: lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (AndF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (AndF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (OrF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) try assumption. (* Goal: lt (Nat.add (weight c) (S (S (S (Nat.add (S (Nat.add (weight_neg b0) (weight_neg b1))) O))))) (S (S (S (S (S (Nat.add (Nat.add (weight_neg b0) (weight_neg b1)) (weight c))))))) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Imp f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Imp f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) simpl in |- *; fold weight_neg in |- *. (* Goal: lt (Nat.add (Nat.add (Nat.add (weight_neg a) (S O)) (Nat.add (weight_neg b) (S O))) (Nat.add (weight_neg c0) (weight c1))) (S (S (S (Nat.add (Nat.add (weight_neg a) (weight_neg b)) (Nat.add (weight_neg c0) (weight c1)))))) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) rewrite <- (plus_Snm_nSm (weight_neg a) 0). (* Goal: @eq flist (@cons form a gamma) (vlist2list (list2vlist (@cons form a gamma))) *) simpl in |- *. (* Goal: lt (S (PeanoNat.Nat.add m (weight c))) (S (S (Nat.add m (weight c)))) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) apply lt_n_S. (* Goal: lt (Nat.add (Nat.add (Nat.add (weight_neg a) O) (Nat.add (weight_neg b) (S O))) (Nat.add (weight_neg c0) (weight c1))) (S (S (Nat.add (Nat.add (weight_neg a) (weight_neg b)) (Nat.add (weight_neg c0) (weight c1))))) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) rewrite (plus_O (weight_neg a)). (* Goal: lt (Nat.add (Nat.add (weight_neg a) (Nat.add (weight_neg b) (S O))) (Nat.add (weight_neg c0) (weight c1))) (S (S (Nat.add (Nat.add (weight_neg a) (weight_neg b)) (Nat.add (weight_neg c0) (weight c1))))) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) rewrite <- (plus_Snm_nSm (weight_neg b) 0). (* Goal: @eq flist (@cons form a gamma) (vlist2list (list2vlist (@cons form a gamma))) *) simpl in |- *. (* Goal: lt (Nat.add (Nat.add (weight_neg a) (S (Nat.add (weight_neg b) O))) (Nat.add (weight_neg c0) (weight c1))) (S (S (Nat.add (Nat.add (weight_neg a) (weight_neg b)) (Nat.add (weight_neg c0) (weight c1))))) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) rewrite (plus_O (weight_neg b)). (* Goal: lt (Nat.add (Nat.add (weight_neg a) (S (weight_neg b))) (Nat.add (weight_neg c0) (weight c1))) (S (S (Nat.add (Nat.add (weight_neg a) (weight_neg b)) (Nat.add (weight_neg c0) (weight c1))))) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) rewrite <- (plus_Snm_nSm (weight_neg a) (weight_neg b)). (* Goal: @eq flist (@cons form a gamma) (vlist2list (list2vlist (@cons form a gamma))) *) simpl in |- *. (* Goal: lt (S (PeanoNat.Nat.add m (weight c))) (S (S (Nat.add m (weight c)))) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) apply lt_n_S. (* Goal: lt (weight_gamma (vlist2hlist (list2vlist gamma))) (S (weight_gamma (vlist2hlist (list2vlist gamma)))) *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (AndF f f0)) (S n)), search_spec (AndF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (OrF f f0)) (S n)), search_spec (OrF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) apply lt_n_Sn. (* a=(Imp a b) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) intros a b ih_c l; clear ih_c. (* Goal: forall _ : lt (Nat.add (weight (Imp (Imp a b) c)) (weight_gamma (vlist2hlist gamma))) (S n), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp a b) c)) (vlist2list gamma)) work context j *) case a; clear a. (* a=Falsum *) (* Goal: forall _ : lt (weight_goal Falsum) (S n), search_spec Falsum gamma work context j *) (* Goal: forall (i : Int) (_ : lt (weight_goal (Atom i)) (S n)), search_spec (Atom i) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (AndF f f0)) (S n)), search_spec (AndF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (OrF f f0)) (S n)), search_spec (OrF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) intros lt_weight. (* Goal: search_spec (Atom goal) (@cons form (vimp l (Imp (Imp Falsum b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (i : Int) (_ : lt (Nat.add (weight (Imp (Imp (Atom i) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) apply rule_vimp_falsum_imp_imp_gamma. (* Goal: search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j *) (* Goal: forall (i : Int) (_ : lt (Nat.add (weight (Imp (Imp (Atom i) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) apply ih with (gamma := (l, c) :: gamma). (* Goal: @eq flist (@cons form a gamma) (vlist2list (list2vlist (@cons form a gamma))) *) simpl in |- *. (* Goal: lt (weight_goal g1) n *) apply lt_S_n; assumption. (* a=(Atom i0) *) (* Goal: forall (i : Int) (_ : lt (Nat.add (weight (Imp (Imp (Atom i) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) intros i0. (* Goal: forall _ : lt (Nat.add (weight (Imp (Imp (Atom i0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) case b; clear b. (* b=Falsum *) (* Goal: forall _ : lt (weight_goal Falsum) (S n), search_spec Falsum gamma work context j *) (* Goal: forall (i : Int) (_ : lt (weight_goal (Atom i)) (S n)), search_spec (Atom i) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (AndF f f0)) (S n)), search_spec (AndF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (OrF f f0)) (S n)), search_spec (OrF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) intros lt_weight. (* Goal: search_spec (OrF g0 g1) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) elim (int_succ j). (* Goal: forall (x : Int) (_ : Less j x), search_spec (OrF g0 g1) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) intros j1 less1. (* Goal: lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (AndF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (AndF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (OrF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) apply rule_vimp_imp_falsum_imp_gamma with j1; try assumption. (* Goal: search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Atom j)) c)) (vlist2list gamma)) work (@cons form (vimp l (Imp (Imp (Atom i0) (Atom j)) c)) context) j1 *) (* Goal: forall (i : Int) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Atom i)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Atom i)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (AndF f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (AndF f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (OrF f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (OrF f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Imp f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Imp f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) apply ih with (gamma := (l, Imp (Imp (Atom i0) (Atom j)) c) :: gamma). (* Goal: lt (weight_goal g1) n *) simpl in |- *; apply lt_S_n; assumption. (* b=(Atom i1) *) (* Goal: forall (i : Int) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Atom i)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Atom i)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (AndF f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (AndF f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (OrF f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (OrF f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Imp f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Imp f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) intros i1. (* Goal: forall _ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Atom i1)) c)) (weight_gamma (vlist2hlist gamma))) (S n), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Atom i1)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (AndF f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (AndF f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (OrF f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (OrF f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Imp f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Imp f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) case c; clear c. (* c=Falsum *) (* Goal: forall _ : lt (weight_goal Falsum) (S n), search_spec Falsum gamma work context j *) (* Goal: forall (i : Int) (_ : lt (weight_goal (Atom i)) (S n)), search_spec (Atom i) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (AndF f f0)) (S n)), search_spec (AndF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (OrF f f0)) (S n)), search_spec (OrF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) intros lt_weight. (* Goal: search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Atom i1)) Falsum)) (vlist2list gamma)) work context j *) (* Goal: forall (i : Int) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Atom i1)) (Atom i))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Atom i1)) (Atom i))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Atom i1)) (AndF f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Atom i1)) (AndF f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Atom i1)) (OrF f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Atom i1)) (OrF f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Atom i1)) (Imp f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Atom i1)) (Imp f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (AndF f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (AndF f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (OrF f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (OrF f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Imp f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Imp f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) apply rule_shift_gamma_work with (a := NImp_NF (NImp i0 i1 NFalsum)). (* Goal: search_spec g1 (@cons form g0 gamma) work (@cons form g0 context) j *) apply ih. (* Goal: lt (weight_gamma (vlist2hlist gamma)) n *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Atom i1)) (AndF f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Atom i1)) (AndF f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Atom i1)) (OrF f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Atom i1)) (OrF f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Atom i1)) (Imp f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Atom i1)) (Imp f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (AndF f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (AndF f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (OrF f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (OrF f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Imp f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Imp f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) apply my_lt_weak. (* Goal: lt (weight_goal g1) n *) apply lt_S_n; assumption. (* c=(Atom i2) *) (* Goal: forall (i : Int) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Atom i1)) (Atom i))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Atom i1)) (Atom i))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Atom i1)) (AndF f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Atom i1)) (AndF f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Atom i1)) (OrF f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Atom i1)) (OrF f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Atom i1)) (Imp f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Atom i1)) (Imp f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (AndF f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (AndF f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (OrF f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (OrF f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Imp f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Imp f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) intros i2 lt_weight. (* Goal: search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Atom i1)) (Atom i2))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Atom i1)) (AndF f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Atom i1)) (AndF f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Atom i1)) (OrF f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Atom i1)) (OrF f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Atom i1)) (Imp f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Atom i1)) (Imp f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (AndF f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (AndF f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (OrF f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (OrF f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Imp f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Imp f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) apply rule_shift_gamma_work with (a := NImp_NF (NImp i0 i1 (NAtom i2))). (* Goal: search_spec g1 (@cons form g0 gamma) work (@cons form g0 context) j *) apply ih. (* Goal: lt (weight_gamma (vlist2hlist gamma)) n *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Atom i1)) (AndF f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Atom i1)) (AndF f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Atom i1)) (OrF f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Atom i1)) (OrF f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Atom i1)) (Imp f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Atom i1)) (Imp f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (AndF f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (AndF f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (OrF f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (OrF f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Imp f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Imp f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) apply my_lt_weak. (* Goal: lt (weight_goal g1) n *) apply lt_S_n; assumption. (* c=(AndF c0 c1) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Atom i1)) (Imp f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Atom i1)) (Imp f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (AndF f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (AndF f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (OrF f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (OrF f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Imp f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Imp f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) intros c0 c1 lt_weight. (* Goal: search_spec (OrF g0 g1) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) elim (int_succ j). (* Goal: forall (x : Int) (_ : Less j x), search_spec (OrF g0 g1) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) intros j1 less1. (* Goal: lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (AndF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (AndF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (OrF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) apply rule_vimp_imp_gamma with j1; try assumption. (* Goal: search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Atom i1)) (Atom j))) (@cons form (vimp (@cons Int j (@nil Int)) (Imp c0 c1)) (vlist2list gamma))) work (@cons form (vimp l (Imp (Imp (Atom i0) (Atom i1)) (Atom j))) (@cons form (Imp (Atom j) (Imp c0 c1)) context)) j1 *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (AndF f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (AndF f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (OrF f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (OrF f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Imp f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Imp f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) apply rule_shift_gamma_work with (a := NImp_NF (NImp i0 i1 (NAtom j))). (* Goal: search_spec (Atom goal) (@cons form (vimp (@cons Int j (@nil Int)) (AndF c0 c1)) (vlist2list gamma)) (@cons normal_form (nvimp l (NImp_NF (NImp i0 i1 (NAtom j)))) work) (@cons form (vimp l (Imp (Imp (Atom i0) (Atom i1)) (Atom j))) (@cons form (Imp (Atom j) (AndF c0 c1)) context)) j1 *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Atom i1)) (OrF f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Atom i1)) (OrF f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Atom i1)) (Imp f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Atom i1)) (Imp f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (AndF f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (AndF f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (OrF f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (OrF f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Imp f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Imp f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) apply ih with (gamma := (j :: nil, AndF c0 c1) :: gamma). (* Goal: lt (weight_goal g1) n *) apply lt_S_n; assumption. (* c=(OrF c0 c1) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Atom i1)) (Imp f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Atom i1)) (Imp f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (AndF f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (AndF f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (OrF f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (OrF f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Imp f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Imp f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) intros c0 c1 lt_weight. (* Goal: search_spec (OrF g0 g1) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) elim (int_succ j). (* Goal: forall (x : Int) (_ : Less j x), search_spec (OrF g0 g1) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) intros j1 less1. (* Goal: lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (AndF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (AndF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (OrF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) apply rule_vimp_imp_gamma with j1; try assumption. (* Goal: search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Atom i1)) (Atom j))) (@cons form (vimp (@cons Int j (@nil Int)) (Imp c0 c1)) (vlist2list gamma))) work (@cons form (vimp l (Imp (Imp (Atom i0) (Atom i1)) (Atom j))) (@cons form (Imp (Atom j) (Imp c0 c1)) context)) j1 *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (AndF f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (AndF f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (OrF f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (OrF f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Imp f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Imp f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) apply rule_shift_gamma_work with (a := NImp_NF (NImp i0 i1 (NAtom j))). (* Goal: search_spec (Atom goal) (@cons form (vimp (@cons Int j (@nil Int)) (OrF c0 c1)) (vlist2list gamma)) (@cons normal_form (nvimp l (NImp_NF (NImp i0 i1 (NAtom j)))) work) (@cons form (vimp l (Imp (Imp (Atom i0) (Atom i1)) (Atom j))) (@cons form (Imp (Atom j) (OrF c0 c1)) context)) j1 *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Atom i1)) (Imp f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Atom i1)) (Imp f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (AndF f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (AndF f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (OrF f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (OrF f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Imp f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Imp f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) apply ih with (gamma := (j :: nil, OrF c0 c1) :: gamma). (* Goal: lt (weight_goal g1) n *) apply lt_S_n; assumption. (* c=(Imp c0 c1) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Atom i1)) (Imp f f0))) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Atom i1)) (Imp f f0))) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (AndF f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (AndF f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (OrF f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (OrF f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Imp f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Imp f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) intros c0 c1 lt_weight. (* Goal: search_spec (OrF g0 g1) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) elim (int_succ j). (* Goal: forall (x : Int) (_ : Less j x), search_spec (OrF g0 g1) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) intros j1 less1. (* Goal: lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (AndF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (AndF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (OrF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) apply rule_vimp_imp_gamma with j1; try assumption. (* Goal: search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Atom i1)) (Atom j))) (@cons form (vimp (@cons Int j (@nil Int)) (Imp c0 c1)) (vlist2list gamma))) work (@cons form (vimp l (Imp (Imp (Atom i0) (Atom i1)) (Atom j))) (@cons form (Imp (Atom j) (Imp c0 c1)) context)) j1 *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (AndF f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (AndF f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (OrF f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (OrF f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Imp f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Imp f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) apply rule_shift_gamma_work with (a := NImp_NF (NImp i0 i1 (NAtom j))). (* Goal: search_spec (Atom goal) (@cons form (vimp (@cons Int j (@nil Int)) (Imp c0 c1)) (vlist2list gamma)) (@cons normal_form (nvimp l (NImp_NF (NImp i0 i1 (NAtom j)))) work) (@cons form (vimp l (Imp (Imp (Atom i0) (Atom i1)) (Atom j))) (@cons form (Imp (Atom j) (Imp c0 c1)) context)) j1 *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (AndF f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (AndF f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (OrF f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (OrF f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Imp f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Imp f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) apply ih with (gamma := (j :: nil, Imp c0 c1) :: gamma). (* Goal: lt (weight_goal g1) n *) apply lt_S_n; assumption. (* (Imp (Imp (Atom i0) (AndF b0 b1)) c) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Imp f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Imp f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) intros b0 b1 lt_weight. (* Goal: search_spec (OrF g0 g1) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) elim (int_succ j). (* Goal: forall (x : Int) (_ : Less j x), search_spec (OrF g0 g1) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) intros j1 less1. (* Goal: lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (AndF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (AndF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (OrF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) apply rule_atom_imp_b_imp_c_gamma with j1; try assumption. apply ih with (gamma := (l, Imp (Imp (Atom i0) (Atom j)) c) :: (i0 :: l, Imp (AndF b0 b1) (Atom j)) :: gamma). apply (weight_gamma_weak2' (Imp (Imp (Atom i0) (Atom j)) c) (Imp (AndF b0 b1) (Atom j)) (Imp (Imp (Atom i0) (AndF b0 b1)) c) (* Goal: lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (AndF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (AndF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (OrF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) (vlist2hlist gamma)); try assumption. (* Goal: lt (Nat.add (weight c) (S (S (S (Nat.add (S (Nat.add (weight_neg b0) (weight_neg b1))) O))))) (S (S (S (S (S (Nat.add (Nat.add (weight_neg b0) (weight_neg b1)) (weight c))))))) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Imp f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Imp f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) simpl in |- *; fold weight_neg in |- *. (* Goal: lt (S (PeanoNat.Nat.add m (weight c))) (S (S (Nat.add m (weight c)))) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) apply lt_n_S. (* Goal: lt (Nat.add (weight c) (S (Nat.add (Nat.add (weight_neg b0) (weight_neg b1)) (S O)))) (S (S (S (Nat.add (Nat.add (weight_neg b0) (weight_neg b1)) (weight c))))) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (OrF f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (OrF f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Imp f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Imp f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) rewrite (plus_comm (weight c) (S (weight_neg b0 + weight_neg b1 + 1))). (* Goal: @eq flist (@cons form a gamma) (vlist2list (list2vlist (@cons form a gamma))) *) simpl in |- *. (* Goal: lt (S (PeanoNat.Nat.add m (weight c))) (S (S (Nat.add m (weight c)))) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) apply lt_n_S. (* Goal: lt (Nat.add (weight c) (S (S (S (Nat.add (Nat.add (weight_neg b0) (weight_neg b1)) (S O)))))) (S (S (S (S (S (Nat.add (Nat.add (weight_neg b0) (weight_neg b1)) (weight c))))))) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Imp f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Imp f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) rewrite <- (plus_Snm_nSm (weight_neg b0 + weight_neg b1) 0). (* Goal: @eq flist (@cons form a gamma) (vlist2list (list2vlist (@cons form a gamma))) *) simpl in |- *. (* Goal: lt (S (PeanoNat.Nat.add m (weight c))) (S (S (Nat.add m (weight c)))) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) apply lt_n_S. (* Goal: lt (Nat.add (weight c) (S (S (S (S (Nat.add (Nat.add (weight_neg b0) (weight_neg b1)) O)))))) (S (S (S (S (S (Nat.add (Nat.add (weight_neg b0) (weight_neg b1)) (weight c))))))) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Imp f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Imp f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) rewrite (plus_O (weight_neg b0 + weight_neg b1)). (* Goal: lt (weight_gamma (vlist2hlist (list2vlist gamma))) (S (weight_gamma (vlist2hlist (list2vlist gamma)))) *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (AndF f f0)) (S n)), search_spec (AndF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (OrF f f0)) (S n)), search_spec (OrF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) apply lt_n_Sn. (* (Imp (Imp (Atom i0) (OrF b0 b1)) c) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Imp f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Imp f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) intros b0 b1 lt_weight. (* Goal: search_spec (OrF g0 g1) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) elim (int_succ j). (* Goal: forall (x : Int) (_ : Less j x), search_spec (OrF g0 g1) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) intros j1 less1. (* Goal: lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (AndF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (AndF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (OrF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) apply rule_atom_imp_b_imp_c_gamma with j1; try assumption. apply ih with (gamma := (l, Imp (Imp (Atom i0) (Atom j)) c) :: (i0 :: l, Imp (OrF b0 b1) (Atom j)) :: gamma). apply (weight_gamma_weak2' (Imp (Imp (Atom i0) (Atom j)) c) (Imp (OrF b0 b1) (Atom j)) (Imp (Imp (Atom i0) (OrF b0 b1)) c) (* Goal: lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (AndF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (AndF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (OrF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) (vlist2hlist gamma)); try assumption. (* Goal: lt (Nat.add (weight c) (S (S (S (Nat.add (S (Nat.add (weight_neg b0) (weight_neg b1))) O))))) (S (S (S (S (S (Nat.add (Nat.add (weight_neg b0) (weight_neg b1)) (weight c))))))) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Imp f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Imp f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) simpl in |- *; fold weight_neg in |- *. (* Goal: lt (S (PeanoNat.Nat.add m (weight c))) (S (S (Nat.add m (weight c)))) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) apply lt_n_S. (* Goal: lt (Nat.add (weight c) (S (S (S (Nat.add (Nat.add (weight_neg b0) (weight_neg b1)) (S O)))))) (S (S (S (S (S (Nat.add (Nat.add (weight_neg b0) (weight_neg b1)) (weight c))))))) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Imp f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Imp f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) rewrite <- (plus_Snm_nSm (weight_neg b0 + weight_neg b1) 0). (* Goal: lt (Nat.add (weight c) (S (S (S (Nat.add (S (Nat.add (weight_neg b0) (weight_neg b1))) O))))) (S (S (S (S (S (Nat.add (Nat.add (weight_neg b0) (weight_neg b1)) (weight c))))))) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Imp f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Imp f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) simpl in |- *; fold weight_neg in |- *. (* Goal: lt (Nat.add (weight c) (S (S (S (S (Nat.add (Nat.add (weight_neg b0) (weight_neg b1)) O)))))) (S (S (S (S (S (Nat.add (Nat.add (weight_neg b0) (weight_neg b1)) (weight c))))))) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Imp f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Imp f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) rewrite (plus_O (weight_neg b0 + weight_neg b1)). rewrite (plus_comm (weight c) (S (S (S (S (weight_neg b0 + weight_neg b1)))))) . (* Goal: @eq flist (@cons form a gamma) (vlist2list (list2vlist (@cons form a gamma))) *) simpl in |- *. (* Goal: lt (S (PeanoNat.Nat.add m (weight c))) (S (S (Nat.add m (weight c)))) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) apply lt_n_S. (* Goal: lt (S (PeanoNat.Nat.add m (weight c))) (S (S (Nat.add m (weight c)))) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) apply lt_n_S. (* Goal: lt (S (PeanoNat.Nat.add m (weight c))) (S (S (Nat.add m (weight c)))) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) apply lt_n_S. (* Goal: lt (S (PeanoNat.Nat.add m (weight c))) (S (S (Nat.add m (weight c)))) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) apply lt_n_S. (* Goal: lt (weight_gamma (vlist2hlist (list2vlist gamma))) (S (weight_gamma (vlist2hlist (list2vlist gamma)))) *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (AndF f f0)) (S n)), search_spec (AndF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (OrF f f0)) (S n)), search_spec (OrF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) apply lt_n_Sn. (* (Imp (Imp (Atom i0) (Imp b0 b1)) c) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Atom i0) (Imp f f0)) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Atom i0) (Imp f f0)) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) intros b0 b1 lt_weight. (* Goal: search_spec (OrF g0 g1) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) elim (int_succ j). (* Goal: forall (x : Int) (_ : Less j x), search_spec (OrF g0 g1) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) intros j1 less1. (* Goal: lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (AndF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (AndF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (OrF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) apply rule_atom_imp_b_imp_c_gamma with j1; try assumption. apply ih with (gamma := (l, Imp (Imp (Atom i0) (Atom j)) c) :: (i0 :: l, Imp (Imp b0 b1) (Atom j)) :: gamma). apply (weight_gamma_weak2' (Imp (Imp (Atom i0) (Atom j)) c) (Imp (Imp b0 b1) (Atom j)) (Imp (Imp (Atom i0) (Imp b0 b1)) c) (* Goal: lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (AndF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (AndF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (OrF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) (vlist2hlist gamma)); try assumption. change (S (weight c + (weight_neg (Imp b0 b1) + 1)) < S (S (S (weight_neg (Imp b0 b1) + weight c)))) in |- *. (* Goal: lt (S (PeanoNat.Nat.add m (weight c))) (S (S (Nat.add m (weight c)))) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) apply lt_n_S. (* Goal: lt (Nat.add (weight c) (Nat.add (weight_neg (Imp b0 b1)) (S O))) (S (S (Nat.add (weight_neg (Imp b0 b1)) (weight c)))) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) generalize (weight_neg (Imp b0 b1)); intros m. (* Goal: lt (Nat.add (weight c) (Nat.add m (S O))) (S (S (Nat.add m (weight c)))) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) rewrite <- (plus_Snm_nSm m 0). (* Goal: @eq flist (@cons form a gamma) (vlist2list (list2vlist (@cons form a gamma))) *) simpl in |- *. (* Goal: lt (Nat.add (weight c) (S (Nat.add m O))) (S (S (Nat.add m (weight c)))) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) rewrite (plus_O m). (* Goal: lt (Nat.add (weight c) (S m)) (S (S (Nat.add m (weight c)))) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) rewrite (plus_comm (weight c) (S m)). (* Goal: @eq flist (@cons form a gamma) (vlist2list (list2vlist (@cons form a gamma))) *) simpl in |- *. (* Goal: lt (S (PeanoNat.Nat.add m (weight c))) (S (S (Nat.add m (weight c)))) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (AndF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (AndF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) apply lt_n_S. (* Goal: lt (weight_gamma (vlist2hlist (list2vlist gamma))) (S (weight_gamma (vlist2hlist (list2vlist gamma)))) *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (AndF f f0)) (S n)), search_spec (AndF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (OrF f f0)) (S n)), search_spec (OrF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) apply lt_n_Sn. (* (Imp (Imp (AndF a0 a1) b) c) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) intros a0 a1 lt_weight. (* Goal: search_spec (OrF g0 g1) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) elim (int_succ j). (* Goal: forall (x : Int) (_ : Less j x), search_spec (OrF g0 g1) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) intros j1 less1. (* Goal: lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (AndF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (AndF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (OrF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) apply rule_a_imp_b_imp_c_gamma with j1; try assumption. apply ih with (gamma := (l, Imp (Imp (Atom j) b) c) :: (j :: nil, AndF a0 a1) :: gamma). apply (weight_gamma_weak2' (Imp (Imp (Atom j) b) c) (AndF a0 a1) (Imp (Imp (AndF a0 a1) b) c) (vlist2hlist gamma)); (* Goal: lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (AndF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (AndF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (OrF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) try assumption. change (weight_neg (Imp (Atom j) b) + weight c + weight (AndF a0 a1) < S (S (S (S (weight_neg b + weight (AndF a0 a1) + weight c))))) in |- *. (* Goal: lt (Nat.add (Nat.add (weight_neg (Imp (Atom j) b)) (weight c)) (weight (AndF a0 a1))) (S (S (S (S (Nat.add (Nat.add (weight_neg b) (weight (AndF a0 a1))) (weight c)))))) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (OrF f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (OrF f f0) b) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) generalize (weight (AndF a0 a1)); intro a. (* Goal: lt (Nat.add (Nat.add (weight_neg (Imp (Atom j) b)) (weight c)) a) (S (S (S (S (Nat.add (Nat.add (weight_neg b) a) (weight c)))))) *) generalize (weight c); intro cn. (* Goal: lt (Nat.add (Nat.add (weight_neg (Imp (Atom j) b)) cn) a) (S (S (S (S (Nat.add (Nat.add (weight_neg b) a) cn))))) *) rewrite (plus_assoc_reverse (weight_neg (Imp (Atom j) b)) cn a). (* Goal: lt (Nat.add (weight_neg (Imp (Atom j) b)) (Nat.add cn a)) (S (S (S (S (Nat.add (Nat.add (weight_neg b) a) cn))))) *) rewrite (plus_comm cn a). (* Goal: lt (Nat.add (weight_neg (Imp (Atom j) b)) (PeanoNat.Nat.add a cn)) (S (S (S (S (Nat.add (Nat.add (weight_neg b) a) cn))))) *) rewrite (plus_assoc (weight_neg (Imp (Atom j) b)) a cn). (* Goal: lt (PeanoNat.Nat.add (PeanoNat.Nat.add (weight_neg (Imp (Atom j) b)) a) cn) (S (S (S (S (Nat.add (Nat.add (weight_neg b) a) cn))))) *) apply le_lt_trans with (S (S (S (weight_neg b))) + a + cn). (* Goal: le (PeanoNat.Nat.add (weight_neg (Imp (Atom j) b)) a) (Nat.add (S (S (S (weight_neg b)))) a) *) (* Goal: lt (Nat.add (Nat.add (S (S (S (weight_neg b)))) a) cn) (S (S (S (S (Nat.add (Nat.add (weight_neg b) a) cn))))) *) apply plus_le_compat_r. (* Goal: le (PeanoNat.Nat.add (weight_neg (Imp (Atom j) b)) a) (Nat.add (S (S (S (weight_neg b)))) a) *) (* Goal: lt (Nat.add (Nat.add (S (S (S (weight_neg b)))) a) cn) (S (S (S (S (Nat.add (Nat.add (weight_neg b) a) cn))))) *) apply plus_le_compat_r. (* Goal: le (weight_neg (Imp (Atom j) b)) (S (S (S (weight_neg b)))) *) (* Goal: lt (Nat.add (Nat.add (S (S (S (weight_neg b)))) a) cn) (S (S (S (S (Nat.add (Nat.add (weight_neg b) a) cn))))) *) apply weight_neg_le. (* Goal: lt (weight_gamma (vlist2hlist (list2vlist gamma))) (S (weight_gamma (vlist2hlist (list2vlist gamma)))) *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (AndF f f0)) (S n)), search_spec (AndF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (OrF f f0)) (S n)), search_spec (OrF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) apply lt_n_Sn. (* (Imp (Imp (OrF a0 a1) b) c) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) intros a0 a1 lt_weight. (* Goal: search_spec (OrF g0 g1) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) elim (int_succ j). (* Goal: forall (x : Int) (_ : Less j x), search_spec (OrF g0 g1) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) intros j1 less1. (* Goal: lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (AndF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (AndF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (OrF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) apply rule_a_imp_b_imp_c_gamma with j1; try assumption. apply ih with (gamma := (l, Imp (Imp (Atom j) b) c) :: (j :: nil, OrF a0 a1) :: gamma). apply (weight_gamma_weak2' (Imp (Imp (Atom j) b) c) (OrF a0 a1) (Imp (Imp (OrF a0 a1) b) c) (vlist2hlist gamma)); (* Goal: lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (AndF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (AndF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (OrF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) try assumption. change (weight_neg (Imp (Atom j) b) + weight c + weight (OrF a0 a1) < S (S (S (S (weight_neg b + weight (OrF a0 a1) + weight c))))) in |- *. (* Goal: lt (Nat.add (Nat.add (weight_neg (Imp (Atom j) b)) (weight c)) (weight (OrF a0 a1))) (S (S (S (S (Nat.add (Nat.add (weight_neg b) (weight (OrF a0 a1))) (weight c)))))) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) generalize (weight (OrF a0 a1)); intro a. (* Goal: lt (Nat.add (Nat.add (weight_neg (Imp (Atom j) b)) (weight c)) a) (S (S (S (S (Nat.add (Nat.add (weight_neg b) a) (weight c)))))) *) generalize (weight c); intro cn. (* Goal: lt (Nat.add (Nat.add (weight_neg (Imp (Atom j) b)) cn) a) (S (S (S (S (Nat.add (Nat.add (weight_neg b) a) cn))))) *) rewrite (plus_assoc_reverse (weight_neg (Imp (Atom j) b)) cn a). (* Goal: lt (Nat.add (weight_neg (Imp (Atom j) b)) (Nat.add cn a)) (S (S (S (S (Nat.add (Nat.add (weight_neg b) a) cn))))) *) rewrite (plus_comm cn a). (* Goal: lt (Nat.add (weight_neg (Imp (Atom j) b)) (PeanoNat.Nat.add a cn)) (S (S (S (S (Nat.add (Nat.add (weight_neg b) a) cn))))) *) rewrite (plus_assoc (weight_neg (Imp (Atom j) b)) a cn). (* Goal: lt (PeanoNat.Nat.add (PeanoNat.Nat.add (weight_neg (Imp (Atom j) b)) a) cn) (S (S (S (S (Nat.add (Nat.add (weight_neg b) a) cn))))) *) apply le_lt_trans with (S (S (S (weight_neg b))) + a + cn). (* Goal: le (PeanoNat.Nat.add (weight_neg (Imp (Atom j) b)) a) (Nat.add (S (S (S (weight_neg b)))) a) *) (* Goal: lt (Nat.add (Nat.add (S (S (S (weight_neg b)))) a) cn) (S (S (S (S (Nat.add (Nat.add (weight_neg b) a) cn))))) *) apply plus_le_compat_r. (* Goal: le (PeanoNat.Nat.add (weight_neg (Imp (Atom j) b)) a) (Nat.add (S (S (S (weight_neg b)))) a) *) (* Goal: lt (Nat.add (Nat.add (S (S (S (weight_neg b)))) a) cn) (S (S (S (S (Nat.add (Nat.add (weight_neg b) a) cn))))) *) apply plus_le_compat_r. (* Goal: le (weight_neg (Imp (Atom j) b)) (S (S (S (weight_neg b)))) *) (* Goal: lt (Nat.add (Nat.add (S (S (S (weight_neg b)))) a) cn) (S (S (S (S (Nat.add (Nat.add (weight_neg b) a) cn))))) *) apply weight_neg_le. (* Goal: lt (weight_gamma (vlist2hlist (list2vlist gamma))) (S (weight_gamma (vlist2hlist (list2vlist gamma)))) *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (AndF f f0)) (S n)), search_spec (AndF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (OrF f f0)) (S n)), search_spec (OrF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) apply lt_n_Sn. (* (Imp (Imp (Imp a0 a1) b) c) *) (* Goal: forall (f f0 : form) (_ : lt (Nat.add (weight (Imp (Imp (Imp f f0) b) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp (Imp f f0) b) c)) (vlist2list gamma)) work context j *) intros a0 a1 lt_weight. (* Goal: search_spec (OrF g0 g1) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) elim (int_succ j). (* Goal: forall (x : Int) (_ : Less j x), search_spec (OrF g0 g1) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) intros j1 less1. (* Goal: lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (AndF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (AndF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (OrF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) apply rule_a_imp_b_imp_c_gamma with j1; try assumption. apply ih with (gamma := (l, Imp (Imp (Atom j) b) c) :: (j :: nil, Imp a0 a1) :: gamma). apply (weight_gamma_weak2' (Imp (Imp (Atom j) b) c) (Imp a0 a1) (Imp (Imp (Imp a0 a1) b) c) (vlist2hlist gamma)); (* Goal: lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (AndF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (AndF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (OrF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) try assumption. change (weight_neg (Imp (Atom j) b) + weight c + weight (Imp a0 a1) < S (S (S (S (weight_neg b + weight (Imp a0 a1) + weight c))))) in |- *. (* Goal: lt (Nat.add (Nat.add (weight_neg (Imp (Atom j) b)) (weight c)) (weight (Imp a0 a1))) (S (S (S (S (Nat.add (Nat.add (weight_neg b) (weight (Imp a0 a1))) (weight c)))))) *) generalize (weight (Imp a0 a1)); intro a. (* Goal: lt (Nat.add (Nat.add (weight_neg (Imp (Atom j) b)) (weight c)) a) (S (S (S (S (Nat.add (Nat.add (weight_neg b) a) (weight c)))))) *) generalize (weight c); intro cn. (* Goal: lt (Nat.add (Nat.add (weight_neg (Imp (Atom j) b)) cn) a) (S (S (S (S (Nat.add (Nat.add (weight_neg b) a) cn))))) *) rewrite (plus_assoc_reverse (weight_neg (Imp (Atom j) b)) cn a). (* Goal: lt (Nat.add (weight_neg (Imp (Atom j) b)) (Nat.add cn a)) (S (S (S (S (Nat.add (Nat.add (weight_neg b) a) cn))))) *) rewrite (plus_comm cn a). (* Goal: lt (Nat.add (weight_neg (Imp (Atom j) b)) (PeanoNat.Nat.add a cn)) (S (S (S (S (Nat.add (Nat.add (weight_neg b) a) cn))))) *) rewrite (plus_assoc (weight_neg (Imp (Atom j) b)) a cn). (* Goal: lt (PeanoNat.Nat.add (PeanoNat.Nat.add (weight_neg (Imp (Atom j) b)) a) cn) (S (S (S (S (Nat.add (Nat.add (weight_neg b) a) cn))))) *) apply le_lt_trans with (S (S (S (weight_neg b))) + a + cn). (* Goal: le (PeanoNat.Nat.add (weight_neg (Imp (Atom j) b)) a) (Nat.add (S (S (S (weight_neg b)))) a) *) (* Goal: lt (Nat.add (Nat.add (S (S (S (weight_neg b)))) a) cn) (S (S (S (S (Nat.add (Nat.add (weight_neg b) a) cn))))) *) apply plus_le_compat_r. (* Goal: le (PeanoNat.Nat.add (weight_neg (Imp (Atom j) b)) a) (Nat.add (S (S (S (weight_neg b)))) a) *) (* Goal: lt (Nat.add (Nat.add (S (S (S (weight_neg b)))) a) cn) (S (S (S (S (Nat.add (Nat.add (weight_neg b) a) cn))))) *) apply plus_le_compat_r. (* Goal: le (weight_neg (Imp (Atom j) b)) (S (S (S (weight_neg b)))) *) (* Goal: lt (Nat.add (Nat.add (S (S (S (weight_neg b)))) a) cn) (S (S (S (S (Nat.add (Nat.add (weight_neg b) a) cn))))) *) apply weight_neg_le. (* Goal: lt (weight_gamma (vlist2hlist (list2vlist gamma))) (S (weight_gamma (vlist2hlist (list2vlist gamma)))) *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (AndF f f0)) (S n)), search_spec (AndF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (OrF f f0)) (S n)), search_spec (OrF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) apply lt_n_Sn. Qed. (********************************************************************) Fixpoint list2vlist (gamma : flist) : vlist := match gamma with | nil => nil (A:=list Int * form) | a :: gamma => (nil, a) :: list2vlist gamma end. Lemma vlist_eq : forall gamma : flist, gamma = vlist2list (list2vlist gamma). (* Goal: forall gamma : flist, @eq flist gamma (vlist2list (list2vlist gamma)) *) intros gamma; elim gamma; clear gamma. (* Goal: @eq flist (@nil form) (vlist2list (list2vlist (@nil form))) *) (* Goal: forall (a : form) (l : list form) (_ : @eq flist l (vlist2list (list2vlist l))), @eq flist (@cons form a l) (vlist2list (list2vlist (@cons form a l))) *) trivial. (* Goal: forall (a : form) (l : list form) (_ : @eq flist l (vlist2list (list2vlist l))), @eq flist (@cons form a l) (vlist2list (list2vlist (@cons form a l))) *) intros a gamma ih. (* Goal: @eq flist (@cons form a gamma) (vlist2list (list2vlist (@cons form a gamma))) *) simpl in |- *. (* Goal: @eq flist (@nil form) (vlist2list (list2vlist (@nil form))) *) (* Goal: forall (a : form) (l : list form) (_ : @eq flist l (vlist2list (list2vlist l))), @eq flist (@cons form a l) (vlist2list (list2vlist (@cons form a l))) *) rewrite <- ih; trivial. Qed. Lemma search_goal_invariant : forall (goal : form) (gamma : flist) (work : nf_list) (context : flist) (j : Int), search_spec goal gamma work context j. (* Goal: forall (goal : form) (gamma : flist) (work : nf_list) (context : flist) (j : Int), search_spec goal gamma work context j *) intros goal gamma work context j. cut (forall (n : nat) (goal : form) (gamma : flist) (work : nf_list) (context : flist) (j : Int), weight_goal goal < n -> search_spec goal gamma work context j). (* Goal: forall _ : forall (n : nat) (goal : form) (gamma : flist) (work : nf_list) (context : flist) (j : Int) (_ : lt (weight_goal goal) n), search_spec goal gamma work context j, search_spec goal gamma work context j *) (* Goal: forall (n : nat) (goal : form) (gamma : flist) (work : nf_list) (context : flist) (j : Int) (_ : lt (weight_goal goal) n), search_spec goal gamma work context j *) intros claim. (* Goal: search_spec goal gamma work context j *) (* Goal: forall (n : nat) (goal : form) (gamma : flist) (work : nf_list) (context : flist) (j : Int) (_ : lt (weight_goal goal) n), search_spec goal gamma work context j *) apply claim with (S (weight_goal goal)). (* Goal: lt (weight_gamma (vlist2hlist (list2vlist gamma))) (S (weight_gamma (vlist2hlist (list2vlist gamma)))) *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (AndF f f0)) (S n)), search_spec (AndF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (OrF f f0)) (S n)), search_spec (OrF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) apply lt_n_Sn. (* Goal: forall (n : nat) (goal : form) (gamma : flist) (work : nf_list) (context : flist) (j : Int) (_ : lt (weight_goal goal) n), search_spec goal gamma work context j *) clear goal gamma work context j. (* Goal: forall (n : nat) (goal : form) (gamma : flist) (work : nf_list) (context : flist) (j : Int) (_ : lt (weight_goal goal) n), search_spec goal gamma work context j *) intros n; elim n; clear n. (* Goal: forall (goal : form) (gamma : flist) (work : nf_list) (context : flist) (j : Int) (_ : lt (weight_goal goal) O), search_spec goal gamma work context j *) (* Goal: forall (n : nat) (_ : forall (goal : form) (gamma : flist) (work : nf_list) (context : flist) (j : Int) (_ : lt (weight_goal goal) n), search_spec goal gamma work context j) (goal : form) (gamma : flist) (work : nf_list) (context : flist) (j : Int) (_ : lt (weight_goal goal) (S n)), search_spec goal gamma work context j *) intros goal gamma work context j lt_weight. (* Goal: search_spec goal gamma work context j *) (* Goal: forall (n : nat) (_ : forall (goal : form) (gamma : flist) (work : nf_list) (context : flist) (j : Int) (_ : lt (weight_goal goal) n), search_spec goal gamma work context j) (goal : form) (gamma : flist) (work : nf_list) (context : flist) (j : Int) (_ : lt (weight_goal goal) (S n)), search_spec goal gamma work context j *) elimtype False. (* Goal: lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (AndF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (AndF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (OrF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) apply (lt_n_O (weight_goal goal)); assumption. (* Goal: forall (n : nat) (_ : forall (goal : form) (gamma : flist) (work : nf_list) (context : flist) (j : Int) (_ : lt (weight_goal goal) n), search_spec goal gamma work context j) (goal : form) (gamma : flist) (work : nf_list) (context : flist) (j : Int) (_ : lt (weight_goal goal) (S n)), search_spec goal gamma work context j *) intros n ih goal gamma work context j. (* Goal: forall _ : lt (weight_goal goal) (S n), search_spec goal gamma work context j *) case goal; clear goal. (* goal=Falsum *) (* Goal: forall _ : lt (weight_goal Falsum) (S n), search_spec Falsum gamma work context j *) (* Goal: forall (i : Int) (_ : lt (weight_goal (Atom i)) (S n)), search_spec (Atom i) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (AndF f f0)) (S n)), search_spec (AndF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (OrF f f0)) (S n)), search_spec (OrF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) intros lt_weight. (* Goal: search_spec (OrF g0 g1) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) elim (int_succ j). (* Goal: forall (x : Int) (_ : Less j x), search_spec (OrF g0 g1) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) intros j1 less1. (* Goal: lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (AndF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (AndF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (OrF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) apply rule_gamma_falsum with j1; try assumption. (* Goal: search_spec (Atom i) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (AndF f f0)) (S n)), search_spec (AndF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (OrF f f0)) (S n)), search_spec (OrF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) rewrite (vlist_eq gamma). (* Goal: search_spec (Atom i) (vlist2list (list2vlist gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (AndF f f0)) (S n)), search_spec (AndF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (OrF f f0)) (S n)), search_spec (OrF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) apply (search_atom_aux (S (weight_gamma (vlist2hlist (list2vlist gamma))))). (* Goal: lt (weight_gamma (vlist2hlist (list2vlist gamma))) (S (weight_gamma (vlist2hlist (list2vlist gamma)))) *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (AndF f f0)) (S n)), search_spec (AndF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (OrF f f0)) (S n)), search_spec (OrF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) apply lt_n_Sn. (* goal=(Atom i) *) (* Goal: forall (i : Int) (_ : lt (weight_goal (Atom i)) (S n)), search_spec (Atom i) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (AndF f f0)) (S n)), search_spec (AndF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (OrF f f0)) (S n)), search_spec (OrF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) intros i lt_weight. (* Goal: search_spec (Atom i) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (AndF f f0)) (S n)), search_spec (AndF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (OrF f f0)) (S n)), search_spec (OrF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) rewrite (vlist_eq gamma). (* Goal: search_spec (Atom i) (vlist2list (list2vlist gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (AndF f f0)) (S n)), search_spec (AndF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (OrF f f0)) (S n)), search_spec (OrF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) apply (search_atom_aux (S (weight_gamma (vlist2hlist (list2vlist gamma))))). (* Goal: lt (weight_gamma (vlist2hlist (list2vlist gamma))) (S (weight_gamma (vlist2hlist (list2vlist gamma)))) *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (AndF f f0)) (S n)), search_spec (AndF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (OrF f f0)) (S n)), search_spec (OrF f f0) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) apply lt_n_Sn. (* goal=(AndF g0 g1) *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) intros g0 g1 lt_weight. (* Goal: search_spec (OrF g0 g1) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) elim (int_succ j). (* Goal: forall (x : Int) (_ : Less j x), search_spec (OrF g0 g1) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) intros j1 less1. (* Goal: lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (AndF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (AndF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (OrF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) apply rule_gamma_a with j1; try assumption. (* Goal: search_spec g1 (@cons form g0 gamma) work (@cons form g0 context) j *) apply ih. (* Goal: lt (weight_goal g1) n *) apply lt_S_n; assumption. (* goal=(OrF g0 g1) *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) intros g0 g1 lt_weight. (* Goal: search_spec (OrF g0 g1) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) elim (int_succ j). (* Goal: forall (x : Int) (_ : Less j x), search_spec (OrF g0 g1) gamma work context j *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) intros j1 less1. (* Goal: lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (AndF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (AndF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (OrF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) apply rule_gamma_a with j1; try assumption. (* Goal: search_spec g1 (@cons form g0 gamma) work (@cons form g0 context) j *) apply ih. (* Goal: lt (weight_goal g1) n *) apply lt_S_n; assumption. (* goal=(Imp g0 g1) *) (* Goal: forall (f f0 : form) (_ : lt (weight_goal (Imp f f0)) (S n)), search_spec (Imp f f0) gamma work context j *) intros g0 g1 lt_weight. (* Goal: search_spec (Imp g0 g1) gamma work context j *) apply rule_gamma_a_imp_b. (* Goal: search_spec g1 (@cons form g0 gamma) work (@cons form g0 context) j *) apply ih. (* Goal: lt (weight_goal g1) n *) apply lt_S_n; assumption. Qed. (********************************************************************) Inductive search_spec (goal : form) (gamma : flist) : Set := | derivable : Derivable gamma goal -> search_spec goal gamma | refutable : forall k : kripke_tree, Is_Monotone_kripke_tree k -> (forall a : form, In a gamma -> forces_t k a) -> (forces_t k goal -> False) -> search_spec goal gamma. Theorem search : forall (goal : form) (gamma : flist), search_spec goal gamma. (* Goal: forall (goal : form) (gamma : flist), search_spec goal gamma *) intros goal gamma. (* Goal: search_spec goal gamma *) elim (max_int_of_list (goal :: gamma)). (* Goal: forall (x : Int) (_ : below_list (@cons form goal gamma) x), search_spec goal gamma *) intros j below. (* Goal: search_spec goal gamma *) elim (search_goal_invariant goal gamma nf_nil gamma j). (* Goal: forall _ : Derivable gamma goal, search_spec goal gamma *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma gamma nf_nil k) (_ : forall _ : forces_t k goal, False), search_spec goal gamma *) (* Goal: below_form goal j *) (* Goal: below_list gamma j *) (* Goal: below_list gamma j *) (* Goal: sound gamma nf_nil gamma *) (* Goal: minimal gamma nf_nil gamma *) intros der; apply derivable; assumption. (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma gamma nf_nil k) (_ : forall _ : forces_t k goal, False), search_spec goal gamma *) (* Goal: below_form goal j *) (* Goal: below_list gamma j *) (* Goal: below_list gamma j *) (* Goal: sound gamma nf_nil gamma *) (* Goal: minimal gamma nf_nil gamma *) intros k k_is_mon k_forces_gamma k_notforces_goal. (* Goal: search_spec goal gamma *) (* Goal: below_form goal j *) (* Goal: below_list gamma j *) (* Goal: below_list gamma j *) (* Goal: sound gamma nf_nil gamma *) (* Goal: minimal gamma nf_nil gamma *) apply refutable with k; try assumption. (* Goal: forall (a : form) (_ : in_gamma gamma nf_nil a), Derivable gamma a *) (* Goal: minimal gamma nf_nil gamma *) intros a in_a. (* Goal: forces_t k a *) elim (in_nth form a gamma in_a). (* Goal: forall (x : nat) (_ : my_nth form x gamma a), forces_t k a *) intros n nth. (* Goal: forces_t k a *) apply k_forces_gamma. (* Goal: lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (AndF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (AndF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (OrF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) apply In_Gamma with n; assumption. (* Goal: lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (AndF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (AndF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (OrF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) apply below_cons_list_head with gamma; assumption. (* Goal: lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (AndF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (AndF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (OrF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) apply below_cons_list_tail with goal; assumption. (* Goal: lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (AndF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (AndF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (OrF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) apply below_cons_list_tail with goal; assumption. (* Goal: sound gamma nf_nil gamma *) (* Goal: minimal gamma nf_nil gamma *) unfold sound in |- *. (* Goal: forall (a : form) (_ : in_gamma gamma nf_nil a), Derivable gamma a *) (* Goal: minimal gamma nf_nil gamma *) intros a in_a. (* Goal: Derivable gamma a *) (* Goal: minimal gamma nf_nil gamma *) elim in_a; clear in_a a. (* Goal: forall (n : nat) (a : form) (_ : my_nth form n gamma a), Derivable gamma a *) (* Goal: forall (n : nat) (a : normal_form) (_ : my_nth normal_form n nf_nil a), Derivable gamma (nf2form a) *) (* Goal: minimal gamma nf_nil gamma *) intros n a nth. (* Goal: Derivable gamma a *) (* Goal: forall (n : nat) (a : normal_form) (_ : my_nth normal_form n nf_nil a), Derivable gamma (nf2form a) *) (* Goal: minimal gamma nf_nil gamma *) apply Derivable_Intro with (Var n). (* Goal: lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (AndF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (AndF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (OrF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) apply ByAssumption; assumption. (* Goal: forall (n : nat) (a : normal_form) (_ : my_nth normal_form n nf_nil a), Derivable gamma (nf2form a) *) (* Goal: minimal gamma nf_nil gamma *) intros n a nth; elimtype False; inversion_clear nth. (* Goal: minimal gamma nf_nil gamma *) unfold minimal in |- *. (* Goal: forall (a : form) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma gamma nf_nil k) (_ : @In form a gamma), forces_t k a *) intros a k k_is_mon k_forces_gamma in_a. (* Goal: forces_t k a *) elim (in_nth form a gamma in_a). (* Goal: forall (x : nat) (_ : my_nth form x gamma a), forces_t k a *) intros n nth. (* Goal: forces_t k a *) apply k_forces_gamma. (* Goal: lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n) *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (AndF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (AndF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (OrF f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (OrF f f0) c)) (vlist2list gamma)) work context j *) (* Goal: forall (f f0 : form) (_ : forall (l : list Int) (_ : lt (Nat.add (weight c) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l c) (vlist2list gamma)) work context j) (l : list Int) (_ : lt (Nat.add (weight (Imp (Imp f f0) c)) (weight_gamma (vlist2hlist gamma))) (S n)), search_spec (Atom goal) (@cons form (vimp l (Imp (Imp f f0) c)) (vlist2list gamma)) work context j *) apply In_Gamma with n; assumption. Qed.
(* File: In_NGamma.v (last edited on 27/10/2000) (c) Klaus Weich *) (*******************************************************************) (* The left hand side Gamma of a sequent consists of *) (* work : a list of (arbitray) normalforms *) (* (to be inserted in the following structures) *) (* ds: a list of disjunctions *) (* ni: a list of decorated and undecorated nested implications *) (* ai: an AVL tree of atomic implications *) (* a: an AVL tree of atoms *) (*******************************************************************) Require Export Kripke_Trees. Require Export Normal_Forms. (************************************************************) (* disjunctions are stored as pairs of Int's *) Definition disj := (Int * Int)%type. Definition disjs := list disj. Definition DNil := nil (A:=disj). Definition disj2form (x : disj) := match x with | (i, j) => OrF (Atom i) (Atom j) end. Definition disj2nform (x : disj) := match x with | (i, j) => NDisj i j end. Definition disjs2forms (ds : disjs) := map disj2form ds. Definition disjs2nforms (ds : disjs) := map disj2nform ds. (*****************************************************************) (* Nested implications are stored either as a nimp or as a *) (* nimp and a counter-model *) Inductive nested_imp : Set := | Undecorated : nimp -> nested_imp | Decorated : nimp -> kripke_tree -> nested_imp. Definition nested_imp2nimp (ni : nested_imp) := match ni with | Undecorated ni => ni | Decorated ni _ => ni end. Definition nested_imp2form (x : nested_imp) := nimp2form (nested_imp2nimp x). Definition nested_imp2nform (x : nested_imp) := NImp_NF (nested_imp2nimp x). Definition nested_imps := list nested_imp. Definition NNil := nil (A:=nested_imp). Definition nested_imps2forms (ni : nested_imps) := map nested_imp2form ni. Definition nested_imps2nforms (ni : nested_imps) := map nested_imp2nform ni. Definition nested_imps2nimps (ni : nested_imps) := map nested_imp2nimp ni. Lemma nested_imps2nimps_app : forall ni1 ni2 : nested_imps, nested_imps2nimps (ni1 ++ ni2) = nested_imps2nimps ni1 ++ nested_imps2nimps ni2. (* Goal: forall ni1 ni2 : nested_imps, @eq (list nimp) (nested_imps2nimps (@app nested_imp ni1 ni2)) (@app nimp (nested_imps2nimps ni1) (nested_imps2nimps ni2)) *) intros ni1 ni2. (* Goal: @eq (list nimp) (nested_imps2nimps (@app nested_imp ni1 ni2)) (@app nimp (nested_imps2nimps ni1) (nested_imps2nimps ni2)) *) elim ni1; clear ni1. (* Goal: @eq nat (@length nested_imp (@nil nested_imp)) (@length nimp (nested_imps2nimps (@nil nested_imp))) *) (* Goal: forall (a : nested_imp) (l : list nested_imp) (_ : @eq nat (@length nested_imp l) (@length nimp (nested_imps2nimps l))), @eq nat (@length nested_imp (@cons nested_imp a l)) (@length nimp (nested_imps2nimps (@cons nested_imp a l))) *) simpl in |- *; trivial. (* Goal: forall (a : nested_imp) (l : list nested_imp) (_ : @eq (list nimp) (nested_imps2nimps (@app nested_imp l ni2)) (@app nimp (nested_imps2nimps l) (nested_imps2nimps ni2))), @eq (list nimp) (nested_imps2nimps (@app nested_imp (@cons nested_imp a l) ni2)) (@app nimp (nested_imps2nimps (@cons nested_imp a l)) (nested_imps2nimps ni2)) *) intros x ni1 ih. (* Goal: in_ngamma work ds ni ai a' (NAtom i) *) simpl in |- *. (* Goal: @eq nat (S (@length nested_imp ni)) (S (@length nimp (nested_imps2nimps ni))) *) rewrite ih; trivial. Qed. Lemma nested_imps2nimps_length : forall ni : nested_imps, length ni = length (nested_imps2nimps ni). (* Goal: forall ni : nested_imps, @eq nat (@length nested_imp ni) (@length nimp (nested_imps2nimps ni)) *) intros ni; elim ni; clear ni. (* Goal: @eq nat (@length nested_imp (@nil nested_imp)) (@length nimp (nested_imps2nimps (@nil nested_imp))) *) (* Goal: forall (a : nested_imp) (l : list nested_imp) (_ : @eq nat (@length nested_imp l) (@length nimp (nested_imps2nimps l))), @eq nat (@length nested_imp (@cons nested_imp a l)) (@length nimp (nested_imps2nimps (@cons nested_imp a l))) *) simpl in |- *; trivial. (* Goal: forall (a : nested_imp) (l : list nested_imp) (_ : @eq nat (@length nested_imp l) (@length nimp (nested_imps2nimps l))), @eq nat (@length nested_imp (@cons nested_imp a l)) (@length nimp (nested_imps2nimps (@cons nested_imp a l))) *) intros x ni ih. (* Goal: in_ngamma work ds ni ai a' (NAtom i) *) simpl in |- *. (* Goal: @eq nat (S (@length nested_imp ni)) (S (@length nimp (nested_imps2nimps ni))) *) rewrite ih; trivial. Qed. (************************************************************************) (* Atomic implactions are stored in AVL Trees ai over lists of normal *) (* clauses. *) (* For the node with the key field=i and with the data field=bs, *) (* we define that, for each b in bs, (Imp (Atom i) b) is in ai. *) Definition atomic_imps := AVL nf_list. Definition AI_Nil := AVL_NIL nf_list. (************************************************************************) (* Atoms are stored in AVL Trees ai over unit. *) (* For the node with the key field=i, *) (* we define that (Atom i) is in ai. *) (* (Definition in Kripke_Trees.v *) (************************************************************************) (* The formulae on the left-hand side of the sequent are given by: *) Inductive in_ngamma (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) : normal_form -> Set := | In_Work : forall (n : nat) (c : normal_form), my_nth normal_form n work c -> in_ngamma work ds ni ai a c | In_Disjs : forall (n : nat) (i j : Int), my_nth disj n ds (i, j) -> in_ngamma work ds ni ai a (NDisj i j) | In_Nested_Imps : forall (n : nat) (x : nimp), my_nth nimp n (nested_imps2nimps ni) x -> in_ngamma work ds ni ai a (NImp_NF x) | In_Atomic_Imps : forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list), LOOKUP nf_list i ai bs -> my_nth normal_form n bs b -> in_ngamma work ds ni ai a (AImp i b) | In_Atoms : forall i : Int, LOOKUP unit i a tt -> in_ngamma work ds ni ai a (NAtom i). (********************************************************************) Lemma in_ngamma_cons_work_tail : forall (c0 : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (c : normal_form), in_ngamma work ds ni ai a c -> in_ngamma (c0 :: work) ds ni ai a c. (* Goal: forall (c0 : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (c : normal_form) (_ : in_ngamma (@cons normal_form c0 work) ds ni ai a c), sumor (in_ngamma work ds ni ai a c) (@eq normal_form c c0) *) intros c0 work ds ni ai a c in_ngamma0. (* Goal: sumor (in_ngamma work ds ni ai a c) (@eq normal_form c (NAtom i)) *) elim in_ngamma0; clear in_ngamma0 c. (* Goal: forall (n : nat) (c : normal_form) (_ : my_nth normal_form n work c), in_ngamma (@cons normal_form c0 work) ds ni ai a c *) (* Goal: forall (n : nat) (i j : Int) (_ : my_nth disj n ds (@pair Int Int i j)), in_ngamma (@cons normal_form c0 work) ds ni ai a (NDisj i j) *) (* Goal: forall (n : nat) (x : nimp) (_ : my_nth nimp n (nested_imps2nimps ni) x), in_ngamma (@cons normal_form c0 work) ds ni ai a (NImp_NF x) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), in_ngamma (@cons normal_form c0 work) ds ni ai a (AImp i b) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma (@cons normal_form c0 work) ds ni ai a (NAtom i) *) intros n a0 nth; apply In_Work with (S n); apply My_NthS; assumption. (* Goal: forall (n : nat) (i j : Int) (_ : my_nth disj n ds (@pair Int Int i j)), in_ngamma work ds ni' ai a (NDisj i j) *) (* Goal: forall (n : nat) (x : nimp) (_ : my_nth nimp n (nested_imps2nimps ni) x), in_ngamma work ds ni' ai a (NImp_NF x) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), in_ngamma work ds ni' ai a (AImp i b) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds ni' ai a (NAtom i) *) intros n i j nth; apply In_Disjs with n; assumption. (* Goal: forall (n : nat) (x : nimp) (_ : my_nth nimp n (nested_imps2nimps ni) x), in_ngamma work ds ni ai' a (NImp_NF x) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), in_ngamma work ds ni ai' a (AImp i b) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds ni ai' a (NAtom i) *) intros n x nth; apply In_Nested_Imps with n; assumption. (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), in_ngamma work ds (@app nested_imp ni1 (@cons nested_imp x ni2)) ai a (AImp i b) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds (@app nested_imp ni1 (@cons nested_imp x ni2)) ai a (NAtom i) *) intros i b n bs lookup nth; apply In_Atomic_Imps with n bs; assumption. (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds (@app nested_imp ni1 (@cons nested_imp x ni2)) ai a (NAtom i) *) intros i lookup; apply In_Atoms; assumption. Qed. Lemma in_ngamma_cons_work_head : forall (c : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms), in_ngamma (c :: work) ds ni ai a c. (* Goal: forall (c : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms), in_ngamma (@cons normal_form c work) ds ni ai a c *) intros c work ds ni ai a. (* Goal: in_ngamma (@cons normal_form c work) ds ni ai a c *) apply In_Work with 0. (* Goal: my_nth normal_form O (@cons normal_form b bs) b *) apply My_NthO. Qed. Lemma in_ngamma_work_app1 : forall (bs work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (c : normal_form), in_ngamma work ds ni ai a c -> in_ngamma (bs ++ work) ds ni ai a c. (* Goal: forall (bs work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (c : normal_form) (_ : in_ngamma (@app normal_form bs work) ds ni ai a c), sum (in_ngamma work ds ni ai a c) (@sig nat (fun n : nat => my_nth normal_form n bs c)) *) intros bs work ds ni ai a c in_ngamma0. (* Goal: sumor (in_ngamma work ds ni ai a c) (@eq normal_form c (NAtom i)) *) elim in_ngamma0; clear in_ngamma0 c. (* Goal: forall (n : nat) (c : normal_form) (_ : my_nth normal_form n (@app normal_form bs work) c), sum (in_ngamma work ds ni ai a c) (@sig nat (fun n0 : nat => my_nth normal_form n0 bs c)) *) (* Goal: forall (n : nat) (i j : Int) (_ : my_nth disj n ds (@pair Int Int i j)), sum (in_ngamma work ds ni ai a (NDisj i j)) (@sig nat (fun n0 : nat => my_nth normal_form n0 bs (NDisj i j))) *) (* Goal: forall (n : nat) (x : nimp) (_ : my_nth nimp n (nested_imps2nimps ni) x), sum (in_ngamma work ds ni ai a (NImp_NF x)) (@sig nat (fun n0 : nat => my_nth normal_form n0 bs (NImp_NF x))) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs0 : nf_list) (_ : LOOKUP nf_list i ai bs0) (_ : my_nth normal_form n bs0 b), sum (in_ngamma work ds ni ai a (AImp i b)) (@sig nat (fun n0 : nat => my_nth normal_form n0 bs (AImp i b))) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), sum (in_ngamma work ds ni ai a (NAtom i)) (@sig nat (fun n : nat => my_nth normal_form n bs (NAtom i))) *) intros n c0 nth. (* Goal: in_ngamma (@app normal_form bs work) ds ni ai a c0 *) (* Goal: forall (n : nat) (i j : Int) (_ : my_nth disj n ds (@pair Int Int i j)), in_ngamma (@app normal_form bs work) ds ni ai a (NDisj i j) *) (* Goal: forall (n : nat) (x : nimp) (_ : my_nth nimp n (nested_imps2nimps ni) x), in_ngamma (@app normal_form bs work) ds ni ai a (NImp_NF x) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs0 : nf_list) (_ : LOOKUP nf_list i ai bs0) (_ : my_nth normal_form n bs0 b), in_ngamma (@app normal_form bs work) ds ni ai a (AImp i b) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma (@app normal_form bs work) ds ni ai a (NAtom i) *) apply In_Work with (length bs + n); apply nth_app1; assumption. (* Goal: forall (n : nat) (i j : Int) (_ : my_nth disj n ds (@pair Int Int i j)), in_ngamma work ds ni' ai a (NDisj i j) *) (* Goal: forall (n : nat) (x : nimp) (_ : my_nth nimp n (nested_imps2nimps ni) x), in_ngamma work ds ni' ai a (NImp_NF x) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), in_ngamma work ds ni' ai a (AImp i b) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds ni' ai a (NAtom i) *) intros n i j nth; apply In_Disjs with n; assumption. (* Goal: forall (n : nat) (x : nimp) (_ : my_nth nimp n (nested_imps2nimps ni) x), in_ngamma work ds ni ai' a (NImp_NF x) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), in_ngamma work ds ni ai' a (AImp i b) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds ni ai' a (NAtom i) *) intros n x nth; apply In_Nested_Imps with n; assumption. (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs0 : nf_list) (_ : LOOKUP nf_list i ai bs0) (_ : my_nth normal_form n bs0 b), in_ngamma (@app normal_form bs work) ds ni ai a (AImp i b) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma (@app normal_form bs work) ds ni ai a (NAtom i) *) intros i b n bs' lookup nth; apply In_Atomic_Imps with n bs'; assumption. (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds (@app nested_imp ni1 (@cons nested_imp x ni2)) ai a (NAtom i) *) intros i lookup; apply In_Atoms; assumption. Qed. Lemma in_ngamma_work_app_rev : forall (bs work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (c : normal_form), in_ngamma (bs ++ work) ds ni ai a c -> in_ngamma work ds ni ai a c + {n : nat | my_nth normal_form n bs c}. (* Goal: forall (bs work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (c : normal_form) (_ : in_ngamma (@app normal_form bs work) ds ni ai a c), sum (in_ngamma work ds ni ai a c) (@sig nat (fun n : nat => my_nth normal_form n bs c)) *) intros bs work ds ni ai a c in_ngamma0. (* Goal: sumor (in_ngamma work ds ni ai a c) (@eq normal_form c (NAtom i)) *) elim in_ngamma0; clear in_ngamma0 c. (* Goal: forall (n : nat) (c : normal_form) (_ : my_nth normal_form n (@app normal_form bs work) c), sum (in_ngamma work ds ni ai a c) (@sig nat (fun n0 : nat => my_nth normal_form n0 bs c)) *) (* Goal: forall (n : nat) (i j : Int) (_ : my_nth disj n ds (@pair Int Int i j)), sum (in_ngamma work ds ni ai a (NDisj i j)) (@sig nat (fun n0 : nat => my_nth normal_form n0 bs (NDisj i j))) *) (* Goal: forall (n : nat) (x : nimp) (_ : my_nth nimp n (nested_imps2nimps ni) x), sum (in_ngamma work ds ni ai a (NImp_NF x)) (@sig nat (fun n0 : nat => my_nth normal_form n0 bs (NImp_NF x))) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs0 : nf_list) (_ : LOOKUP nf_list i ai bs0) (_ : my_nth normal_form n bs0 b), sum (in_ngamma work ds ni ai a (AImp i b)) (@sig nat (fun n0 : nat => my_nth normal_form n0 bs (AImp i b))) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), sum (in_ngamma work ds ni ai a (NAtom i)) (@sig nat (fun n : nat => my_nth normal_form n bs (NAtom i))) *) intros n c0 nth. (* Goal: sum (in_ngamma work ds ni ai a c0) (@sig nat (fun n : nat => my_nth normal_form n bs c0)) *) (* Goal: forall (n : nat) (i j : Int) (_ : my_nth disj n ds (@pair Int Int i j)), sum (in_ngamma work ds ni ai a (NDisj i j)) (@sig nat (fun n0 : nat => my_nth normal_form n0 bs (NDisj i j))) *) (* Goal: forall (n : nat) (x : nimp) (_ : my_nth nimp n (nested_imps2nimps ni) x), sum (in_ngamma work ds ni ai a (NImp_NF x)) (@sig nat (fun n0 : nat => my_nth normal_form n0 bs (NImp_NF x))) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs0 : nf_list) (_ : LOOKUP nf_list i ai bs0) (_ : my_nth normal_form n bs0 b), sum (in_ngamma work ds ni ai a (AImp i b)) (@sig nat (fun n0 : nat => my_nth normal_form n0 bs (AImp i b))) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), sum (in_ngamma work ds ni ai a (NAtom i)) (@sig nat (fun n : nat => my_nth normal_form n bs (NAtom i))) *) elim (inv_nth_app normal_form n bs work c0 nth); clear nth. (* Goal: forall _ : my_nth normal_form n bs c0, sum (in_ngamma work ds ni ai a c0) (@sig nat (fun n : nat => my_nth normal_form n bs c0)) *) (* Goal: forall (n' : nat) (_ : my_nth normal_form n' work c0), sum (in_ngamma work ds ni ai a c0) (@sig nat (fun n : nat => my_nth normal_form n bs c0)) *) (* Goal: forall (n : nat) (i j : Int) (_ : my_nth disj n ds (@pair Int Int i j)), sum (in_ngamma work ds ni ai a (NDisj i j)) (@sig nat (fun n0 : nat => my_nth normal_form n0 bs (NDisj i j))) *) (* Goal: forall (n : nat) (x : nimp) (_ : my_nth nimp n (nested_imps2nimps ni) x), sum (in_ngamma work ds ni ai a (NImp_NF x)) (@sig nat (fun n0 : nat => my_nth normal_form n0 bs (NImp_NF x))) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs0 : nf_list) (_ : LOOKUP nf_list i ai bs0) (_ : my_nth normal_form n bs0 b), sum (in_ngamma work ds ni ai a (AImp i b)) (@sig nat (fun n0 : nat => my_nth normal_form n0 bs (AImp i b))) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), sum (in_ngamma work ds ni ai a (NAtom i)) (@sig nat (fun n : nat => my_nth normal_form n bs (NAtom i))) *) intros nth0; right; exists n; assumption. (* Goal: forall (n' : nat) (_ : my_nth normal_form n' work c0), sum (in_ngamma work ds ni ai a c0) (@sig nat (fun n : nat => my_nth normal_form n bs c0)) *) (* Goal: forall (n : nat) (i j : Int) (_ : my_nth disj n ds (@pair Int Int i j)), sum (in_ngamma work ds ni ai a (NDisj i j)) (@sig nat (fun n0 : nat => my_nth normal_form n0 bs (NDisj i j))) *) (* Goal: forall (n : nat) (x : nimp) (_ : my_nth nimp n (nested_imps2nimps ni) x), sum (in_ngamma work ds ni ai a (NImp_NF x)) (@sig nat (fun n0 : nat => my_nth normal_form n0 bs (NImp_NF x))) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs0 : nf_list) (_ : LOOKUP nf_list i ai bs0) (_ : my_nth normal_form n bs0 b), sum (in_ngamma work ds ni ai a (AImp i b)) (@sig nat (fun n0 : nat => my_nth normal_form n0 bs (AImp i b))) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), sum (in_ngamma work ds ni ai a (NAtom i)) (@sig nat (fun n : nat => my_nth normal_form n bs (NAtom i))) *) intros n' nth1; left; apply In_Work with n'; assumption. (* Goal: forall (n : nat) (i j : Int) (_ : my_nth disj n ds (@pair Int Int i j)), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (NDisj i j)) (@eq normal_form (NDisj i j) (NImp_NF (nested_imp2nimp x))) *) (* Goal: forall (n : nat) (x0 : nimp) (_ : my_nth nimp n (nested_imps2nimps (@app nested_imp ni1 (@cons nested_imp x ni2))) x0), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (NImp_NF x0)) (@eq normal_form (NImp_NF x0) (NImp_NF (nested_imp2nimp x))) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (AImp i b)) (@eq normal_form (AImp i b) (NImp_NF (nested_imp2nimp x))) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (NAtom i)) (@eq normal_form (NAtom i) (NImp_NF (nested_imp2nimp x))) *) intros n i j nth; left; apply In_Disjs with n; assumption. (* Goal: forall (n : nat) (x : nimp) (_ : my_nth nimp n (nested_imps2nimps ni) x), sumor (in_ngamma work ds ni ai a (NImp_NF x)) (@eq normal_form (NImp_NF x) (AImp i b)) *) (* Goal: forall (i0 : Int) (b0 : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i0 ai' bs) (_ : my_nth normal_form n bs b0), sumor (in_ngamma work ds ni ai a (AImp i0 b0)) (@eq normal_form (AImp i0 b0) (AImp i b)) *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (AImp i b)) *) intros n x nth; left; apply In_Nested_Imps with n; assumption. intros i b n bs' lookup nth; left; apply In_Atomic_Imps with n bs'; (* Goal: forall (data : unit) (_ : lookup unit i t data), False *) assumption. (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (NAtom i)) (@eq normal_form (NAtom i) (NImp_NF (nested_imp2nimp x))) *) intros i lookup; left; apply In_Atoms; assumption. Qed. Lemma in_ngamma_cons_work_rev : forall (c0 : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (c : normal_form), in_ngamma (c0 :: work) ds ni ai a c -> in_ngamma work ds ni ai a c + {c = c0}. (* Goal: forall (c0 : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (c : normal_form) (_ : in_ngamma (@cons normal_form c0 work) ds ni ai a c), sumor (in_ngamma work ds ni ai a c) (@eq normal_form c c0) *) intros c0 work ds ni ai a c in_ngamma0. (* Goal: sumor (in_ngamma work ds ni ai a c) (@eq normal_form c (NAtom i)) *) elim in_ngamma0; clear in_ngamma0 c. (* Goal: forall (n : nat) (x0 : nimp) (_ : my_nth nimp n (nested_imps2nimps (@cons nested_imp x ni)) x0), sumor (in_ngamma work ds ni ai a (NImp_NF x0)) (@eq normal_form (NImp_NF x0) (NImp_NF (nested_imp2nimp x))) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), sumor (in_ngamma work ds ni ai a (AImp i b)) (@eq normal_form (AImp i b) (NImp_NF (nested_imp2nimp x))) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), sumor (in_ngamma work ds ni ai a (NAtom i)) (@eq normal_form (NAtom i) (NImp_NF (nested_imp2nimp x))) *) intros n; case n; clear n. (* Goal: forall (c : normal_form) (_ : my_nth normal_form O (@cons normal_form c0 work) c), sumor (in_ngamma work ds ni ai a c) (@eq normal_form c c0) *) (* Goal: forall (n : nat) (c : normal_form) (_ : my_nth normal_form (S n) (@cons normal_form c0 work) c), sumor (in_ngamma work ds ni ai a c) (@eq normal_form c c0) *) (* Goal: forall (n : nat) (i j : Int) (_ : my_nth disj n ds (@pair Int Int i j)), sumor (in_ngamma work ds ni ai a (NDisj i j)) (@eq normal_form (NDisj i j) c0) *) (* Goal: forall (n : nat) (x : nimp) (_ : my_nth nimp n (nested_imps2nimps ni) x), sumor (in_ngamma work ds ni ai a (NImp_NF x)) (@eq normal_form (NImp_NF x) c0) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), sumor (in_ngamma work ds ni ai a (AImp i b)) (@eq normal_form (AImp i b) c0) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), sumor (in_ngamma work ds ni ai a (NAtom i)) (@eq normal_form (NAtom i) c0) *) intros a0 nth; right; inversion_clear nth; trivial. (* Goal: forall (n : nat) (c : normal_form) (_ : my_nth normal_form (S n) (@cons normal_form c0 work) c), sumor (in_ngamma work ds ni ai a c) (@eq normal_form c c0) *) (* Goal: forall (n : nat) (i j : Int) (_ : my_nth disj n ds (@pair Int Int i j)), sumor (in_ngamma work ds ni ai a (NDisj i j)) (@eq normal_form (NDisj i j) c0) *) (* Goal: forall (n : nat) (x : nimp) (_ : my_nth nimp n (nested_imps2nimps ni) x), sumor (in_ngamma work ds ni ai a (NImp_NF x)) (@eq normal_form (NImp_NF x) c0) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), sumor (in_ngamma work ds ni ai a (AImp i b)) (@eq normal_form (AImp i b) c0) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), sumor (in_ngamma work ds ni ai a (NAtom i)) (@eq normal_form (NAtom i) c0) *) intros n c1 nth; left; apply In_Work with n; inversion_clear nth; assumption. (* Goal: forall (n : nat) (i j : Int) (_ : my_nth disj n ds (@pair Int Int i j)), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (NDisj i j)) (@eq normal_form (NDisj i j) (NImp_NF (nested_imp2nimp x))) *) (* Goal: forall (n : nat) (x0 : nimp) (_ : my_nth nimp n (nested_imps2nimps (@app nested_imp ni1 (@cons nested_imp x ni2))) x0), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (NImp_NF x0)) (@eq normal_form (NImp_NF x0) (NImp_NF (nested_imp2nimp x))) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (AImp i b)) (@eq normal_form (AImp i b) (NImp_NF (nested_imp2nimp x))) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (NAtom i)) (@eq normal_form (NAtom i) (NImp_NF (nested_imp2nimp x))) *) intros n i j nth; left; apply In_Disjs with n; assumption. (* Goal: forall (n : nat) (x : nimp) (_ : my_nth nimp n (nested_imps2nimps ni) x), sumor (in_ngamma work ds ni ai a (NImp_NF x)) (@eq normal_form (NImp_NF x) (AImp i b)) *) (* Goal: forall (i0 : Int) (b0 : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i0 ai' bs) (_ : my_nth normal_form n bs b0), sumor (in_ngamma work ds ni ai a (AImp i0 b0)) (@eq normal_form (AImp i0 b0) (AImp i b)) *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (AImp i b)) *) intros n x nth; left; apply In_Nested_Imps with n; assumption. (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (AImp i b)) (@eq normal_form (AImp i b) (NImp_NF (nested_imp2nimp x))) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (NAtom i)) (@eq normal_form (NAtom i) (NImp_NF (nested_imp2nimp x))) *) intros i b n bs lookup nth; left; apply In_Atomic_Imps with n bs; assumption. (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (NAtom i)) (@eq normal_form (NAtom i) (NImp_NF (nested_imp2nimp x))) *) intros i lookup; left; apply In_Atoms; assumption. Qed. Lemma in_ngamma_cons_ds_tail : forall (work : nf_list) (i j : Int) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (c : normal_form), in_ngamma work ds ni ai a c -> in_ngamma work ((i, j) :: ds) ni ai a c. (* Goal: forall (work : nf_list) (i j : Int) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (c : normal_form) (_ : in_ngamma work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a c), sumor (in_ngamma work ds ni ai a c) (@eq normal_form c (NDisj i j)) *) intros work i j ds ni ai a c in_ngamma0. (* Goal: sumor (in_ngamma work ds ni ai a c) (@eq normal_form c (NAtom i)) *) elim in_ngamma0; clear in_ngamma0 c. (* Goal: forall (n : nat) (c : normal_form) (_ : my_nth normal_form n work c), in_ngamma work ds ni ai a' c *) (* Goal: forall (n : nat) (i j : Int) (_ : my_nth disj n ds (@pair Int Int i j)), in_ngamma work ds ni ai a' (NDisj i j) *) (* Goal: forall (n : nat) (x : nimp) (_ : my_nth nimp n (nested_imps2nimps ni) x), in_ngamma work ds ni ai a' (NImp_NF x) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), in_ngamma work ds ni ai a' (AImp i b) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds ni ai a' (NAtom i) *) intros n c0 nth; apply In_Work with n; assumption. (* Goal: forall (n : nat) (i0 j0 : Int) (_ : my_nth disj n ds (@pair Int Int i0 j0)), in_ngamma work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a (NDisj i0 j0) *) (* Goal: forall (n : nat) (x : nimp) (_ : my_nth nimp n (nested_imps2nimps ni) x), in_ngamma work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a (NImp_NF x) *) (* Goal: forall (i0 : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i0 ai bs) (_ : my_nth normal_form n bs b), in_ngamma work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a (AImp i0 b) *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), in_ngamma work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a (NAtom i0) *) intros n i' j' nth; apply In_Disjs with (S n); apply My_NthS; assumption. (* Goal: forall (n : nat) (x : nimp) (_ : my_nth nimp n (nested_imps2nimps ni) x), in_ngamma work ds ni ai' a (NImp_NF x) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), in_ngamma work ds ni ai' a (AImp i b) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds ni ai' a (NAtom i) *) intros n x nth; apply In_Nested_Imps with n; assumption. (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), in_ngamma work ds ni' ai a (AImp i b) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds ni' ai a (NAtom i) *) intros i' b n bs lookup nth; apply In_Atomic_Imps with n bs; assumption. (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds ni ai' a (NAtom i) *) intros i' lookup; apply In_Atoms; assumption. Qed. Lemma in_ngamma_cons_ds_head : forall (work : nf_list) (i j : Int) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms), in_ngamma work ((i, j) :: ds) ni ai a (NDisj i j). (* Goal: forall (work : nf_list) (i j : Int) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms), in_ngamma work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a (NDisj i j) *) intros work i j ds ni ai a. (* Goal: in_ngamma work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a (NDisj i j) *) apply In_Disjs with 0. (* Goal: my_nth normal_form O (@cons normal_form b bs) b *) apply My_NthO. Qed. Lemma in_ngamma_cons_ds_rev : forall (work : nf_list) (i j : Int) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (c : normal_form), in_ngamma work ((i, j) :: ds) ni ai a c -> in_ngamma work ds ni ai a c + {c = NDisj i j}. (* Goal: forall (work : nf_list) (i j : Int) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (c : normal_form) (_ : in_ngamma work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a c), sumor (in_ngamma work ds ni ai a c) (@eq normal_form c (NDisj i j)) *) intros work i j ds ni ai a c in_ngamma0. (* Goal: sumor (in_ngamma work ds ni ai a c) (@eq normal_form c (NAtom i)) *) elim in_ngamma0; clear in_ngamma0 c. (* Goal: forall (n : nat) (c : normal_form) (_ : my_nth normal_form n work c), sumor (in_ngamma work ds ni ai a c) (@eq normal_form c (NAtom i)) *) (* Goal: forall (n : nat) (i0 j : Int) (_ : my_nth disj n ds (@pair Int Int i0 j)), sumor (in_ngamma work ds ni ai a (NDisj i0 j)) (@eq normal_form (NDisj i0 j) (NAtom i)) *) (* Goal: forall (n : nat) (x : nimp) (_ : my_nth nimp n (nested_imps2nimps ni) x), sumor (in_ngamma work ds ni ai a (NImp_NF x)) (@eq normal_form (NImp_NF x) (NAtom i)) *) (* Goal: forall (i0 : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i0 ai bs) (_ : my_nth normal_form n bs b), sumor (in_ngamma work ds ni ai a (AImp i0 b)) (@eq normal_form (AImp i0 b) (NAtom i)) *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a' tt), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (NAtom i)) *) intros n c0 nth; left; apply In_Work with n; assumption. (* Goal: forall (n : nat) (x0 : nimp) (_ : my_nth nimp n (nested_imps2nimps (@cons nested_imp x ni)) x0), sumor (in_ngamma work ds ni ai a (NImp_NF x0)) (@eq normal_form (NImp_NF x0) (NImp_NF (nested_imp2nimp x))) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), sumor (in_ngamma work ds ni ai a (AImp i b)) (@eq normal_form (AImp i b) (NImp_NF (nested_imp2nimp x))) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), sumor (in_ngamma work ds ni ai a (NAtom i)) (@eq normal_form (NAtom i) (NImp_NF (nested_imp2nimp x))) *) intros n; case n; clear n. (* Goal: forall (i0 j0 : Int) (_ : my_nth disj O (@cons (prod Int Int) (@pair Int Int i j) ds) (@pair Int Int i0 j0)), sumor (in_ngamma work ds ni ai a (NDisj i0 j0)) (@eq normal_form (NDisj i0 j0) (NDisj i j)) *) (* Goal: forall (n : nat) (i0 j0 : Int) (_ : my_nth disj (S n) (@cons (prod Int Int) (@pair Int Int i j) ds) (@pair Int Int i0 j0)), sumor (in_ngamma work ds ni ai a (NDisj i0 j0)) (@eq normal_form (NDisj i0 j0) (NDisj i j)) *) (* Goal: forall (n : nat) (x : nimp) (_ : my_nth nimp n (nested_imps2nimps ni) x), sumor (in_ngamma work ds ni ai a (NImp_NF x)) (@eq normal_form (NImp_NF x) (NDisj i j)) *) (* Goal: forall (i0 : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i0 ai bs) (_ : my_nth normal_form n bs b), sumor (in_ngamma work ds ni ai a (AImp i0 b)) (@eq normal_form (AImp i0 b) (NDisj i j)) *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (NDisj i j)) *) intros i' j' nth; right; inversion_clear nth; trivial. intros n i' j' nth; left; apply In_Disjs with n; inversion_clear nth; (* Goal: forall (data : unit) (_ : lookup unit i t data), False *) assumption. (* Goal: forall (n : nat) (x : nimp) (_ : my_nth nimp n (nested_imps2nimps ni) x), sumor (in_ngamma work ds ni ai a (NImp_NF x)) (@eq normal_form (NImp_NF x) (AImp i b)) *) (* Goal: forall (i0 : Int) (b0 : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i0 ai' bs) (_ : my_nth normal_form n bs b0), sumor (in_ngamma work ds ni ai a (AImp i0 b0)) (@eq normal_form (AImp i0 b0) (AImp i b)) *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (AImp i b)) *) intros n x nth; left; apply In_Nested_Imps with n; assumption. (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), sumor (in_ngamma work ds ni ai a (AImp i b)) (@eq normal_form (AImp i b) (NImp_NF (nested_imp2nimp x))) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), sumor (in_ngamma work ds ni ai a (NAtom i)) (@eq normal_form (NAtom i) (NImp_NF (nested_imp2nimp x))) *) intros i' b n bs lookup nth; left; apply In_Atomic_Imps with n bs; assumption. (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (AImp i b)) *) intros i' lookup; left; apply In_Atoms; assumption. Qed. Lemma in_ngamma_cons_ni_tail : forall (work : nf_list) (ds : disjs) (x : nested_imp) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (c : normal_form), in_ngamma work ds ni ai a c -> in_ngamma work ds (x :: ni) ai a c. (* Goal: forall (work : nf_list) (ds : disjs) (x : nested_imp) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (c : normal_form) (_ : in_ngamma work ds (@cons nested_imp x ni) ai a c), sumor (in_ngamma work ds ni ai a c) (@eq normal_form c (NImp_NF (nested_imp2nimp x))) *) intros work ds x ni ai a c in_ngamma0. (* Goal: sumor (in_ngamma work ds ni ai a c) (@eq normal_form c (NAtom i)) *) elim in_ngamma0; clear in_ngamma0 c. (* Goal: forall (n : nat) (c : normal_form) (_ : my_nth normal_form n work c), in_ngamma work ds ni ai a' c *) (* Goal: forall (n : nat) (i j : Int) (_ : my_nth disj n ds (@pair Int Int i j)), in_ngamma work ds ni ai a' (NDisj i j) *) (* Goal: forall (n : nat) (x : nimp) (_ : my_nth nimp n (nested_imps2nimps ni) x), in_ngamma work ds ni ai a' (NImp_NF x) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), in_ngamma work ds ni ai a' (AImp i b) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds ni ai a' (NAtom i) *) intros n c0 nth; apply In_Work with n; assumption. (* Goal: forall (n : nat) (i j : Int) (_ : my_nth disj n ds (@pair Int Int i j)), in_ngamma work ds ni' ai a (NDisj i j) *) (* Goal: forall (n : nat) (x : nimp) (_ : my_nth nimp n (nested_imps2nimps ni) x), in_ngamma work ds ni' ai a (NImp_NF x) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), in_ngamma work ds ni' ai a (AImp i b) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds ni' ai a (NAtom i) *) intros n i j nth; apply In_Disjs with n; assumption. (* Goal: forall (n : nat) (x0 : nimp) (_ : my_nth nimp n (nested_imps2nimps ni) x0), in_ngamma work ds (@cons nested_imp x ni) ai a (NImp_NF x0) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), in_ngamma work ds (@cons nested_imp x ni) ai a (AImp i b) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds (@cons nested_imp x ni) ai a (NAtom i) *) intros n x' nth; apply In_Nested_Imps with (S n). (* Goal: my_nth nimp (S n') (nested_imps2nimps (@cons nested_imp x ni2)) x0 *) (* Goal: my_nth nimp n (@app nimp (nested_imps2nimps ni1) (nested_imps2nimps ni2)) x0 *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), in_ngamma work ds (@app nested_imp ni1 (@cons nested_imp x ni2)) ai a (AImp i b) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds (@app nested_imp ni1 (@cons nested_imp x ni2)) ai a (NAtom i) *) simpl in |- *; apply My_NthS; assumption. (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), in_ngamma work ds ni' ai a (AImp i b) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds ni' ai a (NAtom i) *) intros i' b n bs lookup nth; apply In_Atomic_Imps with n bs; assumption. (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds ni ai' a (NAtom i) *) intros i' lookup; apply In_Atoms; assumption. Qed. Lemma in_ngamma_cons_ni_head : forall (work : nf_list) (ds : disjs) (x : nested_imp) (ni : nested_imps) (ai : atomic_imps) (a : atoms), in_ngamma work ds (x :: ni) ai a (NImp_NF (nested_imp2nimp x)). (* Goal: forall (work : nf_list) (ds : disjs) (x : nested_imp) (ni : nested_imps) (ai : atomic_imps) (a : atoms), in_ngamma work ds (@cons nested_imp x ni) ai a (NImp_NF (nested_imp2nimp x)) *) intros work ds x ni ai a. (* Goal: my_nth normal_form O (@cons normal_form b bs) b *) apply In_Nested_Imps with 0; simpl in |- *; apply My_NthO. Qed. Lemma in_ngamma_cons_ni_rev : forall (work : nf_list) (ds : disjs) (x : nested_imp) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (c : normal_form), in_ngamma work ds (x :: ni) ai a c -> in_ngamma work ds ni ai a c + {c = NImp_NF (nested_imp2nimp x)}. (* Goal: forall (work : nf_list) (ds : disjs) (x : nested_imp) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (c : normal_form) (_ : in_ngamma work ds (@cons nested_imp x ni) ai a c), sumor (in_ngamma work ds ni ai a c) (@eq normal_form c (NImp_NF (nested_imp2nimp x))) *) intros work ds x ni ai a c in_ngamma0. (* Goal: sumor (in_ngamma work ds ni ai a c) (@eq normal_form c (NAtom i)) *) elim in_ngamma0; clear in_ngamma0 c. (* Goal: forall (n : nat) (c : normal_form) (_ : my_nth normal_form n work c), sumor (in_ngamma work ds ni ai a c) (@eq normal_form c (NImp_NF (nested_imp2nimp x))) *) (* Goal: forall (n : nat) (i j : Int) (_ : my_nth disj n ds (@pair Int Int i j)), sumor (in_ngamma work ds ni ai a (NDisj i j)) (@eq normal_form (NDisj i j) (NImp_NF (nested_imp2nimp x))) *) (* Goal: forall (n : nat) (x0 : nimp) (_ : my_nth nimp n (nested_imps2nimps (@cons nested_imp x ni)) x0), sumor (in_ngamma work ds ni ai a (NImp_NF x0)) (@eq normal_form (NImp_NF x0) (NImp_NF (nested_imp2nimp x))) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), sumor (in_ngamma work ds ni ai a (AImp i b)) (@eq normal_form (AImp i b) (NImp_NF (nested_imp2nimp x))) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), sumor (in_ngamma work ds ni ai a (NAtom i)) (@eq normal_form (NAtom i) (NImp_NF (nested_imp2nimp x))) *) intros n c1 nth; left; apply In_Work with n; assumption. (* Goal: forall (n : nat) (i0 j : Int) (_ : my_nth disj n ds (@pair Int Int i0 j)), sumor (in_ngamma work ds ni ai a (NDisj i0 j)) (@eq normal_form (NDisj i0 j) (NAtom i)) *) (* Goal: forall (n : nat) (x : nimp) (_ : my_nth nimp n (nested_imps2nimps ni) x), sumor (in_ngamma work ds ni ai a (NImp_NF x)) (@eq normal_form (NImp_NF x) (NAtom i)) *) (* Goal: forall (i0 : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i0 ai bs) (_ : my_nth normal_form n bs b), sumor (in_ngamma work ds ni ai a (AImp i0 b)) (@eq normal_form (AImp i0 b) (NAtom i)) *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a' tt), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (NAtom i)) *) intros n i' j' nth; left; apply In_Disjs with n; assumption. (* Goal: forall (n : nat) (x0 : nimp) (_ : my_nth nimp n (nested_imps2nimps (@cons nested_imp x ni)) x0), sumor (in_ngamma work ds ni ai a (NImp_NF x0)) (@eq normal_form (NImp_NF x0) (NImp_NF (nested_imp2nimp x))) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), sumor (in_ngamma work ds ni ai a (AImp i b)) (@eq normal_form (AImp i b) (NImp_NF (nested_imp2nimp x))) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), sumor (in_ngamma work ds ni ai a (NAtom i)) (@eq normal_form (NAtom i) (NImp_NF (nested_imp2nimp x))) *) intros n; case n; clear n. (* Goal: forall (x0 : nimp) (_ : my_nth nimp O (nested_imps2nimps (@cons nested_imp x ni)) x0), sumor (in_ngamma work ds ni ai a (NImp_NF x0)) (@eq normal_form (NImp_NF x0) (NImp_NF (nested_imp2nimp x))) *) (* Goal: forall (n : nat) (x0 : nimp) (_ : my_nth nimp (S n) (nested_imps2nimps (@cons nested_imp x ni)) x0), sumor (in_ngamma work ds ni ai a (NImp_NF x0)) (@eq normal_form (NImp_NF x0) (NImp_NF (nested_imp2nimp x))) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), sumor (in_ngamma work ds ni ai a (AImp i b)) (@eq normal_form (AImp i b) (NImp_NF (nested_imp2nimp x))) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), sumor (in_ngamma work ds ni ai a (NAtom i)) (@eq normal_form (NAtom i) (NImp_NF (nested_imp2nimp x))) *) intros x' nth; right; inversion_clear nth; trivial. intros n x' nth; left; apply In_Nested_Imps with n; inversion_clear nth; (* Goal: forall (data : unit) (_ : lookup unit i t data), False *) assumption. (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), sumor (in_ngamma work ds ni ai a (AImp i b)) (@eq normal_form (AImp i b) (NImp_NF (nested_imp2nimp x))) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), sumor (in_ngamma work ds ni ai a (NAtom i)) (@eq normal_form (NAtom i) (NImp_NF (nested_imp2nimp x))) *) intros i' b n bs lookup nth; left; apply In_Atomic_Imps with n bs; assumption. (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (AImp i b)) *) intros i' lookup; left; apply In_Atoms; assumption. Qed. Lemma in_ngamma_ni_x_ni_head : forall (work : nf_list) (ds : disjs) (x : nested_imp) (ni1 ni2 : nested_imps) (ai : atomic_imps) (a : atoms), in_ngamma work ds (ni1 ++ x :: ni2) ai a (NImp_NF (nested_imp2nimp x)). (* Goal: forall (work : nf_list) (ds : disjs) (x : nested_imp) (ni1 ni2 : nested_imps) (ai : atomic_imps) (a : atoms), in_ngamma work ds (@app nested_imp ni1 (@cons nested_imp x ni2)) ai a (NImp_NF (nested_imp2nimp x)) *) intros work ds x ni1 ni2 ai a. (* Goal: in_ngamma work ds (@app nested_imp ni1 (@cons nested_imp x ni2)) ai a (NImp_NF (nested_imp2nimp x)) *) apply In_Nested_Imps with (n := length ni1) (x := nested_imp2nimp x). (* Goal: my_nth nimp (Nat.add (@length nested_imp ni1) (S n')) (nested_imps2nimps (@app nested_imp ni1 (@cons nested_imp x ni2))) x0 *) (* Goal: my_nth nimp n (@app nimp (nested_imps2nimps ni1) (nested_imps2nimps ni2)) x0 *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), in_ngamma work ds (@app nested_imp ni1 (@cons nested_imp x ni2)) ai a (AImp i b) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds (@app nested_imp ni1 (@cons nested_imp x ni2)) ai a (NAtom i) *) rewrite (nested_imps2nimps_app ni1 (x :: ni2)). (* Goal: my_nth nimp (Nat.add (@length nested_imp ni1) n') (nested_imps2nimps (@app nested_imp ni1 ni2)) x0 *) (* Goal: my_nth nimp n (@app nimp (nested_imps2nimps ni1) (nested_imps2nimps (@cons nested_imp x ni2))) x0 *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (AImp i b)) (@eq normal_form (AImp i b) (NImp_NF (nested_imp2nimp x))) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (NAtom i)) (@eq normal_form (NAtom i) (NImp_NF (nested_imp2nimp x))) *) rewrite (nested_imps2nimps_length ni1). (* Goal: my_nth nimp (@length nimp (nested_imps2nimps ni1)) (@app nimp (nested_imps2nimps ni1) (nested_imps2nimps (@cons nested_imp x ni2))) (nested_imp2nimp x) *) rewrite <- (plus_O (length (nested_imps2nimps ni1))). (* Goal: my_nth nimp (Nat.add (@length nimp (nested_imps2nimps ni1)) n') (@app nimp (nested_imps2nimps ni1) (nested_imps2nimps ni2)) x0 *) (* Goal: my_nth nimp n (@app nimp (nested_imps2nimps ni1) (nested_imps2nimps (@cons nested_imp x ni2))) x0 *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (AImp i b)) (@eq normal_form (AImp i b) (NImp_NF (nested_imp2nimp x))) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (NAtom i)) (@eq normal_form (NAtom i) (NImp_NF (nested_imp2nimp x))) *) apply nth_app1. (* Goal: my_nth normal_form O (@cons normal_form b bs) b *) simpl in |- *; apply My_NthO. Qed. Lemma in_ngamma_ni_x_ni_tail : forall (work : nf_list) (ds : disjs) (x : nested_imp) (ni1 ni2 : nested_imps) (ai : atomic_imps) (a : atoms) (c : normal_form), in_ngamma work ds (ni1 ++ ni2) ai a c -> in_ngamma work ds (ni1 ++ x :: ni2) ai a c. (* Goal: forall (work : nf_list) (ds : disjs) (x : nested_imp) (ni1 ni2 : nested_imps) (ai : atomic_imps) (a : atoms) (c : normal_form) (_ : in_ngamma work ds (@app nested_imp ni1 (@cons nested_imp x ni2)) ai a c), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a c) (@eq normal_form c (NImp_NF (nested_imp2nimp x))) *) intros work ds x ni1 ni2 ai a c in_ngamma0. (* Goal: sumor (in_ngamma work ds ni ai a c) (@eq normal_form c (NAtom i)) *) elim in_ngamma0; clear in_ngamma0 c. (* Goal: forall (n : nat) (c : normal_form) (_ : my_nth normal_form n work c), in_ngamma work ds ni ai a' c *) (* Goal: forall (n : nat) (i j : Int) (_ : my_nth disj n ds (@pair Int Int i j)), in_ngamma work ds ni ai a' (NDisj i j) *) (* Goal: forall (n : nat) (x : nimp) (_ : my_nth nimp n (nested_imps2nimps ni) x), in_ngamma work ds ni ai a' (NImp_NF x) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), in_ngamma work ds ni ai a' (AImp i b) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds ni ai a' (NAtom i) *) intros n c0 nth; apply In_Work with n; assumption. (* Goal: forall (n : nat) (i j : Int) (_ : my_nth disj n ds (@pair Int Int i j)), in_ngamma work ds ni' ai a (NDisj i j) *) (* Goal: forall (n : nat) (x : nimp) (_ : my_nth nimp n (nested_imps2nimps ni) x), in_ngamma work ds ni' ai a (NImp_NF x) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), in_ngamma work ds ni' ai a (AImp i b) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds ni' ai a (NAtom i) *) intros n i j nth; apply In_Disjs with n; assumption. (* Goal: forall (n : nat) (x0 : nimp) (_ : my_nth nimp n (nested_imps2nimps (@app nested_imp ni1 (@cons nested_imp x ni2))) x0), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (NImp_NF x0)) (@eq normal_form (NImp_NF x0) (NImp_NF (nested_imp2nimp x))) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (AImp i b)) (@eq normal_form (AImp i b) (NImp_NF (nested_imp2nimp x))) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (NAtom i)) (@eq normal_form (NAtom i) (NImp_NF (nested_imp2nimp x))) *) intros n x0 nth. (* Goal: in_ngamma work ds (@app nested_imp ni1 (@cons nested_imp x ni2)) ai a (NImp_NF x0) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), in_ngamma work ds (@app nested_imp ni1 (@cons nested_imp x ni2)) ai a (AImp i b) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds (@app nested_imp ni1 (@cons nested_imp x ni2)) ai a (NAtom i) *) elim (inv_nth_app nimp n (nested_imps2nimps ni1) (nested_imps2nimps ni2) x0). (* Goal: forall _ : my_nth nimp n (nested_imps2nimps ni1) x0, in_ngamma work ds (@app nested_imp ni1 (@cons nested_imp x ni2)) ai a (NImp_NF x0) *) (* Goal: forall (n' : nat) (_ : my_nth nimp n' (nested_imps2nimps ni2) x0), in_ngamma work ds (@app nested_imp ni1 (@cons nested_imp x ni2)) ai a (NImp_NF x0) *) (* Goal: my_nth nimp n (@app nimp (nested_imps2nimps ni1) (nested_imps2nimps ni2)) x0 *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), in_ngamma work ds (@app nested_imp ni1 (@cons nested_imp x ni2)) ai a (AImp i b) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds (@app nested_imp ni1 (@cons nested_imp x ni2)) ai a (NAtom i) *) intros nth'; apply In_Nested_Imps with n. (* Goal: my_nth nimp (Nat.add (@length nested_imp ni1) (S n')) (nested_imps2nimps (@app nested_imp ni1 (@cons nested_imp x ni2))) x0 *) (* Goal: my_nth nimp n (@app nimp (nested_imps2nimps ni1) (nested_imps2nimps ni2)) x0 *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), in_ngamma work ds (@app nested_imp ni1 (@cons nested_imp x ni2)) ai a (AImp i b) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds (@app nested_imp ni1 (@cons nested_imp x ni2)) ai a (NAtom i) *) rewrite (nested_imps2nimps_app ni1 (x :: ni2)). (* Goal: my_nth nimp n (@app nimp (nested_imps2nimps ni1) (nested_imps2nimps ni2)) x0 *) (* Goal: forall (n' : nat) (_ : my_nth nimp n' (nested_imps2nimps (@cons nested_imp x ni2)) x0), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (NImp_NF x0)) (@eq normal_form (NImp_NF x0) (NImp_NF (nested_imp2nimp x))) *) (* Goal: my_nth nimp n (@app nimp (nested_imps2nimps ni1) (nested_imps2nimps (@cons nested_imp x ni2))) x0 *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (AImp i b)) (@eq normal_form (AImp i b) (NImp_NF (nested_imp2nimp x))) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (NAtom i)) (@eq normal_form (NAtom i) (NImp_NF (nested_imp2nimp x))) *) apply nth_app0; assumption. (* Goal: forall (n' : nat) (_ : my_nth nimp n' (nested_imps2nimps ni2) x0), in_ngamma work ds (@app nested_imp ni1 (@cons nested_imp x ni2)) ai a (NImp_NF x0) *) (* Goal: my_nth nimp n (@app nimp (nested_imps2nimps ni1) (nested_imps2nimps ni2)) x0 *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), in_ngamma work ds (@app nested_imp ni1 (@cons nested_imp x ni2)) ai a (AImp i b) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds (@app nested_imp ni1 (@cons nested_imp x ni2)) ai a (NAtom i) *) intros n' nth'; apply In_Nested_Imps with (length ni1 + S n'). (* Goal: my_nth nimp (Nat.add (@length nested_imp ni1) (S n')) (nested_imps2nimps (@app nested_imp ni1 (@cons nested_imp x ni2))) x0 *) (* Goal: my_nth nimp n (@app nimp (nested_imps2nimps ni1) (nested_imps2nimps ni2)) x0 *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), in_ngamma work ds (@app nested_imp ni1 (@cons nested_imp x ni2)) ai a (AImp i b) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds (@app nested_imp ni1 (@cons nested_imp x ni2)) ai a (NAtom i) *) rewrite (nested_imps2nimps_app ni1 (x :: ni2)). (* Goal: my_nth nimp (Nat.add (@length nested_imp ni1) n') (nested_imps2nimps (@app nested_imp ni1 ni2)) x0 *) (* Goal: my_nth nimp n (@app nimp (nested_imps2nimps ni1) (nested_imps2nimps (@cons nested_imp x ni2))) x0 *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (AImp i b)) (@eq normal_form (AImp i b) (NImp_NF (nested_imp2nimp x))) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (NAtom i)) (@eq normal_form (NAtom i) (NImp_NF (nested_imp2nimp x))) *) rewrite (nested_imps2nimps_length ni1). (* Goal: my_nth nimp (Nat.add (@length nimp (nested_imps2nimps ni1)) n') (@app nimp (nested_imps2nimps ni1) (nested_imps2nimps ni2)) x0 *) (* Goal: my_nth nimp n (@app nimp (nested_imps2nimps ni1) (nested_imps2nimps (@cons nested_imp x ni2))) x0 *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (AImp i b)) (@eq normal_form (AImp i b) (NImp_NF (nested_imp2nimp x))) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (NAtom i)) (@eq normal_form (NAtom i) (NImp_NF (nested_imp2nimp x))) *) apply nth_app1. (* Goal: my_nth nimp (S n') (nested_imps2nimps (@cons nested_imp x ni2)) x0 *) (* Goal: my_nth nimp n (@app nimp (nested_imps2nimps ni1) (nested_imps2nimps ni2)) x0 *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), in_ngamma work ds (@app nested_imp ni1 (@cons nested_imp x ni2)) ai a (AImp i b) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds (@app nested_imp ni1 (@cons nested_imp x ni2)) ai a (NAtom i) *) simpl in |- *; apply My_NthS; assumption. (* Goal: my_nth nimp n (@app nimp (nested_imps2nimps ni1) (nested_imps2nimps ni2)) x0 *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), in_ngamma work ds (@app nested_imp ni1 (@cons nested_imp x ni2)) ai a (AImp i b) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds (@app nested_imp ni1 (@cons nested_imp x ni2)) ai a (NAtom i) *) rewrite <- (nested_imps2nimps_app ni1 ni2); assumption. (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), in_ngamma work ds (@app nested_imp ni1 (@cons nested_imp x ni2)) ai a (AImp i b) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds (@app nested_imp ni1 (@cons nested_imp x ni2)) ai a (NAtom i) *) intros i b n bs lookup nth; apply In_Atomic_Imps with n bs; assumption. (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds (@app nested_imp ni1 (@cons nested_imp x ni2)) ai a (NAtom i) *) intros i lookup; apply In_Atoms; assumption. Qed. Lemma in_ngamma_ni_x_ni_rev : forall (work : nf_list) (ds : disjs) (x : nested_imp) (ni1 ni2 : nested_imps) (ai : atomic_imps) (a : atoms) (c : normal_form), in_ngamma work ds (ni1 ++ x :: ni2) ai a c -> in_ngamma work ds (ni1 ++ ni2) ai a c + {c = NImp_NF (nested_imp2nimp x)}. (* Goal: forall (work : nf_list) (ds : disjs) (x : nested_imp) (ni1 ni2 : nested_imps) (ai : atomic_imps) (a : atoms) (c : normal_form) (_ : in_ngamma work ds (@app nested_imp ni1 (@cons nested_imp x ni2)) ai a c), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a c) (@eq normal_form c (NImp_NF (nested_imp2nimp x))) *) intros work ds x ni1 ni2 ai a c in_ngamma0. (* Goal: sumor (in_ngamma work ds ni ai a c) (@eq normal_form c (NAtom i)) *) elim in_ngamma0; clear in_ngamma0 c. (* Goal: forall (n : nat) (c : normal_form) (_ : my_nth normal_form n work c), sumor (in_ngamma work ds ni ai a c) (@eq normal_form c (NAtom i)) *) (* Goal: forall (n : nat) (i0 j : Int) (_ : my_nth disj n ds (@pair Int Int i0 j)), sumor (in_ngamma work ds ni ai a (NDisj i0 j)) (@eq normal_form (NDisj i0 j) (NAtom i)) *) (* Goal: forall (n : nat) (x : nimp) (_ : my_nth nimp n (nested_imps2nimps ni) x), sumor (in_ngamma work ds ni ai a (NImp_NF x)) (@eq normal_form (NImp_NF x) (NAtom i)) *) (* Goal: forall (i0 : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i0 ai bs) (_ : my_nth normal_form n bs b), sumor (in_ngamma work ds ni ai a (AImp i0 b)) (@eq normal_form (AImp i0 b) (NAtom i)) *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a' tt), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (NAtom i)) *) intros n c0 nth; left; apply In_Work with n; assumption. (* Goal: forall (n : nat) (i j : Int) (_ : my_nth disj n ds (@pair Int Int i j)), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (NDisj i j)) (@eq normal_form (NDisj i j) (NImp_NF (nested_imp2nimp x))) *) (* Goal: forall (n : nat) (x0 : nimp) (_ : my_nth nimp n (nested_imps2nimps (@app nested_imp ni1 (@cons nested_imp x ni2))) x0), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (NImp_NF x0)) (@eq normal_form (NImp_NF x0) (NImp_NF (nested_imp2nimp x))) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (AImp i b)) (@eq normal_form (AImp i b) (NImp_NF (nested_imp2nimp x))) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (NAtom i)) (@eq normal_form (NAtom i) (NImp_NF (nested_imp2nimp x))) *) intros n i j nth; left; apply In_Disjs with n; assumption. (* Goal: forall (n : nat) (x0 : nimp) (_ : my_nth nimp n (nested_imps2nimps (@app nested_imp ni1 (@cons nested_imp x ni2))) x0), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (NImp_NF x0)) (@eq normal_form (NImp_NF x0) (NImp_NF (nested_imp2nimp x))) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (AImp i b)) (@eq normal_form (AImp i b) (NImp_NF (nested_imp2nimp x))) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (NAtom i)) (@eq normal_form (NAtom i) (NImp_NF (nested_imp2nimp x))) *) intros n x0 nth. elim (inv_nth_app nimp n (nested_imps2nimps ni1) (nested_imps2nimps (x :: ni2)) x0). (* Goal: forall _ : my_nth nimp n (nested_imps2nimps ni1) x0, sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (NImp_NF x0)) (@eq normal_form (NImp_NF x0) (NImp_NF (nested_imp2nimp x))) *) (* Goal: forall (n' : nat) (_ : my_nth nimp n' (nested_imps2nimps (@cons nested_imp x ni2)) x0), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (NImp_NF x0)) (@eq normal_form (NImp_NF x0) (NImp_NF (nested_imp2nimp x))) *) (* Goal: my_nth nimp n (@app nimp (nested_imps2nimps ni1) (nested_imps2nimps (@cons nested_imp x ni2))) x0 *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (AImp i b)) (@eq normal_form (AImp i b) (NImp_NF (nested_imp2nimp x))) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (NAtom i)) (@eq normal_form (NAtom i) (NImp_NF (nested_imp2nimp x))) *) intros n0; left; apply In_Nested_Imps with n. (* Goal: my_nth nimp (Nat.add (@length nimp (nested_imps2nimps ni1)) n') (nested_imps2nimps (@app nested_imp ni1 ni2)) x0 *) (* Goal: my_nth nimp n (@app nimp (nested_imps2nimps ni1) (nested_imps2nimps (@cons nested_imp x ni2))) x0 *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (AImp i b)) (@eq normal_form (AImp i b) (NImp_NF (nested_imp2nimp x))) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (NAtom i)) (@eq normal_form (NAtom i) (NImp_NF (nested_imp2nimp x))) *) rewrite (nested_imps2nimps_app ni1 ni2). (* Goal: my_nth nimp n (@app nimp (nested_imps2nimps ni1) (nested_imps2nimps ni2)) x0 *) (* Goal: forall (n' : nat) (_ : my_nth nimp n' (nested_imps2nimps (@cons nested_imp x ni2)) x0), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (NImp_NF x0)) (@eq normal_form (NImp_NF x0) (NImp_NF (nested_imp2nimp x))) *) (* Goal: my_nth nimp n (@app nimp (nested_imps2nimps ni1) (nested_imps2nimps (@cons nested_imp x ni2))) x0 *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (AImp i b)) (@eq normal_form (AImp i b) (NImp_NF (nested_imp2nimp x))) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (NAtom i)) (@eq normal_form (NAtom i) (NImp_NF (nested_imp2nimp x))) *) apply nth_app0; assumption. (* Goal: forall (n' : nat) (_ : my_nth nimp n' (nested_imps2nimps (@cons nested_imp x ni2)) x0), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (NImp_NF x0)) (@eq normal_form (NImp_NF x0) (NImp_NF (nested_imp2nimp x))) *) (* Goal: my_nth nimp n (@app nimp (nested_imps2nimps ni1) (nested_imps2nimps (@cons nested_imp x ni2))) x0 *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (AImp i b)) (@eq normal_form (AImp i b) (NImp_NF (nested_imp2nimp x))) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (NAtom i)) (@eq normal_form (NAtom i) (NImp_NF (nested_imp2nimp x))) *) intros n'; case n'; clear n'. (* Goal: forall _ : my_nth nimp O (nested_imps2nimps (@cons nested_imp x ni2)) x0, sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (NImp_NF x0)) (@eq normal_form (NImp_NF x0) (NImp_NF (nested_imp2nimp x))) *) (* Goal: forall (n : nat) (_ : my_nth nimp (S n) (nested_imps2nimps (@cons nested_imp x ni2)) x0), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (NImp_NF x0)) (@eq normal_form (NImp_NF x0) (NImp_NF (nested_imp2nimp x))) *) (* Goal: my_nth nimp n (@app nimp (nested_imps2nimps ni1) (nested_imps2nimps (@cons nested_imp x ni2))) x0 *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (AImp i b)) (@eq normal_form (AImp i b) (NImp_NF (nested_imp2nimp x))) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (NAtom i)) (@eq normal_form (NAtom i) (NImp_NF (nested_imp2nimp x))) *) intros nth'; right; inversion_clear nth'; trivial. (* Goal: forall (n : nat) (_ : my_nth nimp (S n) (nested_imps2nimps (@cons nested_imp x ni2)) x0), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (NImp_NF x0)) (@eq normal_form (NImp_NF x0) (NImp_NF (nested_imp2nimp x))) *) (* Goal: my_nth nimp n (@app nimp (nested_imps2nimps ni1) (nested_imps2nimps (@cons nested_imp x ni2))) x0 *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (AImp i b)) (@eq normal_form (AImp i b) (NImp_NF (nested_imp2nimp x))) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (NAtom i)) (@eq normal_form (NAtom i) (NImp_NF (nested_imp2nimp x))) *) intros n' nth'; left; apply In_Nested_Imps with (length ni1 + n'). (* Goal: my_nth nimp (Nat.add (@length nested_imp ni1) n') (nested_imps2nimps (@app nested_imp ni1 ni2)) x0 *) (* Goal: my_nth nimp n (@app nimp (nested_imps2nimps ni1) (nested_imps2nimps (@cons nested_imp x ni2))) x0 *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (AImp i b)) (@eq normal_form (AImp i b) (NImp_NF (nested_imp2nimp x))) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (NAtom i)) (@eq normal_form (NAtom i) (NImp_NF (nested_imp2nimp x))) *) rewrite (nested_imps2nimps_length ni1). (* Goal: my_nth nimp (Nat.add (@length nimp (nested_imps2nimps ni1)) n') (nested_imps2nimps (@app nested_imp ni1 ni2)) x0 *) (* Goal: my_nth nimp n (@app nimp (nested_imps2nimps ni1) (nested_imps2nimps (@cons nested_imp x ni2))) x0 *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (AImp i b)) (@eq normal_form (AImp i b) (NImp_NF (nested_imp2nimp x))) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (NAtom i)) (@eq normal_form (NAtom i) (NImp_NF (nested_imp2nimp x))) *) rewrite (nested_imps2nimps_app ni1 ni2). (* Goal: my_nth nimp (Nat.add (@length nimp (nested_imps2nimps ni1)) n') (@app nimp (nested_imps2nimps ni1) (nested_imps2nimps ni2)) x0 *) (* Goal: my_nth nimp n (@app nimp (nested_imps2nimps ni1) (nested_imps2nimps (@cons nested_imp x ni2))) x0 *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (AImp i b)) (@eq normal_form (AImp i b) (NImp_NF (nested_imp2nimp x))) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (NAtom i)) (@eq normal_form (NAtom i) (NImp_NF (nested_imp2nimp x))) *) apply nth_app1. (* Goal: my_nth nimp n' (nested_imps2nimps ni2) x0 *) (* Goal: my_nth nimp n (@app nimp (nested_imps2nimps ni1) (nested_imps2nimps (@cons nested_imp x ni2))) x0 *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (AImp i b)) (@eq normal_form (AImp i b) (NImp_NF (nested_imp2nimp x))) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (NAtom i)) (@eq normal_form (NAtom i) (NImp_NF (nested_imp2nimp x))) *) inversion_clear nth'; assumption. (* Goal: my_nth nimp n (@app nimp (nested_imps2nimps ni1) (nested_imps2nimps (@cons nested_imp x ni2))) x0 *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (AImp i b)) (@eq normal_form (AImp i b) (NImp_NF (nested_imp2nimp x))) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (NAtom i)) (@eq normal_form (NAtom i) (NImp_NF (nested_imp2nimp x))) *) rewrite <- (nested_imps2nimps_app ni1 (x :: ni2)); assumption. (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (AImp i b)) (@eq normal_form (AImp i b) (NImp_NF (nested_imp2nimp x))) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (NAtom i)) (@eq normal_form (NAtom i) (NImp_NF (nested_imp2nimp x))) *) intros i b n bs lookup nth; left; apply In_Atomic_Imps with n bs; assumption. (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), sumor (in_ngamma work ds (@app nested_imp ni1 ni2) ai a (NAtom i)) (@eq normal_form (NAtom i) (NImp_NF (nested_imp2nimp x))) *) intros i lookup; left; apply In_Atoms; assumption. Qed. Lemma in_ngamma_ni_eq : forall (work : nf_list) (ds : disjs) (ni ni' : nested_imps) (ai : atomic_imps) (a : atoms) (c : normal_form), nested_imps2nimps ni = nested_imps2nimps ni' -> in_ngamma work ds ni ai a c -> in_ngamma work ds ni' ai a c. (* Goal: forall (work : nf_list) (ds : disjs) (ni ni' : nested_imps) (ai : atomic_imps) (a : atoms) (c : normal_form) (_ : @eq (list nimp) (nested_imps2nimps ni) (nested_imps2nimps ni')) (_ : in_ngamma work ds ni ai a c), in_ngamma work ds ni' ai a c *) intros work ds ni ni' ai a c eq in_ngamma0. (* Goal: sumor (in_ngamma work ds ni ai a c) (@eq normal_form c (NAtom i)) *) elim in_ngamma0; clear in_ngamma0 c. (* Goal: forall (n : nat) (c : normal_form) (_ : my_nth normal_form n work c), in_ngamma work ds ni ai a' c *) (* Goal: forall (n : nat) (i j : Int) (_ : my_nth disj n ds (@pair Int Int i j)), in_ngamma work ds ni ai a' (NDisj i j) *) (* Goal: forall (n : nat) (x : nimp) (_ : my_nth nimp n (nested_imps2nimps ni) x), in_ngamma work ds ni ai a' (NImp_NF x) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), in_ngamma work ds ni ai a' (AImp i b) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds ni ai a' (NAtom i) *) intros n c0 nth; apply In_Work with n; assumption. (* Goal: forall (n : nat) (i j : Int) (_ : my_nth disj n ds (@pair Int Int i j)), in_ngamma work ds ni' ai a (NDisj i j) *) (* Goal: forall (n : nat) (x : nimp) (_ : my_nth nimp n (nested_imps2nimps ni) x), in_ngamma work ds ni' ai a (NImp_NF x) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), in_ngamma work ds ni' ai a (AImp i b) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds ni' ai a (NAtom i) *) intros n i j nth; apply In_Disjs with n; assumption. (* Goal: forall (n : nat) (x : nimp) (_ : my_nth nimp n (nested_imps2nimps ni) x), in_ngamma work ds ni' ai a (NImp_NF x) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), in_ngamma work ds ni' ai a (AImp i b) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds ni' ai a (NAtom i) *) intros n x' nth; apply In_Nested_Imps with n. (* Goal: my_nth nimp n (nested_imps2nimps ni') x' *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), in_ngamma work ds ni' ai a (AImp i b) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds ni' ai a (NAtom i) *) rewrite <- eq; assumption. (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), in_ngamma work ds ni' ai a (AImp i b) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds ni' ai a (NAtom i) *) intros i' b n bs lookup nth; apply In_Atomic_Imps with n bs; assumption. (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds ni ai' a (NAtom i) *) intros i' lookup; apply In_Atoms; assumption. Qed. Lemma in_ngamma_ins_ai_tail : forall (work : nf_list) (ds : disjs) (ni : nested_imps) (i : Int) (b : normal_form) (ai ai' : atomic_imps) (a : atoms) (c : normal_form), EQUIV_INS nf_list i (cons b) nf_nil ai ai' -> in_ngamma work ds ni ai a c -> in_ngamma work ds ni ai' a c. (* Goal: forall (work : nf_list) (ds : disjs) (ni : nested_imps) (i : Int) (b : normal_form) (ai ai' : atomic_imps) (a : atoms) (c : normal_form) (_ : EQUIV_INS nf_list i (@cons normal_form b) nf_nil ai ai') (_ : in_ngamma work ds ni ai' a c), in_ngamma (@cons normal_form (AImp i b) work) ds ni ai a c *) intros work ds ni i b ai ai' a c equiv_ins in_ngamma0. (* Goal: sumor (in_ngamma work ds ni ai a c) (@eq normal_form c (NAtom i)) *) elim in_ngamma0; clear in_ngamma0 c. (* Goal: forall (n : nat) (c : normal_form) (_ : my_nth normal_form n work c), in_ngamma work ds ni ai a' c *) (* Goal: forall (n : nat) (i j : Int) (_ : my_nth disj n ds (@pair Int Int i j)), in_ngamma work ds ni ai a' (NDisj i j) *) (* Goal: forall (n : nat) (x : nimp) (_ : my_nth nimp n (nested_imps2nimps ni) x), in_ngamma work ds ni ai a' (NImp_NF x) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), in_ngamma work ds ni ai a' (AImp i b) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds ni ai a' (NAtom i) *) intros n c0 nth; apply In_Work with n; assumption. (* Goal: forall (n : nat) (i j : Int) (_ : my_nth disj n ds (@pair Int Int i j)), in_ngamma work ds ni ai a' (NDisj i j) *) (* Goal: forall (n : nat) (x : nimp) (_ : my_nth nimp n (nested_imps2nimps ni) x), in_ngamma work ds ni ai a' (NImp_NF x) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), in_ngamma work ds ni ai a' (AImp i b) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds ni ai a' (NAtom i) *) intros n i' j' nth; apply In_Disjs with n; assumption. (* Goal: forall (n : nat) (x : nimp) (_ : my_nth nimp n (nested_imps2nimps ni) x), in_ngamma work ds ni ai' a (NImp_NF x) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), in_ngamma work ds ni ai' a (AImp i b) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds ni ai' a (NAtom i) *) intros n x nth; apply In_Nested_Imps with n; assumption. (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), in_ngamma work ds ni ai' a (AImp i b) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds ni ai' a (NAtom i) *) intros i0 b0 n bs lookup nth. (* Goal: AvlTrees.lookup unit i0 t' tt *) case (equal_dec i0 i). (* Goal: forall _ : Equal i0 i, in_ngamma work ds ni ai' a (AImp i0 b0) *) (* Goal: forall _ : not (Equal i0 i), in_ngamma work ds ni ai' a (AImp i0 b0) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds ni ai' a (NAtom i) *) intro equal_i0_i. (* Goal: in_ngamma work ds ni ai' a (AImp i0 b0) *) (* Goal: forall _ : not (Equal i0 i), in_ngamma work ds ni ai' a (AImp i0 b0) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds ni ai' a (NAtom i) *) apply In_Atomic_Imps with (S n) (b :: bs). (* Goal: LOOKUP unit i0 a tt *) generalize equiv_ins lookup; clear equiv_ins lookup. (* Goal: forall (_ : LOOKUP nf_list i ai' bs) (_ : EQUIV_DEL nf_list i ai' ai) (_ : LOOKUP nf_list i0 ai' bs0), LOOKUP nf_list i0 ai bs0 *) (* Goal: my_nth normal_form n bs0 b0 *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sum (in_ngamma work ds ni ai a (NAtom i0)) (in_ngamma_del_ai_rev_spec i bs (NAtom i0)) *) elim ai; clear ai; intros t avl_t. (* Goal: forall (_ : LOOKUP nf_list i ai' bs) (_ : EQUIV_DEL nf_list i ai' (AVL_intro nf_list t avl_t)) (_ : LOOKUP nf_list i0 ai' bs0), LOOKUP nf_list i0 (AVL_intro nf_list t avl_t) bs0 *) (* Goal: my_nth normal_form n bs0 b0 *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sum (in_ngamma work ds ni ai a (NAtom i0)) (in_ngamma_del_ai_rev_spec i bs (NAtom i0)) *) elim ai'; clear ai'; intros t' avl_t'. (* Goal: in_ngamma work ds ni ai a' (NAtom i) *) simpl in |- *. (* Goal: forall (_ : equiv_ins nf_list i (@cons normal_form b) nf_nil t t') (_ : lookup nf_list i0 t' bs), lookup nf_list i0 t bs *) (* Goal: my_nth normal_form n bs b0 *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (AImp i b)) *) intros equiv_ins lookup. (* Goal: AvlTrees.lookup unit i0 t tt *) inversion_clear equiv_ins. (* Goal: AvlTrees.lookup nf_list i0 t' (@cons normal_form b bs) *) (* Goal: my_nth normal_form (S n) (@cons normal_form b bs) b0 *) (* Goal: forall _ : not (Equal i0 i), in_ngamma work ds ni ai' a (AImp i0 b0) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds ni ai' a (NAtom i) *) apply H; assumption. (* Goal: my_nth normal_form (S n) (@cons normal_form b bs) b0 *) (* Goal: forall _ : not (Equal i0 i), in_ngamma work ds ni ai' a (AImp i0 b0) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds ni ai' a (NAtom i) *) apply My_NthS; assumption. (* Goal: forall _ : not (Equal i0 i), in_ngamma work ds ni ai' a (AImp i0 b0) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds ni ai' a (NAtom i) *) intros not_equal_i0_i. (* Goal: in_ngamma work ds ni ai' a (AImp i0 b0) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds ni ai' a (NAtom i) *) apply In_Atomic_Imps with n bs. (* Goal: LOOKUP unit i0 a tt *) generalize equiv_ins lookup; clear equiv_ins lookup. (* Goal: forall (_ : LOOKUP nf_list i ai' bs) (_ : EQUIV_DEL nf_list i ai' ai) (_ : LOOKUP nf_list i0 ai' bs0), LOOKUP nf_list i0 ai bs0 *) (* Goal: my_nth normal_form n bs0 b0 *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sum (in_ngamma work ds ni ai a (NAtom i0)) (in_ngamma_del_ai_rev_spec i bs (NAtom i0)) *) elim ai; clear ai; intros t avl_t. (* Goal: forall (_ : LOOKUP nf_list i ai' bs) (_ : EQUIV_DEL nf_list i ai' (AVL_intro nf_list t avl_t)) (_ : LOOKUP nf_list i0 ai' bs0), LOOKUP nf_list i0 (AVL_intro nf_list t avl_t) bs0 *) (* Goal: my_nth normal_form n bs0 b0 *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sum (in_ngamma work ds ni ai a (NAtom i0)) (in_ngamma_del_ai_rev_spec i bs (NAtom i0)) *) elim ai'; clear ai'; intros t' avl_t'. (* Goal: in_ngamma work ds ni ai a' (NAtom i) *) simpl in |- *. (* Goal: forall (_ : equiv_ins nf_list i (@cons normal_form b) nf_nil t t') (_ : lookup nf_list i0 t' bs), lookup nf_list i0 t bs *) (* Goal: my_nth normal_form n bs b0 *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (AImp i b)) *) intros equiv_ins lookup. (* Goal: AvlTrees.lookup unit i0 t tt *) inversion_clear equiv_ins. (* Goal: AvlTrees.lookup unit i0 t' tt *) apply H1; assumption. (* Goal: forall (data : unit) (_ : lookup unit i t data), False *) assumption. (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds ni ai' a (NAtom i) *) intros i' lookup; apply In_Atoms; assumption. Qed. Lemma in_ngamma_ins_ai_head_new : forall (work : nf_list) (ds : disjs) (ni : nested_imps) (i : Int) (b : normal_form) (ai ai' : atomic_imps) (a : atoms), (forall bs : nf_list, LOOKUP nf_list i ai bs -> False) -> EQUIV_INS nf_list i (cons b) nf_nil ai ai' -> in_ngamma work ds ni ai' a (AImp i b). (* Goal: forall (work : nf_list) (ds : disjs) (ni : nested_imps) (i : Int) (b : normal_form) (ai ai' : atomic_imps) (a : atoms) (_ : forall (bs : nf_list) (_ : LOOKUP nf_list i ai bs), False) (_ : EQUIV_INS nf_list i (@cons normal_form b) nf_nil ai ai'), in_ngamma work ds ni ai' a (AImp i b) *) intros work ds ni i b ai ai' a notlookup equiv_ins. (* Goal: in_ngamma work ds ni ai' a (AImp i b) *) apply In_Atomic_Imps with 0 (b :: nf_nil). (* Goal: LOOKUP nf_list i ai' (@cons normal_form b nf_nil) *) (* Goal: my_nth normal_form O (@cons normal_form b nf_nil) b *) generalize equiv_ins notlookup; clear equiv_ins notlookup. (* Goal: forall (_ : LOOKUP nf_list i ai' bs) (_ : EQUIV_DEL nf_list i ai' ai) (_ : LOOKUP nf_list i0 ai' bs0), LOOKUP nf_list i0 ai bs0 *) (* Goal: my_nth normal_form n bs0 b0 *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sum (in_ngamma work ds ni ai a (NAtom i0)) (in_ngamma_del_ai_rev_spec i bs (NAtom i0)) *) elim ai; clear ai; intros t avl_t. (* Goal: forall (_ : LOOKUP nf_list i ai' bs) (_ : EQUIV_DEL nf_list i ai' (AVL_intro nf_list t avl_t)) (_ : LOOKUP nf_list i0 ai' bs0), LOOKUP nf_list i0 (AVL_intro nf_list t avl_t) bs0 *) (* Goal: my_nth normal_form n bs0 b0 *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sum (in_ngamma work ds ni ai a (NAtom i0)) (in_ngamma_del_ai_rev_spec i bs (NAtom i0)) *) elim ai'; clear ai'; intros t' avl_t'. (* Goal: in_ngamma work ds ni ai a' (NAtom i) *) simpl in |- *. (* Goal: forall (_ : forall d : unit, not (lookup unit i t d)) (_ : equiv_ins unit i (fun _ : unit => tt) tt t t'), lookup unit i t' tt *) intros. (* Goal: AvlTrees.lookup unit i0 t tt *) inversion_clear equiv_ins. (* Goal: AvlTrees.lookup nf_list i0 t (@tl normal_form bs) *) (* Goal: my_nth normal_form n (@tl normal_form bs) b0 *) (* Goal: forall (_ : not (Equal i0 i)) (b1 : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i0 ai' bs) (_ : my_nth normal_form n bs b1), sumor (in_ngamma work ds ni ai a (AImp i0 b1)) (@eq normal_form (AImp i0 b1) (AImp i b)) *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (AImp i b)) *) clear H1 H2. (* Goal: lookup unit i t' tt *) apply H0. (* Goal: Equal i i *) (* Goal: forall (data : unit) (_ : lookup unit i t data), False *) apply equal_refl. (* Goal: forall (data : unit) (_ : lookup unit i t data), False *) assumption. (* Goal: my_nth normal_form O (@cons normal_form b bs) b *) apply My_NthO. Qed. Lemma in_ngamma_ins_ai_head_old : forall (work : nf_list) (ds : disjs) (ni : nested_imps) (i : Int) (b : normal_form) (bs : nf_list) (ai ai' : atomic_imps) (a : atoms), LOOKUP nf_list i ai bs -> EQUIV_INS nf_list i (cons b) nf_nil ai ai' -> in_ngamma work ds ni ai' a (AImp i b). (* Goal: forall (work : nf_list) (ds : disjs) (ni : nested_imps) (i : Int) (b : normal_form) (bs : nf_list) (ai ai' : atomic_imps) (a : atoms) (_ : LOOKUP nf_list i ai bs) (_ : EQUIV_INS nf_list i (@cons normal_form b) nf_nil ai ai'), in_ngamma work ds ni ai' a (AImp i b) *) intros work ds ni i b bs ai ai' a lookup equiv_ins. (* Goal: in_ngamma work ds ni ai' a (AImp i b) *) apply In_Atomic_Imps with 0 (b :: bs). (* Goal: LOOKUP unit i0 a tt *) generalize equiv_ins lookup; clear equiv_ins lookup. (* Goal: forall (_ : LOOKUP nf_list i ai' bs) (_ : EQUIV_DEL nf_list i ai' ai) (_ : LOOKUP nf_list i0 ai' bs0), LOOKUP nf_list i0 ai bs0 *) (* Goal: my_nth normal_form n bs0 b0 *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sum (in_ngamma work ds ni ai a (NAtom i0)) (in_ngamma_del_ai_rev_spec i bs (NAtom i0)) *) elim ai; clear ai; intros t avl_t. (* Goal: forall (_ : LOOKUP nf_list i ai' bs) (_ : EQUIV_DEL nf_list i ai' (AVL_intro nf_list t avl_t)) (_ : LOOKUP nf_list i0 ai' bs0), LOOKUP nf_list i0 (AVL_intro nf_list t avl_t) bs0 *) (* Goal: my_nth normal_form n bs0 b0 *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sum (in_ngamma work ds ni ai a (NAtom i0)) (in_ngamma_del_ai_rev_spec i bs (NAtom i0)) *) elim ai'; clear ai'; intros t' avl_t'. (* Goal: in_ngamma work ds ni ai a' (NAtom i) *) simpl in |- *. (* Goal: forall (_ : forall d : unit, not (lookup unit i t d)) (_ : equiv_ins unit i (fun _ : unit => tt) tt t t'), lookup unit i t' tt *) intros. (* Goal: AvlTrees.lookup unit i0 t tt *) inversion_clear equiv_ins. (* Goal: AvlTrees.lookup nf_list i0 t (@tl normal_form bs) *) (* Goal: my_nth normal_form n (@tl normal_form bs) b0 *) (* Goal: forall (_ : not (Equal i0 i)) (b1 : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i0 ai' bs) (_ : my_nth normal_form n bs b1), sumor (in_ngamma work ds ni ai a (AImp i0 b1)) (@eq normal_form (AImp i0 b1) (AImp i b)) *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (AImp i b)) *) clear H1 H2. (* Goal: AvlTrees.lookup nf_list i t' (@cons normal_form b bs) *) (* Goal: my_nth normal_form O (@cons normal_form b bs) b *) apply H. (* Goal: Equal i i *) (* Goal: forall (data : unit) (_ : lookup unit i t data), False *) apply equal_refl. (* Goal: forall (data : unit) (_ : lookup unit i t data), False *) assumption. (* Goal: my_nth normal_form O (@cons normal_form b bs) b *) apply My_NthO. Qed. Lemma in_ngamma_ins_ai_rev : forall (work : nf_list) (ds : disjs) (ni : nested_imps) (i : Int) (b : normal_form) (ai ai' : atomic_imps) (a : atoms) (c : normal_form), EQUIV_INS nf_list i (cons b) nf_nil ai ai' -> in_ngamma work ds ni ai' a c -> in_ngamma work ds ni ai a c + {c = AImp i b}. (* Goal: forall (work : nf_list) (ds : disjs) (ni : nested_imps) (i : Int) (b : normal_form) (ai ai' : atomic_imps) (a : atoms) (c : normal_form) (_ : EQUIV_INS nf_list i (@cons normal_form b) nf_nil ai ai') (_ : in_ngamma work ds ni ai' a c), in_ngamma (@cons normal_form (AImp i b) work) ds ni ai a c *) intros work ds ni i b ai ai' a c equiv_ins in_ngamma0. (* Goal: sumor (in_ngamma work ds ni ai a c) (@eq normal_form c (NAtom i)) *) elim in_ngamma0; clear in_ngamma0 c. (* Goal: forall (data : unit) (_ : lookup unit i t data), False *) intros n c0; left; apply In_Work with n; assumption. (* Goal: forall (n : nat) (i0 j : Int) (_ : my_nth disj n ds (@pair Int Int i0 j)), sumor (in_ngamma work ds ni ai a (NDisj i0 j)) (@eq normal_form (NDisj i0 j) (NAtom i)) *) (* Goal: forall (n : nat) (x : nimp) (_ : my_nth nimp n (nested_imps2nimps ni) x), sumor (in_ngamma work ds ni ai a (NImp_NF x)) (@eq normal_form (NImp_NF x) (NAtom i)) *) (* Goal: forall (i0 : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i0 ai bs) (_ : my_nth normal_form n bs b), sumor (in_ngamma work ds ni ai a (AImp i0 b)) (@eq normal_form (AImp i0 b) (NAtom i)) *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a' tt), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (NAtom i)) *) intros n i' j' nth; left; apply In_Disjs with n; assumption. (* Goal: forall (n : nat) (x : nimp) (_ : my_nth nimp n (nested_imps2nimps ni) x), sumor (in_ngamma work ds ni ai a (NImp_NF x)) (@eq normal_form (NImp_NF x) (AImp i b)) *) (* Goal: forall (i0 : Int) (b0 : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i0 ai' bs) (_ : my_nth normal_form n bs b0), sumor (in_ngamma work ds ni ai a (AImp i0 b0)) (@eq normal_form (AImp i0 b0) (AImp i b)) *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (AImp i b)) *) intros n x nth; left; apply In_Nested_Imps with n; assumption. (* Goal: forall (i0 : Int) (b0 : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i0 ai' bs) (_ : my_nth normal_form n bs b0), sumor (in_ngamma work ds ni ai a (AImp i0 b0)) (@eq normal_form (AImp i0 b0) (AImp i b)) *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (AImp i b)) *) intros i0. (* Goal: sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (NAtom i)) *) elim (equal_dec i0 i). (* Goal: forall _ : Equal i0 i, sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (NAtom i)) *) (* Goal: forall _ : not (Equal i0 i), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (NAtom i)) *) intro equal. (* Goal: forall (b0 : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i0 ai' bs) (_ : my_nth normal_form n bs b0), sumor (in_ngamma work ds ni ai a (AImp i0 b0)) (@eq normal_form (AImp i0 b0) (AImp i b)) *) (* Goal: forall (_ : not (Equal i0 i)) (b1 : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i0 ai' bs) (_ : my_nth normal_form n bs b1), sumor (in_ngamma work ds ni ai a (AImp i0 b1)) (@eq normal_form (AImp i0 b1) (AImp i b)) *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (AImp i b)) *) intros b0 n. (* Goal: forall (bs : nf_list) (_ : LOOKUP nf_list i0 ai' bs) (_ : my_nth normal_form n bs b0), sumor (in_ngamma work ds ni ai a (AImp i0 b0)) (@eq normal_form (AImp i0 b0) (AImp i b)) *) (* Goal: forall (_ : not (Equal i0 i)) (b1 : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i0 ai' bs) (_ : my_nth normal_form n bs b1), sumor (in_ngamma work ds ni ai a (AImp i0 b1)) (@eq normal_form (AImp i0 b1) (AImp i b)) *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (AImp i b)) *) case n; clear n. (* Goal: forall (bs : nf_list) (_ : LOOKUP nf_list i0 ai' bs) (_ : my_nth normal_form O bs b0), sumor (in_ngamma work ds ni ai a (AImp i0 b0)) (@eq normal_form (AImp i0 b0) (AImp i b)) *) (* Goal: forall (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i0 ai' bs) (_ : my_nth normal_form (S n) bs b0), sumor (in_ngamma work ds ni ai a (AImp i0 b0)) (@eq normal_form (AImp i0 b0) (AImp i b)) *) (* Goal: forall (_ : not (Equal i0 i)) (b1 : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i0 ai' bs) (_ : my_nth normal_form n bs b1), sumor (in_ngamma work ds ni ai a (AImp i0 b1)) (@eq normal_form (AImp i0 b1) (AImp i b)) *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (AImp i b)) *) intros bs lookup nth. (* Goal: sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (NAtom i)) *) (* Goal: forall _ : not (Equal i0 i), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (NAtom i)) *) right. (* Goal: LOOKUP unit i0 a tt *) generalize equiv_ins lookup; clear equiv_ins lookup. (* Goal: forall (_ : LOOKUP nf_list i ai' bs) (_ : EQUIV_DEL nf_list i ai' ai) (_ : LOOKUP nf_list i0 ai' bs0), LOOKUP nf_list i0 ai bs0 *) (* Goal: my_nth normal_form n bs0 b0 *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sum (in_ngamma work ds ni ai a (NAtom i0)) (in_ngamma_del_ai_rev_spec i bs (NAtom i0)) *) elim ai; clear ai; intros t avl_t. (* Goal: forall (_ : LOOKUP nf_list i ai' bs) (_ : EQUIV_DEL nf_list i ai' (AVL_intro nf_list t avl_t)) (_ : LOOKUP nf_list i0 ai' bs0), LOOKUP nf_list i0 (AVL_intro nf_list t avl_t) bs0 *) (* Goal: my_nth normal_form n bs0 b0 *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sum (in_ngamma work ds ni ai a (NAtom i0)) (in_ngamma_del_ai_rev_spec i bs (NAtom i0)) *) elim ai'; clear ai'; intros t' avl_t'. (* Goal: in_ngamma work ds ni ai a' (NAtom i) *) simpl in |- *. (* Goal: forall (_ : equiv_ins nf_list i (@cons normal_form b) nf_nil t t') (_ : lookup nf_list i0 t' bs), lookup nf_list i0 t bs *) (* Goal: my_nth normal_form n bs b0 *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (AImp i b)) *) intros equiv_ins lookup. (* Goal: AvlTrees.lookup unit i0 t tt *) inversion_clear equiv_ins. (* Goal: AvlTrees.lookup nf_list i0 t (@tl normal_form bs) *) (* Goal: my_nth normal_form n (@tl normal_form bs) b0 *) (* Goal: forall (_ : not (Equal i0 i)) (b1 : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i0 ai' bs) (_ : my_nth normal_form n bs b1), sumor (in_ngamma work ds ni ai a (AImp i0 b1)) (@eq normal_form (AImp i0 b1) (AImp i b)) *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (AImp i b)) *) clear H1 H2. (* Goal: AvlTrees.lookup nf_list i0 t (@tl normal_form bs) *) (* Goal: my_nth normal_form n (@tl normal_form bs) b0 *) (* Goal: forall (_ : not (Equal i0 i)) (b1 : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i0 ai' bs) (_ : my_nth normal_form n bs b1), sumor (in_ngamma work ds ni ai a (AImp i0 b1)) (@eq normal_form (AImp i0 b1) (AImp i b)) *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (AImp i b)) *) elim (lookup_dec nf_list i0 t avl_t). (* Goal: forall (d : nf_list) (_ : AvlTrees.lookup nf_list i0 t d), AvlTrees.lookup nf_list i0 t (@tl normal_form bs) *) (* Goal: forall _ : forall d : nf_list, not (AvlTrees.lookup nf_list i0 t d), AvlTrees.lookup nf_list i0 t (@tl normal_form bs) *) (* Goal: my_nth normal_form n (@tl normal_form bs) b0 *) (* Goal: forall (_ : not (Equal i0 i)) (b1 : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i0 ai' bs) (_ : my_nth normal_form n bs b1), sumor (in_ngamma work ds ni ai a (AImp i0 b1)) (@eq normal_form (AImp i0 b1) (AImp i b)) *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (AImp i b)) *) intros bs' lookup0. (* Goal: AvlTrees.lookup nf_list i0 t (@tl normal_form bs) *) (* Goal: forall _ : forall d : nf_list, not (AvlTrees.lookup nf_list i0 t d), AvlTrees.lookup nf_list i0 t (@tl normal_form bs) *) (* Goal: my_nth normal_form n (@tl normal_form bs) b0 *) (* Goal: forall (_ : not (Equal i0 i)) (b1 : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i0 ai' bs) (_ : my_nth normal_form n bs b1), sumor (in_ngamma work ds ni ai a (AImp i0 b1)) (@eq normal_form (AImp i0 b1) (AImp i b)) *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (AImp i b)) *) generalize (H i0 bs' equal lookup0); clear H H0. (* Goal: forall (_ : forall d : unit, not (lookup unit i t d)) (_ : equiv_ins unit i (fun _ : unit => tt) tt t t'), lookup unit i t' tt *) intros. rewrite (lookup_avl_equal nf_list i0 i0 t' bs (b :: bs')) in nth; (* Goal: forall (data : unit) (_ : lookup unit i t data), False *) try assumption. (* Goal: my_nth normal_form n (@tl normal_form bs) b0 *) (* Goal: forall (_ : not (Equal i0 i)) (b1 : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i0 ai' bs) (_ : my_nth normal_form n bs b1), sumor (in_ngamma work ds ni ai a (AImp i0 b1)) (@eq normal_form (AImp i0 b1) (AImp i b)) *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (AImp i b)) *) inversion_clear nth. (* Goal: @eq normal_form (AImp i0 b0) (AImp i b0) *) (* Goal: Equal i0 i0 *) (* Goal: forall (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i0 ai' bs) (_ : my_nth normal_form (S n) bs b0), sumor (in_ngamma work ds ni ai a (AImp i0 b0)) (@eq normal_form (AImp i0 b0) (AImp i b)) *) (* Goal: forall (_ : not (Equal i0 i)) (b1 : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i0 ai' bs) (_ : my_nth normal_form n bs b1), sumor (in_ngamma work ds ni ai a (AImp i0 b1)) (@eq normal_form (AImp i0 b1) (AImp i b)) *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (AImp i b)) *) rewrite (equal_eq i0 i). (* Goal: @eq normal_form (AImp i b0) (AImp i b0) *) (* Goal: forall _ : not (Equal i0 i), sum (in_ngamma work ds ni ai a (AImp i0 b0)) (in_ngamma_del_ai_rev_spec i bs (AImp i0 b0)) *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sum (in_ngamma work ds ni ai a (NAtom i0)) (in_ngamma_del_ai_rev_spec i bs (NAtom i0)) *) trivial. (* Goal: forall (data : unit) (_ : lookup unit i t data), False *) assumption. (* Goal: Equal i i *) (* Goal: forall (data : unit) (_ : lookup unit i t data), False *) apply equal_refl. (* Goal: forall _ : forall d : nf_list, not (AvlTrees.lookup nf_list i0 t d), AvlTrees.lookup nf_list i0 t (@tl normal_form bs) *) (* Goal: my_nth normal_form n (@tl normal_form bs) b0 *) (* Goal: forall (_ : not (Equal i0 i)) (b1 : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i0 ai' bs) (_ : my_nth normal_form n bs b1), sumor (in_ngamma work ds ni ai a (AImp i0 b1)) (@eq normal_form (AImp i0 b1) (AImp i b)) *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (AImp i b)) *) intros notlookup0. (* Goal: AvlTrees.lookup nf_list i0 t (@tl normal_form bs) *) (* Goal: my_nth normal_form n (@tl normal_form bs) b0 *) (* Goal: forall (_ : not (Equal i0 i)) (b1 : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i0 ai' bs) (_ : my_nth normal_form n bs b1), sumor (in_ngamma work ds ni ai a (AImp i0 b1)) (@eq normal_form (AImp i0 b1) (AImp i b)) *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (AImp i b)) *) generalize (H0 i0 equal notlookup0); clear H H0. (* Goal: forall (_ : forall d : unit, not (lookup unit i t d)) (_ : equiv_ins unit i (fun _ : unit => tt) tt t t'), lookup unit i t' tt *) intros. rewrite (lookup_avl_equal nf_list i0 i0 t' bs (b :: nf_nil)) in nth; (* Goal: forall (data : unit) (_ : lookup unit i t data), False *) try assumption. (* Goal: my_nth normal_form n (@tl normal_form bs) b0 *) (* Goal: forall (_ : not (Equal i0 i)) (b1 : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i0 ai' bs) (_ : my_nth normal_form n bs b1), sumor (in_ngamma work ds ni ai a (AImp i0 b1)) (@eq normal_form (AImp i0 b1) (AImp i b)) *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (AImp i b)) *) inversion_clear nth. (* Goal: @eq normal_form (AImp i0 b0) (AImp i b0) *) (* Goal: Equal i0 i0 *) (* Goal: forall (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i0 ai' bs) (_ : my_nth normal_form (S n) bs b0), sumor (in_ngamma work ds ni ai a (AImp i0 b0)) (@eq normal_form (AImp i0 b0) (AImp i b)) *) (* Goal: forall (_ : not (Equal i0 i)) (b1 : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i0 ai' bs) (_ : my_nth normal_form n bs b1), sumor (in_ngamma work ds ni ai a (AImp i0 b1)) (@eq normal_form (AImp i0 b1) (AImp i b)) *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (AImp i b)) *) rewrite (equal_eq i0 i). (* Goal: @eq normal_form (AImp i b0) (AImp i b0) *) (* Goal: forall _ : not (Equal i0 i), sum (in_ngamma work ds ni ai a (AImp i0 b0)) (in_ngamma_del_ai_rev_spec i bs (AImp i0 b0)) *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sum (in_ngamma work ds ni ai a (NAtom i0)) (in_ngamma_del_ai_rev_spec i bs (NAtom i0)) *) trivial. (* Goal: forall (data : unit) (_ : lookup unit i t data), False *) assumption. (* Goal: Equal i i *) (* Goal: forall (data : unit) (_ : lookup unit i t data), False *) apply equal_refl. (* Goal: forall (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i0 ai' bs) (_ : my_nth normal_form (S n) bs b0), sumor (in_ngamma work ds ni ai a (AImp i0 b0)) (@eq normal_form (AImp i0 b0) (AImp i b)) *) (* Goal: forall (_ : not (Equal i0 i)) (b1 : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i0 ai' bs) (_ : my_nth normal_form n bs b1), sumor (in_ngamma work ds ni ai a (AImp i0 b1)) (@eq normal_form (AImp i0 b1) (AImp i b)) *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (AImp i b)) *) intros n bs lookup nth. (* Goal: sumor (in_ngamma work ds ni ai a (AImp i0 b0)) (@eq normal_form (AImp i0 b0) (AImp i b)) *) (* Goal: forall (_ : not (Equal i0 i)) (b1 : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i0 ai' bs) (_ : my_nth normal_form n bs b1), sumor (in_ngamma work ds ni ai a (AImp i0 b1)) (@eq normal_form (AImp i0 b1) (AImp i b)) *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (AImp i b)) *) left; apply In_Atomic_Imps with n (tail bs). (* Goal: LOOKUP unit i0 a tt *) generalize equiv_ins lookup; clear equiv_ins lookup. (* Goal: forall (_ : LOOKUP nf_list i ai' bs) (_ : EQUIV_DEL nf_list i ai' ai) (_ : LOOKUP nf_list i0 ai' bs0), LOOKUP nf_list i0 ai bs0 *) (* Goal: my_nth normal_form n bs0 b0 *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sum (in_ngamma work ds ni ai a (NAtom i0)) (in_ngamma_del_ai_rev_spec i bs (NAtom i0)) *) elim ai; clear ai; intros t avl_t. (* Goal: forall (_ : LOOKUP nf_list i ai' bs) (_ : EQUIV_DEL nf_list i ai' (AVL_intro nf_list t avl_t)) (_ : LOOKUP nf_list i0 ai' bs0), LOOKUP nf_list i0 (AVL_intro nf_list t avl_t) bs0 *) (* Goal: my_nth normal_form n bs0 b0 *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sum (in_ngamma work ds ni ai a (NAtom i0)) (in_ngamma_del_ai_rev_spec i bs (NAtom i0)) *) elim ai'; clear ai'; intros t' avl_t'. (* Goal: in_ngamma work ds ni ai a' (NAtom i) *) simpl in |- *. (* Goal: forall (_ : equiv_ins nf_list i (@cons normal_form b) nf_nil t t') (_ : lookup nf_list i0 t' bs), lookup nf_list i0 t bs *) (* Goal: my_nth normal_form n bs b0 *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (AImp i b)) *) intros equiv_ins lookup. (* Goal: AvlTrees.lookup unit i0 t tt *) inversion_clear equiv_ins. (* Goal: AvlTrees.lookup nf_list i0 t (@tl normal_form bs) *) (* Goal: my_nth normal_form n (@tl normal_form bs) b0 *) (* Goal: forall (_ : not (Equal i0 i)) (b1 : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i0 ai' bs) (_ : my_nth normal_form n bs b1), sumor (in_ngamma work ds ni ai a (AImp i0 b1)) (@eq normal_form (AImp i0 b1) (AImp i b)) *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (AImp i b)) *) clear H1 H2. (* Goal: AvlTrees.lookup nf_list i0 t (@tl normal_form bs) *) (* Goal: my_nth normal_form n (@tl normal_form bs) b0 *) (* Goal: forall (_ : not (Equal i0 i)) (b1 : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i0 ai' bs) (_ : my_nth normal_form n bs b1), sumor (in_ngamma work ds ni ai a (AImp i0 b1)) (@eq normal_form (AImp i0 b1) (AImp i b)) *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (AImp i b)) *) elim (lookup_dec nf_list i0 t avl_t). (* Goal: forall (d : nf_list) (_ : AvlTrees.lookup nf_list i0 t d), AvlTrees.lookup nf_list i0 t (@tl normal_form bs) *) (* Goal: forall _ : forall d : nf_list, not (AvlTrees.lookup nf_list i0 t d), AvlTrees.lookup nf_list i0 t (@tl normal_form bs) *) (* Goal: my_nth normal_form n (@tl normal_form bs) b0 *) (* Goal: forall (_ : not (Equal i0 i)) (b1 : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i0 ai' bs) (_ : my_nth normal_form n bs b1), sumor (in_ngamma work ds ni ai a (AImp i0 b1)) (@eq normal_form (AImp i0 b1) (AImp i b)) *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (AImp i b)) *) intros bs' lookup0. (* Goal: AvlTrees.lookup nf_list i0 t (@tl normal_form bs) *) (* Goal: forall _ : forall d : nf_list, not (AvlTrees.lookup nf_list i0 t d), AvlTrees.lookup nf_list i0 t (@tl normal_form bs) *) (* Goal: my_nth normal_form n (@tl normal_form bs) b0 *) (* Goal: forall (_ : not (Equal i0 i)) (b1 : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i0 ai' bs) (_ : my_nth normal_form n bs b1), sumor (in_ngamma work ds ni ai a (AImp i0 b1)) (@eq normal_form (AImp i0 b1) (AImp i b)) *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (AImp i b)) *) generalize (H i0 bs' equal lookup0); clear H H0. (* Goal: forall (_ : forall d : unit, not (lookup unit i t d)) (_ : equiv_ins unit i (fun _ : unit => tt) tt t t'), lookup unit i t' tt *) intros. (* Goal: forall (data : unit) (_ : lookup unit i t data), False *) rewrite (lookup_avl_equal nf_list i0 i0 t' bs (b :: bs')); try assumption. (* Goal: Equal i i *) (* Goal: forall (data : unit) (_ : lookup unit i t data), False *) apply equal_refl. (* Goal: forall _ : forall d : nf_list, not (AvlTrees.lookup nf_list i0 t d), AvlTrees.lookup nf_list i0 t (@tl normal_form bs) *) (* Goal: my_nth normal_form n (@tl normal_form bs) b0 *) (* Goal: forall (_ : not (Equal i0 i)) (b1 : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i0 ai' bs) (_ : my_nth normal_form n bs b1), sumor (in_ngamma work ds ni ai a (AImp i0 b1)) (@eq normal_form (AImp i0 b1) (AImp i b)) *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (AImp i b)) *) intros notlookup0. (* Goal: AvlTrees.lookup nf_list i0 t (@tl normal_form bs) *) (* Goal: my_nth normal_form n (@tl normal_form bs) b0 *) (* Goal: forall (_ : not (Equal i0 i)) (b1 : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i0 ai' bs) (_ : my_nth normal_form n bs b1), sumor (in_ngamma work ds ni ai a (AImp i0 b1)) (@eq normal_form (AImp i0 b1) (AImp i b)) *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (AImp i b)) *) generalize (H0 i0 equal notlookup0); clear H H0. (* Goal: forall (_ : forall d : unit, not (lookup unit i t d)) (_ : equiv_ins unit i (fun _ : unit => tt) tt t t'), lookup unit i t' tt *) intros. rewrite (lookup_avl_equal nf_list i0 i0 t' bs (b :: nf_nil)) in nth; (* Goal: forall (data : unit) (_ : lookup unit i t data), False *) try assumption. (* Goal: my_nth normal_form n (@tl normal_form bs) b0 *) (* Goal: forall (_ : not (Equal i0 i)) (b1 : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i0 ai' bs) (_ : my_nth normal_form n bs b1), sumor (in_ngamma work ds ni ai a (AImp i0 b1)) (@eq normal_form (AImp i0 b1) (AImp i b)) *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (AImp i b)) *) inversion_clear nth. (* Goal: AvlTrees.lookup nf_list i0 t (@tl normal_form bs) *) (* Goal: Equal i0 i0 *) (* Goal: my_nth normal_form n (@tl normal_form bs) b0 *) (* Goal: forall (_ : not (Equal i0 i)) (b1 : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i0 ai' bs) (_ : my_nth normal_form n bs b1), sumor (in_ngamma work ds ni ai a (AImp i0 b1)) (@eq normal_form (AImp i0 b1) (AImp i b)) *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (AImp i b)) *) inversion_clear H0. (* Goal: Equal i i *) (* Goal: forall (data : unit) (_ : lookup unit i t data), False *) apply equal_refl. (* Goal: my_nth normal_form n (@tl normal_form bs) b0 *) (* Goal: forall (_ : not (Equal i0 i)) (b1 : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i0 ai' bs) (_ : my_nth normal_form n bs b1), sumor (in_ngamma work ds ni ai a (AImp i0 b1)) (@eq normal_form (AImp i0 b1) (AImp i b)) *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (AImp i b)) *) inversion_clear nth. (* Goal: forall (data : unit) (_ : lookup unit i t data), False *) assumption. (* Goal: forall _ : not (Equal i0 i), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (NAtom i)) *) intros notequal. (* Goal: forall (b0 : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i0 ai' bs) (_ : my_nth normal_form n bs b0), sumor (in_ngamma work ds ni ai a (AImp i0 b0)) (@eq normal_form (AImp i0 b0) (AImp i b)) *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (AImp i b)) *) intros b0 n bs lookup nth. (* Goal: in_ngamma work ds ni ai' a (AImp i0 b0) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds ni ai' a (NAtom i) *) left; apply In_Atomic_Imps with n bs. (* Goal: LOOKUP unit i0 a tt *) generalize equiv_ins lookup; clear equiv_ins lookup. (* Goal: forall (_ : LOOKUP nf_list i ai' bs) (_ : EQUIV_DEL nf_list i ai' ai) (_ : LOOKUP nf_list i0 ai' bs0), LOOKUP nf_list i0 ai bs0 *) (* Goal: my_nth normal_form n bs0 b0 *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sum (in_ngamma work ds ni ai a (NAtom i0)) (in_ngamma_del_ai_rev_spec i bs (NAtom i0)) *) elim ai; clear ai; intros t avl_t. (* Goal: forall (_ : LOOKUP nf_list i ai' bs) (_ : EQUIV_DEL nf_list i ai' (AVL_intro nf_list t avl_t)) (_ : LOOKUP nf_list i0 ai' bs0), LOOKUP nf_list i0 (AVL_intro nf_list t avl_t) bs0 *) (* Goal: my_nth normal_form n bs0 b0 *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sum (in_ngamma work ds ni ai a (NAtom i0)) (in_ngamma_del_ai_rev_spec i bs (NAtom i0)) *) elim ai'; clear ai'; intros t' avl_t'. (* Goal: in_ngamma work ds ni ai a' (NAtom i) *) simpl in |- *. (* Goal: forall (_ : equiv_ins nf_list i (@cons normal_form b) nf_nil t t') (_ : lookup nf_list i0 t' bs), lookup nf_list i0 t bs *) (* Goal: my_nth normal_form n bs b0 *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (AImp i b)) *) intros equiv_ins lookup. (* Goal: AvlTrees.lookup unit i0 t tt *) inversion_clear equiv_ins. (* Goal: AvlTrees.lookup nf_list i0 t bs *) (* Goal: my_nth normal_form n bs b0 *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (AImp i b)) *) clear H H0. (* Goal: forall (data : unit) (_ : lookup unit i t data), False *) apply H2; assumption. (* Goal: forall (data : unit) (_ : lookup unit i t data), False *) assumption. (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (AImp i b)) *) intros i' lookup; left; apply In_Atoms; assumption. Qed. Lemma in_ngamma_del_ai_tail : forall (work : nf_list) (ds : disjs) (ni : nested_imps) (i : Int) (ai ai' : atomic_imps) (a : atoms) (c : normal_form), EQUIV_DEL nf_list i ai' ai -> in_ngamma work ds ni ai a c -> in_ngamma work ds ni ai' a c. (* Goal: forall (work : nf_list) (ds : disjs) (ni : nested_imps) (i : Int) (ai ai' : atomic_imps) (a : atoms) (c : normal_form) (_ : EQUIV_DEL nf_list i ai' ai) (_ : in_ngamma work ds ni ai a c), in_ngamma work ds ni ai' a c *) intros work ds ni i ai ai' a c equiv_del in_ngamma0. (* Goal: sumor (in_ngamma work ds ni ai a c) (@eq normal_form c (NAtom i)) *) elim in_ngamma0; clear in_ngamma0 c. (* Goal: forall (n : nat) (c : normal_form) (_ : my_nth normal_form n work c), in_ngamma work ds ni ai a' c *) (* Goal: forall (n : nat) (i j : Int) (_ : my_nth disj n ds (@pair Int Int i j)), in_ngamma work ds ni ai a' (NDisj i j) *) (* Goal: forall (n : nat) (x : nimp) (_ : my_nth nimp n (nested_imps2nimps ni) x), in_ngamma work ds ni ai a' (NImp_NF x) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), in_ngamma work ds ni ai a' (AImp i b) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds ni ai a' (NAtom i) *) intros n c0 nth; apply In_Work with n; assumption. (* Goal: forall (n : nat) (i j : Int) (_ : my_nth disj n ds (@pair Int Int i j)), in_ngamma work ds ni ai a' (NDisj i j) *) (* Goal: forall (n : nat) (x : nimp) (_ : my_nth nimp n (nested_imps2nimps ni) x), in_ngamma work ds ni ai a' (NImp_NF x) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), in_ngamma work ds ni ai a' (AImp i b) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds ni ai a' (NAtom i) *) intros n i' j' nth; apply In_Disjs with n; assumption. (* Goal: forall (data : unit) (_ : lookup unit i t data), False *) intros n x' nth; apply In_Nested_Imps with n; assumption. (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), in_ngamma work ds ni ai' a (AImp i b) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds ni ai' a (NAtom i) *) intros i0 b0 n bs lookup nth. (* Goal: in_ngamma work ds ni ai' a (AImp i0 b0) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds ni ai' a (NAtom i) *) apply In_Atomic_Imps with n bs. (* Goal: LOOKUP nf_list i0 ai' bs *) (* Goal: my_nth normal_form n bs b0 *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds ni ai' a (NAtom i) *) generalize equiv_del lookup; clear equiv_del lookup. (* Goal: forall (_ : LOOKUP nf_list i ai' bs) (_ : EQUIV_DEL nf_list i ai' ai) (_ : LOOKUP nf_list i0 ai' bs0), LOOKUP nf_list i0 ai bs0 *) (* Goal: my_nth normal_form n bs0 b0 *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sum (in_ngamma work ds ni ai a (NAtom i0)) (in_ngamma_del_ai_rev_spec i bs (NAtom i0)) *) elim ai; clear ai; intros t avl_t. (* Goal: forall (_ : LOOKUP nf_list i ai' bs) (_ : EQUIV_DEL nf_list i ai' (AVL_intro nf_list t avl_t)) (_ : LOOKUP nf_list i0 ai' bs0), LOOKUP nf_list i0 (AVL_intro nf_list t avl_t) bs0 *) (* Goal: my_nth normal_form n bs0 b0 *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sum (in_ngamma work ds ni ai a (NAtom i0)) (in_ngamma_del_ai_rev_spec i bs (NAtom i0)) *) elim ai'; clear ai'; intros t' avl_t'. (* Goal: in_ngamma work ds ni ai a' (NAtom i) *) simpl in |- *. (* Goal: forall (_ : equiv_del nf_list i t' t) (_ : lookup nf_list i0 t bs), lookup nf_list i0 t' bs *) (* Goal: my_nth normal_form n bs b0 *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds ni ai' a (NAtom i) *) intros equiv_del lookup. (* Goal: AvlTrees.lookup nf_list i0 t bs0 *) (* Goal: my_nth normal_form n bs0 b0 *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sum (in_ngamma work ds ni ai a (NAtom i0)) (in_ngamma_del_ai_rev_spec i bs (NAtom i0)) *) inversion_clear equiv_del. (* Goal: sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (NAtom i)) *) elim (equal_dec i0 i). (* Goal: forall _ : Equal i0 i, sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (NAtom i)) *) (* Goal: forall _ : not (Equal i0 i), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (NAtom i)) *) intro equal. (* Goal: AvlTrees.lookup nf_list i0 t' bs *) (* Goal: forall _ : not (Equal i0 i), AvlTrees.lookup nf_list i0 t' bs *) (* Goal: my_nth normal_form n bs b0 *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds ni ai' a (NAtom i) *) elimtype False. (* Goal: False *) (* Goal: forall _ : not (Equal i0 i), AvlTrees.lookup nf_list i0 t' bs *) (* Goal: my_nth normal_form n bs b0 *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds ni ai' a (NAtom i) *) apply (H i0 equal bs lookup). (* Goal: forall _ : not (Equal i0 i), AvlTrees.lookup nf_list i0 t' bs *) (* Goal: my_nth normal_form n bs b0 *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds ni ai' a (NAtom i) *) intros not_equal. (* Goal: AvlTrees.lookup unit i0 t' tt *) apply H1; assumption. (* Goal: forall (data : unit) (_ : lookup unit i t data), False *) assumption. (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds ni ai' a (NAtom i) *) intros i' lookup; apply In_Atoms; assumption. Qed. Inductive in_ngamma_del_ai_rev_spec (i : Int) (bs : nf_list) (c : normal_form) : Set := In_NGamma_Del_AI_Rev_Spec_Intro : forall (b : normal_form) (n : nat), my_nth normal_form n bs b -> c = AImp i b -> in_ngamma_del_ai_rev_spec i bs c. Lemma in_ngamma_del_ai_rev : forall (work : nf_list) (ds : disjs) (ni : nested_imps) (i : Int) (bs : nf_list) (ai ai' : atomic_imps) (a : atoms) (c : normal_form), LOOKUP nf_list i ai' bs -> EQUIV_DEL nf_list i ai' ai -> in_ngamma work ds ni ai' a c -> in_ngamma work ds ni ai a c + in_ngamma_del_ai_rev_spec i bs c. (* Goal: forall (work : nf_list) (ds : disjs) (ni : nested_imps) (i : Int) (bs : nf_list) (ai ai' : atomic_imps) (a : atoms) (c : normal_form) (_ : LOOKUP nf_list i ai' bs) (_ : EQUIV_DEL nf_list i ai' ai) (_ : in_ngamma work ds ni ai' a c), sum (in_ngamma work ds ni ai a c) (in_ngamma_del_ai_rev_spec i bs c) *) intros work ds ni i bs ai ai' a c lookup equiv_del in_ngamma0. (* Goal: sumor (in_ngamma work ds ni ai a c) (@eq normal_form c (NAtom i)) *) elim in_ngamma0; clear in_ngamma0 c. (* Goal: forall (n : nat) (c : normal_form) (_ : my_nth normal_form n work c), sumor (in_ngamma work ds ni ai a c) (@eq normal_form c (NAtom i)) *) (* Goal: forall (n : nat) (i0 j : Int) (_ : my_nth disj n ds (@pair Int Int i0 j)), sumor (in_ngamma work ds ni ai a (NDisj i0 j)) (@eq normal_form (NDisj i0 j) (NAtom i)) *) (* Goal: forall (n : nat) (x : nimp) (_ : my_nth nimp n (nested_imps2nimps ni) x), sumor (in_ngamma work ds ni ai a (NImp_NF x)) (@eq normal_form (NImp_NF x) (NAtom i)) *) (* Goal: forall (i0 : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i0 ai bs) (_ : my_nth normal_form n bs b), sumor (in_ngamma work ds ni ai a (AImp i0 b)) (@eq normal_form (AImp i0 b) (NAtom i)) *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a' tt), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (NAtom i)) *) intros n c0 nth; left; apply In_Work with n; assumption. (* Goal: forall (n : nat) (i0 j : Int) (_ : my_nth disj n ds (@pair Int Int i0 j)), sumor (in_ngamma work ds ni ai a (NDisj i0 j)) (@eq normal_form (NDisj i0 j) (NAtom i)) *) (* Goal: forall (n : nat) (x : nimp) (_ : my_nth nimp n (nested_imps2nimps ni) x), sumor (in_ngamma work ds ni ai a (NImp_NF x)) (@eq normal_form (NImp_NF x) (NAtom i)) *) (* Goal: forall (i0 : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i0 ai bs) (_ : my_nth normal_form n bs b), sumor (in_ngamma work ds ni ai a (AImp i0 b)) (@eq normal_form (AImp i0 b) (NAtom i)) *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a' tt), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (NAtom i)) *) intros n i' j' nth; left; apply In_Disjs with n; assumption. (* Goal: forall (data : unit) (_ : lookup unit i t data), False *) intros n x' nth; left; apply In_Nested_Imps with n; assumption. (* Goal: forall (i0 : Int) (b : normal_form) (n : nat) (bs0 : nf_list) (_ : LOOKUP nf_list i0 ai' bs0) (_ : my_nth normal_form n bs0 b), sum (in_ngamma work ds ni ai a (AImp i0 b)) (in_ngamma_del_ai_rev_spec i bs (AImp i0 b)) *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sum (in_ngamma work ds ni ai a (NAtom i0)) (in_ngamma_del_ai_rev_spec i bs (NAtom i0)) *) intros i0 b0 n bs0 lookup0 nth. (* Goal: sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (NAtom i)) *) elim (equal_dec i0 i). (* Goal: forall _ : Equal i0 i, sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (NAtom i)) *) (* Goal: forall _ : not (Equal i0 i), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (NAtom i)) *) intro equal. (* Goal: sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (NAtom i)) *) (* Goal: forall _ : not (Equal i0 i), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (NAtom i)) *) right. (* Goal: in_ngamma_del_ai_rev_spec i bs (AImp i0 b0) *) (* Goal: forall _ : not (Equal i0 i), sum (in_ngamma work ds ni ai a (AImp i0 b0)) (in_ngamma_del_ai_rev_spec i bs (AImp i0 b0)) *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sum (in_ngamma work ds ni ai a (NAtom i0)) (in_ngamma_del_ai_rev_spec i bs (NAtom i0)) *) rewrite (equal_eq i0 i equal). (* Goal: in_ngamma_del_ai_rev_spec i bs (AImp i b0) *) (* Goal: forall _ : not (Equal i0 i), sum (in_ngamma work ds ni ai a (AImp i0 b0)) (in_ngamma_del_ai_rev_spec i bs (AImp i0 b0)) *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sum (in_ngamma work ds ni ai a (NAtom i0)) (in_ngamma_del_ai_rev_spec i bs (NAtom i0)) *) exists b0 n. (* Goal: my_nth normal_form n bs b0 *) (* Goal: @eq normal_form (AImp i b0) (AImp i b0) *) (* Goal: forall _ : not (Equal i0 i), sum (in_ngamma work ds ni ai a (AImp i0 b0)) (in_ngamma_del_ai_rev_spec i bs (AImp i0 b0)) *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sum (in_ngamma work ds ni ai a (NAtom i0)) (in_ngamma_del_ai_rev_spec i bs (NAtom i0)) *) generalize equiv_del lookup0 lookup; clear equiv_del lookup0 lookup. (* Goal: forall (_ : LOOKUP nf_list i ai' bs) (_ : EQUIV_DEL nf_list i ai' ai) (_ : LOOKUP nf_list i0 ai' bs0), LOOKUP nf_list i0 ai bs0 *) (* Goal: my_nth normal_form n bs0 b0 *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sum (in_ngamma work ds ni ai a (NAtom i0)) (in_ngamma_del_ai_rev_spec i bs (NAtom i0)) *) elim ai; clear ai; intros t avl_t. (* Goal: forall (_ : LOOKUP nf_list i ai' bs) (_ : EQUIV_DEL nf_list i ai' (AVL_intro nf_list t avl_t)) (_ : LOOKUP nf_list i0 ai' bs0), LOOKUP nf_list i0 (AVL_intro nf_list t avl_t) bs0 *) (* Goal: my_nth normal_form n bs0 b0 *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sum (in_ngamma work ds ni ai a (NAtom i0)) (in_ngamma_del_ai_rev_spec i bs (NAtom i0)) *) elim ai'; clear ai'; intros t' avl_t'. (* Goal: in_ngamma work ds ni ai a' (NAtom i) *) simpl in |- *. (* Goal: forall (_ : forall d : unit, not (lookup unit i t d)) (_ : equiv_ins unit i (fun _ : unit => tt) tt t t'), lookup unit i t' tt *) intros. (* Goal: forall (data : unit) (_ : lookup unit i t data), False *) rewrite <- (lookup_avl_equal nf_list i0 i t' bs0 bs); try assumption. (* Goal: @eq normal_form (AImp i b0) (AImp i b0) *) (* Goal: forall _ : not (Equal i0 i), sum (in_ngamma work ds ni ai a (AImp i0 b0)) (in_ngamma_del_ai_rev_spec i bs (AImp i0 b0)) *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sum (in_ngamma work ds ni ai a (NAtom i0)) (in_ngamma_del_ai_rev_spec i bs (NAtom i0)) *) trivial. (* Goal: forall _ : not (Equal i0 i), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (NAtom i)) *) intros notequal. (* Goal: sum (in_ngamma work ds ni ai a (AImp i0 b0)) (in_ngamma_del_ai_rev_spec i bs (AImp i0 b0)) *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sum (in_ngamma work ds ni ai a (NAtom i0)) (in_ngamma_del_ai_rev_spec i bs (NAtom i0)) *) left. (* Goal: in_ngamma work ds ni ai a (AImp i0 b0) *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sum (in_ngamma work ds ni ai a (NAtom i0)) (in_ngamma_del_ai_rev_spec i bs (NAtom i0)) *) apply In_Atomic_Imps with n bs0. (* Goal: LOOKUP nf_list i0 ai bs0 *) (* Goal: my_nth normal_form n bs0 b0 *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sum (in_ngamma work ds ni ai a (NAtom i0)) (in_ngamma_del_ai_rev_spec i bs (NAtom i0)) *) generalize lookup equiv_del lookup0; clear lookup equiv_del lookup0. (* Goal: forall (_ : LOOKUP nf_list i ai' bs) (_ : EQUIV_DEL nf_list i ai' ai) (_ : LOOKUP nf_list i0 ai' bs0), LOOKUP nf_list i0 ai bs0 *) (* Goal: my_nth normal_form n bs0 b0 *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sum (in_ngamma work ds ni ai a (NAtom i0)) (in_ngamma_del_ai_rev_spec i bs (NAtom i0)) *) elim ai; clear ai; intros t avl_t. (* Goal: forall (_ : LOOKUP nf_list i ai' bs) (_ : EQUIV_DEL nf_list i ai' (AVL_intro nf_list t avl_t)) (_ : LOOKUP nf_list i0 ai' bs0), LOOKUP nf_list i0 (AVL_intro nf_list t avl_t) bs0 *) (* Goal: my_nth normal_form n bs0 b0 *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sum (in_ngamma work ds ni ai a (NAtom i0)) (in_ngamma_del_ai_rev_spec i bs (NAtom i0)) *) elim ai'; clear ai'; intros t' avl_t'. (* Goal: forall (_ : forall d : unit, not (lookup unit i t d)) (_ : equiv_ins unit i (fun _ : unit => tt) tt t t'), lookup unit i t' tt *) simpl in |- *; intros. (* Goal: AvlTrees.lookup nf_list i0 t bs0 *) (* Goal: my_nth normal_form n bs0 b0 *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sum (in_ngamma work ds ni ai a (NAtom i0)) (in_ngamma_del_ai_rev_spec i bs (NAtom i0)) *) inversion_clear equiv_del. (* Goal: forall (data : unit) (_ : lookup unit i t data), False *) apply H0; assumption. (* Goal: forall (data : unit) (_ : lookup unit i t data), False *) assumption. (* Goal: forall (data : unit) (_ : lookup unit i t data), False *) intros i' lookup'; left; apply In_Atoms; assumption. Qed. Lemma in_ngamma_ins_a_tail : forall (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (i : Int) (a a' : atoms) (c : normal_form), EQUIV_INS unit i (fun _ : unit => tt) tt a a' -> in_ngamma work ds ni ai a c -> in_ngamma work ds ni ai a' c. (* Goal: forall (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (i : Int) (a a' : atoms) (c : normal_form) (_ : EQUIV_INS unit i (fun _ : unit => tt) tt a a') (_ : in_ngamma work ds ni ai a' c), in_ngamma (@cons normal_form (NAtom i) work) ds ni ai a c *) intros work ds ni ai i a a' c equiv_ins in_ngamma0. (* Goal: sumor (in_ngamma work ds ni ai a c) (@eq normal_form c (NAtom i)) *) elim in_ngamma0; clear in_ngamma0 c. (* Goal: forall (n : nat) (c : normal_form) (_ : my_nth normal_form n work c), in_ngamma work ds ni ai a' c *) (* Goal: forall (n : nat) (i j : Int) (_ : my_nth disj n ds (@pair Int Int i j)), in_ngamma work ds ni ai a' (NDisj i j) *) (* Goal: forall (n : nat) (x : nimp) (_ : my_nth nimp n (nested_imps2nimps ni) x), in_ngamma work ds ni ai a' (NImp_NF x) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), in_ngamma work ds ni ai a' (AImp i b) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds ni ai a' (NAtom i) *) intros n c0 nth; apply In_Work with n; assumption. (* Goal: forall (n : nat) (i j : Int) (_ : my_nth disj n ds (@pair Int Int i j)), in_ngamma work ds ni ai a' (NDisj i j) *) (* Goal: forall (n : nat) (x : nimp) (_ : my_nth nimp n (nested_imps2nimps ni) x), in_ngamma work ds ni ai a' (NImp_NF x) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i ai bs) (_ : my_nth normal_form n bs b), in_ngamma work ds ni ai a' (AImp i b) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i a tt), in_ngamma work ds ni ai a' (NAtom i) *) intros n i' j' nth; apply In_Disjs with n; assumption. (* Goal: forall (data : unit) (_ : lookup unit i t data), False *) intros n x' nth; apply In_Nested_Imps with n; assumption. (* Goal: forall (data : unit) (_ : lookup unit i t data), False *) intros i0 b0 n bs lookup nth; apply In_Atomic_Imps with n bs; assumption. (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a' tt), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (NAtom i)) *) intros i0 lookup. (* Goal: in_ngamma work ds ni ai a' (NAtom i) *) apply In_Atoms. (* Goal: LOOKUP unit i0 a tt *) generalize equiv_ins lookup; clear equiv_ins lookup. (* Goal: forall (_ : EQUIV_INS unit i (fun _ : unit => tt) tt a a') (_ : LOOKUP unit i0 a' tt), LOOKUP unit i0 a tt *) elim a; clear a; intros t avl_t. (* Goal: forall (_ : EQUIV_INS unit i (fun _ : unit => tt) tt (AVL_intro unit t avl_t) a') (_ : LOOKUP unit i0 a' tt), LOOKUP unit i0 (AVL_intro unit t avl_t) tt *) elim a'; clear a'; intros t' avl_t'. (* Goal: forall (_ : equiv_ins nf_list i (@cons normal_form b) nf_nil t t') (_ : lookup nf_list i0 t' bs), lookup nf_list i0 t bs *) (* Goal: my_nth normal_form n bs b0 *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (AImp i b)) *) simpl in |- *; intros equiv_ins lookup. (* Goal: AvlTrees.lookup unit i0 t tt *) inversion_clear equiv_ins. (* Goal: AvlTrees.lookup unit i0 t' tt *) case (equal_dec i0 i). (* Goal: forall _ : Equal i0 i, sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (NAtom i)) *) (* Goal: forall _ : not (Equal i0 i), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (NAtom i)) *) intro equal. (* Goal: forall (data : unit) (_ : lookup unit i t data), False *) apply H with tt; assumption. (* Goal: forall _ : not (Equal i0 i), AvlTrees.lookup unit i0 t' tt *) intro notequal. (* Goal: AvlTrees.lookup unit i0 t' tt *) apply H1; assumption. Qed. Lemma in_ngamma_ins_a_head : forall (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (i : Int) (a a' : atoms), EQUIV_INS unit i (fun _ : unit => tt) tt a a' -> in_ngamma work ds ni ai a' (NAtom i). (* Goal: forall (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (i : Int) (a a' : atoms) (_ : EQUIV_INS unit i (fun _ : unit => tt) tt a a'), in_ngamma work ds ni ai a' (NAtom i) *) intros work ds ni ai i a a' equiv_ins. (* Goal: in_ngamma work ds ni ai a' (NAtom i) *) apply In_Atoms. (* Goal: LOOKUP unit i a' tt *) generalize equiv_ins; clear equiv_ins. (* Goal: forall (_ : EQUIV_INS unit i (fun _ : unit => tt) tt a a') (_ : LOOKUP unit i0 a' tt), LOOKUP unit i0 a tt *) elim a; clear a; intros t avl_t. (* Goal: forall (_ : EQUIV_INS unit i (fun _ : unit => tt) tt (AVL_intro unit t avl_t) a') (_ : LOOKUP unit i0 a' tt), LOOKUP unit i0 (AVL_intro unit t avl_t) tt *) elim a'; clear a'; intros t' avl_t'. (* Goal: in_ngamma work ds ni ai a' (NAtom i) *) simpl in |- *. (* Goal: forall _ : equiv_ins unit i (fun _ : unit => tt) tt t t', lookup unit i t' tt *) elim (lookup_dec unit i t avl_t). (* Goal: forall (_ : forall d : unit, not (lookup unit i t d)) (_ : equiv_ins unit i (fun _ : unit => tt) tt t t'), lookup unit i t' tt *) intros. (* Goal: AvlTrees.lookup unit i0 t tt *) inversion_clear equiv_ins. (* Goal: lookup unit i t' tt *) (* Goal: forall (_ : forall d : unit, not (lookup unit i t d)) (_ : equiv_ins unit i (fun _ : unit => tt) tt t t'), lookup unit i t' tt *) apply H with d. (* Goal: Equal i i *) (* Goal: forall (data : unit) (_ : lookup unit i t data), False *) apply equal_refl. (* Goal: forall (data : unit) (_ : lookup unit i t data), False *) assumption. (* Goal: forall (_ : forall d : unit, not (lookup unit i t d)) (_ : equiv_ins unit i (fun _ : unit => tt) tt t t'), lookup unit i t' tt *) intros. (* Goal: AvlTrees.lookup unit i0 t tt *) inversion_clear equiv_ins. (* Goal: lookup unit i t' tt *) apply H0. (* Goal: Equal i i *) (* Goal: forall (data : unit) (_ : lookup unit i t data), False *) apply equal_refl. (* Goal: forall (data : unit) (_ : lookup unit i t data), False *) assumption. Qed. Lemma in_ngamma_ins_a_rev : forall (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (i : Int) (a a' : atoms) (c : normal_form), EQUIV_INS unit i (fun _ : unit => tt) tt a a' -> in_ngamma work ds ni ai a' c -> in_ngamma work ds ni ai a c + {c = NAtom i}. (* Goal: forall (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (i : Int) (a a' : atoms) (c : normal_form) (_ : EQUIV_INS unit i (fun _ : unit => tt) tt a a') (_ : in_ngamma work ds ni ai a' c), in_ngamma (@cons normal_form (NAtom i) work) ds ni ai a c *) intros work ds ni ai i a a' c equiv_ins in_ngamma0. (* Goal: sumor (in_ngamma work ds ni ai a c) (@eq normal_form c (NAtom i)) *) elim in_ngamma0; clear in_ngamma0 c. (* Goal: forall (n : nat) (c : normal_form) (_ : my_nth normal_form n work c), sumor (in_ngamma work ds ni ai a c) (@eq normal_form c (NAtom i)) *) (* Goal: forall (n : nat) (i0 j : Int) (_ : my_nth disj n ds (@pair Int Int i0 j)), sumor (in_ngamma work ds ni ai a (NDisj i0 j)) (@eq normal_form (NDisj i0 j) (NAtom i)) *) (* Goal: forall (n : nat) (x : nimp) (_ : my_nth nimp n (nested_imps2nimps ni) x), sumor (in_ngamma work ds ni ai a (NImp_NF x)) (@eq normal_form (NImp_NF x) (NAtom i)) *) (* Goal: forall (i0 : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i0 ai bs) (_ : my_nth normal_form n bs b), sumor (in_ngamma work ds ni ai a (AImp i0 b)) (@eq normal_form (AImp i0 b) (NAtom i)) *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a' tt), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (NAtom i)) *) intros n c0 nth; left; apply In_Work with n; assumption. (* Goal: forall (n : nat) (i0 j : Int) (_ : my_nth disj n ds (@pair Int Int i0 j)), sumor (in_ngamma work ds ni ai a (NDisj i0 j)) (@eq normal_form (NDisj i0 j) (NAtom i)) *) (* Goal: forall (n : nat) (x : nimp) (_ : my_nth nimp n (nested_imps2nimps ni) x), sumor (in_ngamma work ds ni ai a (NImp_NF x)) (@eq normal_form (NImp_NF x) (NAtom i)) *) (* Goal: forall (i0 : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i0 ai bs) (_ : my_nth normal_form n bs b), sumor (in_ngamma work ds ni ai a (AImp i0 b)) (@eq normal_form (AImp i0 b) (NAtom i)) *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a' tt), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (NAtom i)) *) intros n i' j' nth; left; apply In_Disjs with n; assumption. (* Goal: forall (data : unit) (_ : lookup unit i t data), False *) intros n x' nth; left; apply In_Nested_Imps with n; assumption. (* Goal: forall (data : unit) (_ : lookup unit i t data), False *) intros i0 b n bs lookup nth; left; apply In_Atomic_Imps with n bs; assumption. (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a' tt), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (NAtom i)) *) intros i0 lookup. (* Goal: sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (NAtom i)) *) elim (equal_dec i0 i). (* Goal: forall _ : Equal i0 i, sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (NAtom i)) *) (* Goal: forall _ : not (Equal i0 i), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (NAtom i)) *) intro equal. (* Goal: sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (NAtom i)) *) (* Goal: forall _ : not (Equal i0 i), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (NAtom i)) *) right. (* Goal: @eq normal_form (AImp i b0) (AImp i b0) *) (* Goal: forall _ : not (Equal i0 i), sum (in_ngamma work ds ni ai a (AImp i0 b0)) (in_ngamma_del_ai_rev_spec i bs (AImp i0 b0)) *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sum (in_ngamma work ds ni ai a (NAtom i0)) (in_ngamma_del_ai_rev_spec i bs (NAtom i0)) *) rewrite (equal_eq i0 i); trivial. (* Goal: forall _ : not (Equal i0 i), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (NAtom i)) *) intros notequal. (* Goal: in_ngamma work ds ni ai a' (NAtom i) *) left; apply In_Atoms. (* Goal: LOOKUP unit i0 a tt *) generalize equiv_ins lookup; clear equiv_ins lookup. (* Goal: forall (_ : EQUIV_INS unit i (fun _ : unit => tt) tt a a') (_ : LOOKUP unit i0 a' tt), LOOKUP unit i0 a tt *) elim a; clear a; intros t avl_t. (* Goal: forall (_ : EQUIV_INS unit i (fun _ : unit => tt) tt (AVL_intro unit t avl_t) a') (_ : LOOKUP unit i0 a' tt), LOOKUP unit i0 (AVL_intro unit t avl_t) tt *) elim a'; clear a'; intros t' avl_t'. (* Goal: forall (_ : equiv_ins nf_list i (@cons normal_form b) nf_nil t t') (_ : lookup nf_list i0 t' bs), lookup nf_list i0 t bs *) (* Goal: my_nth normal_form n bs b0 *) (* Goal: forall (i0 : Int) (_ : LOOKUP unit i0 a tt), sumor (in_ngamma work ds ni ai a (NAtom i0)) (@eq normal_form (NAtom i0) (AImp i b)) *) simpl in |- *; intros equiv_ins lookup. (* Goal: AvlTrees.lookup unit i0 t tt *) inversion_clear equiv_ins. (* Goal: forall (data : unit) (_ : lookup unit i t data), False *) apply H2; assumption. Qed. (********************************************************************) Lemma in_ngamma_shift_work_ds : forall (i j : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (c : normal_form), in_ngamma (NDisj i j :: work) ds ni ai a c -> in_ngamma work ((i, j) :: ds) ni ai a c. (* Goal: forall (i j : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (c : normal_form) (_ : in_ngamma work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a c), in_ngamma (@cons normal_form (NDisj i j) work) ds ni ai a c *) intros i j work ds ni ai a c in_ngamma0. elim (in_ngamma_cons_work_rev (NDisj i j) work ds ni ai a c in_ngamma0); clear in_ngamma0. (* Goal: forall _ : in_ngamma work ds ni ai a c, in_ngamma (@cons normal_form (NAtom i) work) ds ni ai a c *) (* Goal: forall _ : @eq normal_form c (NAtom i), in_ngamma (@cons normal_form (NAtom i) work) ds ni ai a c *) intros in_ngamma0. (* Goal: forall (data : unit) (_ : lookup unit i t data), False *) apply in_ngamma_cons_ds_tail; assumption. intros eq_c; rewrite eq_c. (* Goal: in_ngamma work ds ni ai a' (NAtom i) *) simpl in |- *. (* Goal: in_ngamma work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a (NDisj i j) *) apply in_ngamma_cons_ds_head. Qed. Lemma in_ngamma_shift_ds_work : forall (i j : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (c : normal_form), in_ngamma work ((i, j) :: ds) ni ai a c -> in_ngamma (NDisj i j :: work) ds ni ai a c. (* Goal: forall (i j : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (c : normal_form) (_ : in_ngamma work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a c), in_ngamma (@cons normal_form (NDisj i j) work) ds ni ai a c *) intros i j work ds ni ai a c in_ngamma0. elim (in_ngamma_cons_ds_rev work i j ds ni ai a c in_ngamma0); clear in_ngamma0. (* Goal: forall _ : in_ngamma work ds ni ai a c, in_ngamma (@cons normal_form (NAtom i) work) ds ni ai a c *) (* Goal: forall _ : @eq normal_form c (NAtom i), in_ngamma (@cons normal_form (NAtom i) work) ds ni ai a c *) intros in_ngamma0. (* Goal: forall (data : unit) (_ : lookup unit i t data), False *) apply in_ngamma_cons_work_tail; assumption. intros eq_c; rewrite eq_c. (* Goal: in_ngamma (@cons normal_form (NDisj i j) work) ds ni ai a (NDisj i j) *) apply in_ngamma_cons_work_head with (c := NDisj i j). Qed. Lemma in_ngamma_shift_work_ni : forall (x : nested_imp) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (c : normal_form), in_ngamma (NImp_NF (nested_imp2nimp x) :: work) ds ni ai a c -> in_ngamma work ds (x :: ni) ai a c. (* Goal: forall (x : nested_imp) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (c : normal_form) (_ : in_ngamma work ds (@cons nested_imp x ni) ai a c), in_ngamma (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds ni ai a c *) intros x work ds ni ai a c in_ngamma0. elim (in_ngamma_cons_work_rev (NImp_NF (nested_imp2nimp x)) work ds ni ai a c in_ngamma0); clear in_ngamma0. (* Goal: forall _ : in_ngamma work ds ni ai a c, in_ngamma (@cons normal_form (NAtom i) work) ds ni ai a c *) (* Goal: forall _ : @eq normal_form c (NAtom i), in_ngamma (@cons normal_form (NAtom i) work) ds ni ai a c *) intros in_ngamma0. (* Goal: forall (data : unit) (_ : lookup unit i t data), False *) apply in_ngamma_cons_ni_tail; assumption. intros eq_c; rewrite eq_c. (* Goal: in_ngamma work ds (@cons nested_imp x ni) ai a (NImp_NF (nested_imp2nimp x)) *) apply in_ngamma_cons_ni_head. Qed. Lemma in_ngamma_shift_ni_work : forall (x : nested_imp) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (c : normal_form), in_ngamma work ds (x :: ni) ai a c -> in_ngamma (NImp_NF (nested_imp2nimp x) :: work) ds ni ai a c. (* Goal: forall (x : nested_imp) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (c : normal_form) (_ : in_ngamma work ds (@cons nested_imp x ni) ai a c), in_ngamma (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds ni ai a c *) intros x work ds ni ai a c in_ngamma0. (* Goal: in_ngamma (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds ni ai a c *) elim (in_ngamma_cons_ni_rev work ds x ni ai a c in_ngamma0); clear in_ngamma0. (* Goal: forall _ : in_ngamma work ds ni ai a c, in_ngamma (@cons normal_form (NAtom i) work) ds ni ai a c *) (* Goal: forall _ : @eq normal_form c (NAtom i), in_ngamma (@cons normal_form (NAtom i) work) ds ni ai a c *) intros in_ngamma0. (* Goal: forall (data : unit) (_ : lookup unit i t data), False *) apply in_ngamma_cons_work_tail; assumption. intros eq_c; rewrite eq_c. (* Goal: in_ngamma (@cons normal_form (AImp i b) work) ds ni ai a (AImp i b) *) apply in_ngamma_cons_work_head. Qed. Lemma in_ngamma_shift_work_ni_x_ni : forall (x : nested_imp) (work : nf_list) (ds : disjs) (ni1 ni2 : nested_imps) (ai : atomic_imps) (a : atoms) (c : normal_form), in_ngamma (NImp_NF (nested_imp2nimp x) :: work) ds (ni1 ++ ni2) ai a c -> in_ngamma work ds (ni1 ++ x :: ni2) ai a c. (* Goal: forall (x : nested_imp) (work : nf_list) (ds : disjs) (ni1 ni2 : nested_imps) (ai : atomic_imps) (a : atoms) (c : normal_form) (_ : in_ngamma work ds (@app nested_imp ni1 (@cons nested_imp x ni2)) ai a c), in_ngamma (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds (@app nested_imp ni1 ni2) ai a c *) intros x work ds ni1 ni2 ai a c in_ngamma0. elim (in_ngamma_cons_work_rev (NImp_NF (nested_imp2nimp x)) work ds (ni1 ++ ni2) ai a c in_ngamma0); clear in_ngamma0. (* Goal: forall _ : in_ngamma work ds ni ai a c, in_ngamma (@cons normal_form (NAtom i) work) ds ni ai a c *) (* Goal: forall _ : @eq normal_form c (NAtom i), in_ngamma (@cons normal_form (NAtom i) work) ds ni ai a c *) intros in_ngamma0. (* Goal: forall (data : unit) (_ : lookup unit i t data), False *) apply in_ngamma_ni_x_ni_tail; assumption. intros eq_c; rewrite eq_c. (* Goal: in_ngamma work ds (@app nested_imp ni1 (@cons nested_imp x ni2)) ai a (NImp_NF (nested_imp2nimp x)) *) apply in_ngamma_ni_x_ni_head with (x := x). Qed. Lemma in_ngamma_shift_ni_x_ni_work : forall (x : nested_imp) (work : nf_list) (ds : disjs) (ni1 ni2 : nested_imps) (ai : atomic_imps) (a : atoms) (c : normal_form), in_ngamma work ds (ni1 ++ x :: ni2) ai a c -> in_ngamma (NImp_NF (nested_imp2nimp x) :: work) ds (ni1 ++ ni2) ai a c. (* Goal: forall (x : nested_imp) (work : nf_list) (ds : disjs) (ni1 ni2 : nested_imps) (ai : atomic_imps) (a : atoms) (c : normal_form) (_ : in_ngamma work ds (@app nested_imp ni1 (@cons nested_imp x ni2)) ai a c), in_ngamma (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds (@app nested_imp ni1 ni2) ai a c *) intros x work ds ni1 ni2 ai a c in_ngamma0. elim (in_ngamma_ni_x_ni_rev work ds x ni1 ni2 ai a c in_ngamma0); clear in_ngamma0. (* Goal: forall _ : in_ngamma work ds ni ai a c, in_ngamma (@cons normal_form (NAtom i) work) ds ni ai a c *) (* Goal: forall _ : @eq normal_form c (NAtom i), in_ngamma (@cons normal_form (NAtom i) work) ds ni ai a c *) intros in_ngamma0. (* Goal: forall (data : unit) (_ : lookup unit i t data), False *) apply in_ngamma_cons_work_tail; assumption. intros eq_c; rewrite eq_c. (* Goal: in_ngamma (@cons normal_form (AImp i b) work) ds ni ai a (AImp i b) *) apply in_ngamma_cons_work_head. Qed. Lemma in_ngamma_shift_work_ai_new : forall (work : nf_list) (ds : disjs) (ni : nested_imps) (i : Int) (b : normal_form) (ai ai' : atomic_imps) (a : atoms) (c : normal_form), (forall bs : nf_list, LOOKUP nf_list i ai bs -> False) -> EQUIV_INS nf_list i (cons b) nf_nil ai ai' -> in_ngamma (AImp i b :: work) ds ni ai a c -> in_ngamma work ds ni ai' a c. (* Goal: forall (work : nf_list) (ds : disjs) (ni : nested_imps) (i : Int) (b : normal_form) (ai ai' : atomic_imps) (a : atoms) (c : normal_form) (_ : forall (bs : nf_list) (_ : LOOKUP nf_list i ai bs), False) (_ : EQUIV_INS nf_list i (@cons normal_form b) nf_nil ai ai') (_ : in_ngamma (@cons normal_form (AImp i b) work) ds ni ai a c), in_ngamma work ds ni ai' a c *) intros work ds ni i b ai ai' a c notlookup equiv_ins in_ngamma0. elim (in_ngamma_cons_work_rev (AImp i b) work ds ni ai a c in_ngamma0); clear in_ngamma0. (* Goal: forall _ : in_ngamma work ds ni ai a c, in_ngamma (@cons normal_form (NAtom i) work) ds ni ai a c *) (* Goal: forall _ : @eq normal_form c (NAtom i), in_ngamma (@cons normal_form (NAtom i) work) ds ni ai a c *) intros in_ngamma0. (* Goal: forall (data : unit) (_ : lookup unit i t data), False *) apply in_ngamma_ins_ai_tail with i b ai; assumption. intros eq_c; rewrite eq_c. (* Goal: forall (data : unit) (_ : lookup unit i t data), False *) apply in_ngamma_ins_ai_head_new with ai; assumption. Qed. Lemma in_ngamma_shift_work_ai_old : forall (work : nf_list) (ds : disjs) (ni : nested_imps) (i : Int) (b : normal_form) (bs : nf_list) (ai ai' : atomic_imps) (a : atoms) (c : normal_form), LOOKUP nf_list i ai bs -> EQUIV_INS nf_list i (cons b) nf_nil ai ai' -> in_ngamma (AImp i b :: work) ds ni ai a c -> in_ngamma work ds ni ai' a c. (* Goal: forall (work : nf_list) (ds : disjs) (ni : nested_imps) (i : Int) (b : normal_form) (bs : nf_list) (ai ai' : atomic_imps) (a : atoms) (c : normal_form) (_ : LOOKUP nf_list i ai bs) (_ : EQUIV_INS nf_list i (@cons normal_form b) nf_nil ai ai') (_ : in_ngamma (@cons normal_form (AImp i b) work) ds ni ai a c), in_ngamma work ds ni ai' a c *) intros work ds ni i b bs ai ai' a c lookup equiv_ins in_ngamma0. elim (in_ngamma_cons_work_rev (AImp i b) work ds ni ai a c in_ngamma0); clear in_ngamma0. (* Goal: forall _ : in_ngamma work ds ni ai a c, in_ngamma (@cons normal_form (NAtom i) work) ds ni ai a c *) (* Goal: forall _ : @eq normal_form c (NAtom i), in_ngamma (@cons normal_form (NAtom i) work) ds ni ai a c *) intros in_ngamma0. (* Goal: forall (data : unit) (_ : lookup unit i t data), False *) apply in_ngamma_ins_ai_tail with i b ai; assumption. intros eq_c; rewrite eq_c. (* Goal: forall (data : unit) (_ : lookup unit i t data), False *) apply in_ngamma_ins_ai_head_old with bs ai; assumption. Qed. Lemma in_ngamma_shift_ai_work : forall (work : nf_list) (ds : disjs) (ni : nested_imps) (i : Int) (b : normal_form) (ai ai' : atomic_imps) (a : atoms) (c : normal_form), EQUIV_INS nf_list i (cons b) nf_nil ai ai' -> in_ngamma work ds ni ai' a c -> in_ngamma (AImp i b :: work) ds ni ai a c. (* Goal: forall (work : nf_list) (ds : disjs) (ni : nested_imps) (i : Int) (b : normal_form) (ai ai' : atomic_imps) (a : atoms) (c : normal_form) (_ : EQUIV_INS nf_list i (@cons normal_form b) nf_nil ai ai') (_ : in_ngamma work ds ni ai' a c), in_ngamma (@cons normal_form (AImp i b) work) ds ni ai a c *) intros work ds ni i b ai ai' a c equiv_ins in_ngamma0. elim (in_ngamma_ins_ai_rev work ds ni i b ai ai' a c); try assumption; clear in_ngamma0. (* Goal: forall _ : in_ngamma work ds ni ai a c, in_ngamma (@cons normal_form (NAtom i) work) ds ni ai a c *) (* Goal: forall _ : @eq normal_form c (NAtom i), in_ngamma (@cons normal_form (NAtom i) work) ds ni ai a c *) intros in_ngamma0. (* Goal: forall (data : unit) (_ : lookup unit i t data), False *) apply in_ngamma_cons_work_tail; assumption. intros eq_c; rewrite eq_c. (* Goal: in_ngamma (@cons normal_form (AImp i b) work) ds ni ai a (AImp i b) *) apply in_ngamma_cons_work_head. Qed. Lemma in_ngamma_shift_work_a : forall (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (i : Int) (a a' : atoms) (c : normal_form), EQUIV_INS unit i (fun _ : unit => tt) tt a a' -> in_ngamma (NAtom i :: work) ds ni ai a c -> in_ngamma work ds ni ai a' c. (* Goal: forall (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (i : Int) (a a' : atoms) (c : normal_form) (_ : EQUIV_INS unit i (fun _ : unit => tt) tt a a') (_ : in_ngamma work ds ni ai a' c), in_ngamma (@cons normal_form (NAtom i) work) ds ni ai a c *) intros work ds ni ai i a a' c equiv_ins in_ngamma0. elim (in_ngamma_cons_work_rev (NAtom i) work ds ni ai a c in_ngamma0); clear in_ngamma0. (* Goal: forall _ : in_ngamma work ds ni ai a c, in_ngamma (@cons normal_form (NAtom i) work) ds ni ai a c *) (* Goal: forall _ : @eq normal_form c (NAtom i), in_ngamma (@cons normal_form (NAtom i) work) ds ni ai a c *) intros in_ngamma0. (* Goal: forall (data : unit) (_ : lookup unit i t data), False *) apply in_ngamma_ins_a_tail with i a; assumption. intros eq_c; rewrite eq_c. (* Goal: in_ngamma work ds ni ai a' (NAtom i) *) simpl in |- *. (* Goal: forall (data : unit) (_ : lookup unit i t data), False *) apply in_ngamma_ins_a_head with a; assumption. Qed. Lemma in_ngamma_shift_a_work : forall (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (i : Int) (a a' : atoms) (c : normal_form), EQUIV_INS unit i (fun _ : unit => tt) tt a a' -> in_ngamma work ds ni ai a' c -> in_ngamma (NAtom i :: work) ds ni ai a c. (* Goal: forall (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (i : Int) (a a' : atoms) (c : normal_form) (_ : EQUIV_INS unit i (fun _ : unit => tt) tt a a') (_ : in_ngamma work ds ni ai a' c), in_ngamma (@cons normal_form (NAtom i) work) ds ni ai a c *) intros work ds ni ai i a a' c equiv_ins in_ngamma0. elim (in_ngamma_ins_a_rev work ds ni ai i a a' c); try assumption; clear in_ngamma0. (* Goal: forall _ : in_ngamma work ds ni ai a c, in_ngamma (@cons normal_form (NAtom i) work) ds ni ai a c *) (* Goal: forall _ : @eq normal_form c (NAtom i), in_ngamma (@cons normal_form (NAtom i) work) ds ni ai a c *) intros in_ngamma0. (* Goal: forall (data : unit) (_ : lookup unit i t data), False *) apply in_ngamma_cons_work_tail; assumption. intros eq_c; rewrite eq_c. (* Goal: in_ngamma (@cons normal_form (NAtom i) work) ds ni ai a (NAtom i) *) apply in_ngamma_cons_work_head with (c := NAtom i). Qed.
(* File: Forces_NGamma.v (last edited on 27/10/2000) (c) Klaus Weich *) Require Export Le_Ks. Definition forces_ngamma (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (k : kripke_tree) := forall c : normal_form, in_ngamma work ds ni ai a c -> forces_t k (nf2form c). (********************************************************************) Lemma forces_ngamma_cons_work : forall (c : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (k : kripke_tree), forces_t k (nf2form c) -> forces_ngamma work ds ni ai a k -> forces_ngamma (c :: work) ds ni ai a k. (* Goal: forall (c : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (k : kripke_tree) (_ : forces_t k (nf2form c)) (_ : forces_ngamma work ds ni ai a k), forces_ngamma (@cons normal_form c work) ds ni ai a k *) intros c work ds ni ai a k forces_a forces_ngamma0. (* Goal: forces_ngamma (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds (@app nested_imp ni1 ni2) ai a k *) unfold forces_ngamma in |- *. (* Goal: forall (c : normal_form) (_ : in_ngamma work ds ni ai a c), forces_t k (nf2form c) *) intros c0 in_ngamma. elim (in_ngamma_cons_work_rev c work ds ni ai a c0 in_ngamma); clear in_ngamma. (* Goal: forall _ : in_ngamma work ds ni ai' a c, forces_t k (nf2form c) *) (* Goal: forall _ : in_ngamma_del_ai_rev_spec i bs c, forces_t k (nf2form c) *) intros in_ngamma. (* Goal: forces_t k (nf2form c) *) (* Goal: forall _ : @sig nat (fun n : nat => my_nth normal_form n bs c), forces_t k (nf2form c) *) apply forces_ngamma0; assumption. (* Goal: Is_Monotone_kripke_tree k *) (* Goal: forces_t k (nf2form b) *) (* Goal: forces_ngamma work ds ni ai' a k *) intros eq_c0_c; rewrite eq_c0_c; assumption. Qed. Lemma forces_ngamma_cons_work_tail : forall (c : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (k : kripke_tree), forces_ngamma (c :: work) ds ni ai a k -> forces_ngamma work ds ni ai a k. (* Goal: forall (c : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (k : kripke_tree) (_ : forces_ngamma (@cons normal_form c work) ds ni ai a k), forces_ngamma work ds ni ai a k *) intros c work ds ni ai a k forces. (* Goal: forces_ngamma (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds (@app nested_imp ni1 ni2) ai a k *) unfold forces_ngamma in |- *. (* Goal: forall (c : normal_form) (_ : in_ngamma work ds ni ai a c), forces_t k (nf2form c) *) intros c0 in_ngamma. (* Goal: forces_t k (nf2form c) *) apply forces. (* Goal: In_NGamma.in_ngamma (@cons normal_form c work) ds ni ai a c0 *) apply in_ngamma_cons_work_tail; assumption. Qed. Remark forces_ngamma_app_work : forall (bs work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (k : kripke_tree), (forall (n : nat) (b : normal_form), my_nth normal_form n bs b -> forces_t k (nf2form b)) -> forces_ngamma work ds ni ai a k -> forces_ngamma (bs ++ work) ds ni ai a k. (* Goal: forall (bs work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (k : kripke_tree) (_ : forall (n : nat) (b : normal_form) (_ : my_nth normal_form n bs b), forces_t k (nf2form b)) (_ : forces_ngamma work ds ni ai a k), forces_ngamma (@app normal_form bs work) ds ni ai a k *) intros bs work ds ni ai a k forces_bs forces_ngamma0. (* Goal: forces_ngamma (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds (@app nested_imp ni1 ni2) ai a k *) unfold forces_ngamma in |- *. (* Goal: forall (c : normal_form) (_ : in_ngamma (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds (@app nested_imp ni1 ni2) ai a c), forces_t k (nf2form c) *) intros c in_ngamma. (* Goal: forces_t k (nf2form c) *) elim (in_ngamma_work_app_rev bs work ds ni ai a c in_ngamma); clear in_ngamma. (* Goal: forall _ : in_ngamma work ds ni ai' a c, forces_t k (nf2form c) *) (* Goal: forall _ : in_ngamma_del_ai_rev_spec i bs c, forces_t k (nf2form c) *) intros in_ngamma. (* Goal: forces_t k (nf2form c) *) (* Goal: forall _ : @sig nat (fun n : nat => my_nth normal_form n bs c), forces_t k (nf2form c) *) apply forces_ngamma0; assumption. (* Goal: forall _ : @sig nat (fun n : nat => my_nth normal_form n bs c), forces_t k (nf2form c) *) intros nth; elim nth; clear nth. (* Goal: forall (x : nat) (_ : my_nth normal_form x bs c), forces_t k (nf2form c) *) intros n nth. (* Goal: forces_t k (nf2form (AImp i b)) *) apply forces_bs with n; assumption. Qed. Lemma forces_ngamma_app_work_tail : forall (bs work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (k : kripke_tree), forces_ngamma (bs ++ work) ds ni ai a k -> forces_ngamma work ds ni ai a k. (* Goal: forall (bs work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (k : kripke_tree) (_ : forces_ngamma (@app normal_form bs work) ds ni ai a k), forces_ngamma work ds ni ai a k *) intros bs work ds ni ai a k forces. (* Goal: forces_ngamma (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds (@app nested_imp ni1 ni2) ai a k *) unfold forces_ngamma in |- *. (* Goal: forall (c : normal_form) (_ : in_ngamma (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds (@app nested_imp ni1 ni2) ai a c), forces_t k (nf2form c) *) intros c in_ngamma. (* Goal: forces_t k (nf2form c) *) apply forces. (* Goal: In_NGamma.in_ngamma (@app normal_form bs work) ds ni ai a c *) apply in_ngamma_work_app1; assumption. Qed. Lemma forces_ngamma_cons_ds_tail : forall (work : nf_list) (i j : Int) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (k : kripke_tree), forces_ngamma work ((i, j) :: ds) ni ai a k -> forces_ngamma work ds ni ai a k. (* Goal: forall (work : nf_list) (i j : Int) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (k : kripke_tree) (_ : forces_ngamma work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a k), forces_ngamma work ds ni ai a k *) intros work i j ds ni ai a k forces. (* Goal: forces_ngamma (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds (@app nested_imp ni1 ni2) ai a k *) unfold forces_ngamma in |- *. (* Goal: forall (c : normal_form) (_ : in_ngamma (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds (@app nested_imp ni1 ni2) ai a c), forces_t k (nf2form c) *) intros c in_ngamma. (* Goal: forces_t k (nf2form c) *) apply forces. (* Goal: In_NGamma.in_ngamma work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a c *) apply in_ngamma_cons_ds_tail; assumption. Qed. Lemma forces_ngamma_cons_ni_tail : forall (work : nf_list) (ds : disjs) (x : nested_imp) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (k : kripke_tree), forces_ngamma work ds (x :: ni) ai a k -> forces_ngamma work ds ni ai a k. (* Goal: forall (work : nf_list) (ds : disjs) (x : nested_imp) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (k : kripke_tree) (_ : forces_ngamma work ds (@cons nested_imp x ni) ai a k), forces_ngamma work ds ni ai a k *) intros work ds x ni ai a k forces. (* Goal: forces_ngamma (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds (@app nested_imp ni1 ni2) ai a k *) unfold forces_ngamma in |- *. (* Goal: forall (c : normal_form) (_ : in_ngamma (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds (@app nested_imp ni1 ni2) ai a c), forces_t k (nf2form c) *) intros c in_ngamma. (* Goal: forces_t k (nf2form c) *) apply forces. (* Goal: In_NGamma.in_ngamma work ds (@cons nested_imp x ni) ai a c *) apply in_ngamma_cons_ni_tail; assumption. Qed. Remark forces_ngamma_del_ai : forall (i : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai ai' : atomic_imps) (a : atoms) (k : kripke_tree), EQUIV_DEL nf_list i ai ai' -> forces_ngamma work ds ni ai a k -> forces_ngamma work ds ni ai' a k. (* Goal: forall (i : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai ai' : atomic_imps) (a : atoms) (k : kripke_tree) (_ : EQUIV_DEL nf_list i ai ai') (_ : forces_ngamma work ds ni ai a k), forces_ngamma work ds ni ai' a k *) intros i work ds ni ai ai' a k equiv_del k_forces_ngamma. (* Goal: forces_ngamma (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds (@app nested_imp ni1 ni2) ai a k *) unfold forces_ngamma in |- *. (* Goal: forall (c : normal_form) (_ : in_ngamma (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds (@app nested_imp ni1 ni2) ai a c), forces_t k (nf2form c) *) intros c in_ngamma. (* Goal: forces_t k (nf2form b) *) (* Goal: forces_ngamma work ds ni ai' a k *) apply k_forces_ngamma. (* Goal: In_NGamma.in_ngamma work ds ni ai a c *) apply in_ngamma_del_ai_tail with i ai'; assumption. Qed. Lemma forces_ngamma_del_ai_rev : forall (i : Int) (bs work : nf_list) (ds : disjs) (ni : nested_imps) (ai ai' : atomic_imps) (a : atoms) (k : kripke_tree), LOOKUP nf_list i ai bs -> (forall (n : nat) (b : normal_form), my_nth normal_form n bs b -> forces_t k (nf2form (AImp i b))) -> EQUIV_DEL nf_list i ai ai' -> forces_ngamma work ds ni ai' a k -> forces_ngamma work ds ni ai a k. (* Goal: forall (i : Int) (bs work : nf_list) (ds : disjs) (ni : nested_imps) (ai ai' : atomic_imps) (a : atoms) (k : kripke_tree) (_ : LOOKUP nf_list i ai bs) (_ : forall (n : nat) (b : normal_form) (_ : my_nth normal_form n bs b), forces_t k (nf2form (AImp i b))) (_ : EQUIV_DEL nf_list i ai ai') (_ : forces_ngamma work ds ni ai' a k), forces_ngamma work ds ni ai a k *) intros i bs work ds ni ai ai' a k lookup forces_bs equiv_del k_forces_ngamma. (* Goal: forces_ngamma (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds (@app nested_imp ni1 ni2) ai a k *) unfold forces_ngamma in |- *. (* Goal: forall (c : normal_form) (_ : in_ngamma (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds (@app nested_imp ni1 ni2) ai a c), forces_t k (nf2form c) *) intros c in_ngamma. elim (in_ngamma_del_ai_rev work ds ni i bs ai' ai a c); try assumption; clear in_ngamma. (* Goal: forall _ : in_ngamma work ds ni ai' a c, forces_t k (nf2form c) *) (* Goal: forall _ : in_ngamma_del_ai_rev_spec i bs c, forces_t k (nf2form c) *) intros in_ngamma. (* Goal: forces_t k (nf2form c) *) (* Goal: forall _ : in_ngamma_del_ai_rev_spec i bs c, forces_t k (nf2form c) *) apply k_forces_ngamma; assumption. (* Goal: forall _ : in_ngamma_del_ai_rev_spec i bs c, forces_t k (nf2form c) *) intros in_bs; elim in_bs; clear in_bs. (* Goal: forall (b : normal_form) (n : nat) (_ : my_nth normal_form n bs b) (_ : @eq normal_form c (AImp i b)), forces_t k (nf2form c) *) intros b n nth eq_a. (* Goal: forces_t k (nf2form c) *) rewrite eq_a. (* Goal: forces_t k (nf2form (AImp i b)) *) apply forces_bs with n; assumption. Qed. (***********************************************************************) Lemma forces_ngamma_eqv : forall (ni1 ni2 : nested_imps) (work : nf_list) (ds : disjs) (ai : atomic_imps) (a : atoms) (k : kripke_tree), eqv_ni ni1 ni2 -> forces_ngamma work ds ni2 ai a k -> forces_ngamma work ds ni1 ai a k. (* Goal: forall (ni1 ni2 : nested_imps) (work : nf_list) (ds : disjs) (ai : atomic_imps) (a : atoms) (k : kripke_tree) (_ : eqv_ni ni1 ni2) (_ : forces_ngamma work ds ni2 ai a k), forces_ngamma work ds ni1 ai a k *) intros ni1 ni2 work ds ai a k eqv12 forces2. (* Goal: forces_ngamma (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds (@app nested_imp ni1 ni2) ai a k *) unfold forces_ngamma in |- *. (* Goal: forall (c : normal_form) (_ : in_ngamma (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds (@app nested_imp ni1 ni2) ai a c), forces_t k (nf2form c) *) intros c in_ngamma. (* Goal: forces_t k (nf2form c) *) apply forces2. (* Goal: In_NGamma.in_ngamma work ds ni2 ai a c *) apply in_ngamma_eqv with ni1; assumption. Qed. (***********************************************************************) Lemma forces_ngamma_shift_ds_work : forall (i j : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (k : kripke_tree), forces_ngamma work ((i, j) :: ds) ni ai a k -> forces_ngamma (NDisj i j :: work) ds ni ai a k. (* Goal: forall (i j : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (k : kripke_tree) (_ : forces_ngamma (@cons normal_form (NDisj i j) work) ds ni ai a k), forces_ngamma work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a k *) intros i j work ds ni ai a k k_forces_ngamma. (* Goal: forces_ngamma (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds (@app nested_imp ni1 ni2) ai a k *) unfold forces_ngamma in |- *. (* Goal: forall (c : normal_form) (_ : in_ngamma work ds ni ai a' c), forces_t k (nf2form c) *) intros d in_gamma. (* Goal: forces_t k (nf2form b) *) (* Goal: forces_ngamma work ds ni ai' a k *) apply k_forces_ngamma. (* Goal: in_ngamma work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a d *) apply in_ngamma_shift_work_ds; assumption. Qed. Lemma forces_ngamma_shift_work_ds : forall (i j : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (k : kripke_tree), forces_ngamma (NDisj i j :: work) ds ni ai a k -> forces_ngamma work ((i, j) :: ds) ni ai a k. (* Goal: forall (i j : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (k : kripke_tree) (_ : forces_ngamma (@cons normal_form (NDisj i j) work) ds ni ai a k), forces_ngamma work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a k *) intros i j work ds ni ai a k k_forces_ngamma. (* Goal: forces_ngamma (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds (@app nested_imp ni1 ni2) ai a k *) unfold forces_ngamma in |- *. (* Goal: forall (c : normal_form) (_ : in_ngamma work ds ni ai a' c), forces_t k (nf2form c) *) intros d in_gamma. (* Goal: forces_t k (nf2form b) *) (* Goal: forces_ngamma work ds ni ai' a k *) apply k_forces_ngamma. (* Goal: in_ngamma (@cons normal_form (NDisj i j) work) ds ni ai a d *) apply in_ngamma_shift_ds_work; assumption. Qed. Lemma forces_ngamma_shift_ni_work : forall (x : nested_imp) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (k : kripke_tree), forces_ngamma work ds (x :: ni) ai a k -> forces_ngamma (NImp_NF (nested_imp2nimp x) :: work) ds ni ai a k. (* Goal: forall (x : nested_imp) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (k : kripke_tree) (_ : forces_ngamma (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds ni ai a k), forces_ngamma work ds (@cons nested_imp x ni) ai a k *) intros x work ds ni ai a k k_forces_ngamma. (* Goal: forces_ngamma (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds (@app nested_imp ni1 ni2) ai a k *) unfold forces_ngamma in |- *. (* Goal: forall (c : normal_form) (_ : in_ngamma work ds ni ai a' c), forces_t k (nf2form c) *) intros d in_gamma. (* Goal: forces_t k (nf2form b) *) (* Goal: forces_ngamma work ds ni ai' a k *) apply k_forces_ngamma. (* Goal: in_ngamma work ds (@cons nested_imp x ni) ai a d *) apply in_ngamma_shift_work_ni; assumption. Qed. Lemma forces_ngamma_shift_work_ni : forall (x : nested_imp) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (k : kripke_tree), forces_ngamma (NImp_NF (nested_imp2nimp x) :: work) ds ni ai a k -> forces_ngamma work ds (x :: ni) ai a k. (* Goal: forall (x : nested_imp) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (k : kripke_tree) (_ : forces_ngamma (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds ni ai a k), forces_ngamma work ds (@cons nested_imp x ni) ai a k *) intros x work ds ni ai a k k_forces_ngamma. (* Goal: forces_ngamma (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds (@app nested_imp ni1 ni2) ai a k *) unfold forces_ngamma in |- *. (* Goal: forall (c : normal_form) (_ : in_ngamma work ds ni ai a' c), forces_t k (nf2form c) *) intros d in_gamma. (* Goal: forces_t k (nf2form b) *) (* Goal: forces_ngamma work ds ni ai' a k *) apply k_forces_ngamma. (* Goal: in_ngamma (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds ni ai a d *) apply in_ngamma_shift_ni_work; assumption. Qed. Lemma forces_ngamma_shift_ai_work_new : forall (i : Int) (b : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai ai' : atomic_imps) (a : atoms) (k : kripke_tree), (forall bs : nf_list, LOOKUP nf_list i ai bs -> False) -> EQUIV_INS nf_list i (cons b) nf_nil ai ai' -> forces_ngamma work ds ni ai' a k -> forces_ngamma (AImp i b :: work) ds ni ai a k. (* Goal: forall (i : Int) (b : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai ai' : atomic_imps) (a : atoms) (k : kripke_tree) (_ : forall (bs : nf_list) (_ : LOOKUP nf_list i ai bs), False) (_ : EQUIV_INS nf_list i (@cons normal_form b) nf_nil ai ai') (_ : forces_ngamma work ds ni ai' a k), forces_ngamma (@cons normal_form (AImp i b) work) ds ni ai a k *) intros i b work ds ni ai ai' a k notlookup equiv_ins k_forces_ngamma. (* Goal: forces_ngamma (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds (@app nested_imp ni1 ni2) ai a k *) unfold forces_ngamma in |- *. (* Goal: forall (c : normal_form) (_ : in_ngamma work ds ni ai a' c), forces_t k (nf2form c) *) intros d in_gamma. (* Goal: forces_t k (nf2form b) *) (* Goal: forces_ngamma work ds ni ai' a k *) apply k_forces_ngamma. (* Goal: in_ngamma work ds ni ai' a d *) apply in_ngamma_shift_work_ai_new with i b ai; assumption. Qed. Lemma forces_ngamma_shift_ai_work_old : forall (i : Int) (b : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (bs : nf_list) (ai ai' : atomic_imps) (a : atoms) (k : kripke_tree), LOOKUP nf_list i ai bs -> EQUIV_INS nf_list i (cons b) nf_nil ai ai' -> forces_ngamma work ds ni ai' a k -> forces_ngamma (AImp i b :: work) ds ni ai a k. (* Goal: forall (i : Int) (b : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (bs : nf_list) (ai ai' : atomic_imps) (a : atoms) (k : kripke_tree) (_ : LOOKUP nf_list i ai bs) (_ : EQUIV_INS nf_list i (@cons normal_form b) nf_nil ai ai') (_ : forces_ngamma work ds ni ai' a k), forces_ngamma (@cons normal_form (AImp i b) work) ds ni ai a k *) intros i b work ds ni bs ai ai' a k lookup equiv_ins k_forces_ngamma. (* Goal: forces_ngamma (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds (@app nested_imp ni1 ni2) ai a k *) unfold forces_ngamma in |- *. (* Goal: forall (c : normal_form) (_ : in_ngamma work ds ni ai a' c), forces_t k (nf2form c) *) intros d in_gamma. (* Goal: forces_t k (nf2form b) *) (* Goal: forces_ngamma work ds ni ai' a k *) apply k_forces_ngamma. (* Goal: in_ngamma work ds ni ai' a d *) apply in_ngamma_shift_work_ai_old with i b bs ai; assumption. Qed. Lemma forces_ngamma_shift_work_ai : forall (i : Int) (b : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai ai' : atomic_imps) (a : atoms) (k : kripke_tree), EQUIV_INS nf_list i (cons b) nf_nil ai ai' -> forces_ngamma (AImp i b :: work) ds ni ai a k -> forces_ngamma work ds ni ai' a k. (* Goal: forall (i : Int) (b : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai ai' : atomic_imps) (a : atoms) (k : kripke_tree) (_ : EQUIV_INS nf_list i (@cons normal_form b) nf_nil ai ai') (_ : forces_ngamma (@cons normal_form (AImp i b) work) ds ni ai a k), forces_ngamma work ds ni ai' a k *) intros i b work ds ni ai ai' a k equiv_ins k_forces_ngamma. (* Goal: forces_ngamma (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds (@app nested_imp ni1 ni2) ai a k *) unfold forces_ngamma in |- *. (* Goal: forall (c : normal_form) (_ : in_ngamma work ds ni ai a' c), forces_t k (nf2form c) *) intros d in_gamma. (* Goal: forces_t k (nf2form b) *) (* Goal: forces_ngamma work ds ni ai' a k *) apply k_forces_ngamma. (* Goal: in_ngamma (@cons normal_form (AImp i b) work) ds ni ai a d *) apply in_ngamma_shift_ai_work with ai'; assumption. Qed. Lemma forces_ngamma_shift_a_work : forall (i : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a a' : atoms) (k : kripke_tree), EQUIV_INS unit i (fun _ : unit => tt) tt a a' -> forces_ngamma work ds ni ai a' k -> forces_ngamma (NAtom i :: work) ds ni ai a k. (* Goal: forall (i : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a a' : atoms) (k : kripke_tree) (_ : EQUIV_INS unit i (fun _ : unit => tt) tt a a') (_ : forces_ngamma (@cons normal_form (NAtom i) work) ds ni ai a k), forces_ngamma work ds ni ai a' k *) intros i work ds ni ai a a' k equiv_ins k_forces_ngamma. (* Goal: forces_ngamma (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds (@app nested_imp ni1 ni2) ai a k *) unfold forces_ngamma in |- *. (* Goal: forall (c : normal_form) (_ : in_ngamma work ds ni ai a' c), forces_t k (nf2form c) *) intros d in_gamma. (* Goal: forces_t k (nf2form b) *) (* Goal: forces_ngamma work ds ni ai' a k *) apply k_forces_ngamma. (* Goal: in_ngamma work ds ni ai a' d *) apply in_ngamma_shift_work_a with i a; assumption. Qed. Lemma forces_ngamma_shift_work_a : forall (i : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a a' : atoms) (k : kripke_tree), EQUIV_INS unit i (fun _ : unit => tt) tt a a' -> forces_ngamma (NAtom i :: work) ds ni ai a k -> forces_ngamma work ds ni ai a' k. (* Goal: forall (i : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a a' : atoms) (k : kripke_tree) (_ : EQUIV_INS unit i (fun _ : unit => tt) tt a a') (_ : forces_ngamma (@cons normal_form (NAtom i) work) ds ni ai a k), forces_ngamma work ds ni ai a' k *) intros i work ds ni ai a a' k equiv_ins k_forces_ngamma. (* Goal: forces_ngamma (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds (@app nested_imp ni1 ni2) ai a k *) unfold forces_ngamma in |- *. (* Goal: forall (c : normal_form) (_ : in_ngamma work ds ni ai a' c), forces_t k (nf2form c) *) intros d in_gamma. (* Goal: forces_t k (nf2form b) *) (* Goal: forces_ngamma work ds ni ai' a k *) apply k_forces_ngamma. (* Goal: in_ngamma (@cons normal_form (NAtom i) work) ds ni ai a d *) apply in_ngamma_shift_a_work with a'; assumption. Qed. Lemma forces_ngamma_shift_work_ni_x_ni : forall (x : nested_imp) (work : nf_list) (ds : disjs) (ni1 ni2 : nested_imps) (ai : atomic_imps) (a : atoms) (k : kripke_tree), forces_ngamma (NImp_NF (nested_imp2nimp x) :: work) ds (ni1 ++ ni2) ai a k -> forces_ngamma work ds (ni1 ++ x :: ni2) ai a k. (* Goal: forall (x : nested_imp) (work : nf_list) (ds : disjs) (ni1 ni2 : nested_imps) (ai : atomic_imps) (a : atoms) (k : kripke_tree) (_ : forces_ngamma work ds (@app nested_imp ni1 (@cons nested_imp x ni2)) ai a k), forces_ngamma (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds (@app nested_imp ni1 ni2) ai a k *) intros x work ds ni1 ni2 ai a k forces. (* Goal: forces_ngamma (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds (@app nested_imp ni1 ni2) ai a k *) unfold forces_ngamma in |- *. (* Goal: forall (c : normal_form) (_ : in_ngamma (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds (@app nested_imp ni1 ni2) ai a c), forces_t k (nf2form c) *) intros c in_ngamma. (* Goal: forces_t k (nf2form c) *) apply forces. (* Goal: In_NGamma.in_ngamma (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds (@app nested_imp ni1 ni2) ai a c *) apply in_ngamma_shift_ni_x_ni_work; assumption. Qed. Lemma forces_ngamma_shift_ni_x_ni_work : forall (x : nested_imp) (work : nf_list) (ds : disjs) (ni1 ni2 : nested_imps) (ai : atomic_imps) (a : atoms) (k : kripke_tree), forces_ngamma work ds (ni1 ++ x :: ni2) ai a k -> forces_ngamma (NImp_NF (nested_imp2nimp x) :: work) ds (ni1 ++ ni2) ai a k. (* Goal: forall (x : nested_imp) (work : nf_list) (ds : disjs) (ni1 ni2 : nested_imps) (ai : atomic_imps) (a : atoms) (k : kripke_tree) (_ : forces_ngamma work ds (@app nested_imp ni1 (@cons nested_imp x ni2)) ai a k), forces_ngamma (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds (@app nested_imp ni1 ni2) ai a k *) intros x work ds ni1 ni2 ai a k forces. (* Goal: forces_ngamma (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds (@app nested_imp ni1 ni2) ai a k *) unfold forces_ngamma in |- *. (* Goal: forall (c : normal_form) (_ : in_ngamma (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds (@app nested_imp ni1 ni2) ai a c), forces_t k (nf2form c) *) intros c in_ngamma. (* Goal: forces_t k (nf2form c) *) apply forces. (* Goal: In_NGamma.in_ngamma work ds (@app nested_imp ni1 (@cons nested_imp x ni2)) ai a c *) apply in_ngamma_shift_work_ni_x_ni; assumption. Qed. (********************************************************************) Lemma forces_ngamma_cons_work_weak : forall (b c : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (k : kripke_tree), Is_Monotone_kripke_tree k -> (forces_t k (nf2form b) -> forces_t k (nf2form c)) -> forces_ngamma (b :: work) ds ni ai a k -> forces_ngamma (c :: work) ds ni ai a k. (* Goal: forall (b c : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forall _ : forces_t k (nf2form b), forces_t k (nf2form c)) (_ : forces_ngamma (@cons normal_form b work) ds ni ai a k), forces_ngamma (@cons normal_form c work) ds ni ai a k *) intros b c work ds ni ai a k k_is_mon forces_bc k_forces_ngamma. (* Goal: forces_ngamma (@cons normal_form d work) ds ni ai a k *) apply forces_ngamma_cons_work. (* Goal: forces_t k (nf2form c) *) (* Goal: forces_ngamma work ds ni ai a k *) apply forces_bc. (* Goal: forces_t k (nf2form b) *) (* Goal: forces_ngamma work ds ni ai' a k *) apply k_forces_ngamma. (* Goal: in_ngamma (@cons normal_form c work) ds ni ai a c *) (* Goal: forces_ngamma work ds ni ai a k *) apply in_ngamma_cons_work_head. (* Goal: forces_ngamma (@cons normal_form c work) ds ni ai a k *) apply forces_ngamma_cons_work_tail with b; assumption. Qed. Lemma forces_ngamma_cons_work_weak2 : forall (b c d : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (k : kripke_tree), Is_Monotone_kripke_tree k -> (forces_t k (nf2form b) -> forces_t k (nf2form c) -> forces_t k (nf2form d)) -> forces_ngamma (b :: c :: work) ds ni ai a k -> forces_ngamma (d :: work) ds ni ai a k. (* Goal: forall (b c d : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forall (_ : forces_t k (nf2form b)) (_ : forces_t k (nf2form c)), forces_t k (nf2form d)) (_ : forces_ngamma (@cons normal_form b (@cons normal_form c work)) ds ni ai a k), forces_ngamma (@cons normal_form d work) ds ni ai a k *) intros b c d work ds ni ai a k k_is_mon forces_bcd k_forces_ngamma. (* Goal: forces_ngamma (@cons normal_form d work) ds ni ai a k *) apply forces_ngamma_cons_work. (* Goal: forces_t k (nf2form d) *) (* Goal: forces_ngamma work ds ni ai a k *) apply forces_bcd. (* Goal: forces_t k (nf2form b) *) (* Goal: forces_ngamma work ds ni ai' a k *) apply k_forces_ngamma. (* Goal: in_ngamma (@cons normal_form c work) ds ni ai a c *) (* Goal: forces_ngamma work ds ni ai a k *) apply in_ngamma_cons_work_head. (* Goal: forces_t k (nf2form b) *) (* Goal: forces_ngamma work ds ni ai' a k *) apply k_forces_ngamma. (* Goal: in_ngamma (@cons normal_form b (@cons normal_form c work)) ds ni ai a c *) (* Goal: forces_ngamma work ds ni ai a k *) apply in_ngamma_cons_work_tail. (* Goal: in_ngamma (@cons normal_form c work) ds ni ai a c *) (* Goal: forces_ngamma work ds ni ai a k *) apply in_ngamma_cons_work_head. (* Goal: forces_ngamma work ds ni ai a k *) apply forces_ngamma_cons_work_tail with c. (* Goal: forces_ngamma (@cons normal_form c work) ds ni ai a k *) apply forces_ngamma_cons_work_tail with b; assumption. Qed. Lemma forces_ngamma_shift_work_ai_weak : forall (i : Int) (bs work : nf_list) (ds : disjs) (ni : nested_imps) (ai ai' : atomic_imps) (a : atoms) (k : kripke_tree), Is_Monotone_kripke_tree k -> LOOKUP nf_list i ai bs -> EQUIV_DEL nf_list i ai ai' -> forces_ngamma (bs ++ work) ds ni ai' a k -> forces_ngamma work ds ni ai a k. (* Goal: forall (i : Int) (bs work : nf_list) (ds : disjs) (ni : nested_imps) (ai ai' : atomic_imps) (a : atoms) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : LOOKUP nf_list i ai bs) (_ : EQUIV_DEL nf_list i ai ai') (_ : forces_ngamma (@app normal_form bs work) ds ni ai' a k), forces_ngamma work ds ni ai a k *) intros i bs work ds ni ai ai' a k k_is_mon lookup equiv_del k_forces_ngamma. (* Goal: forces_ngamma work ds ni ai a k *) apply forces_ngamma_del_ai_rev with i bs ai'; try assumption. (* Goal: forall (n : nat) (b : normal_form) (_ : my_nth normal_form n bs b), forces_t k (nf2form b) *) (* Goal: forces_ngamma work ds ni ai' a' k *) intros n b nth. (* Goal: forces_t k (nf2form (AImp i b)) *) (* Goal: forces_ngamma work ds ni ai' a k *) simpl in |- *; apply forces_b__forces_a_imp_b_t. (* Goal: Is_Monotone_kripke_tree k *) (* Goal: forces_t k (nf2form b) *) (* Goal: forces_ngamma work ds ni ai' a k *) assumption. (* Goal: forces_t k (nf2form b) *) (* Goal: forces_ngamma work ds ni ai' a k *) apply k_forces_ngamma. (* Goal: in_ngamma (@app normal_form bs work) ds ni ai' a b *) (* Goal: forces_ngamma work ds ni ai' a k *) apply In_Work with n. (* Goal: Is_Monotone_kripke_tree k *) (* Goal: forces_t k (nf2form b) *) (* Goal: forces_ngamma work ds ni ai' a k *) apply nth_app0; assumption. (* Goal: Is_Monotone_kripke_tree k *) (* Goal: forces_t k (nf2form b) *) (* Goal: forces_ngamma work ds ni ai' a k *) apply forces_ngamma_app_work_tail with bs; assumption. Qed. Lemma forces_ngamma_shift_work_ai_strength : forall (i : Int) (bs work : nf_list) (ds : disjs) (ni : nested_imps) (ai ai' : atomic_imps) (a a' : atoms) (k : kripke_tree), Is_Monotone_kripke_tree k -> EQUIV_INS unit i (fun _ : unit => tt) tt a a' -> LOOKUP nf_list i ai bs -> EQUIV_DEL nf_list i ai ai' -> forces_ngamma work ds ni ai a' k -> forces_ngamma (bs ++ work) ds ni ai' a' k. intros i bs work ds ni ai ai' a a' k k_is_mon equiv_ins lookup equiv_del forces. (* Goal: forces_ngamma (@app normal_form bs work) ds ni ai' a' k *) apply forces_ngamma_app_work. (* Goal: forall (n : nat) (b : normal_form) (_ : my_nth normal_form n bs b), forces_t k (nf2form b) *) (* Goal: forces_ngamma work ds ni ai' a' k *) intros n b nth. (* Goal: Is_Monotone_kripke_tree k *) (* Goal: forces_t k (nf2form b) *) (* Goal: forces_ngamma work ds ni ai' a k *) apply forces_a_a_imp_b__forces_b_t with (Atom i); try assumption. (* Goal: forces_t k (Atom i) *) (* Goal: forces_t k (Imp (Atom i) (nf2form b)) *) (* Goal: forces_ngamma work ds ni ai' a' k *) apply forces with (c := NAtom i). (* Goal: Is_Monotone_kripke_tree k *) (* Goal: forces_t k (nf2form b) *) (* Goal: forces_ngamma work ds ni ai' a k *) apply in_ngamma_ins_a_head with a; assumption. (* Goal: forces_t k (Imp (Atom i) (nf2form b)) *) (* Goal: forces_ngamma work ds ni ai' a' k *) apply forces with (c := AImp i b). (* Goal: Is_Monotone_kripke_tree k *) (* Goal: forces_t k (nf2form b) *) (* Goal: forces_ngamma work ds ni ai' a k *) apply In_Atomic_Imps with (i := i) (b := b) (n := n) (bs := bs); assumption. (* Goal: Is_Monotone_kripke_tree k *) (* Goal: forces_t k (nf2form b) *) (* Goal: forces_ngamma work ds ni ai' a k *) apply forces_ngamma_del_ai with i ai; assumption. Qed.
(* File: Sound.v (last edited on 27/10/2000) (c) Klaus Weich *) Require Export NSound. Require Export In_Gamma. Definition sound (Gamma : flist) (work : nf_list) (context : flist) := forall a : form, in_gamma Gamma work a -> Derivable context a. Lemma sound_cons_gamma : forall (gamma : flist) (work : nf_list) (context : flist) (a : form), Derivable context a -> sound gamma work context -> sound (a :: gamma) work context. (* Goal: forall (gamma : flist) (work : nf_list) (context : flist) (a : form) (_ : Derivable context a) (_ : sound gamma work context), sound (@cons form a gamma) work context *) intros gamma work context a der_a sound0. (* Goal: sound gamma work (@cons form a context) *) unfold sound in |- *. (* Goal: forall (a0 : form) (_ : in_gamma gamma work a0), Derivable (@cons form a context) a0 *) intros c in_gamma0. (* Goal: Derivable context c *) elim (in_gamma_cons_gamma_rev a gamma work c in_gamma0); clear in_gamma0. (* Goal: forall _ : in_gamma gamma work c, Derivable context c *) (* Goal: forall _ : @eq form c a, Derivable context c *) intros in_gamma0. (* Goal: Derivable context c *) (* Goal: forall _ : @eq form c a, Derivable context c *) apply sound0; assumption. (* Goal: Derivable context c *) (* Goal: sound gamma work context *) (* Goal: Derivable context a *) intros eq_c; rewrite eq_c; assumption. Qed. Lemma sound_cons_gamma_tail : forall (gamma : flist) (work : nf_list) (context : flist) (a : form), sound (a :: gamma) work context -> sound gamma work context. (* Goal: forall (gamma : flist) (work : nf_list) (context : flist) (a : form) (_ : sound gamma work context), sound (@cons form a gamma) work (@cons form a context) *) intros gamma work context a sound0. (* Goal: sound gamma work (@cons form a context) *) unfold sound in |- *. (* Goal: forall (a0 : form) (_ : in_gamma gamma work a0), Derivable (@cons form a context) a0 *) intros c in_gamma0. (* Goal: Derivable context c *) apply sound0. (* Goal: in_gamma (@cons form a gamma) work c *) apply in_gamma_cons_gamma_tail; assumption. Qed. Lemma sound_cons_gamma_head : forall (gamma : flist) (work : nf_list) (context : flist) (a : form), sound (a :: gamma) work context -> Derivable context a. (* Goal: forall (gamma : flist) (work : nf_list) (context : flist) (a : form) (_ : sound gamma work context), sound (@cons form a gamma) work (@cons form a context) *) intros gamma work context a sound0. (* Goal: Derivable context c *) apply sound0. (* Goal: in_gamma (@cons form a gamma) work a *) apply in_gamma_cons_gamma_head; assumption. Qed. (**********************************************************************) Lemma sound_shift_gamma_work : forall (a : normal_form) (gamma : flist) (work : nf_list) (context : flist), sound (nf2form a :: gamma) work context -> sound gamma (a :: work) context. (* Goal: forall (a : normal_form) (gamma : flist) (work : nf_list) (context : flist) (_ : sound gamma (@cons normal_form a work) context), sound (@cons form (nf2form a) gamma) work context *) intros a gamma work context sound0. (* Goal: sound gamma work (@cons form a context) *) unfold sound in |- *. (* Goal: forall (a0 : form) (_ : in_gamma (@cons form (nf2form a) gamma) work a0), Derivable context a0 *) intros c in_gamma. (* Goal: Derivable context c *) apply sound0. (* Goal: In_Gamma.in_gamma (@cons form (nf2form a) gamma) work c *) apply in_gamma_shift_work_gamma; assumption. Qed. Lemma sound_shift_work_gamma : forall (a : normal_form) (gamma : flist) (work : nf_list) (context : flist), sound gamma (a :: work) context -> sound (nf2form a :: gamma) work context. (* Goal: forall (a : normal_form) (gamma : flist) (work : nf_list) (context : flist) (_ : sound gamma (@cons normal_form a work) context), sound (@cons form (nf2form a) gamma) work context *) intros a gamma work context sound0. (* Goal: sound gamma work (@cons form a context) *) unfold sound in |- *. (* Goal: forall (a0 : form) (_ : in_gamma (@cons form (nf2form a) gamma) work a0), Derivable context a0 *) intros c in_gamma. (* Goal: Derivable context c *) apply sound0. (* Goal: In_Gamma.in_gamma gamma (@cons normal_form a work) c *) apply in_gamma_shift_gamma_work; assumption. Qed. (**********************************************************************) Lemma sound_cons_gamma_cons_context : forall (gamma : flist) (work : nf_list) (context : flist) (a : form), sound gamma work context -> sound (a :: gamma) work (a :: context). (* Goal: forall (gamma : flist) (work : nf_list) (context : flist) (a : form) (_ : sound gamma work context), sound (@cons form a gamma) work (@cons form a context) *) intros gamma work context a sound0. (* Goal: sound (@cons form c gamma) work context *) (* Goal: Derivable context a *) apply sound_cons_gamma. (* Goal: Derivable (@cons form a context) a *) (* Goal: sound gamma work (@cons form a context) *) apply Derivable_Intro with (Var 0). (* Goal: derives (@cons form a context) (Var O) a *) (* Goal: sound gamma work (@cons form a context) *) apply ByAssumption. (* Goal: my_nth form O (@cons form a context) a *) (* Goal: sound gamma work (@cons form a context) *) apply My_NthO. (* Goal: sound gamma work (@cons form a context) *) unfold sound in |- *. (* Goal: forall (a0 : form) (_ : in_gamma gamma work a0), Derivable (@cons form a context) a0 *) intros c in_gamma0. (* Goal: Derivable (@cons form a context) c *) elim (sound0 c in_gamma0). (* Goal: forall (t : proof_term) (_ : derives context t c), Derivable (@cons form a context) c *) intros t der_t. (* Goal: Derivable (@cons form a context) c *) apply Derivable_Intro with (Shift t). (* Goal: derives (@cons form a context) (Shift t) c *) apply ShiftIntro; assumption. Qed. (************************************************************) Lemma sound_cons_gamma_weak : forall (gamma : flist) (work : nf_list) (context : flist) (a b : form), (Derivable context a -> Derivable context b) -> sound (a :: gamma) work context -> sound (b :: gamma) work context. (* Goal: forall (gamma : flist) (work : nf_list) (context : flist) (a b : form) (_ : forall _ : Derivable context a, Derivable context b) (_ : sound (@cons form a gamma) work context), sound (@cons form b gamma) work context *) intros gamma work context a b der_ab sound0. (* Goal: sound (@cons form c gamma) work context *) (* Goal: Derivable context a *) apply sound_cons_gamma. (* Goal: Derivable context b *) (* Goal: sound gamma work context *) apply der_ab. (* Goal: Derivable context a *) apply sound_cons_gamma_head with gamma work; assumption. (* Goal: sound gamma work context *) (* Goal: Derivable context a *) apply sound_cons_gamma_tail with a; assumption. Qed. Lemma sound_cons_gamma_weak2 : forall (gamma : flist) (work : nf_list) (context : flist) (a b c : form), (Derivable context a -> Derivable2 context b c) -> sound (a :: gamma) work context -> sound (b :: c :: gamma) work context. (* Goal: forall (gamma : flist) (work : nf_list) (context : flist) (a b c : form) (_ : forall _ : Derivable context a, Derivable2 context b c) (_ : sound (@cons form a gamma) work context), sound (@cons form b (@cons form c gamma)) work context *) intros gamma work context a b c der_abc sound0. (* Goal: sound (@cons form b (@cons form c gamma)) work context *) elim der_abc; clear der_abc. (* Goal: forall (_ : Derivable context b) (_ : Derivable context c), sound (@cons form b (@cons form c gamma)) work context *) (* Goal: Derivable context a *) intros der_b der_c. (* Goal: sound (@cons form c gamma) work context *) (* Goal: Derivable context a *) apply sound_cons_gamma. (* Goal: Derivable context c *) (* Goal: sound gamma work context *) (* Goal: Derivable context a *) assumption. (* Goal: sound (@cons form c gamma) work context *) (* Goal: Derivable context a *) apply sound_cons_gamma. (* Goal: Derivable context c *) (* Goal: sound gamma work context *) (* Goal: Derivable context a *) assumption. (* Goal: sound gamma work context *) (* Goal: Derivable context a *) apply sound_cons_gamma_tail with a; assumption. (* Goal: Derivable context a *) apply sound_cons_gamma_head with gamma work; assumption. Qed.
(* File: AvlTrees.v (last edited on 25/10/2000) (c) Klaus Weich *) Require Import ML_Int. Require Import My_Arith. Require Import List. Global Set Asymmetric Patterns. Section avl_trees. Variable B : Set. (*********************************************************) (* Definition bal and avl_tree *) Inductive bal : Set := | Left_Balanced : bal | Balanced : bal | Right_Balanced : bal. Inductive avl_tree : Set := | Avl_Nil : avl_tree | Avl_Node : Int -> B -> avl_tree -> avl_tree -> bal -> avl_tree. (*********************************************************) (* Definition is_below *) Inductive is_below : avl_tree -> Int -> Prop := | Below_Nil : forall k0 : Int, is_below Avl_Nil k0 | Below_Node : forall (k : Int) (d : B) (l r : avl_tree) (b : bal) (k0 : Int), Less k k0 -> is_below l k0 -> is_below r k0 -> is_below (Avl_Node k d l r b) k0. Lemma inv_below_key : forall (k : Int) (d : B) (l r : avl_tree) (b : bal) (k0 : Int), is_below (Avl_Node k d l r b) k0 -> Less k k0. (* Goal: forall (key : Int) (t0 t : avl_tree) (k : Int) (d : B) (_ : equiv_del key t0 t) (_ : not (Equal k key)) (_ : lookup k t d), lookup k t0 d *) intros. (* Goal: is_above_avl r k *) inversion H; assumption. Qed. Lemma inv_below_left : forall (k : Int) (d : B) (l r : avl_tree) (b : bal) (k0 : Int), is_below (Avl_Node k d l r b) k0 -> is_below l k0. (* Goal: forall (key : Int) (t0 t : avl_tree) (k : Int) (d : B) (_ : equiv_del key t0 t) (_ : not (Equal k key)) (_ : lookup k t d), lookup k t0 d *) intros. (* Goal: is_above_avl r k *) inversion H; assumption. Qed. Lemma inv_below_right : forall (k : Int) (d : B) (l r : avl_tree) (b : bal) (k0 : Int), is_below (Avl_Node k d l r b) k0 -> is_below r k0. (* Goal: forall (key : Int) (t0 t : avl_tree) (k : Int) (d : B) (_ : equiv_del key t0 t) (_ : not (Equal k key)) (_ : lookup k t d), lookup k t0 d *) intros. (* Goal: is_above_avl r k *) inversion H; assumption. Qed. Lemma below_trans : forall (t : avl_tree) (k0 k1 : Int), is_below t k0 -> Less k0 k1 -> is_below t k1. (* Goal: forall (t : avl_tree) (_ : @eq nat (height_avl t) O), @eq avl_tree t Avl_Nil *) intros t; elim t; clear t. (* Goal: forall (key : Int) (t0 t : avl_tree) (k : Int) (d : B) (_ : equiv_del key t0 t) (_ : not (Equal k key)) (_ : lookup k t d), lookup k t0 d *) intros. (* Goal: is_below Avl_Nil k0 *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall (k0 : Int) (_ : forall (k : Int) (d : B) (_ : lookup k a d), Less k k0), is_below a k0) (a0 : avl_tree) (_ : forall (k0 : Int) (_ : forall (k : Int) (d : B) (_ : lookup k a0 d), Less k k0), is_below a0 k0) (b0 : bal) (k0 : Int) (_ : forall (k : Int) (d : B) (_ : lookup k (Avl_Node i b a a0 b0) d), Less k k0), is_below (Avl_Node i b a a0 b0) k0 *) apply Below_Nil. (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall (k0 k1 : Int) (_ : is_above_avl a k0) (_ : Less k1 k0), is_above_avl a k1) (a0 : avl_tree) (_ : forall (k0 k1 : Int) (_ : is_above_avl a0 k0) (_ : Less k1 k0), is_above_avl a0 k1) (b0 : bal) (k0 k1 : Int) (_ : is_above_avl (Avl_Node i b a a0 b0) k0) (_ : Less k1 k0), is_above_avl (Avl_Node i b a a0 b0) k1 *) intros k d l ih_l r ih_r b k0 k1 H0 H1. (* Goal: is_below (Avl_Node k0 d0 l0 r b0) k *) (* Goal: Less k0 k *) (* Goal: equiv t (Avl_Node k0 d0 l0 r b0) *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0)) (@app (prod Int B) (lin_avl t) (@cons (prod Int B) (@pair Int B k d) (@nil (prod Int B)))) *) (* Goal: equiv_del k (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl (Avl_Node kr0 dr0 lr0 rr0 br0) *) apply Below_Node. (* Goal: Less k k1 *) (* Goal: is_below_avl r k1 *) apply (less_trans k k0 k1). (* Goal: Less k k0 *) (* Goal: Less k0 k1 *) (* Goal: is_below l k1 *) (* Goal: is_below r k1 *) apply (inv_below_key k d l r b k0 H0). (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: is_below l k1 *) (* Goal: is_below r k1 *) apply (ih_l k0 k1 (inv_below_left k d l r b k0 H0) H1). (* Goal: is_below r k1 *) apply (ih_r k0 k1 (inv_below_right k d l r b k0 H0) H1). Qed. (*********************************************************) (* Definition is_above *) Inductive is_above : avl_tree -> Int -> Prop := | Above_Nil : forall k0 : Int, is_above Avl_Nil k0 | Above_Node : forall (k : Int) (d : B) (l r : avl_tree) (b : bal) (k0 : Int), Less k0 k -> is_above l k0 -> is_above r k0 -> is_above (Avl_Node k d l r b) k0. Lemma inv_above_key : forall (k : Int) (d : B) (l r : avl_tree) (b : bal) (k0 : Int), is_above (Avl_Node k d l r b) k0 -> Less k0 k. (* Goal: forall (key : Int) (t0 t : avl_tree) (k : Int) (d : B) (_ : equiv_del key t0 t) (_ : not (Equal k key)) (_ : lookup k t d), lookup k t0 d *) intros. (* Goal: is_above_avl r k *) inversion H; assumption. Qed. Lemma inv_above_left : forall (k : Int) (d : B) (l r : avl_tree) (b : bal) (k0 : Int), is_above (Avl_Node k d l r b) k0 -> is_above l k0. (* Goal: forall (key : Int) (t0 t : avl_tree) (k : Int) (d : B) (_ : equiv_del key t0 t) (_ : not (Equal k key)) (_ : lookup k t d), lookup k t0 d *) intros. (* Goal: is_above_avl r k *) inversion H; assumption. Qed. Lemma inv_above_right : forall (k : Int) (d : B) (l r : avl_tree) (b : bal) (k0 : Int), is_above (Avl_Node k d l r b) k0 -> is_above r k0. (* Goal: forall (key : Int) (t0 t : avl_tree) (k : Int) (d : B) (_ : equiv_del key t0 t) (_ : not (Equal k key)) (_ : lookup k t d), lookup k t0 d *) intros. (* Goal: is_above_avl r k *) inversion H; assumption. Qed. Lemma above_trans : forall (t : avl_tree) (k0 k1 : Int), is_above t k0 -> Less k1 k0 -> is_above t k1. (* Goal: forall (t : avl_tree) (_ : @eq nat (height_avl t) O), @eq avl_tree t Avl_Nil *) intros t; elim t; clear t. (* Goal: forall (key : Int) (t0 t : avl_tree) (k : Int) (d : B) (_ : equiv_del key t0 t) (_ : not (Equal k key)) (_ : lookup k t d), lookup k t0 d *) intros. (* Goal: is_above Avl_Nil k0 *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall (k0 : Int) (_ : forall (k : Int) (d : B) (_ : lookup k a d), Less k0 k), is_above a k0) (a0 : avl_tree) (_ : forall (k0 : Int) (_ : forall (k : Int) (d : B) (_ : lookup k a0 d), Less k0 k), is_above a0 k0) (b0 : bal) (k0 : Int) (_ : forall (k : Int) (d : B) (_ : lookup k (Avl_Node i b a a0 b0) d), Less k0 k), is_above (Avl_Node i b a a0 b0) k0 *) apply Above_Nil. (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall (k0 k1 : Int) (_ : is_above_avl a k0) (_ : Less k1 k0), is_above_avl a k1) (a0 : avl_tree) (_ : forall (k0 k1 : Int) (_ : is_above_avl a0 k0) (_ : Less k1 k0), is_above_avl a0 k1) (b0 : bal) (k0 k1 : Int) (_ : is_above_avl (Avl_Node i b a a0 b0) k0) (_ : Less k1 k0), is_above_avl (Avl_Node i b a a0 b0) k1 *) intros k d l ih_l r ih_r b k0 k1 H0 H1. (* Goal: is_above (Avl_Node k d l r b) k0 *) apply Above_Node. (* Goal: Less k1 k *) (* Goal: is_above_avl l k1 *) apply (less_trans k1 k0 k H1). (* Goal: Less k0 k *) (* Goal: is_above l k1 *) (* Goal: is_above r k1 *) apply (inv_above_key k d l r b k0 H0). (* Goal: is_above l k1 *) (* Goal: is_above r k1 *) apply (ih_l k0 k1 (inv_above_left k d l r b k0 H0) H1). (* Goal: is_above r k1 *) apply (ih_r k0 k1 (inv_above_right k d l r b k0 H0) H1). Qed. (*********************************************************) (* Definition height *) Fixpoint height (t : avl_tree) : nat := match t with | Avl_Nil => 0 | Avl_Node _ _ l r _ => S (max (height l) (height r)) end. Lemma height_O_nil : forall t : avl_tree, height t = 0 -> t = Avl_Nil. (* Goal: forall (t : avl_tree) (_ : @eq nat (height_avl t) O), @eq avl_tree t Avl_Nil *) intros t; elim t; clear t. (* Goal: forall _ : @eq nat (height_avl Avl_Nil) O, @eq avl_tree Avl_Nil Avl_Nil *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : @eq nat (height_avl a) O, @eq avl_tree a Avl_Nil) (a0 : avl_tree) (_ : forall _ : @eq nat (height_avl a0) O, @eq avl_tree a0 Avl_Nil) (b0 : bal) (_ : @eq nat (height_avl (Avl_Node i b a a0 b0)) O), @eq avl_tree (Avl_Node i b a a0 b0) Avl_Nil *) intros; trivial. (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : @eq nat (height_avl a) O, @eq avl_tree a Avl_Nil) (a0 : avl_tree) (_ : forall _ : @eq nat (height_avl a0) O, @eq avl_tree a0 Avl_Nil) (b0 : bal) (_ : @eq nat (height_avl (Avl_Node i b a a0 b0)) O), @eq avl_tree (Avl_Node i b a a0 b0) Avl_Nil *) intros k d l ih_l r ih_r b. simpl in |- *; intro u0; discriminate u0. Qed. (*********************************************************) (* Definition is_balanced *) Inductive is_balanced (l r : avl_tree) : bal -> Prop := | Is_Left_Balanced : height l = S (height r) -> is_balanced l r Left_Balanced | Is_Fully_Balanced : height l = height r -> is_balanced l r Balanced | Is_Right_Balanced : S (height l) = height r -> is_balanced l r Right_Balanced. Lemma inv_left_balanced : forall l r : avl_tree, is_balanced l r Left_Balanced -> height l = S (height r). (* Goal: forall (key : Int) (t0 t : avl_tree) (k : Int) (d : B) (_ : equiv_del key t0 t) (_ : not (Equal k key)) (_ : lookup k t d), lookup k t0 d *) intros. (* Goal: is_above_avl r k *) inversion H; assumption. Qed. Lemma inv_fully_balanced : forall l r : avl_tree, is_balanced l r Balanced -> height l = height r. (* Goal: forall (key : Int) (t0 t : avl_tree) (k : Int) (d : B) (_ : equiv_del key t0 t) (_ : not (Equal k key)) (_ : lookup k t d), lookup k t0 d *) intros. (* Goal: is_above_avl r k *) inversion H; assumption. Qed. Lemma inv_right_balanced : forall l r : avl_tree, is_balanced l r Right_Balanced -> S (height l) = height r. (* Goal: forall (key : Int) (t0 t : avl_tree) (k : Int) (d : B) (_ : equiv_del key t0 t) (_ : not (Equal k key)) (_ : lookup k t d), lookup k t0 d *) intros. (* Goal: is_above_avl r k *) inversion H; assumption. Qed. (************************************************************************) (* lookup *) Inductive lookup (key : Int) : avl_tree -> B -> Prop := | Lookup_Equal : forall (d : B) (l r : avl_tree) (b : bal), lookup key (Avl_Node key d l r b) d | Lookup_Left : forall (k : Int) (d : B) (l r : avl_tree) (b : bal) (data : B), lookup key l data -> lookup key (Avl_Node k d l r b) data | Lookup_Right : forall (k : Int) (d : B) (l r : avl_tree) (b : bal) (data : B), lookup key r data -> lookup key (Avl_Node k d l r b) data. Lemma inv_lookup_nil : forall (key : Int) (data : B), lookup key Avl_Nil data -> False. (* Goal: forall (key : Int) (t0 t : avl_tree) (k : Int) (d : B) (_ : equiv_del key t0 t) (_ : not (Equal k key)) (_ : lookup k t d), lookup k t0 d *) intros. (* Goal: lookup k t0 d *) inversion H. Qed. Lemma inv_lookup : forall (key k : Int) (d : B) (l r : avl_tree) (b : bal) (data : B), lookup key (Avl_Node k d l r b) data -> k = key /\ d = data \/ lookup key l data \/ lookup key r data. (* Goal: forall (key : Int) (t0 t : avl_tree) (k : Int) (d : B) (_ : equiv_del key t0 t) (_ : not (Equal k key)) (_ : lookup k t d), lookup k t0 d *) intros. (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 r data), lookup k0 (Avl_Node k d Avl_Nil r b) data *) inversion_clear H. (* Goal: or (and (@eq Int k k) (@eq B data data)) (or (lookup k l data) (lookup k r data)) *) (* Goal: or (and (@eq Int k key) (@eq B d data)) (or (lookup key l data) (lookup key r data)) *) (* Goal: or (and (@eq Int k key) (@eq B d data)) (or (lookup key l data) (lookup key r data)) *) left; split; trivial. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) right; left; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) right; right; assumption. Qed. (*******************************************************) (* Lemmata about Lookup and below/above *) Lemma lookup_below_less : forall (key : Int) (t : avl_tree) (data : B) (k0 : Int), lookup key t data -> is_below t k0 -> Less key k0. (* Goal: forall (key : Int) (t : avl_tree) (data : B) (k0 : Int) (_ : lookup key t data) (_ : is_above t k0), Less k0 key *) intros key t; elim t; clear t. (* Goal: forall (data : B) (k0 : Int) (_ : lookup key Avl_Nil data) (_ : is_below Avl_Nil k0), Less key k0 *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall (data : B) (k0 : Int) (_ : lookup key a data) (_ : is_below a k0), Less key k0) (a0 : avl_tree) (_ : forall (data : B) (k0 : Int) (_ : lookup key a0 data) (_ : is_below a0 k0), Less key k0) (b0 : bal) (data : B) (k0 : Int) (_ : lookup key (Avl_Node i b a a0 b0) data) (_ : is_below (Avl_Node i b a a0 b0) k0), Less key k0 *) intros data k0 lookup_t below_t. (* Goal: lin_del_spec key d Avl_Nil Avl_Nil *) (* Goal: equiv_del key Avl_Nil Avl_Nil *) (* Goal: sumbool (@eq nat (height_avl Avl_Nil) (height_avl Avl_Nil)) (@eq nat (height_avl Avl_Nil) (S (height_avl Avl_Nil))) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, delete_spec key a) (a0 : avl_tree) (_ : forall _ : is_avl a0, delete_spec key a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), delete_spec key (Avl_Node i b a a0 b0) *) elimtype False. (* Goal: False *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall (data : B) (k0 : Int) (_ : lookup key a data) (_ : is_above a k0), Less k0 key) (a0 : avl_tree) (_ : forall (data : B) (k0 : Int) (_ : lookup key a0 data) (_ : is_above a0 k0), Less k0 key) (b0 : bal) (data : B) (k0 : Int) (_ : lookup key (Avl_Node i b a a0 b0) data) (_ : is_above (Avl_Node i b a a0 b0) k0), Less k0 key *) apply (inv_lookup_nil key data lookup_t). (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall (data : B) (k0 : Int) (_ : lookup key a data) (_ : is_below a k0), Less key k0) (a0 : avl_tree) (_ : forall (data : B) (k0 : Int) (_ : lookup key a0 data) (_ : is_below a0 k0), Less key k0) (b0 : bal) (data : B) (k0 : Int) (_ : lookup key (Avl_Node i b a a0 b0) data) (_ : is_below (Avl_Node i b a a0 b0) k0), Less key k0 *) intros k d l ih_l r ih_r b data k0 lookup_t below_t. (* Goal: lookup key r data *) elim (inv_lookup key k d l r b data lookup_t); clear lookup_t; intro u0. (* Goal: False *) (* Goal: False *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), lookup k (Avl_Node k0 d0 l0 r b) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) elim u0; clear u0; intros u0 u1. (* Goal: Equal k0 key *) (* Goal: lookup k0 (Avl_Node k d l0 r0 b) data *) rewrite <- u0. (* Goal: Less k k0 *) (* Goal: Less key k0 *) apply (inv_below_key k d l r b k0 below_t). (* Goal: False *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), lookup k (Avl_Node k0 d0 l0 r b) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) elim u0; clear u0; intro u0. (* Goal: Less k0 key *) (* Goal: Less k0 key *) apply (ih_l data). (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: is_below l k0 *) (* Goal: Less key k0 *) apply (inv_below_left k d l r b k0 below_t). (* Goal: Less k0 key *) apply (ih_r data). (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: is_below r k0 *) apply (inv_below_right k d l r b k0 below_t). Qed. Lemma lookup_above_greater : forall (key : Int) (t : avl_tree) (data : B) (k0 : Int), lookup key t data -> is_above t k0 -> Less k0 key. (* Goal: forall (key : Int) (t : avl_tree) (data : B) (k0 : Int) (_ : lookup key t data) (_ : is_above t k0), Less k0 key *) intros key t; elim t; clear t. (* Goal: forall (data : B) (k0 : Int) (_ : lookup key Avl_Nil data) (_ : is_above Avl_Nil k0), Less k0 key *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall (data : B) (k0 : Int) (_ : lookup key a data) (_ : is_above a k0), Less k0 key) (a0 : avl_tree) (_ : forall (data : B) (k0 : Int) (_ : lookup key a0 data) (_ : is_above a0 k0), Less k0 key) (b0 : bal) (data : B) (k0 : Int) (_ : lookup key (Avl_Node i b a a0 b0) data) (_ : is_above (Avl_Node i b a a0 b0) k0), Less k0 key *) intros data k0 lookup_t above_t. (* Goal: lin_del_spec key d Avl_Nil Avl_Nil *) (* Goal: equiv_del key Avl_Nil Avl_Nil *) (* Goal: sumbool (@eq nat (height_avl Avl_Nil) (height_avl Avl_Nil)) (@eq nat (height_avl Avl_Nil) (S (height_avl Avl_Nil))) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, delete_spec key a) (a0 : avl_tree) (_ : forall _ : is_avl a0, delete_spec key a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), delete_spec key (Avl_Node i b a a0 b0) *) elimtype False. (* Goal: False *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall (data : B) (k0 : Int) (_ : lookup key a data) (_ : is_above a k0), Less k0 key) (a0 : avl_tree) (_ : forall (data : B) (k0 : Int) (_ : lookup key a0 data) (_ : is_above a0 k0), Less k0 key) (b0 : bal) (data : B) (k0 : Int) (_ : lookup key (Avl_Node i b a a0 b0) data) (_ : is_above (Avl_Node i b a a0 b0) k0), Less k0 key *) apply (inv_lookup_nil key data lookup_t). (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall (data : B) (k0 : Int) (_ : lookup key a data) (_ : is_above a k0), Less k0 key) (a0 : avl_tree) (_ : forall (data : B) (k0 : Int) (_ : lookup key a0 data) (_ : is_above a0 k0), Less k0 key) (b0 : bal) (data : B) (k0 : Int) (_ : lookup key (Avl_Node i b a a0 b0) data) (_ : is_above (Avl_Node i b a a0 b0) k0), Less k0 key *) intros k d l ih_l r ih_r b data k0 lookup_t above_t. (* Goal: lookup key r data *) elim (inv_lookup key k d l r b data lookup_t); clear lookup_t; intro u0. (* Goal: False *) (* Goal: False *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), lookup k (Avl_Node k0 d0 l0 r b) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) elim u0; clear u0; intros u0 u1. (* Goal: Equal k0 key *) (* Goal: lookup k0 (Avl_Node k d l0 r0 b) data *) rewrite <- u0. (* Goal: Less k0 k *) (* Goal: Less k0 key *) apply (inv_above_key k d l r b k0 above_t). (* Goal: False *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), lookup k (Avl_Node k0 d0 l0 r b) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) elim u0; clear u0; intro u0. (* Goal: Less k0 key *) (* Goal: Less k0 key *) apply (ih_l data). (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: is_above l k0 *) (* Goal: Less k0 key *) apply (inv_above_left k d l r b k0 above_t). (* Goal: Less k0 key *) apply (ih_r data). (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: is_above r k0 *) apply (inv_above_right k d l r b k0 above_t). Qed. Lemma lookup_less_below : forall (t : avl_tree) (k0 : Int), (forall (k : Int) (d : B), lookup k t d -> Less k k0) -> is_below t k0. (* Goal: forall (t : avl_tree) (_ : @eq nat (height_avl t) O), @eq avl_tree t Avl_Nil *) intros t; elim t; clear t. (* Goal: forall (key : Int) (t0 t : avl_tree) (k : Int) (d : B) (_ : equiv_del key t0 t) (_ : not (Equal k key)) (_ : lookup k t d), lookup k t0 d *) intros. (* Goal: is_below Avl_Nil k0 *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall (k0 : Int) (_ : forall (k : Int) (d : B) (_ : lookup k a d), Less k k0), is_below a k0) (a0 : avl_tree) (_ : forall (k0 : Int) (_ : forall (k : Int) (d : B) (_ : lookup k a0 d), Less k k0), is_below a0 k0) (b0 : bal) (k0 : Int) (_ : forall (k : Int) (d : B) (_ : lookup k (Avl_Node i b a a0 b0) d), Less k k0), is_below (Avl_Node i b a a0 b0) k0 *) apply Below_Nil. (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall (k0 : Int) (_ : forall (k : Int) (d : B) (_ : lookup k a d), Less k0 k), is_above a k0) (a0 : avl_tree) (_ : forall (k0 : Int) (_ : forall (k : Int) (d : B) (_ : lookup k a0 d), Less k0 k), is_above a0 k0) (b0 : bal) (k0 : Int) (_ : forall (k : Int) (d : B) (_ : lookup k (Avl_Node i b a a0 b0) d), Less k0 k), is_above (Avl_Node i b a a0 b0) k0 *) intros k d l ih_l r ih_r b k0 H. (* Goal: is_below (Avl_Node k0 d0 l0 r b0) k *) (* Goal: Less k0 k *) (* Goal: equiv t (Avl_Node k0 d0 l0 r b0) *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0)) (@app (prod Int B) (lin_avl t) (@cons (prod Int B) (@pair Int B k d) (@nil (prod Int B)))) *) (* Goal: equiv_del k (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl (Avl_Node kr0 dr0 lr0 rr0 br0) *) apply Below_Node. (* Goal: Less k0 k *) (* Goal: is_above l k0 *) (* Goal: is_above r k0 *) apply (H k d). (* Goal: lookup k0 (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d0 *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup_Equal. (* Goal: is_below l k0 *) (* Goal: is_below r k0 *) apply ih_l. (* Goal: forall (k : Int) (d : B) (_ : lookup k l d), Less k0 k *) (* Goal: is_above r k0 *) intros k1 d0 lookup_l. (* Goal: Less k0 k1 *) apply (H k1 d0). (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Left; assumption. (* Goal: is_above r k0 *) apply ih_r. (* Goal: forall (k : Int) (d : B) (_ : lookup k r d), Less k0 k *) intros k1 d0 lookup_r. (* Goal: Less k0 k1 *) apply (H k1 d0). (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Right; assumption. Qed. Lemma lookup_greater_above : forall (t : avl_tree) (k0 : Int), (forall (k : Int) (d : B), lookup k t d -> Less k0 k) -> is_above t k0. (* Goal: forall (t : avl_tree) (_ : @eq nat (height_avl t) O), @eq avl_tree t Avl_Nil *) intros t; elim t; clear t. (* Goal: forall (key : Int) (t0 t : avl_tree) (k : Int) (d : B) (_ : equiv_del key t0 t) (_ : not (Equal k key)) (_ : lookup k t d), lookup k t0 d *) intros. (* Goal: is_above Avl_Nil k0 *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall (k0 : Int) (_ : forall (k : Int) (d : B) (_ : lookup k a d), Less k0 k), is_above a k0) (a0 : avl_tree) (_ : forall (k0 : Int) (_ : forall (k : Int) (d : B) (_ : lookup k a0 d), Less k0 k), is_above a0 k0) (b0 : bal) (k0 : Int) (_ : forall (k : Int) (d : B) (_ : lookup k (Avl_Node i b a a0 b0) d), Less k0 k), is_above (Avl_Node i b a a0 b0) k0 *) apply Above_Nil. (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall (k0 : Int) (_ : forall (k : Int) (d : B) (_ : lookup k a d), Less k0 k), is_above a k0) (a0 : avl_tree) (_ : forall (k0 : Int) (_ : forall (k : Int) (d : B) (_ : lookup k a0 d), Less k0 k), is_above a0 k0) (b0 : bal) (k0 : Int) (_ : forall (k : Int) (d : B) (_ : lookup k (Avl_Node i b a a0 b0) d), Less k0 k), is_above (Avl_Node i b a a0 b0) k0 *) intros k d l ih_l r ih_r b k0 H. (* Goal: is_above (Avl_Node k d l r b) k0 *) apply Above_Node. (* Goal: Less k0 k *) (* Goal: is_above l k0 *) (* Goal: is_above r k0 *) apply (H k d). (* Goal: lookup k0 (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d0 *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup_Equal. (* Goal: is_below l k0 *) (* Goal: is_below r k0 *) apply ih_l. (* Goal: forall (k : Int) (d : B) (_ : lookup k l d), Less k0 k *) (* Goal: is_above r k0 *) intros k1 d0 lookup_l. (* Goal: Less k0 k1 *) apply (H k1 d0). (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Left; assumption. (* Goal: is_above r k0 *) apply ih_r. (* Goal: forall (k : Int) (d : B) (_ : lookup k r d), Less k0 k *) intros k1 d0 lookup_r. (* Goal: Less k0 k1 *) apply (H k1 d0). (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Right; assumption. Qed. Lemma lookup_above_lookup : forall (key k : Int) (d : B) (l r : avl_tree) (b : bal) (data : B), lookup key (Avl_Node k d l r b) data -> Less key k -> is_above r key -> lookup key l data. (* Goal: forall (key k : Int) (d : B) (l r : avl_tree) (b : bal) (data : B) (_ : lookup key (Avl_Node k d l r b) data) (_ : Less key k) (_ : is_above r key), lookup key l data *) intros key k d l r b data lookup_t less above_r. (* Goal: lookup key r data *) elim (inv_lookup key k d l r b data lookup_t); clear lookup_t; intro u0. (* Goal: lin_del_spec key d Avl_Nil Avl_Nil *) (* Goal: equiv_del key Avl_Nil Avl_Nil *) (* Goal: sumbool (@eq nat (height_avl Avl_Nil) (height_avl Avl_Nil)) (@eq nat (height_avl Avl_Nil) (S (height_avl Avl_Nil))) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, delete_spec key a) (a0 : avl_tree) (_ : forall _ : is_avl a0, delete_spec key a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), delete_spec key (Avl_Node i b a a0 b0) *) elimtype False. (* Goal: False *) (* Goal: False *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), lookup k (Avl_Node k0 d0 l0 r b) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) elim u0; clear u0; intros u0 u1. (* Goal: False *) apply less_irrefl with key. (* Goal: False *) (* Goal: False *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), lookup k (Avl_Node k0 d0 l0 r b) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) rewrite u0 in less. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: False *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), lookup k (Avl_Node k0 d0 l0 r b) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) elim u0; clear u0; intro u0. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: lin_del_spec key d Avl_Nil Avl_Nil *) (* Goal: equiv_del key Avl_Nil Avl_Nil *) (* Goal: sumbool (@eq nat (height_avl Avl_Nil) (height_avl Avl_Nil)) (@eq nat (height_avl Avl_Nil) (S (height_avl Avl_Nil))) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, delete_spec key a) (a0 : avl_tree) (_ : forall _ : is_avl a0, delete_spec key a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), delete_spec key (Avl_Node i b a a0 b0) *) elimtype False. (* Goal: False *) apply less_irrefl with key. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply lookup_above_greater with r data; assumption. Qed. Lemma lookup_below_lookup : forall (key k : Int) (d : B) (l r : avl_tree) (b : bal) (data : B), lookup key (Avl_Node k d l r b) data -> Less k key -> is_below l key -> lookup key r data. (* Goal: forall (key k : Int) (d : B) (l r : avl_tree) (b : bal) (data : B) (_ : lookup key (Avl_Node k d l r b) data) (_ : Less k key) (_ : is_below l key), lookup key r data *) intros key k d l r b data lookup_t less below_l. (* Goal: lookup key r data *) elim (inv_lookup key k d l r b data lookup_t); clear lookup_t; intro u0. (* Goal: lin_del_spec key d Avl_Nil Avl_Nil *) (* Goal: equiv_del key Avl_Nil Avl_Nil *) (* Goal: sumbool (@eq nat (height_avl Avl_Nil) (height_avl Avl_Nil)) (@eq nat (height_avl Avl_Nil) (S (height_avl Avl_Nil))) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, delete_spec key a) (a0 : avl_tree) (_ : forall _ : is_avl a0, delete_spec key a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), delete_spec key (Avl_Node i b a a0 b0) *) elimtype False. (* Goal: False *) (* Goal: False *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), lookup k (Avl_Node k0 d0 l0 r b) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) elim u0; clear u0; intros u0 u1. (* Goal: False *) apply less_irrefl with key. (* Goal: False *) (* Goal: False *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), lookup k (Avl_Node k0 d0 l0 r b) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) rewrite u0 in less. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: False *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), lookup k (Avl_Node k0 d0 l0 r b) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) elim u0; clear u0; intro u0. (* Goal: lin_del_spec key d Avl_Nil Avl_Nil *) (* Goal: equiv_del key Avl_Nil Avl_Nil *) (* Goal: sumbool (@eq nat (height_avl Avl_Nil) (height_avl Avl_Nil)) (@eq nat (height_avl Avl_Nil) (S (height_avl Avl_Nil))) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, delete_spec key a) (a0 : avl_tree) (_ : forall _ : is_avl a0, delete_spec key a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), delete_spec key (Avl_Node i b a a0 b0) *) elimtype False. (* Goal: False *) apply less_irrefl with key. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply lookup_below_less with l data; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. Qed. Lemma lookup_below_false : forall (key : Int) (t : avl_tree) (data : B), lookup key t data -> is_below t key -> False. (* Goal: forall (key : Int) (t : avl_tree) (data : B) (_ : lookup key t data) (_ : is_below t key), False *) intros key t data lookup_t below_t. (* Goal: False *) apply less_irrefl with key. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply lookup_below_less with t data; assumption. Qed. Lemma lookup_above_false : forall (key : Int) (t : avl_tree) (data : B), lookup key t data -> is_above t key -> False. (* Goal: forall (key : Int) (t : avl_tree) (data : B) (_ : lookup key t data) (_ : is_above t key), False *) intros key t data lookup_t above_t. (* Goal: False *) apply less_irrefl with key. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply lookup_above_greater with t data; assumption. Qed. (*********************************************************) (* Definition is_below_avl *) Inductive is_below_avl : avl_tree -> Int -> Prop := | Below_Avl_Nil : forall k0 : Int, is_below_avl Avl_Nil k0 | Below_Avl_Node : forall (k : Int) (d : B) (l r : avl_tree) (b : bal) (k0 : Int), Less k k0 -> is_below_avl r k0 -> is_below_avl (Avl_Node k d l r b) k0. Lemma inv_below_avl_key : forall (k : Int) (d : B) (l r : avl_tree) (b : bal) (k0 : Int), is_below_avl (Avl_Node k d l r b) k0 -> Less k k0. (* Goal: forall (key : Int) (t0 t : avl_tree) (k : Int) (d : B) (_ : equiv_del key t0 t) (_ : not (Equal k key)) (_ : lookup k t d), lookup k t0 d *) intros. (* Goal: is_above_avl r k *) inversion H; assumption. Qed. Lemma inv_below_avl_right : forall (k : Int) (d : B) (l r : avl_tree) (b : bal) (k0 : Int), is_below_avl (Avl_Node k d l r b) k0 -> is_below_avl r k0. (* Goal: forall (key : Int) (t0 t : avl_tree) (k : Int) (d : B) (_ : equiv_del key t0 t) (_ : not (Equal k key)) (_ : lookup k t d), lookup k t0 d *) intros. (* Goal: is_above_avl r k *) inversion H; assumption. Qed. Lemma below_avl_trans : forall (t : avl_tree) (k0 k1 : Int), is_below_avl t k0 -> Less k0 k1 -> is_below_avl t k1. (* Goal: forall (t : avl_tree) (_ : @eq nat (height_avl t) O), @eq avl_tree t Avl_Nil *) intros t; elim t; clear t. (* Goal: forall (key : Int) (t0 t : avl_tree) (k : Int) (d : B) (_ : equiv_del key t0 t) (_ : not (Equal k key)) (_ : lookup k t d), lookup k t0 d *) intros. (* Goal: is_below_avl Avl_Nil k *) (* Goal: is_above_avl Avl_Nil k *) apply Below_Avl_Nil. (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall (k0 k1 : Int) (_ : is_above_avl a k0) (_ : Less k1 k0), is_above_avl a k1) (a0 : avl_tree) (_ : forall (k0 k1 : Int) (_ : is_above_avl a0 k0) (_ : Less k1 k0), is_above_avl a0 k1) (b0 : bal) (k0 k1 : Int) (_ : is_above_avl (Avl_Node i b a a0 b0) k0) (_ : Less k1 k0), is_above_avl (Avl_Node i b a a0 b0) k1 *) intros k d l ih_l r ih_r b k0 k1 H0 H1. (* Goal: is_below_avl (Avl_Node k d l r b) key *) apply Below_Avl_Node. (* Goal: Less k k1 *) (* Goal: is_below_avl r k1 *) apply (less_trans k k0 k1). (* Goal: Less k k0 *) (* Goal: Less k0 k1 *) (* Goal: is_below_avl r k1 *) apply (inv_below_avl_key k d l r b k0 H0). (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: is_below_avl r k1 *) apply (ih_r k0 k1 (inv_below_avl_right k d l r b k0 H0) H1). Qed. Lemma below_below_avl : forall (t : avl_tree) (key : Int), is_below t key -> is_below_avl t key. (* Goal: forall (t : avl_tree) (key : Int) (_ : is_above t key), is_above_avl t key *) intros t key; elim t; clear t. (* Goal: forall (key : Int) (t0 t : avl_tree) (k : Int) (d : B) (_ : equiv_del key t0 t) (_ : not (Equal k key)) (_ : lookup k t d), lookup k t0 d *) intros. (* Goal: is_below_avl Avl_Nil k *) (* Goal: is_above_avl Avl_Nil k *) apply Below_Avl_Nil. (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_below a key, is_below_avl a key) (a0 : avl_tree) (_ : forall _ : is_below a0 key, is_below_avl a0 key) (b0 : bal) (_ : is_below (Avl_Node i b a a0 b0) key), is_below_avl (Avl_Node i b a a0 b0) key *) intros k d l ih_l r ih_r b below_t. (* Goal: is_below_avl (Avl_Node k d l r b) key *) apply Below_Avl_Node. (* Goal: Less k key *) (* Goal: is_below_avl r key *) apply (inv_below_key k d l r b key below_t). (* Goal: is_above r k0 *) apply ih_r. (* Goal: is_below r key *) apply (inv_below_right k d l r b key below_t). Qed. (*********************************************************) (* Definition is_above_avl *) Inductive is_above_avl : avl_tree -> Int -> Prop := | Above_Avl_Nil : forall k0 : Int, is_above_avl Avl_Nil k0 | Above_Avl_Node : forall (k : Int) (d : B) (l r : avl_tree) (b : bal) (k0 : Int), Less k0 k -> is_above_avl l k0 -> is_above_avl (Avl_Node k d l r b) k0. Lemma inv_above_avl_key : forall (k : Int) (d : B) (l r : avl_tree) (b : bal) (k0 : Int), is_above_avl (Avl_Node k d l r b) k0 -> Less k0 k. (* Goal: forall (key : Int) (t0 t : avl_tree) (k : Int) (d : B) (_ : equiv_del key t0 t) (_ : not (Equal k key)) (_ : lookup k t d), lookup k t0 d *) intros. (* Goal: is_above_avl r k *) inversion H; assumption. Qed. Lemma inv_above_avl_left : forall (k : Int) (d : B) (l r : avl_tree) (b : bal) (k0 : Int), is_above_avl (Avl_Node k d l r b) k0 -> is_above_avl l k0. (* Goal: forall (key : Int) (t0 t : avl_tree) (k : Int) (d : B) (_ : equiv_del key t0 t) (_ : not (Equal k key)) (_ : lookup k t d), lookup k t0 d *) intros. (* Goal: is_above_avl r k *) inversion H; assumption. Qed. Lemma above_avl_trans : forall (t : avl_tree) (k0 k1 : Int), is_above_avl t k0 -> Less k1 k0 -> is_above_avl t k1. (* Goal: forall (t : avl_tree) (_ : @eq nat (height_avl t) O), @eq avl_tree t Avl_Nil *) intros t; elim t; clear t. (* Goal: forall (key : Int) (t0 t : avl_tree) (k : Int) (d : B) (_ : equiv_del key t0 t) (_ : not (Equal k key)) (_ : lookup k t d), lookup k t0 d *) intros. (* Goal: is_above_avl Avl_Nil k *) apply Above_Avl_Nil. (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall (k0 k1 : Int) (_ : is_above_avl a k0) (_ : Less k1 k0), is_above_avl a k1) (a0 : avl_tree) (_ : forall (k0 k1 : Int) (_ : is_above_avl a0 k0) (_ : Less k1 k0), is_above_avl a0 k1) (b0 : bal) (k0 k1 : Int) (_ : is_above_avl (Avl_Node i b a a0 b0) k0) (_ : Less k1 k0), is_above_avl (Avl_Node i b a a0 b0) k1 *) intros k d l ih_l r ih_r b k0 k1 H0 H1. (* Goal: is_above_avl (Avl_Node k d l r b) key *) apply Above_Avl_Node. (* Goal: Less k1 k *) (* Goal: is_above_avl l k1 *) apply (less_trans k1 k0 k H1). (* Goal: Less k0 k *) (* Goal: is_above_avl l k1 *) apply (inv_above_avl_key k d l r b k0 H0). (* Goal: is_above_avl l k1 *) apply (ih_l k0 k1 (inv_above_avl_left k d l r b k0 H0) H1). Qed. Lemma above_above_avl : forall (t : avl_tree) (key : Int), is_above t key -> is_above_avl t key. (* Goal: forall (t : avl_tree) (key : Int) (_ : is_above t key), is_above_avl t key *) intros t key; elim t; clear t. (* Goal: forall (key : Int) (t0 t : avl_tree) (k : Int) (d : B) (_ : equiv_del key t0 t) (_ : not (Equal k key)) (_ : lookup k t d), lookup k t0 d *) intros. (* Goal: is_above_avl Avl_Nil k *) apply Above_Avl_Nil. (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_above a key, is_above_avl a key) (a0 : avl_tree) (_ : forall _ : is_above a0 key, is_above_avl a0 key) (b0 : bal) (_ : is_above (Avl_Node i b a a0 b0) key), is_above_avl (Avl_Node i b a a0 b0) key *) intros k d l ih_l r ih_r b above_t. (* Goal: is_above_avl (Avl_Node k d l r b) key *) apply Above_Avl_Node. (* Goal: Less key k *) (* Goal: is_above_avl l key *) apply (inv_above_key k d l r b key above_t). (* Goal: is_below l k0 *) (* Goal: is_below r k0 *) apply ih_l. (* Goal: is_above l key *) apply (inv_above_left k d l r b key above_t). Qed. (*****************************************************************) (* height_avl *) Fixpoint height_avl (t : avl_tree) : nat := match t with | Avl_Nil => 0 | Avl_Node _ _ l _ Left_Balanced => S (height_avl l) | Avl_Node _ _ l _ Balanced => S (height_avl l) | Avl_Node _ _ _ r Right_Balanced => S (height_avl r) end. Lemma height_avl_O_nil : forall t : avl_tree, height_avl t = 0 -> t = Avl_Nil. (* Goal: forall (t : avl_tree) (_ : @eq nat (height_avl t) O), @eq avl_tree t Avl_Nil *) intros t; elim t; clear t. (* Goal: forall _ : @eq nat (height_avl Avl_Nil) O, @eq avl_tree Avl_Nil Avl_Nil *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : @eq nat (height_avl a) O, @eq avl_tree a Avl_Nil) (a0 : avl_tree) (_ : forall _ : @eq nat (height_avl a0) O, @eq avl_tree a0 Avl_Nil) (b0 : bal) (_ : @eq nat (height_avl (Avl_Node i b a a0 b0)) O), @eq avl_tree (Avl_Node i b a a0 b0) Avl_Nil *) intros; trivial. (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : @eq nat (height_avl a) O, @eq avl_tree a Avl_Nil) (a0 : avl_tree) (_ : forall _ : @eq nat (height_avl a0) O, @eq avl_tree a0 Avl_Nil) (b0 : bal) (_ : @eq nat (height_avl (Avl_Node i b a a0 b0)) O), @eq avl_tree (Avl_Node i b a a0 b0) Avl_Nil *) intros k d l ih_l r ih_r b. elim b; simpl in |- *; intro u0; discriminate u0. Qed. (*********************************************************) (* Definition is_balanced *) Inductive is_balanced_avl (l r : avl_tree) : bal -> Prop := | Is_Left_Balanced_Avl : height_avl l = S (height_avl r) -> is_balanced_avl l r Left_Balanced | Is_Fully_Balanced_Avl : height_avl l = height_avl r -> is_balanced_avl l r Balanced | Is_Right_Balanced_Avl : S (height_avl l) = height_avl r -> is_balanced_avl l r Right_Balanced. Lemma inv_left_balanced_avl : forall l r : avl_tree, is_balanced_avl l r Left_Balanced -> height_avl l = S (height_avl r). (* Goal: forall (key : Int) (t0 t : avl_tree) (k : Int) (d : B) (_ : equiv_del key t0 t) (_ : not (Equal k key)) (_ : lookup k t d), lookup k t0 d *) intros. (* Goal: is_above_avl r k *) inversion H; assumption. Qed. Lemma inv_fully_balanced_avl : forall l r : avl_tree, is_balanced_avl l r Balanced -> height_avl l = height_avl r. (* Goal: forall (key : Int) (t0 t : avl_tree) (k : Int) (d : B) (_ : equiv_del key t0 t) (_ : not (Equal k key)) (_ : lookup k t d), lookup k t0 d *) intros. (* Goal: is_above_avl r k *) inversion H; assumption. Qed. Lemma inv_right_balanced_avl : forall l r : avl_tree, is_balanced_avl l r Right_Balanced -> S (height_avl l) = height_avl r. (* Goal: forall (key : Int) (t0 t : avl_tree) (k : Int) (d : B) (_ : equiv_del key t0 t) (_ : not (Equal k key)) (_ : lookup k t d), lookup k t0 d *) intros. (* Goal: is_above_avl r k *) inversion H; assumption. Qed. Lemma hasnot_grown_left__preserves_is_balanced_avl : forall (l l0 r0 : avl_tree) (b0 : bal), is_balanced_avl l0 r0 b0 -> height_avl l = height_avl l0 -> is_balanced_avl l r0 b0. (* Goal: forall (l l0 r0 : avl_tree) (b0 : bal) (_ : is_balanced_avl l0 r0 b0) (_ : @eq nat (height_avl l) (height_avl l0)), is_balanced_avl l r0 b0 *) intros l l0 r0 b0 Balanced_l0 height_l. (* Goal: is_balanced_avl_right_shift l r0 b0 *) inversion_clear Balanced_l0. (* Goal: is_balanced_avl l r Left_Balanced *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node k d l r Left_Balanced)) (lin_avl (Avl_Node k d l r Balanced)) *) (* Goal: equiv (Avl_Node k d l r Left_Balanced) (Avl_Node k d l r Balanced) *) (* Goal: sumbool (hasnot_shrunk_left (Avl_Node k d l r Left_Balanced) k d l r Balanced) (has_shrunk_left (Avl_Node k d l r Left_Balanced) k d l r Balanced) *) (* Goal: bal_shrunk_left_spec k d l r Right_Balanced *) apply Is_Left_Balanced_Avl. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) rewrite height_l; assumption. (* Goal: is_balanced_avl l r Balanced *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node k d l r Balanced)) (lin_avl (Avl_Node k d l r Left_Balanced)) *) (* Goal: equiv (Avl_Node k d l r Balanced) (Avl_Node k d l r Left_Balanced) *) (* Goal: sumbool (hasnot_shrunk_right (Avl_Node k d l r Balanced) k d l r Left_Balanced) (has_shrunk_right (Avl_Node k d l r Balanced) k d l r Left_Balanced) *) (* Goal: bal_shrunk_right_spec k d l r Balanced *) (* Goal: bal_shrunk_right_spec k d l r Right_Balanced *) apply Is_Fully_Balanced_Avl. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) rewrite height_l; assumption. (* Goal: is_balanced_avl l r Right_Balanced *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node k d l r Right_Balanced)) (lin_avl (Avl_Node k d l r Balanced)) *) (* Goal: equiv (Avl_Node k d l r Right_Balanced) (Avl_Node k d l r Balanced) *) (* Goal: sumbool (hasnot_shrunk_right (Avl_Node k d l r Right_Balanced) k d l r Balanced) (has_shrunk_right (Avl_Node k d l r Right_Balanced) k d l r Balanced) *) (* Goal: bal_shrunk_right_spec k d l r Right_Balanced *) apply Is_Right_Balanced_Avl. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) rewrite height_l; assumption. Qed. Lemma hasnot_grown_right__preserves_is_balanced_avl : forall (l0 r r0 : avl_tree) (b0 : bal), is_balanced_avl l0 r0 b0 -> height_avl r = height_avl r0 -> is_balanced_avl l0 r b0. (* Goal: forall (l0 r r0 : avl_tree) (b0 : bal) (_ : is_balanced_avl l0 r0 b0) (_ : @eq nat (height_avl r0) (S (height_avl r))), is_balanced_avl_left_shift l0 r b0 *) intros l0 r r0 b0 Balanced_l0 height_r. (* Goal: is_balanced_avl_right_shift l r0 b0 *) inversion_clear Balanced_l0. (* Goal: is_balanced_avl l r Left_Balanced *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node k d l r Left_Balanced)) (lin_avl (Avl_Node k d l r Balanced)) *) (* Goal: equiv (Avl_Node k d l r Left_Balanced) (Avl_Node k d l r Balanced) *) (* Goal: sumbool (hasnot_shrunk_left (Avl_Node k d l r Left_Balanced) k d l r Balanced) (has_shrunk_left (Avl_Node k d l r Left_Balanced) k d l r Balanced) *) (* Goal: bal_shrunk_left_spec k d l r Right_Balanced *) apply Is_Left_Balanced_Avl. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) rewrite height_r; assumption. (* Goal: is_balanced_avl l r Balanced *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node k d l r Balanced)) (lin_avl (Avl_Node k d l r Left_Balanced)) *) (* Goal: equiv (Avl_Node k d l r Balanced) (Avl_Node k d l r Left_Balanced) *) (* Goal: sumbool (hasnot_shrunk_right (Avl_Node k d l r Balanced) k d l r Left_Balanced) (has_shrunk_right (Avl_Node k d l r Balanced) k d l r Left_Balanced) *) (* Goal: bal_shrunk_right_spec k d l r Balanced *) (* Goal: bal_shrunk_right_spec k d l r Right_Balanced *) apply Is_Fully_Balanced_Avl. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) rewrite height_r; assumption. (* Goal: is_balanced_avl l r Right_Balanced *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node k d l r Right_Balanced)) (lin_avl (Avl_Node k d l r Balanced)) *) (* Goal: equiv (Avl_Node k d l r Right_Balanced) (Avl_Node k d l r Balanced) *) (* Goal: sumbool (hasnot_shrunk_right (Avl_Node k d l r Right_Balanced) k d l r Balanced) (has_shrunk_right (Avl_Node k d l r Right_Balanced) k d l r Balanced) *) (* Goal: bal_shrunk_right_spec k d l r Right_Balanced *) apply Is_Right_Balanced_Avl. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) rewrite height_r; assumption. Qed. (*************************************************) (* Definition Avl *) (*************************************************) Inductive is_avl : avl_tree -> Prop := | Nil_Is_Avl : is_avl Avl_Nil | Node_Is_Avl : forall (k : Int) (d : B) (l r : avl_tree) (b : bal), is_avl l -> is_avl r -> is_balanced_avl l r b -> is_below_avl l k -> is_above_avl r k -> is_avl (Avl_Node k d l r b). Lemma is_avl_rec : forall P : avl_tree -> Set, P Avl_Nil -> (forall (k : Int) (d : B) (l r : avl_tree) (b : bal), is_avl l -> P l -> is_avl r -> P r -> is_balanced_avl l r b -> is_below_avl l k -> is_above_avl r k -> P (Avl_Node k d l r b)) -> forall t : avl_tree, is_avl t -> P t. (* Goal: forall (P : forall _ : avl_tree, Set) (_ : P Avl_Nil) (_ : forall (k : Int) (d : B) (l r : avl_tree) (b : bal) (_ : is_avl l) (_ : P l) (_ : is_avl r) (_ : P r) (_ : is_balanced_avl l r b) (_ : is_below_avl l k) (_ : is_above_avl r k), P (Avl_Node k d l r b)) (t : avl_tree) (_ : is_avl t), P t *) intros P base step t. (* Goal: forall _ : is_avl t, P t *) elim t; clear t. (* Goal: forall _ : is_avl Avl_Nil, P Avl_Nil *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, P a) (a0 : avl_tree) (_ : forall _ : is_avl a0, P a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), P (Avl_Node i b a a0 b0) *) intros; apply base. (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, P a) (a0 : avl_tree) (_ : forall _ : is_avl a0, P a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), P (Avl_Node i b a a0 b0) *) intros k d l ih_l r ih_r b avl_t. (* Goal: P (Avl_Node k d l r b) *) apply step. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear avl_t; assumption. (* Goal: is_below l k0 *) (* Goal: is_below r k0 *) apply ih_l. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear avl_t; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear avl_t; assumption. (* Goal: is_above r k0 *) apply ih_r. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear avl_t; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear avl_t; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear avl_t; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear avl_t; assumption. Qed. Lemma inv_is_avl_left : forall (k : Int) (d : B) (l r : avl_tree) (b : bal), is_avl (Avl_Node k d l r b) -> is_avl l. (* Goal: forall (key : Int) (t0 t : avl_tree) (k : Int) (d : B) (_ : equiv_del key t0 t) (_ : not (Equal k key)) (_ : lookup k t d), lookup k t0 d *) intros. (* Goal: is_above_avl r k *) inversion H; assumption. Qed. Lemma inv_is_avl_right : forall (k : Int) (d : B) (l r : avl_tree) (b : bal), is_avl (Avl_Node k d l r b) -> is_avl r. (* Goal: forall (key : Int) (t0 t : avl_tree) (k : Int) (d : B) (_ : equiv_del key t0 t) (_ : not (Equal k key)) (_ : lookup k t d), lookup k t0 d *) intros. (* Goal: is_above_avl r k *) inversion H; assumption. Qed. Lemma inv_is_avl_is_balanced_avl : forall (k : Int) (d : B) (l r : avl_tree) (b : bal), is_avl (Avl_Node k d l r b) -> is_balanced_avl l r b. (* Goal: forall (key : Int) (t0 t : avl_tree) (k : Int) (d : B) (_ : equiv_del key t0 t) (_ : not (Equal k key)) (_ : lookup k t d), lookup k t0 d *) intros. (* Goal: is_above_avl r k *) inversion H; assumption. Qed. Lemma inv_is_avl_is_is_below_avl : forall (k : Int) (d : B) (l r : avl_tree) (b : bal), is_avl (Avl_Node k d l r b) -> is_below_avl l k. (* Goal: forall (key : Int) (t0 t : avl_tree) (k : Int) (d : B) (_ : equiv_del key t0 t) (_ : not (Equal k key)) (_ : lookup k t d), lookup k t0 d *) intros. (* Goal: is_above_avl r k *) inversion H; assumption. Qed. Lemma inv_is_avl_is_is_above_avl : forall (k : Int) (d : B) (l r : avl_tree) (b : bal), is_avl (Avl_Node k d l r b) -> is_above_avl r k. (* Goal: forall (key : Int) (t0 t : avl_tree) (k : Int) (d : B) (_ : equiv_del key t0 t) (_ : not (Equal k key)) (_ : lookup k t d), lookup k t0 d *) intros. (* Goal: is_above_avl r k *) inversion H; assumption. Qed. Lemma avl_height_avl_height : forall t : avl_tree, is_avl t -> height_avl t = height t. (* Goal: forall (t : avl_tree) (_ : is_avl t) (k0 : Int) (_ : is_below_avl t k0), is_below t k0 *) intros t avl_t. (* Goal: @eq nat (height_avl t) (height t) *) elim avl_t. (* Goal: forall _ : is_balanced_avl l0 r0 Left_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Left_Balanced)) (S (height_avl l0)) *) (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *; trivial. (* Goal: forall (k : Int) (d : B) (l r : avl_tree) (b : bal) (_ : is_avl l) (_ : lookup_dec_spec key l) (_ : is_avl r) (_ : lookup_dec_spec key r) (_ : is_balanced_avl l r b) (_ : is_below_avl l k) (_ : is_above_avl r k), lookup_dec_spec key (Avl_Node k d l r b) *) intros k d l r b avl_l ih_l avl_r ih_r Balanced_t below_l above_r. (* Goal: @eq nat (height_avl (Avl_Node k d l r b)) (height (Avl_Node k d l r b)) *) clear avl_l avl_r below_l above_r. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *. (* Goal: @eq nat match b with | Left_Balanced => S (height_avl l) | Balanced => S (height_avl l) | Right_Balanced => S (height_avl r) end (S (max (height l) (height r))) *) rewrite <- ih_l. (* Goal: @eq nat match b with | Left_Balanced => S (height_avl l) | Balanced => S (height_avl l) | Right_Balanced => S (height_avl r) end (S (max (height_avl l) (height r))) *) rewrite <- ih_r. (* Goal: @eq nat match b with | Left_Balanced => S (height_avl l) | Balanced => S (height_avl l) | Right_Balanced => S (height_avl r) end (S (max (height_avl l) (height_avl r))) *) clear ih_l ih_r. (* Goal: @eq nat match b with | Left_Balanced => S (height_avl l) | Balanced => S (height_avl l) | Right_Balanced => S (height_avl r) end (S (max (height_avl l) (height_avl r))) *) inversion_clear Balanced_t. (* Goal: @eq nat (S match br0 with | Left_Balanced => S (height_avl lr0) | Balanced => S (height_avl lr0) | Right_Balanced => S (height_avl rr0) end) (S (S (height_avl l0))) *) (* Goal: forall _ : is_balanced_avl l0 (Avl_Node kr0 dr0 lr0 rr0 br0) Left_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) Left_Balanced)) (height_avl t) *) (* Goal: forall _ : is_balanced_avl l0 (Avl_Node kr0 dr0 lr0 rr0 br0) Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) Balanced)) (height_avl t) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl (Avl_Node kr0 dr0 lr0 rr0 br0) *) rewrite H. (* Goal: @eq nat (S (S (height_avl r))) (S (max (S (height_avl r)) (height_avl r))) *) (* Goal: @eq nat (S (height_avl l)) (S (max (height_avl l) (height_avl r))) *) (* Goal: @eq nat (S (height_avl r)) (S (max (height_avl l) (height_avl r))) *) rewrite (max_Sn_n (height_avl r)). (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. (* Goal: @eq nat (S match br0 with | Left_Balanced => S (height_avl lr0) | Balanced => S (height_avl lr0) | Right_Balanced => S (height_avl rr0) end) (S (S (height_avl l0))) *) (* Goal: forall _ : is_balanced_avl l0 (Avl_Node kr0 dr0 lr0 rr0 br0) Left_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) Left_Balanced)) (height_avl t) *) (* Goal: forall _ : is_balanced_avl l0 (Avl_Node kr0 dr0 lr0 rr0 br0) Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) Balanced)) (height_avl t) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl (Avl_Node kr0 dr0 lr0 rr0 br0) *) rewrite H. (* Goal: @eq nat (S (height_avl r)) (S (max (height_avl r) (height_avl r))) *) (* Goal: @eq nat (S (height_avl r)) (S (max (height_avl l) (height_avl r))) *) rewrite (max_n_n (height_avl r)). (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. (* Goal: @eq nat (S match bl0 with | Left_Balanced => S (height_avl ll0) | Balanced => S (height_avl ll0) | Right_Balanced => S (height_avl rl0) end) (S (height_avl r0)) *) (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced, @eq nat (S (height_avl r0)) (S (height_avl r0)) *) (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Balanced, @eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Balanced)) (height_avl t) *) (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced)) (height_avl t) *) (* Goal: forall _ : has_shrunk_right t k d l r0 b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) rewrite <- H. (* Goal: @eq nat (S (S (height_avl l))) (S (max (height_avl l) (S (height_avl l)))) *) rewrite (max_n_Sn (height_avl l)). (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. Qed. Lemma is_balanced_avl_is_balanced : forall l r : avl_tree, is_avl l -> is_avl r -> forall b : bal, is_balanced_avl l r b -> is_balanced l r b. (* Goal: forall (l r : avl_tree) (_ : is_avl l) (_ : is_avl r) (b : bal) (_ : is_balanced_avl l r b), is_balanced l r b *) intros l r avl_l avl_r. (* Goal: forall (b : bal) (_ : is_balanced_avl l r b), is_balanced l r b *) intro b; elim b; clear b; intro bal0. (* Goal: is_balanced l r Left_Balanced *) (* Goal: is_balanced l r Balanced *) (* Goal: is_balanced l r Right_Balanced *) apply Is_Left_Balanced. (* Goal: @eq nat (S (height l)) (height r) *) rewrite <- (avl_height_avl_height r avl_r). (* Goal: @eq nat (S (height l)) (height_avl r) *) rewrite <- (avl_height_avl_height l avl_l). (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply inv_left_balanced_avl; assumption. (* Goal: is_balanced l r Balanced *) (* Goal: is_balanced l r Right_Balanced *) apply Is_Fully_Balanced. (* Goal: @eq nat (S (height l)) (height r) *) rewrite <- (avl_height_avl_height r avl_r). (* Goal: @eq nat (S (height l)) (height_avl r) *) rewrite <- (avl_height_avl_height l avl_l). (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply inv_fully_balanced_avl; assumption. (* Goal: is_balanced l r Right_Balanced *) apply Is_Right_Balanced. (* Goal: @eq nat (S (height l)) (height r) *) rewrite <- (avl_height_avl_height r avl_r). (* Goal: @eq nat (S (height l)) (height_avl r) *) rewrite <- (avl_height_avl_height l avl_l). (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply inv_right_balanced_avl; assumption. Qed. Lemma is_avl_is_balanced : forall (l r : avl_tree) (k : Int) (d : B) (b : bal), is_avl (Avl_Node k d l r b) -> is_balanced l r b. (* Goal: forall (l r : avl_tree) (k : Int) (d : B) (b : bal) (_ : is_avl (Avl_Node k d l r b)), is_balanced l r b *) intros l r k d b avl_t. (* Goal: is_balanced l r b *) apply is_balanced_avl_is_balanced. (* Goal: is_avl l *) (* Goal: is_avl r *) (* Goal: is_balanced_avl l r b *) (* Goal: is_below_avl l k *) (* Goal: is_above_avl r k *) apply (inv_is_avl_left k d l r b avl_t). (* Goal: is_avl r *) (* Goal: is_balanced_avl l r b *) (* Goal: is_below_avl l k *) (* Goal: is_above_avl r k *) apply (inv_is_avl_right k d l r b avl_t). (* Goal: is_balanced_avl l r b *) (* Goal: is_below_avl l k *) (* Goal: is_above_avl r k *) apply (inv_is_avl_is_balanced_avl k d l r b avl_t). Qed. Lemma is_below_avl_is_below : forall t : avl_tree, is_avl t -> forall k0 : Int, is_below_avl t k0 -> is_below t k0. (* Goal: forall (t : avl_tree) (_ : is_avl t) (k0 : Int) (_ : is_below_avl t k0), is_below t k0 *) intros t avl_t. (* Goal: forall (k0 : Int) (_ : is_below_avl t k0), is_below t k0 *) elim avl_t; clear avl_t t. (* Goal: is_below Avl_Nil k0 *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall (k0 : Int) (_ : forall (k : Int) (d : B) (_ : lookup k a d), Less k k0), is_below a k0) (a0 : avl_tree) (_ : forall (k0 : Int) (_ : forall (k : Int) (d : B) (_ : lookup k a0 d), Less k k0), is_below a0 k0) (b0 : bal) (k0 : Int) (_ : forall (k : Int) (d : B) (_ : lookup k (Avl_Node i b a a0 b0) d), Less k k0), is_below (Avl_Node i b a a0 b0) k0 *) intros; apply Below_Nil. intros k d l r b avl_l ih_l avl_r ih_r Balanced_t below_l above_r k0 below_avl. (* Goal: is_below (Avl_Node k d l r b) k0 *) inversion_clear below_avl. (* Goal: is_below (Avl_Node k0 d0 l0 r b0) k *) (* Goal: Less k0 k *) (* Goal: equiv t (Avl_Node k0 d0 l0 r b0) *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0)) (@app (prod Int B) (lin_avl t) (@cons (prod Int B) (@pair Int B k d) (@nil (prod Int B)))) *) (* Goal: equiv_del k (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl (Avl_Node kr0 dr0 lr0 rr0 br0) *) apply Below_Node. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: is_below l k0 *) (* Goal: is_below r k0 *) apply ih_l. (* Goal: is_below_avl l k0 *) (* Goal: is_below r k0 *) apply below_avl_trans with k. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply ih_r; assumption. Qed. Lemma is_above_avl_is_above : forall t : avl_tree, is_avl t -> forall k0 : Int, is_above_avl t k0 -> is_above t k0. (* Goal: forall (k0 : Int) (_ : is_below_avl t k0), is_below t k0 *) intros t avl_t; elim avl_t; clear avl_t t. (* Goal: is_above Avl_Nil k0 *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall (k0 : Int) (_ : forall (k : Int) (d : B) (_ : lookup k a d), Less k0 k), is_above a k0) (a0 : avl_tree) (_ : forall (k0 : Int) (_ : forall (k : Int) (d : B) (_ : lookup k a0 d), Less k0 k), is_above a0 k0) (b0 : bal) (k0 : Int) (_ : forall (k : Int) (d : B) (_ : lookup k (Avl_Node i b a a0 b0) d), Less k0 k), is_above (Avl_Node i b a a0 b0) k0 *) intros; apply Above_Nil. intros k d l r b avl_l ih_l avl_r ih_r Balanced_t below_l above_r k0 above_avl. (* Goal: is_above (Avl_Node k d l r b) k0 *) clear avl_l avl_r Balanced_t. (* Goal: is_above (Avl_Node k d l r b) k0 *) inversion_clear above_avl. (* Goal: is_above (Avl_Node k d l r b) k0 *) apply Above_Node. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply ih_l; assumption. (* Goal: is_above r k0 *) apply ih_r. (* Goal: is_above_avl r k0 *) apply above_avl_trans with k. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. Qed. (***************************************************************) (* lookup_avl *) Lemma lookup_avl_inv_equal : forall (key k : Int) (d : B) (l r : avl_tree) (b : bal) (data : B), is_avl (Avl_Node k d l r b) -> Equal key k -> lookup key (Avl_Node k d l r b) data -> d = data. (* Goal: forall (key k : Int) (d : B) (l r : avl_tree) (b : bal) (data : B) (_ : is_avl (Avl_Node k d l r b)) (_ : Equal key k) (_ : lookup key (Avl_Node k d l r b) data), @eq B d data *) intros key k d l r b data avl_t equal lookup_t. (* Goal: lookup key r data *) elim (inv_lookup key k d l r b data lookup_t); intro u0. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) elim u0; trivial. (* Goal: lin_del_spec key d Avl_Nil Avl_Nil *) (* Goal: equiv_del key Avl_Nil Avl_Nil *) (* Goal: sumbool (@eq nat (height_avl Avl_Nil) (height_avl Avl_Nil)) (@eq nat (height_avl Avl_Nil) (S (height_avl Avl_Nil))) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, delete_spec key a) (a0 : avl_tree) (_ : forall _ : is_avl a0, delete_spec key a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), delete_spec key (Avl_Node i b a a0 b0) *) elimtype False. (* Goal: False *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), lookup k (Avl_Node k0 d0 l0 r b) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) elim u0; clear u0; intro u0. (* Goal: False *) (* Goal: lookup key r data *) apply (lookup_below_false key l data u0). (* Goal: is_below (Avl_Node kl0 dl0 ll0 rl0 bl0) k0 *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply is_below_avl_is_below. (* Goal: is_avl l *) (* Goal: is_avl r *) (* Goal: is_balanced_avl l r b *) (* Goal: is_below_avl l k *) (* Goal: is_above_avl r k *) apply (inv_is_avl_left k d l r b avl_t). (* Goal: is_above_avl r key *) rewrite (equal_eq key k equal). (* Goal: is_below_avl l k *) (* Goal: is_above_avl r k *) apply (inv_is_avl_is_is_below_avl k d l r b avl_t). (* Goal: False *) apply (lookup_above_false key r data u0). (* Goal: is_above r0 k0 *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: equiv (Avl_Node k d l r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply is_above_avl_is_above. (* Goal: is_avl r *) (* Goal: is_balanced_avl l r b *) (* Goal: is_below_avl l k *) (* Goal: is_above_avl r k *) apply (inv_is_avl_right k d l r b avl_t). (* Goal: is_above_avl r key *) rewrite (equal_eq key k equal). (* Goal: is_above_avl r k *) apply (inv_is_avl_is_is_above_avl k d l r b avl_t). Qed. Lemma lookup_avl_inv_less : forall (key k : Int) (d : B) (l r : avl_tree) (b : bal) (data : B), is_avl (Avl_Node k d l r b) -> Less key k -> lookup key (Avl_Node k d l r b) data -> lookup key l data. (* Goal: forall (key k : Int) (d : B) (l r : avl_tree) (b : bal) (data : B) (_ : is_avl (Avl_Node k d l r b)) (_ : Less k key) (_ : lookup key (Avl_Node k d l r b) data), lookup key r data *) intros key k d l r b data avl_t less lookup_t. (* Goal: lookup key r data *) elim (inv_lookup key k d l r b data lookup_t); intro u0. (* Goal: lin_del_spec key d Avl_Nil Avl_Nil *) (* Goal: equiv_del key Avl_Nil Avl_Nil *) (* Goal: sumbool (@eq nat (height_avl Avl_Nil) (height_avl Avl_Nil)) (@eq nat (height_avl Avl_Nil) (S (height_avl Avl_Nil))) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, delete_spec key a) (a0 : avl_tree) (_ : forall _ : is_avl a0, delete_spec key a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), delete_spec key (Avl_Node i b a a0 b0) *) elimtype False. (* Goal: False *) (* Goal: lookup key r data *) apply (less_irrefl key). (* Goal: False *) (* Goal: False *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), lookup k (Avl_Node k0 d0 l0 r b) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) elim u0; clear u0; intros u0 u1. (* Goal: False *) (* Goal: False *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), lookup k (Avl_Node k0 d0 l0 r b) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) rewrite u0 in less. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: False *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), lookup k (Avl_Node k0 d0 l0 r b) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) elim u0; clear u0; intro u0. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: lin_del_spec key d Avl_Nil Avl_Nil *) (* Goal: equiv_del key Avl_Nil Avl_Nil *) (* Goal: sumbool (@eq nat (height_avl Avl_Nil) (height_avl Avl_Nil)) (@eq nat (height_avl Avl_Nil) (S (height_avl Avl_Nil))) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, delete_spec key a) (a0 : avl_tree) (_ : forall _ : is_avl a0, delete_spec key a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), delete_spec key (Avl_Node i b a a0 b0) *) elimtype False. (* Goal: False *) apply (lookup_above_false key r data u0). (* Goal: is_above r0 k0 *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: equiv (Avl_Node k d l r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply is_above_avl_is_above. (* Goal: is_avl r *) (* Goal: is_balanced_avl l r b *) (* Goal: is_below_avl l k *) (* Goal: is_above_avl r k *) apply (inv_is_avl_right k d l r b avl_t). (* Goal: is_above_avl r key *) apply (above_avl_trans r k key). (* Goal: is_above_avl r k *) apply (inv_is_avl_is_is_above_avl k d l r b avl_t). (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. Qed. Lemma lookup_avl_inv_greater : forall (key k : Int) (d : B) (l r : avl_tree) (b : bal) (data : B), is_avl (Avl_Node k d l r b) -> Less k key -> lookup key (Avl_Node k d l r b) data -> lookup key r data. (* Goal: forall (key k : Int) (d : B) (l r : avl_tree) (b : bal) (data : B) (_ : is_avl (Avl_Node k d l r b)) (_ : Less k key) (_ : lookup key (Avl_Node k d l r b) data), lookup key r data *) intros key k d l r b data avl_t less lookup_t. (* Goal: lookup key r data *) elim (inv_lookup key k d l r b data lookup_t); intro u0. (* Goal: lin_del_spec key d Avl_Nil Avl_Nil *) (* Goal: equiv_del key Avl_Nil Avl_Nil *) (* Goal: sumbool (@eq nat (height_avl Avl_Nil) (height_avl Avl_Nil)) (@eq nat (height_avl Avl_Nil) (S (height_avl Avl_Nil))) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, delete_spec key a) (a0 : avl_tree) (_ : forall _ : is_avl a0, delete_spec key a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), delete_spec key (Avl_Node i b a a0 b0) *) elimtype False. (* Goal: False *) (* Goal: lookup key r data *) apply (less_irrefl key). (* Goal: False *) (* Goal: False *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), lookup k (Avl_Node k0 d0 l0 r b) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) elim u0; clear u0; intros u0 u1. (* Goal: False *) (* Goal: False *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), lookup k (Avl_Node k0 d0 l0 r b) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) rewrite u0 in less. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: False *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), lookup k (Avl_Node k0 d0 l0 r b) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) elim u0; clear u0; intro u0. (* Goal: lin_del_spec key d Avl_Nil Avl_Nil *) (* Goal: equiv_del key Avl_Nil Avl_Nil *) (* Goal: sumbool (@eq nat (height_avl Avl_Nil) (height_avl Avl_Nil)) (@eq nat (height_avl Avl_Nil) (S (height_avl Avl_Nil))) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, delete_spec key a) (a0 : avl_tree) (_ : forall _ : is_avl a0, delete_spec key a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), delete_spec key (Avl_Node i b a a0 b0) *) elimtype False. (* Goal: False *) (* Goal: lookup key r data *) apply (lookup_below_false key l data u0). (* Goal: is_below l key *) (* Goal: lookup key r data *) apply (below_trans l k key). (* Goal: is_below (Avl_Node kl0 dl0 ll0 rl0 bl0) k0 *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply is_below_avl_is_below. (* Goal: is_avl l *) (* Goal: is_avl r *) (* Goal: is_balanced_avl l r b *) (* Goal: is_below_avl l k *) (* Goal: is_above_avl r k *) apply (inv_is_avl_left k d l r b avl_t). (* Goal: is_below_avl l k *) (* Goal: is_above_avl r k *) apply (inv_is_avl_is_is_below_avl k d l r b avl_t). (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. Qed. Lemma lookup_avl_equal : forall (k1 k : Int) (t : avl_tree) (d1 d : B), is_avl t -> lookup k1 t d1 -> lookup k t d -> Equal k1 k -> d1 = d. (* Goal: forall (k1 k : Int) (t : avl_tree) (d1 d : B) (_ : is_avl t) (_ : lookup k1 t d1) (_ : lookup k t d) (_ : Equal k1 k), @eq B d1 d *) intros k1 k t d1 d avl_t. (* Goal: forall (_ : lookup k1 t d1) (_ : lookup k t d) (_ : Equal k1 k), @eq B d1 d *) generalize d; clear d. (* Goal: forall (d : B) (_ : lookup k1 t d1) (_ : lookup k t d) (_ : Equal k1 k), @eq B d1 d *) generalize d1; clear d1. (* Goal: forall (d1 d : B) (_ : lookup k1 t d1) (_ : lookup k t d) (_ : Equal k1 k), @eq B d1 d *) generalize k; clear k. (* Goal: forall (k : Int) (d1 d : B) (_ : lookup k1 t d1) (_ : lookup k t d) (_ : Equal k1 k), @eq B d1 d *) generalize k1; clear k1. (* Goal: forall (k1 k : Int) (d1 d : B) (_ : lookup k1 t d1) (_ : lookup k t d) (_ : Equal k1 k), @eq B d1 d *) elim avl_t; clear avl_t. (* Goal: forall (key : Int) (t0 t : avl_tree) (k : Int) (d : B) (_ : equiv_del key t0 t) (_ : not (Equal k key)) (_ : lookup k t d), lookup k t0 d *) intros. (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 r data), lookup k0 (Avl_Node k d Avl_Nil r b) data *) inversion_clear H. intros k0 d0 l r b avl_l ih_l avl_r ih_r Balanced_l below_avl_r above_avl_r k1 k2 d1 d2 lookup_k1. (* Goal: forall (_ : lookup k2 (Avl_Node k0 d0 l r b) d2) (_ : Equal k1 k2), @eq B d1 d2 *) inversion_clear lookup_k1. (* Goal: forall (_ : lookup k2 (Avl_Node k0 d1 l r b) d2) (_ : Equal k0 k2), @eq B d1 d2 *) (* Goal: forall (_ : lookup k2 (Avl_Node k0 d0 l r b) d2) (_ : Equal k1 k2), @eq B d1 d2 *) (* Goal: forall (_ : lookup k2 (Avl_Node k0 d0 l r b) d2) (_ : Equal k1 k2), @eq B d1 d2 *) intros lookup_k0 equal_k1. (* Goal: @eq B d1 d2 *) (* Goal: forall (_ : lookup k2 (Avl_Node k0 d0 l r b) d2) (_ : Equal k1 k2), @eq B d1 d2 *) (* Goal: forall (_ : lookup k2 (Avl_Node k0 d0 l r b) d2) (_ : Equal k1 k2), @eq B d1 d2 *) apply lookup_avl_inv_equal with k2 k0 l r b. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Node_Is_Avl; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply equal_sym; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: forall (_ : lookup k2 (Avl_Node k0 d0 l r b) d2) (_ : Equal k1 k2), @eq B d1 d2 *) intros lookup_k2 equal_k1. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply ih_l with k1 k2; try assumption. (* Goal: lookup k2 l d2 *) (* Goal: forall (_ : lookup k2 (Avl_Node k0 d0 l r b) d2) (_ : Equal k1 k2), @eq B d1 d2 *) apply lookup_avl_inv_less with k0 d0 r b. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Node_Is_Avl; assumption. (* Goal: Less k0 k2 *) (* Goal: lookup k2 (Avl_Node k0 d0 l r b) d2 *) rewrite <- (equal_eq k1 k2 equal_k1). (* Goal: Less k1 k0 *) (* Goal: lookup k2 (Avl_Node k0 d0 l r b) d2 *) (* Goal: forall (_ : lookup k2 (Avl_Node k0 d0 l r b) d2) (_ : Equal k1 k2), @eq B d1 d2 *) apply lookup_below_less with l d1. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply is_below_avl_is_below; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: forall (_ : lookup k2 (Avl_Node k0 d0 l r b) d2) (_ : Equal k1 k2), @eq B d1 d2 *) intros lookup_k2 equal_k1. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply ih_r with k1 k2; try assumption. (* Goal: lookup k2 r d2 *) apply lookup_avl_inv_greater with k0 d0 l b. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Node_Is_Avl; assumption. (* Goal: Less k0 k2 *) (* Goal: lookup k2 (Avl_Node k0 d0 l r b) d2 *) rewrite <- (equal_eq k1 k2 equal_k1). (* Goal: Less k0 k1 *) (* Goal: lookup k2 (Avl_Node k0 d0 l r b) d2 *) apply lookup_above_greater with r d1. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply is_above_avl_is_above; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. Qed. (****************************************************************************) Inductive lookup_dec_spec (key : Int) (t : avl_tree) : Set := | Lookup : forall d : B, lookup key t d -> lookup_dec_spec key t | Not_Lookup : (forall d : B, ~ lookup key t d) -> lookup_dec_spec key t. Lemma lookup_dec : forall (key : Int) (t : avl_tree), is_avl t -> lookup_dec_spec key t. (* Goal: forall (k0 : Int) (_ : is_below_avl t k0), is_below t k0 *) intros key t avl_t; elim avl_t; clear avl_t t. (* Goal: lookup_dec_spec key (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: is_avl t *) (* Goal: lin_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: equiv_ins key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl t) (height_avl (Avl_Node k0 d0 l0 r0 b0))) (@eq nat (height_avl t) (S (height_avl (Avl_Node k0 d0 l0 r0 b0)))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_right_shift l0 r b0) *) apply Not_Lookup. (* Goal: forall d : B, not (lookup key Avl_Nil d) *) (* Goal: forall (k : Int) (d : B) (l r : avl_tree) (b : bal) (_ : is_avl l) (_ : lookup_dec_spec key l) (_ : is_avl r) (_ : lookup_dec_spec key r) (_ : is_balanced_avl l r b) (_ : is_below_avl l k) (_ : is_above_avl r k), lookup_dec_spec key (Avl_Node k d l r b) *) unfold not in |- *; intros d lookup_nil. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply (inv_lookup_nil key d); assumption. (* Goal: forall (k : Int) (d : B) (l r : avl_tree) (b : bal) (_ : is_avl l) (_ : lookup_dec_spec key l) (_ : is_avl r) (_ : lookup_dec_spec key r) (_ : is_balanced_avl l r b) (_ : is_below_avl l k) (_ : is_above_avl r k), lookup_dec_spec key (Avl_Node k d l r b) *) intros k d l r b avl_l ih_l avl_r ih_r Balanced_t below_l above_r. (* Goal: lookup_dec_spec key (Avl_Node k d l r b) *) elim (equal_dec key k). (* Goal: forall _ : Equal key k, lookup_dec_spec key (Avl_Node k d l r b) *) (* Goal: forall _ : not (Equal key k), lookup_dec_spec key (Avl_Node k d l r b) *) intro equal_key_k. (* Goal: lookup_dec_spec key (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: forall _ : forall d : B, not (lookup key r0 d), lookup_dec_spec key (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: is_avl t *) (* Goal: lin_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: equiv_ins key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl t) (height_avl (Avl_Node k0 d0 l0 r0 b0))) (@eq nat (height_avl t) (S (height_avl (Avl_Node k0 d0 l0 r0 b0)))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_right_shift l0 r b0) *) apply Lookup with d. (* Goal: lookup key (Avl_Node k d l r b) d *) (* Goal: forall _ : not (Equal key k), lookup_dec_spec key (Avl_Node k d l r b) *) rewrite (equal_eq key k equal_key_k). (* Goal: lookup k0 (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d0 *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup_Equal. (* Goal: forall _ : not (Equal key k), lookup_dec_spec key (Avl_Node k d l r b) *) intros not_equal_key_k. (* Goal: lookup_dec_spec key (Avl_Node k d l r b) *) elim (less_dec key k). (* Goal: forall _ : Less key k, lookup_dec_spec key (Avl_Node k d l r b) *) (* Goal: forall _ : not (Less key k), lookup_dec_spec key (Avl_Node k d l r b) *) intro less_key_k. (* Goal: lookup_dec_spec key (Avl_Node k d l r b) *) (* Goal: forall _ : not (Less key k), lookup_dec_spec key (Avl_Node k d l r b) *) elim ih_l; clear ih_r ih_l. (* Goal: forall (d0 : B) (_ : lookup key r d0), lookup_dec_spec key (Avl_Node k d l r b) *) (* Goal: forall _ : forall d : B, not (lookup key r d), lookup_dec_spec key (Avl_Node k d l r b) *) intros d0 lookup_d0. (* Goal: lookup_dec_spec key (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: is_avl (Avl_Node k0 (update d0) l0 r0 b0) *) (* Goal: lin_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) (Avl_Node k0 (update d0) l0 r0 b0) *) (* Goal: equiv_ins key update init (Avl_Node k0 d0 l0 r0 b0) (Avl_Node k0 (update d0) l0 r0 b0) *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 (update d0) l0 r0 b0)) (height_avl (Avl_Node k0 d0 l0 r0 b0))) (@eq nat (height_avl (Avl_Node k0 (update d0) l0 r0 b0)) (S (height_avl (Avl_Node k0 d0 l0 r0 b0)))) *) (* Goal: forall _ : not (Equal key k0), avl_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup with d0. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Left; assumption. (* Goal: forall _ : forall d : B, not (lookup key r0 d), lookup_dec_spec key (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: is_avl t *) (* Goal: lin_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: equiv_ins key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl t) (height_avl (Avl_Node k0 d0 l0 r0 b0))) (@eq nat (height_avl t) (S (height_avl (Avl_Node k0 d0 l0 r0 b0)))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_right_shift l0 r b0) *) intros not_lookup_d0. (* Goal: lookup_dec_spec key (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: is_avl t *) (* Goal: lin_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: equiv_ins key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl t) (height_avl (Avl_Node k0 d0 l0 r0 b0))) (@eq nat (height_avl t) (S (height_avl (Avl_Node k0 d0 l0 r0 b0)))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_right_shift l0 r b0) *) apply Not_Lookup. (* Goal: forall (d0 : B) (_ : lookup key r d0), lookup_dec_spec key (Avl_Node k d l r b) *) (* Goal: forall _ : forall d : B, not (lookup key r d), lookup_dec_spec key (Avl_Node k d l r b) *) unfold not in |- *; intros d0 lookup_d0. (* Goal: False *) apply (not_lookup_d0 d0). (* Goal: lookup key l d0 *) (* Goal: forall _ : not (Less key k), lookup_dec_spec key (Avl_Node k d l r b) *) apply (lookup_avl_inv_less key k d l r b). (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Node_Is_Avl; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: forall _ : not (Less key k), lookup_dec_spec key (Avl_Node k d l r b) *) intros not_less. (* Goal: lookup_dec_spec key (Avl_Node k d l r b) *) generalize (notequal_notless_greater key k not_equal_key_k not_less). (* Goal: forall _ : Less k key, lookup_dec_spec key (Avl_Node k d l r b) *) clear not_equal_key_k not_less. (* Goal: forall _ : Less k key, lookup_dec_spec key (Avl_Node k d l r b) *) intros less_k_key. (* Goal: lookup_dec_spec key (Avl_Node k d l r b) *) elim ih_r; clear ih_r ih_l. (* Goal: forall (d0 : B) (_ : lookup key r d0), lookup_dec_spec key (Avl_Node k d l r b) *) (* Goal: forall _ : forall d : B, not (lookup key r d), lookup_dec_spec key (Avl_Node k d l r b) *) intros d0 lookup_d0. (* Goal: lookup_dec_spec key (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: is_avl (Avl_Node k0 (update d0) l0 r0 b0) *) (* Goal: lin_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) (Avl_Node k0 (update d0) l0 r0 b0) *) (* Goal: equiv_ins key update init (Avl_Node k0 d0 l0 r0 b0) (Avl_Node k0 (update d0) l0 r0 b0) *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 (update d0) l0 r0 b0)) (height_avl (Avl_Node k0 d0 l0 r0 b0))) (@eq nat (height_avl (Avl_Node k0 (update d0) l0 r0 b0)) (S (height_avl (Avl_Node k0 d0 l0 r0 b0)))) *) (* Goal: forall _ : not (Equal key k0), avl_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup with d0. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Right; assumption. (* Goal: forall _ : forall d : B, not (lookup key r0 d), lookup_dec_spec key (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: is_avl t *) (* Goal: lin_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: equiv_ins key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl t) (height_avl (Avl_Node k0 d0 l0 r0 b0))) (@eq nat (height_avl t) (S (height_avl (Avl_Node k0 d0 l0 r0 b0)))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_right_shift l0 r b0) *) intros not_lookup_d0. (* Goal: lookup_dec_spec key (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: is_avl t *) (* Goal: lin_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: equiv_ins key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl t) (height_avl (Avl_Node k0 d0 l0 r0 b0))) (@eq nat (height_avl t) (S (height_avl (Avl_Node k0 d0 l0 r0 b0)))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_right_shift l0 r b0) *) apply Not_Lookup. (* Goal: forall (d0 : B) (_ : lookup key r d0), lookup_dec_spec key (Avl_Node k d l r b) *) (* Goal: forall _ : forall d : B, not (lookup key r d), lookup_dec_spec key (Avl_Node k d l r b) *) unfold not in |- *; intros d0 lookup_d0. (* Goal: False *) apply (not_lookup_d0 d0). (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply (lookup_avl_inv_greater key k d l r b); try assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Node_Is_Avl; assumption. Qed. (***************************************************************************) (* equiv *) Fixpoint lin_avl (t : avl_tree) : list (Int * B) := match t with | Avl_Nil => nil (A:=Int * B) | Avl_Node k d l r _ => lin_avl l ++ (k, d) :: lin_avl r end. Inductive equiv : avl_tree -> avl_tree -> Prop := equiv_intro : forall t0 t1 : avl_tree, (forall (key : Int) (data : B), lookup key t0 data -> lookup key t1 data) -> (forall (key : Int) (data : B), lookup key t1 data -> lookup key t0 data) -> equiv t0 t1. Lemma inv_equiv_t0_t1 : forall (t0 t1 : avl_tree) (key : Int) (data : B), equiv t0 t1 -> lookup key t0 data -> lookup key t1 data. (* Goal: forall (key : Int) (t0 t : avl_tree) (k : Int) (d : B) (_ : equiv_del key t0 t) (_ : not (Equal k key)) (_ : lookup k t d), lookup k t0 d *) intros. (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 r data), lookup k0 (Avl_Node k d Avl_Nil r b) data *) inversion_clear H. (* Goal: lookup k0 l0 d1 *) (* Goal: is_below l0 k0 *) (* Goal: False *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k0)) (_ : lookup k1 (Avl_Node k0 d0 l0 r0 b0) data), lookup k1 (Avl_Node k d l r0 b0) data *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k0)) (_ : lookup k1 (Avl_Node k d l r0 b0) data), lookup k1 (Avl_Node k0 d0 l0 r0 b0) data *) apply H1. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. Qed. Lemma inv_equiv_t1_t0 : forall (t0 t1 : avl_tree) (key : Int) (data : B), equiv t0 t1 -> lookup key t1 data -> lookup key t0 data. (* Goal: forall (key : Int) (t0 t : avl_tree) (k : Int) (d : B) (_ : equiv_del key t0 t) (_ : not (Equal k key)) (_ : lookup k t d), lookup k t0 d *) intros. (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 r data), lookup k0 (Avl_Node k d Avl_Nil r b) data *) inversion_clear H. (* Goal: lookup k t2 data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k t2 data), lookup k t0 data *) apply H2. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. Qed. Lemma equiv_sym : forall t t0 : avl_tree, equiv t t0 -> equiv t0 t. (* Goal: forall (t t0 : avl_tree) (_ : equiv t t0), equiv t0 t *) intros t t0 equiv_t_t0. (* Goal: equiv t0 t *) inversion_clear equiv_t_t0. (* Goal: equiv (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced) (Avl_Node k d l (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced) b) *) (* Goal: @eq nat (height_avl (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (height_avl (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced)) *) (* Goal: forall (_ : is_balanced_avl lr rr Balanced) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr lr rr Balanced))), rebalance_right_spec k d l (Avl_Node kr dr lr rr Balanced) b *) (* Goal: forall (_ : is_balanced_avl lr rr Right_Balanced) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr Right_Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr lr rr Right_Balanced))), rebalance_right_spec k d l (Avl_Node kr dr lr rr Right_Balanced) b *) apply equiv_intro. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. Qed. Lemma equiv_refl : forall (k : Int) (d : B) (l r : avl_tree) (b b' : bal), equiv (Avl_Node k d l r b) (Avl_Node k d l r b'). (* Goal: forall (k : Int) (d : B) (l r : avl_tree) (b b' : bal), equiv (Avl_Node k d l r b) (Avl_Node k d l r b') *) intros k d l r b b'. (* Goal: equiv (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced) (Avl_Node k d l (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced) b) *) (* Goal: @eq nat (height_avl (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (height_avl (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced)) *) (* Goal: forall (_ : is_balanced_avl lr rr Balanced) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr lr rr Balanced))), rebalance_right_spec k d l (Avl_Node kr dr lr rr Balanced) b *) (* Goal: forall (_ : is_balanced_avl lr rr Right_Balanced) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr Right_Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr lr rr Right_Balanced))), rebalance_right_spec k d l (Avl_Node kr dr lr rr Right_Balanced) b *) apply equiv_intro. (* Goal: forall (key : Int) (data : B) (_ : lookup key (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced) data), lookup key (Avl_Node k d l (Avl_Node kr dr lr rr Right_Balanced) b) data *) (* Goal: forall (key : Int) (data : B) (_ : lookup key (Avl_Node k d l (Avl_Node kr dr lr rr Right_Balanced) b) data), lookup key (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced) data *) (* Goal: @eq nat (height_avl (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced)) (height_avl (Avl_Node kr dr lr rr Right_Balanced)) *) intros key data lookup_t. (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 r data), lookup k0 (Avl_Node k d Avl_Nil r b) data *) inversion_clear lookup_t. (* Goal: lookup k0 (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d0 *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup_Equal. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Left; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Right; assumption. (* Goal: forall (key : Int) (data : B) (_ : lookup key (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced) data), lookup key (Avl_Node k d l (Avl_Node kr dr lr rr Right_Balanced) b) data *) (* Goal: forall (key : Int) (data : B) (_ : lookup key (Avl_Node k d l (Avl_Node kr dr lr rr Right_Balanced) b) data), lookup key (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced) data *) (* Goal: @eq nat (height_avl (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced)) (height_avl (Avl_Node kr dr lr rr Right_Balanced)) *) intros key data lookup_t. (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 r data), lookup k0 (Avl_Node k d Avl_Nil r b) data *) inversion_clear lookup_t. (* Goal: lookup k0 (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d0 *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup_Equal. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Left; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Right; assumption. Qed. (******************************************************************) Definition rebalance_left_spec (k : Int) (d : B) (l r : avl_tree) (b : bal) : Set := { t : avl_tree | is_avl t /\ lin_avl t = lin_avl (Avl_Node k d l r b) /\ equiv t (Avl_Node k d l r b) /\ match l with | Avl_Nil => True | Avl_Node _ _ _ _ Left_Balanced => height_avl t = height_avl l | Avl_Node _ _ _ _ Balanced => height_avl t = S (height_avl l) | Avl_Node _ _ _ _ Right_Balanced => height_avl t = height_avl l end }. Lemma rebalance_left : forall (k : Int) (d : B) (l r : avl_tree) (b : bal), is_avl l -> is_below_avl l k -> is_avl r -> is_above_avl r k -> height_avl l = S (S (height_avl r)) -> rebalance_left_spec k d l r b. (* Goal: forall (k : Int) (d : B) (l r : avl_tree) (b : bal) (_ : is_avl l) (_ : is_below_avl l k) (_ : is_avl r) (_ : is_above_avl r k) (_ : @eq nat (height_avl l) (S (S (height_avl r)))), rebalance_left_spec k d l r b *) intros k d l r b avl_l below_avl_l avl_r above_avl_r. (* Goal: forall _ : @eq nat (height_avl l) (S (S (height_avl r))), rebalance_left_spec k d l r b *) generalize below_avl_l; clear below_avl_l. (* Goal: forall (_ : is_below_avl l k) (_ : @eq nat (height_avl l) (S (S (height_avl r)))), rebalance_left_spec k d l r b *) elim avl_l; clear avl_l l. (* l=Avl_Nil *) (* Goal: forall (_ : is_below_avl Avl_Nil k) (_ : @eq nat (height_avl Avl_Nil) (S (S (height_avl r)))), rebalance_left_spec k d Avl_Nil r b *) (* Goal: forall (k0 : Int) (d0 : B) (l r0 : avl_tree) (b0 : bal) (_ : is_avl l) (_ : forall (_ : is_below_avl l k) (_ : @eq nat (height_avl l) (S (S (height_avl r)))), rebalance_left_spec k d l r b) (_ : is_avl r0) (_ : forall (_ : is_below_avl r0 k) (_ : @eq nat (height_avl r0) (S (S (height_avl r)))), rebalance_left_spec k d r0 r b) (_ : is_balanced_avl l r0 b0) (_ : is_below_avl l k0) (_ : is_above_avl r0 k0) (_ : is_below_avl (Avl_Node k0 d0 l r0 b0) k) (_ : @eq nat (height_avl (Avl_Node k0 d0 l r0 b0)) (S (S (height_avl r)))), rebalance_left_spec k d (Avl_Node k0 d0 l r0 b0) r b *) intros below_avl_l height_l. (* Goal: rebalance_left_spec k d (Avl_Node kl dl ll Avl_Nil Right_Balanced) r b *) (* Goal: forall (k0 : Int) (d0 : B) (l r0 : avl_tree) (b0 : bal) (_ : is_avl l) (_ : forall (_ : is_balanced_avl ll l Right_Balanced) (_ : is_below_avl ll kl) (_ : is_above_avl l kl) (_ : is_below_avl (Avl_Node kl dl ll l Right_Balanced) k) (_ : @eq nat (S (height_avl l)) (S (S (height_avl r)))), rebalance_left_spec k d (Avl_Node kl dl ll l Right_Balanced) r b) (_ : is_avl r0) (_ : forall (_ : is_balanced_avl ll r0 Right_Balanced) (_ : is_below_avl ll kl) (_ : is_above_avl r0 kl) (_ : is_below_avl (Avl_Node kl dl ll r0 Right_Balanced) k) (_ : @eq nat (S (height_avl r0)) (S (S (height_avl r)))), rebalance_left_spec k d (Avl_Node kl dl ll r0 Right_Balanced) r b) (_ : is_balanced_avl l r0 b0) (_ : is_below_avl l k0) (_ : is_above_avl r0 k0) (_ : is_balanced_avl ll (Avl_Node k0 d0 l r0 b0) Right_Balanced) (_ : is_below_avl ll kl) (_ : is_above_avl (Avl_Node k0 d0 l r0 b0) kl) (_ : is_below_avl (Avl_Node kl dl ll (Avl_Node k0 d0 l r0 b0) Right_Balanced) k) (_ : @eq nat (S match b0 with | Left_Balanced => S (height_avl l) | Balanced => S (height_avl l) | Right_Balanced => S (height_avl r0) end) (S (S (height_avl r)))), rebalance_left_spec k d (Avl_Node kl dl ll (Avl_Node k0 d0 l r0 b0) Right_Balanced) r b *) discriminate height_l. (* l=(Avl_Node kl dl ll rl bl) *) (* Goal: forall (i : Int) (b : B) (a a0 : avl_tree) (b0 : bal) (_ : is_balanced_avl_left_shift (Avl_Node i b a a0 b0) r Left_Balanced) (_ : match b0 with | Left_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node i b a a0 b0)) | Balanced => @eq nat (height_avl t) (S (height_avl (Avl_Node i b a a0 b0))) | Right_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node i b a a0 b0)) end), sumbool (hasnot_shrunk_left t k d (Avl_Node i b a a0 b0) r Left_Balanced) (has_shrunk_left t k d (Avl_Node i b a a0 b0) r Left_Balanced) *) (* Goal: @eq nat (height_avl l) (S (S (height_avl r))) *) (* Goal: bal_shrunk_left_spec k d l r Balanced *) (* Goal: bal_shrunk_left_spec k d l r Right_Balanced *) intros kl dl ll rl bl. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) case bl; clear bl; simpl in |- *. (* bl=Left_Balanced => single LL-rotation *) intros avl_ll ih_ll avl_rl ih_rl Balanced_l below_ll above_rl below_avl_l height_l; injection height_l; clear height_l ih_ll ih_rl; intros height_l. (* Goal: rebalance_left_spec k d (Avl_Node kl dl ll rl Left_Balanced) r b *) (* Goal: forall (_ : is_avl ll) (_ : forall (_ : is_below_avl ll k) (_ : @eq nat (height_avl ll) (S (S (height_avl r)))), rebalance_left_spec k d ll r b) (_ : is_avl rl) (_ : forall (_ : is_below_avl rl k) (_ : @eq nat (height_avl rl) (S (S (height_avl r)))), rebalance_left_spec k d rl r b) (_ : is_balanced_avl ll rl Balanced) (_ : is_below_avl ll kl) (_ : is_above_avl rl kl) (_ : is_below_avl (Avl_Node kl dl ll rl Balanced) k) (_ : @eq nat (S (height_avl ll)) (S (S (height_avl r)))), rebalance_left_spec k d (Avl_Node kl dl ll rl Balanced) r b *) (* Goal: forall (_ : is_avl ll) (_ : forall (_ : is_below_avl ll k) (_ : @eq nat (height_avl ll) (S (S (height_avl r)))), rebalance_left_spec k d ll r b) (_ : is_avl rl) (_ : forall (_ : is_below_avl rl k) (_ : @eq nat (height_avl rl) (S (S (height_avl r)))), rebalance_left_spec k d rl r b) (_ : is_balanced_avl ll rl Right_Balanced) (_ : is_below_avl ll kl) (_ : is_above_avl rl kl) (_ : is_below_avl (Avl_Node kl dl ll rl Right_Balanced) k) (_ : @eq nat (S (height_avl rl)) (S (S (height_avl r)))), rebalance_left_spec k d (Avl_Node kl dl ll rl Right_Balanced) r b *) exists (Avl_Node kl dl ll (Avl_Node k d rl r Balanced) Balanced). (* Goal: and (is_avl (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced)) (and (@eq (list (prod Int B)) (lin_avl (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced)) (lin_avl (Avl_Node k d l (Avl_Node kr dr lr rr Right_Balanced) b))) (and (equiv (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced) (Avl_Node k d l (Avl_Node kr dr lr rr Right_Balanced) b)) (@eq nat (height_avl (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced)) (height_avl (Avl_Node kr dr lr rr Right_Balanced))))) *) repeat apply conj. (* Goal: is_avl (Avl_Node klr dlr (Avl_Node kl dl ll llr match blr with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node k d rlr r match blr with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced) *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node klr dlr (Avl_Node kl dl ll llr match blr with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node k d rlr r match blr with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (lin_avl (Avl_Node k d (Avl_Node kl dl ll (Avl_Node klr dlr llr rlr blr) Right_Balanced) r b)) *) (* Goal: equiv (Avl_Node klr dlr (Avl_Node kl dl ll llr match blr with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node k d rlr r match blr with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced) (Avl_Node k d (Avl_Node kl dl ll (Avl_Node klr dlr llr rlr blr) Right_Balanced) r b) *) (* Goal: @eq nat (height_avl (Avl_Node klr dlr (Avl_Node kl dl ll llr match blr with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node k d rlr r match blr with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (height_avl (Avl_Node kl dl ll (Avl_Node klr dlr llr rlr blr) Right_Balanced)) *) inversion_clear below_avl_l. (* Goal: forall _ : @eq nat match blr with | Left_Balanced => S (height_avl llr) | Balanced => S (height_avl llr) | Right_Balanced => S (height_avl rlr) end (S (height_avl r)), @eq nat (height_avl (Avl_Node klr dlr (Avl_Node kl dl ll llr match blr with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node k d rlr r match blr with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (height_avl (Avl_Node kl dl ll (Avl_Node klr dlr llr rlr blr) Right_Balanced)) *) inversion_clear Balanced_l. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Node_Is_Avl; try assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Node_Is_Avl; try assumption. (* Goal: is_balanced_avl l r Balanced *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node k d l r Balanced)) (lin_avl (Avl_Node k d l r Left_Balanced)) *) (* Goal: equiv (Avl_Node k d l r Balanced) (Avl_Node k d l r Left_Balanced) *) (* Goal: sumbool (hasnot_shrunk_right (Avl_Node k d l r Balanced) k d l r Left_Balanced) (has_shrunk_right (Avl_Node k d l r Balanced) k d l r Left_Balanced) *) (* Goal: bal_shrunk_right_spec k d l r Balanced *) (* Goal: bal_shrunk_right_spec k d l r Right_Balanced *) apply Is_Fully_Balanced_Avl. (* Goal: @eq nat (height_avl rl) (height_avl r) *) (* Goal: is_balanced_avl ll (Avl_Node k d rl r Balanced) Balanced *) (* Goal: is_above_avl (Avl_Node k d rl r Balanced) kl *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node kl dl ll (Avl_Node k d rl r Balanced) Balanced)) (lin_avl (Avl_Node k d (Avl_Node kl dl ll rl Left_Balanced) r b)) *) (* Goal: equiv (Avl_Node kl dl ll (Avl_Node k d rl r Balanced) Balanced) (Avl_Node k d (Avl_Node kl dl ll rl Left_Balanced) r b) *) (* Goal: @eq nat (height_avl (Avl_Node kl dl ll (Avl_Node k d rl r Balanced) Balanced)) (height_avl (Avl_Node kl dl ll rl Left_Balanced)) *) (* Goal: forall (_ : is_avl ll) (_ : forall (_ : is_below_avl ll k) (_ : @eq nat (height_avl ll) (S (S (height_avl r)))), rebalance_left_spec k d ll r b) (_ : is_avl rl) (_ : forall (_ : is_below_avl rl k) (_ : @eq nat (height_avl rl) (S (S (height_avl r)))), rebalance_left_spec k d rl r b) (_ : is_balanced_avl ll rl Balanced) (_ : is_below_avl ll kl) (_ : is_above_avl rl kl) (_ : is_below_avl (Avl_Node kl dl ll rl Balanced) k) (_ : @eq nat (S (height_avl ll)) (S (S (height_avl r)))), rebalance_left_spec k d (Avl_Node kl dl ll rl Balanced) r b *) (* Goal: forall (_ : is_avl ll) (_ : forall (_ : is_below_avl ll k) (_ : @eq nat (height_avl ll) (S (S (height_avl r)))), rebalance_left_spec k d ll r b) (_ : is_avl rl) (_ : forall (_ : is_below_avl rl k) (_ : @eq nat (height_avl rl) (S (S (height_avl r)))), rebalance_left_spec k d rl r b) (_ : is_balanced_avl ll rl Right_Balanced) (_ : is_below_avl ll kl) (_ : is_above_avl rl kl) (_ : is_below_avl (Avl_Node kl dl ll rl Right_Balanced) k) (_ : @eq nat (S (height_avl rl)) (S (S (height_avl r)))), rebalance_left_spec k d (Avl_Node kl dl ll rl Right_Balanced) r b *) rewrite height_l in H1. symmetry in |- *. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) injection H1; trivial. (* Goal: is_balanced_avl l r Balanced *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node k d l r Balanced)) (lin_avl (Avl_Node k d l r Left_Balanced)) *) (* Goal: equiv (Avl_Node k d l r Balanced) (Avl_Node k d l r Left_Balanced) *) (* Goal: sumbool (hasnot_shrunk_right (Avl_Node k d l r Balanced) k d l r Left_Balanced) (has_shrunk_right (Avl_Node k d l r Balanced) k d l r Left_Balanced) *) (* Goal: bal_shrunk_right_spec k d l r Balanced *) (* Goal: bal_shrunk_right_spec k d l r Right_Balanced *) apply Is_Fully_Balanced_Avl. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Above_Avl_Node; assumption. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *. rewrite (app_ass (lin_avl ll) ((kl, dl) :: lin_avl rl) ((k, d) :: lin_avl r)) . (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. (* Goal: equiv (Avl_Node kl dl ll (Avl_Node k d rl r Balanced) Balanced) (Avl_Node k d (Avl_Node kl dl ll rl Left_Balanced) r b) *) (* Goal: @eq nat (height_avl (Avl_Node kl dl ll (Avl_Node k d rl r Balanced) Balanced)) (height_avl (Avl_Node kl dl ll rl Left_Balanced)) *) (* Goal: forall (_ : is_avl ll) (_ : forall (_ : is_below_avl ll k) (_ : @eq nat (height_avl ll) (S (S (height_avl r)))), rebalance_left_spec k d ll r b) (_ : is_avl rl) (_ : forall (_ : is_below_avl rl k) (_ : @eq nat (height_avl rl) (S (S (height_avl r)))), rebalance_left_spec k d rl r b) (_ : is_balanced_avl ll rl Balanced) (_ : is_below_avl ll kl) (_ : is_above_avl rl kl) (_ : is_below_avl (Avl_Node kl dl ll rl Balanced) k) (_ : @eq nat (S (height_avl ll)) (S (S (height_avl r)))), rebalance_left_spec k d (Avl_Node kl dl ll rl Balanced) r b *) (* Goal: forall (_ : is_avl ll) (_ : forall (_ : is_below_avl ll k) (_ : @eq nat (height_avl ll) (S (S (height_avl r)))), rebalance_left_spec k d ll r b) (_ : is_avl rl) (_ : forall (_ : is_below_avl rl k) (_ : @eq nat (height_avl rl) (S (S (height_avl r)))), rebalance_left_spec k d rl r b) (_ : is_balanced_avl ll rl Right_Balanced) (_ : is_below_avl ll kl) (_ : is_above_avl rl kl) (_ : is_below_avl (Avl_Node kl dl ll rl Right_Balanced) k) (_ : @eq nat (S (height_avl rl)) (S (S (height_avl r)))), rebalance_left_spec k d (Avl_Node kl dl ll rl Right_Balanced) r b *) apply equiv_intro; clear avl_ll avl_rl height_l Balanced_l. (* Goal: forall (key : Int) (data : B) (_ : lookup key (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced) data), lookup key (Avl_Node k d l (Avl_Node kr dr lr rr Right_Balanced) b) data *) (* Goal: forall (key : Int) (data : B) (_ : lookup key (Avl_Node k d l (Avl_Node kr dr lr rr Right_Balanced) b) data), lookup key (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced) data *) (* Goal: @eq nat (height_avl (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced)) (height_avl (Avl_Node kr dr lr rr Right_Balanced)) *) intros key data lookup_t. (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 r data), lookup k0 (Avl_Node k d Avl_Nil r b) data *) inversion_clear lookup_t. (* Goal: lookup k0 (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d0 *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup_Left; apply Lookup_Equal. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Left; apply Lookup_Left; assumption. (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 r data), lookup k0 (Avl_Node k d Avl_Nil r b) data *) inversion_clear H. (* Goal: lookup k0 (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d0 *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup_Equal. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Left; apply Lookup_Right; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Right; assumption. (* Goal: forall (key : Int) (data : B) (_ : lookup key (Avl_Node k d l (Avl_Node kr dr lr rr Right_Balanced) b) data), lookup key (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced) data *) (* Goal: @eq nat (height_avl (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced)) (height_avl (Avl_Node kr dr lr rr Right_Balanced)) *) intros key data lookup_t0. (* Goal: False *) (* Goal: equiv_del key Avl_Nil Avl_Nil *) (* Goal: sumbool (@eq nat (height_avl Avl_Nil) (height_avl Avl_Nil)) (@eq nat (height_avl Avl_Nil) (S (height_avl Avl_Nil))) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, delete_spec key a) (a0 : avl_tree) (_ : forall _ : is_avl a0, delete_spec key a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), delete_spec key (Avl_Node i b a a0 b0) *) inversion_clear lookup_t0. (* Goal: lookup k0 (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d0 *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup_Right; apply Lookup_Equal. (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 r data), lookup k0 (Avl_Node k d Avl_Nil r b) data *) inversion_clear H. (* Goal: lookup k0 (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d0 *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup_Equal. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Left; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Right; apply Lookup_Left; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Right; apply Lookup_Right; assumption. (* Goal: forall _ : is_balanced_avl l0 r0 Left_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Left_Balanced)) (S (height_avl l0)) *) (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *; trivial. (* bl=Balanced => single LL-rotation *) intros avl_ll ih_ll avl_rl ih_rl Balanced_l below_ll above_rl below_avl_l height_l; injection height_l; clear height_l ih_ll ih_rl; intros height_l. (* Goal: rebalance_left_spec k d (Avl_Node kl dl ll rl Balanced) r b *) (* Goal: forall (_ : is_avl ll) (_ : forall (_ : is_below_avl ll k) (_ : @eq nat (height_avl ll) (S (S (height_avl r)))), rebalance_left_spec k d ll r b) (_ : is_avl rl) (_ : forall (_ : is_below_avl rl k) (_ : @eq nat (height_avl rl) (S (S (height_avl r)))), rebalance_left_spec k d rl r b) (_ : is_balanced_avl ll rl Right_Balanced) (_ : is_below_avl ll kl) (_ : is_above_avl rl kl) (_ : is_below_avl (Avl_Node kl dl ll rl Right_Balanced) k) (_ : @eq nat (S (height_avl rl)) (S (S (height_avl r)))), rebalance_left_spec k d (Avl_Node kl dl ll rl Right_Balanced) r b *) exists (Avl_Node kl dl ll (Avl_Node k d rl r Left_Balanced) Right_Balanced). (* Goal: and (is_avl (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced)) (and (@eq (list (prod Int B)) (lin_avl (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced)) (lin_avl (Avl_Node k d l (Avl_Node kr dr lr rr Right_Balanced) b))) (and (equiv (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced) (Avl_Node k d l (Avl_Node kr dr lr rr Right_Balanced) b)) (@eq nat (height_avl (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced)) (height_avl (Avl_Node kr dr lr rr Right_Balanced))))) *) repeat apply conj. (* Goal: forall _ : @eq nat match blr with | Left_Balanced => S (height_avl llr) | Balanced => S (height_avl llr) | Right_Balanced => S (height_avl rlr) end (S (height_avl r)), @eq nat (height_avl (Avl_Node klr dlr (Avl_Node kl dl ll llr match blr with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node k d rlr r match blr with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (height_avl (Avl_Node kl dl ll (Avl_Node klr dlr llr rlr blr) Right_Balanced)) *) inversion_clear Balanced_l. (* Goal: is_avl (Avl_Node klr dlr (Avl_Node kl dl ll llr match blr with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node k d rlr r match blr with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced) *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node klr dlr (Avl_Node kl dl ll llr match blr with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node k d rlr r match blr with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (lin_avl (Avl_Node k d (Avl_Node kl dl ll (Avl_Node klr dlr llr rlr blr) Right_Balanced) r b)) *) (* Goal: equiv (Avl_Node klr dlr (Avl_Node kl dl ll llr match blr with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node k d rlr r match blr with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced) (Avl_Node k d (Avl_Node kl dl ll (Avl_Node klr dlr llr rlr blr) Right_Balanced) r b) *) (* Goal: @eq nat (height_avl (Avl_Node klr dlr (Avl_Node kl dl ll llr match blr with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node k d rlr r match blr with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (height_avl (Avl_Node kl dl ll (Avl_Node klr dlr llr rlr blr) Right_Balanced)) *) inversion_clear below_avl_l. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Node_Is_Avl; try assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Node_Is_Avl; try assumption. (* Goal: is_balanced_avl l r Left_Balanced *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node k d l r Left_Balanced)) (lin_avl (Avl_Node k d l r Balanced)) *) (* Goal: equiv (Avl_Node k d l r Left_Balanced) (Avl_Node k d l r Balanced) *) (* Goal: sumbool (hasnot_shrunk_left (Avl_Node k d l r Left_Balanced) k d l r Balanced) (has_shrunk_left (Avl_Node k d l r Left_Balanced) k d l r Balanced) *) (* Goal: bal_shrunk_left_spec k d l r Right_Balanced *) apply Is_Left_Balanced_Avl. (* Goal: @eq nat (height_avl rl) (S (height_avl r)) *) (* Goal: is_balanced_avl ll (Avl_Node k d rl r Left_Balanced) Right_Balanced *) (* Goal: is_above_avl (Avl_Node k d rl r Left_Balanced) kl *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node kl dl ll (Avl_Node k d rl r Left_Balanced) Right_Balanced)) (lin_avl (Avl_Node k d (Avl_Node kl dl ll rl Balanced) r b)) *) (* Goal: equiv (Avl_Node kl dl ll (Avl_Node k d rl r Left_Balanced) Right_Balanced) (Avl_Node k d (Avl_Node kl dl ll rl Balanced) r b) *) (* Goal: @eq nat (height_avl (Avl_Node kl dl ll (Avl_Node k d rl r Left_Balanced) Right_Balanced)) (S (height_avl (Avl_Node kl dl ll rl Balanced))) *) (* Goal: forall (_ : is_avl ll) (_ : forall (_ : is_below_avl ll k) (_ : @eq nat (height_avl ll) (S (S (height_avl r)))), rebalance_left_spec k d ll r b) (_ : is_avl rl) (_ : forall (_ : is_below_avl rl k) (_ : @eq nat (height_avl rl) (S (S (height_avl r)))), rebalance_left_spec k d rl r b) (_ : is_balanced_avl ll rl Right_Balanced) (_ : is_below_avl ll kl) (_ : is_above_avl rl kl) (_ : is_below_avl (Avl_Node kl dl ll rl Right_Balanced) k) (_ : @eq nat (S (height_avl rl)) (S (S (height_avl r)))), rebalance_left_spec k d (Avl_Node kl dl ll rl Right_Balanced) r b *) rewrite <- height_l. symmetry in |- *. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: is_balanced_avl l r Right_Balanced *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node k d l r Right_Balanced)) (lin_avl (Avl_Node k d l r Balanced)) *) (* Goal: equiv (Avl_Node k d l r Right_Balanced) (Avl_Node k d l r Balanced) *) (* Goal: sumbool (hasnot_shrunk_right (Avl_Node k d l r Right_Balanced) k d l r Balanced) (has_shrunk_right (Avl_Node k d l r Right_Balanced) k d l r Balanced) *) (* Goal: bal_shrunk_right_spec k d l r Right_Balanced *) apply Is_Right_Balanced_Avl. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H; trivial. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Above_Avl_Node; assumption. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *. rewrite (app_ass (lin_avl ll) ((kl, dl) :: lin_avl rl) ((k, d) :: lin_avl r)) . (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. (* Goal: equiv (Avl_Node kl dl ll (Avl_Node k d rl r Left_Balanced) Right_Balanced) (Avl_Node k d (Avl_Node kl dl ll rl Balanced) r b) *) (* Goal: @eq nat (height_avl (Avl_Node kl dl ll (Avl_Node k d rl r Left_Balanced) Right_Balanced)) (S (height_avl (Avl_Node kl dl ll rl Balanced))) *) (* Goal: forall (_ : is_avl ll) (_ : forall (_ : is_below_avl ll k) (_ : @eq nat (height_avl ll) (S (S (height_avl r)))), rebalance_left_spec k d ll r b) (_ : is_avl rl) (_ : forall (_ : is_below_avl rl k) (_ : @eq nat (height_avl rl) (S (S (height_avl r)))), rebalance_left_spec k d rl r b) (_ : is_balanced_avl ll rl Right_Balanced) (_ : is_below_avl ll kl) (_ : is_above_avl rl kl) (_ : is_below_avl (Avl_Node kl dl ll rl Right_Balanced) k) (_ : @eq nat (S (height_avl rl)) (S (S (height_avl r)))), rebalance_left_spec k d (Avl_Node kl dl ll rl Right_Balanced) r b *) apply equiv_intro; clear avl_ll avl_rl below_avl_l height_l. (* Goal: forall (key : Int) (data : B) (_ : lookup key (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced) data), lookup key (Avl_Node k d l (Avl_Node kr dr lr rr Right_Balanced) b) data *) (* Goal: forall (key : Int) (data : B) (_ : lookup key (Avl_Node k d l (Avl_Node kr dr lr rr Right_Balanced) b) data), lookup key (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced) data *) (* Goal: @eq nat (height_avl (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced)) (height_avl (Avl_Node kr dr lr rr Right_Balanced)) *) intros key data lookup_t. (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 r data), lookup k0 (Avl_Node k d Avl_Nil r b) data *) inversion_clear lookup_t. (* Goal: lookup k0 (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d0 *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup_Left; apply Lookup_Equal. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Left; apply Lookup_Left; assumption. (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 r data), lookup k0 (Avl_Node k d Avl_Nil r b) data *) inversion_clear H. (* Goal: lookup k0 (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d0 *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup_Equal. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Left; apply Lookup_Right; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Right; assumption. (* Goal: forall (key : Int) (data : B) (_ : lookup key (Avl_Node k d l (Avl_Node kr dr lr rr Right_Balanced) b) data), lookup key (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced) data *) (* Goal: @eq nat (height_avl (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced)) (height_avl (Avl_Node kr dr lr rr Right_Balanced)) *) intros key data lookup_t0. (* Goal: False *) (* Goal: equiv_del key Avl_Nil Avl_Nil *) (* Goal: sumbool (@eq nat (height_avl Avl_Nil) (height_avl Avl_Nil)) (@eq nat (height_avl Avl_Nil) (S (height_avl Avl_Nil))) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, delete_spec key a) (a0 : avl_tree) (_ : forall _ : is_avl a0, delete_spec key a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), delete_spec key (Avl_Node i b a a0 b0) *) inversion_clear lookup_t0. (* Goal: lookup k0 (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d0 *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup_Right; apply Lookup_Equal. (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 r data), lookup k0 (Avl_Node k d Avl_Nil r b) data *) inversion_clear H. (* Goal: lookup k0 (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d0 *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup_Equal. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Left; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Right; apply Lookup_Left; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Right; apply Lookup_Right; assumption. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *. (* Goal: forall _ : @eq nat match blr with | Left_Balanced => S (height_avl llr) | Balanced => S (height_avl llr) | Right_Balanced => S (height_avl rlr) end (S (height_avl r)), @eq nat (height_avl (Avl_Node klr dlr (Avl_Node kl dl ll llr match blr with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node k d rlr r match blr with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (height_avl (Avl_Node kl dl ll (Avl_Node klr dlr llr rlr blr) Right_Balanced)) *) inversion_clear Balanced_l. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H; trivial. (* bl=Right_Balanced => double LR-rotation *) (* Goal: forall (_ : is_avl ll) (_ : forall (_ : is_below_avl ll k) (_ : @eq nat (height_avl ll) (S (S (height_avl r)))), rebalance_left_spec k d ll r b) (_ : is_avl rl) (_ : forall (_ : is_below_avl rl k) (_ : @eq nat (height_avl rl) (S (S (height_avl r)))), rebalance_left_spec k d rl r b) (_ : is_balanced_avl ll rl Right_Balanced) (_ : is_below_avl ll kl) (_ : is_above_avl rl kl) (_ : is_below_avl (Avl_Node kl dl ll rl Right_Balanced) k) (_ : @eq nat (S (height_avl rl)) (S (S (height_avl r)))), rebalance_left_spec k d (Avl_Node kl dl ll rl Right_Balanced) r b *) intros avl_ll ih_ll avl_rl ih_rl; clear ih_ll ih_rl. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) elim avl_rl; clear avl_rl rl; simpl in |- *. (* Goal: forall (_ : is_balanced_avl ll Avl_Nil Right_Balanced) (_ : is_below_avl ll kl) (_ : is_above_avl Avl_Nil kl) (_ : is_below_avl (Avl_Node kl dl ll Avl_Nil Right_Balanced) k) (_ : @eq nat (S O) (S (S (height_avl r)))), rebalance_left_spec k d (Avl_Node kl dl ll Avl_Nil Right_Balanced) r b *) (* Goal: forall (k0 : Int) (d0 : B) (l r0 : avl_tree) (b0 : bal) (_ : is_avl l) (_ : forall (_ : is_balanced_avl ll l Right_Balanced) (_ : is_below_avl ll kl) (_ : is_above_avl l kl) (_ : is_below_avl (Avl_Node kl dl ll l Right_Balanced) k) (_ : @eq nat (S (height_avl l)) (S (S (height_avl r)))), rebalance_left_spec k d (Avl_Node kl dl ll l Right_Balanced) r b) (_ : is_avl r0) (_ : forall (_ : is_balanced_avl ll r0 Right_Balanced) (_ : is_below_avl ll kl) (_ : is_above_avl r0 kl) (_ : is_below_avl (Avl_Node kl dl ll r0 Right_Balanced) k) (_ : @eq nat (S (height_avl r0)) (S (S (height_avl r)))), rebalance_left_spec k d (Avl_Node kl dl ll r0 Right_Balanced) r b) (_ : is_balanced_avl l r0 b0) (_ : is_below_avl l k0) (_ : is_above_avl r0 k0) (_ : is_balanced_avl ll (Avl_Node k0 d0 l r0 b0) Right_Balanced) (_ : is_below_avl ll kl) (_ : is_above_avl (Avl_Node k0 d0 l r0 b0) kl) (_ : is_below_avl (Avl_Node kl dl ll (Avl_Node k0 d0 l r0 b0) Right_Balanced) k) (_ : @eq nat (S match b0 with | Left_Balanced => S (height_avl l) | Balanced => S (height_avl l) | Right_Balanced => S (height_avl r0) end) (S (S (height_avl r)))), rebalance_left_spec k d (Avl_Node kl dl ll (Avl_Node k0 d0 l r0 b0) Right_Balanced) r b *) intros Balanced_l below_ll above_l below_avl_l height_l. (* Goal: rebalance_left_spec k d (Avl_Node kl dl ll Avl_Nil Right_Balanced) r b *) (* Goal: forall (k0 : Int) (d0 : B) (l r0 : avl_tree) (b0 : bal) (_ : is_avl l) (_ : forall (_ : is_balanced_avl ll l Right_Balanced) (_ : is_below_avl ll kl) (_ : is_above_avl l kl) (_ : is_below_avl (Avl_Node kl dl ll l Right_Balanced) k) (_ : @eq nat (S (height_avl l)) (S (S (height_avl r)))), rebalance_left_spec k d (Avl_Node kl dl ll l Right_Balanced) r b) (_ : is_avl r0) (_ : forall (_ : is_balanced_avl ll r0 Right_Balanced) (_ : is_below_avl ll kl) (_ : is_above_avl r0 kl) (_ : is_below_avl (Avl_Node kl dl ll r0 Right_Balanced) k) (_ : @eq nat (S (height_avl r0)) (S (S (height_avl r)))), rebalance_left_spec k d (Avl_Node kl dl ll r0 Right_Balanced) r b) (_ : is_balanced_avl l r0 b0) (_ : is_below_avl l k0) (_ : is_above_avl r0 k0) (_ : is_balanced_avl ll (Avl_Node k0 d0 l r0 b0) Right_Balanced) (_ : is_below_avl ll kl) (_ : is_above_avl (Avl_Node k0 d0 l r0 b0) kl) (_ : is_below_avl (Avl_Node kl dl ll (Avl_Node k0 d0 l r0 b0) Right_Balanced) k) (_ : @eq nat (S match b0 with | Left_Balanced => S (height_avl l) | Balanced => S (height_avl l) | Right_Balanced => S (height_avl r0) end) (S (S (height_avl r)))), rebalance_left_spec k d (Avl_Node kl dl ll (Avl_Node k0 d0 l r0 b0) Right_Balanced) r b *) discriminate height_l. (* Goal: forall (k0 : Int) (d0 : B) (l r0 : avl_tree) (b0 : bal) (_ : is_avl l) (_ : forall (_ : is_balanced_avl ll l Right_Balanced) (_ : is_below_avl ll kl) (_ : is_above_avl l kl) (_ : is_below_avl (Avl_Node kl dl ll l Right_Balanced) k) (_ : @eq nat (S (height_avl l)) (S (S (height_avl r)))), rebalance_left_spec k d (Avl_Node kl dl ll l Right_Balanced) r b) (_ : is_avl r0) (_ : forall (_ : is_balanced_avl ll r0 Right_Balanced) (_ : is_below_avl ll kl) (_ : is_above_avl r0 kl) (_ : is_below_avl (Avl_Node kl dl ll r0 Right_Balanced) k) (_ : @eq nat (S (height_avl r0)) (S (S (height_avl r)))), rebalance_left_spec k d (Avl_Node kl dl ll r0 Right_Balanced) r b) (_ : is_balanced_avl l r0 b0) (_ : is_below_avl l k0) (_ : is_above_avl r0 k0) (_ : is_balanced_avl ll (Avl_Node k0 d0 l r0 b0) Right_Balanced) (_ : is_below_avl ll kl) (_ : is_above_avl (Avl_Node k0 d0 l r0 b0) kl) (_ : is_below_avl (Avl_Node kl dl ll (Avl_Node k0 d0 l r0 b0) Right_Balanced) k) (_ : @eq nat (S match b0 with | Left_Balanced => S (height_avl l) | Balanced => S (height_avl l) | Right_Balanced => S (height_avl r0) end) (S (S (height_avl r)))), rebalance_left_spec k d (Avl_Node kl dl ll (Avl_Node k0 d0 l r0 b0) Right_Balanced) r b *) intros klr dlr llr rlr blr avl_llr ih_llr avl_rlr ih_rlr; clear ih_llr ih_rlr. intros Balanced_rl below_llr above_rlr Balanced_l below_ll above_lr below_avl_l height_l. (* Goal: rebalance_left_spec k d (Avl_Node kl dl ll (Avl_Node klr dlr llr rlr blr) Right_Balanced) r b *) injection height_l; clear height_l; intros height_l. exists (Avl_Node klr dlr (Avl_Node kl dl ll llr match blr with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node k d rlr r match blr with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced). (* Goal: and (is_avl (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced)) (and (@eq (list (prod Int B)) (lin_avl (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced)) (lin_avl (Avl_Node k d l (Avl_Node kr dr lr rr Right_Balanced) b))) (and (equiv (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced) (Avl_Node k d l (Avl_Node kr dr lr rr Right_Balanced) b)) (@eq nat (height_avl (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced)) (height_avl (Avl_Node kr dr lr rr Right_Balanced))))) *) repeat apply conj. (* Goal: forall _ : @eq nat match blr with | Left_Balanced => S (height_avl llr) | Balanced => S (height_avl llr) | Right_Balanced => S (height_avl rlr) end (S (height_avl r)), @eq nat (height_avl (Avl_Node klr dlr (Avl_Node kl dl ll llr match blr with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node k d rlr r match blr with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (height_avl (Avl_Node kl dl ll (Avl_Node klr dlr llr rlr blr) Right_Balanced)) *) inversion_clear Balanced_l. (* Goal: is_avl (Avl_Node klr dlr (Avl_Node kl dl ll llr match blr with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node k d rlr r match blr with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced) *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node klr dlr (Avl_Node kl dl ll llr match blr with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node k d rlr r match blr with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (lin_avl (Avl_Node k d (Avl_Node kl dl ll (Avl_Node klr dlr llr rlr blr) Right_Balanced) r b)) *) (* Goal: equiv (Avl_Node klr dlr (Avl_Node kl dl ll llr match blr with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node k d rlr r match blr with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced) (Avl_Node k d (Avl_Node kl dl ll (Avl_Node klr dlr llr rlr blr) Right_Balanced) r b) *) (* Goal: @eq nat (height_avl (Avl_Node klr dlr (Avl_Node kl dl ll llr match blr with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node k d rlr r match blr with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (height_avl (Avl_Node kl dl ll (Avl_Node klr dlr llr rlr blr) Right_Balanced)) *) inversion_clear above_lr. (* Goal: is_avl (Avl_Node klr dlr (Avl_Node kl dl ll llr match blr with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node k d rlr r match blr with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced) *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node klr dlr (Avl_Node kl dl ll llr match blr with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node k d rlr r match blr with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (lin_avl (Avl_Node k d (Avl_Node kl dl ll (Avl_Node klr dlr llr rlr blr) Right_Balanced) r b)) *) (* Goal: equiv (Avl_Node klr dlr (Avl_Node kl dl ll llr match blr with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node k d rlr r match blr with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced) (Avl_Node k d (Avl_Node kl dl ll (Avl_Node klr dlr llr rlr blr) Right_Balanced) r b) *) (* Goal: @eq nat (height_avl (Avl_Node klr dlr (Avl_Node kl dl ll llr match blr with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node k d rlr r match blr with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (height_avl (Avl_Node kl dl ll (Avl_Node klr dlr llr rlr blr) Right_Balanced)) *) inversion_clear below_avl_l. (* Goal: is_avl (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced) *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (lin_avl (Avl_Node k d l (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced) b)) *) (* Goal: equiv (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced) (Avl_Node k d l (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced) b) *) (* Goal: @eq nat (height_avl (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (height_avl (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced)) *) (* Goal: forall (_ : is_balanced_avl lr rr Balanced) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr lr rr Balanced))), rebalance_right_spec k d l (Avl_Node kr dr lr rr Balanced) b *) (* Goal: forall (_ : is_balanced_avl lr rr Right_Balanced) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr Right_Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr lr rr Right_Balanced))), rebalance_right_spec k d l (Avl_Node kr dr lr rr Right_Balanced) b *) inversion_clear H3. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Node_Is_Avl; try assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Node_Is_Avl; try assumption. (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node klr dlr (Avl_Node kl dl ll llr match blr with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node k d rlr r match blr with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (lin_avl (Avl_Node k d (Avl_Node kl dl ll (Avl_Node klr dlr llr rlr blr) Right_Balanced) r b)) *) (* Goal: equiv (Avl_Node klr dlr (Avl_Node kl dl ll llr match blr with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node k d rlr r match blr with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced) (Avl_Node k d (Avl_Node kl dl ll (Avl_Node klr dlr llr rlr blr) Right_Balanced) r b) *) (* Goal: @eq nat (height_avl (Avl_Node klr dlr (Avl_Node kl dl ll llr match blr with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node k d rlr r match blr with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (height_avl (Avl_Node kl dl ll (Avl_Node klr dlr llr rlr blr) Right_Balanced)) *) clear height_l. (* Goal: forall _ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced)), @eq nat (height_avl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end)) (height_avl (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end)) *) (* Goal: is_below_avl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) krl *) (* Goal: is_above_avl (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) krl *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (lin_avl (Avl_Node k d l (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced) b)) *) (* Goal: equiv (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced) (Avl_Node k d l (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced) b) *) (* Goal: @eq nat (height_avl (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (height_avl (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced)) *) (* Goal: forall (_ : is_balanced_avl lr rr Balanced) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr lr rr Balanced))), rebalance_right_spec k d l (Avl_Node kr dr lr rr Balanced) b *) (* Goal: forall (_ : is_balanced_avl lr rr Right_Balanced) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr Right_Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr lr rr Right_Balanced))), rebalance_right_spec k d l (Avl_Node kr dr lr rr Right_Balanced) b *) generalize H; clear H. (* Goal: forall (key : Int) (t0 t : avl_tree) (k : Int) (d : B) (_ : equiv_del key t0 t) (_ : not (Equal k key)) (_ : lookup k t d), lookup k t0 d *) inversion_clear Balanced_rl; simpl in |- *; intros. (* Goal: is_balanced_avl l r Balanced *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node k d l r Balanced)) (lin_avl (Avl_Node k d l r Left_Balanced)) *) (* Goal: equiv (Avl_Node k d l r Balanced) (Avl_Node k d l r Left_Balanced) *) (* Goal: sumbool (hasnot_shrunk_right (Avl_Node k d l r Balanced) k d l r Left_Balanced) (has_shrunk_right (Avl_Node k d l r Balanced) k d l r Left_Balanced) *) (* Goal: bal_shrunk_right_spec k d l r Balanced *) (* Goal: bal_shrunk_right_spec k d l r Right_Balanced *) apply Is_Fully_Balanced_Avl. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) injection H3; trivial. (* Goal: is_balanced_avl l r Balanced *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node k d l r Balanced)) (lin_avl (Avl_Node k d l r Left_Balanced)) *) (* Goal: equiv (Avl_Node k d l r Balanced) (Avl_Node k d l r Left_Balanced) *) (* Goal: sumbool (hasnot_shrunk_right (Avl_Node k d l r Balanced) k d l r Left_Balanced) (has_shrunk_right (Avl_Node k d l r Balanced) k d l r Left_Balanced) *) (* Goal: bal_shrunk_right_spec k d l r Balanced *) (* Goal: bal_shrunk_right_spec k d l r Right_Balanced *) apply Is_Fully_Balanced_Avl. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) injection H3; trivial. (* Goal: is_balanced_avl l r Left_Balanced *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node k d l r Left_Balanced)) (lin_avl (Avl_Node k d l r Balanced)) *) (* Goal: equiv (Avl_Node k d l r Left_Balanced) (Avl_Node k d l r Balanced) *) (* Goal: sumbool (hasnot_shrunk_left (Avl_Node k d l r Left_Balanced) k d l r Balanced) (has_shrunk_left (Avl_Node k d l r Left_Balanced) k d l r Balanced) *) (* Goal: bal_shrunk_left_spec k d l r Right_Balanced *) apply Is_Left_Balanced_Avl. (* Goal: @eq nat (height_avl ll) (S (height_avl llr)) *) (* Goal: is_avl (Avl_Node k d rlr r match blr with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) *) (* Goal: is_balanced_avl (Avl_Node kl dl ll llr match blr with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node k d rlr r match blr with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced *) (* Goal: is_below_avl (Avl_Node kl dl ll llr match blr with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) klr *) (* Goal: is_above_avl (Avl_Node k d rlr r match blr with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) klr *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node klr dlr (Avl_Node kl dl ll llr match blr with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node k d rlr r match blr with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (lin_avl (Avl_Node k d (Avl_Node kl dl ll (Avl_Node klr dlr llr rlr blr) Right_Balanced) r b)) *) (* Goal: equiv (Avl_Node klr dlr (Avl_Node kl dl ll llr match blr with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node k d rlr r match blr with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced) (Avl_Node k d (Avl_Node kl dl ll (Avl_Node klr dlr llr rlr blr) Right_Balanced) r b) *) (* Goal: @eq nat (height_avl (Avl_Node klr dlr (Avl_Node kl dl ll llr match blr with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node k d rlr r match blr with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (height_avl (Avl_Node kl dl ll (Avl_Node klr dlr llr rlr blr) Right_Balanced)) *) rewrite <- H in H3. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) injection H3; trivial. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Node_Is_Avl; try assumption. (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node klr dlr (Avl_Node kl dl ll llr match blr with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node k d rlr r match blr with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (lin_avl (Avl_Node k d (Avl_Node kl dl ll (Avl_Node klr dlr llr rlr blr) Right_Balanced) r b)) *) (* Goal: equiv (Avl_Node klr dlr (Avl_Node kl dl ll llr match blr with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node k d rlr r match blr with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced) (Avl_Node k d (Avl_Node kl dl ll (Avl_Node klr dlr llr rlr blr) Right_Balanced) r b) *) (* Goal: @eq nat (height_avl (Avl_Node klr dlr (Avl_Node kl dl ll llr match blr with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node k d rlr r match blr with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (height_avl (Avl_Node kl dl ll (Avl_Node klr dlr llr rlr blr) Right_Balanced)) *) generalize height_l; clear height_l. (* Goal: forall _ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced)), @eq nat (height_avl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end)) (height_avl (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end)) *) (* Goal: is_below_avl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) krl *) (* Goal: is_above_avl (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) krl *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (lin_avl (Avl_Node k d l (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced) b)) *) (* Goal: equiv (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced) (Avl_Node k d l (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced) b) *) (* Goal: @eq nat (height_avl (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (height_avl (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced)) *) (* Goal: forall (_ : is_balanced_avl lr rr Balanced) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr lr rr Balanced))), rebalance_right_spec k d l (Avl_Node kr dr lr rr Balanced) b *) (* Goal: forall (_ : is_balanced_avl lr rr Right_Balanced) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr Right_Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr lr rr Right_Balanced))), rebalance_right_spec k d l (Avl_Node kr dr lr rr Right_Balanced) b *) generalize H; clear H. (* Goal: forall (key : Int) (t0 t : avl_tree) (k : Int) (d : B) (_ : equiv_del key t0 t) (_ : not (Equal k key)) (_ : lookup k t d), lookup k t0 d *) inversion_clear Balanced_rl; simpl in |- *; intros. (* Goal: is_balanced_avl l r Right_Balanced *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node k d l r Right_Balanced)) (lin_avl (Avl_Node k d l r Balanced)) *) (* Goal: equiv (Avl_Node k d l r Right_Balanced) (Avl_Node k d l r Balanced) *) (* Goal: sumbool (hasnot_shrunk_right (Avl_Node k d l r Right_Balanced) k d l r Balanced) (has_shrunk_right (Avl_Node k d l r Right_Balanced) k d l r Balanced) *) (* Goal: bal_shrunk_right_spec k d l r Right_Balanced *) apply Is_Right_Balanced_Avl. (* Goal: @eq nat (S match bl0 with | Left_Balanced => S (height_avl ll0) | Balanced => S (height_avl ll0) | Right_Balanced => S (height_avl rl0) end) (S (height_avl r0)) *) (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced, @eq nat (S (height_avl r0)) (S (height_avl r0)) *) (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Balanced, @eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Balanced)) (height_avl t) *) (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced)) (height_avl t) *) (* Goal: forall _ : has_shrunk_right t k d l r0 b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) rewrite <- H. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) injection height_l; trivial. (* Goal: is_balanced_avl l r Balanced *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node k d l r Balanced)) (lin_avl (Avl_Node k d l r Left_Balanced)) *) (* Goal: equiv (Avl_Node k d l r Balanced) (Avl_Node k d l r Left_Balanced) *) (* Goal: sumbool (hasnot_shrunk_right (Avl_Node k d l r Balanced) k d l r Left_Balanced) (has_shrunk_right (Avl_Node k d l r Balanced) k d l r Left_Balanced) *) (* Goal: bal_shrunk_right_spec k d l r Balanced *) (* Goal: bal_shrunk_right_spec k d l r Right_Balanced *) apply Is_Fully_Balanced_Avl. (* Goal: @eq nat (S match bl0 with | Left_Balanced => S (height_avl ll0) | Balanced => S (height_avl ll0) | Right_Balanced => S (height_avl rl0) end) (S (height_avl r0)) *) (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced, @eq nat (S (height_avl r0)) (S (height_avl r0)) *) (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Balanced, @eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Balanced)) (height_avl t) *) (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced)) (height_avl t) *) (* Goal: forall _ : has_shrunk_right t k d l r0 b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) rewrite <- H. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) injection height_l; trivial. (* Goal: is_balanced_avl l r Balanced *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node k d l r Balanced)) (lin_avl (Avl_Node k d l r Left_Balanced)) *) (* Goal: equiv (Avl_Node k d l r Balanced) (Avl_Node k d l r Left_Balanced) *) (* Goal: sumbool (hasnot_shrunk_right (Avl_Node k d l r Balanced) k d l r Left_Balanced) (has_shrunk_right (Avl_Node k d l r Balanced) k d l r Left_Balanced) *) (* Goal: bal_shrunk_right_spec k d l r Balanced *) (* Goal: bal_shrunk_right_spec k d l r Right_Balanced *) apply Is_Fully_Balanced_Avl. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) injection height_l; trivial. (* Goal: is_balanced_avl l r Balanced *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node k d l r Balanced)) (lin_avl (Avl_Node k d l r Left_Balanced)) *) (* Goal: equiv (Avl_Node k d l r Balanced) (Avl_Node k d l r Left_Balanced) *) (* Goal: sumbool (hasnot_shrunk_right (Avl_Node k d l r Balanced) k d l r Left_Balanced) (has_shrunk_right (Avl_Node k d l r Balanced) k d l r Left_Balanced) *) (* Goal: bal_shrunk_right_spec k d l r Balanced *) (* Goal: bal_shrunk_right_spec k d l r Right_Balanced *) apply Is_Fully_Balanced_Avl. (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node klr dlr (Avl_Node kl dl ll llr match blr with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node k d rlr r match blr with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (lin_avl (Avl_Node k d (Avl_Node kl dl ll (Avl_Node klr dlr llr rlr blr) Right_Balanced) r b)) *) (* Goal: equiv (Avl_Node klr dlr (Avl_Node kl dl ll llr match blr with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node k d rlr r match blr with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced) (Avl_Node k d (Avl_Node kl dl ll (Avl_Node klr dlr llr rlr blr) Right_Balanced) r b) *) (* Goal: @eq nat (height_avl (Avl_Node klr dlr (Avl_Node kl dl ll llr match blr with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node k d rlr r match blr with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (height_avl (Avl_Node kl dl ll (Avl_Node klr dlr llr rlr blr) Right_Balanced)) *) generalize height_l; clear height_l. (* Goal: forall _ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced)), @eq nat (height_avl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end)) (height_avl (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end)) *) (* Goal: is_below_avl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) krl *) (* Goal: is_above_avl (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) krl *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (lin_avl (Avl_Node k d l (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced) b)) *) (* Goal: equiv (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced) (Avl_Node k d l (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced) b) *) (* Goal: @eq nat (height_avl (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (height_avl (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced)) *) (* Goal: forall (_ : is_balanced_avl lr rr Balanced) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr lr rr Balanced))), rebalance_right_spec k d l (Avl_Node kr dr lr rr Balanced) b *) (* Goal: forall (_ : is_balanced_avl lr rr Right_Balanced) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr Right_Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr lr rr Right_Balanced))), rebalance_right_spec k d l (Avl_Node kr dr lr rr Right_Balanced) b *) generalize H; clear H. (* Goal: forall (key : Int) (t0 t : avl_tree) (k : Int) (d : B) (_ : equiv_del key t0 t) (_ : not (Equal k key)) (_ : lookup k t d), lookup k t0 d *) inversion_clear Balanced_rl; clear blr; simpl in |- *; intros. (* Goal: @eq nat (S (height_avl ll)) (S (height_avl r)) *) (* Goal: @eq nat (S (height_avl ll)) (S (height_avl rlr)) *) (* Goal: @eq nat (S (height_avl ll)) (S (height_avl rlr)) *) (* Goal: is_below_avl (Avl_Node kl dl ll llr match blr with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) klr *) (* Goal: is_above_avl (Avl_Node k d rlr r match blr with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) klr *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node klr dlr (Avl_Node kl dl ll llr match blr with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node k d rlr r match blr with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (lin_avl (Avl_Node k d (Avl_Node kl dl ll (Avl_Node klr dlr llr rlr blr) Right_Balanced) r b)) *) (* Goal: equiv (Avl_Node klr dlr (Avl_Node kl dl ll llr match blr with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node k d rlr r match blr with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced) (Avl_Node k d (Avl_Node kl dl ll (Avl_Node klr dlr llr rlr blr) Right_Balanced) r b) *) (* Goal: @eq nat (height_avl (Avl_Node klr dlr (Avl_Node kl dl ll llr match blr with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node k d rlr r match blr with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (height_avl (Avl_Node kl dl ll (Avl_Node klr dlr llr rlr blr) Right_Balanced)) *) rewrite H3. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: @eq nat (S match bl0 with | Left_Balanced => S (height_avl ll0) | Balanced => S (height_avl ll0) | Right_Balanced => S (height_avl rl0) end) (S (height_avl r0)) *) (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced, @eq nat (S (height_avl r0)) (S (height_avl r0)) *) (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Balanced, @eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Balanced)) (height_avl t) *) (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced)) (height_avl t) *) (* Goal: forall _ : has_shrunk_right t k d l r0 b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) rewrite <- H. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Below_Avl_Node; try assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Above_Avl_Node; try assumption. (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node klr dlr (Avl_Node kl dl ll llr match blr with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node k d rlr r match blr with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (lin_avl (Avl_Node k d (Avl_Node kl dl ll (Avl_Node klr dlr llr rlr blr) Right_Balanced) r b)) *) (* Goal: equiv (Avl_Node klr dlr (Avl_Node kl dl ll llr match blr with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node k d rlr r match blr with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced) (Avl_Node k d (Avl_Node kl dl ll (Avl_Node klr dlr llr rlr blr) Right_Balanced) r b) *) (* Goal: @eq nat (height_avl (Avl_Node klr dlr (Avl_Node kl dl ll llr match blr with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node k d rlr r match blr with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (height_avl (Avl_Node kl dl ll (Avl_Node klr dlr llr rlr blr) Right_Balanced)) *) clear height_l. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *. rewrite (app_ass (lin_avl ll) ((kl, dl) :: lin_avl llr) ((klr, dlr) :: lin_avl rlr ++ (k, d) :: lin_avl r)) . rewrite (app_ass (lin_avl ll) ((kl, dl) :: lin_avl llr ++ (klr, dlr) :: lin_avl rlr) ((k, d) :: lin_avl r)). (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *. rewrite (app_ass (lin_avl llr) ((klr, dlr) :: lin_avl rlr) ((k, d) :: lin_avl r)) . (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. (* Goal: equiv (Avl_Node klr dlr (Avl_Node kl dl ll llr match blr with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node k d rlr r match blr with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced) (Avl_Node k d (Avl_Node kl dl ll (Avl_Node klr dlr llr rlr blr) Right_Balanced) r b) *) (* Goal: @eq nat (height_avl (Avl_Node klr dlr (Avl_Node kl dl ll llr match blr with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node k d rlr r match blr with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (height_avl (Avl_Node kl dl ll (Avl_Node klr dlr llr rlr blr) Right_Balanced)) *) apply equiv_intro; clear avl_ll avl_llr avl_rlr below_avl_l height_l. (* Goal: forall (key : Int) (data : B) (_ : lookup key (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced) data), lookup key (Avl_Node k d l (Avl_Node kr dr lr rr Right_Balanced) b) data *) (* Goal: forall (key : Int) (data : B) (_ : lookup key (Avl_Node k d l (Avl_Node kr dr lr rr Right_Balanced) b) data), lookup key (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced) data *) (* Goal: @eq nat (height_avl (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced)) (height_avl (Avl_Node kr dr lr rr Right_Balanced)) *) intros key data lookup_t. (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 r data), lookup k0 (Avl_Node k d Avl_Nil r b) data *) inversion_clear lookup_t. (* Goal: lookup k0 (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d0 *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup_Left; apply Lookup_Right; apply Lookup_Equal. (* Goal: lookup k1 (Avl_Node k0 d0 l0 r0 b0) d1 *) (* Goal: lookup k1 (Avl_Node k0 d0 l0 r0 b0) d1 *) apply Lookup_Left. (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 r data), lookup k0 (Avl_Node k d Avl_Nil r b) data *) inversion_clear H. (* Goal: lookup k0 (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d0 *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup_Equal. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Left; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Right; apply Lookup_Left; assumption. (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 r data), lookup k0 (Avl_Node k d Avl_Nil r b) data *) inversion_clear H. (* Goal: lookup k0 (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d0 *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup_Equal. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Left; apply Lookup_Right; apply Lookup_Right; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Right; assumption. (* Goal: forall (key : Int) (data : B) (_ : lookup key (Avl_Node k d l (Avl_Node kr dr lr rr Right_Balanced) b) data), lookup key (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced) data *) (* Goal: @eq nat (height_avl (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced)) (height_avl (Avl_Node kr dr lr rr Right_Balanced)) *) intros key data lookup_t0. (* Goal: False *) (* Goal: equiv_del key Avl_Nil Avl_Nil *) (* Goal: sumbool (@eq nat (height_avl Avl_Nil) (height_avl Avl_Nil)) (@eq nat (height_avl Avl_Nil) (S (height_avl Avl_Nil))) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, delete_spec key a) (a0 : avl_tree) (_ : forall _ : is_avl a0, delete_spec key a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), delete_spec key (Avl_Node i b a a0 b0) *) inversion_clear lookup_t0. (* Goal: lookup k0 (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d0 *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup_Right; apply Lookup_Equal. (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 r data), lookup k0 (Avl_Node k d Avl_Nil r b) data *) inversion_clear H. (* Goal: lookup k0 (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d0 *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup_Left; apply Lookup_Equal. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Left; apply Lookup_Left; assumption. (* Goal: lookup key (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced) data *) (* Goal: lookup key (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced) data *) (* Goal: @eq nat (height_avl (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (height_avl (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced)) *) (* Goal: forall (_ : is_balanced_avl lr rr Balanced) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr lr rr Balanced))), rebalance_right_spec k d l (Avl_Node kr dr lr rr Balanced) b *) (* Goal: forall (_ : is_balanced_avl lr rr Right_Balanced) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr Right_Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr lr rr Right_Balanced))), rebalance_right_spec k d l (Avl_Node kr dr lr rr Right_Balanced) b *) inversion_clear H0. (* Goal: lookup k0 (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d0 *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup_Equal. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Left; apply Lookup_Right; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Right; apply Lookup_Left; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Right; apply Lookup_Right; assumption. (* Goal: @eq nat (height_avl (Avl_Node klr dlr (Avl_Node kl dl ll llr match blr with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node k d rlr r match blr with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (height_avl (Avl_Node kl dl ll (Avl_Node klr dlr llr rlr blr) Right_Balanced)) *) clear below_avl_l above_lr below_ll above_rlr below_llr avl_rlr avl_llr. (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node klr dlr (Avl_Node kl dl ll llr match blr with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node k d rlr r match blr with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (lin_avl (Avl_Node k d (Avl_Node kl dl ll (Avl_Node klr dlr llr rlr blr) Right_Balanced) r b)) *) (* Goal: equiv (Avl_Node klr dlr (Avl_Node kl dl ll llr match blr with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node k d rlr r match blr with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced) (Avl_Node k d (Avl_Node kl dl ll (Avl_Node klr dlr llr rlr blr) Right_Balanced) r b) *) (* Goal: @eq nat (height_avl (Avl_Node klr dlr (Avl_Node kl dl ll llr match blr with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node k d rlr r match blr with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (height_avl (Avl_Node kl dl ll (Avl_Node klr dlr llr rlr blr) Right_Balanced)) *) generalize height_l; clear height_l. (* Goal: forall _ : @eq nat match blr with | Left_Balanced => S (height_avl llr) | Balanced => S (height_avl llr) | Right_Balanced => S (height_avl rlr) end (S (height_avl r)), @eq nat (height_avl (Avl_Node klr dlr (Avl_Node kl dl ll llr match blr with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node k d rlr r match blr with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (height_avl (Avl_Node kl dl ll (Avl_Node klr dlr llr rlr blr) Right_Balanced)) *) inversion_clear Balanced_l. (* Goal: forall _ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced)), @eq nat (height_avl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end)) (height_avl (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end)) *) (* Goal: is_below_avl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) krl *) (* Goal: is_above_avl (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) krl *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (lin_avl (Avl_Node k d l (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced) b)) *) (* Goal: equiv (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced) (Avl_Node k d l (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced) b) *) (* Goal: @eq nat (height_avl (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (height_avl (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced)) *) (* Goal: forall (_ : is_balanced_avl lr rr Balanced) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr lr rr Balanced))), rebalance_right_spec k d l (Avl_Node kr dr lr rr Balanced) b *) (* Goal: forall (_ : is_balanced_avl lr rr Right_Balanced) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr Right_Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr lr rr Right_Balanced))), rebalance_right_spec k d l (Avl_Node kr dr lr rr Right_Balanced) b *) generalize H; clear H. (* Goal: forall (key : Int) (t0 t : avl_tree) (k : Int) (d : B) (_ : equiv_del key t0 t) (_ : not (Equal k key)) (_ : lookup k t d), lookup k t0 d *) inversion_clear Balanced_rl; clear blr; simpl in |- *; intros. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H0; trivial. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H0; trivial. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H0; trivial. Qed. (******************************************************************) Definition rebalance_right_spec (k : Int) (d : B) (l r : avl_tree) (b : bal) : Set := { t : avl_tree | is_avl t /\ lin_avl t = lin_avl (Avl_Node k d l r b) /\ equiv t (Avl_Node k d l r b) /\ match r with | Avl_Nil => True | Avl_Node _ _ _ _ Left_Balanced => height_avl t = height_avl r | Avl_Node _ _ _ _ Balanced => height_avl t = S (height_avl r) | Avl_Node _ _ _ _ Right_Balanced => height_avl t = height_avl r end }. Lemma rebalance_right : forall (k : Int) (d : B) (l r : avl_tree) (b : bal), is_avl l -> is_below_avl l k -> is_avl r -> is_above_avl r k -> S (S (height_avl l)) = height_avl r -> rebalance_right_spec k d l r b. (* Goal: forall (k : Int) (d : B) (l r : avl_tree) (b : bal) (_ : is_avl l) (_ : is_below_avl l k) (_ : is_avl r) (_ : is_above_avl r k) (_ : @eq nat (S (S (height_avl l))) (height_avl r)), rebalance_right_spec k d l r b *) intros k d l r b avl_l below_avl_l avl_r. (* Goal: forall (_ : is_above_avl r k) (_ : @eq nat (S (S (height_avl l))) (height_avl r)), rebalance_right_spec k d l r b *) elim avl_r; clear avl_r. (* r=Avl_Nil *) (* Goal: forall (_ : is_above_avl Avl_Nil k) (_ : @eq nat (S (S (height_avl l))) (height_avl Avl_Nil)), rebalance_right_spec k d l Avl_Nil b *) (* Goal: forall (k0 : Int) (d0 : B) (l0 r : avl_tree) (b0 : bal) (_ : is_avl l0) (_ : forall (_ : is_above_avl l0 k) (_ : @eq nat (S (S (height_avl l))) (height_avl l0)), rebalance_right_spec k d l l0 b) (_ : is_avl r) (_ : forall (_ : is_above_avl r k) (_ : @eq nat (S (S (height_avl l))) (height_avl r)), rebalance_right_spec k d l r b) (_ : is_balanced_avl l0 r b0) (_ : is_below_avl l0 k0) (_ : is_above_avl r k0) (_ : is_above_avl (Avl_Node k0 d0 l0 r b0) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node k0 d0 l0 r b0))), rebalance_right_spec k d l (Avl_Node k0 d0 l0 r b0) b *) intros above_avl_r height_r. (* Goal: rebalance_right_spec k d l (Avl_Node kr dr Avl_Nil rr Left_Balanced) b *) (* Goal: forall (k0 : Int) (d0 : B) (l0 r : avl_tree) (b0 : bal) (_ : is_avl l0) (_ : forall (_ : is_balanced_avl l0 rr Left_Balanced) (_ : is_below_avl l0 kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr l0 rr Left_Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr l0 rr Left_Balanced))), rebalance_right_spec k d l (Avl_Node kr dr l0 rr Left_Balanced) b) (_ : is_avl r) (_ : forall (_ : is_balanced_avl r rr Left_Balanced) (_ : is_below_avl r kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr r rr Left_Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr r rr Left_Balanced))), rebalance_right_spec k d l (Avl_Node kr dr r rr Left_Balanced) b) (_ : is_balanced_avl l0 r b0) (_ : is_below_avl l0 k0) (_ : is_above_avl r k0) (_ : is_balanced_avl (Avl_Node k0 d0 l0 r b0) rr Left_Balanced) (_ : is_below_avl (Avl_Node k0 d0 l0 r b0) kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr (Avl_Node k0 d0 l0 r b0) rr Left_Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr (Avl_Node k0 d0 l0 r b0) rr Left_Balanced))), rebalance_right_spec k d l (Avl_Node kr dr (Avl_Node k0 d0 l0 r b0) rr Left_Balanced) b *) (* Goal: forall (_ : is_balanced_avl lr rr Balanced) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr lr rr Balanced))), rebalance_right_spec k d l (Avl_Node kr dr lr rr Balanced) b *) (* Goal: forall (_ : is_balanced_avl lr rr Right_Balanced) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr Right_Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr lr rr Right_Balanced))), rebalance_right_spec k d l (Avl_Node kr dr lr rr Right_Balanced) b *) discriminate height_r. (* r=(Avl_Node kr dr lr rr br) *) (* Goal: forall (k0 : Int) (d0 : B) (l0 r : avl_tree) (b0 : bal) (_ : is_avl l0) (_ : forall (_ : is_above_avl l0 k) (_ : @eq nat (S (S (height_avl l))) (height_avl l0)), rebalance_right_spec k d l l0 b) (_ : is_avl r) (_ : forall (_ : is_above_avl r k) (_ : @eq nat (S (S (height_avl l))) (height_avl r)), rebalance_right_spec k d l r b) (_ : is_balanced_avl l0 r b0) (_ : is_below_avl l0 k0) (_ : is_above_avl r k0) (_ : is_above_avl (Avl_Node k0 d0 l0 r b0) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node k0 d0 l0 r b0))), rebalance_right_spec k d l (Avl_Node k0 d0 l0 r b0) b *) intros kr dr lr rr br avl_lr ih_lr avl_rr ih_rr. (* Goal: forall (_ : is_balanced_avl lr rr br) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr br) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr lr rr br))), rebalance_right_spec k d l (Avl_Node kr dr lr rr br) b *) clear ih_lr ih_rr. (* Goal: forall (_ : is_balanced_avl lr rr br) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr br) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr lr rr br))), rebalance_right_spec k d l (Avl_Node kr dr lr rr br) b *) case br; clear br. (* br=Left_Balanced => double RL-rotation *) (* Goal: forall (_ : is_balanced_avl lr rr Left_Balanced) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr Left_Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr lr rr Left_Balanced))), rebalance_right_spec k d l (Avl_Node kr dr lr rr Left_Balanced) b *) (* Goal: forall (_ : is_balanced_avl lr rr Balanced) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr lr rr Balanced))), rebalance_right_spec k d l (Avl_Node kr dr lr rr Balanced) b *) (* Goal: forall (_ : is_balanced_avl lr rr Right_Balanced) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr Right_Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr lr rr Right_Balanced))), rebalance_right_spec k d l (Avl_Node kr dr lr rr Right_Balanced) b *) elim avl_lr; clear avl_lr lr. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *. (* Goal: forall (_ : is_balanced_avl lr rr Right_Balanced) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr Right_Balanced) k) (_ : @eq nat (S (S (height_avl l))) (S (height_avl rr))), rebalance_right_spec k d l (Avl_Node kr dr lr rr Right_Balanced) b *) intros Balanced_r below_lr above_rr above_avl_r height_r. (* Goal: rebalance_right_spec k d l (Avl_Node kr dr Avl_Nil rr Left_Balanced) b *) (* Goal: forall (k0 : Int) (d0 : B) (l0 r : avl_tree) (b0 : bal) (_ : is_avl l0) (_ : forall (_ : is_balanced_avl l0 rr Left_Balanced) (_ : is_below_avl l0 kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr l0 rr Left_Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr l0 rr Left_Balanced))), rebalance_right_spec k d l (Avl_Node kr dr l0 rr Left_Balanced) b) (_ : is_avl r) (_ : forall (_ : is_balanced_avl r rr Left_Balanced) (_ : is_below_avl r kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr r rr Left_Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr r rr Left_Balanced))), rebalance_right_spec k d l (Avl_Node kr dr r rr Left_Balanced) b) (_ : is_balanced_avl l0 r b0) (_ : is_below_avl l0 k0) (_ : is_above_avl r k0) (_ : is_balanced_avl (Avl_Node k0 d0 l0 r b0) rr Left_Balanced) (_ : is_below_avl (Avl_Node k0 d0 l0 r b0) kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr (Avl_Node k0 d0 l0 r b0) rr Left_Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr (Avl_Node k0 d0 l0 r b0) rr Left_Balanced))), rebalance_right_spec k d l (Avl_Node kr dr (Avl_Node k0 d0 l0 r b0) rr Left_Balanced) b *) (* Goal: forall (_ : is_balanced_avl lr rr Balanced) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr lr rr Balanced))), rebalance_right_spec k d l (Avl_Node kr dr lr rr Balanced) b *) (* Goal: forall (_ : is_balanced_avl lr rr Right_Balanced) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr Right_Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr lr rr Right_Balanced))), rebalance_right_spec k d l (Avl_Node kr dr lr rr Right_Balanced) b *) discriminate height_r. (* Goal: forall (k0 : Int) (d0 : B) (l0 r : avl_tree) (b0 : bal) (_ : is_avl l0) (_ : forall (_ : is_balanced_avl l0 rr Left_Balanced) (_ : is_below_avl l0 kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr l0 rr Left_Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr l0 rr Left_Balanced))), rebalance_right_spec k d l (Avl_Node kr dr l0 rr Left_Balanced) b) (_ : is_avl r) (_ : forall (_ : is_balanced_avl r rr Left_Balanced) (_ : is_below_avl r kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr r rr Left_Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr r rr Left_Balanced))), rebalance_right_spec k d l (Avl_Node kr dr r rr Left_Balanced) b) (_ : is_balanced_avl l0 r b0) (_ : is_below_avl l0 k0) (_ : is_above_avl r k0) (_ : is_balanced_avl (Avl_Node k0 d0 l0 r b0) rr Left_Balanced) (_ : is_below_avl (Avl_Node k0 d0 l0 r b0) kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr (Avl_Node k0 d0 l0 r b0) rr Left_Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr (Avl_Node k0 d0 l0 r b0) rr Left_Balanced))), rebalance_right_spec k d l (Avl_Node kr dr (Avl_Node k0 d0 l0 r b0) rr Left_Balanced) b *) (* Goal: forall (_ : is_balanced_avl lr rr Balanced) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr lr rr Balanced))), rebalance_right_spec k d l (Avl_Node kr dr lr rr Balanced) b *) (* Goal: forall (_ : is_balanced_avl lr rr Right_Balanced) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr Right_Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr lr rr Right_Balanced))), rebalance_right_spec k d l (Avl_Node kr dr lr rr Right_Balanced) b *) intros krl drl lrl rrl brl avl_lrl ih_lrl avl_rrl ih_rrl; clear ih_lrl ih_rrl. intros Balanced_lr below_lrl above_rrl Balanced_r below_lr above_rr above_avl_r height_r. exists (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced). (* Goal: and (is_avl (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced)) (and (@eq (list (prod Int B)) (lin_avl (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced)) (lin_avl (Avl_Node k d l (Avl_Node kr dr lr rr Right_Balanced) b))) (and (equiv (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced) (Avl_Node k d l (Avl_Node kr dr lr rr Right_Balanced) b)) (@eq nat (height_avl (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced)) (height_avl (Avl_Node kr dr lr rr Right_Balanced))))) *) repeat apply conj. (* Goal: is_avl (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced) *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced)) (lin_avl (Avl_Node k d l (Avl_Node kr dr lr rr Right_Balanced) b)) *) (* Goal: equiv (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced) (Avl_Node k d l (Avl_Node kr dr lr rr Right_Balanced) b) *) (* Goal: @eq nat (height_avl (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced)) (height_avl (Avl_Node kr dr lr rr Right_Balanced)) *) inversion_clear Balanced_r. (* Goal: is_avl (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced) *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (lin_avl (Avl_Node k d l (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced) b)) *) (* Goal: equiv (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced) (Avl_Node k d l (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced) b) *) (* Goal: @eq nat (height_avl (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (height_avl (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced)) *) (* Goal: forall (_ : is_balanced_avl lr rr Balanced) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr lr rr Balanced))), rebalance_right_spec k d l (Avl_Node kr dr lr rr Balanced) b *) (* Goal: forall (_ : is_balanced_avl lr rr Right_Balanced) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr Right_Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr lr rr Right_Balanced))), rebalance_right_spec k d l (Avl_Node kr dr lr rr Right_Balanced) b *) inversion_clear below_lr. (* Goal: is_avl (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced) *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced)) (lin_avl (Avl_Node k d l (Avl_Node kr dr lr rr Right_Balanced) b)) *) (* Goal: equiv (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced) (Avl_Node k d l (Avl_Node kr dr lr rr Right_Balanced) b) *) (* Goal: @eq nat (height_avl (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced)) (height_avl (Avl_Node kr dr lr rr Right_Balanced)) *) inversion_clear above_avl_r. (* Goal: is_avl (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced) *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (lin_avl (Avl_Node k d l (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced) b)) *) (* Goal: equiv (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced) (Avl_Node k d l (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced) b) *) (* Goal: @eq nat (height_avl (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (height_avl (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced)) *) (* Goal: forall (_ : is_balanced_avl lr rr Balanced) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr lr rr Balanced))), rebalance_right_spec k d l (Avl_Node kr dr lr rr Balanced) b *) (* Goal: forall (_ : is_balanced_avl lr rr Right_Balanced) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr Right_Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr lr rr Right_Balanced))), rebalance_right_spec k d l (Avl_Node kr dr lr rr Right_Balanced) b *) inversion_clear H3. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Node_Is_Avl; try assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Node_Is_Avl; try assumption. generalize height_r; (* Goal: is_balanced_avl rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end *) (* Goal: is_balanced_avl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced *) (* Goal: is_below_avl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) krl *) (* Goal: is_above_avl (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) krl *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (lin_avl (Avl_Node k d l (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced) b)) *) (* Goal: equiv (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced) (Avl_Node k d l (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced) b) *) (* Goal: @eq nat (height_avl (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (height_avl (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced)) *) (* Goal: forall (_ : is_balanced_avl lr rr Balanced) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr lr rr Balanced))), rebalance_right_spec k d l (Avl_Node kr dr lr rr Balanced) b *) (* Goal: forall (_ : is_balanced_avl lr rr Right_Balanced) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr Right_Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr lr rr Right_Balanced))), rebalance_right_spec k d l (Avl_Node kr dr lr rr Right_Balanced) b *) clear height_r H5 H4 H2 H1 H0 above_rr above_rrl below_lrl. (* Goal: forall _ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced)), @eq nat (height_avl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end)) (height_avl (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end)) *) (* Goal: is_below_avl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) krl *) (* Goal: is_above_avl (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) krl *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (lin_avl (Avl_Node k d l (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced) b)) *) (* Goal: equiv (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced) (Avl_Node k d l (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced) b) *) (* Goal: @eq nat (height_avl (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (height_avl (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced)) *) (* Goal: forall (_ : is_balanced_avl lr rr Balanced) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr lr rr Balanced))), rebalance_right_spec k d l (Avl_Node kr dr lr rr Balanced) b *) (* Goal: forall (_ : is_balanced_avl lr rr Right_Balanced) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr Right_Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr lr rr Right_Balanced))), rebalance_right_spec k d l (Avl_Node kr dr lr rr Right_Balanced) b *) generalize H; clear H. (* Goal: forall (key : Int) (t0 t : avl_tree) (k : Int) (d : B) (_ : equiv_del key t0 t) (_ : not (Equal k key)) (_ : lookup k t d), lookup k t0 d *) inversion_clear Balanced_lr; clear brl; simpl in |- *; intros. (* blr=Left_Balanced *) (* Goal: is_balanced_avl l r Balanced *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node k d l r Balanced)) (lin_avl (Avl_Node k d l r Left_Balanced)) *) (* Goal: equiv (Avl_Node k d l r Balanced) (Avl_Node k d l r Left_Balanced) *) (* Goal: sumbool (hasnot_shrunk_right (Avl_Node k d l r Balanced) k d l r Left_Balanced) (has_shrunk_right (Avl_Node k d l r Balanced) k d l r Left_Balanced) *) (* Goal: bal_shrunk_right_spec k d l r Balanced *) (* Goal: bal_shrunk_right_spec k d l r Right_Balanced *) apply Is_Fully_Balanced_Avl. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) injection height_r; trivial. (* blr=Balanced *) (* Goal: is_balanced_avl l r Balanced *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node k d l r Balanced)) (lin_avl (Avl_Node k d l r Left_Balanced)) *) (* Goal: equiv (Avl_Node k d l r Balanced) (Avl_Node k d l r Left_Balanced) *) (* Goal: sumbool (hasnot_shrunk_right (Avl_Node k d l r Balanced) k d l r Left_Balanced) (has_shrunk_right (Avl_Node k d l r Balanced) k d l r Left_Balanced) *) (* Goal: bal_shrunk_right_spec k d l r Balanced *) (* Goal: bal_shrunk_right_spec k d l r Right_Balanced *) apply Is_Fully_Balanced_Avl. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) injection height_r; trivial. (* blr=Right_Balanced *) (* Goal: is_balanced_avl l r Left_Balanced *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node k d l r Left_Balanced)) (lin_avl (Avl_Node k d l r Balanced)) *) (* Goal: equiv (Avl_Node k d l r Left_Balanced) (Avl_Node k d l r Balanced) *) (* Goal: sumbool (hasnot_shrunk_left (Avl_Node k d l r Left_Balanced) k d l r Balanced) (has_shrunk_left (Avl_Node k d l r Left_Balanced) k d l r Balanced) *) (* Goal: bal_shrunk_left_spec k d l r Right_Balanced *) apply Is_Left_Balanced_Avl. (* Goal: @eq nat (S match br0 with | Left_Balanced => S (height_avl lr0) | Balanced => S (height_avl lr0) | Right_Balanced => S (height_avl rr0) end) (S (S (height_avl l0))) *) (* Goal: forall _ : is_balanced_avl l0 (Avl_Node kr0 dr0 lr0 rr0 br0) Left_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) Left_Balanced)) (height_avl t) *) (* Goal: forall _ : is_balanced_avl l0 (Avl_Node kr0 dr0 lr0 rr0 br0) Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) Balanced)) (height_avl t) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl (Avl_Node kr0 dr0 lr0 rr0 br0) *) rewrite H. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) injection height_r; trivial. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Node_Is_Avl; try assumption. (* Goal: is_balanced_avl rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end *) (* Goal: is_balanced_avl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced *) (* Goal: is_below_avl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) krl *) (* Goal: is_above_avl (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) krl *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (lin_avl (Avl_Node k d l (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced) b)) *) (* Goal: equiv (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced) (Avl_Node k d l (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced) b) *) (* Goal: @eq nat (height_avl (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (height_avl (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced)) *) (* Goal: forall (_ : is_balanced_avl lr rr Balanced) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr lr rr Balanced))), rebalance_right_spec k d l (Avl_Node kr dr lr rr Balanced) b *) (* Goal: forall (_ : is_balanced_avl lr rr Right_Balanced) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr Right_Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr lr rr Right_Balanced))), rebalance_right_spec k d l (Avl_Node kr dr lr rr Right_Balanced) b *) clear height_r H5 H4 H2 H1 H0 above_rr above_rrl below_lrl. (* Goal: forall _ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced)), @eq nat (height_avl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end)) (height_avl (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end)) *) (* Goal: is_below_avl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) krl *) (* Goal: is_above_avl (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) krl *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (lin_avl (Avl_Node k d l (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced) b)) *) (* Goal: equiv (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced) (Avl_Node k d l (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced) b) *) (* Goal: @eq nat (height_avl (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (height_avl (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced)) *) (* Goal: forall (_ : is_balanced_avl lr rr Balanced) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr lr rr Balanced))), rebalance_right_spec k d l (Avl_Node kr dr lr rr Balanced) b *) (* Goal: forall (_ : is_balanced_avl lr rr Right_Balanced) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr Right_Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr lr rr Right_Balanced))), rebalance_right_spec k d l (Avl_Node kr dr lr rr Right_Balanced) b *) generalize H; clear H. (* Goal: forall (key : Int) (t0 t : avl_tree) (k : Int) (d : B) (_ : equiv_del key t0 t) (_ : not (Equal k key)) (_ : lookup k t d), lookup k t0 d *) inversion_clear Balanced_lr; clear brl; simpl in |- *; intros. (* brl=Left_Balanced *) (* Goal: is_balanced_avl l r Right_Balanced *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node k d l r Right_Balanced)) (lin_avl (Avl_Node k d l r Balanced)) *) (* Goal: equiv (Avl_Node k d l r Right_Balanced) (Avl_Node k d l r Balanced) *) (* Goal: sumbool (hasnot_shrunk_right (Avl_Node k d l r Right_Balanced) k d l r Balanced) (has_shrunk_right (Avl_Node k d l r Right_Balanced) k d l r Balanced) *) (* Goal: bal_shrunk_right_spec k d l r Right_Balanced *) apply Is_Right_Balanced_Avl. (* Goal: @eq nat (S match bl0 with | Left_Balanced => S (height_avl ll0) | Balanced => S (height_avl ll0) | Right_Balanced => S (height_avl rl0) end) (S (height_avl r0)) *) (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced, @eq nat (S (height_avl r0)) (S (height_avl r0)) *) (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Balanced, @eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Balanced)) (height_avl t) *) (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced)) (height_avl t) *) (* Goal: forall _ : has_shrunk_right t k d l r0 b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) rewrite <- H. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) injection H0; trivial. (* brl=Balanced *) (* Goal: is_balanced_avl l r Balanced *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node k d l r Balanced)) (lin_avl (Avl_Node k d l r Left_Balanced)) *) (* Goal: equiv (Avl_Node k d l r Balanced) (Avl_Node k d l r Left_Balanced) *) (* Goal: sumbool (hasnot_shrunk_right (Avl_Node k d l r Balanced) k d l r Left_Balanced) (has_shrunk_right (Avl_Node k d l r Balanced) k d l r Left_Balanced) *) (* Goal: bal_shrunk_right_spec k d l r Balanced *) (* Goal: bal_shrunk_right_spec k d l r Right_Balanced *) apply Is_Fully_Balanced_Avl. (* Goal: @eq nat (S match bl0 with | Left_Balanced => S (height_avl ll0) | Balanced => S (height_avl ll0) | Right_Balanced => S (height_avl rl0) end) (S (height_avl r0)) *) (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced, @eq nat (S (height_avl r0)) (S (height_avl r0)) *) (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Balanced, @eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Balanced)) (height_avl t) *) (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced)) (height_avl t) *) (* Goal: forall _ : has_shrunk_right t k d l r0 b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) rewrite <- H. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) injection H0; trivial. (* brl=Right_Balanced *) (* Goal: is_balanced_avl l r Balanced *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node k d l r Balanced)) (lin_avl (Avl_Node k d l r Left_Balanced)) *) (* Goal: equiv (Avl_Node k d l r Balanced) (Avl_Node k d l r Left_Balanced) *) (* Goal: sumbool (hasnot_shrunk_right (Avl_Node k d l r Balanced) k d l r Left_Balanced) (has_shrunk_right (Avl_Node k d l r Balanced) k d l r Left_Balanced) *) (* Goal: bal_shrunk_right_spec k d l r Balanced *) (* Goal: bal_shrunk_right_spec k d l r Right_Balanced *) apply Is_Fully_Balanced_Avl. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) injection H0; trivial. (* Goal: is_balanced_avl l r Balanced *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node k d l r Balanced)) (lin_avl (Avl_Node k d l r Left_Balanced)) *) (* Goal: equiv (Avl_Node k d l r Balanced) (Avl_Node k d l r Left_Balanced) *) (* Goal: sumbool (hasnot_shrunk_right (Avl_Node k d l r Balanced) k d l r Left_Balanced) (has_shrunk_right (Avl_Node k d l r Balanced) k d l r Left_Balanced) *) (* Goal: bal_shrunk_right_spec k d l r Balanced *) (* Goal: bal_shrunk_right_spec k d l r Right_Balanced *) apply Is_Fully_Balanced_Avl. generalize height_r; (* Goal: is_balanced_avl rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end *) (* Goal: is_balanced_avl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced *) (* Goal: is_below_avl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) krl *) (* Goal: is_above_avl (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) krl *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (lin_avl (Avl_Node k d l (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced) b)) *) (* Goal: equiv (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced) (Avl_Node k d l (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced) b) *) (* Goal: @eq nat (height_avl (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (height_avl (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced)) *) (* Goal: forall (_ : is_balanced_avl lr rr Balanced) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr lr rr Balanced))), rebalance_right_spec k d l (Avl_Node kr dr lr rr Balanced) b *) (* Goal: forall (_ : is_balanced_avl lr rr Right_Balanced) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr Right_Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr lr rr Right_Balanced))), rebalance_right_spec k d l (Avl_Node kr dr lr rr Right_Balanced) b *) clear height_r H5 H4 H2 H1 H0 above_rr above_rrl below_lrl. (* Goal: forall _ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced)), @eq nat (height_avl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end)) (height_avl (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end)) *) (* Goal: is_below_avl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) krl *) (* Goal: is_above_avl (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) krl *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (lin_avl (Avl_Node k d l (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced) b)) *) (* Goal: equiv (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced) (Avl_Node k d l (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced) b) *) (* Goal: @eq nat (height_avl (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (height_avl (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced)) *) (* Goal: forall (_ : is_balanced_avl lr rr Balanced) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr lr rr Balanced))), rebalance_right_spec k d l (Avl_Node kr dr lr rr Balanced) b *) (* Goal: forall (_ : is_balanced_avl lr rr Right_Balanced) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr Right_Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr lr rr Right_Balanced))), rebalance_right_spec k d l (Avl_Node kr dr lr rr Right_Balanced) b *) generalize H; clear H. (* Goal: forall (key : Int) (t0 t : avl_tree) (k : Int) (d : B) (_ : equiv_del key t0 t) (_ : not (Equal k key)) (_ : lookup k t d), lookup k t0 d *) inversion_clear Balanced_lr; clear brl; simpl in |- *; intros. (* brl=Left_Balanced *) (* Goal: @eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Left_Balanced)) (S (S (height_avl r0))) *) (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) rewrite <- H0. (* Goal: rebalance_right_spec k d l (Avl_Node kr dr lr rr Right_Balanced) b *) injection height_r; clear height_r; intro height_r. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite height_r; trivial. (* brl=Balanced *) (* Goal: @eq nat (S match bl0 with | Left_Balanced => S (height_avl ll0) | Balanced => S (height_avl ll0) | Right_Balanced => S (height_avl rl0) end) (S (height_avl r0)) *) (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced, @eq nat (S (height_avl r0)) (S (height_avl r0)) *) (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Balanced, @eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Balanced)) (height_avl t) *) (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced)) (height_avl t) *) (* Goal: forall _ : has_shrunk_right t k d l r0 b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) rewrite <- H. (* Goal: rebalance_right_spec k d l (Avl_Node kr dr lr rr Right_Balanced) b *) injection height_r; clear height_r; intro height_r. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite height_r; trivial. (* brl=Right_Balanced *) (* Goal: rebalance_right_spec k d l (Avl_Node kr dr lr rr Right_Balanced) b *) injection height_r; clear height_r; intro height_r. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite height_r; trivial. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Below_Avl_Node; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Above_Avl_Node; assumption. clear height_r above_avl_r above_rr below_lr Balanced_r above_rrl below_lrl Balanced_lr. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *. rewrite (app_ass (lin_avl l) ((k, d) :: lin_avl lrl) ((krl, drl) :: lin_avl rrl ++ (kr, dr) :: lin_avl rr)) . (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *. rewrite (app_ass (lin_avl lrl) ((krl, drl) :: lin_avl rrl) ((kr, dr) :: lin_avl rr)) . (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. clear height_r above_avl_r above_rr below_lr Balanced_r above_rrl below_lrl Balanced_lr. (* Goal: equiv (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced) (Avl_Node k d l (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced) b) *) (* Goal: @eq nat (height_avl (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (height_avl (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced)) *) (* Goal: forall (_ : is_balanced_avl lr rr Balanced) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr lr rr Balanced))), rebalance_right_spec k d l (Avl_Node kr dr lr rr Balanced) b *) (* Goal: forall (_ : is_balanced_avl lr rr Right_Balanced) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr Right_Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr lr rr Right_Balanced))), rebalance_right_spec k d l (Avl_Node kr dr lr rr Right_Balanced) b *) apply equiv_intro. (* Goal: forall (key : Int) (data : B) (_ : lookup key (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced) data), lookup key (Avl_Node k d l (Avl_Node kr dr lr rr Right_Balanced) b) data *) (* Goal: forall (key : Int) (data : B) (_ : lookup key (Avl_Node k d l (Avl_Node kr dr lr rr Right_Balanced) b) data), lookup key (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced) data *) (* Goal: @eq nat (height_avl (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced)) (height_avl (Avl_Node kr dr lr rr Right_Balanced)) *) intros key data lookup_t. (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 r data), lookup k0 (Avl_Node k d Avl_Nil r b) data *) inversion_clear lookup_t. (* Goal: lookup k0 (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d0 *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup_Right; apply Lookup_Left; apply Lookup_Equal. (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 r data), lookup k0 (Avl_Node k d Avl_Nil r b) data *) inversion_clear H. (* Goal: lookup k0 (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d0 *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup_Equal. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Left; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Right; apply Lookup_Left; apply Lookup_Left; assumption. (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 r data), lookup k0 (Avl_Node k d Avl_Nil r b) data *) inversion_clear H. (* Goal: lookup k0 (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d0 *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup_Right; apply Lookup_Equal. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Right; apply Lookup_Left; apply Lookup_Right; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Right; apply Lookup_Right; assumption. (* Goal: forall (key : Int) (data : B) (_ : lookup key (Avl_Node k d l (Avl_Node kr dr lr rr Right_Balanced) b) data), lookup key (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced) data *) (* Goal: @eq nat (height_avl (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced)) (height_avl (Avl_Node kr dr lr rr Right_Balanced)) *) intros key data lookup_t0. (* Goal: False *) (* Goal: equiv_del key Avl_Nil Avl_Nil *) (* Goal: sumbool (@eq nat (height_avl Avl_Nil) (height_avl Avl_Nil)) (@eq nat (height_avl Avl_Nil) (S (height_avl Avl_Nil))) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, delete_spec key a) (a0 : avl_tree) (_ : forall _ : is_avl a0, delete_spec key a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), delete_spec key (Avl_Node i b a a0 b0) *) inversion_clear lookup_t0. (* Goal: lookup k0 (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d0 *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup_Left; apply Lookup_Equal. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Left; apply Lookup_Left; assumption. (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 r data), lookup k0 (Avl_Node k d Avl_Nil r b) data *) inversion_clear H. (* Goal: lookup k0 (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d0 *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup_Right; apply Lookup_Equal. (* Goal: lookup key (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced) data *) (* Goal: lookup key (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced) data *) (* Goal: @eq nat (height_avl (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (height_avl (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced)) *) (* Goal: forall (_ : is_balanced_avl lr rr Balanced) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr lr rr Balanced))), rebalance_right_spec k d l (Avl_Node kr dr lr rr Balanced) b *) (* Goal: forall (_ : is_balanced_avl lr rr Right_Balanced) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr Right_Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr lr rr Right_Balanced))), rebalance_right_spec k d l (Avl_Node kr dr lr rr Right_Balanced) b *) inversion_clear H0. (* Goal: lookup k0 (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d0 *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup_Equal. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Left; apply Lookup_Right; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Right; apply Lookup_Left; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Right; apply Lookup_Right; assumption. (* Goal: @eq nat (height_avl (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (height_avl (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced)) *) (* Goal: forall (_ : is_balanced_avl lr rr Balanced) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr lr rr Balanced))), rebalance_right_spec k d l (Avl_Node kr dr lr rr Balanced) b *) (* Goal: forall (_ : is_balanced_avl lr rr Right_Balanced) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr Right_Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr lr rr Right_Balanced))), rebalance_right_spec k d l (Avl_Node kr dr lr rr Right_Balanced) b *) clear above_avl_r above_rr below_lr above_rrl below_lrl. (* Goal: @eq nat (height_avl (Avl_Node krl drl (Avl_Node k d l lrl match brl with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node kr dr rrl rr match brl with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (height_avl (Avl_Node kr dr (Avl_Node krl drl lrl rrl brl) rr Left_Balanced)) *) (* Goal: forall (_ : is_balanced_avl lr rr Balanced) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr lr rr Balanced))), rebalance_right_spec k d l (Avl_Node kr dr lr rr Balanced) b *) (* Goal: forall (_ : is_balanced_avl lr rr Right_Balanced) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr Right_Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr lr rr Right_Balanced))), rebalance_right_spec k d l (Avl_Node kr dr lr rr Right_Balanced) b *) generalize height_r; clear height_r. (* Goal: forall _ : is_balanced_avl l0 r0 Left_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Left_Balanced)) (S (height_avl l0)) *) (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) elim brl; simpl in |- *; trivial. (* br=Balanced *) (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *. (* Goal: forall (_ : is_balanced_avl lr rr Right_Balanced) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr Right_Balanced) k) (_ : @eq nat (S (S (height_avl l))) (S (height_avl rr))), rebalance_right_spec k d l (Avl_Node kr dr lr rr Right_Balanced) b *) intros Balanced_r below_lr above_rr above_avl_r height_r. (* Goal: rebalance_right_spec k d l (Avl_Node kr dr lr rr Balanced) b *) (* Goal: forall (_ : is_balanced_avl lr rr Right_Balanced) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr Right_Balanced) k) (_ : @eq nat (S (S (height_avl l))) (height_avl (Avl_Node kr dr lr rr Right_Balanced))), rebalance_right_spec k d l (Avl_Node kr dr lr rr Right_Balanced) b *) exists (Avl_Node kr dr (Avl_Node k d l lr Right_Balanced) rr Left_Balanced). (* Goal: and (is_avl (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced)) (and (@eq (list (prod Int B)) (lin_avl (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced)) (lin_avl (Avl_Node k d l (Avl_Node kr dr lr rr Right_Balanced) b))) (and (equiv (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced) (Avl_Node k d l (Avl_Node kr dr lr rr Right_Balanced) b)) (@eq nat (height_avl (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced)) (height_avl (Avl_Node kr dr lr rr Right_Balanced))))) *) repeat apply conj. (* Goal: is_avl (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced) *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced)) (lin_avl (Avl_Node k d l (Avl_Node kr dr lr rr Right_Balanced) b)) *) (* Goal: equiv (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced) (Avl_Node k d l (Avl_Node kr dr lr rr Right_Balanced) b) *) (* Goal: @eq nat (height_avl (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced)) (height_avl (Avl_Node kr dr lr rr Right_Balanced)) *) inversion_clear above_avl_r. (* Goal: rebalance_right_spec k d l (Avl_Node kr dr lr rr Right_Balanced) b *) injection height_r; clear height_r; intro height_r. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Node_Is_Avl; try assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Node_Is_Avl; try assumption. (* Goal: is_balanced_avl l r Right_Balanced *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node k d l r Right_Balanced)) (lin_avl (Avl_Node k d l r Balanced)) *) (* Goal: equiv (Avl_Node k d l r Right_Balanced) (Avl_Node k d l r Balanced) *) (* Goal: sumbool (hasnot_shrunk_right (Avl_Node k d l r Right_Balanced) k d l r Balanced) (has_shrunk_right (Avl_Node k d l r Right_Balanced) k d l r Balanced) *) (* Goal: bal_shrunk_right_spec k d l r Right_Balanced *) apply Is_Right_Balanced_Avl. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: is_balanced_avl l r Left_Balanced *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node k d l r Left_Balanced)) (lin_avl (Avl_Node k d l r Balanced)) *) (* Goal: equiv (Avl_Node k d l r Left_Balanced) (Avl_Node k d l r Balanced) *) (* Goal: sumbool (hasnot_shrunk_left (Avl_Node k d l r Left_Balanced) k d l r Balanced) (has_shrunk_left (Avl_Node k d l r Left_Balanced) k d l r Balanced) *) (* Goal: bal_shrunk_left_spec k d l r Right_Balanced *) apply Is_Left_Balanced_Avl. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *. (* Goal: is_avl (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced) *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced)) (lin_avl (Avl_Node k d l (Avl_Node kr dr lr rr Right_Balanced) b)) *) (* Goal: equiv (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced) (Avl_Node k d l (Avl_Node kr dr lr rr Right_Balanced) b) *) (* Goal: @eq nat (height_avl (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced)) (height_avl (Avl_Node kr dr lr rr Right_Balanced)) *) inversion_clear Balanced_r. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H1; trivial. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Below_Avl_Node; assumption. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *. rewrite (app_ass (lin_avl l) ((k, d) :: lin_avl lr) ((kr, dr) :: lin_avl rr)) . (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. (* Goal: equiv (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced) (Avl_Node k d l (Avl_Node kr dr lr rr Right_Balanced) b) *) (* Goal: @eq nat (height_avl (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced)) (height_avl (Avl_Node kr dr lr rr Right_Balanced)) *) apply equiv_intro; clear above_avl_r height_r. (* Goal: forall (key : Int) (data : B) (_ : lookup key (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced) data), lookup key (Avl_Node k d l (Avl_Node kr dr lr rr Right_Balanced) b) data *) (* Goal: forall (key : Int) (data : B) (_ : lookup key (Avl_Node k d l (Avl_Node kr dr lr rr Right_Balanced) b) data), lookup key (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced) data *) (* Goal: @eq nat (height_avl (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced)) (height_avl (Avl_Node kr dr lr rr Right_Balanced)) *) intros key data lookup_t. (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 r data), lookup k0 (Avl_Node k d Avl_Nil r b) data *) inversion_clear lookup_t. (* Goal: lookup k0 (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d0 *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup_Right; apply Lookup_Equal. (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 r data), lookup k0 (Avl_Node k d Avl_Nil r b) data *) inversion_clear H. (* Goal: lookup k0 (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d0 *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup_Equal. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Left; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Right; apply Lookup_Left; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Right; apply Lookup_Right; assumption. (* Goal: forall (key : Int) (data : B) (_ : lookup key (Avl_Node k d l (Avl_Node kr dr lr rr Right_Balanced) b) data), lookup key (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced) data *) (* Goal: @eq nat (height_avl (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced)) (height_avl (Avl_Node kr dr lr rr Right_Balanced)) *) intros key data lookup_t0. (* Goal: False *) (* Goal: equiv_del key Avl_Nil Avl_Nil *) (* Goal: sumbool (@eq nat (height_avl Avl_Nil) (height_avl Avl_Nil)) (@eq nat (height_avl Avl_Nil) (S (height_avl Avl_Nil))) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, delete_spec key a) (a0 : avl_tree) (_ : forall _ : is_avl a0, delete_spec key a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), delete_spec key (Avl_Node i b a a0 b0) *) inversion_clear lookup_t0. (* Goal: lookup k0 (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d0 *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup_Left; apply Lookup_Equal. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Left; apply Lookup_Left; assumption. (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 r data), lookup k0 (Avl_Node k d Avl_Nil r b) data *) inversion_clear H. (* Goal: lookup k0 (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d0 *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup_Equal. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Left; apply Lookup_Right; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Right; assumption. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. (* br=Right_Balanced *) (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *. (* Goal: forall (_ : is_balanced_avl lr rr Right_Balanced) (_ : is_below_avl lr kr) (_ : is_above_avl rr kr) (_ : is_above_avl (Avl_Node kr dr lr rr Right_Balanced) k) (_ : @eq nat (S (S (height_avl l))) (S (height_avl rr))), rebalance_right_spec k d l (Avl_Node kr dr lr rr Right_Balanced) b *) intros Balanced_r below_lr above_rr above_avl_r height_r. (* Goal: rebalance_right_spec k d l (Avl_Node kr dr lr rr Right_Balanced) b *) injection height_r; clear height_r; intro height_r. (* Goal: rebalance_right_spec k d l (Avl_Node kr dr lr rr Right_Balanced) b *) exists (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced). (* Goal: and (is_avl (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced)) (and (@eq (list (prod Int B)) (lin_avl (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced)) (lin_avl (Avl_Node k d l (Avl_Node kr dr lr rr Right_Balanced) b))) (and (equiv (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced) (Avl_Node k d l (Avl_Node kr dr lr rr Right_Balanced) b)) (@eq nat (height_avl (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced)) (height_avl (Avl_Node kr dr lr rr Right_Balanced))))) *) repeat apply conj. (* Goal: is_avl (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced) *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced)) (lin_avl (Avl_Node k d l (Avl_Node kr dr lr rr Right_Balanced) b)) *) (* Goal: equiv (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced) (Avl_Node k d l (Avl_Node kr dr lr rr Right_Balanced) b) *) (* Goal: @eq nat (height_avl (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced)) (height_avl (Avl_Node kr dr lr rr Right_Balanced)) *) inversion_clear above_avl_r. (* Goal: is_avl (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced) *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced)) (lin_avl (Avl_Node k d l (Avl_Node kr dr lr rr Right_Balanced) b)) *) (* Goal: equiv (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced) (Avl_Node k d l (Avl_Node kr dr lr rr Right_Balanced) b) *) (* Goal: @eq nat (height_avl (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced)) (height_avl (Avl_Node kr dr lr rr Right_Balanced)) *) inversion_clear Balanced_r. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Node_Is_Avl; try assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Node_Is_Avl; try assumption. (* Goal: is_balanced_avl l r Balanced *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node k d l r Balanced)) (lin_avl (Avl_Node k d l r Left_Balanced)) *) (* Goal: equiv (Avl_Node k d l r Balanced) (Avl_Node k d l r Left_Balanced) *) (* Goal: sumbool (hasnot_shrunk_right (Avl_Node k d l r Balanced) k d l r Left_Balanced) (has_shrunk_right (Avl_Node k d l r Balanced) k d l r Left_Balanced) *) (* Goal: bal_shrunk_right_spec k d l r Balanced *) (* Goal: bal_shrunk_right_spec k d l r Right_Balanced *) apply Is_Fully_Balanced_Avl. (* Goal: @eq nat (height_avl l) (height_avl lr) *) (* Goal: is_balanced_avl (Avl_Node k d l lr Balanced) rr Balanced *) (* Goal: is_below_avl (Avl_Node k d l lr Balanced) kr *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced)) (lin_avl (Avl_Node k d l (Avl_Node kr dr lr rr Right_Balanced) b)) *) (* Goal: equiv (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced) (Avl_Node k d l (Avl_Node kr dr lr rr Right_Balanced) b) *) (* Goal: @eq nat (height_avl (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced)) (height_avl (Avl_Node kr dr lr rr Right_Balanced)) *) rewrite <- height_r in H1. symmetry in |- *. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) injection H1; trivial. (* Goal: is_balanced_avl l r Balanced *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node k d l r Balanced)) (lin_avl (Avl_Node k d l r Left_Balanced)) *) (* Goal: equiv (Avl_Node k d l r Balanced) (Avl_Node k d l r Left_Balanced) *) (* Goal: sumbool (hasnot_shrunk_right (Avl_Node k d l r Balanced) k d l r Left_Balanced) (has_shrunk_right (Avl_Node k d l r Balanced) k d l r Left_Balanced) *) (* Goal: bal_shrunk_right_spec k d l r Balanced *) (* Goal: bal_shrunk_right_spec k d l r Right_Balanced *) apply Is_Fully_Balanced_Avl. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Below_Avl_Node; assumption. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *. rewrite (app_ass (lin_avl l) ((k, d) :: lin_avl lr) ((kr, dr) :: lin_avl rr)) . (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. (* Goal: equiv (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced) (Avl_Node k d l (Avl_Node kr dr lr rr Right_Balanced) b) *) (* Goal: @eq nat (height_avl (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced)) (height_avl (Avl_Node kr dr lr rr Right_Balanced)) *) apply equiv_intro; clear above_avl_r height_r. (* Goal: forall (key : Int) (data : B) (_ : lookup key (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced) data), lookup key (Avl_Node k d l (Avl_Node kr dr lr rr Right_Balanced) b) data *) (* Goal: forall (key : Int) (data : B) (_ : lookup key (Avl_Node k d l (Avl_Node kr dr lr rr Right_Balanced) b) data), lookup key (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced) data *) (* Goal: @eq nat (height_avl (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced)) (height_avl (Avl_Node kr dr lr rr Right_Balanced)) *) intros key data lookup_t. (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 r data), lookup k0 (Avl_Node k d Avl_Nil r b) data *) inversion_clear lookup_t. (* Goal: lookup k0 (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d0 *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup_Right; apply Lookup_Equal. (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 r data), lookup k0 (Avl_Node k d Avl_Nil r b) data *) inversion_clear H. (* Goal: lookup k0 (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d0 *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup_Equal. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Left; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Right; apply Lookup_Left; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Right; apply Lookup_Right; assumption. (* Goal: forall (key : Int) (data : B) (_ : lookup key (Avl_Node k d l (Avl_Node kr dr lr rr Right_Balanced) b) data), lookup key (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced) data *) (* Goal: @eq nat (height_avl (Avl_Node kr dr (Avl_Node k d l lr Balanced) rr Balanced)) (height_avl (Avl_Node kr dr lr rr Right_Balanced)) *) intros key data lookup_t0. (* Goal: False *) (* Goal: equiv_del key Avl_Nil Avl_Nil *) (* Goal: sumbool (@eq nat (height_avl Avl_Nil) (height_avl Avl_Nil)) (@eq nat (height_avl Avl_Nil) (S (height_avl Avl_Nil))) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, delete_spec key a) (a0 : avl_tree) (_ : forall _ : is_avl a0, delete_spec key a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), delete_spec key (Avl_Node i b a a0 b0) *) inversion_clear lookup_t0. (* Goal: lookup k0 (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d0 *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup_Left; apply Lookup_Equal. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Left; apply Lookup_Left; assumption. (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 r data), lookup k0 (Avl_Node k d Avl_Nil r b) data *) inversion_clear H. (* Goal: lookup k0 (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d0 *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup_Equal. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Left; apply Lookup_Right; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Right; assumption. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite height_r; trivial. Qed. (********************************************************************) Inductive is_balanced_avl_left_shift (l r : avl_tree) : bal -> Prop := | Is_Left_Balanced_Avl_Left_Shift : height_avl l = S (S (height_avl r)) -> is_balanced_avl_left_shift l r Left_Balanced | Is_Fully_Balanced_Avl_Left_Shift : height_avl l = S (height_avl r) -> is_balanced_avl_left_shift l r Balanced | Is_Right_Balanced_Avl_Left_Shift : height_avl l = height_avl r -> is_balanced_avl_left_shift l r Right_Balanced. Lemma is_left_balanced_is_left_balanced_left_shift : forall (l0 l r0 : avl_tree) (b0 : bal), is_balanced_avl l0 r0 b0 -> height_avl l = S (height_avl l0) -> is_balanced_avl_left_shift l r0 b0. (* Goal: forall (l0 l r0 : avl_tree) (b0 : bal) (_ : is_balanced_avl l0 r0 b0) (_ : @eq nat (height_avl l) (S (height_avl l0))), is_balanced_avl_left_shift l r0 b0 *) intros l0 l r0 b0 Balanced_l0 height_l. (* Goal: is_balanced_avl_right_shift l r0 b0 *) inversion_clear Balanced_l0. (* Goal: is_balanced_avl_left_shift l0 r Left_Balanced *) (* Goal: is_balanced_avl_left_shift l0 r Balanced *) (* Goal: is_balanced_avl_left_shift l0 r Right_Balanced *) apply Is_Left_Balanced_Avl_Left_Shift. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) rewrite <- H; assumption. (* Goal: is_balanced_avl_left_shift l0 r Balanced *) (* Goal: is_balanced_avl_left_shift l0 r Right_Balanced *) apply Is_Fully_Balanced_Avl_Left_Shift. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) rewrite <- H; assumption. (* Goal: is_balanced_avl_left_shift l0 r Right_Balanced *) apply Is_Right_Balanced_Avl_Left_Shift. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) rewrite <- H; assumption. Qed. Lemma is_balanced_is_balanced_left_shift_false : forall (l r : avl_tree) (b : bal), is_balanced_avl l r b -> is_balanced_avl_left_shift l r b -> False. (* Goal: forall (l r : avl_tree) (b : bal) (_ : is_balanced_avl l r b) (_ : is_balanced_avl_right_shift l r b), False *) intros l r b Balanced_l. inversion_clear Balanced_l; intros Balanced_shift_l; (* Goal: @eq nat (S (height_avl l)) (S (height_avl r)) *) (* Goal: bal_shrunk_right_spec k d l r Balanced *) (* Goal: bal_shrunk_right_spec k d l r Right_Balanced *) inversion_clear Balanced_shift_l. (* Goal: False *) (* Goal: False *) (* Goal: False *) apply n_Sn_false with (S (height_avl r)). (* Goal: @eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Left_Balanced)) (S (S (height_avl r0))) *) (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) rewrite <- H0. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) symmetry in |- *; assumption. (* Goal: False *) (* Goal: False *) (* Goal: False *) apply n_Sn_false with (height_avl r). (* Goal: @eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Left_Balanced)) (S (S (height_avl r0))) *) (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) rewrite <- H0. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) symmetry in |- *; assumption. (* Goal: False *) (* Goal: False *) apply n_Sn_false with (height_avl l). (* Goal: @eq nat (S match br0 with | Left_Balanced => S (height_avl lr0) | Balanced => S (height_avl lr0) | Right_Balanced => S (height_avl rr0) end) (S (S (height_avl l0))) *) (* Goal: forall _ : is_balanced_avl l0 (Avl_Node kr0 dr0 lr0 rr0 br0) Left_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) Left_Balanced)) (height_avl t) *) (* Goal: forall _ : is_balanced_avl l0 (Avl_Node kr0 dr0 lr0 rr0 br0) Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) Balanced)) (height_avl t) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl (Avl_Node kr0 dr0 lr0 rr0 br0) *) rewrite H. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. Qed. (********************************************************************) Inductive is_balanced_avl_right_shift (l r : avl_tree) : bal -> Prop := | Is_Left_Balanced_Avl_Right_Shift : height_avl l = height_avl r -> is_balanced_avl_right_shift l r Left_Balanced | Is_Fully_Balanced_Avl_Right_Shift : S (height_avl l) = height_avl r -> is_balanced_avl_right_shift l r Balanced | Is_Right_Balanced_Avl_Right_Shift : S (S (height_avl l)) = height_avl r -> is_balanced_avl_right_shift l r Right_Balanced. Lemma is_balanced_avl_is_balanced_avl_right_shift : forall (l0 r r0 : avl_tree) (b0 : bal), is_balanced_avl l0 r0 b0 -> height_avl r = S (height_avl r0) -> is_balanced_avl_right_shift l0 r b0. (* Goal: forall (l0 r r0 : avl_tree) (b0 : bal) (_ : is_balanced_avl l0 r0 b0) (_ : @eq nat (height_avl r) (S (height_avl r0))), is_balanced_avl_right_shift l0 r b0 *) intros l0 r r0 b0 Balanced_r0 height_l. (* Goal: is_balanced_avl_right_shift l r0 b0 *) inversion_clear Balanced_r0. (* Goal: is_balanced_avl_right_shift l r0 Left_Balanced *) (* Goal: is_balanced_avl_right_shift l r0 Balanced *) (* Goal: is_balanced_avl_right_shift l r0 Right_Balanced *) apply Is_Left_Balanced_Avl_Right_Shift. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) rewrite H; symmetry in |- *; assumption. (* Goal: is_balanced_avl_right_shift l r0 Balanced *) (* Goal: is_balanced_avl_right_shift l r0 Right_Balanced *) apply Is_Fully_Balanced_Avl_Right_Shift. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) rewrite H; symmetry in |- *; assumption. (* Goal: is_balanced_avl_right_shift l r0 Right_Balanced *) apply Is_Right_Balanced_Avl_Right_Shift. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) rewrite H; symmetry in |- *; assumption. Qed. Lemma is_balanced_avl_is_balanced_avl_right_shift_false : forall (l r : avl_tree) (b : bal), is_balanced_avl l r b -> is_balanced_avl_right_shift l r b -> False. (* Goal: forall (l r : avl_tree) (b : bal) (_ : is_balanced_avl l r b) (_ : is_balanced_avl_right_shift l r b), False *) intros l r b Balanced_l. inversion_clear Balanced_l; intros Balanced_shift_l; (* Goal: @eq nat (S (height_avl l)) (S (height_avl r)) *) (* Goal: bal_shrunk_right_spec k d l r Balanced *) (* Goal: bal_shrunk_right_spec k d l r Right_Balanced *) inversion_clear Balanced_shift_l. (* Goal: False *) (* Goal: False *) (* Goal: False *) apply n_Sn_false with (height_avl r). (* Goal: @eq nat (S match bl0 with | Left_Balanced => S (height_avl ll0) | Balanced => S (height_avl ll0) | Right_Balanced => S (height_avl rl0) end) (S (height_avl r0)) *) (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced, @eq nat (S (height_avl r0)) (S (height_avl r0)) *) (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Balanced, @eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Balanced)) (height_avl t) *) (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced)) (height_avl t) *) (* Goal: forall _ : has_shrunk_right t k d l r0 b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) rewrite <- H. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) symmetry in |- *; assumption. (* Goal: False *) (* Goal: False *) apply n_Sn_false with (height_avl l). (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Balanced, @eq nat (S match bl0 with | Left_Balanced => S (height_avl ll0) | Balanced => S (height_avl ll0) | Right_Balanced => S (height_avl rl0) end) (S (height_avl l)) *) (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced, @eq nat (S (height_avl r0)) (S (height_avl r0)) *) (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Balanced, @eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Balanced)) (height_avl t) *) (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced)) (height_avl t) *) (* Goal: forall _ : has_shrunk_right t k d l r0 b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) rewrite H0. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: False *) apply n_Sn_false with (S (height_avl l)). (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Balanced, @eq nat (S match bl0 with | Left_Balanced => S (height_avl ll0) | Balanced => S (height_avl ll0) | Right_Balanced => S (height_avl rl0) end) (S (height_avl l)) *) (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced, @eq nat (S (height_avl r0)) (S (height_avl r0)) *) (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Balanced, @eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Balanced)) (height_avl t) *) (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced)) (height_avl t) *) (* Goal: forall _ : has_shrunk_right t k d l r0 b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) rewrite H0. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. Qed. (**********************************************************************) Inductive hasnot_grown_left (t : avl_tree) (k : Int) (d : B) (l r : avl_tree) : bal -> Prop := | Hasnot_Grown_Left_Bal : forall b : bal, is_balanced_avl l r b -> height_avl t = height_avl (Avl_Node k d l r b) -> hasnot_grown_left t k d l r b | Hasnot_Grown_Left_Shift_Left : is_balanced_avl_left_shift l r Left_Balanced -> height_avl t = height_avl l -> hasnot_grown_left t k d l r Left_Balanced | Hasnot_Grown_Left_Shift_Right : is_balanced_avl_left_shift l r Right_Balanced -> height_avl t = S (height_avl l) -> hasnot_grown_left t k d l r Right_Balanced. Inductive has_grown_left (t : avl_tree) (k : Int) (d : B) (l r : avl_tree) : bal -> Prop := | Has_Grown_Left_Shift_Left : is_balanced_avl_left_shift l r Left_Balanced -> height_avl t = S (height_avl l) -> has_grown_left t k d l r Left_Balanced | Has_Grown_Left_Shift_Balanced : is_balanced_avl_left_shift l r Balanced -> height_avl t = S (height_avl l) -> has_grown_left t k d l r Balanced. Inductive bal_grow_left_spec (k : Int) (d : B) (l r : avl_tree) (b : bal) : Set := Balance_Grow_Left_Spec_Intro : forall t : avl_tree, is_avl t -> lin_avl t = lin_avl (Avl_Node k d l r b) -> equiv t (Avl_Node k d l r b) -> {hasnot_grown_left t k d l r b} + {has_grown_left t k d l r b} -> bal_grow_left_spec k d l r b. Lemma balance_left : forall (k : Int) (d : B) (l r : avl_tree) (b : bal), is_avl l -> is_below_avl l k -> is_avl r -> is_above_avl r k -> {is_balanced_avl l r b} + {is_balanced_avl_left_shift l r b} -> bal_grow_left_spec k d l r b. (* Goal: forall (k : Int) (d : B) (l r : avl_tree) (b : bal) (_ : is_avl l) (_ : is_below_avl l k) (_ : is_avl r) (_ : is_above_avl r k) (_ : sumbool (is_balanced_avl l r b) (is_balanced_avl_right_shift l r b)), bal_shrunk_right_spec k d l r b *) intros k d l r b avl_l below_avl_l avl_r above_avl_r bal_or_shift. (* Goal: bal_shrunk_right_spec k d l r b *) elim bal_or_shift; clear bal_or_shift. (* l and r is Balanced with respect to b *) (* Goal: forall _ : is_balanced_avl l r b, bal_shrunk_right_spec k d l r b *) (* Goal: forall _ : is_balanced_avl_right_shift l r b, bal_shrunk_right_spec k d l r b *) intro Balanced_l. (* Goal: bal_grow_left_spec k d l r b *) (* Goal: forall _ : is_balanced_avl_left_shift l r b, bal_grow_left_spec k d l r b *) apply Balance_Grow_Left_Spec_Intro with (Avl_Node k d l r b). (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Node_Is_Avl; assumption. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. (* Goal: equiv (Avl_Node k d l r Right_Balanced) (Avl_Node k d l r Balanced) *) (* Goal: sumbool (hasnot_shrunk_right (Avl_Node k d l r Right_Balanced) k d l r Balanced) (has_shrunk_right (Avl_Node k d l r Right_Balanced) k d l r Balanced) *) (* Goal: bal_shrunk_right_spec k d l r Right_Balanced *) apply equiv_refl. (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) left. (* Goal: hasnot_grown_left (Avl_Node k d l r b) k d l r b *) (* Goal: forall _ : is_balanced_avl_left_shift l r b, bal_grow_left_spec k d l r b *) apply Hasnot_Grown_Left_Bal. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. (* l and r is'nt Balanced with respect to b *) (* Goal: forall _ : is_balanced_avl_right_shift l r b, bal_shrunk_right_spec k d l r b *) elim b; clear b; intros Balanced_shift_l. (* b=Left_Balanced *) (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) elim (rebalance_left k d l r Left_Balanced); try assumption. (* Goal: forall (x : avl_tree) (_ : and (is_avl x) (and (@eq (list (prod Int B)) (lin_avl x) (lin_avl (Avl_Node k d l r Right_Balanced))) (and (equiv x (Avl_Node k d l r Right_Balanced)) match r with | Avl_Nil => True | Avl_Node i b a a0 (Left_Balanced as b0) => @eq nat (height_avl x) (height_avl r) | Avl_Node i b a a0 (Balanced as b0) => @eq nat (height_avl x) (S (height_avl r)) | Avl_Node i b a a0 (Right_Balanced as b0) => @eq nat (height_avl x) (height_avl r) end))), bal_grow_right_spec k d l r Right_Balanced *) (* Goal: @eq nat (S (S (height_avl l))) (height_avl r) *) intros t (avl_t,(lin,(equiv_t,height_t))). (* Goal: bal_grow_left_spec k d l r Left_Balanced *) (* Goal: @eq nat (height_avl l) (S (S (height_avl r))) *) (* Goal: bal_grow_left_spec k d l r Balanced *) (* Goal: bal_grow_left_spec k d l r Right_Balanced *) apply Balance_Grow_Left_Spec_Intro with t. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: sumbool (hasnot_grown_left t k d l r Left_Balanced) (has_grown_left t k d l r Left_Balanced) *) (* Goal: @eq nat (height_avl l) (S (S (height_avl r))) *) (* Goal: bal_grow_left_spec k d l r Balanced *) (* Goal: bal_grow_left_spec k d l r Right_Balanced *) clear lin equiv_t avl_l below_avl_l. (* Goal: sumbool (hasnot_shrunk_right t k d l r Right_Balanced) (has_shrunk_right t k d l r Right_Balanced) *) (* Goal: @eq nat (S (S (height_avl l))) (height_avl r) *) generalize height_t; clear height_t. (* Goal: forall _ : match r with | Avl_Nil => True | Avl_Node i b a a0 (Left_Balanced as b0) => @eq nat (height_avl t) (height_avl r) | Avl_Node i b a a0 (Balanced as b0) => @eq nat (height_avl t) (S (height_avl r)) | Avl_Node i b a a0 (Right_Balanced as b0) => @eq nat (height_avl t) (height_avl r) end, sumbool (hasnot_shrunk_right t k d l r Right_Balanced) (has_shrunk_right t k d l r Right_Balanced) *) (* Goal: @eq nat (S (S (height_avl l))) (height_avl r) *) generalize Balanced_shift_l; clear Balanced_shift_l. (* Goal: forall (_ : is_balanced_avl_left_shift l r Left_Balanced) (_ : match l with | Avl_Nil => True | Avl_Node i b a a0 (Left_Balanced as b0) => @eq nat (height_avl t) (height_avl l) | Avl_Node i b a a0 (Balanced as b0) => @eq nat (height_avl t) (S (height_avl l)) | Avl_Node i b a a0 (Right_Balanced as b0) => @eq nat (height_avl t) (height_avl l) end), sumbool (hasnot_shrunk_left t k d l r Left_Balanced) (has_shrunk_left t k d l r Left_Balanced) *) (* Goal: @eq nat (height_avl l) (S (S (height_avl r))) *) (* Goal: bal_shrunk_left_spec k d l r Balanced *) (* Goal: bal_shrunk_left_spec k d l r Right_Balanced *) case l; clear l. (* Goal: forall (_ : is_balanced_avl_right_shift l Avl_Nil Right_Balanced) (_ : True), sumbool (hasnot_shrunk_right t k d l Avl_Nil Right_Balanced) (has_shrunk_right t k d l Avl_Nil Right_Balanced) *) (* Goal: forall (i : Int) (b : B) (a a0 : avl_tree) (b0 : bal) (_ : is_balanced_avl_right_shift l (Avl_Node i b a a0 b0) Right_Balanced) (_ : match b0 with | Left_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node i b a a0 b0)) | Balanced => @eq nat (height_avl t) (S (height_avl (Avl_Node i b a a0 b0))) | Right_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node i b a a0 b0)) end), sumbool (hasnot_shrunk_right t k d l (Avl_Node i b a a0 b0) Right_Balanced) (has_shrunk_right t k d l (Avl_Node i b a a0 b0) Right_Balanced) *) (* Goal: @eq nat (S (S (height_avl l))) (height_avl r) *) intro u0. (* Goal: lin_del_spec key d Avl_Nil Avl_Nil *) (* Goal: equiv_del key Avl_Nil Avl_Nil *) (* Goal: sumbool (@eq nat (height_avl Avl_Nil) (height_avl Avl_Nil)) (@eq nat (height_avl Avl_Nil) (S (height_avl Avl_Nil))) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, delete_spec key a) (a0 : avl_tree) (_ : forall _ : is_avl a0, delete_spec key a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), delete_spec key (Avl_Node i b a a0 b0) *) elimtype False. (* Goal: False *) (* Goal: forall (i : Int) (b : B) (a a0 : avl_tree) (b0 : bal) (_ : is_balanced_avl_right_shift l (Avl_Node i b a a0 b0) Right_Balanced) (_ : match b0 with | Left_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node i b a a0 b0)) | Balanced => @eq nat (height_avl t) (S (height_avl (Avl_Node i b a a0 b0))) | Right_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node i b a a0 b0)) end), sumbool (hasnot_shrunk_right t k d l (Avl_Node i b a a0 b0) Right_Balanced) (has_shrunk_right t k d l (Avl_Node i b a a0 b0) Right_Balanced) *) (* Goal: @eq nat (S (S (height_avl l))) (height_avl r) *) inversion_clear u0. (* Goal: False *) (* Goal: forall (i : Int) (b : B) (a a0 : avl_tree) (b0 : bal) (_ : is_balanced_avl_right_shift l (Avl_Node i b a a0 b0) Right_Balanced) (_ : match b0 with | Left_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node i b a a0 b0)) | Balanced => @eq nat (height_avl t) (S (height_avl (Avl_Node i b a a0 b0))) | Right_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node i b a a0 b0)) end), sumbool (hasnot_shrunk_right t k d l (Avl_Node i b a a0 b0) Right_Balanced) (has_shrunk_right t k d l (Avl_Node i b a a0 b0) Right_Balanced) *) (* Goal: @eq nat (S (S (height_avl l))) (height_avl r) *) discriminate H. (* Goal: forall (i : Int) (b : B) (a a0 : avl_tree) (b0 : bal) (_ : is_balanced_avl_left_shift (Avl_Node i b a a0 b0) r Left_Balanced) (_ : match b0 with | Left_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node i b a a0 b0)) | Balanced => @eq nat (height_avl t) (S (height_avl (Avl_Node i b a a0 b0))) | Right_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node i b a a0 b0)) end), sumbool (hasnot_shrunk_left t k d (Avl_Node i b a a0 b0) r Left_Balanced) (has_shrunk_left t k d (Avl_Node i b a a0 b0) r Left_Balanced) *) (* Goal: @eq nat (height_avl l) (S (S (height_avl r))) *) (* Goal: bal_shrunk_left_spec k d l r Balanced *) (* Goal: bal_shrunk_left_spec k d l r Right_Balanced *) intros kl dl ll rl bl. (* Goal: forall (_ : is_balanced_avl_left_shift (Avl_Node kl dl ll rl bl) r Left_Balanced) (_ : match bl with | Left_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node kl dl ll rl bl)) | Balanced => @eq nat (height_avl t) (S (height_avl (Avl_Node kl dl ll rl bl))) | Right_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node kl dl ll rl bl)) end), sumbool (hasnot_shrunk_left t k d (Avl_Node kl dl ll rl bl) r Left_Balanced) (has_shrunk_left t k d (Avl_Node kl dl ll rl bl) r Left_Balanced) *) (* Goal: @eq nat (height_avl l) (S (S (height_avl r))) *) (* Goal: bal_shrunk_left_spec k d l r Balanced *) (* Goal: bal_shrunk_left_spec k d l r Right_Balanced *) elim bl; clear bl; simpl in |- *; intros Balanced_shift_l height_t. (* bl=Left_Balanced *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) left. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Hasnot_Grown_Left_Shift_Left; assumption. (* bl=Balanced *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) right. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Has_Grown_Left_Shift_Left; assumption. (* bl=Right_Balanced *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) left. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Hasnot_Grown_Left_Shift_Left; assumption. (* side premisses of (Elim (rebalance ... )) *) (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear Balanced_shift_l; assumption. (* b=Balanced *) (* Goal: bal_grow_left_spec k d l r Balanced *) (* Goal: bal_grow_left_spec k d l r Right_Balanced *) apply Balance_Grow_Left_Spec_Intro with (Avl_Node k d l r Left_Balanced). (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Node_Is_Avl; try assumption. (* Goal: is_balanced_avl l r Left_Balanced *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node k d l r Left_Balanced)) (lin_avl (Avl_Node k d l r Balanced)) *) (* Goal: equiv (Avl_Node k d l r Left_Balanced) (Avl_Node k d l r Balanced) *) (* Goal: sumbool (hasnot_shrunk_left (Avl_Node k d l r Left_Balanced) k d l r Balanced) (has_shrunk_left (Avl_Node k d l r Left_Balanced) k d l r Balanced) *) (* Goal: bal_shrunk_left_spec k d l r Right_Balanced *) apply Is_Left_Balanced_Avl. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear Balanced_shift_l; assumption. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. (* Goal: equiv (Avl_Node k d l r Right_Balanced) (Avl_Node k d l r Balanced) *) (* Goal: sumbool (hasnot_shrunk_right (Avl_Node k d l r Right_Balanced) k d l r Balanced) (has_shrunk_right (Avl_Node k d l r Right_Balanced) k d l r Balanced) *) (* Goal: bal_shrunk_right_spec k d l r Right_Balanced *) apply equiv_refl. (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) right. (* Goal: has_grown_left (Avl_Node k d l r Left_Balanced) k d l r Balanced *) (* Goal: bal_grow_left_spec k d l r Right_Balanced *) apply Has_Grown_Left_Shift_Balanced. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. (* b=Right_Balanced *) (* Goal: bal_grow_left_spec k d l r Right_Balanced *) apply Balance_Grow_Left_Spec_Intro with (Avl_Node k d l r Balanced). (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Node_Is_Avl; try assumption. (* Goal: is_balanced_avl l r Balanced *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node k d l r Balanced)) (lin_avl (Avl_Node k d l r Left_Balanced)) *) (* Goal: equiv (Avl_Node k d l r Balanced) (Avl_Node k d l r Left_Balanced) *) (* Goal: sumbool (hasnot_shrunk_right (Avl_Node k d l r Balanced) k d l r Left_Balanced) (has_shrunk_right (Avl_Node k d l r Balanced) k d l r Left_Balanced) *) (* Goal: bal_shrunk_right_spec k d l r Balanced *) (* Goal: bal_shrunk_right_spec k d l r Right_Balanced *) apply Is_Fully_Balanced_Avl. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear Balanced_shift_l; assumption. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. (* Goal: equiv (Avl_Node k d l r Right_Balanced) (Avl_Node k d l r Balanced) *) (* Goal: sumbool (hasnot_shrunk_right (Avl_Node k d l r Right_Balanced) k d l r Balanced) (has_shrunk_right (Avl_Node k d l r Right_Balanced) k d l r Balanced) *) (* Goal: bal_shrunk_right_spec k d l r Right_Balanced *) apply equiv_refl. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *. (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) left. (* Goal: hasnot_grown_left (Avl_Node k d l r Balanced) k d l r Right_Balanced *) apply Hasnot_Grown_Left_Shift_Right. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. Qed. (**********************************************************************) Inductive hasnot_grown_right (t : avl_tree) (k : Int) (d : B) (l r : avl_tree) : bal -> Prop := | Hasnot_Grown_Right_Bal : forall b : bal, is_balanced_avl l r b -> height_avl t = height_avl (Avl_Node k d l r b) -> hasnot_grown_right t k d l r b | Hasnot_Grown_Right_Shift_Left : is_balanced_avl_right_shift l r Left_Balanced -> height_avl t = S (height_avl r) -> hasnot_grown_right t k d l r Left_Balanced | Hasnot_Grown_Right_Shift_Right : is_balanced_avl_right_shift l r Right_Balanced -> height_avl t = height_avl r -> hasnot_grown_right t k d l r Right_Balanced. Inductive has_grown_right (t : avl_tree) (k : Int) (d : B) (l r : avl_tree) : bal -> Prop := | Has_Grown_Right_Shift_Balanced : is_balanced_avl_right_shift l r Balanced -> height_avl t = S (height_avl r) -> has_grown_right t k d l r Balanced | Has_Grown_Right_Shift_Right : is_balanced_avl_right_shift l r Right_Balanced -> height_avl t = S (height_avl r) -> has_grown_right t k d l r Right_Balanced. Inductive bal_grow_right_spec (k : Int) (d : B) (l r : avl_tree) (b : bal) : Set := Balance_Grow_Right_Spec_Intro : forall t : avl_tree, is_avl t -> lin_avl t = lin_avl (Avl_Node k d l r b) -> equiv t (Avl_Node k d l r b) -> {hasnot_grown_right t k d l r b} + {has_grown_right t k d l r b} -> bal_grow_right_spec k d l r b. Lemma balance_right : forall (k : Int) (d : B) (l r : avl_tree) (b : bal), is_avl l -> is_below_avl l k -> is_avl r -> is_above_avl r k -> {is_balanced_avl l r b} + {is_balanced_avl_right_shift l r b} -> bal_grow_right_spec k d l r b. (* Goal: forall (k : Int) (d : B) (l r : avl_tree) (b : bal) (_ : is_avl l) (_ : is_below_avl l k) (_ : is_avl r) (_ : is_above_avl r k) (_ : sumbool (is_balanced_avl l r b) (is_balanced_avl_right_shift l r b)), bal_shrunk_right_spec k d l r b *) intros k d l r b avl_l below_avl_l avl_r above_avl_r bal_or_shift. (* Goal: bal_shrunk_right_spec k d l r b *) elim bal_or_shift; clear bal_or_shift. (* l and r is Balanced with respect to b *) (* Goal: forall _ : is_balanced_avl l r b, bal_shrunk_right_spec k d l r b *) (* Goal: forall _ : is_balanced_avl_right_shift l r b, bal_shrunk_right_spec k d l r b *) intro Balanced_l. (* Goal: bal_grow_right_spec k d l r b *) (* Goal: forall _ : is_balanced_avl_right_shift l r b, bal_grow_right_spec k d l r b *) apply Balance_Grow_Right_Spec_Intro with (Avl_Node k d l r b). (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Node_Is_Avl; assumption. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. (* Goal: equiv (Avl_Node k d l r Right_Balanced) (Avl_Node k d l r Balanced) *) (* Goal: sumbool (hasnot_shrunk_right (Avl_Node k d l r Right_Balanced) k d l r Balanced) (has_shrunk_right (Avl_Node k d l r Right_Balanced) k d l r Balanced) *) (* Goal: bal_shrunk_right_spec k d l r Right_Balanced *) apply equiv_refl. (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) left. (* Goal: hasnot_grown_right (Avl_Node k d l r b) k d l r b *) (* Goal: forall _ : is_balanced_avl_right_shift l r b, bal_grow_right_spec k d l r b *) apply Hasnot_Grown_Right_Bal. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. (* l and r is'nt Balanced with respect to b *) (* Goal: forall _ : is_balanced_avl_right_shift l r b, bal_shrunk_right_spec k d l r b *) elim b; clear b; intros Balanced_shift_l. (* b=Left_Balanced *) (* Goal: bal_grow_right_spec k d l r Left_Balanced *) (* Goal: bal_grow_right_spec k d l r Balanced *) (* Goal: bal_grow_right_spec k d l r Right_Balanced *) apply Balance_Grow_Right_Spec_Intro with (Avl_Node k d l r Balanced). (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Node_Is_Avl; try assumption. (* Goal: is_balanced_avl l r Balanced *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node k d l r Balanced)) (lin_avl (Avl_Node k d l r Left_Balanced)) *) (* Goal: equiv (Avl_Node k d l r Balanced) (Avl_Node k d l r Left_Balanced) *) (* Goal: sumbool (hasnot_shrunk_right (Avl_Node k d l r Balanced) k d l r Left_Balanced) (has_shrunk_right (Avl_Node k d l r Balanced) k d l r Left_Balanced) *) (* Goal: bal_shrunk_right_spec k d l r Balanced *) (* Goal: bal_shrunk_right_spec k d l r Right_Balanced *) apply Is_Fully_Balanced_Avl. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear Balanced_shift_l; assumption. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. (* Goal: equiv (Avl_Node k d l r Right_Balanced) (Avl_Node k d l r Balanced) *) (* Goal: sumbool (hasnot_shrunk_right (Avl_Node k d l r Right_Balanced) k d l r Balanced) (has_shrunk_right (Avl_Node k d l r Right_Balanced) k d l r Balanced) *) (* Goal: bal_shrunk_right_spec k d l r Right_Balanced *) apply equiv_refl. (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) left. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *. (* Goal: hasnot_grown_right (Avl_Node k d l r Balanced) k d l r Left_Balanced *) (* Goal: bal_grow_right_spec k d l r Balanced *) (* Goal: bal_grow_right_spec k d l r Right_Balanced *) apply Hasnot_Grown_Right_Shift_Left. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *. (* Goal: @eq nat (S (height_avl l)) (S (height_avl r)) *) (* Goal: bal_shrunk_right_spec k d l r Balanced *) (* Goal: bal_shrunk_right_spec k d l r Right_Balanced *) inversion_clear Balanced_shift_l. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H; trivial. (* b=Balanced *) (* Goal: bal_grow_right_spec k d l r Balanced *) (* Goal: bal_grow_right_spec k d l r Right_Balanced *) apply Balance_Grow_Right_Spec_Intro with (Avl_Node k d l r Right_Balanced). (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Node_Is_Avl; try assumption. (* Goal: is_balanced_avl l r Right_Balanced *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node k d l r Right_Balanced)) (lin_avl (Avl_Node k d l r Balanced)) *) (* Goal: equiv (Avl_Node k d l r Right_Balanced) (Avl_Node k d l r Balanced) *) (* Goal: sumbool (hasnot_shrunk_right (Avl_Node k d l r Right_Balanced) k d l r Balanced) (has_shrunk_right (Avl_Node k d l r Right_Balanced) k d l r Balanced) *) (* Goal: bal_shrunk_right_spec k d l r Right_Balanced *) apply Is_Right_Balanced_Avl. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear Balanced_shift_l; assumption. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. (* Goal: equiv (Avl_Node k d l r Right_Balanced) (Avl_Node k d l r Balanced) *) (* Goal: sumbool (hasnot_shrunk_right (Avl_Node k d l r Right_Balanced) k d l r Balanced) (has_shrunk_right (Avl_Node k d l r Right_Balanced) k d l r Balanced) *) (* Goal: bal_shrunk_right_spec k d l r Right_Balanced *) apply equiv_refl. (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) right. (* Goal: has_grown_right (Avl_Node k d l r Right_Balanced) k d l r Balanced *) (* Goal: bal_grow_right_spec k d l r Right_Balanced *) apply Has_Grown_Right_Shift_Balanced. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. (* b=Right_Balanced *) (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) elim (rebalance_right k d l r Right_Balanced); try assumption. (* Goal: forall (x : avl_tree) (_ : and (is_avl x) (and (@eq (list (prod Int B)) (lin_avl x) (lin_avl (Avl_Node k d l r Right_Balanced))) (and (equiv x (Avl_Node k d l r Right_Balanced)) match r with | Avl_Nil => True | Avl_Node i b a a0 (Left_Balanced as b0) => @eq nat (height_avl x) (height_avl r) | Avl_Node i b a a0 (Balanced as b0) => @eq nat (height_avl x) (S (height_avl r)) | Avl_Node i b a a0 (Right_Balanced as b0) => @eq nat (height_avl x) (height_avl r) end))), bal_grow_right_spec k d l r Right_Balanced *) (* Goal: @eq nat (S (S (height_avl l))) (height_avl r) *) intros t (avl_t,(lin,(equiv_t,height_t))). (* Goal: bal_grow_right_spec k d l r Right_Balanced *) (* Goal: @eq nat (S (S (height_avl l))) (height_avl r) *) apply Balance_Grow_Right_Spec_Intro with t. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: sumbool (hasnot_grown_right t k d l r Right_Balanced) (has_grown_right t k d l r Right_Balanced) *) (* Goal: @eq nat (S (S (height_avl l))) (height_avl r) *) clear lin equiv_t avl_l below_avl_l avl_r above_avl_r. (* Goal: sumbool (hasnot_shrunk_right t k d l r Right_Balanced) (has_shrunk_right t k d l r Right_Balanced) *) (* Goal: @eq nat (S (S (height_avl l))) (height_avl r) *) generalize height_t; clear height_t. (* Goal: forall _ : match r with | Avl_Nil => True | Avl_Node i b a a0 (Left_Balanced as b0) => @eq nat (height_avl t) (height_avl r) | Avl_Node i b a a0 (Balanced as b0) => @eq nat (height_avl t) (S (height_avl r)) | Avl_Node i b a a0 (Right_Balanced as b0) => @eq nat (height_avl t) (height_avl r) end, sumbool (hasnot_shrunk_right t k d l r Right_Balanced) (has_shrunk_right t k d l r Right_Balanced) *) (* Goal: @eq nat (S (S (height_avl l))) (height_avl r) *) generalize Balanced_shift_l; clear Balanced_shift_l. (* Goal: forall (_ : is_balanced_avl_right_shift l r Right_Balanced) (_ : match r with | Avl_Nil => True | Avl_Node i b a a0 (Left_Balanced as b0) => @eq nat (height_avl t) (height_avl r) | Avl_Node i b a a0 (Balanced as b0) => @eq nat (height_avl t) (S (height_avl r)) | Avl_Node i b a a0 (Right_Balanced as b0) => @eq nat (height_avl t) (height_avl r) end), sumbool (hasnot_shrunk_right t k d l r Right_Balanced) (has_shrunk_right t k d l r Right_Balanced) *) (* Goal: @eq nat (S (S (height_avl l))) (height_avl r) *) case r; clear r. (* Goal: forall (_ : is_balanced_avl_right_shift l Avl_Nil Right_Balanced) (_ : True), sumbool (hasnot_shrunk_right t k d l Avl_Nil Right_Balanced) (has_shrunk_right t k d l Avl_Nil Right_Balanced) *) (* Goal: forall (i : Int) (b : B) (a a0 : avl_tree) (b0 : bal) (_ : is_balanced_avl_right_shift l (Avl_Node i b a a0 b0) Right_Balanced) (_ : match b0 with | Left_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node i b a a0 b0)) | Balanced => @eq nat (height_avl t) (S (height_avl (Avl_Node i b a a0 b0))) | Right_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node i b a a0 b0)) end), sumbool (hasnot_shrunk_right t k d l (Avl_Node i b a a0 b0) Right_Balanced) (has_shrunk_right t k d l (Avl_Node i b a a0 b0) Right_Balanced) *) (* Goal: @eq nat (S (S (height_avl l))) (height_avl r) *) intro u0. (* Goal: lin_del_spec key d Avl_Nil Avl_Nil *) (* Goal: equiv_del key Avl_Nil Avl_Nil *) (* Goal: sumbool (@eq nat (height_avl Avl_Nil) (height_avl Avl_Nil)) (@eq nat (height_avl Avl_Nil) (S (height_avl Avl_Nil))) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, delete_spec key a) (a0 : avl_tree) (_ : forall _ : is_avl a0, delete_spec key a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), delete_spec key (Avl_Node i b a a0 b0) *) elimtype False. (* Goal: False *) (* Goal: forall (i : Int) (b : B) (a a0 : avl_tree) (b0 : bal) (_ : is_balanced_avl_right_shift l (Avl_Node i b a a0 b0) Right_Balanced) (_ : match b0 with | Left_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node i b a a0 b0)) | Balanced => @eq nat (height_avl t) (S (height_avl (Avl_Node i b a a0 b0))) | Right_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node i b a a0 b0)) end), sumbool (hasnot_shrunk_right t k d l (Avl_Node i b a a0 b0) Right_Balanced) (has_shrunk_right t k d l (Avl_Node i b a a0 b0) Right_Balanced) *) (* Goal: @eq nat (S (S (height_avl l))) (height_avl r) *) inversion_clear u0. (* Goal: False *) (* Goal: forall (i : Int) (b : B) (a a0 : avl_tree) (b0 : bal) (_ : is_balanced_avl_right_shift l (Avl_Node i b a a0 b0) Right_Balanced) (_ : match b0 with | Left_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node i b a a0 b0)) | Balanced => @eq nat (height_avl t) (S (height_avl (Avl_Node i b a a0 b0))) | Right_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node i b a a0 b0)) end), sumbool (hasnot_shrunk_right t k d l (Avl_Node i b a a0 b0) Right_Balanced) (has_shrunk_right t k d l (Avl_Node i b a a0 b0) Right_Balanced) *) (* Goal: @eq nat (S (S (height_avl l))) (height_avl r) *) discriminate H. (* Goal: forall (i : Int) (b : B) (a a0 : avl_tree) (b0 : bal) (_ : is_balanced_avl_right_shift l (Avl_Node i b a a0 b0) Right_Balanced) (_ : match b0 with | Left_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node i b a a0 b0)) | Balanced => @eq nat (height_avl t) (S (height_avl (Avl_Node i b a a0 b0))) | Right_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node i b a a0 b0)) end), sumbool (hasnot_shrunk_right t k d l (Avl_Node i b a a0 b0) Right_Balanced) (has_shrunk_right t k d l (Avl_Node i b a a0 b0) Right_Balanced) *) (* Goal: @eq nat (S (S (height_avl l))) (height_avl r) *) intros kr dr lr rr br. (* Goal: forall (_ : is_balanced_avl_right_shift l (Avl_Node kr dr lr rr br) Right_Balanced) (_ : match br with | Left_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node kr dr lr rr br)) | Balanced => @eq nat (height_avl t) (S (height_avl (Avl_Node kr dr lr rr br))) | Right_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node kr dr lr rr br)) end), sumbool (hasnot_shrunk_right t k d l (Avl_Node kr dr lr rr br) Right_Balanced) (has_shrunk_right t k d l (Avl_Node kr dr lr rr br) Right_Balanced) *) (* Goal: @eq nat (S (S (height_avl l))) (height_avl r) *) elim br; clear br; simpl in |- *; intros Balanced_shift_l height_t. (* br=Left_Balanced *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) left. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Hasnot_Grown_Right_Shift_Right; assumption. (* br=Balanced *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) right. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Has_Grown_Right_Shift_Right; assumption. (* br=Right_Balanced *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) left. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Hasnot_Grown_Right_Shift_Right; assumption. (* side premisses of (Elim (rebalance ... )) *) (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear Balanced_shift_l; assumption. Qed. (*********************************************************************) (* equiv_ins *) Inductive equiv_ins (key : Int) (update : B -> B) (init : B) (t0 t : avl_tree) : Prop := equiv_ins_intro : (forall (k : Int) (data : B), Equal k key -> lookup k t0 data -> lookup k t (update data)) -> (forall k : Int, Equal k key -> (forall data : B, lookup k t0 data -> False) -> lookup k t (update init)) -> (forall (k : Int) (data : B), ~ Equal k key -> lookup k t0 data -> lookup k t data) -> (forall (k : Int) (data : B), ~ Equal k key -> lookup k t data -> lookup k t0 data) -> equiv_ins key update init t0 t. Lemma inv_equiv_ins_equal0 : forall (key : Int) (update : B -> B) (init : B) (t0 t : avl_tree) (k : Int) (data : B), equiv_ins key update init t0 t -> Equal k key -> lookup k t0 data -> lookup k t (update data). (* Goal: forall (key : Int) (t0 t : avl_tree) (k : Int) (d : B) (_ : equiv_del key t0 t) (_ : not (Equal k key)) (_ : lookup k t d), lookup k t0 d *) intros. (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 r data), lookup k0 (Avl_Node k d Avl_Nil r b) data *) inversion_clear H. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply H2; assumption. Qed. Lemma inv_equiv_ins_equal1 : forall (key : Int) (update : B -> B) (init : B) (t0 t : avl_tree) (k : Int), equiv_ins key update init t0 t -> Equal k key -> (forall data : B, lookup k t0 data -> False) -> lookup k t (update init). (* Goal: forall (key : Int) (t0 t : avl_tree) (k : Int) (d : B) (_ : equiv_del key t0 t) (_ : not (Equal k key)) (_ : lookup k t d), lookup k t0 d *) intros. (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 r data), lookup k0 (Avl_Node k d Avl_Nil r b) data *) inversion_clear H. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply H3; assumption. Qed. Lemma inv_equiv_ins_notequal0 : forall (key : Int) (update : B -> B) (init : B) (t0 t : avl_tree) (k : Int) (data : B), equiv_ins key update init t0 t -> ~ Equal k key -> lookup k t0 data -> lookup k t data. (* Goal: forall (key : Int) (t0 t : avl_tree) (k : Int) (d : B) (_ : equiv_del key t0 t) (_ : not (Equal k key)) (_ : lookup k t d), lookup k t0 d *) intros. (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 r data), lookup k0 (Avl_Node k d Avl_Nil r b) data *) inversion_clear H. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply H4; assumption. Qed. Lemma inv_equiv_ins_notequal1 : forall (key : Int) (update : B -> B) (init : B) (t0 t : avl_tree) (k : Int) (data : B), equiv_ins key update init t0 t -> ~ Equal k key -> lookup k t data -> lookup k t0 data. (* Goal: forall (key : Int) (t0 t : avl_tree) (k : Int) (d : B) (_ : equiv_del key t0 t) (_ : not (Equal k key)) (_ : lookup k t d), lookup k t0 d *) intros. (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 r data), lookup k0 (Avl_Node k d Avl_Nil r b) data *) inversion_clear H. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply H5; assumption. Qed. Lemma equiv_ins_equiv_equiv_ins : forall (key : Int) (update : B -> B) (init : B) (t0 t1 t2 : avl_tree), equiv_ins key update init t0 t1 -> equiv t1 t2 -> equiv_ins key update init t0 t2. (* Goal: forall (key : Int) (update : forall _ : B, B) (init : B) (t0 t1 t2 : avl_tree) (_ : equiv_ins key update init t0 t1) (_ : equiv t1 t2), equiv_ins key update init t0 t2 *) intros key update init t0 t1 t2 equiv_ins0 equiv0. (* Goal: equiv_ins key update init (Avl_Node k0 d0 l0 r0 b0) (Avl_Node k0 d0 l0 r b) *) apply equiv_ins_intro. (* Goal: forall (k : Int) (data : B) (_ : Equal k key) (_ : lookup k t0 data), lookup k t2 (update data) *) (* Goal: forall (k : Int) (_ : Equal k key) (_ : forall (data : B) (_ : lookup k t0 data), False), lookup k t2 (update init) *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k t0 data), lookup k t2 data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k t2 data), lookup k t0 data *) intros k data equal Lookup_t0. (* Goal: lookup k t2 data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k t2 data), lookup k t0 data *) apply (inv_equiv_t0_t1 t1 t2). (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply (inv_equiv_ins_equal0 key update init t0 t1 k data); assumption. (* Goal: forall (k : Int) (_ : Equal k key) (_ : forall (data : B) (_ : lookup k t0 data), False), lookup k t2 (update init) *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k t0 data), lookup k t2 data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k t2 data), lookup k t0 data *) intros k equal not_Lookup_t0. (* Goal: lookup k t2 data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k t2 data), lookup k t0 data *) apply (inv_equiv_t0_t1 t1 t2). (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply (inv_equiv_ins_equal1 key update init t0 t1 k); assumption. (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k t0 data), lookup k t2 data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k t2 data), lookup k t0 data *) intros k data notequal Lookup_t0. (* Goal: lookup k t2 data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k t2 data), lookup k t0 data *) apply (inv_equiv_t0_t1 t1 t2). (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply (inv_equiv_ins_notequal0 key update init t0 t1 k data); assumption. (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k t2 data), lookup k t0 data *) intros k data notequal Lookup_t2. (* Goal: lookup k t0 data *) apply (inv_equiv_ins_notequal1 key update init t0 t1 k data). (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply (inv_equiv_t1_t0 t1 t2); assumption. Qed. Lemma equiv_ins_below : forall (key : Int) (update : B -> B) (init : B) (t0 t : avl_tree) (k0 : Int), equiv_ins key update init t0 t -> Less key k0 -> is_below t0 k0 -> is_below t k0. (* Goal: forall (key : Int) (update : forall _ : B, B) (init : B) (t0 t : avl_tree) (k0 : Int) (_ : equiv_ins key update init t0 t) (_ : Less key k0) (_ : is_below t0 k0), is_below t k0 *) intros key update init t0 t k0 equiv_t0 less below_t0. (* Goal: is_below t k *) apply lookup_less_below. (* Goal: forall (k : Int) (d : B) (_ : lookup k t d), Less k0 k *) intros k d lookup_t. (* Goal: Less k0 k *) elim (equal_dec k key). (* Goal: forall _ : Equal k key, Less k0 k *) (* Goal: forall _ : not (Equal k key), Less k0 k *) intro equal. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply (equal_less_less k key k0); assumption. (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) intro notequal. generalize (inv_equiv_ins_notequal1 key update init t0 t k d equiv_t0 notequal lookup_t). (* Goal: forall _ : lookup k (Avl_Node k0 d0 l0 r0 b0) data, lookup k (Avl_Node k0 d0 l r0 b) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l r0 b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) intro lookup_t0. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply (lookup_below_less k t0 d); assumption. Qed. Lemma equiv_ins_above : forall (key : Int) (update : B -> B) (init : B) (t0 t : avl_tree) (k0 : Int), equiv_ins key update init t0 t -> Less k0 key -> is_above t0 k0 -> is_above t k0. (* Goal: forall (key : Int) (update : forall _ : B, B) (init : B) (t0 t : avl_tree) (k0 : Int) (_ : equiv_ins key update init t0 t) (_ : Less k0 key) (_ : is_above t0 k0), is_above t k0 *) intros key update init t0 t k0 equiv_t0 greater below_t0. (* Goal: is_above t k *) apply lookup_greater_above. (* Goal: forall (k : Int) (d : B) (_ : lookup k t d), Less k0 k *) intros k d lookup_t. (* Goal: Less k0 k *) elim (equal_dec k key). (* Goal: forall _ : Equal k key, Less k0 k *) (* Goal: forall _ : not (Equal k key), Less k0 k *) intro equal. (* Goal: Less k0 k *) (* Goal: forall _ : not (Equal k key), Less k0 k *) apply (less_equal_less k0 key k). (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply equal_sym; assumption. (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) intro notequal. generalize (inv_equiv_ins_notequal1 key update init t0 t k d equiv_t0 notequal lookup_t). (* Goal: forall _ : lookup k (Avl_Node k0 d0 l0 r0 b0) data, lookup k (Avl_Node k0 d0 l r0 b) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l r0 b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) intro lookup_t0. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply (lookup_above_greater k t0 d); assumption. Qed. (***************************************************************************) Lemma leave_is_avl : forall (k : Int) (d : B), is_avl (Avl_Node k d Avl_Nil Avl_Nil Balanced). (* Goal: forall (key : Int) (t0 t : avl_tree) (k : Int) (d : B) (_ : equiv_del key t0 t) (_ : not (Equal k key)) (_ : lookup k t d), lookup k t0 d *) intros. (* Goal: is_avl (Avl_Node k d' l r b) *) apply Node_Is_Avl. (* Goal: is_avl Avl_Nil *) (* Goal: is_balanced_avl Avl_Nil Avl_Nil Balanced *) (* Goal: is_below_avl Avl_Nil k *) (* Goal: is_above_avl Avl_Nil k *) apply Nil_Is_Avl. (* Goal: is_avl Avl_Nil *) (* Goal: is_balanced_avl Avl_Nil Avl_Nil Balanced *) (* Goal: is_below_avl Avl_Nil k *) (* Goal: is_above_avl Avl_Nil k *) apply Nil_Is_Avl. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) apply Is_Fully_Balanced_Avl; trivial. (* Goal: is_below_avl Avl_Nil k *) (* Goal: is_above_avl Avl_Nil k *) apply Below_Avl_Nil. (* Goal: is_above_avl Avl_Nil k *) apply Above_Avl_Nil. Qed. Lemma equiv_ins_nil : forall (key : Int) (update : B -> B) (init : B), equiv_ins key update init Avl_Nil (Avl_Node key (update init) Avl_Nil Avl_Nil Balanced). (* Goal: forall (key : Int) (update : forall _ : B, B) (init : B), equiv_ins key update init Avl_Nil (Avl_Node key (update init) Avl_Nil Avl_Nil Balanced) *) intros key update init. (* Goal: equiv_ins key update init (Avl_Node k0 d0 l0 r0 b0) (Avl_Node k0 d0 l0 r b) *) apply equiv_ins_intro. (* Goal: forall (k : Int) (data : B) (_ : Equal k key) (_ : lookup k Avl_Nil data), lookup k (Avl_Node key (update init) Avl_Nil Avl_Nil Balanced) (update data) *) (* Goal: forall (k : Int) (_ : Equal k key) (_ : forall (data : B) (_ : lookup k Avl_Nil data), False), lookup k (Avl_Node key (update init) Avl_Nil Avl_Nil Balanced) (update init) *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k Avl_Nil data), lookup k (Avl_Node key (update init) Avl_Nil Avl_Nil Balanced) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node key (update init) Avl_Nil Avl_Nil Balanced) data), lookup k Avl_Nil data *) intros k data equal lookup_nil. (* Goal: lin_del_spec key d Avl_Nil Avl_Nil *) (* Goal: equiv_del key Avl_Nil Avl_Nil *) (* Goal: sumbool (@eq nat (height_avl Avl_Nil) (height_avl Avl_Nil)) (@eq nat (height_avl Avl_Nil) (S (height_avl Avl_Nil))) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, delete_spec key a) (a0 : avl_tree) (_ : forall _ : is_avl a0, delete_spec key a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), delete_spec key (Avl_Node i b a a0 b0) *) elimtype False. (* Goal: False *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node key (update init) Avl_Nil Avl_Nil Balanced) data), lookup k Avl_Nil data *) apply (inv_lookup_nil k data lookup_nil). (* Goal: forall (k : Int) (_ : Equal k key) (_ : forall (data : B) (_ : lookup k Avl_Nil data), False), lookup k (Avl_Node key (update init) Avl_Nil Avl_Nil Balanced) (update init) *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k Avl_Nil data), lookup k (Avl_Node key (update init) Avl_Nil Avl_Nil Balanced) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node key (update init) Avl_Nil Avl_Nil Balanced) data), lookup k Avl_Nil data *) intros k equal notlookup_nil. (* Goal: lookup k (Avl_Node key (update init) Avl_Nil Avl_Nil Balanced) (update init) *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k Avl_Nil data), lookup k (Avl_Node key (update init) Avl_Nil Avl_Nil Balanced) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node key (update init) Avl_Nil Avl_Nil Balanced) data), lookup k Avl_Nil data *) rewrite (equal_eq k key equal). (* Goal: lookup k0 (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d0 *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup_Equal. (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node key (update init) Avl_Nil Avl_Nil Balanced) data), lookup k Avl_Nil data *) intros k data notequal lookup_nil. (* Goal: lin_del_spec key d Avl_Nil Avl_Nil *) (* Goal: equiv_del key Avl_Nil Avl_Nil *) (* Goal: sumbool (@eq nat (height_avl Avl_Nil) (height_avl Avl_Nil)) (@eq nat (height_avl Avl_Nil) (S (height_avl Avl_Nil))) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, delete_spec key a) (a0 : avl_tree) (_ : forall _ : is_avl a0, delete_spec key a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), delete_spec key (Avl_Node i b a a0 b0) *) elimtype False. (* Goal: False *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node key (update init) Avl_Nil Avl_Nil Balanced) data), lookup k Avl_Nil data *) apply (inv_lookup_nil k data lookup_nil). (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node key (update init) Avl_Nil Avl_Nil Balanced) data), lookup k Avl_Nil data *) intros k data notequal lookup_nil. elim (inv_lookup k key (update init) Avl_Nil Avl_Nil Balanced data lookup_nil). (* Goal: forall (_ : is_balanced_avl_right_shift l Avl_Nil Right_Balanced) (_ : True), sumbool (hasnot_shrunk_right t k d l Avl_Nil Right_Balanced) (has_shrunk_right t k d l Avl_Nil Right_Balanced) *) (* Goal: forall (i : Int) (b : B) (a a0 : avl_tree) (b0 : bal) (_ : is_balanced_avl_right_shift l (Avl_Node i b a a0 b0) Right_Balanced) (_ : match b0 with | Left_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node i b a a0 b0)) | Balanced => @eq nat (height_avl t) (S (height_avl (Avl_Node i b a a0 b0))) | Right_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node i b a a0 b0)) end), sumbool (hasnot_shrunk_right t k d l (Avl_Node i b a a0 b0) Right_Balanced) (has_shrunk_right t k d l (Avl_Node i b a a0 b0) Right_Balanced) *) (* Goal: @eq nat (S (S (height_avl l))) (height_avl r) *) intro u0. (* Goal: lin_del_spec key d Avl_Nil Avl_Nil *) (* Goal: equiv_del key Avl_Nil Avl_Nil *) (* Goal: sumbool (@eq nat (height_avl Avl_Nil) (height_avl Avl_Nil)) (@eq nat (height_avl Avl_Nil) (S (height_avl Avl_Nil))) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, delete_spec key a) (a0 : avl_tree) (_ : forall _ : is_avl a0, delete_spec key a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), delete_spec key (Avl_Node i b a a0 b0) *) elimtype False. (* Goal: False *) (* Goal: lookup k1 (Avl_Node k d l r0 b0) d1 *) (* Goal: lookup k1 (Avl_Node k d l r0 b0) d1 *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k0)) (_ : lookup k1 (Avl_Node k d l r0 b0) data), lookup k1 (Avl_Node k0 d0 l0 r0 b0) data *) apply notequal. (* Goal: Equal k key *) (* Goal: forall _ : or (lookup k Avl_Nil data) (lookup k Avl_Nil data), lookup k Avl_Nil data *) elim u0; intros u00 u01. (* Goal: Equal k key *) (* Goal: forall _ : or (lookup k Avl_Nil data) (lookup k Avl_Nil data), lookup k Avl_Nil data *) rewrite u00. (* Goal: Equal k0 k0 *) (* Goal: lookup k1 (Avl_Node k d l r0 b0) d1 *) (* Goal: lookup k1 (Avl_Node k d l r0 b0) d1 *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k0)) (_ : lookup k1 (Avl_Node k d l r0 b0) data), lookup k1 (Avl_Node k0 d0 l0 r0 b0) data *) apply equal_refl. (* Goal: forall _ : or (lookup k Avl_Nil data) (lookup k Avl_Nil data), lookup k Avl_Nil data *) tauto. Qed. Lemma avl_ins_eq : forall (k : Int) (d : B) (l r : avl_tree) (b : bal) (d' : B), is_avl (Avl_Node k d l r b) -> is_avl (Avl_Node k d' l r b). (* Goal: forall (k : Int) (d : B) (l r : avl_tree) (b : bal) (d' : B) (_ : is_avl (Avl_Node k d l r b)), is_avl (Avl_Node k d' l r b) *) intros k d l r b d' avl_t. (* Goal: is_avl (Avl_Node k d' l r b) *) apply Node_Is_Avl. (* Goal: is_avl l *) (* Goal: is_avl r *) (* Goal: is_balanced_avl l r b *) (* Goal: is_below_avl l k *) (* Goal: is_above_avl r k *) apply (inv_is_avl_left k d l r b avl_t). (* Goal: is_avl r *) (* Goal: is_balanced_avl l r b *) (* Goal: is_below_avl l k *) (* Goal: is_above_avl r k *) apply (inv_is_avl_right k d l r b avl_t). (* Goal: is_balanced_avl l r b *) (* Goal: is_below_avl l k *) (* Goal: is_above_avl r k *) apply (inv_is_avl_is_balanced_avl k d l r b avl_t). (* Goal: is_below_avl l k *) (* Goal: is_above_avl r k *) apply (inv_is_avl_is_is_below_avl k d l r b avl_t). (* Goal: is_above_avl r k *) apply (inv_is_avl_is_is_above_avl k d l r b avl_t). Qed. Lemma equiv_ins_eq : forall (key : Int) (update : B -> B) (init : B) (k : Int) (d : B) (l0 r0 : avl_tree) (b : bal), is_avl (Avl_Node k d l0 r0 b) -> Equal key k -> equiv_ins key update init (Avl_Node k d l0 r0 b) (Avl_Node k (update d) l0 r0 b). (* Goal: forall (key : Int) (update : forall _ : B, B) (init : B) (k : Int) (d : B) (l0 r0 : avl_tree) (b : bal) (_ : is_avl (Avl_Node k d l0 r0 b)) (_ : Equal key k), equiv_ins key update init (Avl_Node k d l0 r0 b) (Avl_Node k (update d) l0 r0 b) *) intros key update init k d l0 r0 b avl_t0 equal. (* Goal: equiv_ins key update init (Avl_Node k d l0 r0 b) (Avl_Node k (update d) l0 r0 b) *) generalize (avl_ins_eq k d l0 r0 b (update d) avl_t0). (* Goal: forall _ : is_avl (Avl_Node k (update d) l0 r0 b), equiv_ins key update init (Avl_Node k d l0 r0 b) (Avl_Node k (update d) l0 r0 b) *) intro avl_t. (* Goal: equiv_ins key update init (Avl_Node k0 d0 l0 r0 b0) (Avl_Node k0 d0 l0 r b) *) apply equiv_ins_intro. (* Goal: forall (k0 : Int) (data : B) (_ : Equal k0 key) (_ : lookup k0 (Avl_Node k d l0 r0 b) data), lookup k0 (Avl_Node k (update d) l0 r0 b) (update data) *) (* Goal: forall (k0 : Int) (_ : Equal k0 key) (_ : forall (data : B) (_ : lookup k0 (Avl_Node k d l0 r0 b) data), False), lookup k0 (Avl_Node k (update d) l0 r0 b) (update init) *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 key)) (_ : lookup k0 (Avl_Node k d l0 r0 b) data), lookup k0 (Avl_Node k (update d) l0 r0 b) data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 key)) (_ : lookup k0 (Avl_Node k (update d) l0 r0 b) data), lookup k0 (Avl_Node k d l0 r0 b) data *) intros k0 data equal1. (* Goal: forall _ : forall (data : B) (_ : lookup k0 (Avl_Node k d l0 r0 b) data), False, lookup k0 (Avl_Node k (update d) l0 r0 b) (update init) *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 key)) (_ : lookup k0 (Avl_Node k d l0 r0 b) data), lookup k0 (Avl_Node k (update d) l0 r0 b) data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 key)) (_ : lookup k0 (Avl_Node k (update d) l0 r0 b) data), lookup k0 (Avl_Node k d l0 r0 b) data *) generalize (equal_trans k0 key k equal1 equal). (* Goal: forall (_ : Equal k0 k) (_ : forall (data : B) (_ : lookup k0 (Avl_Node k d l0 r0 b) data), False), lookup k0 (Avl_Node k (update d) l0 r0 b) (update init) *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 key)) (_ : lookup k0 (Avl_Node k d l0 r0 b) data), lookup k0 (Avl_Node k (update d) l0 r0 b) data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 key)) (_ : lookup k0 (Avl_Node k (update d) l0 r0 b) data), lookup k0 (Avl_Node k d l0 r0 b) data *) intro equal2. (* Goal: forall _ : lookup k (Avl_Node k0 d0 l0 r0 b0) data, lookup k (Avl_Node k0 d0 l r0 b) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l r0 b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) intro lookup_t0. (* Goal: lookup k0 (Avl_Node k (update d) l0 r0 b) (update data) *) (* Goal: forall (k0 : Int) (_ : Equal k0 key) (_ : forall (data : B) (_ : lookup k0 (Avl_Node k d l0 r0 b) data), False), lookup k0 (Avl_Node k (update d) l0 r0 b) (update init) *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 key)) (_ : lookup k0 (Avl_Node k d l0 r0 b) data), lookup k0 (Avl_Node k (update d) l0 r0 b) data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 key)) (_ : lookup k0 (Avl_Node k (update d) l0 r0 b) data), lookup k0 (Avl_Node k d l0 r0 b) data *) rewrite (lookup_avl_inv_equal k0 k d l0 r0 b data avl_t0 equal2 lookup_t0). (* Goal: lookup k0 (Avl_Node k d l0 r0 b) d *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 key)) (_ : lookup k0 (Avl_Node k d l0 r0 b) data), lookup k0 (Avl_Node k (update d) l0 r0 b) data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 key)) (_ : lookup k0 (Avl_Node k (update d) l0 r0 b) data), lookup k0 (Avl_Node k d l0 r0 b) data *) rewrite (equal_eq k0 k equal2). (* Goal: lookup k0 (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d0 *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup_Equal. (* Goal: forall (k0 : Int) (_ : Equal k0 key) (_ : forall (data : B) (_ : lookup k0 (Avl_Node k d l0 r0 b) data), False), lookup k0 (Avl_Node k (update d) l0 r0 b) (update init) *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 key)) (_ : lookup k0 (Avl_Node k d l0 r0 b) data), lookup k0 (Avl_Node k (update d) l0 r0 b) data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 key)) (_ : lookup k0 (Avl_Node k (update d) l0 r0 b) data), lookup k0 (Avl_Node k d l0 r0 b) data *) intros k0 equal1. (* Goal: forall _ : forall (data : B) (_ : lookup k0 (Avl_Node k d l0 r0 b) data), False, lookup k0 (Avl_Node k (update d) l0 r0 b) (update init) *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 key)) (_ : lookup k0 (Avl_Node k d l0 r0 b) data), lookup k0 (Avl_Node k (update d) l0 r0 b) data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 key)) (_ : lookup k0 (Avl_Node k (update d) l0 r0 b) data), lookup k0 (Avl_Node k d l0 r0 b) data *) generalize (equal_trans k0 key k equal1 equal). (* Goal: forall (_ : Equal k0 k) (_ : forall (data : B) (_ : lookup k0 (Avl_Node k d l0 r0 b) data), False), lookup k0 (Avl_Node k (update d) l0 r0 b) (update init) *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 key)) (_ : lookup k0 (Avl_Node k d l0 r0 b) data), lookup k0 (Avl_Node k (update d) l0 r0 b) data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 key)) (_ : lookup k0 (Avl_Node k (update d) l0 r0 b) data), lookup k0 (Avl_Node k d l0 r0 b) data *) intro equal2. (* Goal: forall _ : forall (data : B) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), False, lookup k (Avl_Node k0 d0 l r0 b) (update init) *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), lookup k (Avl_Node k0 d0 l r0 b) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l r0 b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) intro not_lookup_t0. (* Goal: lin_del_spec key d Avl_Nil Avl_Nil *) (* Goal: equiv_del key Avl_Nil Avl_Nil *) (* Goal: sumbool (@eq nat (height_avl Avl_Nil) (height_avl Avl_Nil)) (@eq nat (height_avl Avl_Nil) (S (height_avl Avl_Nil))) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, delete_spec key a) (a0 : avl_tree) (_ : forall _ : is_avl a0, delete_spec key a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), delete_spec key (Avl_Node i b a a0 b0) *) elimtype False. (* Goal: False *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 key)) (_ : lookup k0 (Avl_Node k d l0 r0 b) data), lookup k0 (Avl_Node k (update d) l0 r0 b) data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 key)) (_ : lookup k0 (Avl_Node k (update d) l0 r0 b) data), lookup k0 (Avl_Node k d l0 r0 b) data *) apply (not_lookup_t0 d). (* Goal: lookup k0 (Avl_Node k d l0 r0 b) d *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 key)) (_ : lookup k0 (Avl_Node k d l0 r0 b) data), lookup k0 (Avl_Node k (update d) l0 r0 b) data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 key)) (_ : lookup k0 (Avl_Node k (update d) l0 r0 b) data), lookup k0 (Avl_Node k d l0 r0 b) data *) rewrite (equal_eq k0 k equal2). (* Goal: lookup k0 (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d0 *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup_Equal. (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 key)) (_ : lookup k0 (Avl_Node k (update d) l0 r0 b) data), lookup k0 (Avl_Node k d l0 r0 b) data *) intros k0 data notequal0. (* Goal: forall _ : lookup k (Avl_Node k0 d0 l0 r0 b0) data, lookup k (Avl_Node k0 d0 l r0 b) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l r0 b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) intro lookup_t0. (* Goal: forall (_ : is_balanced_avl_right_shift l Avl_Nil Right_Balanced) (_ : True), sumbool (hasnot_shrunk_right t k d l Avl_Nil Right_Balanced) (has_shrunk_right t k d l Avl_Nil Right_Balanced) *) (* Goal: forall (i : Int) (b : B) (a a0 : avl_tree) (b0 : bal) (_ : is_balanced_avl_right_shift l (Avl_Node i b a a0 b0) Right_Balanced) (_ : match b0 with | Left_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node i b a a0 b0)) | Balanced => @eq nat (height_avl t) (S (height_avl (Avl_Node i b a a0 b0))) | Right_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node i b a a0 b0)) end), sumbool (hasnot_shrunk_right t k d l (Avl_Node i b a a0 b0) Right_Balanced) (has_shrunk_right t k d l (Avl_Node i b a a0 b0) Right_Balanced) *) (* Goal: @eq nat (S (S (height_avl l))) (height_avl r) *) elim (inv_lookup k0 k d l0 r0 b data lookup_t0); intro u0. (* Goal: lin_del_spec key d Avl_Nil Avl_Nil *) (* Goal: equiv_del key Avl_Nil Avl_Nil *) (* Goal: sumbool (@eq nat (height_avl Avl_Nil) (height_avl Avl_Nil)) (@eq nat (height_avl Avl_Nil) (S (height_avl Avl_Nil))) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, delete_spec key a) (a0 : avl_tree) (_ : forall _ : is_avl a0, delete_spec key a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), delete_spec key (Avl_Node i b a a0 b0) *) elimtype False. (* Goal: False *) (* Goal: lookup k0 (Avl_Node k d l0 r0 b) data *) apply notequal0. (* Goal: False *) (* Goal: False *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), lookup k (Avl_Node k0 d0 l0 r b) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) elim u0; clear u0; intros u0 u1. (* Goal: Equal k0 key *) (* Goal: lookup k0 (Avl_Node k d l0 r0 b) data *) rewrite <- u0. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply equal_sym; assumption. (* Goal: False *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), lookup k (Avl_Node k0 d0 l0 r b) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) elim u0; clear u0; intro u0. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Left; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Right; assumption. (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 key)) (_ : lookup k0 (Avl_Node k (update d) l0 r0 b) data), lookup k0 (Avl_Node k d l0 r0 b) data *) intros k0 data notequal0. (* Goal: forall _ : lookup k (Avl_Node k0 d0 l r0 b) data, lookup k (Avl_Node k0 d0 l0 r0 b0) data *) intro lookup_t. (* Goal: forall (_ : is_balanced_avl_right_shift l Avl_Nil Right_Balanced) (_ : True), sumbool (hasnot_shrunk_right t k d l Avl_Nil Right_Balanced) (has_shrunk_right t k d l Avl_Nil Right_Balanced) *) (* Goal: forall (i : Int) (b : B) (a a0 : avl_tree) (b0 : bal) (_ : is_balanced_avl_right_shift l (Avl_Node i b a a0 b0) Right_Balanced) (_ : match b0 with | Left_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node i b a a0 b0)) | Balanced => @eq nat (height_avl t) (S (height_avl (Avl_Node i b a a0 b0))) | Right_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node i b a a0 b0)) end), sumbool (hasnot_shrunk_right t k d l (Avl_Node i b a a0 b0) Right_Balanced) (has_shrunk_right t k d l (Avl_Node i b a a0 b0) Right_Balanced) *) (* Goal: @eq nat (S (S (height_avl l))) (height_avl r) *) elim (inv_lookup k0 k (update d) l0 r0 b data lookup_t); intro u0. (* Goal: lin_del_spec key d Avl_Nil Avl_Nil *) (* Goal: equiv_del key Avl_Nil Avl_Nil *) (* Goal: sumbool (@eq nat (height_avl Avl_Nil) (height_avl Avl_Nil)) (@eq nat (height_avl Avl_Nil) (S (height_avl Avl_Nil))) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, delete_spec key a) (a0 : avl_tree) (_ : forall _ : is_avl a0, delete_spec key a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), delete_spec key (Avl_Node i b a a0 b0) *) elimtype False. (* Goal: False *) (* Goal: lookup k0 (Avl_Node k d l0 r0 b) data *) apply notequal0. (* Goal: False *) (* Goal: False *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), lookup k (Avl_Node k0 d0 l0 r b) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) elim u0; clear u0; intros u0 u1. (* Goal: Equal k0 key *) (* Goal: lookup k0 (Avl_Node k d l0 r0 b) data *) rewrite <- u0. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply equal_sym; assumption. (* Goal: False *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), lookup k (Avl_Node k0 d0 l0 r b) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) elim u0; clear u0; intro u0. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Left; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Right; assumption. Qed. Lemma equiv_ins_left : forall (key : Int) (update : B -> B) (init : B) (k0 : Int) (d0 : B) (l0 r0 : avl_tree) (b0 : bal) (l : avl_tree) (b : bal), is_avl (Avl_Node k0 d0 l0 r0 b0) -> Less key k0 -> equiv_ins key update init l0 l -> equiv_ins key update init (Avl_Node k0 d0 l0 r0 b0) (Avl_Node k0 d0 l r0 b). (* Goal: forall (key : Int) (update : forall _ : B, B) (init : B) (k0 : Int) (d0 : B) (l0 r0 : avl_tree) (b0 : bal) (l : avl_tree) (b : bal) (_ : is_avl (Avl_Node k0 d0 l0 r0 b0)) (_ : Less key k0) (_ : equiv_ins key update init l0 l), equiv_ins key update init (Avl_Node k0 d0 l0 r0 b0) (Avl_Node k0 d0 l r0 b) *) intros key update init k0 d0 l0 r0 b0 l b avl_t0 less equiv_ins_l0. (* Goal: equiv_ins key update init (Avl_Node k0 d0 l0 r0 b0) (Avl_Node k0 d0 l0 r b) *) apply equiv_ins_intro. (* Goal: forall (k : Int) (data : B) (_ : Equal k key) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), lookup k (Avl_Node k0 d0 l r0 b) (update data) *) (* Goal: forall (k : Int) (_ : Equal k key) (_ : forall (data : B) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), False), lookup k (Avl_Node k0 d0 l r0 b) (update init) *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), lookup k (Avl_Node k0 d0 l r0 b) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l r0 b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) intros k data equal. (* Goal: forall _ : lookup k (Avl_Node k0 d0 l0 r0 b0) data, lookup k (Avl_Node k0 d0 l r0 b) (update data) *) (* Goal: forall (k : Int) (_ : Equal k key) (_ : forall (data : B) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), False), lookup k (Avl_Node k0 d0 l r0 b) (update init) *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), lookup k (Avl_Node k0 d0 l r0 b) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l r0 b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) generalize (equal_less_less k key k0 equal less); intro less1. (* Goal: forall _ : lookup k (Avl_Node k0 d0 l0 r0 b0) data, lookup k (Avl_Node k0 d0 l r0 b) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l r0 b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) intro lookup_t0. (* Goal: lookup k1 (Avl_Node k0 d0 l0 r0 b0) d1 *) (* Goal: lookup k1 (Avl_Node k0 d0 l0 r0 b0) d1 *) apply Lookup_Left. (* Goal: lookup k l (update data) *) (* Goal: forall (k : Int) (_ : Equal k key) (_ : forall (data : B) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), False), lookup k (Avl_Node k0 d0 l r0 b) (update init) *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), lookup k (Avl_Node k0 d0 l r0 b) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l r0 b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) apply (inv_equiv_ins_equal0 key update init l0 l). (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply (lookup_avl_inv_less k k0 d0 l0 r0 b0 data); assumption. (* Goal: forall (k : Int) (_ : Equal k key) (_ : forall (data : B) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), False), lookup k (Avl_Node k0 d0 l r0 b) (update init) *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), lookup k (Avl_Node k0 d0 l r0 b) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l r0 b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) intros k equal. (* Goal: forall _ : forall (data : B) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), False, lookup k (Avl_Node k0 d0 l r0 b) (update init) *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), lookup k (Avl_Node k0 d0 l r0 b) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l r0 b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) intro not_lookup_t0. (* Goal: lookup k1 (Avl_Node k0 d0 l0 r0 b0) d1 *) (* Goal: lookup k1 (Avl_Node k0 d0 l0 r0 b0) d1 *) apply Lookup_Left. (* Goal: lookup k l (update init) *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), lookup k (Avl_Node k0 d0 l r0 b) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l r0 b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) apply (inv_equiv_ins_equal1 key update init l0 l). (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: forall (data : B) (_ : lookup k r0 data), False *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), lookup k (Avl_Node k0 d0 l0 r b) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) intros data lookup_l0. (* Goal: False *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), lookup k (Avl_Node k0 d0 l0 r b) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) apply (not_lookup_t0 data). (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Left; assumption. (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l r0 b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) intros k data notequal. (* Goal: forall _ : lookup k (Avl_Node k0 d0 l0 r0 b0) data, lookup k (Avl_Node k0 d0 l r0 b) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l r0 b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) intro lookup_t0. (* Goal: forall (_ : is_balanced_avl_right_shift l Avl_Nil Right_Balanced) (_ : True), sumbool (hasnot_shrunk_right t k d l Avl_Nil Right_Balanced) (has_shrunk_right t k d l Avl_Nil Right_Balanced) *) (* Goal: forall (i : Int) (b : B) (a a0 : avl_tree) (b0 : bal) (_ : is_balanced_avl_right_shift l (Avl_Node i b a a0 b0) Right_Balanced) (_ : match b0 with | Left_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node i b a a0 b0)) | Balanced => @eq nat (height_avl t) (S (height_avl (Avl_Node i b a a0 b0))) | Right_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node i b a a0 b0)) end), sumbool (hasnot_shrunk_right t k d l (Avl_Node i b a a0 b0) Right_Balanced) (has_shrunk_right t k d l (Avl_Node i b a a0 b0) Right_Balanced) *) (* Goal: @eq nat (S (S (height_avl l))) (height_avl r) *) elim (inv_lookup k k0 d0 l0 r0 b0 data lookup_t0); intro u0. (* Goal: False *) (* Goal: False *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), lookup k (Avl_Node k0 d0 l0 r b) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) elim u0; clear u0; intros u0 u1. (* Goal: lookup k (Avl_Node k0 d0 l0 r0 b0) data *) (* Goal: lookup k (Avl_Node k0 d0 l0 r0 b0) data *) rewrite u0. (* Goal: lookup k (Avl_Node k d0 l0 r0 b0) data *) (* Goal: lookup k (Avl_Node k0 d0 l0 r0 b0) data *) rewrite u1. (* Goal: lookup k0 (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d0 *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup_Equal. (* Goal: lookup k (Avl_Node k0 d0 l0 r0 b0) data *) elim u0; clear u0; intros u0. (* Goal: lookup k1 (Avl_Node k0 d0 l0 r0 b0) d1 *) (* Goal: lookup k1 (Avl_Node k0 d0 l0 r0 b0) d1 *) apply Lookup_Left. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply (inv_equiv_ins_notequal0 key update init l0 l); assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Right; assumption. (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l r0 b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) intros k data notequal. (* Goal: forall _ : lookup k (Avl_Node k0 d0 l r0 b) data, lookup k (Avl_Node k0 d0 l0 r0 b0) data *) intro lookup_t. (* Goal: forall (_ : is_balanced_avl_right_shift l Avl_Nil Right_Balanced) (_ : True), sumbool (hasnot_shrunk_right t k d l Avl_Nil Right_Balanced) (has_shrunk_right t k d l Avl_Nil Right_Balanced) *) (* Goal: forall (i : Int) (b : B) (a a0 : avl_tree) (b0 : bal) (_ : is_balanced_avl_right_shift l (Avl_Node i b a a0 b0) Right_Balanced) (_ : match b0 with | Left_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node i b a a0 b0)) | Balanced => @eq nat (height_avl t) (S (height_avl (Avl_Node i b a a0 b0))) | Right_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node i b a a0 b0)) end), sumbool (hasnot_shrunk_right t k d l (Avl_Node i b a a0 b0) Right_Balanced) (has_shrunk_right t k d l (Avl_Node i b a a0 b0) Right_Balanced) *) (* Goal: @eq nat (S (S (height_avl l))) (height_avl r) *) elim (inv_lookup k k0 d0 l r0 b data lookup_t); intro u0. (* Goal: False *) (* Goal: False *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), lookup k (Avl_Node k0 d0 l0 r b) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) elim u0; clear u0; intros u0 u1. (* Goal: lookup k (Avl_Node k0 d0 l0 r0 b0) data *) (* Goal: lookup k (Avl_Node k0 d0 l0 r0 b0) data *) rewrite u0. (* Goal: lookup k (Avl_Node k d0 l0 r0 b0) data *) (* Goal: lookup k (Avl_Node k0 d0 l0 r0 b0) data *) rewrite u1. (* Goal: lookup k0 (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d0 *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup_Equal. (* Goal: lookup k (Avl_Node k0 d0 l0 r0 b0) data *) elim u0; clear u0; intros u0. (* Goal: lookup k1 (Avl_Node k0 d0 l0 r0 b0) d1 *) (* Goal: lookup k1 (Avl_Node k0 d0 l0 r0 b0) d1 *) apply Lookup_Left. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply (inv_equiv_ins_notequal1 key update init l0 l); assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Right; assumption. Qed. Lemma equiv_ins_right : forall (key : Int) (update : B -> B) (init : B) (k0 : Int) (d0 : B) (l0 r0 : avl_tree) (b0 : bal) (r : avl_tree) (b : bal), is_avl (Avl_Node k0 d0 l0 r0 b0) -> Less k0 key -> equiv_ins key update init r0 r -> equiv_ins key update init (Avl_Node k0 d0 l0 r0 b0) (Avl_Node k0 d0 l0 r b). (* Goal: forall (key : Int) (update : forall _ : B, B) (init : B) (k0 : Int) (d0 : B) (l0 r0 : avl_tree) (b0 : bal) (r : avl_tree) (b : bal) (_ : is_avl (Avl_Node k0 d0 l0 r0 b0)) (_ : Less k0 key) (_ : equiv_ins key update init r0 r), equiv_ins key update init (Avl_Node k0 d0 l0 r0 b0) (Avl_Node k0 d0 l0 r b) *) intros key update init k0 d0 l0 r0 b0 r b avl_t0 less equiv_r0. (* Goal: equiv_del key (Avl_Node k0 d0 l0 r0 b0) (Avl_Node k0 d0 l0 r b) *) inversion_clear equiv_r0. (* Goal: equiv_ins key update init (Avl_Node k0 d0 l0 r0 b0) (Avl_Node k0 d0 l0 r b) *) apply equiv_ins_intro. (* Goal: forall (k : Int) (data : B) (_ : Equal k key) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), lookup k (Avl_Node k0 d0 l0 r b) (update data) *) (* Goal: forall (k : Int) (_ : Equal k key) (_ : forall (data : B) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), False), lookup k (Avl_Node k0 d0 l0 r b) (update init) *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), lookup k (Avl_Node k0 d0 l0 r b) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) intros k data equal lookup_t0. (* Goal: lookup k1 (Avl_Node k0 d0 l0 l b0) d1 *) apply Lookup_Right. (* Goal: lookup k r (update data) *) (* Goal: forall (k : Int) (_ : Equal k key) (_ : forall (data : B) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), False), lookup k (Avl_Node k0 d0 l0 r b) (update init) *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), lookup k (Avl_Node k0 d0 l0 r b) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) apply H. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply (lookup_avl_inv_greater k k0 d0 l0 r0 b0 data); try assumption. (* Goal: Less k0 k *) (* Goal: forall _ : not (Equal k key), Less k0 k *) apply (less_equal_less k0 key k). (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply equal_sym; assumption. (* Goal: forall (k : Int) (_ : Equal k key) (_ : forall (data : B) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), False), lookup k (Avl_Node k0 d0 l0 r b) (update init) *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), lookup k (Avl_Node k0 d0 l0 r b) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) intros k equal not_lookup_t0. (* Goal: lookup k1 (Avl_Node k0 d0 l0 l b0) d1 *) apply Lookup_Right. (* Goal: lookup k r (update init) *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), lookup k (Avl_Node k0 d0 l0 r b) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) apply H0. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: forall (data : B) (_ : lookup k r0 data), False *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), lookup k (Avl_Node k0 d0 l0 r b) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) intros data lookup_l0. (* Goal: False *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), lookup k (Avl_Node k0 d0 l0 r b) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) apply (not_lookup_t0 data). (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Right; assumption. (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), lookup k (Avl_Node k0 d0 l0 r b) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) intros k data notequal lookup_t0. (* Goal: False *) (* Goal: equiv_del key Avl_Nil Avl_Nil *) (* Goal: sumbool (@eq nat (height_avl Avl_Nil) (height_avl Avl_Nil)) (@eq nat (height_avl Avl_Nil) (S (height_avl Avl_Nil))) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, delete_spec key a) (a0 : avl_tree) (_ : forall _ : is_avl a0, delete_spec key a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), delete_spec key (Avl_Node i b a a0 b0) *) inversion_clear lookup_t0. (* Goal: lookup k0 (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d0 *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup_Equal. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Left; assumption. (* Goal: lookup k1 (Avl_Node k0 d0 l0 l b0) d1 *) apply Lookup_Right. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply H1; assumption. (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) intros k data notequal lookup_t. (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 r data), lookup k0 (Avl_Node k d Avl_Nil r b) data *) inversion_clear lookup_t. (* Goal: lookup k0 (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d0 *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup_Equal. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Left; assumption. (* Goal: lookup k1 (Avl_Node k0 d0 l0 l b0) d1 *) apply Lookup_Right. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply H2; assumption. Qed. (***************************************************************************) Inductive lin_ins_spec (key : Int) (update : B -> B) (init : B) (t0 t : avl_tree) : Prop := | Lin_Ins_New : forall l0 l1 : list (Int * B), lin_avl t0 = l0 ++ l1 -> lin_avl t = l0 ++ (key, update init) :: l1 -> lin_ins_spec key update init t0 t | Lin_Ins_Update : forall (d : B) (l0 l1 : list (Int * B)), lin_avl t0 = l0 ++ (key, d) :: l1 -> lin_avl t = l0 ++ (key, update d) :: l1 -> lin_ins_spec key update init t0 t. Inductive avl_ins_spec (key : Int) (update : B -> B) (init : B) (t0 : avl_tree) : Set := Avl_Ins_Spec_Intro : forall t : avl_tree, lookup_dec_spec key t0 -> is_avl t -> lin_ins_spec key update init t0 t -> equiv_ins key update init t0 t -> {height_avl t = height_avl t0} + {height_avl t = S (height_avl t0)} -> avl_ins_spec key update init t0. (***************************************************************************) (***************************************************************************) Lemma insert_avl : forall (key : Int) (update : B -> B) (init : B) (t0 : avl_tree), is_avl t0 -> avl_ins_spec key update init t0. (* Goal: forall (key : Int) (update : forall _ : B, B) (init : B) (t0 : avl_tree) (_ : is_avl t0), avl_ins_spec key update init t0 *) intros key update init t0. (* Goal: forall _ : is_avl t0, avl_ins_spec key update init t0 *) elim t0; clear t0. (* t0=Avl_Nil *) (* Goal: forall _ : is_avl Avl_Nil, delete_spec key Avl_Nil *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, delete_spec key a) (a0 : avl_tree) (_ : forall _ : is_avl a0, delete_spec key a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), delete_spec key (Avl_Node i b a a0 b0) *) intros avl_t0. apply Avl_Ins_Spec_Intro with (t := Avl_Node key (update init) Avl_Nil Avl_Nil Balanced). (* Goal: lookup_dec_spec key (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: is_avl t *) (* Goal: lin_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: equiv_ins key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl t) (height_avl (Avl_Node k0 d0 l0 r0 b0))) (@eq nat (height_avl t) (S (height_avl (Avl_Node k0 d0 l0 r0 b0)))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_right_shift l0 r b0) *) apply Not_Lookup. (* Goal: forall d : B, not (lookup key Avl_Nil d) *) (* Goal: is_avl (Avl_Node key (update init) Avl_Nil Avl_Nil Balanced) *) (* Goal: lin_ins_spec key update init Avl_Nil (Avl_Node key (update init) Avl_Nil Avl_Nil Balanced) *) (* Goal: equiv_ins key update init Avl_Nil (Avl_Node key (update init) Avl_Nil Avl_Nil Balanced) *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node key (update init) Avl_Nil Avl_Nil Balanced)) (height_avl Avl_Nil)) (@eq nat (height_avl (Avl_Node key (update init) Avl_Nil Avl_Nil Balanced)) (S (height_avl Avl_Nil))) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, avl_ins_spec key update init a) (a0 : avl_tree) (_ : forall _ : is_avl a0, avl_ins_spec key update init a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), avl_ins_spec key update init (Avl_Node i b a a0 b0) *) unfold not in |- *; intros d lookup0. (* Goal: False *) (* Goal: is_avl (Avl_Node key (update init) Avl_Nil Avl_Nil Balanced) *) (* Goal: lin_ins_spec key update init Avl_Nil (Avl_Node key (update init) Avl_Nil Avl_Nil Balanced) *) (* Goal: equiv_ins key update init Avl_Nil (Avl_Node key (update init) Avl_Nil Avl_Nil Balanced) *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node key (update init) Avl_Nil Avl_Nil Balanced)) (height_avl Avl_Nil)) (@eq nat (height_avl (Avl_Node key (update init) Avl_Nil Avl_Nil Balanced)) (S (height_avl Avl_Nil))) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, avl_ins_spec key update init a) (a0 : avl_tree) (_ : forall _ : is_avl a0, avl_ins_spec key update init a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), avl_ins_spec key update init (Avl_Node i b a a0 b0) *) apply (inv_lookup_nil key d lookup0). (* Goal: is_avl (Avl_Node key (update init) Avl_Nil Avl_Nil Balanced) *) (* Goal: lin_ins_spec key update init Avl_Nil (Avl_Node key (update init) Avl_Nil Avl_Nil Balanced) *) (* Goal: equiv_ins key update init Avl_Nil (Avl_Node key (update init) Avl_Nil Avl_Nil Balanced) *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node key (update init) Avl_Nil Avl_Nil Balanced)) (height_avl Avl_Nil)) (@eq nat (height_avl (Avl_Node key (update init) Avl_Nil Avl_Nil Balanced)) (S (height_avl Avl_Nil))) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, avl_ins_spec key update init a) (a0 : avl_tree) (_ : forall _ : is_avl a0, avl_ins_spec key update init a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), avl_ins_spec key update init (Avl_Node i b a a0 b0) *) apply leave_is_avl. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) apply Lin_Ins_New with (nil (A:=Int * B)) (nil (A:=Int * B)); trivial. (* Goal: equiv_ins key update init Avl_Nil (Avl_Node key (update init) Avl_Nil Avl_Nil Balanced) *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node key (update init) Avl_Nil Avl_Nil Balanced)) (height_avl Avl_Nil)) (@eq nat (height_avl (Avl_Node key (update init) Avl_Nil Avl_Nil Balanced)) (S (height_avl Avl_Nil))) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, avl_ins_spec key update init a) (a0 : avl_tree) (_ : forall _ : is_avl a0, avl_ins_spec key update init a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), avl_ins_spec key update init (Avl_Node i b a a0 b0) *) apply equiv_ins_nil. (* Goal: forall _ : is_balanced_avl l0 r0 Left_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Left_Balanced)) (S (height_avl l0)) *) (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) right; simpl in |- *; trivial. (* t0=(Avl_Node k0 d0 l0 r0 b0) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, delete_spec key a) (a0 : avl_tree) (_ : forall _ : is_avl a0, delete_spec key a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), delete_spec key (Avl_Node i b a a0 b0) *) intros k0 d0 l0 ih_l0 r0 ih_r0 b0 avl_t0. (* Goal: delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) elim (equal_dec key k0). (* Goal: forall _ : Equal k key, Less k0 k *) (* Goal: forall _ : not (Equal k key), Less k0 k *) intro equal. (* Goal: delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) clear ih_l0 ih_r0. (* Goal: avl_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: forall _ : not (Equal key k0), avl_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) *) apply Avl_Ins_Spec_Intro with (t := Avl_Node k0 (update d0) l0 r0 b0). (* Goal: lookup_dec_spec key (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: is_avl (Avl_Node k0 (update d0) l0 r0 b0) *) (* Goal: lin_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) (Avl_Node k0 (update d0) l0 r0 b0) *) (* Goal: equiv_ins key update init (Avl_Node k0 d0 l0 r0 b0) (Avl_Node k0 (update d0) l0 r0 b0) *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 (update d0) l0 r0 b0)) (height_avl (Avl_Node k0 d0 l0 r0 b0))) (@eq nat (height_avl (Avl_Node k0 (update d0) l0 r0 b0)) (S (height_avl (Avl_Node k0 d0 l0 r0 b0)))) *) (* Goal: forall _ : not (Equal key k0), avl_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup with d0. (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (@cons (prod Int B) (@pair Int B key d1) (lin_avl r0))) *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) rewrite (equal_eq key k0 equal). (* Goal: lookup k0 (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d0 *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup_Equal. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply (avl_ins_eq k0 d0 l0 r0 b0); assumption. (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (@cons (prod Int B) (@pair Int B key d1) (lin_avl r0))) *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) rewrite (equal_eq key k0 equal). (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) apply Lin_Ins_Update with d0 (lin_avl l0) (lin_avl r0); trivial. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply equiv_ins_eq; assumption. (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) left. (* Goal: forall _ : is_balanced_avl l0 r0 Left_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Left_Balanced)) (S (height_avl l0)) *) (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) elim b0; simpl in |- *; trivial. (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) intro notequal. (* Goal: delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) elim (less_dec key k0). (* Goal: forall _ : Less key k0, delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: forall _ : not (Less key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) intro less. (* Goal: delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) elim (ih_l0 (inv_is_avl_left k0 d0 l0 r0 b0 avl_t0)); clear ih_l0 ih_r0. (* Goal: forall (t : avl_tree) (_ : lookup_dec_spec key l0) (_ : is_avl t) (_ : lin_ins_spec key update init l0 t) (_ : equiv_ins key update init l0 t) (_ : sumbool (@eq nat (height_avl t) (height_avl l0)) (@eq nat (height_avl t) (S (height_avl l0)))), avl_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: forall _ : not (Less key k0), avl_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) *) intros l lookup_dec_spec0 avl_l lin_ins_l equiv_ins_l bal_or_shift. (* Goal: avl_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: forall _ : not (Less key k0), avl_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) *) elim (balance_left k0 d0 l r0 b0). (* Goal: forall (t : avl_tree) (_ : is_avl t) (_ : @eq (list (prod Int B)) (lin_avl t) (lin_avl (Avl_Node k0 d0 l0 r b0))) (_ : equiv t (Avl_Node k0 d0 l0 r b0)) (_ : sumbool (hasnot_grown_right t k0 d0 l0 r b0) (has_grown_right t k0 d0 l0 r b0)), avl_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_right_shift l0 r b0) *) intros t avl_t lin_t equiv_t growth_dec. (* Goal: avl_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_right_shift l0 r b0) *) apply Avl_Ins_Spec_Intro with t. (* Goal: lookup_dec_spec key (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: is_avl t *) (* Goal: lin_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: equiv_ins key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl t) (height_avl (Avl_Node k0 d0 l0 r0 b0))) (@eq nat (height_avl t) (S (height_avl (Avl_Node k0 d0 l0 r0 b0)))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_right_shift l0 r b0) *) elim lookup_dec_spec0; clear lookup_dec_spec0. (* Goal: forall (d : B) (_ : lookup key r0 d), lookup_dec_spec key (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: forall _ : forall d : B, not (lookup key r0 d), lookup_dec_spec key (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: forall (d : B) (_ : lookup key (Avl_Node k0 d0 l0 r0 b0) d), lin_del_spec key d (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: equiv_del key (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) intros d lookup_d. (* Goal: lookup_dec_spec key (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: forall _ : forall d : B, not (lookup key r0 d), lookup_dec_spec key (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: is_avl t *) (* Goal: lin_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: equiv_ins key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl t) (height_avl (Avl_Node k0 d0 l0 r0 b0))) (@eq nat (height_avl t) (S (height_avl (Avl_Node k0 d0 l0 r0 b0)))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_right_shift l0 r b0) *) apply Lookup with d. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Left; assumption. (* Goal: forall _ : forall d : B, not (lookup key r0 d), lookup_dec_spec key (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: is_avl t *) (* Goal: lin_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: equiv_ins key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl t) (height_avl (Avl_Node k0 d0 l0 r0 b0))) (@eq nat (height_avl t) (S (height_avl (Avl_Node k0 d0 l0 r0 b0)))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_right_shift l0 r b0) *) intros not_lookup_d0. (* Goal: lookup_dec_spec key (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: is_avl t *) (* Goal: lin_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: equiv_ins key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl t) (height_avl (Avl_Node k0 d0 l0 r0 b0))) (@eq nat (height_avl t) (S (height_avl (Avl_Node k0 d0 l0 r0 b0)))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_right_shift l0 r b0) *) apply Not_Lookup. (* Goal: forall d : B, not (lookup key (Avl_Node k0 d0 l0 r0 b0) d) *) (* Goal: is_avl t *) (* Goal: lin_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: equiv_ins key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl t) (height_avl (Avl_Node k0 d0 l0 r0 b0))) (@eq nat (height_avl t) (S (height_avl (Avl_Node k0 d0 l0 r0 b0)))) *) (* Goal: is_avl l *) (* Goal: is_below_avl l k0 *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k0 *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_left_shift l r0 b0) *) (* Goal: forall _ : not (Less key k0), avl_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) *) unfold not in |- *; intros d lookup_d0. (* Goal: False *) (* Goal: is_avl t *) (* Goal: lin_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: equiv_ins key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl t) (height_avl (Avl_Node k0 d0 l0 r0 b0))) (@eq nat (height_avl t) (S (height_avl (Avl_Node k0 d0 l0 r0 b0)))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_right_shift l0 r b0) *) apply (not_lookup_d0 d). (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply (lookup_avl_inv_less key k0 d0 l0 r0 b0); assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: lin_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: equiv_ins key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl t) (height_avl (Avl_Node k0 d0 l0 r0 b0))) (@eq nat (height_avl t) (S (height_avl (Avl_Node k0 d0 l0 r0 b0)))) *) (* Goal: is_avl l *) (* Goal: is_below_avl l k0 *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k0 *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_left_shift l r0 b0) *) (* Goal: forall _ : not (Less key k0), avl_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) *) elim lin_ins_l; clear lin_ins_l. (* Goal: forall (l1 l2 : list (prod Int B)) (_ : @eq (list (prod Int B)) (lin_avl l0) (@app (prod Int B) l1 (@cons (prod Int B) (@pair Int B key d) l2))) (_ : @eq (list (prod Int B)) (lin_avl l) (@app (prod Int B) l1 l2)), lin_del_spec key d (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: lookup key l0 d *) (* Goal: equiv_del key (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_below_avl l k0 *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k0 *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: forall _ : not (Less key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) intros l1 l2 lin_l0 lin_l. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) apply Lin_Ins_New with l1 (l2 ++ (k0, d0) :: lin_avl r0); simpl in |- *. (* Goal: @eq (list (prod Int B)) (@app (prod Int B) (lin_avl l0) (@cons (prod Int B) (@pair Int B k0 d0) (lin_avl r0))) (@app (prod Int B) l1 (@cons (prod Int B) (@pair Int B key d) (@app (prod Int B) l2 (@cons (prod Int B) (@pair Int B k0 d0) (lin_avl r0))))) *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) l1 (@app (prod Int B) l2 (@cons (prod Int B) (@pair Int B k0 d0) (lin_avl r0)))) *) (* Goal: lookup key l0 d *) (* Goal: equiv_del key (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_below_avl l k0 *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k0 *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: forall _ : not (Less key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) rewrite lin_l0. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite (app_ass l1 l2 ((k0, d0) :: lin_avl r0)); trivial. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite lin_t; simpl in |- *. (* Goal: @eq (list (prod Int B)) (@app (prod Int B) (lin_avl l) (@cons (prod Int B) (@pair Int B k0 d0) (lin_avl r0))) (@app (prod Int B) l1 (@app (prod Int B) l2 (@cons (prod Int B) (@pair Int B k0 d0) (lin_avl r0)))) *) (* Goal: lookup key l0 d *) (* Goal: equiv_del key (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_below_avl l k0 *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k0 *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: forall _ : not (Less key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) rewrite lin_l. (* Goal: @eq (list (prod Int B)) (@app (prod Int B) (@app (prod Int B) l1 (@cons (prod Int B) (@pair Int B key (update init)) l2)) (@cons (prod Int B) (@pair Int B k0 d0) (lin_avl r0))) (@app (prod Int B) l1 (@cons (prod Int B) (@pair Int B key (update init)) (@app (prod Int B) l2 (@cons (prod Int B) (@pair Int B k0 d0) (lin_avl r0))))) *) (* Goal: forall (d : B) (l1 l2 : list (prod Int B)) (_ : @eq (list (prod Int B)) (lin_avl l0) (@app (prod Int B) l1 (@cons (prod Int B) (@pair Int B key d) l2))) (_ : @eq (list (prod Int B)) (lin_avl l) (@app (prod Int B) l1 (@cons (prod Int B) (@pair Int B key (update d)) l2))), lin_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: equiv_ins key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl t) (height_avl (Avl_Node k0 d0 l0 r0 b0))) (@eq nat (height_avl t) (S (height_avl (Avl_Node k0 d0 l0 r0 b0)))) *) (* Goal: is_avl l *) (* Goal: is_below_avl l k0 *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k0 *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_left_shift l r0 b0) *) (* Goal: forall _ : not (Less key k0), avl_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) *) rewrite (app_ass l1 ((key, update init) :: l2) ((k0, d0) :: lin_avl r0)). (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. (* Goal: forall (d : B) (l1 l2 : list (prod Int B)) (_ : @eq (list (prod Int B)) (lin_avl l0) (@app (prod Int B) l1 (@cons (prod Int B) (@pair Int B key d) l2))) (_ : @eq (list (prod Int B)) (lin_avl l) (@app (prod Int B) l1 (@cons (prod Int B) (@pair Int B key (update d)) l2))), lin_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: equiv_ins key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl t) (height_avl (Avl_Node k0 d0 l0 r0 b0))) (@eq nat (height_avl t) (S (height_avl (Avl_Node k0 d0 l0 r0 b0)))) *) (* Goal: is_avl l *) (* Goal: is_below_avl l k0 *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k0 *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_left_shift l r0 b0) *) (* Goal: forall _ : not (Less key k0), avl_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) *) intros d' l1 l2 lin_l0 lin_l. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) apply Lin_Ins_Update with d' l1 (l2 ++ (k0, d0) :: lin_avl r0); simpl in |- *. (* Goal: @eq (list (prod Int B)) (@app (prod Int B) (lin_avl l0) (@cons (prod Int B) (@pair Int B k0 d0) (lin_avl r0))) (@app (prod Int B) l1 (@cons (prod Int B) (@pair Int B key d) (@app (prod Int B) l2 (@cons (prod Int B) (@pair Int B k0 d0) (lin_avl r0))))) *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) l1 (@app (prod Int B) l2 (@cons (prod Int B) (@pair Int B k0 d0) (lin_avl r0)))) *) (* Goal: lookup key l0 d *) (* Goal: equiv_del key (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_below_avl l k0 *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k0 *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: forall _ : not (Less key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) rewrite lin_l0. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite (app_ass l1 ((key, d') :: l2) ((k0, d0) :: lin_avl r0)); trivial. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite lin_t; simpl in |- *. (* Goal: @eq (list (prod Int B)) (@app (prod Int B) (lin_avl l) (@cons (prod Int B) (@pair Int B k0 d0) (lin_avl r0))) (@app (prod Int B) l1 (@app (prod Int B) l2 (@cons (prod Int B) (@pair Int B k0 d0) (lin_avl r0)))) *) (* Goal: lookup key l0 d *) (* Goal: equiv_del key (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_below_avl l k0 *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k0 *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: forall _ : not (Less key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) rewrite lin_l. (* Goal: @eq (list (prod Int B)) (@app (prod Int B) (@app (prod Int B) l1 (@cons (prod Int B) (@pair Int B key (update d')) l2)) (@cons (prod Int B) (@pair Int B k0 d0) (lin_avl r0))) (@app (prod Int B) l1 (@cons (prod Int B) (@pair Int B key (update d')) (@app (prod Int B) l2 (@cons (prod Int B) (@pair Int B k0 d0) (lin_avl r0))))) *) (* Goal: equiv_ins key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl t) (height_avl (Avl_Node k0 d0 l0 r0 b0))) (@eq nat (height_avl t) (S (height_avl (Avl_Node k0 d0 l0 r0 b0)))) *) (* Goal: is_avl l *) (* Goal: is_below_avl l k0 *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k0 *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_left_shift l r0 b0) *) (* Goal: forall _ : not (Less key k0), avl_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) *) rewrite (app_ass l1 ((key, update d') :: l2) ((k0, d0) :: lin_avl r0)). (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. (* Goal: equiv_ins key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl t) (height_avl (Avl_Node k0 d0 l0 r0 b0))) (@eq nat (height_avl t) (S (height_avl (Avl_Node k0 d0 l0 r0 b0)))) *) (* Goal: is_avl l *) (* Goal: is_below_avl l k0 *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k0 *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_left_shift l r0 b0) *) (* Goal: forall _ : not (Less key k0), avl_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) *) apply equiv_ins_equiv_equiv_ins with (Avl_Node k0 d0 l r0 b0). (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply (equiv_ins_left key update init k0 d0 l0 r0 b0 l b0); assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply equiv_sym; assumption. (* Goal: sumbool (@eq nat (height_avl t) (height_avl (Avl_Node k0 d0 l0 r0 b0))) (@eq nat (height_avl t) (S (height_avl (Avl_Node k0 d0 l0 r0 b0)))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_right_shift l0 r b0) *) elim growth_dec; clear growth_dec. (* Goal: forall _ : hasnot_grown_right t k0 d0 l0 r b0, sumbool (@eq nat (height_avl t) (height_avl (Avl_Node k0 d0 l0 r0 b0))) (@eq nat (height_avl t) (S (height_avl (Avl_Node k0 d0 l0 r0 b0)))) *) (* Goal: forall _ : has_grown_right t k0 d0 l0 r b0, sumbool (@eq nat (height_avl t) (height_avl (Avl_Node k0 d0 l0 r0 b0))) (@eq nat (height_avl t) (S (height_avl (Avl_Node k0 d0 l0 r0 b0)))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_right_shift l0 r b0) *) intro has_not_grown. (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) left. (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) inversion_clear avl_t0. (* Goal: @eq nat (height_avl t) (height_avl (Avl_Node k0 d0 l0 r0 b0)) *) (* Goal: forall _ : has_grown_left t k0 d0 l r0 b0, sumbool (@eq nat (height_avl t) (height_avl (Avl_Node k0 d0 l0 r0 b0))) (@eq nat (height_avl t) (S (height_avl (Avl_Node k0 d0 l0 r0 b0)))) *) (* Goal: is_avl l *) (* Goal: is_below_avl l k0 *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k0 *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_left_shift l r0 b0) *) (* Goal: forall _ : not (Less key k0), avl_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) *) generalize H1; clear H1. (* Goal: forall _ : is_balanced_avl l0 r0 b0, @eq nat (height_avl t) (height_avl (Avl_Node k0 d0 l0 r0 b0)) *) (* Goal: forall _ : has_grown_left t k0 d0 l r0 b0, sumbool (@eq nat (height_avl t) (height_avl (Avl_Node k0 d0 l0 r0 b0))) (@eq nat (height_avl t) (S (height_avl (Avl_Node k0 d0 l0 r0 b0)))) *) (* Goal: is_avl l *) (* Goal: is_below_avl l k0 *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k0 *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_left_shift l r0 b0) *) (* Goal: forall _ : not (Less key k0), avl_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) *) clear equiv_t equiv_ins_l H3 H2 H0 H. (* Goal: forall _ : is_balanced_avl l0 r0 b0, @eq nat (height_avl t) (height_avl (Avl_Node k0 d0 l0 r0 b0)) *) (* Goal: forall _ : has_grown_right t k0 d0 l0 r b0, sumbool (@eq nat (height_avl t) (height_avl (Avl_Node k0 d0 l0 r0 b0))) (@eq nat (height_avl t) (S (height_avl (Avl_Node k0 d0 l0 r0 b0)))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_right_shift l0 r b0) *) inversion_clear has_not_grown. (* (is_balanced_avl l r0 b0) *) (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H0; clear H0. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) inversion_clear H; simpl in |- *. (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H0; clear H0. (* Goal: is_balanced_avl_right_shift l r0 b0 *) intros Balanced_l0; inversion_clear Balanced_l0. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H; trivial. (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H0; clear H0. (* Goal: is_balanced_avl_right_shift l r0 b0 *) intro Balanced_l0; inversion_clear Balanced_l0. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H; trivial. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. (* (is_balanced_avl_left_shift l r0 Left_Balanced) *) (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H0; clear H0. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *. (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 r data), lookup k0 (Avl_Node k d Avl_Nil r b) data *) inversion_clear H. (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H0; clear H0. (* Goal: is_balanced_avl_right_shift l r0 b0 *) intros Balanced_l0; inversion_clear Balanced_l0. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H; trivial. (* (is_balanced_avl_left_shift l r0 Right_Balanced) *) (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H0; clear H0. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *. (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 r data), lookup k0 (Avl_Node k d Avl_Nil r b) data *) inversion_clear H. (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H0; clear H0. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. (* Goal: forall _ : has_grown_right t k0 d0 l0 r b0, sumbool (@eq nat (height_avl t) (height_avl (Avl_Node k0 d0 l0 r0 b0))) (@eq nat (height_avl t) (S (height_avl (Avl_Node k0 d0 l0 r0 b0)))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_right_shift l0 r b0) *) intro has_grown. (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) right. (* Goal: @eq nat (height_avl t) (S (height_avl (Avl_Node k0 d0 l0 r0 b0))) *) (* Goal: is_avl l *) (* Goal: is_below_avl l k0 *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k0 *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_left_shift l r0 b0) *) (* Goal: forall _ : not (Less key k0), avl_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) *) clear equiv_t equiv_ins_l. (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) inversion_clear avl_t0. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) generalize H1; clear H H0 H1 H2 H3. (* Goal: forall _ : is_balanced_avl l0 r0 b0, @eq nat (height_avl t) (S (height_avl (Avl_Node k0 d0 l0 r0 b0))) *) (* Goal: is_avl l *) (* Goal: is_below_avl l k0 *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k0 *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_left_shift l r0 b0) *) (* Goal: forall _ : not (Less key k0), avl_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) *) inversion_clear has_grown. (* (is_balanced_avl_left_shift l r0 Left_Balanced) *) (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H0; clear H0. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *. (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 r data), lookup k0 (Avl_Node k d Avl_Nil r b) data *) inversion_clear H. (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H0; clear H0. (* Goal: is_balanced_avl_right_shift l r0 b0 *) intros Balanced_l0; inversion_clear Balanced_l0. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H; trivial. (* (is_balanced_avl_left_shift l r0 Balanced) *) (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H0; clear H0. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *. (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 r data), lookup k0 (Avl_Node k d Avl_Nil r b) data *) inversion_clear H. (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H0; clear H0. (* Goal: is_balanced_avl_right_shift l r0 b0 *) intros Balanced_l0; inversion_clear Balanced_l0. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H; trivial. (* side premisses of Elim (balance...) *) (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: is_below_avl l k0 *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k0 *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: forall _ : not (Less key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply below_below_avl. (* Goal: is_below l k0 *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k0 *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_left_shift l r0 b0) *) (* Goal: forall _ : not (Less key k0), avl_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) *) apply equiv_ins_below with key update init l0. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) inversion_clear avl_t0. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply is_below_avl_is_below; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear avl_t0; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear avl_t0; assumption. (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_left_shift l r0 b0) *) (* Goal: forall _ : not (Less key k0), avl_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) *) elim bal_or_shift; clear bal_or_shift; intro height_l. (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) left. (* Goal: is_balanced_avl l r0 b0 *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: forall _ : not (Less key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply hasnot_grown_left__preserves_is_balanced_avl with l0. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear avl_t0; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) right. (* Goal: is_balanced_avl_left_shift l r0 b0 *) (* Goal: forall _ : not (Less key k0), avl_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) *) apply is_left_balanced_is_left_balanced_left_shift with l0. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear avl_t0; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (********** greater **********************************) (* Goal: forall _ : not (Less key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) intro notless. (* Goal: avl_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) *) generalize (notequal_notless_greater key k0 notequal notless). (* Goal: forall _ : Less k0 key, avl_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) *) intro greater; clear notless. (* Goal: delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) elim (ih_r0 (inv_is_avl_right k0 d0 l0 r0 b0 avl_t0)); clear ih_l0 ih_r0. (* Goal: forall (t : avl_tree) (_ : lookup_dec_spec key r0) (_ : is_avl t) (_ : lin_ins_spec key update init r0 t) (_ : equiv_ins key update init r0 t) (_ : sumbool (@eq nat (height_avl t) (height_avl r0)) (@eq nat (height_avl t) (S (height_avl r0)))), avl_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) *) intros r lookup_dec_spec0 avl_r lin_ins_r equiv_ins_r bal_or_shift. (* Goal: avl_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) *) elim (balance_right k0 d0 l0 r b0). (* Goal: forall (t : avl_tree) (_ : is_avl t) (_ : @eq (list (prod Int B)) (lin_avl t) (lin_avl (Avl_Node k0 d0 l0 r b0))) (_ : equiv t (Avl_Node k0 d0 l0 r b0)) (_ : sumbool (hasnot_grown_right t k0 d0 l0 r b0) (has_grown_right t k0 d0 l0 r b0)), avl_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_right_shift l0 r b0) *) intros t avl_t lin_t equiv_t growth_dec. (* Goal: avl_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_right_shift l0 r b0) *) apply Avl_Ins_Spec_Intro with t. (* Goal: lookup_dec_spec key (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: is_avl t *) (* Goal: lin_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: equiv_ins key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl t) (height_avl (Avl_Node k0 d0 l0 r0 b0))) (@eq nat (height_avl t) (S (height_avl (Avl_Node k0 d0 l0 r0 b0)))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_right_shift l0 r b0) *) elim lookup_dec_spec0; clear lookup_dec_spec0. (* Goal: forall (d : B) (_ : lookup key r0 d), lookup_dec_spec key (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: forall _ : forall d : B, not (lookup key r0 d), lookup_dec_spec key (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: forall (d : B) (_ : lookup key (Avl_Node k0 d0 l0 r0 b0) d), lin_del_spec key d (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: equiv_del key (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) intros d lookup_d. (* Goal: lookup_dec_spec key (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: forall _ : forall d : B, not (lookup key r0 d), lookup_dec_spec key (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: is_avl t *) (* Goal: lin_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: equiv_ins key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl t) (height_avl (Avl_Node k0 d0 l0 r0 b0))) (@eq nat (height_avl t) (S (height_avl (Avl_Node k0 d0 l0 r0 b0)))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_right_shift l0 r b0) *) apply Lookup with d. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Right; assumption. (* Goal: forall _ : forall d : B, not (lookup key r0 d), lookup_dec_spec key (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: is_avl t *) (* Goal: lin_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: equiv_ins key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl t) (height_avl (Avl_Node k0 d0 l0 r0 b0))) (@eq nat (height_avl t) (S (height_avl (Avl_Node k0 d0 l0 r0 b0)))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_right_shift l0 r b0) *) intros not_lookup_d0. (* Goal: lookup_dec_spec key (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: is_avl t *) (* Goal: lin_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: equiv_ins key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl t) (height_avl (Avl_Node k0 d0 l0 r0 b0))) (@eq nat (height_avl t) (S (height_avl (Avl_Node k0 d0 l0 r0 b0)))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_right_shift l0 r b0) *) apply Not_Lookup. (* Goal: forall (d : B) (_ : lookup key r0 d), lookup_dec_spec key (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: forall _ : forall d : B, not (lookup key r0 d), lookup_dec_spec key (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: forall (d : B) (_ : lookup key (Avl_Node k0 d0 l0 r0 b0) d), lin_del_spec key d (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: equiv_del key (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) unfold not in |- *; intros d lookup_d. (* Goal: False *) (* Goal: is_avl t *) (* Goal: lin_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: equiv_ins key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl t) (height_avl (Avl_Node k0 d0 l0 r0 b0))) (@eq nat (height_avl t) (S (height_avl (Avl_Node k0 d0 l0 r0 b0)))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_right_shift l0 r b0) *) apply (not_lookup_d0 d). (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply (lookup_avl_inv_greater key k0 d0 l0 r0 b0); assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: lin_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: equiv_ins key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl t) (height_avl (Avl_Node k0 d0 l0 r0 b0))) (@eq nat (height_avl t) (S (height_avl (Avl_Node k0 d0 l0 r0 b0)))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_right_shift l0 r b0) *) elim lin_ins_r; clear lin_ins_r. (* Goal: forall (l1 l2 : list (prod Int B)) (_ : @eq (list (prod Int B)) (lin_avl r0) (@app (prod Int B) l1 (@cons (prod Int B) (@pair Int B key d) l2))) (_ : @eq (list (prod Int B)) (lin_avl r) (@app (prod Int B) l1 l2)), lin_del_spec key d (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: lookup key r0 d *) (* Goal: equiv_del key (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) intros l1 l2 lin_r0 lin_r. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) apply Lin_Ins_New with (lin_avl l0 ++ (k0, d0) :: l1) l2; simpl in |- *. (* Goal: @eq (list (prod Int B)) (@app (prod Int B) (lin_avl l0) (@cons (prod Int B) (@pair Int B k0 d0) (lin_avl r0))) (@app (prod Int B) (@app (prod Int B) (lin_avl l0) (@cons (prod Int B) (@pair Int B k0 d0) l1)) (@cons (prod Int B) (@pair Int B key d') l2)) *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl l0) (@cons (prod Int B) (@pair Int B k0 d0) l1)) (@cons (prod Int B) (@pair Int B key (update d')) l2)) *) (* Goal: equiv_ins key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl t) (height_avl (Avl_Node k0 d0 l0 r0 b0))) (@eq nat (height_avl t) (S (height_avl (Avl_Node k0 d0 l0 r0 b0)))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_right_shift l0 r b0) *) rewrite lin_r0. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite (app_ass (lin_avl l0) ((k0, d0) :: l1) l2); trivial. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite lin_t; simpl in |- *. (* Goal: @eq (list (prod Int B)) (@app (prod Int B) (lin_avl l0) (@cons (prod Int B) (@pair Int B k0 d0) (lin_avl r))) (@app (prod Int B) (@app (prod Int B) (lin_avl l0) (@cons (prod Int B) (@pair Int B k0 d0) l1)) (@cons (prod Int B) (@pair Int B key (update d')) l2)) *) (* Goal: equiv_ins key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl t) (height_avl (Avl_Node k0 d0 l0 r0 b0))) (@eq nat (height_avl t) (S (height_avl (Avl_Node k0 d0 l0 r0 b0)))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_right_shift l0 r b0) *) rewrite lin_r. (* Goal: @eq (list (prod Int B)) (@app (prod Int B) (lin_avl l0) (@cons (prod Int B) (@pair Int B k0 d0) (@app (prod Int B) l1 (@cons (prod Int B) (@pair Int B key (update init)) l2)))) (@app (prod Int B) (@app (prod Int B) (lin_avl l0) (@cons (prod Int B) (@pair Int B k0 d0) l1)) (@cons (prod Int B) (@pair Int B key (update init)) l2)) *) (* Goal: forall (d : B) (l1 l2 : list (prod Int B)) (_ : @eq (list (prod Int B)) (lin_avl r0) (@app (prod Int B) l1 (@cons (prod Int B) (@pair Int B key d) l2))) (_ : @eq (list (prod Int B)) (lin_avl r) (@app (prod Int B) l1 (@cons (prod Int B) (@pair Int B key (update d)) l2))), lin_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: equiv_ins key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl t) (height_avl (Avl_Node k0 d0 l0 r0 b0))) (@eq nat (height_avl t) (S (height_avl (Avl_Node k0 d0 l0 r0 b0)))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_right_shift l0 r b0) *) rewrite (app_ass (lin_avl l0) ((k0, d0) :: l1) ((key, update init) :: l2)). (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. (* Goal: forall (d : B) (l1 l2 : list (prod Int B)) (_ : @eq (list (prod Int B)) (lin_avl r0) (@app (prod Int B) l1 (@cons (prod Int B) (@pair Int B key d) l2))) (_ : @eq (list (prod Int B)) (lin_avl r) (@app (prod Int B) l1 (@cons (prod Int B) (@pair Int B key (update d)) l2))), lin_ins_spec key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: equiv_ins key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl t) (height_avl (Avl_Node k0 d0 l0 r0 b0))) (@eq nat (height_avl t) (S (height_avl (Avl_Node k0 d0 l0 r0 b0)))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_right_shift l0 r b0) *) intros d' l1 l2 lin_r0 lin_r. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) apply Lin_Ins_Update with d' (lin_avl l0 ++ (k0, d0) :: l1) l2; simpl in |- *. (* Goal: @eq (list (prod Int B)) (@app (prod Int B) (lin_avl l0) (@cons (prod Int B) (@pair Int B k0 d0) (lin_avl r0))) (@app (prod Int B) (@app (prod Int B) (lin_avl l0) (@cons (prod Int B) (@pair Int B k0 d0) l1)) (@cons (prod Int B) (@pair Int B key d') l2)) *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl l0) (@cons (prod Int B) (@pair Int B k0 d0) l1)) (@cons (prod Int B) (@pair Int B key (update d')) l2)) *) (* Goal: equiv_ins key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl t) (height_avl (Avl_Node k0 d0 l0 r0 b0))) (@eq nat (height_avl t) (S (height_avl (Avl_Node k0 d0 l0 r0 b0)))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_right_shift l0 r b0) *) rewrite lin_r0. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite (app_ass (lin_avl l0) ((k0, d0) :: l1) ((key, d') :: l2)); trivial. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite lin_t; simpl in |- *. (* Goal: @eq (list (prod Int B)) (@app (prod Int B) (lin_avl l0) (@cons (prod Int B) (@pair Int B k0 d0) (lin_avl r))) (@app (prod Int B) (@app (prod Int B) (lin_avl l0) (@cons (prod Int B) (@pair Int B k0 d0) l1)) (@cons (prod Int B) (@pair Int B key (update d')) l2)) *) (* Goal: equiv_ins key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl t) (height_avl (Avl_Node k0 d0 l0 r0 b0))) (@eq nat (height_avl t) (S (height_avl (Avl_Node k0 d0 l0 r0 b0)))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_right_shift l0 r b0) *) rewrite lin_r. (* Goal: @eq (list (prod Int B)) (@app (prod Int B) (lin_avl l0) (@cons (prod Int B) (@pair Int B k0 d0) (@app (prod Int B) l1 (@cons (prod Int B) (@pair Int B key (update d')) l2)))) (@app (prod Int B) (@app (prod Int B) (lin_avl l0) (@cons (prod Int B) (@pair Int B k0 d0) l1)) (@cons (prod Int B) (@pair Int B key (update d')) l2)) *) (* Goal: equiv_ins key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl t) (height_avl (Avl_Node k0 d0 l0 r0 b0))) (@eq nat (height_avl t) (S (height_avl (Avl_Node k0 d0 l0 r0 b0)))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_right_shift l0 r b0) *) rewrite (app_ass (lin_avl l0) ((k0, d0) :: l1) ((key, update d') :: l2)). (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. (* Goal: equiv_ins key update init (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl t) (height_avl (Avl_Node k0 d0 l0 r0 b0))) (@eq nat (height_avl t) (S (height_avl (Avl_Node k0 d0 l0 r0 b0)))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_right_shift l0 r b0) *) apply equiv_ins_equiv_equiv_ins with (Avl_Node k0 d0 l0 r b0). (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply (equiv_ins_right key update init k0 d0 l0 r0 b0 r b0); assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply equiv_sym; assumption. (* Goal: sumbool (@eq nat (height_avl t) (height_avl (Avl_Node k0 d0 l0 r0 b0))) (@eq nat (height_avl t) (S (height_avl (Avl_Node k0 d0 l0 r0 b0)))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_right_shift l0 r b0) *) clear equiv_t avl_t bal_or_shift equiv_ins_r. (* Goal: sumbool (@eq nat (height_avl t) (height_avl (Avl_Node k0 d0 l0 r0 b0))) (@eq nat (height_avl t) (S (height_avl (Avl_Node k0 d0 l0 r0 b0)))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_right_shift l0 r b0) *) elim growth_dec; clear growth_dec. (* Goal: forall _ : hasnot_grown_right t k0 d0 l0 r b0, sumbool (@eq nat (height_avl t) (height_avl (Avl_Node k0 d0 l0 r0 b0))) (@eq nat (height_avl t) (S (height_avl (Avl_Node k0 d0 l0 r0 b0)))) *) (* Goal: forall _ : has_grown_right t k0 d0 l0 r b0, sumbool (@eq nat (height_avl t) (height_avl (Avl_Node k0 d0 l0 r0 b0))) (@eq nat (height_avl t) (S (height_avl (Avl_Node k0 d0 l0 r0 b0)))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_right_shift l0 r b0) *) intro has_not_grown. (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) left. (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) inversion_clear avl_t0. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) generalize H1; clear H H0 H1 H2 H3. (* Goal: forall _ : is_balanced_avl l0 r0 b0, @eq nat (height_avl t) (height_avl (Avl_Node k0 d0 l0 r0 b0)) *) (* Goal: forall _ : has_grown_right t k0 d0 l0 r b0, sumbool (@eq nat (height_avl t) (height_avl (Avl_Node k0 d0 l0 r0 b0))) (@eq nat (height_avl t) (S (height_avl (Avl_Node k0 d0 l0 r0 b0)))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_right_shift l0 r b0) *) inversion_clear has_not_grown. (* (is_balanced_avl l0 r b0) *) (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H0; clear H0. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) inversion_clear H; simpl in |- *. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (S (height_avl r0)) (S (height_avl r)) *) (* Goal: forall _ : is_balanced_avl l0 r0 Left_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Left_Balanced)) (height_avl t) *) (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Balanced)) (height_avl t) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite <- H0; clear H0. (* Goal: is_balanced_avl_right_shift l r0 b0 *) intros Balanced_l0; inversion_clear Balanced_l0. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H; trivial. (* (is_balanced_avl_right_shift l0 r Left_Balanced) *) (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H0; clear H0; simpl in |- *. (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 r data), lookup k0 (Avl_Node k d Avl_Nil r b) data *) inversion_clear H. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H0; trivial. (* (is_balanced_avl_left_shift l0 r Right_Balanced) *) (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H0; clear H0; simpl in |- *. (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 r data), lookup k0 (Avl_Node k d Avl_Nil r b) data *) inversion_clear H. (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (S (height_avl r0)) (S (height_avl r)) *) (* Goal: forall _ : is_balanced_avl l0 r0 Left_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Left_Balanced)) (height_avl t) *) (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Balanced)) (height_avl t) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite <- H0; clear H0. (* Goal: is_balanced_avl_right_shift l r0 b0 *) intro Balanced_l0; inversion_clear Balanced_l0. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H; trivial. (* Goal: forall _ : has_grown_right t k0 d0 l0 r b0, sumbool (@eq nat (height_avl t) (height_avl (Avl_Node k0 d0 l0 r0 b0))) (@eq nat (height_avl t) (S (height_avl (Avl_Node k0 d0 l0 r0 b0)))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_right_shift l0 r b0) *) intro has_grown. (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) right. (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) inversion_clear avl_t0. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) generalize H1; clear H H0 H1 H2 H3. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) inversion_clear has_grown; simpl in |- *. (* (is_balanced_avl_right_shift l0 r Balanced) *) (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H0; clear H0. (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 r data), lookup k0 (Avl_Node k d Avl_Nil r b) data *) inversion_clear H. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H0; trivial. (* (is_balanced_avl_right_shift l0 r Right_Balanced) *) (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H0; clear H0. (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 r data), lookup k0 (Avl_Node k d Avl_Nil r b) data *) inversion_clear H. (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (S (height_avl r0)) (S (height_avl r)) *) (* Goal: forall _ : is_balanced_avl l0 r0 Left_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Left_Balanced)) (height_avl t) *) (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Balanced)) (height_avl t) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite <- H0; clear H0. (* Goal: is_balanced_avl_right_shift l r0 b0 *) intros Balanced_l0; inversion_clear Balanced_l0. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H; trivial. (* side premisses of Elim (balance...) *) (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear avl_t0; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear avl_t0; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) apply above_above_avl. (* Goal: is_above r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_right_shift l0 r b0) *) apply equiv_ins_above with key update init r0. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) inversion_clear avl_t0. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply is_above_avl_is_above; assumption. (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_right_shift l0 r b0) *) elim bal_or_shift; clear bal_or_shift; intro height_r. (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) left. (* Goal: is_balanced_avl l0 r b0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) apply hasnot_grown_right__preserves_is_balanced_avl with r0. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear avl_t0; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) right. (* Goal: is_balanced_avl_right_shift l0 r b0 *) apply is_balanced_avl_is_balanced_avl_right_shift with r0. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear avl_t0; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. Qed. (***********************************************************************) Inductive equiv_del (key : Int) (t0 t : avl_tree) : Prop := equiv_del_intro : (forall k : Int, Equal k key -> forall d : B, lookup k t d -> False) -> (forall (k : Int) (data : B), ~ Equal k key -> lookup k t0 data -> lookup k t data) -> (forall (k : Int) (data : B), ~ Equal k key -> lookup k t data -> lookup k t0 data) -> equiv_del key t0 t. Lemma inv_equiv_del_equal : forall (key : Int) (t0 t : avl_tree) (k : Int) (d : B), equiv_del key t0 t -> Equal k key -> lookup k t d -> False. (* Goal: forall (key : Int) (t0 t : avl_tree) (k : Int) (d : B) (_ : equiv_del key t0 t) (_ : not (Equal k key)) (_ : lookup k t d), lookup k t0 d *) intros. (* Goal: lookup k t0 d *) inversion H. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply H2 with (k := k) (d := d); assumption. Qed. Lemma inv_equiv_del_notequal0 : forall (key : Int) (t0 t : avl_tree) (k : Int) (d : B), equiv_del key t0 t -> ~ Equal k key -> lookup k t0 d -> lookup k t d. (* Goal: forall (key : Int) (t0 t : avl_tree) (k : Int) (d : B) (_ : equiv_del key t0 t) (_ : not (Equal k key)) (_ : lookup k t d), lookup k t0 d *) intros. (* Goal: lookup k t0 d *) inversion H. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply H3; assumption. Qed. Lemma inv_equiv_del_notequal1 : forall (key : Int) (t0 t : avl_tree) (k : Int) (d : B), equiv_del key t0 t -> ~ Equal k key -> lookup k t d -> lookup k t0 d. (* Goal: forall (key : Int) (t0 t : avl_tree) (k : Int) (d : B) (_ : equiv_del key t0 t) (_ : not (Equal k key)) (_ : lookup k t d), lookup k t0 d *) intros. (* Goal: lookup k t0 d *) inversion H. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply H4; assumption. Qed. Lemma equiv_del_equiv_equiv_del : forall (key : Int) (t0 t1 t2 : avl_tree), equiv_del key t0 t1 -> equiv t1 t2 -> equiv_del key t0 t2. (* Goal: forall (key : Int) (t0 t1 t2 : avl_tree) (_ : equiv_del key t0 t1) (_ : equiv t1 t2), equiv_del key t0 t2 *) intros key t0 t1 t2 equiv_del0 equiv0. (* Goal: equiv_del key t0 t2 *) inversion_clear equiv_del0. (* Goal: equiv_del key t0 t2 *) inversion_clear equiv0. (* Goal: equiv_del k (Avl_Node k0 d0 l0 l b0) (Avl_Node k0 d0 l0 r0 b0) *) apply equiv_del_intro. (* Goal: forall (k : Int) (_ : Equal k key) (d : B) (_ : lookup k t2 d), False *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k t0 data), lookup k t2 data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k t2 data), lookup k t0 data *) intros k equal data lookup_t2. (* Goal: False *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k t0 data), lookup k t2 data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k t2 data), lookup k t0 data *) apply H with k data. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply H3; assumption. (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), lookup k (Avl_Node k0 d0 l0 r b) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) intros k data notequal lookup_t0. (* Goal: lookup k t2 data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k t2 data), lookup k t0 data *) apply H2. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply H0; assumption. (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k t2 data), lookup k t0 data *) intros k data notequal lookup_t2. (* Goal: lookup k0 l0 d1 *) (* Goal: is_below l0 k0 *) (* Goal: False *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k0)) (_ : lookup k1 (Avl_Node k0 d0 l0 r0 b0) data), lookup k1 (Avl_Node k d l r0 b0) data *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k0)) (_ : lookup k1 (Avl_Node k d l r0 b0) data), lookup k1 (Avl_Node k0 d0 l0 r0 b0) data *) apply H1. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply H3; assumption. Qed. (*****************************************************************) Lemma equiv_del_semi_leave : forall (k : Int) (d : B) (l : avl_tree) (b : bal), is_avl (Avl_Node k d l Avl_Nil b) -> equiv_del k (Avl_Node k d l Avl_Nil b) l. (* Goal: forall (k : Int) (d : B) (l : avl_tree) (b : bal) (_ : is_avl (Avl_Node k d l Avl_Nil b)), equiv_del k (Avl_Node k d l Avl_Nil b) l *) intros k d l b avl_t. (* Goal: equiv_del k (Avl_Node k0 d0 l0 l b0) (Avl_Node k0 d0 l0 r0 b0) *) apply equiv_del_intro. (* Goal: forall (k0 : Int) (_ : Equal k0 k) (d : B) (_ : lookup k0 l d), False *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 (Avl_Node k d l Avl_Nil b) data), lookup k0 l data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 l data), lookup k0 (Avl_Node k d l Avl_Nil b) data *) intros k0 equal d0 lookup_l. (* Goal: is_above r k *) (* Goal: Equal k0 k *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 (Avl_Node k d Avl_Nil r b) data), lookup k0 r data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 r data), lookup k0 (Avl_Node k d Avl_Nil r b) data *) inversion_clear avl_t. (* Goal: False *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 (Avl_Node k d l Avl_Nil b) data), lookup k0 l data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 l data), lookup k0 (Avl_Node k d l Avl_Nil b) data *) apply lookup_below_false with k0 l d0. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: is_below l k0 *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 (Avl_Node k d l Avl_Nil b) data), lookup k0 l data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 l data), lookup k0 (Avl_Node k d l Avl_Nil b) data *) rewrite (equal_eq k0 k equal). (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply is_below_avl_is_below; assumption. (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 (Avl_Node k d Avl_Nil r b) data), lookup k0 r data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 r data), lookup k0 (Avl_Node k d Avl_Nil r b) data *) intros k0 data notequal lookup_t. (* Goal: lookup k0 l data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 l data), lookup k0 (Avl_Node k d l Avl_Nil b) data *) inversion lookup_t. (* Goal: lookup k l data *) (* Goal: lookup k0 l data *) (* Goal: lookup k0 l data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 l data), lookup k0 (Avl_Node k d l Avl_Nil b) data *) rewrite H0 in notequal. (* Goal: lin_del_spec key d Avl_Nil Avl_Nil *) (* Goal: equiv_del key Avl_Nil Avl_Nil *) (* Goal: sumbool (@eq nat (height_avl Avl_Nil) (height_avl Avl_Nil)) (@eq nat (height_avl Avl_Nil) (S (height_avl Avl_Nil))) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, delete_spec key a) (a0 : avl_tree) (_ : forall _ : is_avl a0, delete_spec key a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), delete_spec key (Avl_Node i b a a0 b0) *) elimtype False. (* Goal: False *) (* Goal: lookup k1 (Avl_Node k d l r0 b0) d1 *) (* Goal: lookup k1 (Avl_Node k d l r0 b0) d1 *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k0)) (_ : lookup k1 (Avl_Node k d l r0 b0) data), lookup k1 (Avl_Node k0 d0 l0 r0 b0) data *) apply notequal. (* Goal: Equal k0 k0 *) (* Goal: lookup k1 (Avl_Node k d l r0 b0) d1 *) (* Goal: lookup k1 (Avl_Node k d l r0 b0) d1 *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k0)) (_ : lookup k1 (Avl_Node k d l r0 b0) data), lookup k1 (Avl_Node k0 d0 l0 r0 b0) data *) apply equal_refl. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: lookup k0 l data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 l data), lookup k0 (Avl_Node k d l Avl_Nil b) data *) inversion_clear H5. (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 r data), lookup k0 (Avl_Node k d Avl_Nil r b) data *) intros k0 data notequal lookup_l. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Left; assumption. Qed. (*************************************************************************) Lemma equiv_del_above : forall (key : Int) (t0 t : avl_tree) (k0 : Int), equiv_del key t0 t -> Less k0 key -> is_above t0 k0 -> is_above t k0. (* Goal: forall (key : Int) (t0 t : avl_tree) (k0 : Int) (_ : equiv_del key t0 t) (_ : Less k0 key) (_ : is_above t0 k0), is_above t k0 *) intros key t0 t k0 equiv_t0 greater below_t0. (* Goal: is_above t k *) apply lookup_greater_above. (* Goal: forall (k : Int) (d : B) (_ : lookup k t d), Less k0 k *) intros k d lookup_t. (* Goal: Less k0 k *) elim (equal_dec k key). (* Goal: forall _ : Equal k key, Less k0 k *) (* Goal: forall _ : not (Equal k key), Less k0 k *) intro equal. (* Goal: Less k0 k *) (* Goal: forall _ : not (Equal k key), Less k0 k *) apply (less_equal_less k0 key k). (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply equal_sym; assumption. (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) intro notequal. (* Goal: Less k0 k *) apply (lookup_above_greater k t0 d). (* Goal: lookup k t0 d *) (* Goal: is_above t0 k0 *) inversion_clear equiv_t0. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply H1; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. Qed. Lemma equiv_del_right : forall (key k0 : Int) (d0 : B) (l0 r0 : avl_tree) (b0 : bal) (r : avl_tree) (b : bal), is_avl (Avl_Node k0 d0 l0 r0 b0) -> Less k0 key -> equiv_del key r0 r -> equiv_del key (Avl_Node k0 d0 l0 r0 b0) (Avl_Node k0 d0 l0 r b). (* Goal: forall (key k0 : Int) (d0 : B) (l0 r0 : avl_tree) (b0 : bal) (r : avl_tree) (b : bal) (_ : is_avl (Avl_Node k0 d0 l0 r0 b0)) (_ : Less k0 key) (_ : equiv_del key r0 r), equiv_del key (Avl_Node k0 d0 l0 r0 b0) (Avl_Node k0 d0 l0 r b) *) intros key k0 d0 l0 r0 b0 r b avl_t0 less equiv_r0. (* Goal: equiv_del key (Avl_Node k0 d0 l0 r0 b0) (Avl_Node k0 d0 l0 r b) *) inversion_clear equiv_r0. (* Goal: equiv_del k (Avl_Node k0 d0 l0 l b0) (Avl_Node k0 d0 l0 r0 b0) *) apply equiv_del_intro. (* Goal: forall (k : Int) (_ : Equal k key) (d : B) (_ : lookup k (Avl_Node k0 d0 l0 r b) d), False *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), lookup k (Avl_Node k0 d0 l0 r b) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) intros k equal data lookup_t. (* Goal: forall (_ : is_balanced_avl_right_shift l Avl_Nil Right_Balanced) (_ : True), sumbool (hasnot_shrunk_right t k d l Avl_Nil Right_Balanced) (has_shrunk_right t k d l Avl_Nil Right_Balanced) *) (* Goal: forall (i : Int) (b : B) (a a0 : avl_tree) (b0 : bal) (_ : is_balanced_avl_right_shift l (Avl_Node i b a a0 b0) Right_Balanced) (_ : match b0 with | Left_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node i b a a0 b0)) | Balanced => @eq nat (height_avl t) (S (height_avl (Avl_Node i b a a0 b0))) | Right_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node i b a a0 b0)) end), sumbool (hasnot_shrunk_right t k d l (Avl_Node i b a a0 b0) Right_Balanced) (has_shrunk_right t k d l (Avl_Node i b a a0 b0) Right_Balanced) *) (* Goal: @eq nat (S (S (height_avl l))) (height_avl r) *) elim (inv_lookup k k0 d0 l0 r b data lookup_t); intro u0. (* Goal: False *) (* Goal: False *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), lookup k (Avl_Node k0 d0 l0 r b) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) elim u0; clear u0; intros u0 u1. (* Goal: False *) (* Goal: False *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), lookup k (Avl_Node k0 d0 l0 r b) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) rewrite u0 in less. (* Goal: False *) (* Goal: False *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), lookup k (Avl_Node k0 d0 l0 r b) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) rewrite (equal_eq k key equal) in less. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply less_irrefl with key; assumption. (* Goal: False *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), lookup k (Avl_Node k0 d0 l0 r b) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) elim u0; clear u0; intro u0. (* Goal: False *) (* Goal: False *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), lookup k (Avl_Node k0 d0 l0 r b) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) rewrite (equal_eq k key equal) in u0. (* Goal: False *) (* Goal: False *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), lookup k (Avl_Node k0 d0 l0 r b) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) apply lookup_below_false with key l0 data. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: is_below l0 k *) (* Goal: lookup k r0 d1 *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k)) (_ : lookup k1 (Avl_Node k0 d0 l0 l b0) data), lookup k1 (Avl_Node k0 d0 l0 r0 b0) data *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k)) (_ : lookup k1 (Avl_Node k0 d0 l0 r0 b0) data), lookup k1 (Avl_Node k0 d0 l0 l b0) data *) apply below_trans with k0. (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) inversion_clear avl_t0. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply is_below_avl_is_below; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply H with k data; assumption. (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r0 b0) data), lookup k (Avl_Node k0 d0 l0 r b) data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) intros k data notequal lookup_t0. (* Goal: False *) (* Goal: equiv_del key Avl_Nil Avl_Nil *) (* Goal: sumbool (@eq nat (height_avl Avl_Nil) (height_avl Avl_Nil)) (@eq nat (height_avl Avl_Nil) (S (height_avl Avl_Nil))) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, delete_spec key a) (a0 : avl_tree) (_ : forall _ : is_avl a0, delete_spec key a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), delete_spec key (Avl_Node i b a a0 b0) *) inversion_clear lookup_t0. (* Goal: lookup k0 (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d0 *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup_Equal. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Left; assumption. (* Goal: lookup k1 (Avl_Node k0 d0 l0 l b0) d1 *) apply Lookup_Right. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply H0; assumption. (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k (Avl_Node k0 d0 l0 r b) data), lookup k (Avl_Node k0 d0 l0 r0 b0) data *) intros k data notequal lookup_t. (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 r data), lookup k0 (Avl_Node k d Avl_Nil r b) data *) inversion_clear lookup_t. (* Goal: lookup k0 (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d0 *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup_Equal. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Left; assumption. (* Goal: lookup k1 (Avl_Node k0 d0 l0 l b0) d1 *) apply Lookup_Right. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply H1; assumption. Qed. (**********************************************************************) Lemma below_equiv_below : forall (k : Int) (t0 t : avl_tree), is_below t0 k -> equiv t t0 -> is_below t k. (* Goal: forall (k : Int) (t0 t : avl_tree) (_ : is_below t0 k) (_ : equiv t t0), is_below t k *) intros k t0 t below_t0 equiv_t. (* Goal: is_below t k *) inversion_clear equiv_t. (* Goal: is_below t k *) apply lookup_less_below. (* Goal: forall (k0 : Int) (d : B) (_ : lookup k0 t d), Less k k0 *) intros k0 d0 lookup_k0. (* Goal: Less k0 k *) apply lookup_below_less with t0 d0. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply H; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. Qed. Lemma Balanced_shrunk_left_balanced_shift : forall (l0 r r0 : avl_tree) (b0 : bal), is_balanced_avl l0 r0 b0 -> height_avl r0 = S (height_avl r) -> is_balanced_avl_left_shift l0 r b0. (* Goal: forall (l0 r r0 : avl_tree) (b0 : bal) (_ : is_balanced_avl l0 r0 b0) (_ : @eq nat (height_avl r0) (S (height_avl r))), is_balanced_avl_left_shift l0 r b0 *) intros l0 r r0 b0 Balanced_l0 height_r. (* Goal: is_balanced_avl_right_shift l r0 b0 *) inversion_clear Balanced_l0. (* Goal: is_balanced_avl_left_shift l0 r Left_Balanced *) (* Goal: is_balanced_avl_left_shift l0 r Balanced *) (* Goal: is_balanced_avl_left_shift l0 r Right_Balanced *) apply Is_Left_Balanced_Avl_Left_Shift. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) rewrite <- height_r; assumption. (* Goal: is_balanced_avl_left_shift l0 r Balanced *) (* Goal: is_balanced_avl_left_shift l0 r Right_Balanced *) apply Is_Fully_Balanced_Avl_Left_Shift. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) rewrite <- height_r; assumption. (* Goal: is_balanced_avl_left_shift l0 r Right_Balanced *) apply Is_Right_Balanced_Avl_Left_Shift. (* Goal: @eq nat (height_avl l0) (height_avl r) *) rewrite <- H in height_r. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) injection height_r; trivial. Qed. Lemma below_equiv_del_below : forall (t0 t : avl_tree) (k key : Int), is_below t0 k -> equiv_del key t0 t -> is_below t k. (* Goal: forall (t0 t : avl_tree) (k key : Int) (_ : is_below t0 k) (_ : equiv_del key t0 t), is_below t k *) intros t0 t k key below_t0 equiv_del_t0. (* Goal: is_above t k *) inversion_clear equiv_del_t0. (* Goal: is_below t k *) apply lookup_less_below. (* Goal: forall (k0 : Int) (d : B) (_ : lookup k0 t d), Less k k0 *) intros k0 d0 lookup_k0. (* Goal: Less k0 k *) apply lookup_below_less with t0 d0. (* Goal: lookup k0 t0 d0 *) (* Goal: is_above t0 k *) elim (equal_dec k0 key). (* Goal: forall _ : Equal k0 key, lookup k0 t0 d0 *) (* Goal: forall _ : not (Equal k0 key), lookup k0 t0 d0 *) (* Goal: is_above t0 k *) intros equal_k0. (* Goal: lin_del_spec key d Avl_Nil Avl_Nil *) (* Goal: equiv_del key Avl_Nil Avl_Nil *) (* Goal: sumbool (@eq nat (height_avl Avl_Nil) (height_avl Avl_Nil)) (@eq nat (height_avl Avl_Nil) (S (height_avl Avl_Nil))) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, delete_spec key a) (a0 : avl_tree) (_ : forall _ : is_avl a0, delete_spec key a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), delete_spec key (Avl_Node i b a a0 b0) *) elimtype False. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply H with k0 d0; assumption. (* Goal: forall _ : not (Equal k0 key), lookup k0 t0 d0 *) (* Goal: is_above t0 k *) intros not_equal_k0. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply H1; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. Qed. Lemma above_equiv_del_above : forall (t0 t : avl_tree) (k key : Int), is_above t0 k -> equiv_del key t0 t -> is_above t k. (* Goal: forall (t0 t : avl_tree) (k key : Int) (_ : is_above t0 k) (_ : equiv_del key t0 t), is_above t k *) intros t0 t k key above_t0 equiv_del_t0. (* Goal: is_above t k *) inversion_clear equiv_del_t0. (* Goal: is_above t k *) apply lookup_greater_above. (* Goal: forall (k0 : Int) (d : B) (_ : lookup k0 t d), Less k k0 *) intros k0 d0 lookup_k0. (* Goal: Less k k0 *) apply lookup_above_greater with t0 d0. (* Goal: lookup k0 t0 d0 *) (* Goal: is_above t0 k *) elim (equal_dec k0 key). (* Goal: forall _ : Equal k0 key, lookup k0 t0 d0 *) (* Goal: forall _ : not (Equal k0 key), lookup k0 t0 d0 *) (* Goal: is_above t0 k *) intros equal_k0. (* Goal: lin_del_spec key d Avl_Nil Avl_Nil *) (* Goal: equiv_del key Avl_Nil Avl_Nil *) (* Goal: sumbool (@eq nat (height_avl Avl_Nil) (height_avl Avl_Nil)) (@eq nat (height_avl Avl_Nil) (S (height_avl Avl_Nil))) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, delete_spec key a) (a0 : avl_tree) (_ : forall _ : is_avl a0, delete_spec key a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), delete_spec key (Avl_Node i b a a0 b0) *) elimtype False. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply H with k0 d0; assumption. (* Goal: forall _ : not (Equal k0 key), lookup k0 t0 d0 *) (* Goal: is_above t0 k *) intros not_equal_k0. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply H1; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. Qed. (**********************************************************************) Inductive hasnot_shrunk_left (t : avl_tree) (k : Int) (d : B) (l r : avl_tree) : bal -> Prop := | Hasnot_Shrunk_Left_Bal : forall b : bal, is_balanced_avl l r b -> height_avl t = height_avl (Avl_Node k d l r b) -> hasnot_shrunk_left t k d l r b | Hasnot_Shrunk_Left_Shift_Left : is_balanced_avl_left_shift l r Left_Balanced -> height_avl t = S (height_avl l) -> hasnot_shrunk_left t k d l r Left_Balanced | Hasnot_Shrunk_Left_Shift_Balanced : is_balanced_avl_left_shift l r Balanced -> height_avl t = S (height_avl l) -> hasnot_shrunk_left t k d l r Balanced. Inductive has_shrunk_left (t : avl_tree) (k : Int) (d : B) (l r : avl_tree) : bal -> Prop := | Has_Shrunk_Left_Shift_Left : is_balanced_avl_left_shift l r Left_Balanced -> height_avl t = height_avl l -> has_shrunk_left t k d l r Left_Balanced | Has_Shrunk_Left_Shift_Right : is_balanced_avl_left_shift l r Right_Balanced -> height_avl t = S (height_avl l) -> has_shrunk_left t k d l r Right_Balanced. Inductive bal_shrunk_left_spec (k : Int) (d : B) (l r : avl_tree) (b : bal) : Set := Balance_Shrunk_Left_Spec_Intro : forall t : avl_tree, is_avl t -> lin_avl t = lin_avl (Avl_Node k d l r b) -> equiv t (Avl_Node k d l r b) -> {hasnot_shrunk_left t k d l r b} + {has_shrunk_left t k d l r b} -> bal_shrunk_left_spec k d l r b. Lemma balance_shrunk_left : forall (k : Int) (d : B) (l r : avl_tree) (b : bal), is_avl l -> is_below_avl l k -> is_avl r -> is_above_avl r k -> {is_balanced_avl l r b} + {is_balanced_avl_left_shift l r b} -> bal_shrunk_left_spec k d l r b. (* Goal: forall (k : Int) (d : B) (l r : avl_tree) (b : bal) (_ : is_avl l) (_ : is_below_avl l k) (_ : is_avl r) (_ : is_above_avl r k) (_ : sumbool (is_balanced_avl l r b) (is_balanced_avl_right_shift l r b)), bal_shrunk_right_spec k d l r b *) intros k d l r b avl_l below_avl_l avl_r above_avl_r bal_or_shift. (* Goal: bal_shrunk_right_spec k d l r b *) elim bal_or_shift; clear bal_or_shift. (* l and r is Balanced with respect to b *) (* Goal: forall _ : is_balanced_avl l r b, bal_shrunk_right_spec k d l r b *) (* Goal: forall _ : is_balanced_avl_right_shift l r b, bal_shrunk_right_spec k d l r b *) intro Balanced_l. (* Goal: bal_shrunk_left_spec k d l r b *) (* Goal: forall _ : is_balanced_avl_left_shift l r b, bal_shrunk_left_spec k d l r b *) apply Balance_Shrunk_Left_Spec_Intro with (Avl_Node k d l r b). (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Node_Is_Avl; assumption. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. (* Goal: equiv (Avl_Node k d l r Right_Balanced) (Avl_Node k d l r Balanced) *) (* Goal: sumbool (hasnot_shrunk_right (Avl_Node k d l r Right_Balanced) k d l r Balanced) (has_shrunk_right (Avl_Node k d l r Right_Balanced) k d l r Balanced) *) (* Goal: bal_shrunk_right_spec k d l r Right_Balanced *) apply equiv_refl. (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) left. (* Goal: hasnot_shrunk_left (Avl_Node k d l r b) k d l r b *) (* Goal: forall _ : is_balanced_avl_left_shift l r b, bal_shrunk_left_spec k d l r b *) apply Hasnot_Shrunk_Left_Bal. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. (* l and r is'nt Balanced with respect to b *) (* Goal: forall _ : is_balanced_avl_right_shift l r b, bal_shrunk_right_spec k d l r b *) elim b; clear b; intros Balanced_shift_l. (* b=Left_Balanced *) (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) elim (rebalance_left k d l r Left_Balanced); try assumption. (* Goal: forall (x : avl_tree) (_ : and (is_avl x) (and (@eq (list (prod Int B)) (lin_avl x) (lin_avl (Avl_Node k d l r Right_Balanced))) (and (equiv x (Avl_Node k d l r Right_Balanced)) match r with | Avl_Nil => True | Avl_Node i b a a0 (Left_Balanced as b0) => @eq nat (height_avl x) (height_avl r) | Avl_Node i b a a0 (Balanced as b0) => @eq nat (height_avl x) (S (height_avl r)) | Avl_Node i b a a0 (Right_Balanced as b0) => @eq nat (height_avl x) (height_avl r) end))), bal_shrunk_right_spec k d l r Right_Balanced *) (* Goal: @eq nat (S (S (height_avl l))) (height_avl r) *) intros t (avl_t,(lin_t,(equiv_t,height_t))). (* Goal: bal_shrunk_left_spec k d l r Left_Balanced *) (* Goal: @eq nat (height_avl l) (S (S (height_avl r))) *) (* Goal: bal_shrunk_left_spec k d l r Balanced *) (* Goal: bal_shrunk_left_spec k d l r Right_Balanced *) apply Balance_Shrunk_Left_Spec_Intro with t. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: sumbool (hasnot_shrunk_left t k d l r Left_Balanced) (has_shrunk_left t k d l r Left_Balanced) *) (* Goal: @eq nat (height_avl l) (S (S (height_avl r))) *) (* Goal: bal_shrunk_left_spec k d l r Balanced *) (* Goal: bal_shrunk_left_spec k d l r Right_Balanced *) clear lin_t equiv_t avl_l below_avl_l. (* Goal: sumbool (hasnot_shrunk_right t k d l r Right_Balanced) (has_shrunk_right t k d l r Right_Balanced) *) (* Goal: @eq nat (S (S (height_avl l))) (height_avl r) *) generalize height_t; clear height_t. (* Goal: forall _ : match r with | Avl_Nil => True | Avl_Node i b a a0 (Left_Balanced as b0) => @eq nat (height_avl t) (height_avl r) | Avl_Node i b a a0 (Balanced as b0) => @eq nat (height_avl t) (S (height_avl r)) | Avl_Node i b a a0 (Right_Balanced as b0) => @eq nat (height_avl t) (height_avl r) end, sumbool (hasnot_shrunk_right t k d l r Right_Balanced) (has_shrunk_right t k d l r Right_Balanced) *) (* Goal: @eq nat (S (S (height_avl l))) (height_avl r) *) generalize Balanced_shift_l; clear Balanced_shift_l. (* Goal: forall (_ : is_balanced_avl_left_shift l r Left_Balanced) (_ : match l with | Avl_Nil => True | Avl_Node i b a a0 (Left_Balanced as b0) => @eq nat (height_avl t) (height_avl l) | Avl_Node i b a a0 (Balanced as b0) => @eq nat (height_avl t) (S (height_avl l)) | Avl_Node i b a a0 (Right_Balanced as b0) => @eq nat (height_avl t) (height_avl l) end), sumbool (hasnot_shrunk_left t k d l r Left_Balanced) (has_shrunk_left t k d l r Left_Balanced) *) (* Goal: @eq nat (height_avl l) (S (S (height_avl r))) *) (* Goal: bal_shrunk_left_spec k d l r Balanced *) (* Goal: bal_shrunk_left_spec k d l r Right_Balanced *) case l; clear l. (* Goal: forall (_ : is_balanced_avl_right_shift l Avl_Nil Right_Balanced) (_ : True), sumbool (hasnot_shrunk_right t k d l Avl_Nil Right_Balanced) (has_shrunk_right t k d l Avl_Nil Right_Balanced) *) (* Goal: forall (i : Int) (b : B) (a a0 : avl_tree) (b0 : bal) (_ : is_balanced_avl_right_shift l (Avl_Node i b a a0 b0) Right_Balanced) (_ : match b0 with | Left_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node i b a a0 b0)) | Balanced => @eq nat (height_avl t) (S (height_avl (Avl_Node i b a a0 b0))) | Right_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node i b a a0 b0)) end), sumbool (hasnot_shrunk_right t k d l (Avl_Node i b a a0 b0) Right_Balanced) (has_shrunk_right t k d l (Avl_Node i b a a0 b0) Right_Balanced) *) (* Goal: @eq nat (S (S (height_avl l))) (height_avl r) *) intro u0. (* Goal: lin_del_spec key d Avl_Nil Avl_Nil *) (* Goal: equiv_del key Avl_Nil Avl_Nil *) (* Goal: sumbool (@eq nat (height_avl Avl_Nil) (height_avl Avl_Nil)) (@eq nat (height_avl Avl_Nil) (S (height_avl Avl_Nil))) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, delete_spec key a) (a0 : avl_tree) (_ : forall _ : is_avl a0, delete_spec key a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), delete_spec key (Avl_Node i b a a0 b0) *) elimtype False. (* Goal: False *) (* Goal: forall (i : Int) (b : B) (a a0 : avl_tree) (b0 : bal) (_ : is_balanced_avl_right_shift l (Avl_Node i b a a0 b0) Right_Balanced) (_ : match b0 with | Left_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node i b a a0 b0)) | Balanced => @eq nat (height_avl t) (S (height_avl (Avl_Node i b a a0 b0))) | Right_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node i b a a0 b0)) end), sumbool (hasnot_shrunk_right t k d l (Avl_Node i b a a0 b0) Right_Balanced) (has_shrunk_right t k d l (Avl_Node i b a a0 b0) Right_Balanced) *) (* Goal: @eq nat (S (S (height_avl l))) (height_avl r) *) inversion_clear u0. (* Goal: False *) (* Goal: forall (i : Int) (b : B) (a a0 : avl_tree) (b0 : bal) (_ : is_balanced_avl_right_shift l (Avl_Node i b a a0 b0) Right_Balanced) (_ : match b0 with | Left_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node i b a a0 b0)) | Balanced => @eq nat (height_avl t) (S (height_avl (Avl_Node i b a a0 b0))) | Right_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node i b a a0 b0)) end), sumbool (hasnot_shrunk_right t k d l (Avl_Node i b a a0 b0) Right_Balanced) (has_shrunk_right t k d l (Avl_Node i b a a0 b0) Right_Balanced) *) (* Goal: @eq nat (S (S (height_avl l))) (height_avl r) *) discriminate H. (* Goal: forall (i : Int) (b : B) (a a0 : avl_tree) (b0 : bal) (_ : is_balanced_avl_left_shift (Avl_Node i b a a0 b0) r Left_Balanced) (_ : match b0 with | Left_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node i b a a0 b0)) | Balanced => @eq nat (height_avl t) (S (height_avl (Avl_Node i b a a0 b0))) | Right_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node i b a a0 b0)) end), sumbool (hasnot_shrunk_left t k d (Avl_Node i b a a0 b0) r Left_Balanced) (has_shrunk_left t k d (Avl_Node i b a a0 b0) r Left_Balanced) *) (* Goal: @eq nat (height_avl l) (S (S (height_avl r))) *) (* Goal: bal_shrunk_left_spec k d l r Balanced *) (* Goal: bal_shrunk_left_spec k d l r Right_Balanced *) intros kl dl ll rl bl. (* Goal: forall (_ : is_balanced_avl_left_shift (Avl_Node kl dl ll rl bl) r Left_Balanced) (_ : match bl with | Left_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node kl dl ll rl bl)) | Balanced => @eq nat (height_avl t) (S (height_avl (Avl_Node kl dl ll rl bl))) | Right_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node kl dl ll rl bl)) end), sumbool (hasnot_shrunk_left t k d (Avl_Node kl dl ll rl bl) r Left_Balanced) (has_shrunk_left t k d (Avl_Node kl dl ll rl bl) r Left_Balanced) *) (* Goal: @eq nat (height_avl l) (S (S (height_avl r))) *) (* Goal: bal_shrunk_left_spec k d l r Balanced *) (* Goal: bal_shrunk_left_spec k d l r Right_Balanced *) elim bl; clear bl; simpl in |- *; intros Balanced_shift_l height_t. (* bl=Left_Balanced *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) right. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Has_Shrunk_Left_Shift_Left; assumption. (* bl=Balanced *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) left. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Hasnot_Shrunk_Left_Shift_Left; assumption. (* bl=Right_Balanced *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) right. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Has_Shrunk_Left_Shift_Left; assumption. (* side premisses of (Elim (rebalance ... )) *) (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear Balanced_shift_l; assumption. (* b=Balanced *) (* Goal: bal_shrunk_left_spec k d l r Balanced *) (* Goal: bal_shrunk_left_spec k d l r Right_Balanced *) apply Balance_Shrunk_Left_Spec_Intro with (Avl_Node k d l r Left_Balanced). (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Node_Is_Avl; try assumption. (* Goal: is_balanced_avl l r Left_Balanced *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node k d l r Left_Balanced)) (lin_avl (Avl_Node k d l r Balanced)) *) (* Goal: equiv (Avl_Node k d l r Left_Balanced) (Avl_Node k d l r Balanced) *) (* Goal: sumbool (hasnot_shrunk_left (Avl_Node k d l r Left_Balanced) k d l r Balanced) (has_shrunk_left (Avl_Node k d l r Left_Balanced) k d l r Balanced) *) (* Goal: bal_shrunk_left_spec k d l r Right_Balanced *) apply Is_Left_Balanced_Avl. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear Balanced_shift_l; assumption. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. (* Goal: equiv (Avl_Node k d l r Right_Balanced) (Avl_Node k d l r Balanced) *) (* Goal: sumbool (hasnot_shrunk_right (Avl_Node k d l r Right_Balanced) k d l r Balanced) (has_shrunk_right (Avl_Node k d l r Right_Balanced) k d l r Balanced) *) (* Goal: bal_shrunk_right_spec k d l r Right_Balanced *) apply equiv_refl. (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) left. (* Goal: hasnot_shrunk_left (Avl_Node k d l r Left_Balanced) k d l r Balanced *) (* Goal: bal_shrunk_left_spec k d l r Right_Balanced *) apply Hasnot_Shrunk_Left_Shift_Balanced. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. (* b=Right_Balanced *) (* Goal: bal_shrunk_left_spec k d l r Right_Balanced *) apply Balance_Shrunk_Left_Spec_Intro with (Avl_Node k d l r Balanced). (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Node_Is_Avl; try assumption. (* Goal: is_balanced_avl l r Balanced *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node k d l r Balanced)) (lin_avl (Avl_Node k d l r Left_Balanced)) *) (* Goal: equiv (Avl_Node k d l r Balanced) (Avl_Node k d l r Left_Balanced) *) (* Goal: sumbool (hasnot_shrunk_right (Avl_Node k d l r Balanced) k d l r Left_Balanced) (has_shrunk_right (Avl_Node k d l r Balanced) k d l r Left_Balanced) *) (* Goal: bal_shrunk_right_spec k d l r Balanced *) (* Goal: bal_shrunk_right_spec k d l r Right_Balanced *) apply Is_Fully_Balanced_Avl. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear Balanced_shift_l; assumption. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. (* Goal: equiv (Avl_Node k d l r Right_Balanced) (Avl_Node k d l r Balanced) *) (* Goal: sumbool (hasnot_shrunk_right (Avl_Node k d l r Right_Balanced) k d l r Balanced) (has_shrunk_right (Avl_Node k d l r Right_Balanced) k d l r Balanced) *) (* Goal: bal_shrunk_right_spec k d l r Right_Balanced *) apply equiv_refl. (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) right. (* Goal: has_shrunk_left (Avl_Node k d l r Balanced) k d l r Right_Balanced *) apply Has_Shrunk_Left_Shift_Right. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. Qed. (*****************************************************************) Inductive delete_max_spec (t0 : avl_tree) : Set := Del_Max_Spec_Intro : forall (k : Int) (d : B) (t : avl_tree), lookup k t0 d -> is_avl t -> is_below_avl t k -> lin_avl t0 = lin_avl t ++ (k, d) :: nil -> equiv_del k t0 t -> {height_avl t0 = height_avl t} + {height_avl t0 = S (height_avl t)} -> delete_max_spec t0. (*****************************************************************) Lemma delete_max : forall (k0 : Int) (d0 : B) (l0 r0 : avl_tree) (b0 : bal), is_avl (Avl_Node k0 d0 l0 r0 b0) -> delete_max_spec (Avl_Node k0 d0 l0 r0 b0). (* Goal: forall (k0 : Int) (d0 : B) (l0 r0 : avl_tree) (b0 : bal) (_ : is_avl (Avl_Node k0 d0 l0 r0 b0)), delete_max_spec (Avl_Node k0 d0 l0 r0 b0) *) intros k0 d0 l0 r0. (* Goal: forall (b0 : bal) (_ : is_avl (Avl_Node k0 d0 l0 r0 b0)), delete_max_spec (Avl_Node k0 d0 l0 r0 b0) *) generalize l0; clear l0. (* Goal: forall (l0 : avl_tree) (b0 : bal) (_ : is_avl (Avl_Node k0 d0 l0 r0 b0)), delete_max_spec (Avl_Node k0 d0 l0 r0 b0) *) generalize d0; clear d0. (* Goal: forall (d0 : B) (l0 : avl_tree) (b0 : bal) (_ : is_avl (Avl_Node k0 d0 l0 r0 b0)), delete_max_spec (Avl_Node k0 d0 l0 r0 b0) *) generalize k0; clear k0. (* Goal: forall (k0 : Int) (d0 : B) (l0 : avl_tree) (b0 : bal) (_ : is_avl (Avl_Node k0 d0 l0 r0 b0)), delete_max_spec (Avl_Node k0 d0 l0 r0 b0) *) elim r0; clear r0. (* r0=Avl_Nil *) (* Goal: forall (k0 : Int) (d0 : B) (l0 : avl_tree) (b0 : bal) (_ : is_avl (Avl_Node k0 d0 l0 Avl_Nil b0)), delete_max_spec (Avl_Node k0 d0 l0 Avl_Nil b0) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall (k0 : Int) (d0 : B) (l0 : avl_tree) (b0 : bal) (_ : is_avl (Avl_Node k0 d0 l0 a b0)), delete_max_spec (Avl_Node k0 d0 l0 a b0)) (a0 : avl_tree) (_ : forall (k0 : Int) (d0 : B) (l0 : avl_tree) (b0 : bal) (_ : is_avl (Avl_Node k0 d0 l0 a0 b0)), delete_max_spec (Avl_Node k0 d0 l0 a0 b0)) (b0 : bal) (k0 : Int) (d0 : B) (l0 : avl_tree) (b1 : bal) (_ : is_avl (Avl_Node k0 d0 l0 (Avl_Node i b a a0 b0) b1)), delete_max_spec (Avl_Node k0 d0 l0 (Avl_Node i b a a0 b0) b1) *) intros k0 d0 l0 b0 avl_t0. (* Goal: delete_max_spec (Avl_Node k0 d0 l0 Avl_Nil b0) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall (k0 : Int) (d0 : B) (l0 : avl_tree) (b0 : bal) (_ : is_avl (Avl_Node k0 d0 l0 a b0)), delete_max_spec (Avl_Node k0 d0 l0 a b0)) (a0 : avl_tree) (_ : forall (k0 : Int) (d0 : B) (l0 : avl_tree) (b0 : bal) (_ : is_avl (Avl_Node k0 d0 l0 a0 b0)), delete_max_spec (Avl_Node k0 d0 l0 a0 b0)) (b0 : bal) (k0 : Int) (d0 : B) (l0 : avl_tree) (b1 : bal) (_ : is_avl (Avl_Node k0 d0 l0 (Avl_Node i b a a0 b0) b1)), delete_max_spec (Avl_Node k0 d0 l0 (Avl_Node i b a a0 b0) b1) *) apply Del_Max_Spec_Intro with k0 d0 l0. (* Goal: lookup k0 (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d0 *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup_Equal. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear avl_t0; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear avl_t0; assumption. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply equiv_del_semi_leave; assumption. (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) right. (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) inversion_clear avl_t0. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 Avl_Nil b0)) (S (height_avl l0)) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall (k0 : Int) (d0 : B) (l0 : avl_tree) (b0 : bal) (_ : is_avl (Avl_Node k0 d0 l0 a b0)), delete_max_spec (Avl_Node k0 d0 l0 a b0)) (a0 : avl_tree) (_ : forall (k0 : Int) (d0 : B) (l0 : avl_tree) (b0 : bal) (_ : is_avl (Avl_Node k0 d0 l0 a0 b0)), delete_max_spec (Avl_Node k0 d0 l0 a0 b0)) (b0 : bal) (k0 : Int) (d0 : B) (l0 : avl_tree) (b1 : bal) (_ : is_avl (Avl_Node k0 d0 l0 (Avl_Node i b a a0 b0) b1)), delete_max_spec (Avl_Node k0 d0 l0 (Avl_Node i b a a0 b0) b1) *) inversion_clear H1. (* Goal: forall _ : is_balanced_avl l0 r0 Left_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Left_Balanced)) (S (height_avl l0)) *) (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *; trivial. (* Goal: forall _ : is_balanced_avl l0 r0 Left_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Left_Balanced)) (S (height_avl l0)) *) (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *; trivial. (* Goal: @eq nat (S O) (S (height_avl r0)) *) (* Goal: @eq nat (S O) (S (height_avl r0)) *) (* Goal: @eq nat (S (height_avl r0)) (S (height_avl r0)) *) (* Goal: forall (i : Int) (b : B) (a a0 : avl_tree) (b1 : bal) (_ : is_avl (Avl_Node k0 d0 (Avl_Node i b a a0 b1) r0 b0)), delete_spec key (Avl_Node k0 d0 (Avl_Node i b a a0 b1) r0 b0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) discriminate H4. (* r0=(Avl_Node kr0 dr0 lr0 rr0 br0) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall (k0 : Int) (d0 : B) (l0 : avl_tree) (b0 : bal) (_ : is_avl (Avl_Node k0 d0 l0 a b0)), delete_max_spec (Avl_Node k0 d0 l0 a b0)) (a0 : avl_tree) (_ : forall (k0 : Int) (d0 : B) (l0 : avl_tree) (b0 : bal) (_ : is_avl (Avl_Node k0 d0 l0 a0 b0)), delete_max_spec (Avl_Node k0 d0 l0 a0 b0)) (b0 : bal) (k0 : Int) (d0 : B) (l0 : avl_tree) (b1 : bal) (_ : is_avl (Avl_Node k0 d0 l0 (Avl_Node i b a a0 b0) b1)), delete_max_spec (Avl_Node k0 d0 l0 (Avl_Node i b a a0 b0) b1) *) intros kr0 dr0 lr0 ih_lr0 rr0 ih_rr0 br0 k0 d0 l0 b0 avl_t0. (* Goal: delete_max_spec (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0) *) elim (ih_rr0 kr0 dr0 lr0 br0); clear ih_lr0 ih_rr0. (* Goal: forall (k : Int) (d : B) (t : avl_tree) (_ : lookup k (Avl_Node kr0 dr0 lr0 rr0 br0) d) (_ : is_avl t) (_ : is_below_avl t k) (_ : @eq (list (prod Int B)) (lin_avl (Avl_Node kr0 dr0 lr0 rr0 br0)) (@app (prod Int B) (lin_avl t) (@cons (prod Int B) (@pair Int B k d) (@nil (prod Int B))))) (_ : equiv_del k (Avl_Node kr0 dr0 lr0 rr0 br0) t) (_ : sumbool (@eq nat (height_avl (Avl_Node kr0 dr0 lr0 rr0 br0)) (height_avl t)) (@eq nat (height_avl (Avl_Node kr0 dr0 lr0 rr0 br0)) (S (height_avl t)))), delete_max_spec (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0) *) (* Goal: is_avl (Avl_Node kr0 dr0 lr0 rr0 br0) *) intros k d r lookup_r avl_r below_avl_r lin_r equiv_del_r bal_or_shift. (* Goal: delete_max_spec (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0) *) (* Goal: is_avl (Avl_Node kr0 dr0 lr0 rr0 br0) *) elim (balance_shrunk_left k0 d0 l0 r b0). (* Goal: forall (t : avl_tree) (_ : is_avl t) (_ : @eq (list (prod Int B)) (lin_avl t) (lin_avl (Avl_Node k0 d0 l0 r b0))) (_ : equiv t (Avl_Node k0 d0 l0 r b0)) (_ : sumbool (hasnot_shrunk_left t k0 d0 l0 r b0) (has_shrunk_left t k0 d0 l0 r b0)), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) intros t avl_t lin_t equiv_t shrunk_dec. (* Goal: delete_max_spec (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl (Avl_Node kr0 dr0 lr0 rr0 br0) *) apply Del_Max_Spec_Intro with k d t. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Right; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: is_below_avl l k0 *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k0 *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: forall _ : not (Less key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply below_below_avl. (* Goal: is_below t k *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0)) (@app (prod Int B) (lin_avl t) (@cons (prod Int B) (@pair Int B k d) (@nil (prod Int B)))) *) (* Goal: equiv_del k (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl (Avl_Node kr0 dr0 lr0 rr0 br0) *) apply below_equiv_below with (Avl_Node k0 d0 l0 r b0). (* Goal: is_below (Avl_Node k0 d0 l0 r b0) k *) (* Goal: equiv t (Avl_Node k0 d0 l0 r b0) *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0)) (@app (prod Int B) (lin_avl t) (@cons (prod Int B) (@pair Int B k d) (@nil (prod Int B)))) *) (* Goal: equiv_del k (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl (Avl_Node kr0 dr0 lr0 rr0 br0) *) cut (Less k0 k). (* Goal: forall _ : Less k0 k, is_below (Avl_Node k0 d0 l0 r b0) k *) (* Goal: Less k0 k *) (* Goal: equiv t (Avl_Node k0 d0 l0 r b0) *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0)) (@app (prod Int B) (lin_avl t) (@cons (prod Int B) (@pair Int B k d) (@nil (prod Int B)))) *) (* Goal: equiv_del k (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl (Avl_Node kr0 dr0 lr0 rr0 br0) *) intro less_k0. (* Goal: is_below (Avl_Node k0 d0 l0 r b0) k *) (* Goal: Less k0 k *) (* Goal: equiv t (Avl_Node k0 d0 l0 r b0) *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0)) (@app (prod Int B) (lin_avl t) (@cons (prod Int B) (@pair Int B k d) (@nil (prod Int B)))) *) (* Goal: equiv_del k (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl (Avl_Node kr0 dr0 lr0 rr0 br0) *) apply Below_Node. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: is_below l0 k *) (* Goal: lookup k r0 d1 *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k)) (_ : lookup k1 (Avl_Node k0 d0 l0 l b0) data), lookup k1 (Avl_Node k0 d0 l0 r0 b0) data *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k)) (_ : lookup k1 (Avl_Node k0 d0 l0 r0 b0) data), lookup k1 (Avl_Node k0 d0 l0 l b0) data *) apply below_trans with k0. (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) inversion_clear avl_t0. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply is_below_avl_is_below; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply is_below_avl_is_below; assumption. (* Goal: Less k0 k *) (* Goal: equiv_del k (Avl_Node kr0 dr0 lr0 rr0 br0) r *) (* Goal: equiv (Avl_Node k0 d0 l0 r b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl (Avl_Node kr0 dr0 lr0 rr0 br0) *) apply lookup_above_greater with (Avl_Node kr0 dr0 lr0 rr0 br0) d. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) inversion_clear avl_t0. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply is_above_avl_is_above; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl l0) (@cons (prod Int B) (@pair Int B k0 d0) l1)) l2) *) (* Goal: lookup key r0 d *) (* Goal: equiv_del key (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite lin_t. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *. (* Goal: @eq (list (prod Int B)) (@app (prod Int B) (lin_avl l0) (@cons (prod Int B) (@pair Int B k0 d0) (@app (prod Int B) (lin_avl lr0) (@cons (prod Int B) (@pair Int B kr0 dr0) (lin_avl rr0))))) (@app (prod Int B) (@app (prod Int B) (lin_avl l0) (@cons (prod Int B) (@pair Int B k0 d0) (lin_avl r))) (@cons (prod Int B) (@pair Int B k d) (@nil (prod Int B)))) *) (* Goal: equiv_del k (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl (Avl_Node kr0 dr0 lr0 rr0 br0) *) rewrite (app_ass (lin_avl l0) ((k0, d0) :: lin_avl r) ((k, d) :: nil)). (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *. (* Goal: @eq (list (prod Int B)) (@app (prod Int B) (lin_avl l0) (@cons (prod Int B) (@pair Int B k0 d0) (@app (prod Int B) (lin_avl lr0) (@cons (prod Int B) (@pair Int B kr0 dr0) (lin_avl rr0))))) (@app (prod Int B) (lin_avl l0) (@cons (prod Int B) (@pair Int B k0 d0) (@app (prod Int B) (lin_avl r) (@cons (prod Int B) (@pair Int B k d) (@nil (prod Int B)))))) *) (* Goal: equiv_del k (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl (Avl_Node kr0 dr0 lr0 rr0 br0) *) rewrite <- lin_r. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. (* Goal: equiv_del k (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl (Avl_Node kr0 dr0 lr0 rr0 br0) *) apply equiv_del_equiv_equiv_del with (Avl_Node k0 d0 l0 r b0). (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) apply equiv_del_right. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: Less k0 k *) (* Goal: equiv_del k (Avl_Node kr0 dr0 lr0 rr0 br0) r *) (* Goal: equiv (Avl_Node k0 d0 l0 r b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl (Avl_Node kr0 dr0 lr0 rr0 br0) *) apply lookup_above_greater with (Avl_Node kr0 dr0 lr0 rr0 br0) d. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) inversion_clear avl_t0. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply is_above_avl_is_above; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply equiv_sym; assumption. (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl (Avl_Node kr0 dr0 lr0 rr0 br0) *) clear equiv_t avl_t lin_r equiv_del_r below_avl_r lookup_r bal_or_shift. (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) elim shrunk_dec; clear shrunk_dec. (* Goal: forall _ : hasnot_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0)) (S (height_avl t))) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl (Avl_Node kr0 dr0 lr0 rr0 br0) *) intros has_notshrunk. (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) left. (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) inversion_clear avl_t0. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) generalize H1; clear H H0 H1 H2 H3. (* Goal: forall _ : is_balanced_avl l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0, @eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0)) (height_avl t) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl (Avl_Node kr0 dr0 lr0 rr0 br0) *) inversion_clear has_notshrunk. (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H0; clear H0. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) inversion_clear H; simpl in |- *. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (S (height_avl r0)) (S (height_avl r)) *) (* Goal: forall _ : is_balanced_avl l0 r0 Left_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Left_Balanced)) (height_avl t) *) (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Balanced)) (height_avl t) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite <- H0; clear H0. (* Goal: forall _ : @eq nat match blr with | Left_Balanced => S (height_avl llr) | Balanced => S (height_avl llr) | Right_Balanced => S (height_avl rlr) end (S (height_avl r)), @eq nat (height_avl (Avl_Node klr dlr (Avl_Node kl dl ll llr match blr with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node k d rlr r match blr with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (height_avl (Avl_Node kl dl ll (Avl_Node klr dlr llr rlr blr) Right_Balanced)) *) intros Balanced_l; inversion_clear Balanced_l. (* Goal: @eq nat (S match br0 with | Left_Balanced => S (height_avl lr0) | Balanced => S (height_avl lr0) | Right_Balanced => S (height_avl rr0) end) (S (S (height_avl l0))) *) (* Goal: forall _ : is_balanced_avl l0 (Avl_Node kr0 dr0 lr0 rr0 br0) Left_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) Left_Balanced)) (height_avl t) *) (* Goal: forall _ : is_balanced_avl l0 (Avl_Node kr0 dr0 lr0 rr0 br0) Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) Balanced)) (height_avl t) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl (Avl_Node kr0 dr0 lr0 rr0 br0) *) rewrite H. (* Goal: forall _ : is_balanced_avl l0 r0 Left_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Left_Balanced)) (S (height_avl l0)) *) (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *; trivial. (* Goal: forall _ : is_balanced_avl l0 r0 Left_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Left_Balanced)) (S (height_avl l0)) *) (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H0; simpl in |- *; trivial. (* Goal: forall _ : is_balanced_avl l0 r0 Left_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Left_Balanced)) (S (height_avl l0)) *) (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H0; simpl in |- *; trivial. (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl (Avl_Node kr0 dr0 lr0 rr0 br0) *) intro has_shrunk. (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) right. (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) inversion_clear avl_t0. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 (Avl_Node kr0 dr0 lr0 rr0 br0) b0)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_avl r *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl (Avl_Node kr0 dr0 lr0 rr0 br0) *) generalize H1; clear H1 H H0 H2 H3. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) inversion_clear has_shrunk; simpl in |- *. (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H0; clear H0. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H0; clear H0. (* Goal: forall _ : @eq nat match blr with | Left_Balanced => S (height_avl llr) | Balanced => S (height_avl llr) | Right_Balanced => S (height_avl rlr) end (S (height_avl r)), @eq nat (height_avl (Avl_Node klr dlr (Avl_Node kl dl ll llr match blr with | Left_Balanced => Balanced | Balanced => Balanced | Right_Balanced => Left_Balanced end) (Avl_Node k d rlr r match blr with | Left_Balanced => Right_Balanced | Balanced => Balanced | Right_Balanced => Balanced end) Balanced)) (height_avl (Avl_Node kl dl ll (Avl_Node klr dlr llr rlr blr) Right_Balanced)) *) intros Balanced_l; inversion_clear Balanced_l. (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Balanced, @eq nat (S match bl0 with | Left_Balanced => S (height_avl ll0) | Balanced => S (height_avl ll0) | Right_Balanced => S (height_avl rl0) end) (S (height_avl l)) *) (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced, @eq nat (S (height_avl r0)) (S (height_avl r0)) *) (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Balanced, @eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Balanced)) (height_avl t) *) (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced)) (height_avl t) *) (* Goal: forall _ : has_shrunk_right t k d l r0 b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) rewrite H0. (* Goal: forall _ : is_balanced_avl l0 r0 Left_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Left_Balanced)) (S (height_avl l0)) *) (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *; trivial. (* side premisses (Elim (balance ...)) *) (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear avl_t0; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear avl_t0; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) apply above_above_avl. (* Goal: is_above r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl (Avl_Node kr0 dr0 lr0 rr0 br0) *) apply above_equiv_del_above with (Avl_Node kr0 dr0 lr0 rr0 br0) k. (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) inversion_clear avl_t0. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply is_above_avl_is_above; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl (Avl_Node kr0 dr0 lr0 rr0 br0) *) elim bal_or_shift; clear bal_or_shift; intros height_r. (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) left. apply hasnot_grown_right__preserves_is_balanced_avl with (Avl_Node kr0 dr0 lr0 rr0 br0). (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear avl_t0; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) symmetry in |- *; assumption. (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) right. (* Goal: is_balanced_avl_left_shift l0 r b0 *) (* Goal: is_avl (Avl_Node kr0 dr0 lr0 rr0 br0) *) apply Balanced_shrunk_left_balanced_shift with (Avl_Node kr0 dr0 lr0 rr0 br0). (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear avl_t0; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Side premiss of (Elim ih_rr0) *) (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear avl_t0; assumption. Qed. (**********************************************************************) Inductive hasnot_shrunk_right (t : avl_tree) (k : Int) (d : B) (l r : avl_tree) : bal -> Prop := | Hasnot_Shrunk_Right_Bal : forall b : bal, is_balanced_avl l r b -> height_avl t = height_avl (Avl_Node k d l r b) -> hasnot_shrunk_right t k d l r b | Hasnot_Shrunk_Right_Shift_Balanced : is_balanced_avl_right_shift l r Balanced -> height_avl t = S (height_avl r) -> hasnot_shrunk_right t k d l r Balanced | Hasnot_Shrunk_Right_Shift_Right : is_balanced_avl_right_shift l r Right_Balanced -> height_avl t = S (height_avl r) -> hasnot_shrunk_right t k d l r Right_Balanced. Inductive has_shrunk_right (t : avl_tree) (k : Int) (d : B) (l r : avl_tree) : bal -> Prop := | Has_Shrunk_Right_Shift_Left : is_balanced_avl_right_shift l r Left_Balanced -> height_avl t = S (height_avl r) -> has_shrunk_right t k d l r Left_Balanced | Has_Shrunk_Right_Shift_Right : is_balanced_avl_right_shift l r Right_Balanced -> height_avl t = height_avl r -> has_shrunk_right t k d l r Right_Balanced. Inductive bal_shrunk_right_spec (k : Int) (d : B) (l r : avl_tree) (b : bal) : Set := Balance_Shrunk_Right_Spec_Intro : forall t : avl_tree, is_avl t -> lin_avl t = lin_avl (Avl_Node k d l r b) -> equiv t (Avl_Node k d l r b) -> {hasnot_shrunk_right t k d l r b} + {has_shrunk_right t k d l r b} -> bal_shrunk_right_spec k d l r b. Lemma balance_shrunk_right : forall (k : Int) (d : B) (l r : avl_tree) (b : bal), is_avl l -> is_below_avl l k -> is_avl r -> is_above_avl r k -> {is_balanced_avl l r b} + {is_balanced_avl_right_shift l r b} -> bal_shrunk_right_spec k d l r b. (* Goal: forall (k : Int) (d : B) (l r : avl_tree) (b : bal) (_ : is_avl l) (_ : is_below_avl l k) (_ : is_avl r) (_ : is_above_avl r k) (_ : sumbool (is_balanced_avl l r b) (is_balanced_avl_right_shift l r b)), bal_shrunk_right_spec k d l r b *) intros k d l r b avl_l below_avl_l avl_r above_avl_r bal_or_shift. (* Goal: bal_shrunk_right_spec k d l r b *) elim bal_or_shift; clear bal_or_shift. (* l and r is Balanced with respect to b *) (* Goal: forall _ : is_balanced_avl l r b, bal_shrunk_right_spec k d l r b *) (* Goal: forall _ : is_balanced_avl_right_shift l r b, bal_shrunk_right_spec k d l r b *) intro Balanced_l. (* Goal: bal_shrunk_right_spec k d l r b *) (* Goal: forall _ : is_balanced_avl_right_shift l r b, bal_shrunk_right_spec k d l r b *) apply Balance_Shrunk_Right_Spec_Intro with (Avl_Node k d l r b). (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Node_Is_Avl; assumption. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. (* Goal: equiv (Avl_Node k d l r Right_Balanced) (Avl_Node k d l r Balanced) *) (* Goal: sumbool (hasnot_shrunk_right (Avl_Node k d l r Right_Balanced) k d l r Balanced) (has_shrunk_right (Avl_Node k d l r Right_Balanced) k d l r Balanced) *) (* Goal: bal_shrunk_right_spec k d l r Right_Balanced *) apply equiv_refl. (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) left. (* Goal: hasnot_shrunk_right (Avl_Node k d l r b) k d l r b *) (* Goal: forall _ : is_balanced_avl_right_shift l r b, bal_shrunk_right_spec k d l r b *) apply Hasnot_Shrunk_Right_Bal. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. (* l and r is'nt Balanced with respect to b *) (* Goal: forall _ : is_balanced_avl_right_shift l r b, bal_shrunk_right_spec k d l r b *) elim b; clear b; intros Balanced_shift_l. (* b=Left_Balanced *) (* Goal: bal_shrunk_right_spec k d l r Left_Balanced *) (* Goal: bal_shrunk_right_spec k d l r Balanced *) (* Goal: bal_shrunk_right_spec k d l r Right_Balanced *) apply Balance_Shrunk_Right_Spec_Intro with (Avl_Node k d l r Balanced). (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Node_Is_Avl; try assumption. (* Goal: is_balanced_avl l r Balanced *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node k d l r Balanced)) (lin_avl (Avl_Node k d l r Left_Balanced)) *) (* Goal: equiv (Avl_Node k d l r Balanced) (Avl_Node k d l r Left_Balanced) *) (* Goal: sumbool (hasnot_shrunk_right (Avl_Node k d l r Balanced) k d l r Left_Balanced) (has_shrunk_right (Avl_Node k d l r Balanced) k d l r Left_Balanced) *) (* Goal: bal_shrunk_right_spec k d l r Balanced *) (* Goal: bal_shrunk_right_spec k d l r Right_Balanced *) apply Is_Fully_Balanced_Avl. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear Balanced_shift_l; assumption. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. (* Goal: equiv (Avl_Node k d l r Right_Balanced) (Avl_Node k d l r Balanced) *) (* Goal: sumbool (hasnot_shrunk_right (Avl_Node k d l r Right_Balanced) k d l r Balanced) (has_shrunk_right (Avl_Node k d l r Right_Balanced) k d l r Balanced) *) (* Goal: bal_shrunk_right_spec k d l r Right_Balanced *) apply equiv_refl. (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) right. (* Goal: has_shrunk_right (Avl_Node k d l r Balanced) k d l r Left_Balanced *) (* Goal: bal_shrunk_right_spec k d l r Balanced *) (* Goal: bal_shrunk_right_spec k d l r Right_Balanced *) apply Has_Shrunk_Right_Shift_Left. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *. (* Goal: @eq nat (S (height_avl l)) (S (height_avl r)) *) (* Goal: bal_shrunk_right_spec k d l r Balanced *) (* Goal: bal_shrunk_right_spec k d l r Right_Balanced *) inversion_clear Balanced_shift_l. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H; trivial. (* b=Balanced *) (* Goal: bal_shrunk_right_spec k d l r Balanced *) (* Goal: bal_shrunk_right_spec k d l r Right_Balanced *) apply Balance_Shrunk_Right_Spec_Intro with (Avl_Node k d l r Right_Balanced). (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Node_Is_Avl; try assumption. (* Goal: is_balanced_avl l r Right_Balanced *) (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node k d l r Right_Balanced)) (lin_avl (Avl_Node k d l r Balanced)) *) (* Goal: equiv (Avl_Node k d l r Right_Balanced) (Avl_Node k d l r Balanced) *) (* Goal: sumbool (hasnot_shrunk_right (Avl_Node k d l r Right_Balanced) k d l r Balanced) (has_shrunk_right (Avl_Node k d l r Right_Balanced) k d l r Balanced) *) (* Goal: bal_shrunk_right_spec k d l r Right_Balanced *) apply Is_Right_Balanced_Avl. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear Balanced_shift_l; assumption. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. (* Goal: equiv (Avl_Node k d l r Right_Balanced) (Avl_Node k d l r Balanced) *) (* Goal: sumbool (hasnot_shrunk_right (Avl_Node k d l r Right_Balanced) k d l r Balanced) (has_shrunk_right (Avl_Node k d l r Right_Balanced) k d l r Balanced) *) (* Goal: bal_shrunk_right_spec k d l r Right_Balanced *) apply equiv_refl. (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) left. (* Goal: hasnot_shrunk_right (Avl_Node k d l r Right_Balanced) k d l r Balanced *) (* Goal: bal_shrunk_right_spec k d l r Right_Balanced *) apply Hasnot_Shrunk_Right_Shift_Balanced. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. (* b=Right_Balanced *) (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) elim (rebalance_right k d l r Right_Balanced); try assumption. (* Goal: forall (x : avl_tree) (_ : and (is_avl x) (and (@eq (list (prod Int B)) (lin_avl x) (lin_avl (Avl_Node k d l r Right_Balanced))) (and (equiv x (Avl_Node k d l r Right_Balanced)) match r with | Avl_Nil => True | Avl_Node i b a a0 (Left_Balanced as b0) => @eq nat (height_avl x) (height_avl r) | Avl_Node i b a a0 (Balanced as b0) => @eq nat (height_avl x) (S (height_avl r)) | Avl_Node i b a a0 (Right_Balanced as b0) => @eq nat (height_avl x) (height_avl r) end))), bal_shrunk_right_spec k d l r Right_Balanced *) (* Goal: @eq nat (S (S (height_avl l))) (height_avl r) *) intros t (avl_t,(lin_t,(equiv_t,height_t))). (* Goal: bal_shrunk_right_spec k d l r Right_Balanced *) (* Goal: @eq nat (S (S (height_avl l))) (height_avl r) *) apply Balance_Shrunk_Right_Spec_Intro with t. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: sumbool (hasnot_shrunk_right t k d l r Right_Balanced) (has_shrunk_right t k d l r Right_Balanced) *) (* Goal: @eq nat (S (S (height_avl l))) (height_avl r) *) clear lin_t equiv_t avl_l below_avl_l avl_r above_avl_r. (* Goal: sumbool (hasnot_shrunk_right t k d l r Right_Balanced) (has_shrunk_right t k d l r Right_Balanced) *) (* Goal: @eq nat (S (S (height_avl l))) (height_avl r) *) generalize height_t; clear height_t. (* Goal: forall _ : match r with | Avl_Nil => True | Avl_Node i b a a0 (Left_Balanced as b0) => @eq nat (height_avl t) (height_avl r) | Avl_Node i b a a0 (Balanced as b0) => @eq nat (height_avl t) (S (height_avl r)) | Avl_Node i b a a0 (Right_Balanced as b0) => @eq nat (height_avl t) (height_avl r) end, sumbool (hasnot_shrunk_right t k d l r Right_Balanced) (has_shrunk_right t k d l r Right_Balanced) *) (* Goal: @eq nat (S (S (height_avl l))) (height_avl r) *) generalize Balanced_shift_l; clear Balanced_shift_l. (* Goal: forall (_ : is_balanced_avl_right_shift l r Right_Balanced) (_ : match r with | Avl_Nil => True | Avl_Node i b a a0 (Left_Balanced as b0) => @eq nat (height_avl t) (height_avl r) | Avl_Node i b a a0 (Balanced as b0) => @eq nat (height_avl t) (S (height_avl r)) | Avl_Node i b a a0 (Right_Balanced as b0) => @eq nat (height_avl t) (height_avl r) end), sumbool (hasnot_shrunk_right t k d l r Right_Balanced) (has_shrunk_right t k d l r Right_Balanced) *) (* Goal: @eq nat (S (S (height_avl l))) (height_avl r) *) case r; clear r. (* Goal: forall (_ : is_balanced_avl_right_shift l Avl_Nil Right_Balanced) (_ : True), sumbool (hasnot_shrunk_right t k d l Avl_Nil Right_Balanced) (has_shrunk_right t k d l Avl_Nil Right_Balanced) *) (* Goal: forall (i : Int) (b : B) (a a0 : avl_tree) (b0 : bal) (_ : is_balanced_avl_right_shift l (Avl_Node i b a a0 b0) Right_Balanced) (_ : match b0 with | Left_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node i b a a0 b0)) | Balanced => @eq nat (height_avl t) (S (height_avl (Avl_Node i b a a0 b0))) | Right_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node i b a a0 b0)) end), sumbool (hasnot_shrunk_right t k d l (Avl_Node i b a a0 b0) Right_Balanced) (has_shrunk_right t k d l (Avl_Node i b a a0 b0) Right_Balanced) *) (* Goal: @eq nat (S (S (height_avl l))) (height_avl r) *) intro u0. (* Goal: lin_del_spec key d Avl_Nil Avl_Nil *) (* Goal: equiv_del key Avl_Nil Avl_Nil *) (* Goal: sumbool (@eq nat (height_avl Avl_Nil) (height_avl Avl_Nil)) (@eq nat (height_avl Avl_Nil) (S (height_avl Avl_Nil))) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, delete_spec key a) (a0 : avl_tree) (_ : forall _ : is_avl a0, delete_spec key a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), delete_spec key (Avl_Node i b a a0 b0) *) elimtype False. (* Goal: False *) (* Goal: forall (i : Int) (b : B) (a a0 : avl_tree) (b0 : bal) (_ : is_balanced_avl_right_shift l (Avl_Node i b a a0 b0) Right_Balanced) (_ : match b0 with | Left_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node i b a a0 b0)) | Balanced => @eq nat (height_avl t) (S (height_avl (Avl_Node i b a a0 b0))) | Right_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node i b a a0 b0)) end), sumbool (hasnot_shrunk_right t k d l (Avl_Node i b a a0 b0) Right_Balanced) (has_shrunk_right t k d l (Avl_Node i b a a0 b0) Right_Balanced) *) (* Goal: @eq nat (S (S (height_avl l))) (height_avl r) *) inversion_clear u0. (* Goal: False *) (* Goal: forall (i : Int) (b : B) (a a0 : avl_tree) (b0 : bal) (_ : is_balanced_avl_right_shift l (Avl_Node i b a a0 b0) Right_Balanced) (_ : match b0 with | Left_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node i b a a0 b0)) | Balanced => @eq nat (height_avl t) (S (height_avl (Avl_Node i b a a0 b0))) | Right_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node i b a a0 b0)) end), sumbool (hasnot_shrunk_right t k d l (Avl_Node i b a a0 b0) Right_Balanced) (has_shrunk_right t k d l (Avl_Node i b a a0 b0) Right_Balanced) *) (* Goal: @eq nat (S (S (height_avl l))) (height_avl r) *) discriminate H. (* Goal: forall (i : Int) (b : B) (a a0 : avl_tree) (b0 : bal) (_ : is_balanced_avl_right_shift l (Avl_Node i b a a0 b0) Right_Balanced) (_ : match b0 with | Left_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node i b a a0 b0)) | Balanced => @eq nat (height_avl t) (S (height_avl (Avl_Node i b a a0 b0))) | Right_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node i b a a0 b0)) end), sumbool (hasnot_shrunk_right t k d l (Avl_Node i b a a0 b0) Right_Balanced) (has_shrunk_right t k d l (Avl_Node i b a a0 b0) Right_Balanced) *) (* Goal: @eq nat (S (S (height_avl l))) (height_avl r) *) intros kr dr lr rr br. (* Goal: forall (_ : is_balanced_avl_right_shift l (Avl_Node kr dr lr rr br) Right_Balanced) (_ : match br with | Left_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node kr dr lr rr br)) | Balanced => @eq nat (height_avl t) (S (height_avl (Avl_Node kr dr lr rr br))) | Right_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node kr dr lr rr br)) end), sumbool (hasnot_shrunk_right t k d l (Avl_Node kr dr lr rr br) Right_Balanced) (has_shrunk_right t k d l (Avl_Node kr dr lr rr br) Right_Balanced) *) (* Goal: @eq nat (S (S (height_avl l))) (height_avl r) *) elim br; clear br; simpl in |- *; intros Balanced_shift_l height_t. (* br=Left_Balanced *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) right. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Has_Shrunk_Right_Shift_Right; assumption. (* br=Balanced *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) left. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Hasnot_Shrunk_Right_Shift_Right; assumption. (* br=Right_Balanced *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) right. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Has_Shrunk_Right_Shift_Right; assumption. (* side premisses of (Elim (rebalance ... )) *) (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear Balanced_shift_l; assumption. Qed. (*******************************************************************) Inductive lin_del_spec (key : Int) (d : B) (t0 t : avl_tree) : Prop := Lin_Del_Spec_Intro : forall l0 l1 : list (Int * B), lin_avl t0 = l0 ++ (key, d) :: l1 -> lin_avl t = l0 ++ l1 -> lin_del_spec key d t0 t. Inductive delete_spec (key : Int) (t0 : avl_tree) : Set := Delete_Spec_Intro : forall t : avl_tree, lookup_dec_spec key t0 -> is_avl t -> (forall d : B, lookup key t0 d -> lin_del_spec key d t0 t) -> equiv_del key t0 t -> {height_avl t0 = height_avl t} + {height_avl t0 = S (height_avl t)} -> delete_spec key t0. Lemma equiv_del_nil : forall key : Int, equiv_del key Avl_Nil Avl_Nil. (* Goal: forall key : Int, equiv_del key Avl_Nil Avl_Nil *) intros key. (* Goal: equiv_del k (Avl_Node k0 d0 l0 l b0) (Avl_Node k0 d0 l0 r0 b0) *) apply equiv_del_intro. (* Goal: forall (k : Int) (_ : Equal k key) (d : B) (_ : lookup k Avl_Nil d), False *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k Avl_Nil data), lookup k Avl_Nil data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k Avl_Nil data), lookup k Avl_Nil data *) intros k equal d lookup_nil. (* Goal: False *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k Avl_Nil data), lookup k Avl_Nil data *) (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k Avl_Nil data), lookup k Avl_Nil data *) apply (inv_lookup_nil k d lookup_nil). (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k Avl_Nil data), lookup k Avl_Nil data *) intros k d notequal lookup_nil. (* Goal: lookup k Avl_Nil d *) apply lookup_nil. (* Goal: forall (k : Int) (data : B) (_ : not (Equal k key)) (_ : lookup k Avl_Nil data), lookup k Avl_Nil data *) intros k d notequal lookup_nil. (* Goal: lookup k Avl_Nil d *) apply lookup_nil. Qed. Lemma equiv_del_right_semi_leave : forall (k : Int) (d : B) (r : avl_tree) (b : bal), is_avl (Avl_Node k d Avl_Nil r b) -> equiv_del k (Avl_Node k d Avl_Nil r b) r. (* Goal: forall (k : Int) (d : B) (r : avl_tree) (b : bal) (_ : is_avl (Avl_Node k d Avl_Nil r b)), equiv_del k (Avl_Node k d Avl_Nil r b) r *) intros k d r b avl_t. (* Goal: equiv_del k (Avl_Node k0 d0 l0 l b0) (Avl_Node k0 d0 l0 r0 b0) *) apply equiv_del_intro. (* Goal: forall (k0 : Int) (_ : Equal k0 k) (d : B) (_ : lookup k0 r d), False *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 (Avl_Node k d Avl_Nil r b) data), lookup k0 r data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 r data), lookup k0 (Avl_Node k d Avl_Nil r b) data *) intros k0 equal d0 lookup_r. (* Goal: False *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 (Avl_Node k d Avl_Nil r b) data), lookup k0 r data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 r data), lookup k0 (Avl_Node k d Avl_Nil r b) data *) apply (less_irrefl k). (* Goal: Less k k *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 (Avl_Node k d Avl_Nil r b) data), lookup k0 r data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 r data), lookup k0 (Avl_Node k d Avl_Nil r b) data *) apply (less_equal_less k k0 k). (* Goal: Less k k0 *) (* Goal: Equal k0 k *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 (Avl_Node k d Avl_Nil r b) data), lookup k0 r data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 r data), lookup k0 (Avl_Node k d Avl_Nil r b) data *) apply (lookup_above_greater k0 r d0 k lookup_r). (* Goal: is_above r k *) (* Goal: Equal k0 k *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 (Avl_Node k d Avl_Nil r b) data), lookup k0 r data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 r data), lookup k0 (Avl_Node k d Avl_Nil r b) data *) inversion_clear avl_t. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply is_above_avl_is_above; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 (Avl_Node k d Avl_Nil r b) data), lookup k0 r data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 r data), lookup k0 (Avl_Node k d Avl_Nil r b) data *) intros k0 data notequal lookup_t. (* Goal: lookup k0 r data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 r data), lookup k0 (Avl_Node k d Avl_Nil r b) data *) generalize notequal; clear notequal. (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 r data), lookup k0 (Avl_Node k d Avl_Nil r b) data *) inversion_clear lookup_t. (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) intro notequal. (* Goal: lin_del_spec key d Avl_Nil Avl_Nil *) (* Goal: equiv_del key Avl_Nil Avl_Nil *) (* Goal: sumbool (@eq nat (height_avl Avl_Nil) (height_avl Avl_Nil)) (@eq nat (height_avl Avl_Nil) (S (height_avl Avl_Nil))) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, delete_spec key a) (a0 : avl_tree) (_ : forall _ : is_avl a0, delete_spec key a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), delete_spec key (Avl_Node i b a a0 b0) *) elimtype False. (* Goal: False *) (* Goal: lookup k1 (Avl_Node k d l r0 b0) d1 *) (* Goal: lookup k1 (Avl_Node k d l r0 b0) d1 *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k0)) (_ : lookup k1 (Avl_Node k d l r0 b0) data), lookup k1 (Avl_Node k0 d0 l0 r0 b0) data *) apply notequal. (* Goal: Equal k0 k0 *) (* Goal: lookup k1 (Avl_Node k d l r0 b0) d1 *) (* Goal: lookup k1 (Avl_Node k d l r0 b0) d1 *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k0)) (_ : lookup k1 (Avl_Node k d l r0 b0) data), lookup k1 (Avl_Node k0 d0 l0 r0 b0) data *) apply equal_refl. (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall _ : not (Equal k0 k), lookup k0 r data *) (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 r data), lookup k0 (Avl_Node k d Avl_Nil r b) data *) inversion_clear H. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) intros; assumption. (* Goal: forall (k0 : Int) (data : B) (_ : not (Equal k0 k)) (_ : lookup k0 r data), lookup k0 (Avl_Node k d Avl_Nil r b) data *) intros k0 data notequal lookup_l. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Right; assumption. Qed. Lemma equiv_del_equal : forall (key k0 k : Int) (l0 l r0 : avl_tree) (b0 : bal) (d d0 : B), Equal key k0 -> equiv_del k l0 l -> lookup k l0 d -> is_below l0 k0 -> is_above r0 k0 -> is_avl l0 -> equiv_del key (Avl_Node k0 d0 l0 r0 b0) (Avl_Node k d l r0 b0). intros key k0 k l0 l r0 b0 d d0 equal_key equiv_del_l lookup_l below_l0 above_r0 avl_l0. (* Goal: equiv_del key (Avl_Node k0 d0 l0 r0 b0) (Avl_Node k d l r0 b0) *) rewrite (equal_eq key k0 equal_key); clear equal_key key. (* Goal: equiv_del k (Avl_Node k0 d0 l0 l b0) (Avl_Node k0 d0 l0 r0 b0) *) apply equiv_del_intro. (* Goal: forall (k1 : Int) (_ : Equal k1 k0) (d0 : B) (_ : lookup k1 (Avl_Node k d l r0 b0) d0), False *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k0)) (_ : lookup k1 (Avl_Node k0 d0 l0 r0 b0) data), lookup k1 (Avl_Node k d l r0 b0) data *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k0)) (_ : lookup k1 (Avl_Node k d l r0 b0) data), lookup k1 (Avl_Node k0 d0 l0 r0 b0) data *) intros k1 equal_k1 d1 lookup_d1. (* Goal: False *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k0)) (_ : lookup k1 (Avl_Node k0 d0 l0 r0 b0) data), lookup k1 (Avl_Node k d l r0 b0) data *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k0)) (_ : lookup k1 (Avl_Node k d l r0 b0) data), lookup k1 (Avl_Node k0 d0 l0 r0 b0) data *) rewrite (equal_eq k1 k0 equal_k1) in lookup_d1; clear equal_k1 k1. (* Goal: False *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k0)) (_ : lookup k1 (Avl_Node k0 d0 l0 r0 b0) data), lookup k1 (Avl_Node k d l r0 b0) data *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k0)) (_ : lookup k1 (Avl_Node k d l r0 b0) data), lookup k1 (Avl_Node k0 d0 l0 r0 b0) data *) inversion lookup_d1. (* Goal: False *) (* Goal: False *) (* Goal: False *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k0)) (_ : lookup k1 (Avl_Node k0 d0 l0 r0 b0) data), lookup k1 (Avl_Node k d l r0 b0) data *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k0)) (_ : lookup k1 (Avl_Node k d l r0 b0) data), lookup k1 (Avl_Node k0 d0 l0 r0 b0) data *) apply lookup_below_false with k l0 d. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Left_Balanced)) (S (S (height_avl r0))) *) (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) rewrite <- H0. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: False *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k0)) (_ : lookup k1 (Avl_Node k0 d0 l0 r0 b0) data), lookup k1 (Avl_Node k d l r0 b0) data *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k0)) (_ : lookup k1 (Avl_Node k d l r0 b0) data), lookup k1 (Avl_Node k0 d0 l0 r0 b0) data *) clear H0 H4 H3 H2 H1 H data b r l1 d2 k1 lookup_d1. (* Goal: False *) (* Goal: False *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k0)) (_ : lookup k1 (Avl_Node k0 d0 l0 r0 b0) data), lookup k1 (Avl_Node k d l r0 b0) data *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k0)) (_ : lookup k1 (Avl_Node k d l r0 b0) data), lookup k1 (Avl_Node k0 d0 l0 r0 b0) data *) apply lookup_below_false with k0 l0 d1. (* Goal: lookup k1 l0 d1 *) (* Goal: lookup k1 (Avl_Node k0 d0 l0 r0 b0) d1 *) inversion_clear equiv_del_l. (* Goal: lookup k0 l0 d1 *) (* Goal: is_below l0 k0 *) (* Goal: False *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k0)) (_ : lookup k1 (Avl_Node k0 d0 l0 r0 b0) data), lookup k1 (Avl_Node k d l r0 b0) data *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k0)) (_ : lookup k1 (Avl_Node k d l r0 b0) data), lookup k1 (Avl_Node k0 d0 l0 r0 b0) data *) apply H1. (* Goal: forall (_ : is_balanced_avl_right_shift l Avl_Nil Right_Balanced) (_ : True), sumbool (hasnot_shrunk_right t k d l Avl_Nil Right_Balanced) (has_shrunk_right t k d l Avl_Nil Right_Balanced) *) (* Goal: forall (i : Int) (b : B) (a a0 : avl_tree) (b0 : bal) (_ : is_balanced_avl_right_shift l (Avl_Node i b a a0 b0) Right_Balanced) (_ : match b0 with | Left_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node i b a a0 b0)) | Balanced => @eq nat (height_avl t) (S (height_avl (Avl_Node i b a a0 b0))) | Right_Balanced => @eq nat (height_avl t) (height_avl (Avl_Node i b a a0 b0)) end), sumbool (hasnot_shrunk_right t k d l (Avl_Node i b a a0 b0) Right_Balanced) (has_shrunk_right t k d l (Avl_Node i b a a0 b0) Right_Balanced) *) (* Goal: @eq nat (S (S (height_avl l))) (height_avl r) *) unfold not in |- *; intro u0. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply H with k0 d1; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: False *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k0)) (_ : lookup k1 (Avl_Node k0 d0 l0 r0 b0) data), lookup k1 (Avl_Node k d l r0 b0) data *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k0)) (_ : lookup k1 (Avl_Node k d l r0 b0) data), lookup k1 (Avl_Node k0 d0 l0 r0 b0) data *) clear H0 H4 H3 H2 H1 H data b r l1 d2 k1 lookup_d1. (* Goal: False *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k0)) (_ : lookup k1 (Avl_Node k0 d0 l0 r0 b0) data), lookup k1 (Avl_Node k d l r0 b0) data *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k0)) (_ : lookup k1 (Avl_Node k d l r0 b0) data), lookup k1 (Avl_Node k0 d0 l0 r0 b0) data *) apply lookup_above_false with k0 r0 d1. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k0)) (_ : lookup k1 (Avl_Node k0 d0 l0 r0 b0) data), lookup k1 (Avl_Node k d l r0 b0) data *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k0)) (_ : lookup k1 (Avl_Node k d l r0 b0) data), lookup k1 (Avl_Node k0 d0 l0 r0 b0) data *) intros k1 d1 notequal lookup_t0. (* Goal: lookup k1 (Avl_Node k d l r0 b0) d1 *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k0)) (_ : lookup k1 (Avl_Node k d l r0 b0) data), lookup k1 (Avl_Node k0 d0 l0 r0 b0) data *) inversion lookup_t0; clear lookup_t0. (* Goal: lin_del_spec key d Avl_Nil Avl_Nil *) (* Goal: equiv_del key Avl_Nil Avl_Nil *) (* Goal: sumbool (@eq nat (height_avl Avl_Nil) (height_avl Avl_Nil)) (@eq nat (height_avl Avl_Nil) (S (height_avl Avl_Nil))) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, delete_spec key a) (a0 : avl_tree) (_ : forall _ : is_avl a0, delete_spec key a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), delete_spec key (Avl_Node i b a a0 b0) *) elimtype False. (* Goal: False *) (* Goal: lookup k1 (Avl_Node k d l r0 b0) d1 *) (* Goal: lookup k1 (Avl_Node k d l r0 b0) d1 *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k0)) (_ : lookup k1 (Avl_Node k d l r0 b0) data), lookup k1 (Avl_Node k0 d0 l0 r0 b0) data *) apply notequal. (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Balanced, @eq nat (S match bl0 with | Left_Balanced => S (height_avl ll0) | Balanced => S (height_avl ll0) | Right_Balanced => S (height_avl rl0) end) (S (height_avl l)) *) (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced, @eq nat (S (height_avl r0)) (S (height_avl r0)) *) (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Balanced, @eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Balanced)) (height_avl t) *) (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced)) (height_avl t) *) (* Goal: forall _ : has_shrunk_right t k d l r0 b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) rewrite H0. (* Goal: Equal k0 k0 *) (* Goal: lookup k1 (Avl_Node k d l r0 b0) d1 *) (* Goal: lookup k1 (Avl_Node k d l r0 b0) d1 *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k0)) (_ : lookup k1 (Avl_Node k d l r0 b0) data), lookup k1 (Avl_Node k0 d0 l0 r0 b0) data *) apply equal_refl. (* Goal: lookup k1 (Avl_Node k0 d0 l0 r0 b0) d1 *) (* Goal: lookup k1 (Avl_Node k0 d0 l0 r0 b0) d1 *) clear H0 H4 H3 H2 H1 H data b r l1 d2 k2. (* Goal: lookup k1 l0 d1 *) (* Goal: lookup k1 (Avl_Node k0 d0 l0 r0 b0) d1 *) elim (equal_dec k1 k). (* Goal: forall _ : Equal k1 k, lookup k1 l0 d1 *) (* Goal: forall _ : not (Equal k1 k), lookup k1 l0 d1 *) (* Goal: lookup k1 (Avl_Node k0 d0 l0 r0 b0) d1 *) intro equal_k1. (* Goal: lookup k1 r0 d1 *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k)) (_ : lookup k1 (Avl_Node k0 d0 l0 l b0) data), lookup k1 (Avl_Node k0 d0 l0 r0 b0) data *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k)) (_ : lookup k1 (Avl_Node k0 d0 l0 r0 b0) data), lookup k1 (Avl_Node k0 d0 l0 l b0) data *) rewrite (equal_eq k1 k equal_k1). (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) rewrite <- (lookup_avl_equal k1 k l0 d1 d); try assumption. (* Goal: lookup k0 (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d0 *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup_Equal. (* Goal: forall _ : not (Equal k1 k), lookup k1 (Avl_Node k d l r0 b0) d1 *) (* Goal: lookup k1 (Avl_Node k d l r0 b0) d1 *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k0)) (_ : lookup k1 (Avl_Node k d l r0 b0) data), lookup k1 (Avl_Node k0 d0 l0 r0 b0) data *) intros notequal0. (* Goal: lookup k1 (Avl_Node k0 d0 l0 r0 b0) d1 *) (* Goal: lookup k1 (Avl_Node k0 d0 l0 r0 b0) d1 *) apply Lookup_Left. (* Goal: lookup k1 l0 d1 *) (* Goal: lookup k1 (Avl_Node k0 d0 l0 r0 b0) d1 *) inversion_clear equiv_del_l. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply H0; assumption. (* Goal: lookup k1 (Avl_Node k0 d0 l0 r0 b0) d1 *) (* Goal: lookup k1 (Avl_Node k0 d0 l0 r0 b0) d1 *) clear H0 H4 H3 H2 H1 H data b r l1 d2 k2. (* Goal: lookup k1 (Avl_Node k0 d0 l0 l b0) d1 *) apply Lookup_Right. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k0)) (_ : lookup k1 (Avl_Node k d l r0 b0) data), lookup k1 (Avl_Node k0 d0 l0 r0 b0) data *) intros k1 d1 notequal lookup_k1. (* Goal: lookup k1 (Avl_Node k0 d0 l0 r0 b0) d1 *) inversion lookup_k1. (* Goal: lookup k (Avl_Node k0 d0 l0 r0 b0) d1 *) (* Goal: lookup k1 (Avl_Node k0 d0 l0 r0 b0) d1 *) (* Goal: lookup k1 (Avl_Node k0 d0 l0 r0 b0) d1 *) rewrite <- H5. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Left; assumption. (* Goal: lookup k1 (Avl_Node k0 d0 l0 r0 b0) d1 *) (* Goal: lookup k1 (Avl_Node k0 d0 l0 r0 b0) d1 *) clear H0 H4 H3 H2 H1 H data b r l1 d2 k2. (* Goal: lookup k1 (Avl_Node k0 d0 l0 r0 b0) d1 *) (* Goal: lookup k1 (Avl_Node k0 d0 l0 r0 b0) d1 *) apply Lookup_Left. (* Goal: lookup k1 l0 d1 *) (* Goal: lookup k1 (Avl_Node k0 d0 l0 r0 b0) d1 *) inversion_clear equiv_del_l. (* Goal: lookup k1 l0 d1 *) (* Goal: lookup k1 (Avl_Node k0 d0 l0 r0 b0) d1 *) elim (equal_dec k1 k). (* Goal: forall _ : Equal k1 k, lookup k1 l0 d1 *) (* Goal: forall _ : not (Equal k1 k), lookup k1 l0 d1 *) (* Goal: lookup k1 (Avl_Node k0 d0 l0 r0 b0) d1 *) intro equal_k1. (* Goal: lin_del_spec key d Avl_Nil Avl_Nil *) (* Goal: equiv_del key Avl_Nil Avl_Nil *) (* Goal: sumbool (@eq nat (height_avl Avl_Nil) (height_avl Avl_Nil)) (@eq nat (height_avl Avl_Nil) (S (height_avl Avl_Nil))) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, delete_spec key a) (a0 : avl_tree) (_ : forall _ : is_avl a0, delete_spec key a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), delete_spec key (Avl_Node i b a a0 b0) *) elimtype False. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply H with k1 d1; assumption. (* Goal: forall _ : not (Equal k1 k), lookup k1 l0 d1 *) (* Goal: lookup k1 (Avl_Node k0 d0 l0 r0 b0) d1 *) intro notequal_k1. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply H1; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Right; assumption. Qed. Lemma is_balanced_avl_is_balanced_avl_right_shift_left : forall (l l0 r0 : avl_tree) (b0 : bal), is_balanced_avl l0 r0 b0 -> S (height_avl l) = height_avl l0 -> is_balanced_avl_right_shift l r0 b0. (* Goal: forall (l l0 r0 : avl_tree) (b0 : bal) (_ : is_balanced_avl l0 r0 b0) (_ : @eq nat (S (height_avl l)) (height_avl l0)), is_balanced_avl_right_shift l r0 b0 *) intros l l0 r0 b0 Balanced_r0 height_l. (* Goal: is_balanced_avl_right_shift l r0 b0 *) inversion_clear Balanced_r0. (* Goal: is_balanced_avl_right_shift l r0 Left_Balanced *) (* Goal: is_balanced_avl_right_shift l r0 Balanced *) (* Goal: is_balanced_avl_right_shift l r0 Right_Balanced *) apply Is_Left_Balanced_Avl_Right_Shift. (* Goal: @eq nat (height_avl l) (height_avl r0) *) (* Goal: is_balanced_avl_right_shift l r0 Balanced *) (* Goal: is_balanced_avl_right_shift l r0 Right_Balanced *) rewrite H in height_l. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) injection height_l; trivial. (* Goal: is_balanced_avl_right_shift l r0 Balanced *) (* Goal: is_balanced_avl_right_shift l r0 Right_Balanced *) apply Is_Fully_Balanced_Avl_Right_Shift. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) rewrite <- H; assumption. (* Goal: is_balanced_avl_right_shift l r0 Right_Balanced *) apply Is_Right_Balanced_Avl_Right_Shift. (* Goal: @eq nat (S (S (height_avl l))) (height_avl r0) *) rewrite height_l. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. Qed. Lemma is_balanced_is_balanced_right_shift : forall (l l0 r0 : avl_tree) (b0 : bal), is_balanced_avl l0 r0 b0 -> height_avl l0 = S (height_avl l) -> is_balanced_avl_right_shift l r0 b0. (* Goal: forall (l l0 r0 : avl_tree) (b0 : bal) (_ : is_balanced_avl l0 r0 b0) (_ : @eq nat (height_avl l0) (S (height_avl l))), is_balanced_avl_right_shift l r0 b0 *) intros l l0 r0 b0 Balanced_l0 height_r. (* Goal: is_balanced_avl_right_shift l r0 b0 *) inversion_clear Balanced_l0. (* Goal: is_balanced_avl_right_shift l r0 Left_Balanced *) (* Goal: is_balanced_avl_right_shift l r0 Balanced *) (* Goal: is_balanced_avl_right_shift l r0 Right_Balanced *) apply Is_Left_Balanced_Avl_Right_Shift. (* Goal: @eq nat (height_avl l) (height_avl r0) *) (* Goal: is_balanced_avl_right_shift l r0 Balanced *) (* Goal: is_balanced_avl_right_shift l r0 Right_Balanced *) rewrite H in height_r. symmetry in |- *. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) injection height_r; trivial. (* Goal: is_balanced_avl_right_shift l r0 Balanced *) (* Goal: is_balanced_avl_right_shift l r0 Right_Balanced *) apply Is_Fully_Balanced_Avl_Right_Shift. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) rewrite <- height_r; assumption. (* Goal: is_balanced_avl_right_shift l r0 Right_Balanced *) apply Is_Right_Balanced_Avl_Right_Shift. (* Goal: @eq nat (S match bl0 with | Left_Balanced => S (height_avl ll0) | Balanced => S (height_avl ll0) | Right_Balanced => S (height_avl rl0) end) (S (height_avl r0)) *) (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced, @eq nat (S (height_avl r0)) (S (height_avl r0)) *) (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Balanced, @eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Balanced)) (height_avl t) *) (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced)) (height_avl t) *) (* Goal: forall _ : has_shrunk_right t k d l r0 b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) rewrite <- H. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite height_r; trivial. Qed. Lemma equiv_del_trans_left : forall (k k0 : Int) (d0 : B) (l0 r0 l : avl_tree) (b0 : bal), Less k k0 -> is_above r0 k0 -> equiv_del k l0 l -> equiv_del k (Avl_Node k0 d0 l0 r0 b0) (Avl_Node k0 d0 l r0 b0). (* Goal: forall (k k0 : Int) (d0 : B) (l0 r0 l : avl_tree) (b0 : bal) (_ : Less k k0) (_ : is_above r0 k0) (_ : equiv_del k l0 l), equiv_del k (Avl_Node k0 d0 l0 r0 b0) (Avl_Node k0 d0 l r0 b0) *) intros k k0 d0 l0 r0 l b0 less_k above_r0 equiv_del_l0. (* Goal: equiv_del k (Avl_Node k0 d0 l0 r0 b0) (Avl_Node k0 d0 l r0 b0) *) inversion_clear equiv_del_l0. (* Goal: equiv_del k (Avl_Node k0 d0 l0 l b0) (Avl_Node k0 d0 l0 r0 b0) *) apply equiv_del_intro. (* Goal: forall (k1 : Int) (_ : Equal k1 k) (d : B) (_ : lookup k1 (Avl_Node k0 d0 l0 r0 b0) d), False *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k)) (_ : lookup k1 (Avl_Node k0 d0 l0 l b0) data), lookup k1 (Avl_Node k0 d0 l0 r0 b0) data *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k)) (_ : lookup k1 (Avl_Node k0 d0 l0 r0 b0) data), lookup k1 (Avl_Node k0 d0 l0 l b0) data *) intros k1 equal_k1 d1 lookup1. (* Goal: False *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k)) (_ : lookup k1 (Avl_Node k0 d0 l0 l b0) data), lookup k1 (Avl_Node k0 d0 l0 r0 b0) data *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k)) (_ : lookup k1 (Avl_Node k0 d0 l0 r0 b0) data), lookup k1 (Avl_Node k0 d0 l0 l b0) data *) apply H with k1 d1. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: lookup k1 r0 d1 *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k)) (_ : lookup k1 (Avl_Node k0 d0 l0 l b0) data), lookup k1 (Avl_Node k0 d0 l0 r0 b0) data *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k)) (_ : lookup k1 (Avl_Node k0 d0 l0 r0 b0) data), lookup k1 (Avl_Node k0 d0 l0 l b0) data *) rewrite (equal_eq k1 k equal_k1). (* Goal: lookup k r0 d1 *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k)) (_ : lookup k1 (Avl_Node k0 d0 l0 l b0) data), lookup k1 (Avl_Node k0 d0 l0 r0 b0) data *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k)) (_ : lookup k1 (Avl_Node k0 d0 l0 r0 b0) data), lookup k1 (Avl_Node k0 d0 l0 l b0) data *) rewrite (equal_eq k1 k equal_k1) in lookup1; clear equal_k1 k1. (* Goal: lookup k r0 d1 *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k)) (_ : lookup k1 (Avl_Node k0 d0 l0 l b0) data), lookup k1 (Avl_Node k0 d0 l0 r0 b0) data *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k)) (_ : lookup k1 (Avl_Node k0 d0 l0 r0 b0) data), lookup k1 (Avl_Node k0 d0 l0 l b0) data *) inversion lookup1. (* Goal: lin_del_spec key d Avl_Nil Avl_Nil *) (* Goal: equiv_del key Avl_Nil Avl_Nil *) (* Goal: sumbool (@eq nat (height_avl Avl_Nil) (height_avl Avl_Nil)) (@eq nat (height_avl Avl_Nil) (S (height_avl Avl_Nil))) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, delete_spec key a) (a0 : avl_tree) (_ : forall _ : is_avl a0, delete_spec key a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), delete_spec key (Avl_Node i b a a0 b0) *) elimtype False. (* Goal: False *) (* Goal: lookup k r0 d1 *) (* Goal: lookup k r0 d1 *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k)) (_ : lookup k1 (Avl_Node k0 d0 l0 l b0) data), lookup k1 (Avl_Node k0 d0 l0 r0 b0) data *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k)) (_ : lookup k1 (Avl_Node k0 d0 l0 r0 b0) data), lookup k1 (Avl_Node k0 d0 l0 l b0) data *) apply less_irrefl with k0. (* Goal: Less k0 k0 *) (* Goal: lookup k l d1 *) (* Goal: lookup k l d1 *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k)) (_ : lookup k1 (Avl_Node k0 d0 l0 r0 b0) data), lookup k1 (Avl_Node k0 d0 l r0 b0) data *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k)) (_ : lookup k1 (Avl_Node k0 d0 l r0 b0) data), lookup k1 (Avl_Node k0 d0 l0 r0 b0) data *) rewrite H3 in less_k. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: lin_del_spec key d Avl_Nil Avl_Nil *) (* Goal: equiv_del key Avl_Nil Avl_Nil *) (* Goal: sumbool (@eq nat (height_avl Avl_Nil) (height_avl Avl_Nil)) (@eq nat (height_avl Avl_Nil) (S (height_avl Avl_Nil))) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, delete_spec key a) (a0 : avl_tree) (_ : forall _ : is_avl a0, delete_spec key a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), delete_spec key (Avl_Node i b a a0 b0) *) elimtype False. (* Goal: False *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k)) (_ : lookup k1 (Avl_Node k0 d0 l0 r0 b0) data), lookup k1 (Avl_Node k0 d0 l r0 b0) data *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k)) (_ : lookup k1 (Avl_Node k0 d0 l r0 b0) data), lookup k1 (Avl_Node k0 d0 l0 r0 b0) data *) apply lookup_above_false with k r0 d1. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: is_above r0 k *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k)) (_ : lookup k1 (Avl_Node k0 d0 l0 r0 b0) data), lookup k1 (Avl_Node k0 d0 l r0 b0) data *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k)) (_ : lookup k1 (Avl_Node k0 d0 l r0 b0) data), lookup k1 (Avl_Node k0 d0 l0 r0 b0) data *) apply above_trans with k0. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k)) (_ : lookup k1 (Avl_Node k0 d0 l0 r0 b0) data), lookup k1 (Avl_Node k0 d0 l0 l b0) data *) intros k1 d1 notequal lookup1. (* Goal: lookup k1 (Avl_Node k0 d0 l0 l b0) d1 *) inversion_clear lookup1. (* Goal: lookup k0 (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d0 *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup_Equal. (* Goal: lookup k1 (Avl_Node k0 d0 l0 r0 b0) d1 *) (* Goal: lookup k1 (Avl_Node k0 d0 l0 r0 b0) d1 *) apply Lookup_Left. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply H0; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Right; assumption. (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k)) (_ : lookup k1 (Avl_Node k0 d0 l0 r0 b0) data), lookup k1 (Avl_Node k0 d0 l0 l b0) data *) intros k1 d1 notequal lookup1. (* Goal: lookup k1 (Avl_Node k0 d0 l0 l b0) d1 *) inversion_clear lookup1. (* Goal: lookup k0 (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d0 *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup_Equal. (* Goal: lookup k1 (Avl_Node k0 d0 l0 r0 b0) d1 *) (* Goal: lookup k1 (Avl_Node k0 d0 l0 r0 b0) d1 *) apply Lookup_Left. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply H1; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Right; assumption. Qed. Lemma equiv_del_trans_right : forall (k k0 : Int) (d0 : B) (l0 r r0 : avl_tree) (b0 : bal), Less k0 k -> is_below l0 k0 -> equiv_del k r0 r -> equiv_del k (Avl_Node k0 d0 l0 r0 b0) (Avl_Node k0 d0 l0 r b0). (* Goal: forall (k k0 : Int) (d0 : B) (l0 r r0 : avl_tree) (b0 : bal) (_ : Less k0 k) (_ : is_below l0 k0) (_ : equiv_del k r0 r), equiv_del k (Avl_Node k0 d0 l0 r0 b0) (Avl_Node k0 d0 l0 r b0) *) intros k k0 d0 l0 r0 l b0 greater_k below_l0 equiv_del_r0. (* Goal: equiv_del k (Avl_Node k0 d0 l0 l b0) (Avl_Node k0 d0 l0 r0 b0) *) inversion_clear equiv_del_r0. (* Goal: equiv_del k (Avl_Node k0 d0 l0 l b0) (Avl_Node k0 d0 l0 r0 b0) *) apply equiv_del_intro. (* Goal: forall (k1 : Int) (_ : Equal k1 k) (d : B) (_ : lookup k1 (Avl_Node k0 d0 l0 r0 b0) d), False *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k)) (_ : lookup k1 (Avl_Node k0 d0 l0 l b0) data), lookup k1 (Avl_Node k0 d0 l0 r0 b0) data *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k)) (_ : lookup k1 (Avl_Node k0 d0 l0 r0 b0) data), lookup k1 (Avl_Node k0 d0 l0 l b0) data *) intros k1 equal_k1 d1 lookup1. (* Goal: False *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k)) (_ : lookup k1 (Avl_Node k0 d0 l0 l b0) data), lookup k1 (Avl_Node k0 d0 l0 r0 b0) data *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k)) (_ : lookup k1 (Avl_Node k0 d0 l0 r0 b0) data), lookup k1 (Avl_Node k0 d0 l0 l b0) data *) apply H with k1 d1. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: lookup k1 r0 d1 *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k)) (_ : lookup k1 (Avl_Node k0 d0 l0 l b0) data), lookup k1 (Avl_Node k0 d0 l0 r0 b0) data *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k)) (_ : lookup k1 (Avl_Node k0 d0 l0 r0 b0) data), lookup k1 (Avl_Node k0 d0 l0 l b0) data *) rewrite (equal_eq k1 k equal_k1). (* Goal: lookup k r0 d1 *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k)) (_ : lookup k1 (Avl_Node k0 d0 l0 l b0) data), lookup k1 (Avl_Node k0 d0 l0 r0 b0) data *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k)) (_ : lookup k1 (Avl_Node k0 d0 l0 r0 b0) data), lookup k1 (Avl_Node k0 d0 l0 l b0) data *) rewrite (equal_eq k1 k equal_k1) in lookup1; clear equal_k1 k1. (* Goal: lookup k r0 d1 *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k)) (_ : lookup k1 (Avl_Node k0 d0 l0 l b0) data), lookup k1 (Avl_Node k0 d0 l0 r0 b0) data *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k)) (_ : lookup k1 (Avl_Node k0 d0 l0 r0 b0) data), lookup k1 (Avl_Node k0 d0 l0 l b0) data *) inversion lookup1. (* Goal: lin_del_spec key d Avl_Nil Avl_Nil *) (* Goal: equiv_del key Avl_Nil Avl_Nil *) (* Goal: sumbool (@eq nat (height_avl Avl_Nil) (height_avl Avl_Nil)) (@eq nat (height_avl Avl_Nil) (S (height_avl Avl_Nil))) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, delete_spec key a) (a0 : avl_tree) (_ : forall _ : is_avl a0, delete_spec key a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), delete_spec key (Avl_Node i b a a0 b0) *) elimtype False. (* Goal: False *) (* Goal: lookup k r0 d1 *) (* Goal: lookup k r0 d1 *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k)) (_ : lookup k1 (Avl_Node k0 d0 l0 l b0) data), lookup k1 (Avl_Node k0 d0 l0 r0 b0) data *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k)) (_ : lookup k1 (Avl_Node k0 d0 l0 r0 b0) data), lookup k1 (Avl_Node k0 d0 l0 l b0) data *) apply less_irrefl with k0. (* Goal: Less k0 k0 *) (* Goal: lookup k r0 d1 *) (* Goal: lookup k r0 d1 *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k)) (_ : lookup k1 (Avl_Node k0 d0 l0 l b0) data), lookup k1 (Avl_Node k0 d0 l0 r0 b0) data *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k)) (_ : lookup k1 (Avl_Node k0 d0 l0 r0 b0) data), lookup k1 (Avl_Node k0 d0 l0 l b0) data *) rewrite H3 in greater_k. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: lin_del_spec key d Avl_Nil Avl_Nil *) (* Goal: equiv_del key Avl_Nil Avl_Nil *) (* Goal: sumbool (@eq nat (height_avl Avl_Nil) (height_avl Avl_Nil)) (@eq nat (height_avl Avl_Nil) (S (height_avl Avl_Nil))) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, delete_spec key a) (a0 : avl_tree) (_ : forall _ : is_avl a0, delete_spec key a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), delete_spec key (Avl_Node i b a a0 b0) *) elimtype False. (* Goal: False *) (* Goal: lookup k r0 d1 *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k)) (_ : lookup k1 (Avl_Node k0 d0 l0 l b0) data), lookup k1 (Avl_Node k0 d0 l0 r0 b0) data *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k)) (_ : lookup k1 (Avl_Node k0 d0 l0 r0 b0) data), lookup k1 (Avl_Node k0 d0 l0 l b0) data *) apply lookup_below_false with k l0 d1. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: is_below l0 k *) (* Goal: lookup k r0 d1 *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k)) (_ : lookup k1 (Avl_Node k0 d0 l0 l b0) data), lookup k1 (Avl_Node k0 d0 l0 r0 b0) data *) (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k)) (_ : lookup k1 (Avl_Node k0 d0 l0 r0 b0) data), lookup k1 (Avl_Node k0 d0 l0 l b0) data *) apply below_trans with k0. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k)) (_ : lookup k1 (Avl_Node k0 d0 l0 r0 b0) data), lookup k1 (Avl_Node k0 d0 l0 l b0) data *) intros k1 d1 notequal lookup1. (* Goal: lookup k1 (Avl_Node k0 d0 l0 l b0) d1 *) inversion_clear lookup1. (* Goal: lookup k0 (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d0 *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup_Equal. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Left; assumption. (* Goal: lookup k1 (Avl_Node k0 d0 l0 l b0) d1 *) apply Lookup_Right. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply H0; assumption. (* Goal: forall (k1 : Int) (data : B) (_ : not (Equal k1 k)) (_ : lookup k1 (Avl_Node k0 d0 l0 r0 b0) data), lookup k1 (Avl_Node k0 d0 l0 l b0) data *) intros k1 d1 notequal lookup1. (* Goal: lookup k1 (Avl_Node k0 d0 l0 l b0) d1 *) inversion_clear lookup1. (* Goal: lookup k0 (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d0 *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup_Equal. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Left; assumption. (* Goal: lookup k1 (Avl_Node k0 d0 l0 l b0) d1 *) apply Lookup_Right. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply H1; assumption. Qed. (*****************************************************************) Lemma delete_avl : forall (key : Int) (t0 : avl_tree), is_avl t0 -> delete_spec key t0. (* Goal: forall _ : is_avl t0, avl_ins_spec key update init t0 *) intros key t0; elim t0; clear t0. (* t0=nil *) (* Goal: forall _ : is_avl Avl_Nil, delete_spec key Avl_Nil *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, delete_spec key a) (a0 : avl_tree) (_ : forall _ : is_avl a0, delete_spec key a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), delete_spec key (Avl_Node i b a a0 b0) *) intros avl_t0. (* Goal: delete_spec key Avl_Nil *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, delete_spec key a) (a0 : avl_tree) (_ : forall _ : is_avl a0, delete_spec key a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), delete_spec key (Avl_Node i b a a0 b0) *) apply Delete_Spec_Intro with (t := Avl_Nil). (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) right. (* Goal: forall d : B, not (lookup key Avl_Nil d) *) (* Goal: is_avl Avl_Nil *) (* Goal: forall (d : B) (_ : lookup key Avl_Nil d), lin_del_spec key d Avl_Nil Avl_Nil *) (* Goal: equiv_del key Avl_Nil Avl_Nil *) (* Goal: sumbool (@eq nat (height_avl Avl_Nil) (height_avl Avl_Nil)) (@eq nat (height_avl Avl_Nil) (S (height_avl Avl_Nil))) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, delete_spec key a) (a0 : avl_tree) (_ : forall _ : is_avl a0, delete_spec key a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), delete_spec key (Avl_Node i b a a0 b0) *) unfold not in |- *; intros d lookup_t0. (* Goal: False *) (* Goal: equiv_del key Avl_Nil Avl_Nil *) (* Goal: sumbool (@eq nat (height_avl Avl_Nil) (height_avl Avl_Nil)) (@eq nat (height_avl Avl_Nil) (S (height_avl Avl_Nil))) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, delete_spec key a) (a0 : avl_tree) (_ : forall _ : is_avl a0, delete_spec key a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), delete_spec key (Avl_Node i b a a0 b0) *) inversion_clear lookup_t0. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: forall (d : B) (_ : lookup key Avl_Nil d), lin_del_spec key d Avl_Nil Avl_Nil *) (* Goal: equiv_del key Avl_Nil Avl_Nil *) (* Goal: sumbool (@eq nat (height_avl Avl_Nil) (height_avl Avl_Nil)) (@eq nat (height_avl Avl_Nil) (S (height_avl Avl_Nil))) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, delete_spec key a) (a0 : avl_tree) (_ : forall _ : is_avl a0, delete_spec key a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), delete_spec key (Avl_Node i b a a0 b0) *) intros d lookup_t0. (* Goal: lin_del_spec key d Avl_Nil Avl_Nil *) (* Goal: equiv_del key Avl_Nil Avl_Nil *) (* Goal: sumbool (@eq nat (height_avl Avl_Nil) (height_avl Avl_Nil)) (@eq nat (height_avl Avl_Nil) (S (height_avl Avl_Nil))) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, delete_spec key a) (a0 : avl_tree) (_ : forall _ : is_avl a0, delete_spec key a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), delete_spec key (Avl_Node i b a a0 b0) *) elimtype False. (* Goal: False *) (* Goal: equiv_del key Avl_Nil Avl_Nil *) (* Goal: sumbool (@eq nat (height_avl Avl_Nil) (height_avl Avl_Nil)) (@eq nat (height_avl Avl_Nil) (S (height_avl Avl_Nil))) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, delete_spec key a) (a0 : avl_tree) (_ : forall _ : is_avl a0, delete_spec key a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), delete_spec key (Avl_Node i b a a0 b0) *) inversion_clear lookup_t0. (* Goal: equiv_del key Avl_Nil Avl_Nil *) (* Goal: sumbool (@eq nat (height_avl Avl_Nil) (height_avl Avl_Nil)) (@eq nat (height_avl Avl_Nil) (S (height_avl Avl_Nil))) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, delete_spec key a) (a0 : avl_tree) (_ : forall _ : is_avl a0, delete_spec key a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), delete_spec key (Avl_Node i b a a0 b0) *) apply equiv_del_nil. (* Goal: forall _ : is_balanced_avl l0 r0 Left_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Left_Balanced)) (S (height_avl l0)) *) (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) left; simpl in |- *; trivial. (* t0=(Avl_Node k0 d0 l0 r0 b0) *) (* Goal: forall (i : Int) (b : B) (a : avl_tree) (_ : forall _ : is_avl a, delete_spec key a) (a0 : avl_tree) (_ : forall _ : is_avl a0, delete_spec key a0) (b0 : bal) (_ : is_avl (Avl_Node i b a a0 b0)), delete_spec key (Avl_Node i b a a0 b0) *) intros k0 d0 l0 ih_l0 r0 ih_r0 b0 avl_t0. (* Goal: delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) elim (equal_dec key k0). (* (Equal key=k0) *) (* Goal: forall _ : Equal key k0, delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) intros equal. (* Goal: delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) clear ih_l0 ih_r0. (* Goal: delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) generalize avl_t0; clear avl_t0. (* Goal: forall _ : is_avl (Avl_Node k0 d0 l0 r0 b0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) case l0; clear l0. (* l0=nil *) (* Goal: forall _ : is_avl (Avl_Node k0 d0 Avl_Nil r0 b0), delete_spec key (Avl_Node k0 d0 Avl_Nil r0 b0) *) (* Goal: forall (i : Int) (b : B) (a a0 : avl_tree) (b1 : bal) (_ : is_avl (Avl_Node k0 d0 (Avl_Node i b a a0 b1) r0 b0)), delete_spec key (Avl_Node k0 d0 (Avl_Node i b a a0 b1) r0 b0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) intro avl_t0. (* Goal: delete_spec key (Avl_Node k0 d0 Avl_Nil r0 b0) *) (* Goal: forall (i : Int) (b : B) (a a0 : avl_tree) (b1 : bal) (_ : is_avl (Avl_Node k0 d0 (Avl_Node i b a a0 b1) r0 b0)), delete_spec key (Avl_Node k0 d0 (Avl_Node i b a a0 b1) r0 b0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Delete_Spec_Intro with (t := r0). (* Goal: lookup_dec_spec key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) *) (* Goal: is_avl t *) (* Goal: forall (d : B) (_ : lookup key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d), lin_del_spec key d (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) left with d0. (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (@cons (prod Int B) (@pair Int B key d1) (lin_avl r0))) *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) rewrite (equal_eq key k0 equal). (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *. (* Goal: lookup k0 (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d0 *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup_Equal. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear avl_t0; assumption. (* Goal: forall (d : B) (_ : lookup key (Avl_Node k0 d0 l0 r0 b0) d), lin_del_spec key d (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: equiv_del key (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) intros d lookup0. (* Goal: lin_del_spec key d (Avl_Node k0 d0 Avl_Nil r0 b0) r0 *) (* Goal: equiv_del key (Avl_Node k0 d0 Avl_Nil r0 b0) r0 *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 Avl_Nil r0 b0)) (height_avl r0)) (@eq nat (height_avl (Avl_Node k0 d0 Avl_Nil r0 b0)) (S (height_avl r0))) *) (* Goal: forall (i : Int) (b : B) (a a0 : avl_tree) (b1 : bal) (_ : is_avl (Avl_Node k0 d0 (Avl_Node i b a a0 b1) r0 b0)), delete_spec key (Avl_Node k0 d0 (Avl_Node i b a a0 b1) r0 b0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Lin_Del_Spec_Intro with (nil (A:=Int * B)) (lin_avl r0). (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite (equal_eq key k0 equal); trivial. rewrite (lookup_avl_equal key k0 (Avl_Node k0 d0 Avl_Nil r0 b0) d d0); (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) try assumption. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. (* Goal: lookup k0 (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d0 *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup_Equal. (* Goal: forall _ : is_balanced_avl l0 r0 Left_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Left_Balanced)) (S (height_avl l0)) *) (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *; trivial. (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (@cons (prod Int B) (@pair Int B key d1) (lin_avl r0))) *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) rewrite (equal_eq key k0 equal). (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply equiv_del_right_semi_leave; assumption. (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) right. (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) inversion_clear avl_t0. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) inversion_clear H1; simpl in |- *. (* Goal: @eq nat (S O) (S (height_avl r0)) *) (* Goal: @eq nat (S O) (S (height_avl r0)) *) (* Goal: @eq nat (S (height_avl r0)) (S (height_avl r0)) *) (* Goal: forall (i : Int) (b : B) (a a0 : avl_tree) (b1 : bal) (_ : is_avl (Avl_Node k0 d0 (Avl_Node i b a a0 b1) r0 b0)), delete_spec key (Avl_Node k0 d0 (Avl_Node i b a a0 b1) r0 b0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) discriminate H4. (* Goal: @eq nat (S O) (S (height_avl r0)) *) (* Goal: @eq nat (S (height_avl r0)) (S (height_avl r0)) *) (* Goal: forall (i : Int) (b : B) (a a0 : avl_tree) (b1 : bal) (_ : is_avl (Avl_Node k0 d0 (Avl_Node i b a a0 b1) r0 b0)), delete_spec key (Avl_Node k0 d0 (Avl_Node i b a a0 b1) r0 b0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) rewrite <- H4. (* Goal: forall _ : is_balanced_avl l0 r0 Left_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Left_Balanced)) (S (height_avl l0)) *) (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *; trivial. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. (* l0=(node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall (i : Int) (b : B) (a a0 : avl_tree) (b1 : bal) (_ : is_avl (Avl_Node k0 d0 (Avl_Node i b a a0 b1) r0 b0)), delete_spec key (Avl_Node k0 d0 (Avl_Node i b a a0 b1) r0 b0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) intros kl0 dl0 ll0 rl0 bl0 avl_t0. (* Goal: delete_spec key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) elim (delete_max kl0 dl0 ll0 rl0 bl0). (* Goal: forall (k : Int) (d : B) (t : avl_tree) (_ : lookup k (Avl_Node kl0 dl0 ll0 rl0 bl0) d) (_ : is_avl t) (_ : is_below_avl t k) (_ : @eq (list (prod Int B)) (lin_avl (Avl_Node kl0 dl0 ll0 rl0 bl0)) (@app (prod Int B) (lin_avl t) (@cons (prod Int B) (@pair Int B k d) (@nil (prod Int B))))) (_ : equiv_del k (Avl_Node kl0 dl0 ll0 rl0 bl0) t) (_ : sumbool (@eq nat (height_avl (Avl_Node kl0 dl0 ll0 rl0 bl0)) (height_avl t)) (@eq nat (height_avl (Avl_Node kl0 dl0 ll0 rl0 bl0)) (S (height_avl t)))), delete_spec key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) intros k d l lookup_l0 avl_l below_l lin_l0 equiv_del_l0 bal_or_shift. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) elim (balance_shrunk_right k d l r0 b0); try assumption. (* Goal: forall (t : avl_tree) (_ : is_avl t) (_ : @eq (list (prod Int B)) (lin_avl t) (lin_avl (Avl_Node k d l r0 b0))) (_ : equiv t (Avl_Node k d l r0 b0)) (_ : sumbool (hasnot_shrunk_right t k d l r0 b0) (has_shrunk_right t k d l r0 b0)), delete_spec key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) intros t avl_t lin_t0 equiv_t0 shrunk_dec. (* Goal: delete_spec key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Delete_Spec_Intro with (t := t). (* Goal: lookup_dec_spec key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) *) (* Goal: is_avl t *) (* Goal: forall (d : B) (_ : lookup key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d), lin_del_spec key d (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) left with d0. (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (@cons (prod Int B) (@pair Int B key d1) (lin_avl r0))) *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) rewrite (equal_eq key k0 equal). (* Goal: lookup k0 (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d0 *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) simpl in |- *; apply Lookup_Equal. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: forall (d : B) (_ : lookup key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d), lin_del_spec key d (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) intros d1 lookup0. apply Lin_Del_Spec_Intro with (lin_avl ll0 ++ (kl0, dl0) :: lin_avl rl0) (lin_avl r0). (* Goal: @eq (list (prod Int B)) (lin_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (@cons (prod Int B) (@pair Int B key d1) (lin_avl r0))) *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) rewrite (equal_eq key k0 equal). rewrite (lookup_avl_equal key k0 (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d1 d0) (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) ; try assumption. (* Goal: forall _ : is_balanced_avl l0 r0 Left_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Left_Balanced)) (S (height_avl l0)) *) (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *; trivial. (* Goal: lookup k0 (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) d0 *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Lookup_Equal. (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl ll0) (@cons (prod Int B) (@pair Int B kl0 dl0) (lin_avl rl0))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) generalize lin_l0; clear lin_l0; simpl in |- *; intro lin_l0. (* Goal: @eq (list (prod Int B)) (@app (prod Int B) (lin_avl l0) (@cons (prod Int B) (@pair Int B k0 d0) (lin_avl r0))) (@app (prod Int B) l1 (@cons (prod Int B) (@pair Int B key d) (@app (prod Int B) l2 (@cons (prod Int B) (@pair Int B k0 d0) (lin_avl r0))))) *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) l1 (@app (prod Int B) l2 (@cons (prod Int B) (@pair Int B k0 d0) (lin_avl r0)))) *) (* Goal: lookup key l0 d *) (* Goal: equiv_del key (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_below_avl l k0 *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k0 *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: forall _ : not (Less key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) rewrite lin_l0. (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl l) (@cons (prod Int B) (@pair Int B k d) (@nil (prod Int B)))) (lin_avl r0)) *) (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) rewrite (app_ass (lin_avl l) ((k, d) :: nil) (lin_avl r0)). (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. (* Goal: equiv_del key (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply equiv_del_equiv_equiv_del with (t1 := Avl_Node k d l r0 b0). (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply equiv_del_equal; try assumption. (* Goal: is_below (Avl_Node kl0 dl0 ll0 rl0 bl0) k0 *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply is_below_avl_is_below. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear avl_t0; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear avl_t0; assumption. (* Goal: is_above r0 k0 *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: equiv (Avl_Node k d l r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply is_above_avl_is_above. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear avl_t0; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear avl_t0; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear avl_t0; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply equiv_sym; assumption. (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) clear lin_t0 equiv_t0 avl_t bal_or_shift equiv_del_l0 below_l avl_l lookup_l0. (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) elim shrunk_dec; clear shrunk_dec. (* Goal: forall _ : hasnot_shrunk_right t k d l r0 b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: forall _ : has_shrunk_right t k d l r0 b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) intros hasnot_shrunk. (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) left. (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) inversion_clear avl_t0. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t) *) (* Goal: forall _ : has_shrunk_right t k d l r0 b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) generalize H1; clear H1 H3 H2 H0 H. (* Goal: forall _ : is_balanced_avl l0 r0 b0, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) inversion_clear hasnot_shrunk. (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H0; clear H0. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) inversion_clear H; simpl in |- *. (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H0; clear H0. (* Goal: is_balanced_avl_right_shift l r0 b0 *) intros Balanced_l0; inversion_clear Balanced_l0. (* Goal: @eq nat (S match bl0 with | Left_Balanced => S (height_avl ll0) | Balanced => S (height_avl ll0) | Right_Balanced => S (height_avl rl0) end) (S (height_avl r0)) *) (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced, @eq nat (S (height_avl r0)) (S (height_avl r0)) *) (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Balanced, @eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Balanced)) (height_avl t) *) (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced)) (height_avl t) *) (* Goal: forall _ : has_shrunk_right t k d l r0 b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) rewrite <- H. (* Goal: forall _ : is_balanced_avl l0 r0 Left_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Left_Balanced)) (S (height_avl l0)) *) (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *; trivial. (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Balanced, @eq nat (S match bl0 with | Left_Balanced => S (height_avl ll0) | Balanced => S (height_avl ll0) | Right_Balanced => S (height_avl rl0) end) (S (height_avl l)) *) (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced, @eq nat (S (height_avl r0)) (S (height_avl r0)) *) (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Balanced, @eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Balanced)) (height_avl t) *) (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced)) (height_avl t) *) (* Goal: forall _ : has_shrunk_right t k d l r0 b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) rewrite H0. (* Goal: is_balanced_avl_right_shift l r0 b0 *) intros Balanced_l0; inversion_clear Balanced_l0. (* Goal: @eq nat (S match bl0 with | Left_Balanced => S (height_avl ll0) | Balanced => S (height_avl ll0) | Right_Balanced => S (height_avl rl0) end) (S (height_avl r0)) *) (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced, @eq nat (S (height_avl r0)) (S (height_avl r0)) *) (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Balanced, @eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Balanced)) (height_avl t) *) (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced)) (height_avl t) *) (* Goal: forall _ : has_shrunk_right t k d l r0 b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 b0)) (S (height_avl t))) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) rewrite <- H. (* Goal: forall _ : is_balanced_avl l0 r0 Left_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Left_Balanced)) (S (height_avl l0)) *) (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *; trivial. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H0; clear H0. (* Goal: is_balanced_avl_right_shift l r0 b0 *) intros Balanced_l0; inversion_clear Balanced_l0. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Left_Balanced)) (S (S (height_avl r0))) *) (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) rewrite <- H0. (* Goal: forall _ : is_balanced_avl l0 r0 Left_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Left_Balanced)) (S (height_avl l0)) *) (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *; trivial. (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H0; clear H0. (* Goal: forall _ : is_balanced_avl l0 r0 Left_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Left_Balanced)) (S (height_avl l0)) *) (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *; trivial. (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) intros has_shrunk. (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) right. (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) inversion_clear avl_t0. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) generalize H1; clear H H0 H1 H2 H3. (* Goal: forall _ : is_balanced_avl l0 r0 b0, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) inversion_clear has_shrunk. (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H0; clear H0. (* Goal: is_balanced_avl_right_shift l r0 b0 *) intros Balanced_l0; inversion_clear Balanced_l0. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Left_Balanced)) (S (S (height_avl r0))) *) (* Goal: forall _ : is_balanced_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 (Avl_Node kl0 dl0 ll0 rl0 bl0) r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) rewrite <- H0. (* Goal: forall _ : is_balanced_avl l0 r0 Left_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Left_Balanced)) (S (height_avl l0)) *) (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *; trivial. (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H0; clear H0. (* Goal: forall _ : is_balanced_avl l0 r0 Left_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Left_Balanced)) (S (height_avl l0)) *) (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *; trivial. (* side premisses (Elim balance_shrunk_right ...) *) (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear avl_t0; assumption. (* Goal: is_above_avl r0 k *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply above_avl_trans with k0. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear avl_t0; assumption. (* Goal: Less k k0 *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply lookup_below_less with (Avl_Node kl0 dl0 ll0 rl0 bl0) d. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: is_below (Avl_Node kl0 dl0 ll0 rl0 bl0) k0 *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: is_avl (Avl_Node kl0 dl0 ll0 rl0 bl0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply is_below_avl_is_below. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear avl_t0; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear avl_t0; assumption. (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) elim bal_or_shift; clear bal_or_shift; intros height_l0. (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) left. apply hasnot_grown_left__preserves_is_balanced_avl with (Avl_Node kl0 dl0 ll0 rl0 bl0). (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear avl_t0; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) symmetry in |- *; assumption. (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) right. apply is_balanced_avl_is_balanced_avl_right_shift_left with (Avl_Node kl0 dl0 ll0 rl0 bl0). (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear avl_t0; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) symmetry in |- *; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear avl_t0; assumption. (* ~(Equal key k0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) intro notequal. (* Goal: delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) elim (less_dec key k0). (* (Less key k0) *) (* Goal: forall _ : Less key k0, delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: forall _ : not (Less key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) intro less. (* Goal: delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: forall _ : not (Equal key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) elim (ih_l0 (inv_is_avl_left k0 d0 l0 r0 b0 avl_t0)); clear ih_l0 ih_r0. (* Goal: forall (t : avl_tree) (_ : lookup_dec_spec key l0) (_ : is_avl t) (_ : forall (d : B) (_ : lookup key l0 d), lin_del_spec key d l0 t) (_ : equiv_del key l0 t) (_ : sumbool (@eq nat (height_avl l0) (height_avl t)) (@eq nat (height_avl l0) (S (height_avl t)))), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: forall _ : not (Less key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) intros l lookup_l0 avl_l lin_l0 equiv_del_l0 bal_or_shift. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) elim (balance_shrunk_right k0 d0 l r0 b0); try assumption. (* Goal: forall (t : avl_tree) (_ : is_avl t) (_ : @eq (list (prod Int B)) (lin_avl t) (lin_avl (Avl_Node k0 d0 l0 r b0))) (_ : equiv t (Avl_Node k0 d0 l0 r b0)) (_ : sumbool (hasnot_shrunk_left t k0 d0 l0 r b0) (has_shrunk_left t k0 d0 l0 r b0)), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) intros t avl_t lin_t equiv_t shrunk_dec. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Delete_Spec_Intro with t; try assumption. (* Goal: lookup_dec_spec key (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: forall (d : B) (_ : lookup key (Avl_Node k0 d0 l0 r0 b0) d), lin_del_spec key d (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: equiv_del key (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_below_avl l k0 *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k0 *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: forall _ : not (Less key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) elim lookup_l0; clear lookup_l0. (* Goal: forall (d : B) (_ : lookup key r0 d), lookup_dec_spec key (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: forall _ : forall d : B, not (lookup key r0 d), lookup_dec_spec key (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: forall (d : B) (_ : lookup key (Avl_Node k0 d0 l0 r0 b0) d), lin_del_spec key d (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: equiv_del key (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) intros d lookup_d. (* Goal: lookup_dec_spec key (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: forall _ : forall d : B, not (lookup key r0 d), lookup_dec_spec key (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: forall (d : B) (_ : lookup key (Avl_Node k0 d0 l0 r0 b0) d), lin_del_spec key d (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: equiv_del key (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) left with d. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Left; assumption. (* Goal: forall _ : forall d : B, not (lookup key l0 d), lookup_dec_spec key (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: forall (d : B) (_ : lookup key (Avl_Node k0 d0 l0 r0 b0) d), lin_del_spec key d (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: equiv_del key (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_below_avl l k0 *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k0 *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: forall _ : not (Less key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) intro not_lookup_l0. (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) right. (* Goal: forall d : B, not (lookup key (Avl_Node k0 d0 l0 r0 b0) d) *) (* Goal: forall (d : B) (_ : lookup key (Avl_Node k0 d0 l0 r0 b0) d), lin_del_spec key d (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: equiv_del key (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) unfold not in |- *; intros d lookup_t. (* Goal: False *) (* Goal: forall (d : B) (_ : lookup key (Avl_Node k0 d0 l0 r0 b0) d), lin_del_spec key d (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: equiv_del key (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_below_avl l k0 *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k0 *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: forall _ : not (Less key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply (not_lookup_l0 d). (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply (lookup_avl_inv_less key k0 d0 l0 r0 b0 d); assumption. (* Goal: forall (d : B) (_ : lookup key (Avl_Node k0 d0 l0 r0 b0) d), lin_del_spec key d (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: equiv_del key (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_below_avl l k0 *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k0 *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: forall _ : not (Less key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) clear shrunk_dec equiv_t avl_t bal_or_shift equiv_del_l0 lookup_l0. (* Goal: forall (d : B) (_ : lookup key (Avl_Node k0 d0 l0 r0 b0) d), lin_del_spec key d (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: equiv_del key (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) intros d lookup0. (* Goal: lin_del_spec key d (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: equiv_del key (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_below_avl l k0 *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k0 *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: forall _ : not (Less key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) elim lin_l0 with d; clear lin_l0. (* Goal: forall (l1 l2 : list (prod Int B)) (_ : @eq (list (prod Int B)) (lin_avl l0) (@app (prod Int B) l1 (@cons (prod Int B) (@pair Int B key d) l2))) (_ : @eq (list (prod Int B)) (lin_avl l) (@app (prod Int B) l1 l2)), lin_del_spec key d (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: lookup key l0 d *) (* Goal: equiv_del key (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_below_avl l k0 *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k0 *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: forall _ : not (Less key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) intros l1 l2 lin_l0 lin_l. (* Goal: lin_del_spec key d (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: lookup key l0 d *) (* Goal: equiv_del key (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_below_avl l k0 *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k0 *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: forall _ : not (Less key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply Lin_Del_Spec_Intro with l1 (l2 ++ (k0, d0) :: lin_avl r0). (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *. (* Goal: @eq (list (prod Int B)) (@app (prod Int B) (lin_avl l0) (@cons (prod Int B) (@pair Int B k0 d0) (lin_avl r0))) (@app (prod Int B) l1 (@cons (prod Int B) (@pair Int B key d) (@app (prod Int B) l2 (@cons (prod Int B) (@pair Int B k0 d0) (lin_avl r0))))) *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) l1 (@app (prod Int B) l2 (@cons (prod Int B) (@pair Int B k0 d0) (lin_avl r0)))) *) (* Goal: lookup key l0 d *) (* Goal: equiv_del key (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_below_avl l k0 *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k0 *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: forall _ : not (Less key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) rewrite lin_l0. (* Goal: @eq (list (prod Int B)) (@app (prod Int B) (@app (prod Int B) l1 (@cons (prod Int B) (@pair Int B key d) l2)) (@cons (prod Int B) (@pair Int B k0 d0) (lin_avl r0))) (@app (prod Int B) l1 (@cons (prod Int B) (@pair Int B key d) (@app (prod Int B) l2 (@cons (prod Int B) (@pair Int B k0 d0) (lin_avl r0))))) *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) l1 (@app (prod Int B) l2 (@cons (prod Int B) (@pair Int B k0 d0) (lin_avl r0)))) *) (* Goal: lookup key l0 d *) (* Goal: equiv_del key (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_below_avl l k0 *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k0 *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: forall _ : not (Less key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) rewrite (app_ass l1 ((key, d) :: l2) ((k0, d0) :: lin_avl r0)). (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl l0) (@cons (prod Int B) (@pair Int B k0 d0) l1)) l2) *) (* Goal: lookup key r0 d *) (* Goal: equiv_del key (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite lin_t. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *. (* Goal: @eq (list (prod Int B)) (@app (prod Int B) (lin_avl l) (@cons (prod Int B) (@pair Int B k0 d0) (lin_avl r0))) (@app (prod Int B) l1 (@app (prod Int B) l2 (@cons (prod Int B) (@pair Int B k0 d0) (lin_avl r0)))) *) (* Goal: lookup key l0 d *) (* Goal: equiv_del key (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_below_avl l k0 *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k0 *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: forall _ : not (Less key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) rewrite lin_l. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite (app_ass l1 l2 ((k0, d0) :: lin_avl r0)); trivial. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply (lookup_avl_inv_less key k0 d0 l0 r0 b0 d); assumption. (* Goal: equiv_del key (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_below_avl l k0 *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k0 *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: forall _ : not (Less key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) clear shrunk_dec lin_t bal_or_shift lin_l0. apply equiv_del_equiv_equiv_del with (t1 := Avl_Node k0 d0 l r0 b0); (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) try assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply equiv_del_trans_left; try assumption. (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) inversion_clear avl_t0. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply is_above_avl_is_above; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply equiv_sym; assumption. (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_below_avl l k0 *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k0 *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: forall _ : not (Less key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) clear lin_t equiv_t avl_t bal_or_shift equiv_del_l0 lookup_l0. (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) elim shrunk_dec; clear shrunk_dec. (* Goal: forall _ : hasnot_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) intro hasnot_shrunk. (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) left. (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) inversion_clear avl_t0. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) generalize H1; clear H H0 H1 H2 H3. (* Goal: forall _ : is_balanced_avl l0 r0 b0, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) inversion_clear hasnot_shrunk. (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H0; clear H0. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) inversion_clear H; simpl in |- *. (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H0; clear H0. (* Goal: is_balanced_avl_right_shift l r0 b0 *) intros Balanced_l0; inversion_clear Balanced_l0. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H; trivial. (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H0; clear H0. (* Goal: is_balanced_avl_right_shift l r0 b0 *) intros Balanced_l0; inversion_clear Balanced_l0. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H; trivial. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H0; clear H0. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) intros Balanced_l0; inversion_clear Balanced_l0; simpl in |- *. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H0; trivial. (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H0; clear H0. (* Goal: forall _ : is_balanced_avl l0 r0 Left_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Left_Balanced)) (S (height_avl l0)) *) (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *; trivial. (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) intros has_shrunk. (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) right. (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) inversion_clear avl_t0. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) generalize H1; clear H H0 H1 H2 H3. (* Goal: forall _ : is_balanced_avl l0 r0 b0, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) inversion_clear has_shrunk. (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H0; clear H0. (* Goal: is_balanced_avl_right_shift l r0 b0 *) intros Balanced_l0; inversion_clear Balanced_l0. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H0; trivial. (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H0; clear H0. (* Goal: forall _ : is_balanced_avl l0 r0 Left_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Left_Balanced)) (S (height_avl l0)) *) (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *; trivial. (* side premisses (Elim (balance_shrunk_right ...) ) *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) inversion_clear avl_t0. (* Goal: is_below_avl l k0 *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k0 *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: forall _ : not (Less key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply below_below_avl. (* Goal: is_below l k0 *) (* Goal: is_avl r0 *) (* Goal: is_above_avl r0 k0 *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: forall _ : not (Less key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply below_equiv_del_below with l0 key. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply is_below_avl_is_below; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear avl_t0; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear avl_t0; assumption. (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) elim bal_or_shift; clear bal_or_shift; intros height_l0. (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) left. (* Goal: is_balanced_avl l r0 b0 *) (* Goal: sumbool (is_balanced_avl l r0 b0) (is_balanced_avl_right_shift l r0 b0) *) (* Goal: forall _ : not (Less key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply hasnot_grown_left__preserves_is_balanced_avl with l0. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear avl_t0; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) symmetry in |- *; assumption. (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) right. (* Goal: is_balanced_avl_right_shift l r0 b0 *) (* Goal: forall _ : not (Less key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) apply is_balanced_is_balanced_right_shift with l0. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear avl_t0; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* (Less k0 key) *) (* Goal: forall _ : not (Less key k0), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) intro notless. (* Goal: delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) generalize (notequal_notless_greater key k0 notequal notless); intro greater. (* Goal: delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) elim ih_r0; clear ih_r0 ih_l0 notless. (* Goal: forall (t : avl_tree) (_ : lookup_dec_spec key r0) (_ : is_avl t) (_ : forall (d : B) (_ : lookup key r0 d), lin_del_spec key d r0 t) (_ : equiv_del key r0 t) (_ : sumbool (@eq nat (height_avl r0) (height_avl t)) (@eq nat (height_avl r0) (S (height_avl t)))), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: is_avl r0 *) intros r lookup_r0 avl_r lin_r0 equiv_r0 bal_or_shift. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) elim (balance_shrunk_left k0 d0 l0 r b0); try assumption. (* Goal: forall (t : avl_tree) (_ : is_avl t) (_ : @eq (list (prod Int B)) (lin_avl t) (lin_avl (Avl_Node k0 d0 l0 r b0))) (_ : equiv t (Avl_Node k0 d0 l0 r b0)) (_ : sumbool (hasnot_shrunk_left t k0 d0 l0 r b0) (has_shrunk_left t k0 d0 l0 r b0)), delete_spec key (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) intros t avl_t lin_t equiv_t shrunk_dec. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Delete_Spec_Intro with t; try assumption. (* Goal: lookup_dec_spec key (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: forall (d : B) (_ : lookup key (Avl_Node k0 d0 l0 r0 b0) d), lin_del_spec key d (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: equiv_del key (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) elim lookup_r0; clear lookup_r0. (* Goal: forall (d : B) (_ : lookup key r0 d), lookup_dec_spec key (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: forall _ : forall d : B, not (lookup key r0 d), lookup_dec_spec key (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: forall (d : B) (_ : lookup key (Avl_Node k0 d0 l0 r0 b0) d), lin_del_spec key d (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: equiv_del key (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) intros d lookup_d. (* Goal: lookup_dec_spec key (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: forall _ : forall d : B, not (lookup key r0 d), lookup_dec_spec key (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: forall (d : B) (_ : lookup key (Avl_Node k0 d0 l0 r0 b0) d), lin_del_spec key d (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: equiv_del key (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) left with d. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply Lookup_Right; assumption. (* Goal: forall _ : forall d : B, not (lookup key r0 d), lookup_dec_spec key (Avl_Node k0 d0 l0 r0 b0) *) (* Goal: forall (d : B) (_ : lookup key (Avl_Node k0 d0 l0 r0 b0) d), lin_del_spec key d (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: equiv_del key (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) intro not_lookup_r0. (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) right. (* Goal: forall d : B, not (lookup key (Avl_Node k0 d0 l0 r0 b0) d) *) (* Goal: forall (d : B) (_ : lookup key (Avl_Node k0 d0 l0 r0 b0) d), lin_del_spec key d (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: equiv_del key (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) unfold not in |- *; intros d lookup_t. (* Goal: False *) (* Goal: forall (d : B) (_ : lookup key (Avl_Node k0 d0 l0 r0 b0) d), lin_del_spec key d (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: equiv_del key (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) apply (not_lookup_r0 d). (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply (lookup_avl_inv_greater key k0 d0 l0 r0 b0 d); assumption. (* Goal: forall (d : B) (_ : lookup key (Avl_Node k0 d0 l0 r0 b0) d), lin_del_spec key d (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: equiv_del key (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) intros d lookup0. (* Goal: lin_del_spec key d (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: equiv_del key (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) elim lin_r0 with d; clear lin_r0. (* Goal: forall (l1 l2 : list (prod Int B)) (_ : @eq (list (prod Int B)) (lin_avl r0) (@app (prod Int B) l1 (@cons (prod Int B) (@pair Int B key d) l2))) (_ : @eq (list (prod Int B)) (lin_avl r) (@app (prod Int B) l1 l2)), lin_del_spec key d (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: lookup key r0 d *) (* Goal: equiv_del key (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) intros l1 l2 lin_r0 lin_r. apply Lin_Del_Spec_Intro with (lin_avl l0 ++ (k0, d0) :: l1) l2; (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *. (* Goal: @eq (list (prod Int B)) (@app (prod Int B) (lin_avl l0) (@cons (prod Int B) (@pair Int B k0 d0) (lin_avl r0))) (@app (prod Int B) (@app (prod Int B) (lin_avl l0) (@cons (prod Int B) (@pair Int B k0 d0) l1)) (@cons (prod Int B) (@pair Int B key d) l2)) *) (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl l0) (@cons (prod Int B) (@pair Int B k0 d0) l1)) l2) *) (* Goal: lookup key r0 d *) (* Goal: equiv_del key (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite (app_ass (lin_avl l0) ((k0, d0) :: l1) ((key, d) :: l2)). (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite lin_r0; trivial. (* Goal: @eq (list (prod Int B)) (lin_avl t) (@app (prod Int B) (@app (prod Int B) (lin_avl l0) (@cons (prod Int B) (@pair Int B k0 d0) l1)) l2) *) (* Goal: lookup key r0 d *) (* Goal: equiv_del key (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite lin_t. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *. (* Goal: @eq (list (prod Int B)) (@app (prod Int B) (lin_avl l0) (@cons (prod Int B) (@pair Int B k0 d0) (lin_avl r))) (@app (prod Int B) (@app (prod Int B) (lin_avl l0) (@cons (prod Int B) (@pair Int B k0 d0) l1)) l2) *) (* Goal: lookup key r0 d *) (* Goal: equiv_del key (Avl_Node k0 d0 l0 r0 b0) t *) (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite (app_ass (lin_avl l0) ((k0, d0) :: l1) l2). (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite lin_r; trivial. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply (lookup_avl_inv_greater key k0 d0 l0 r0 b0 d); assumption. apply equiv_del_equiv_equiv_del with (t1 := Avl_Node k0 d0 l0 r b0); (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) try assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply equiv_del_trans_right; try assumption. (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) inversion_clear avl_t0. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply is_below_avl_is_below; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply equiv_sym; assumption. (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) clear lin_t equiv_t avl_t bal_or_shift equiv_r0 lookup_r0. (* Goal: sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) elim shrunk_dec; clear shrunk_dec. (* Goal: forall _ : hasnot_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) intro hasnot_shrunk. (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) left. (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) inversion_clear avl_t0. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) generalize H1; clear H H0 H1 H2 H3. (* Goal: forall _ : is_balanced_avl l0 r0 b0, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) inversion_clear hasnot_shrunk. (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H0; clear H0. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) inversion_clear H; simpl in |- *. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (S (height_avl r0)) (S (height_avl r)) *) (* Goal: forall _ : is_balanced_avl l0 r0 Left_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Left_Balanced)) (height_avl t) *) (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Balanced)) (height_avl t) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite <- H0; clear H0. (* Goal: is_balanced_avl_right_shift l r0 b0 *) intros Balanced_l0; inversion_clear Balanced_l0. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H; trivial. (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H0; clear H0. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H0; clear H0. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) trivial. (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) intros has_shrunk. (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) right. (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) inversion_clear avl_t0. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) generalize H1; clear H H0 H1 H2 H3. (* Goal: forall _ : is_balanced_avl l0 r0 b0, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) inversion_clear has_shrunk. (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H0; clear H0. (* Goal: forall _ : is_balanced_avl l0 r0 Left_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Left_Balanced)) (S (height_avl l0)) *) (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *; trivial. (* Goal: forall _ : is_balanced_avl l0 r0 Right_Balanced, @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (height_avl t)) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H0; clear H0. (* Goal: is_balanced_avl_right_shift l r0 b0 *) intros Balanced_l0; inversion_clear Balanced_l0. (* Goal: @eq nat (height_avl (Avl_Node k0 d0 l0 r0 Right_Balanced)) (S (S (height_avl l0))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) simpl in |- *. (* Goal: forall _ : is_balanced_avl l0 r0 Balanced, @eq nat (S (height_avl l0)) (S (height_avl l0)) *) (* Goal: forall _ : has_shrunk_left t k0 d0 l0 r b0, sumbool (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (height_avl t)) (@eq nat (height_avl (Avl_Node k0 d0 l0 r0 b0)) (S (height_avl t))) *) (* Goal: is_avl l0 *) (* Goal: is_below_avl l0 k0 *) (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) rewrite H0; trivial. (* side premisses (Elim (balance_shrunk_right ...) ) *) (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear avl_t0; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear avl_t0; assumption. (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) inversion_clear avl_t0. (* Goal: is_above_avl r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) apply above_above_avl. (* Goal: is_above r k0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) apply above_equiv_del_above with r0 key. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) apply is_above_avl_is_above; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) elim bal_or_shift; clear bal_or_shift; intros height_l0. (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) left. (* Goal: is_balanced_avl l0 r b0 *) (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) apply hasnot_grown_right__preserves_is_balanced_avl with r0. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear avl_t0; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) symmetry in |- *; assumption. (* Goal: sumbool (is_balanced_avl l0 r b0) (is_balanced_avl_left_shift l0 r b0) *) (* Goal: is_avl r0 *) right. (* Goal: is_balanced_avl_left_shift l0 r b0 *) (* Goal: is_avl r0 *) apply Balanced_shrunk_left_balanced_shift with r0. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear avl_t0; assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) assumption. (* Goal: @eq nat (height_avl r0) (S (height_avl r)) *) (* Goal: is_avl r0 *) inversion_clear avl_t0; assumption. Qed. (************************************************************************) (************************************************************************) (************************************************************************) Inductive AVL : Set := AVL_intro : forall t : avl_tree, is_avl t -> AVL. Definition AVL_NIL := AVL_intro Avl_Nil Nil_Is_Avl. Definition LOOKUP (key : Int) (T : AVL) (data : B) := match T with | AVL_intro t _ => lookup key t data end. Definition LOOKUP_Dec_Spec (key : Int) (T : AVL) := match T with | AVL_intro t _ => lookup_dec_spec key t end. Theorem LOOKUP_DEC : forall (key : Int) (T : AVL), LOOKUP_Dec_Spec key T. (* Goal: forall (key : Int) (T : AVL), LOOKUP_Dec_Spec key T *) intros key T. (* Goal: LOOKUP_Dec_Spec key T *) elim T; clear T. (* Goal: forall (t : avl_tree) (i : is_avl t), LOOKUP_Dec_Spec key (AVL_intro t i) *) exact (lookup_dec key). Qed. (***************************************************************************) Definition LIN_AVL (T : AVL) := match T with | AVL_intro t _ => lin_avl t end. (***************************************************************************) Definition LIN_INS (key : Int) (update : B -> B) (init : B) (T0 T : AVL) := match T0 with | AVL_intro t0 _ => match T with | AVL_intro t _ => lin_ins_spec key update init t0 t end end. Definition EQUIV_INS (key : Int) (update : B -> B) (init : B) (T0 T : AVL) := match T0 with | AVL_intro t0 _ => match T with | AVL_intro t _ => equiv_ins key update init t0 t end end. Definition INSRT_Spec (key : Int) (update : B -> B) (init : B) (T0 : AVL) := match T0 with | AVL_intro t0 _ => avl_ins_spec key update init t0 end. Theorem INSRT_AVL : forall (key : Int) (update : B -> B) (init : B) (T0 : AVL), INSRT_Spec key update init T0. (* Goal: forall (key : Int) (update : forall _ : B, B) (init : B) (T0 : AVL), INSRT_Spec key update init T0 *) intros key update init T0. (* Goal: DELETE_Spec key T0 *) elim T0; clear T0. (* Goal: forall (t : avl_tree) (i : is_avl t), INSRT_Spec key update init (AVL_intro t i) *) exact (insert_avl key update init). Qed. (***************************************************************************) Definition LIN_DEL (key : Int) (d : B) (T0 T : AVL) := match T0 with | AVL_intro t0 _ => match T with | AVL_intro t _ => lin_del_spec key d t0 t end end. Definition EQUIV_DEL (key : Int) (T0 T : AVL) := match T0 with | AVL_intro t0 _ => match T with | AVL_intro t _ => equiv_del key t0 t end end. Definition DELETE_Spec (key : Int) (T0 : AVL) := match T0 with | AVL_intro t0 _ => delete_spec key t0 end. Theorem DELETE_AVL : forall (key : Int) (T0 : AVL), DELETE_Spec key T0. (* Goal: forall (key : Int) (T0 : AVL), DELETE_Spec key T0 *) intros key T0. (* Goal: DELETE_Spec key T0 *) elim T0; clear T0. (* Goal: forall (t : avl_tree) (i : is_avl t), DELETE_Spec key (AVL_intro t i) *) exact (delete_avl key). Qed. End avl_trees. (* In order to extract a ML program use: *) (* Require Extraction. Extract Constant Int => int. Link Int := Int. Extract Inductive sumbool => bool [ true false ]. Extract Constant equal_dec => "(=)". Extract Constant less_dec => "(<)". Write Caml File "avl_trees" [rebalance_left rebalance_right balance_left balance_right balance_shrunk_left balance_shrunk_right delete_max lookup_dec insert_avl delete_avl lin_avl]. *)
(* File: Le_Ks.v (last edited on 27/10/2000) (c) Klaus Weich *) Require Export Rev_App. (*****************************************************************) Inductive le_ni : nested_imps -> nested_imps -> Prop := | Le_NI_Nil : le_ni NNil NNil | Le_NI_Cons_NN : forall (x : nimp) (ni1 ni2 : nested_imps), le_ni ni1 ni2 -> le_ni (Undecorated x :: ni1) (Undecorated x :: ni2) | Le_NI_Cons_DN : forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps), le_ni ni1 ni2 -> le_ni (Decorated x k :: ni1) (Undecorated x :: ni2) | Le_NI_Cons_DD : forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps), le_ni ni1 ni2 -> le_ni (Decorated x k :: ni1) (Decorated x k :: ni2). Lemma in_k_le : forall (ni1 ni2 : nested_imps) (x : nimp) (k : kripke_tree), le_ni ni1 ni2 -> In (Decorated x k) ni2 -> In (Decorated x k) ni1. (* Goal: forall (ni1 ni2 : nested_imps) (x : nimp) (k : kripke_tree) (_ : le_ni ni1 ni2) (_ : @In nested_imp (Decorated x k) ni2), @In nested_imp (Decorated x k) ni1 *) intros ni1 ni2 x k le12. (* Goal: forall (ni3 : nested_imps) (_ : le_ni ni2 ni3), le_ni ni1 ni3 *) elim le12; clear le12 ni1 ni2. (* Goal: forall (ni3 : nested_imps) (_ : eqv_ni NNil ni3), eqv_ni NNil ni3 *) (* Goal: forall (x : nimp) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Undecorated x) ni2) ni3), eqv_ni (@cons nested_imp (Undecorated x) ni1) ni3 *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Undecorated x) ni2) ni3), eqv_ni (@cons nested_imp (Decorated x k) ni1) ni3 *) (* Goal: forall (x : nimp) (k k' : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Decorated x k') ni2) ni3), eqv_ni (@cons nested_imp (Decorated x k) ni1) ni3 *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Decorated x k) ni2) ni3), eqv_ni (@cons nested_imp (Undecorated x) ni1) ni3 *) intros; assumption. (* Goal: forall (x0 : nimp) (ni1 ni2 : nested_imps) (_ : le_ni ni1 ni2) (_ : forall _ : @In nested_imp (Decorated x k) ni2, @In nested_imp (Decorated x k) ni1) (_ : @In nested_imp (Decorated x k) (@cons nested_imp (Undecorated x0) ni2)), @In nested_imp (Decorated x k) (@cons nested_imp (Undecorated x0) ni1) *) (* Goal: forall (x0 : nimp) (k0 : kripke_tree) (ni1 ni2 : nested_imps) (_ : le_ni ni1 ni2) (_ : forall _ : @In nested_imp (Decorated x k) ni2, @In nested_imp (Decorated x k) ni1) (_ : @In nested_imp (Decorated x k) (@cons nested_imp (Undecorated x0) ni2)), @In nested_imp (Decorated x k) (@cons nested_imp (Decorated x0 k0) ni1) *) (* Goal: forall (x0 : nimp) (k0 : kripke_tree) (ni1 ni2 : nested_imps) (_ : le_ni ni1 ni2) (_ : forall _ : @In nested_imp (Decorated x k) ni2, @In nested_imp (Decorated x k) ni1) (_ : @In nested_imp (Decorated x k) (@cons nested_imp (Decorated x0 k0) ni2)), @In nested_imp (Decorated x k) (@cons nested_imp (Decorated x0 k0) ni1) *) intros x' ni1 ni2 le12 ih in_k. (* Goal: @In nested_imp (Decorated x k) (@cons nested_imp (Decorated x' k') ni1) *) (* Goal: forall (x0 : nimp) (k0 : kripke_tree) (ni1 ni2 : nested_imps) (_ : le_ni ni1 ni2) (_ : forall _ : @In nested_imp (Decorated x k) ni2, @In nested_imp (Decorated x k) ni1) (_ : @In nested_imp (Decorated x k) (@cons nested_imp (Decorated x0 k0) ni2)), @In nested_imp (Decorated x k) (@cons nested_imp (Decorated x0 k0) ni1) *) right. (* Goal: le_ni (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4)) *) apply ih. (* Goal: forces_t k (Atom i) *) (* Goal: forall (a : nested_imp) (l : list nested_imp) (_ : filter_deco_spec i l), filter_deco_spec i (@cons nested_imp a l) *) inversion_clear in_k. (* Goal: forces_t k' (Atom i) *) (* Goal: forces_t k' (Atom i) *) discriminate H. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) assumption. (* Goal: forall (x0 : nimp) (k0 : kripke_tree) (ni1 ni2 : nested_imps) (_ : le_ni ni1 ni2) (_ : forall _ : @In nested_imp (Decorated x k) ni2, @In nested_imp (Decorated x k) ni1) (_ : @In nested_imp (Decorated x k) (@cons nested_imp (Decorated x0 k0) ni2)), @In nested_imp (Decorated x k) (@cons nested_imp (Decorated x0 k0) ni1) *) intros x' k' ni1 ni2 le12 ih in_k. (* Goal: @In nested_imp (Decorated x k) (@cons nested_imp (Decorated x' k') ni1) *) (* Goal: forall (x0 : nimp) (k0 : kripke_tree) (ni1 ni2 : nested_imps) (_ : le_ni ni1 ni2) (_ : forall _ : @In nested_imp (Decorated x k) ni2, @In nested_imp (Decorated x k) ni1) (_ : @In nested_imp (Decorated x k) (@cons nested_imp (Decorated x0 k0) ni2)), @In nested_imp (Decorated x k) (@cons nested_imp (Decorated x0 k0) ni1) *) right. (* Goal: le_ni (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4)) *) apply ih. (* Goal: forces_t k (Atom i) *) (* Goal: forall (a : nested_imp) (l : list nested_imp) (_ : filter_deco_spec i l), filter_deco_spec i (@cons nested_imp a l) *) inversion_clear in_k. (* Goal: forces_t k' (Atom i) *) (* Goal: forces_t k' (Atom i) *) discriminate H. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) assumption. (* Goal: forall (x0 : nimp) (k0 : kripke_tree) (ni1 ni2 : nested_imps) (_ : le_ni ni1 ni2) (_ : forall _ : @In nested_imp (Decorated x k) ni2, @In nested_imp (Decorated x k) ni1) (_ : @In nested_imp (Decorated x k) (@cons nested_imp (Decorated x0 k0) ni2)), @In nested_imp (Decorated x k) (@cons nested_imp (Decorated x0 k0) ni1) *) intros x' k' ni1 ni2 le12 ih in_k. (* Goal: forces_t k (Atom i) *) (* Goal: forall (a : nested_imp) (l : list nested_imp) (_ : filter_deco_spec i l), filter_deco_spec i (@cons nested_imp a l) *) inversion_clear in_k. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) left; assumption. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) right; apply ih; assumption. Qed. Lemma le_ni_refl : forall ni : nested_imps, le_ni ni ni. (* Goal: forall ni : nested_imps, le_ni ni ni *) intros ni; elim ni; clear ni. (* Goal: le_ni NNil NNil *) (* Goal: eqv_ni NNil NNil *) (* Goal: forall (x : nimp) (k : kripke_tree) (_ : @In nested_imp (Decorated x k) NNil), or (@In nested_imp (Decorated x k) NNil) (@In nested_imp (Decorated x k) NNil) *) (* Goal: forall (x : nimp) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : inf_deco_spec ni1 ni2), inf_deco_spec (@cons nested_imp (Undecorated x) ni1) (@cons nested_imp (Undecorated x) ni2) *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : inf_deco_spec ni1 ni2), inf_deco_spec (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp (Undecorated x) ni2) *) (* Goal: forall (x : nimp) (k k' : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : inf_deco_spec ni1 ni2), inf_deco_spec (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp (Decorated x k') ni2) *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : inf_deco_spec ni1 ni2), inf_deco_spec (@cons nested_imp (Undecorated x) ni1) (@cons nested_imp (Decorated x k) ni2) *) apply Le_NI_Nil. (* Goal: forall (n : nested_imp) (l : list nested_imp) (_ : eqv_ni (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp n l)), P (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp n l) *) intros a; case a; clear a. (* Goal: forall (n : nimp) (l : list nested_imp) (_ : le_ni l l), le_ni (@cons nested_imp (Undecorated n) l) (@cons nested_imp (Undecorated n) l) *) (* Goal: forall (n : nimp) (k : kripke_tree) (l : list nested_imp) (_ : le_ni l l), le_ni (@cons nested_imp (Decorated n k) l) (@cons nested_imp (Decorated n k) l) *) intros x N ih. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) apply Le_NI_Cons_NN; assumption. (* Goal: forall (n : nimp) (k : kripke_tree) (l : list nested_imp) (_ : filter_deco_spec i l), filter_deco_spec i (@cons nested_imp (Decorated n k) l) *) intros x k ni ih. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) apply Le_NI_Cons_DD; assumption. Qed. Lemma le_ni_trans : forall ni1 ni2 ni3 : nested_imps, le_ni ni1 ni2 -> le_ni ni2 ni3 -> le_ni ni1 ni3. (* Goal: forall (ni1 ni2 ni3 : nested_imps) (_ : le_ni ni1 ni2) (_ : le_ni ni2 ni3), le_ni ni1 ni3 *) intros ni1 ni2 ni3 le12. (* Goal: forall (_ : @eq nat (@length nested_imp ni1) (@length nested_imp ni3)) (_ : le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4)), le_ni (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4)) *) generalize ni3; clear ni3. (* Goal: forall (ni3 : nested_imps) (_ : le_ni ni2 ni3), le_ni ni1 ni3 *) elim le12; clear le12 ni1 ni2. (* Goal: forall (ni3 : nested_imps) (_ : eqv_ni NNil ni3), eqv_ni NNil ni3 *) (* Goal: forall (x : nimp) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Undecorated x) ni2) ni3), eqv_ni (@cons nested_imp (Undecorated x) ni1) ni3 *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Undecorated x) ni2) ni3), eqv_ni (@cons nested_imp (Decorated x k) ni1) ni3 *) (* Goal: forall (x : nimp) (k k' : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Decorated x k') ni2) ni3), eqv_ni (@cons nested_imp (Decorated x k) ni1) ni3 *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Decorated x k) ni2) ni3), eqv_ni (@cons nested_imp (Undecorated x) ni1) ni3 *) intros; assumption. (* Goal: forall (x : nimp) (ni1 ni2 : nested_imps) (_ : le_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : le_ni ni2 ni3), le_ni ni1 ni3) (ni3 : nested_imps) (_ : le_ni (@cons nested_imp (Undecorated x) ni2) ni3), le_ni (@cons nested_imp (Undecorated x) ni1) ni3 *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : le_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : le_ni ni2 ni3), le_ni ni1 ni3) (ni3 : nested_imps) (_ : le_ni (@cons nested_imp (Undecorated x) ni2) ni3), le_ni (@cons nested_imp (Decorated x k) ni1) ni3 *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : le_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : le_ni ni2 ni3), le_ni ni1 ni3) (ni3 : nested_imps) (_ : le_ni (@cons nested_imp (Decorated x k) ni2) ni3), le_ni (@cons nested_imp (Decorated x k) ni1) ni3 *) intros x ni1 ni2 le12 ih ni3 le23. (* Goal: le_ni (@cons nested_imp (Decorated x k) ni1) ni3 *) inversion_clear le23. (* Goal: le_ni (@cons nested_imp (Undecorated x0) (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2))) (@cons nested_imp (Undecorated x0) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4))) *) (* Goal: le_ni (@cons nested_imp (Decorated x0 k0) (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2))) (@cons nested_imp (Undecorated x0) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4))) *) (* Goal: le_ni (@cons nested_imp (Decorated x0 k0) (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2))) (@cons nested_imp (Decorated x0 k0) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4))) *) apply Le_NI_Cons_NN. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) apply ih; assumption. (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : le_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : le_ni ni2 ni3), le_ni ni1 ni3) (ni3 : nested_imps) (_ : le_ni (@cons nested_imp (Decorated x k) ni2) ni3), le_ni (@cons nested_imp (Decorated x k) ni1) ni3 *) intros x k ni1 ni2 le12 ih ni3 le23. (* Goal: le_ni (@cons nested_imp (Decorated x k) ni1) ni3 *) inversion_clear le23. (* Goal: le_ni (@cons nested_imp (Decorated x0 k0) (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2))) (@cons nested_imp (Undecorated x0) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4))) *) (* Goal: le_ni (@cons nested_imp (Decorated x0 k0) (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2))) (@cons nested_imp (Decorated x0 k0) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4))) *) apply Le_NI_Cons_DN. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) apply ih; assumption. (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : le_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : le_ni ni2 ni3), le_ni ni1 ni3) (ni3 : nested_imps) (_ : le_ni (@cons nested_imp (Decorated x k) ni2) ni3), le_ni (@cons nested_imp (Decorated x k) ni1) ni3 *) intros x k ni1 ni2 le12 ih ni3 le23. (* Goal: le_ni (@cons nested_imp (Decorated x k) ni1) ni3 *) inversion_clear le23. (* Goal: le_ni (@cons nested_imp (Decorated x0 k0) (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2))) (@cons nested_imp (Undecorated x0) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4))) *) (* Goal: le_ni (@cons nested_imp (Decorated x0 k0) (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2))) (@cons nested_imp (Decorated x0 k0) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4))) *) apply Le_NI_Cons_DN. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) apply ih; assumption. (* Goal: le_ni (@cons nested_imp (Decorated x0 k0) (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2))) (@cons nested_imp (Decorated x0 k0) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4))) *) apply Le_NI_Cons_DD. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) apply ih; assumption. Qed. (*****************************************************************) Inductive filter_deco_spec (i : Int) (N : nested_imps) : Set := Filter_Deco_Spec_Intro : forall ni1 : nested_imps, le_ni N ni1 -> (forall (x : nimp) (k : kripke_tree), In (Decorated x k) ni1 -> forces_t k (Atom i)) -> filter_deco_spec i N. Lemma filter_deco : forall (i : Int) (ni : nested_imps), filter_deco_spec i ni. (* Goal: forall (i : Int) (ni : nested_imps), filter_deco_spec i ni *) intros i ni. (* Goal: filter_deco_spec i ni *) elim ni; clear ni. (* Goal: filter_deco_spec i (@nil nested_imp) *) (* Goal: forall (a : nested_imp) (l : list nested_imp) (_ : filter_deco_spec i l), filter_deco_spec i (@cons nested_imp a l) *) fold NNil in |- *. (* Goal: filter_deco_spec i NNil *) (* Goal: forall (a : nested_imp) (l : list nested_imp) (_ : filter_deco_spec i l), filter_deco_spec i (@cons nested_imp a l) *) apply Filter_Deco_Spec_Intro with NNil. (* Goal: le_ni NNil NNil *) (* Goal: eqv_ni NNil NNil *) (* Goal: forall (x : nimp) (k : kripke_tree) (_ : @In nested_imp (Decorated x k) NNil), or (@In nested_imp (Decorated x k) NNil) (@In nested_imp (Decorated x k) NNil) *) (* Goal: forall (x : nimp) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : inf_deco_spec ni1 ni2), inf_deco_spec (@cons nested_imp (Undecorated x) ni1) (@cons nested_imp (Undecorated x) ni2) *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : inf_deco_spec ni1 ni2), inf_deco_spec (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp (Undecorated x) ni2) *) (* Goal: forall (x : nimp) (k k' : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : inf_deco_spec ni1 ni2), inf_deco_spec (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp (Decorated x k') ni2) *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : inf_deco_spec ni1 ni2), inf_deco_spec (@cons nested_imp (Undecorated x) ni1) (@cons nested_imp (Decorated x k) ni2) *) apply Le_NI_Nil. (* Goal: forall (x : nimp) (k : kripke_tree) (_ : @In nested_imp (Decorated x k) NNil), forces_t k (Atom i) *) (* Goal: forall (a : nested_imp) (l : list nested_imp) (_ : filter_deco_spec i l), filter_deco_spec i (@cons nested_imp a l) *) intros x k in_k. (* Goal: forces_t k (Atom i) *) (* Goal: forall (a : nested_imp) (l : list nested_imp) (_ : filter_deco_spec i l), filter_deco_spec i (@cons nested_imp a l) *) inversion_clear in_k. (* Goal: forall (n : nested_imp) (l : list nested_imp) (_ : eqv_ni (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp n l)), P (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp n l) *) intros a; case a; clear a. (* Goal: forall (n : nimp) (l : list nested_imp) (_ : filter_deco_spec i l), filter_deco_spec i (@cons nested_imp (Undecorated n) l) *) (* Goal: forall (n : nimp) (k : kripke_tree) (l : list nested_imp) (_ : filter_deco_spec i l), filter_deco_spec i (@cons nested_imp (Decorated n k) l) *) intros x ni ih. (* Goal: inf_deco_spec (@cons nested_imp (Undecorated x) ni1) (@cons nested_imp (Decorated x k) ni2) *) elim ih; clear ih. (* Goal: forall (ni1 : nested_imps) (_ : le_ni ni ni1) (_ : forall (x : nimp) (k : kripke_tree) (_ : @In nested_imp (Decorated x k) ni1), forces_t k (Atom i)), filter_deco_spec i (@cons nested_imp (Decorated x k) ni) *) intros ni1 le1 forces_i. (* Goal: filter_deco_spec i (@cons nested_imp (Decorated x (node atoms (AVL_intro unit t avl_t) succs)) ni) *) apply Filter_Deco_Spec_Intro with (Undecorated x :: ni1). (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) apply Le_NI_Cons_NN; assumption. (* Goal: forall (x0 : nimp) (k0 : kripke_tree) (_ : @In nested_imp (Decorated x0 k0) (@cons nested_imp (Decorated x k) ni)), or (@In nested_imp (Decorated x0 k0) (@cons nested_imp (Decorated x k) ni1)) (@In nested_imp (Decorated x0 k0) (@cons nested_imp (Undecorated x) ni2)) *) (* Goal: forall (x : nimp) (k k' : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : inf_deco_spec ni1 ni2), inf_deco_spec (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp (Decorated x k') ni2) *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : inf_deco_spec ni1 ni2), inf_deco_spec (@cons nested_imp (Undecorated x) ni1) (@cons nested_imp (Decorated x k) ni2) *) intros x' k' in_k0. (* Goal: forces_t k' (Atom i) *) (* Goal: forall (n : nimp) (k : kripke_tree) (l : list nested_imp) (_ : filter_deco_spec i l), filter_deco_spec i (@cons nested_imp (Decorated n k) l) *) apply forces_i with x'. (* Goal: or (@In nested_imp (Decorated x0 k0) (@cons nested_imp (Undecorated x) ni1)) (@In nested_imp (Decorated x0 k0) (@cons nested_imp (Decorated x k) ni2)) *) inversion_clear in_k0. (* Goal: forces_t k' (Atom i) *) (* Goal: forces_t k' (Atom i) *) discriminate H. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) assumption. (* Goal: forall (n : nimp) (k : kripke_tree) (l : list nested_imp) (_ : filter_deco_spec i l), filter_deco_spec i (@cons nested_imp (Decorated n k) l) *) intros x k ni ih. (* Goal: inf_deco_spec (@cons nested_imp (Undecorated x) ni1) (@cons nested_imp (Decorated x k) ni2) *) elim ih; clear ih. (* Goal: forall (ni1 : nested_imps) (_ : le_ni ni ni1) (_ : forall (x : nimp) (k : kripke_tree) (_ : @In nested_imp (Decorated x k) ni1), forces_t k (Atom i)), filter_deco_spec i (@cons nested_imp (Decorated x k) ni) *) intros ni1 le1 forces_i. (* Goal: filter_deco_spec i (@cons nested_imp (Decorated x k) ni) *) case k; clear k. (* Goal: forall (a : atoms) (f : Forest atoms), filter_deco_spec i (@cons nested_imp (Decorated x (node atoms a f)) ni) *) intros Atms succs. (* Goal: filter_deco_spec i (@cons nested_imp (Decorated x (node atoms Atms succs)) ni) *) case Atms; clear Atms. (* Goal: forall (t : avl_tree unit) (i0 : is_avl unit t), filter_deco_spec i (@cons nested_imp (Decorated x (node atoms (AVL_intro unit t i0) succs)) ni) *) intros t avl_t. (* Goal: filter_deco_spec i (@cons nested_imp (Decorated x (node atoms (AVL_intro unit t avl_t) succs)) ni) *) elim (lookup_dec unit i t avl_t). (* Goal: forall (d : unit) (_ : lookup unit i t d), filter_deco_spec i (@cons nested_imp (Decorated x (node atoms (AVL_intro unit t avl_t) succs)) ni) *) (* Goal: forall _ : forall d : unit, not (lookup unit i t d), filter_deco_spec i (@cons nested_imp (Decorated x (node atoms (AVL_intro unit t avl_t) succs)) ni) *) intros d; case d; clear d. (* Goal: forall _ : lookup unit i t tt, filter_deco_spec i (@cons nested_imp (Decorated x (node atoms (AVL_intro unit t avl_t) succs)) ni) *) (* Goal: forall _ : forall d : unit, not (lookup unit i t d), filter_deco_spec i (@cons nested_imp (Decorated x (node atoms (AVL_intro unit t avl_t) succs)) ni) *) intros lookup. apply Filter_Deco_Spec_Intro with (Decorated x (node atoms (AVL_intro unit t avl_t) succs) :: ni1). (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) apply Le_NI_Cons_DD; assumption. (* Goal: forall (x0 : nimp) (k0 : kripke_tree) (_ : @In nested_imp (Decorated x0 k0) (@cons nested_imp (Decorated x k) ni)), or (@In nested_imp (Decorated x0 k0) (@cons nested_imp (Decorated x k) ni1)) (@In nested_imp (Decorated x0 k0) (@cons nested_imp (Undecorated x) ni2)) *) (* Goal: forall (x : nimp) (k k' : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : inf_deco_spec ni1 ni2), inf_deco_spec (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp (Decorated x k') ni2) *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : inf_deco_spec ni1 ni2), inf_deco_spec (@cons nested_imp (Undecorated x) ni1) (@cons nested_imp (Decorated x k) ni2) *) intros x' k' in_k0. (* Goal: or (@In nested_imp (Decorated x0 k0) (@cons nested_imp (Undecorated x) ni1)) (@In nested_imp (Decorated x0 k0) (@cons nested_imp (Decorated x k) ni2)) *) inversion_clear in_k0. (* Goal: forces_t k' (Atom i) *) (* Goal: forces_t k' (Atom i) *) (* Goal: forall _ : forall d : unit, not (lookup unit i t d), filter_deco_spec i (@cons nested_imp (Decorated x (node atoms (AVL_intro unit t avl_t) succs)) ni) *) injection H; clear H; intros. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) rewrite <- H; assumption. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) apply forces_i with x'; assumption. (* Goal: forall _ : forall d : unit, not (lookup unit i t d), filter_deco_spec i (@cons nested_imp (Decorated x (node atoms (AVL_intro unit t avl_t) succs)) ni) *) intros notlookup. (* Goal: filter_deco_spec i (@cons nested_imp (Decorated x (node atoms (AVL_intro unit t avl_t) succs)) ni) *) apply Filter_Deco_Spec_Intro with (Undecorated x :: ni1). (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) apply Le_NI_Cons_DN; assumption. (* Goal: forall (x0 : nimp) (k0 : kripke_tree) (_ : @In nested_imp (Decorated x0 k0) (@cons nested_imp (Decorated x k) ni)), or (@In nested_imp (Decorated x0 k0) (@cons nested_imp (Decorated x k) ni1)) (@In nested_imp (Decorated x0 k0) (@cons nested_imp (Undecorated x) ni2)) *) (* Goal: forall (x : nimp) (k k' : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : inf_deco_spec ni1 ni2), inf_deco_spec (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp (Decorated x k') ni2) *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : inf_deco_spec ni1 ni2), inf_deco_spec (@cons nested_imp (Undecorated x) ni1) (@cons nested_imp (Decorated x k) ni2) *) simpl in |- *; intros x' k' in_k0. (* Goal: or (@In nested_imp (Decorated x0 k0) (@cons nested_imp (Undecorated x) ni1)) (@In nested_imp (Decorated x0 k0) (@cons nested_imp (Decorated x k) ni2)) *) inversion_clear in_k0. (* Goal: forces_t k' (Atom i) *) (* Goal: forces_t k' (Atom i) *) discriminate H. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) apply forces_i with x'; assumption. Qed. (*****************************************************************) Inductive eqv_ni : nested_imps -> nested_imps -> Prop := | Eqv_NI_Nil : eqv_ni NNil NNil | Eqv_NI_Cons_NN : forall (x : nimp) (ni1 ni2 : nested_imps), eqv_ni ni1 ni2 -> eqv_ni (Undecorated x :: ni1) (Undecorated x :: ni2) | Eqv_NI_Cons_DN : forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps), eqv_ni ni1 ni2 -> eqv_ni (Decorated x k :: ni1) (Undecorated x :: ni2) | Eqv_NI_Cons_DD : forall (x : nimp) (k k' : kripke_tree) (ni1 ni2 : nested_imps), eqv_ni ni1 ni2 -> eqv_ni (Decorated x k :: ni1) (Decorated x k' :: ni2) | Eqv_NI_Cons_ND : forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps), eqv_ni ni1 ni2 -> eqv_ni (Undecorated x :: ni1) (Decorated x k :: ni2). Lemma eqv_ni_trans : forall ni1 ni2 ni3 : nested_imps, eqv_ni ni1 ni2 -> eqv_ni ni2 ni3 -> eqv_ni ni1 ni3. (* Goal: forall (ni1 ni2 ni3 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3 *) intros ni1 ni2 ni3 eqv12. (* Goal: forall (_ : @eq nat (@length nested_imp ni1) (@length nested_imp ni3)) (_ : le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4)), le_ni (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4)) *) generalize ni3; clear ni3. (* Goal: inf_deco_spec ni1 ni2 *) elim eqv12; clear eqv12 ni1 ni2. (* Goal: forall (ni3 : nested_imps) (_ : eqv_ni NNil ni3), eqv_ni NNil ni3 *) (* Goal: forall (x : nimp) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Undecorated x) ni2) ni3), eqv_ni (@cons nested_imp (Undecorated x) ni1) ni3 *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Undecorated x) ni2) ni3), eqv_ni (@cons nested_imp (Decorated x k) ni1) ni3 *) (* Goal: forall (x : nimp) (k k' : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Decorated x k') ni2) ni3), eqv_ni (@cons nested_imp (Decorated x k) ni1) ni3 *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Decorated x k) ni2) ni3), eqv_ni (@cons nested_imp (Undecorated x) ni1) ni3 *) intros; assumption. (* Goal: forall (x : nimp) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Undecorated x) ni2) ni3), eqv_ni (@cons nested_imp (Undecorated x) ni1) ni3 *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Undecorated x) ni2) ni3), eqv_ni (@cons nested_imp (Decorated x k) ni1) ni3 *) (* Goal: forall (x : nimp) (k k' : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Decorated x k') ni2) ni3), eqv_ni (@cons nested_imp (Decorated x k) ni1) ni3 *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Decorated x k) ni2) ni3), eqv_ni (@cons nested_imp (Undecorated x) ni1) ni3 *) intros x ni1 ni2 eqv12 ih ni3 eqv23. (* Goal: eqv_ni (@cons nested_imp (Undecorated x) ni1) ni3 *) inversion_clear eqv23. (* Goal: eqv_ni (@cons nested_imp (Undecorated x) ni1) (@cons nested_imp (Undecorated x) ni4) *) (* Goal: eqv_ni (@cons nested_imp (Undecorated x) ni1) (@cons nested_imp (Decorated x k') ni4) *) apply Eqv_NI_Cons_NN. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) apply ih; assumption. (* Goal: eqv_ni (@cons nested_imp (Undecorated x) ni1) (@cons nested_imp (Decorated x k') ni4) *) apply Eqv_NI_Cons_ND. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) apply ih; assumption. (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Decorated x k) ni2) ni3), eqv_ni (@cons nested_imp (Undecorated x) ni1) ni3 *) intros x k ni1 ni2 eqv12 ih ni3 eqv23. (* Goal: eqv_ni (@cons nested_imp (Undecorated x) ni1) ni3 *) inversion_clear eqv23. (* Goal: eqv_ni (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp (Undecorated x) ni4) *) (* Goal: eqv_ni (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp (Decorated x k'0) ni4) *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Decorated x k) ni2) ni3), eqv_ni (@cons nested_imp (Undecorated x) ni1) ni3 *) apply Eqv_NI_Cons_DN. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) apply ih; assumption. (* Goal: eqv_ni (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp (Decorated x k'0) ni4) *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Decorated x k) ni2) ni3), eqv_ni (@cons nested_imp (Undecorated x) ni1) ni3 *) apply Eqv_NI_Cons_DD. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) apply ih; assumption. (* Goal: forall (x : nimp) (k k' : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Decorated x k') ni2) ni3), eqv_ni (@cons nested_imp (Decorated x k) ni1) ni3 *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Decorated x k) ni2) ni3), eqv_ni (@cons nested_imp (Undecorated x) ni1) ni3 *) intros x k k' ni1 ni2 eqv12 ih ni3 eqv23. (* Goal: eqv_ni (@cons nested_imp (Undecorated x) ni1) ni3 *) inversion_clear eqv23. (* Goal: eqv_ni (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp (Undecorated x) ni4) *) (* Goal: eqv_ni (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp (Decorated x k'0) ni4) *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Decorated x k) ni2) ni3), eqv_ni (@cons nested_imp (Undecorated x) ni1) ni3 *) apply Eqv_NI_Cons_DN. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) apply ih; assumption. (* Goal: eqv_ni (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp (Decorated x k'0) ni4) *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Decorated x k) ni2) ni3), eqv_ni (@cons nested_imp (Undecorated x) ni1) ni3 *) apply Eqv_NI_Cons_DD. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) apply ih; assumption. (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Decorated x k) ni2) ni3), eqv_ni (@cons nested_imp (Undecorated x) ni1) ni3 *) intros x k ni1 ni2 eqv12 ih ni3 eqv23. (* Goal: eqv_ni (@cons nested_imp (Undecorated x) ni1) ni3 *) inversion_clear eqv23. (* Goal: eqv_ni (@cons nested_imp (Undecorated x) ni1) (@cons nested_imp (Undecorated x) ni4) *) (* Goal: eqv_ni (@cons nested_imp (Undecorated x) ni1) (@cons nested_imp (Decorated x k') ni4) *) apply Eqv_NI_Cons_NN. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) apply ih; assumption. (* Goal: eqv_ni (@cons nested_imp (Undecorated x) ni1) (@cons nested_imp (Decorated x k') ni4) *) apply Eqv_NI_Cons_ND. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) apply ih; assumption. Qed. Lemma le_eqv : forall ni1 ni2 : nested_imps, le_ni ni1 ni2 -> eqv_ni ni1 ni2. (* Goal: forall (ni3 : nested_imps) (_ : le_ni ni2 ni3), le_ni ni1 ni3 *) intros ni1 ni2 le12; elim le12; clear le12 ni1 ni2. (* Goal: eqv_ni NNil NNil *) (* Goal: forall (x : nimp) (k : kripke_tree) (_ : @In nested_imp (Decorated x k) NNil), or (@In nested_imp (Decorated x k) NNil) (@In nested_imp (Decorated x k) NNil) *) (* Goal: forall (x : nimp) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : inf_deco_spec ni1 ni2), inf_deco_spec (@cons nested_imp (Undecorated x) ni1) (@cons nested_imp (Undecorated x) ni2) *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : inf_deco_spec ni1 ni2), inf_deco_spec (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp (Undecorated x) ni2) *) (* Goal: forall (x : nimp) (k k' : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : inf_deco_spec ni1 ni2), inf_deco_spec (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp (Decorated x k') ni2) *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : inf_deco_spec ni1 ni2), inf_deco_spec (@cons nested_imp (Undecorated x) ni1) (@cons nested_imp (Decorated x k) ni2) *) apply Eqv_NI_Nil. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) intros x ni1 ni2 le12 ih; apply Eqv_NI_Cons_NN; assumption. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) intros x k ni1 ni2 le12 ih; apply Eqv_NI_Cons_DN; assumption. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) intros x k ni1 ni2 le12 ih; apply Eqv_NI_Cons_DD; assumption. Qed. Lemma eqv_sym : forall ni1 ni2 : nested_imps, eqv_ni ni1 ni2 -> eqv_ni ni2 ni1. (* Goal: inf_deco_spec ni1 ni2 *) intros ni1 ni2 eqv12; elim eqv12; clear eqv12 ni1 ni2. (* Goal: eqv_ni NNil NNil *) (* Goal: forall (x : nimp) (k : kripke_tree) (_ : @In nested_imp (Decorated x k) NNil), or (@In nested_imp (Decorated x k) NNil) (@In nested_imp (Decorated x k) NNil) *) (* Goal: forall (x : nimp) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : inf_deco_spec ni1 ni2), inf_deco_spec (@cons nested_imp (Undecorated x) ni1) (@cons nested_imp (Undecorated x) ni2) *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : inf_deco_spec ni1 ni2), inf_deco_spec (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp (Undecorated x) ni2) *) (* Goal: forall (x : nimp) (k k' : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : inf_deco_spec ni1 ni2), inf_deco_spec (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp (Decorated x k') ni2) *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : inf_deco_spec ni1 ni2), inf_deco_spec (@cons nested_imp (Undecorated x) ni1) (@cons nested_imp (Decorated x k) ni2) *) apply Eqv_NI_Nil. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) intros x ni1 ni2 eqv12 ih; apply Eqv_NI_Cons_NN; assumption. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) intros x k ni1 ni2 eqv12 ih; apply Eqv_NI_Cons_ND; assumption. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) intros x k k' ni1 ni2 eqv12 ih; apply Eqv_NI_Cons_DD; assumption. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) intros x k ni1 ni2 eqv12 ih; apply Eqv_NI_Cons_DN; assumption. Qed. Lemma ge_eqv : forall ni1 ni2 : nested_imps, le_ni ni2 ni1 -> eqv_ni ni1 ni2. (* Goal: forall (ni1 ni2 : nested_imps) (_ : le_ni ni2 ni1), eqv_ni ni1 ni2 *) intros ni1 ni2 le21. (* Goal: eqv_ni ni1 ni2 *) apply eqv_sym. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) apply le_eqv; assumption. Qed. (*****************************************************************) Lemma eqv_ni_rec : forall P : nested_imps -> nested_imps -> Set, P NNil NNil -> (forall (x : nimp) (ni1 ni2 : nested_imps), eqv_ni ni1 ni2 -> P ni1 ni2 -> P (Undecorated x :: ni1) (Undecorated x :: ni2)) -> (forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps), eqv_ni ni1 ni2 -> P ni1 ni2 -> P (Decorated x k :: ni1) (Undecorated x :: ni2)) -> (forall (x : nimp) (k k' : kripke_tree) (ni1 ni2 : nested_imps), eqv_ni ni1 ni2 -> P ni1 ni2 -> P (Decorated x k :: ni1) (Decorated x k' :: ni2)) -> (forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps), eqv_ni ni1 ni2 -> P ni1 ni2 -> P (Undecorated x :: ni1) (Decorated x k :: ni2)) -> forall ni1 ni2 : nested_imps, eqv_ni ni1 ni2 -> P ni1 ni2. (* Goal: forall (P : forall (_ : nested_imps) (_ : nested_imps), Set) (_ : P NNil NNil) (_ : forall (x : nimp) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : P ni1 ni2), P (@cons nested_imp (Undecorated x) ni1) (@cons nested_imp (Undecorated x) ni2)) (_ : forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : P ni1 ni2), P (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp (Undecorated x) ni2)) (_ : forall (x : nimp) (k k' : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : P ni1 ni2), P (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp (Decorated x k') ni2)) (_ : forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : P ni1 ni2), P (@cons nested_imp (Undecorated x) ni1) (@cons nested_imp (Decorated x k) ni2)) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2), P ni1 ni2 *) intros P base step_nn step_rn step_rr step_nr ni1. (* Goal: forall (ni3 : nested_imps) (_ : @eq nat (@length nested_imp ni1) (@length nested_imp ni3)) (_ : le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4)), le_ni (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4)) *) elim ni1; clear ni1. (* Goal: forall (ni2 : nested_imps) (_ : eqv_ni (@nil nested_imp) ni2), P (@nil nested_imp) ni2 *) (* Goal: forall (a : nested_imp) (l : list nested_imp) (_ : forall (ni2 : nested_imps) (_ : eqv_ni l ni2), P l ni2) (ni2 : nested_imps) (_ : eqv_ni (@cons nested_imp a l) ni2), P (@cons nested_imp a l) ni2 *) intros ni2; case ni2; clear ni2. (* Goal: forall _ : eqv_ni (@nil nested_imp) (@nil nested_imp), P (@nil nested_imp) (@nil nested_imp) *) (* Goal: forall (n : nested_imp) (l : list nested_imp) (_ : eqv_ni (@nil nested_imp) (@cons nested_imp n l)), P (@nil nested_imp) (@cons nested_imp n l) *) (* Goal: forall (a : nested_imp) (l : list nested_imp) (_ : forall (ni2 : nested_imps) (_ : eqv_ni l ni2), P l ni2) (ni2 : nested_imps) (_ : eqv_ni (@cons nested_imp a l) ni2), P (@cons nested_imp a l) ni2 *) intros; apply base. (* Goal: forall (n : nested_imp) (l : list nested_imp) (_ : eqv_ni (@nil nested_imp) (@cons nested_imp n l)), P (@nil nested_imp) (@cons nested_imp n l) *) (* Goal: forall (a : nested_imp) (l : list nested_imp) (_ : forall (ni2 : nested_imps) (_ : eqv_ni l ni2), P l ni2) (ni2 : nested_imps) (_ : eqv_ni (@cons nested_imp a l) ni2), P (@cons nested_imp a l) ni2 *) intros a ni2 eqv; elimtype False; inversion_clear eqv. (* Goal: forall (n : nested_imp) (l : list nested_imp) (_ : eqv_ni (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp n l)), P (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp n l) *) intros a; case a; clear a. (* Goal: forall (n : nimp) (l : list nested_imp) (_ : forall (ni2 : nested_imps) (_ : eqv_ni l ni2), P l ni2) (ni2 : nested_imps) (_ : eqv_ni (@cons nested_imp (Undecorated n) l) ni2), P (@cons nested_imp (Undecorated n) l) ni2 *) (* Goal: forall (n : nimp) (k : kripke_tree) (l : list nested_imp) (_ : forall (ni2 : nested_imps) (_ : eqv_ni l ni2), P l ni2) (ni2 : nested_imps) (_ : eqv_ni (@cons nested_imp (Decorated n k) l) ni2), P (@cons nested_imp (Decorated n k) l) ni2 *) intros x ni1 ih ni2. (* Goal: forall _ : eqv_ni (@cons nested_imp (Decorated x k) ni1) ni2, P (@cons nested_imp (Decorated x k) ni1) ni2 *) case ni2; clear ni2. (* Goal: forall _ : eqv_ni (@cons nested_imp (Decorated x k) ni1) (@nil nested_imp), P (@cons nested_imp (Decorated x k) ni1) (@nil nested_imp) *) (* Goal: forall (n : nested_imp) (l : list nested_imp) (_ : eqv_ni (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp n l)), P (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp n l) *) intros eqv; elimtype False; inversion_clear eqv. (* Goal: forall (n : nested_imp) (l : list nested_imp) (_ : eqv_ni (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp n l)), P (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp n l) *) intros a; case a; clear a. (* Goal: forall (n : nimp) (l : list nested_imp) (_ : eqv_ni (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp (Undecorated n) l)), P (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp (Undecorated n) l) *) (* Goal: forall (n : nimp) (k0 : kripke_tree) (l : list nested_imp) (_ : eqv_ni (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp (Decorated n k0) l)), P (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp (Decorated n k0) l) *) intros x' ni2 eqv. (* Goal: P (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp (Decorated x' k') ni2) *) cut (x = x'). intro eq_x; rewrite eq_x; clear eq_x. (* Goal: P (@cons nested_imp (Undecorated x') ni1) (@cons nested_imp (Undecorated x') ni2) *) (* Goal: @eq nimp x x' *) (* Goal: forall (n : nimp) (k : kripke_tree) (l : list nested_imp) (_ : eqv_ni (@cons nested_imp (Undecorated x) ni1) (@cons nested_imp (Decorated n k) l)), P (@cons nested_imp (Undecorated x) ni1) (@cons nested_imp (Decorated n k) l) *) (* Goal: forall (n : nimp) (k : kripke_tree) (l : list nested_imp) (_ : forall (ni2 : nested_imps) (_ : eqv_ni l ni2), P l ni2) (ni2 : nested_imps) (_ : eqv_ni (@cons nested_imp (Decorated n k) l) ni2), P (@cons nested_imp (Decorated n k) l) ni2 *) apply step_nn. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) inversion_clear eqv; assumption. (* Goal: le_ni (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4)) *) apply ih. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) inversion_clear eqv; assumption. (* Goal: @eq nimp x x' *) inversion_clear eqv; trivial. (* Goal: forall (n : nimp) (k0 : kripke_tree) (l : list nested_imp) (_ : eqv_ni (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp (Decorated n k0) l)), P (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp (Decorated n k0) l) *) intros x' k' ni2 eqv. (* Goal: P (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp (Decorated x' k') ni2) *) cut (x = x'). intro eq_x; rewrite eq_x; clear eq_x. (* Goal: P (@cons nested_imp (Undecorated x') ni1) (@cons nested_imp (Decorated x' k') ni2) *) (* Goal: @eq nimp x x' *) (* Goal: forall (n : nimp) (k : kripke_tree) (l : list nested_imp) (_ : forall (ni2 : nested_imps) (_ : eqv_ni l ni2), P l ni2) (ni2 : nested_imps) (_ : eqv_ni (@cons nested_imp (Decorated n k) l) ni2), P (@cons nested_imp (Decorated n k) l) ni2 *) apply step_nr. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) inversion_clear eqv; assumption. (* Goal: le_ni (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4)) *) apply ih. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) inversion_clear eqv; assumption. (* Goal: @eq nimp x x' *) inversion_clear eqv; trivial. (* Goal: forall (n : nimp) (k : kripke_tree) (l : list nested_imp) (_ : forall (ni2 : nested_imps) (_ : eqv_ni l ni2), P l ni2) (ni2 : nested_imps) (_ : eqv_ni (@cons nested_imp (Decorated n k) l) ni2), P (@cons nested_imp (Decorated n k) l) ni2 *) intros x k ni1 ih ni2. (* Goal: forall _ : eqv_ni (@cons nested_imp (Decorated x k) ni1) ni2, P (@cons nested_imp (Decorated x k) ni1) ni2 *) case ni2; clear ni2. (* Goal: forall _ : eqv_ni (@cons nested_imp (Decorated x k) ni1) (@nil nested_imp), P (@cons nested_imp (Decorated x k) ni1) (@nil nested_imp) *) (* Goal: forall (n : nested_imp) (l : list nested_imp) (_ : eqv_ni (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp n l)), P (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp n l) *) intros eqv; elimtype False; inversion_clear eqv. (* Goal: forall (n : nested_imp) (l : list nested_imp) (_ : eqv_ni (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp n l)), P (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp n l) *) intros a; case a; clear a. (* Goal: forall (n : nimp) (l : list nested_imp) (_ : eqv_ni (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp (Undecorated n) l)), P (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp (Undecorated n) l) *) (* Goal: forall (n : nimp) (k0 : kripke_tree) (l : list nested_imp) (_ : eqv_ni (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp (Decorated n k0) l)), P (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp (Decorated n k0) l) *) intros x' ni2 eqv. (* Goal: P (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp (Decorated x' k') ni2) *) cut (x = x'). intro eq_x; rewrite eq_x; clear eq_x. (* Goal: P (@cons nested_imp (Decorated x' k) ni1) (@cons nested_imp (Undecorated x') ni2) *) (* Goal: @eq nimp x x' *) (* Goal: forall (n : nimp) (k0 : kripke_tree) (l : list nested_imp) (_ : eqv_ni (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp (Decorated n k0) l)), P (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp (Decorated n k0) l) *) apply step_rn. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) inversion_clear eqv; assumption. (* Goal: le_ni (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4)) *) apply ih. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) inversion_clear eqv; assumption. (* Goal: @eq nimp x x' *) inversion_clear eqv; trivial. (* Goal: forall (n : nimp) (k0 : kripke_tree) (l : list nested_imp) (_ : eqv_ni (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp (Decorated n k0) l)), P (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp (Decorated n k0) l) *) intros x' k' ni2 eqv. (* Goal: P (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp (Decorated x' k') ni2) *) cut (x = x'). intro eq_x; rewrite eq_x; clear eq_x. (* Goal: P (@cons nested_imp (Decorated x' k) ni1) (@cons nested_imp (Decorated x' k') ni2) *) (* Goal: @eq nimp x x' *) apply step_rr. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) inversion_clear eqv; assumption. (* Goal: le_ni (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4)) *) apply ih. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) inversion_clear eqv; assumption. (* Goal: @eq nimp x x' *) inversion_clear eqv; trivial. Qed. (*****************************************************************) Inductive inf_deco_spec (ni1 ni2 : nested_imps) : Set := Inf_Deco_Spec_Intro : forall ni : nested_imps, le_ni ni ni1 -> eqv_ni ni ni2 -> (forall (x : nimp) (k : kripke_tree), In (Decorated x k) ni -> In (Decorated x k) ni1 \/ In (Decorated x k) ni2) -> inf_deco_spec ni1 ni2. Lemma inf_deco : forall ni1 ni2 : nested_imps, eqv_ni ni1 ni2 -> inf_deco_spec ni1 ni2. (* Goal: forall (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2), inf_deco_spec ni1 ni2 *) intros ni1 ni2 eqv12. (* Goal: inf_deco_spec ni1 ni2 *) elim eqv12; clear eqv12 ni1 ni2. (* Goal: inf_deco_spec NNil NNil *) (* Goal: forall (x : nimp) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : inf_deco_spec ni1 ni2), inf_deco_spec (@cons nested_imp (Undecorated x) ni1) (@cons nested_imp (Undecorated x) ni2) *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : inf_deco_spec ni1 ni2), inf_deco_spec (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp (Undecorated x) ni2) *) (* Goal: forall (x : nimp) (k k' : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : inf_deco_spec ni1 ni2), inf_deco_spec (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp (Decorated x k') ni2) *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : inf_deco_spec ni1 ni2), inf_deco_spec (@cons nested_imp (Undecorated x) ni1) (@cons nested_imp (Decorated x k) ni2) *) apply Inf_Deco_Spec_Intro with NNil. (* Goal: le_ni NNil NNil *) (* Goal: eqv_ni NNil NNil *) (* Goal: forall (x : nimp) (k : kripke_tree) (_ : @In nested_imp (Decorated x k) NNil), or (@In nested_imp (Decorated x k) NNil) (@In nested_imp (Decorated x k) NNil) *) (* Goal: forall (x : nimp) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : inf_deco_spec ni1 ni2), inf_deco_spec (@cons nested_imp (Undecorated x) ni1) (@cons nested_imp (Undecorated x) ni2) *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : inf_deco_spec ni1 ni2), inf_deco_spec (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp (Undecorated x) ni2) *) (* Goal: forall (x : nimp) (k k' : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : inf_deco_spec ni1 ni2), inf_deco_spec (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp (Decorated x k') ni2) *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : inf_deco_spec ni1 ni2), inf_deco_spec (@cons nested_imp (Undecorated x) ni1) (@cons nested_imp (Decorated x k) ni2) *) apply Le_NI_Nil. (* Goal: eqv_ni NNil NNil *) (* Goal: forall (x : nimp) (k : kripke_tree) (_ : @In nested_imp (Decorated x k) NNil), or (@In nested_imp (Decorated x k) NNil) (@In nested_imp (Decorated x k) NNil) *) (* Goal: forall (x : nimp) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : inf_deco_spec ni1 ni2), inf_deco_spec (@cons nested_imp (Undecorated x) ni1) (@cons nested_imp (Undecorated x) ni2) *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : inf_deco_spec ni1 ni2), inf_deco_spec (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp (Undecorated x) ni2) *) (* Goal: forall (x : nimp) (k k' : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : inf_deco_spec ni1 ni2), inf_deco_spec (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp (Decorated x k') ni2) *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : inf_deco_spec ni1 ni2), inf_deco_spec (@cons nested_imp (Undecorated x) ni1) (@cons nested_imp (Decorated x k) ni2) *) apply Eqv_NI_Nil. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) intros; left; assumption. (* Goal: forall (x : nimp) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : inf_deco_spec ni1 ni2), inf_deco_spec (@cons nested_imp (Undecorated x) ni1) (@cons nested_imp (Undecorated x) ni2) *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : inf_deco_spec ni1 ni2), inf_deco_spec (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp (Undecorated x) ni2) *) (* Goal: forall (x : nimp) (k k' : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : inf_deco_spec ni1 ni2), inf_deco_spec (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp (Decorated x k') ni2) *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : inf_deco_spec ni1 ni2), inf_deco_spec (@cons nested_imp (Undecorated x) ni1) (@cons nested_imp (Decorated x k) ni2) *) intros x ni1 ni2 eqv12 ih. (* Goal: inf_deco_spec (@cons nested_imp (Undecorated x) ni1) (@cons nested_imp (Decorated x k) ni2) *) elim ih; clear ih. (* Goal: forall (ni : nested_imps) (_ : le_ni ni ni1) (_ : eqv_ni ni ni2) (_ : forall (x : nimp) (k : kripke_tree) (_ : @In nested_imp (Decorated x k) ni), or (@In nested_imp (Decorated x k) ni1) (@In nested_imp (Decorated x k) ni2)), inf_deco_spec (@cons nested_imp (Undecorated x) ni1) (@cons nested_imp (Decorated x k) ni2) *) intros ni le eqv inf. (* Goal: inf_deco_spec (@cons nested_imp (Undecorated x) ni1) (@cons nested_imp (Undecorated x) ni2) *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : inf_deco_spec ni1 ni2), inf_deco_spec (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp (Undecorated x) ni2) *) (* Goal: forall (x : nimp) (k k' : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : inf_deco_spec ni1 ni2), inf_deco_spec (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp (Decorated x k') ni2) *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : inf_deco_spec ni1 ni2), inf_deco_spec (@cons nested_imp (Undecorated x) ni1) (@cons nested_imp (Decorated x k) ni2) *) apply Inf_Deco_Spec_Intro with (Undecorated x :: ni). (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) apply Le_NI_Cons_NN; assumption. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) apply Eqv_NI_Cons_NN; assumption. (* Goal: forall (x0 : nimp) (k0 : kripke_tree) (_ : @In nested_imp (Decorated x0 k0) (@cons nested_imp (Decorated x k) ni)), or (@In nested_imp (Decorated x0 k0) (@cons nested_imp (Decorated x k) ni1)) (@In nested_imp (Decorated x0 k0) (@cons nested_imp (Undecorated x) ni2)) *) (* Goal: forall (x : nimp) (k k' : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : inf_deco_spec ni1 ni2), inf_deco_spec (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp (Decorated x k') ni2) *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : inf_deco_spec ni1 ni2), inf_deco_spec (@cons nested_imp (Undecorated x) ni1) (@cons nested_imp (Decorated x k) ni2) *) intros x' k' in_k0. (* Goal: or (@In nested_imp (Decorated x0 k0) (@cons nested_imp (Undecorated x) ni1)) (@In nested_imp (Decorated x0 k0) (@cons nested_imp (Decorated x k) ni2)) *) inversion_clear in_k0. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) left; left; assumption. (* Goal: or (@In nested_imp (Decorated x' k') (@cons nested_imp (Decorated x k) ni1)) (@In nested_imp (Decorated x' k') (@cons nested_imp (Undecorated x) ni2)) *) (* Goal: forall (x : nimp) (k k' : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : inf_deco_spec ni1 ni2), inf_deco_spec (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp (Decorated x k') ni2) *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : inf_deco_spec ni1 ni2), inf_deco_spec (@cons nested_imp (Undecorated x) ni1) (@cons nested_imp (Decorated x k) ni2) *) elim (inf x' k' H); clear inf H. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) intros in_ni1; left; right; assumption. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) intros in_ni2; right; right; assumption. (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : inf_deco_spec ni1 ni2), inf_deco_spec (@cons nested_imp (Undecorated x) ni1) (@cons nested_imp (Decorated x k) ni2) *) intros x k ni1 ni2 eqv12 ih. (* Goal: inf_deco_spec (@cons nested_imp (Undecorated x) ni1) (@cons nested_imp (Decorated x k) ni2) *) elim ih; clear ih. (* Goal: forall (ni : nested_imps) (_ : le_ni ni ni1) (_ : eqv_ni ni ni2) (_ : forall (x : nimp) (k : kripke_tree) (_ : @In nested_imp (Decorated x k) ni), or (@In nested_imp (Decorated x k) ni1) (@In nested_imp (Decorated x k) ni2)), inf_deco_spec (@cons nested_imp (Undecorated x) ni1) (@cons nested_imp (Decorated x k) ni2) *) intros ni le eqv inf. (* Goal: inf_deco_spec (@cons nested_imp (Undecorated x) ni1) (@cons nested_imp (Decorated x k) ni2) *) apply Inf_Deco_Spec_Intro with (Decorated x k :: ni). (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) apply Le_NI_Cons_DD; assumption. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) apply Eqv_NI_Cons_DN; assumption. (* Goal: forall (x0 : nimp) (k0 : kripke_tree) (_ : @In nested_imp (Decorated x0 k0) (@cons nested_imp (Decorated x k) ni)), or (@In nested_imp (Decorated x0 k0) (@cons nested_imp (Decorated x k) ni1)) (@In nested_imp (Decorated x0 k0) (@cons nested_imp (Undecorated x) ni2)) *) (* Goal: forall (x : nimp) (k k' : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : inf_deco_spec ni1 ni2), inf_deco_spec (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp (Decorated x k') ni2) *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : inf_deco_spec ni1 ni2), inf_deco_spec (@cons nested_imp (Undecorated x) ni1) (@cons nested_imp (Decorated x k) ni2) *) intros x' k' in_k0. (* Goal: or (@In nested_imp (Decorated x0 k0) (@cons nested_imp (Undecorated x) ni1)) (@In nested_imp (Decorated x0 k0) (@cons nested_imp (Decorated x k) ni2)) *) inversion_clear in_k0. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) left; left; assumption. (* Goal: or (@In nested_imp (Decorated x' k') (@cons nested_imp (Decorated x k) ni1)) (@In nested_imp (Decorated x' k') (@cons nested_imp (Undecorated x) ni2)) *) (* Goal: forall (x : nimp) (k k' : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : inf_deco_spec ni1 ni2), inf_deco_spec (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp (Decorated x k') ni2) *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : inf_deco_spec ni1 ni2), inf_deco_spec (@cons nested_imp (Undecorated x) ni1) (@cons nested_imp (Decorated x k) ni2) *) elim (inf x' k' H); clear inf H. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) intros in_ni1; left; right; assumption. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) intros in_ni2; right; right; assumption. (* Goal: forall (x : nimp) (k k' : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : inf_deco_spec ni1 ni2), inf_deco_spec (@cons nested_imp (Decorated x k) ni1) (@cons nested_imp (Decorated x k') ni2) *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : inf_deco_spec ni1 ni2), inf_deco_spec (@cons nested_imp (Undecorated x) ni1) (@cons nested_imp (Decorated x k) ni2) *) intros x k k' ni1 ni2 eqv12 ih. (* Goal: inf_deco_spec (@cons nested_imp (Undecorated x) ni1) (@cons nested_imp (Decorated x k) ni2) *) elim ih; clear ih. (* Goal: forall (ni : nested_imps) (_ : le_ni ni ni1) (_ : eqv_ni ni ni2) (_ : forall (x : nimp) (k : kripke_tree) (_ : @In nested_imp (Decorated x k) ni), or (@In nested_imp (Decorated x k) ni1) (@In nested_imp (Decorated x k) ni2)), inf_deco_spec (@cons nested_imp (Undecorated x) ni1) (@cons nested_imp (Decorated x k) ni2) *) intros ni le eqv inf. (* Goal: inf_deco_spec (@cons nested_imp (Undecorated x) ni1) (@cons nested_imp (Decorated x k) ni2) *) apply Inf_Deco_Spec_Intro with (Decorated x k :: ni). (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) apply Le_NI_Cons_DD; assumption. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) apply Eqv_NI_Cons_DD; assumption. (* Goal: forall (x0 : nimp) (k0 : kripke_tree) (_ : @In nested_imp (Decorated x0 k0) (@cons nested_imp (Decorated x k) ni)), or (@In nested_imp (Decorated x0 k0) (@cons nested_imp (Undecorated x) ni1)) (@In nested_imp (Decorated x0 k0) (@cons nested_imp (Decorated x k) ni2)) *) intros x0 k0 in_k0. (* Goal: or (@In nested_imp (Decorated x0 k0) (@cons nested_imp (Undecorated x) ni1)) (@In nested_imp (Decorated x0 k0) (@cons nested_imp (Decorated x k) ni2)) *) inversion_clear in_k0. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) left; left; assumption. (* Goal: or (@In nested_imp (Decorated x0 k0) (@cons nested_imp (Undecorated x) ni1)) (@In nested_imp (Decorated x0 k0) (@cons nested_imp (Decorated x k) ni2)) *) elim (inf x0 k0 H); clear inf H. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) intros in_ni1; left; right; assumption. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) intros in_ni2; right; right; assumption. (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : inf_deco_spec ni1 ni2), inf_deco_spec (@cons nested_imp (Undecorated x) ni1) (@cons nested_imp (Decorated x k) ni2) *) intros x k ni1 ni2 eqv12 ih. (* Goal: inf_deco_spec (@cons nested_imp (Undecorated x) ni1) (@cons nested_imp (Decorated x k) ni2) *) elim ih; clear ih. (* Goal: forall (ni : nested_imps) (_ : le_ni ni ni1) (_ : eqv_ni ni ni2) (_ : forall (x : nimp) (k : kripke_tree) (_ : @In nested_imp (Decorated x k) ni), or (@In nested_imp (Decorated x k) ni1) (@In nested_imp (Decorated x k) ni2)), inf_deco_spec (@cons nested_imp (Undecorated x) ni1) (@cons nested_imp (Decorated x k) ni2) *) intros ni le eqv inf. (* Goal: inf_deco_spec (@cons nested_imp (Undecorated x) ni1) (@cons nested_imp (Decorated x k) ni2) *) apply Inf_Deco_Spec_Intro with (Decorated x k :: ni). (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) apply Le_NI_Cons_DN; assumption. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) apply Eqv_NI_Cons_DD; assumption. (* Goal: forall (x0 : nimp) (k0 : kripke_tree) (_ : @In nested_imp (Decorated x0 k0) (@cons nested_imp (Decorated x k) ni)), or (@In nested_imp (Decorated x0 k0) (@cons nested_imp (Undecorated x) ni1)) (@In nested_imp (Decorated x0 k0) (@cons nested_imp (Decorated x k) ni2)) *) intros x0 k0 in_k0. (* Goal: or (@In nested_imp (Decorated x0 k0) (@cons nested_imp (Undecorated x) ni1)) (@In nested_imp (Decorated x0 k0) (@cons nested_imp (Decorated x k) ni2)) *) inversion_clear in_k0. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) right; left; assumption. (* Goal: or (@In nested_imp (Decorated x0 k0) (@cons nested_imp (Undecorated x) ni1)) (@In nested_imp (Decorated x0 k0) (@cons nested_imp (Decorated x k) ni2)) *) elim (inf x0 k0 H); clear inf H. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) intros in_ni1; left; right; assumption. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) intros in_ni2; right; right; assumption. Qed. (************************************************************************) Remark eqv_nimps_eq : forall ni1 ni2 : nested_imps, eqv_ni ni1 ni2 -> nested_imps2nimps ni1 = nested_imps2nimps ni2. (* Goal: forall (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2), @eq (list nimp) (nested_imps2nimps ni1) (nested_imps2nimps ni2) *) intros ni1 ni2 eqv. (* Goal: @eq (list nimp) (nested_imps2nimps ni1) (nested_imps2nimps ni2) *) elim eqv; clear eqv ni1 ni2; simpl in |- *. (* Goal: @Logic.eq nested_imps (@cons nested_imp x' (@app nested_imp ni11 ni12)) (@app nested_imp (@cons nested_imp x' ni11) ni12) *) (* Goal: @Logic.eq nat (@length nested_imp (@cons nested_imp x' ni11)) (S (@length nested_imp ni21)) *) (* Goal: le_ni ni1 (@app nested_imp ni21 ni22) *) trivial. (* Goal: @Logic.eq nested_imps (@cons nested_imp x' (@app nested_imp ni11 ni12)) (@app nested_imp (@cons nested_imp x' ni11) ni12) *) (* Goal: @Logic.eq nat (@length nested_imp (@cons nested_imp x' ni11)) (S (@length nested_imp ni21)) *) (* Goal: le_ni ni1 (@app nested_imp ni21 ni22) *) intros x ni1 ni2 eqv ih; rewrite ih; trivial. (* Goal: @Logic.eq nested_imps (@cons nested_imp x' (@app nested_imp ni11 ni12)) (@app nested_imp (@cons nested_imp x' ni11) ni12) *) (* Goal: @Logic.eq nat (@length nested_imp (@cons nested_imp x' ni11)) (S (@length nested_imp ni21)) *) (* Goal: le_ni ni1 (@app nested_imp ni21 ni22) *) intros x k ni1 ni2 eqv ih; rewrite ih; trivial. (* Goal: @Logic.eq nested_imps (@cons nested_imp x' (@app nested_imp ni11 ni12)) (@app nested_imp (@cons nested_imp x' ni11) ni12) *) (* Goal: @Logic.eq nat (@length nested_imp (@cons nested_imp x' ni11)) (S (@length nested_imp ni21)) *) (* Goal: le_ni ni1 (@app nested_imp ni21 ni22) *) intros x k1 k2 ni1 ni2 eqv ih; rewrite ih; trivial. (* Goal: @Logic.eq nested_imps (@cons nested_imp x' (@app nested_imp ni11 ni12)) (@app nested_imp (@cons nested_imp x' ni11) ni12) *) (* Goal: @Logic.eq nat (@length nested_imp (@cons nested_imp x' ni11)) (S (@length nested_imp ni21)) *) (* Goal: le_ni ni1 (@app nested_imp ni21 ni22) *) intros x k ni1 ni2 eqv ih; rewrite ih; trivial. Qed. Lemma in_ngamma_eqv : forall (work : nf_list) (ds : disjs) (ni1 ni2 : nested_imps) (ai : atomic_imps) (a : atoms) (c : normal_form), eqv_ni ni1 ni2 -> in_ngamma work ds ni1 ai a c -> in_ngamma work ds ni2 ai a c. (* Goal: forall (work : nf_list) (ds : disjs) (ni1 ni2 : nested_imps) (ai : atomic_imps) (a : atoms) (c : normal_form) (_ : eqv_ni ni1 ni2) (_ : in_ngamma work ds ni1 ai a c), in_ngamma work ds ni2 ai a c *) intros work ds ni1 ni2 ai a c eqv12 ini1. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) apply in_ngamma_ni_eq with ni1; try assumption. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) apply eqv_nimps_eq; assumption. Qed. Lemma in_ngamma_le : forall (work : nf_list) (ds : disjs) (ni1 ni2 : nested_imps) (ai : atomic_imps) (a : atoms) (c : normal_form), le_ni ni1 ni2 -> in_ngamma work ds ni1 ai a c -> in_ngamma work ds ni2 ai a c. (* Goal: forall (work : nf_list) (ds : disjs) (ni1 ni2 : nested_imps) (ai : atomic_imps) (a : atoms) (c : normal_form) (_ : le_ni ni1 ni2) (_ : in_ngamma work ds ni1 ai a c), in_ngamma work ds ni2 ai a c *) intros work ds ni1 ni2 ai a c le12 in_ngamma. (* Goal: In_NGamma.in_ngamma work ds ni2 ai a c *) apply in_ngamma_eqv with ni1. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) apply le_eqv; assumption. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) assumption. Qed. Lemma in_ngamma_ge : forall (work : nf_list) (ds : disjs) (ni1 ni2 : nested_imps) (ai : atomic_imps) (a : atoms) (c : normal_form), le_ni ni2 ni1 -> in_ngamma work ds ni1 ai a c -> in_ngamma work ds ni2 ai a c. (* Goal: forall (work : nf_list) (ds : disjs) (ni1 ni2 : nested_imps) (ai : atomic_imps) (a : atoms) (c : normal_form) (_ : le_ni ni2 ni1) (_ : in_ngamma work ds ni1 ai a c), in_ngamma work ds ni2 ai a c *) intros work ds ni1 ni2 ai a c le21 in_ngamma. (* Goal: In_NGamma.in_ngamma work ds ni2 ai a c *) apply in_ngamma_eqv with ni1. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) apply ge_eqv; assumption. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) assumption. Qed. (***********************************************************************) Inductive le_app_spec (ni1 : nested_imps) (n : nat) : Set := Le_App_Spec_Intro : forall ni11 ni12 : nested_imps, ni1 = ni11 ++ ni12 -> length ni11 = n -> le_app_spec ni1 n. Lemma le_app0 : forall ni1 ni21 ni22 : nested_imps, le_ni ni1 (ni21 ++ ni22) -> le_app_spec ni1 (length ni21). (* Goal: forall (ni1 ni21 ni22 : nested_imps) (_ : le_ni ni1 (@app nested_imp ni21 ni22)), le_app_spec ni1 (@length nested_imp ni21) *) intros ni1 ni21 ni22. (* Goal: forall _ : le_ni ni1 (@app nested_imp ni21 ni22), le_app_spec ni1 (@length nested_imp ni21) *) generalize ni1; clear ni1. (* Goal: forall (ni1 : nested_imps) (_ : le_ni ni1 (@app nested_imp ni21 ni22)), le_app_spec ni1 (@length nested_imp ni21) *) elim ni21; clear ni21. (* Goal: forall (ni1 : nested_imps) (_ : le_ni ni1 (@app nested_imp (@nil nested_imp) ni22)), le_app_spec ni1 (@length nested_imp (@nil nested_imp)) *) (* Goal: forall (a : nested_imp) (l : list nested_imp) (_ : forall (ni1 : nested_imps) (_ : le_ni ni1 (@app nested_imp l ni22)), le_app_spec ni1 (@length nested_imp l)) (ni1 : nested_imps) (_ : le_ni ni1 (@app nested_imp (@cons nested_imp a l) ni22)), le_app_spec ni1 (@length nested_imp (@cons nested_imp a l)) *) simpl in |- *; intros ni1 le. (* Goal: le_app_spec ni1 O *) (* Goal: forall (a : nested_imp) (l : list nested_imp) (_ : forall (ni1 : nested_imps) (_ : le_ni ni1 (@app nested_imp l ni22)), le_app_spec ni1 (@length nested_imp l)) (ni1 : nested_imps) (_ : le_ni ni1 (@app nested_imp (@cons nested_imp a l) ni22)), le_app_spec ni1 (@length nested_imp (@cons nested_imp a l)) *) exists NNil ni1. (* Goal: @Logic.eq nested_imps (@cons nested_imp x' (@app nested_imp ni11 ni12)) (@app nested_imp (@cons nested_imp x' ni11) ni12) *) (* Goal: @Logic.eq nat (@length nested_imp (@cons nested_imp x' ni11)) (S (@length nested_imp ni21)) *) (* Goal: le_ni ni1 (@app nested_imp ni21 ni22) *) trivial. (* Goal: @Logic.eq nested_imps (@cons nested_imp x' (@app nested_imp ni11 ni12)) (@app nested_imp (@cons nested_imp x' ni11) ni12) *) (* Goal: @Logic.eq nat (@length nested_imp (@cons nested_imp x' ni11)) (S (@length nested_imp ni21)) *) (* Goal: le_ni ni1 (@app nested_imp ni21 ni22) *) trivial. (* Goal: forall (a : nested_imp) (l : list nested_imp) (_ : forall (ni1 : nested_imps) (_ : le_ni ni1 (@app nested_imp l ni22)), le_app_spec ni1 (@length nested_imp l)) (ni1 : nested_imps) (_ : le_ni ni1 (@app nested_imp (@cons nested_imp a l) ni22)), le_app_spec ni1 (@length nested_imp (@cons nested_imp a l)) *) intros x ni21 ih ni1. (* Goal: forall _ : le_ni ni1 (@app nested_imp (@cons nested_imp x ni21) ni22), le_app_spec ni1 (@length nested_imp (@cons nested_imp x ni21)) *) case ni1; clear ni1. (* Goal: forall _ : le_ni (@nil nested_imp) (@app nested_imp (@cons nested_imp x ni21) ni22), le_app_spec (@nil nested_imp) (@length nested_imp (@cons nested_imp x ni21)) *) (* Goal: forall (n : nested_imp) (l : list nested_imp) (_ : le_ni (@cons nested_imp n l) (@app nested_imp (@cons nested_imp x ni21) ni22)), le_app_spec (@cons nested_imp n l) (@length nested_imp (@cons nested_imp x ni21)) *) intros le; elimtype False; inversion_clear le. (* Goal: forall (n : nested_imp) (l : list nested_imp) (_ : le_ni (@cons nested_imp n l) (@app nested_imp (@cons nested_imp x ni21) ni22)), le_app_spec (@cons nested_imp n l) (@length nested_imp (@cons nested_imp x ni21)) *) simpl in |- *; intros x' ni1 le1. (* Goal: le_app_spec (@cons nested_imp x' ni1) (S (@length nested_imp ni21)) *) elim (ih ni1); clear ih. (* Goal: forall (ni11 ni12 : nested_imps) (_ : @eq nested_imps ni1 (@app nested_imp ni11 ni12)) (_ : @eq nat (@length nested_imp ni11) (@length nested_imp ni21)), le_app_spec (@cons nested_imp x' ni1) (S (@length nested_imp ni21)) *) (* Goal: le_ni ni1 (@app nested_imp ni21 ni22) *) intros ni11 ni12 eq len. (* Goal: le_app_spec (@cons nested_imp x' ni1) (S (@length nested_imp ni21)) *) (* Goal: le_ni ni1 (@app nested_imp ni21 ni22) *) exists (x' :: ni11) ni12. (* Goal: @Logic.eq nested_imps (@cons nested_imp x' ni1) (@app nested_imp (@cons nested_imp x' ni11) ni12) *) (* Goal: @Logic.eq nat (@length nested_imp (@cons nested_imp x' ni11)) (S (@length nested_imp ni21)) *) (* Goal: le_ni ni1 (@app nested_imp ni21 ni22) *) rewrite eq. (* Goal: @Logic.eq nested_imps (@cons nested_imp x' (@app nested_imp ni11 ni12)) (@app nested_imp (@cons nested_imp x' ni11) ni12) *) (* Goal: @Logic.eq nat (@length nested_imp (@cons nested_imp x' ni11)) (S (@length nested_imp ni21)) *) (* Goal: le_ni ni1 (@app nested_imp ni21 ni22) *) trivial. (* Goal: @Logic.eq nat (@length nested_imp (@cons nested_imp x' ni11)) (S (@length nested_imp ni21)) *) (* Goal: le_ni ni1 (@app nested_imp ni21 ni22) *) simpl in |- *. (* Goal: @Logic.eq nested_imps (@cons nested_imp x' (@app nested_imp ni11 ni12)) (@app nested_imp (@cons nested_imp x' ni11) ni12) *) (* Goal: @Logic.eq nat (@length nested_imp (@cons nested_imp x' ni11)) (S (@length nested_imp ni21)) *) (* Goal: le_ni ni1 (@app nested_imp ni21 ni22) *) rewrite len; trivial. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) inversion_clear le1; assumption. Qed. Lemma le_ni_app_nn : forall (ni1 ni2 ni3 ni4 : nested_imps) (x : nimp), length ni1 = length ni3 -> le_ni (ni1 ++ ni2) (ni3 ++ ni4) -> le_ni (ni1 ++ Undecorated x :: ni2) (ni3 ++ Undecorated x :: ni4). (* Goal: forall (ni1 ni2 ni3 ni4 : nested_imps) (x : nimp) (_ : @eq nat (@length nested_imp ni1) (@length nested_imp ni3)) (_ : le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4)), le_ni (@app nested_imp ni1 (@cons nested_imp (Undecorated x) ni2)) (@app nested_imp ni3 (@cons nested_imp (Undecorated x) ni4)) *) intros ni1 ni2 ni3 ni4 x. (* Goal: forall (_ : @eq nat (@length nested_imp ni1) (@length nested_imp ni3)) (_ : le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4)), le_ni (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4)) *) generalize ni3; clear ni3. (* Goal: forall (ni3 : nested_imps) (_ : @eq nat (@length nested_imp ni1) (@length nested_imp ni3)) (_ : le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4)), le_ni (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4)) *) elim ni1; clear ni1. (* Goal: forall (ni3 : nested_imps) (_ : @eq nat (@length nested_imp (@cons nested_imp y ni1)) (@length nested_imp ni3)) (_ : le_ni (@app nested_imp (@cons nested_imp y ni1) ni2) (@app nested_imp ni3 ni4)), le_ni (@app nested_imp (@cons nested_imp y ni1) (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4)) *) intros ni3; case ni3; clear ni3. (* Goal: forall (_ : @eq nat (@length nested_imp (@nil nested_imp)) (@length nested_imp (@nil nested_imp))) (_ : le_ni (@app nested_imp (@nil nested_imp) ni2) (@app nested_imp (@nil nested_imp) ni4)), le_ni (@app nested_imp (@nil nested_imp) (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp (@nil nested_imp) (@cons nested_imp (Decorated x k) ni4)) *) (* Goal: forall (n : nested_imp) (l : list nested_imp) (_ : @eq nat (@length nested_imp (@nil nested_imp)) (@length nested_imp (@cons nested_imp n l))) (_ : le_ni (@app nested_imp (@nil nested_imp) ni2) (@app nested_imp (@cons nested_imp n l) ni4)), le_ni (@app nested_imp (@nil nested_imp) (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp (@cons nested_imp n l) (@cons nested_imp (Decorated x k) ni4)) *) (* Goal: forall (a : nested_imp) (l : list nested_imp) (_ : forall (ni3 : nested_imps) (_ : @eq nat (@length nested_imp l) (@length nested_imp ni3)) (_ : le_ni (@app nested_imp l ni2) (@app nested_imp ni3 ni4)), le_ni (@app nested_imp l (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4))) (ni3 : nested_imps) (_ : @eq nat (@length nested_imp (@cons nested_imp a l)) (@length nested_imp ni3)) (_ : le_ni (@app nested_imp (@cons nested_imp a l) ni2) (@app nested_imp ni3 ni4)), le_ni (@app nested_imp (@cons nested_imp a l) (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4)) *) simpl in |- *; intros len le. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) apply Le_NI_Cons_NN; assumption. (* Goal: forall (n : nested_imp) (l : list nested_imp) (_ : @eq nat (@length nested_imp (@nil nested_imp)) (@length nested_imp (@cons nested_imp n l))) (_ : le_ni (@app nested_imp (@nil nested_imp) ni2) (@app nested_imp (@cons nested_imp n l) ni4)), le_ni (@app nested_imp (@nil nested_imp) (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp (@cons nested_imp n l) (@cons nested_imp (Decorated x k) ni4)) *) (* Goal: forall (a : nested_imp) (l : list nested_imp) (_ : forall (ni3 : nested_imps) (_ : @eq nat (@length nested_imp l) (@length nested_imp ni3)) (_ : le_ni (@app nested_imp l ni2) (@app nested_imp ni3 ni4)), le_ni (@app nested_imp l (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4))) (ni3 : nested_imps) (_ : @eq nat (@length nested_imp (@cons nested_imp a l)) (@length nested_imp ni3)) (_ : le_ni (@app nested_imp (@cons nested_imp a l) ni2) (@app nested_imp ni3 ni4)), le_ni (@app nested_imp (@cons nested_imp a l) (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4)) *) intros y ni3 len le. (* Goal: le_ni (@app nested_imp (@nil nested_imp) (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp (@cons nested_imp y ni3) (@cons nested_imp (Decorated x k) ni4)) *) (* Goal: forall (a : nested_imp) (l : list nested_imp) (_ : forall (ni3 : nested_imps) (_ : @eq nat (@length nested_imp l) (@length nested_imp ni3)) (_ : le_ni (@app nested_imp l ni2) (@app nested_imp ni3 ni4)), le_ni (@app nested_imp l (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4))) (ni3 : nested_imps) (_ : @eq nat (@length nested_imp (@cons nested_imp a l)) (@length nested_imp ni3)) (_ : le_ni (@app nested_imp (@cons nested_imp a l) ni2) (@app nested_imp ni3 ni4)), le_ni (@app nested_imp (@cons nested_imp a l) (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4)) *) inversion_clear len. (* Goal: forall (a : nested_imp) (l : list nested_imp) (_ : forall (ni3 : nested_imps) (_ : @eq nat (@length nested_imp l) (@length nested_imp ni3)) (_ : le_ni (@app nested_imp l ni2) (@app nested_imp ni3 ni4)), le_ni (@app nested_imp l (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4))) (ni3 : nested_imps) (_ : @eq nat (@length nested_imp (@cons nested_imp a l)) (@length nested_imp ni3)) (_ : le_ni (@app nested_imp (@cons nested_imp a l) ni2) (@app nested_imp ni3 ni4)), le_ni (@app nested_imp (@cons nested_imp a l) (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4)) *) intros y ni1 ih. (* Goal: forall (ni3 : nested_imps) (_ : @eq nat (@length nested_imp (@cons nested_imp y ni1)) (@length nested_imp ni3)) (_ : le_ni (@app nested_imp (@cons nested_imp y ni1) ni2) (@app nested_imp ni3 ni4)), le_ni (@app nested_imp (@cons nested_imp y ni1) (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4)) *) intros ni3; case ni3; clear ni3. (* Goal: le_ni (@app nested_imp (@nil nested_imp) (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp (@cons nested_imp y ni3) (@cons nested_imp (Decorated x k) ni4)) *) (* Goal: forall (a : nested_imp) (l : list nested_imp) (_ : forall (ni3 : nested_imps) (_ : @eq nat (@length nested_imp l) (@length nested_imp ni3)) (_ : le_ni (@app nested_imp l ni2) (@app nested_imp ni3 ni4)), le_ni (@app nested_imp l (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4))) (ni3 : nested_imps) (_ : @eq nat (@length nested_imp (@cons nested_imp a l)) (@length nested_imp ni3)) (_ : le_ni (@app nested_imp (@cons nested_imp a l) ni2) (@app nested_imp ni3 ni4)), le_ni (@app nested_imp (@cons nested_imp a l) (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4)) *) simpl in |- *; intros len le; inversion_clear len. (* Goal: forall (n : nested_imp) (l : list nested_imp) (_ : @eq nat (@length nested_imp (@cons nested_imp y ni1)) (@length nested_imp (@cons nested_imp n l))) (_ : le_ni (@app nested_imp (@cons nested_imp y ni1) ni2) (@app nested_imp (@cons nested_imp n l) ni4)), le_ni (@app nested_imp (@cons nested_imp y ni1) (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp (@cons nested_imp n l) (@cons nested_imp (Decorated x k) ni4)) *) simpl in |- *; intros y' ni3 len le. (* Goal: le_ni (@cons nested_imp y (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2))) (@cons nested_imp y' (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4))) *) inversion_clear le. (* Goal: le_ni (@cons nested_imp (Undecorated x0) (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2))) (@cons nested_imp (Undecorated x0) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4))) *) (* Goal: le_ni (@cons nested_imp (Decorated x0 k0) (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2))) (@cons nested_imp (Undecorated x0) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4))) *) (* Goal: le_ni (@cons nested_imp (Decorated x0 k0) (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2))) (@cons nested_imp (Decorated x0 k0) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4))) *) apply Le_NI_Cons_NN. (* Goal: le_ni (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4)) *) apply ih. (* Goal: forall (ni3 : nested_imps) (_ : eqv_ni NNil ni3), eqv_ni NNil ni3 *) (* Goal: forall (x : nimp) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Undecorated x) ni2) ni3), eqv_ni (@cons nested_imp (Undecorated x) ni1) ni3 *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Undecorated x) ni2) ni3), eqv_ni (@cons nested_imp (Decorated x k) ni1) ni3 *) (* Goal: forall (x : nimp) (k k' : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Decorated x k') ni2) ni3), eqv_ni (@cons nested_imp (Decorated x k) ni1) ni3 *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Decorated x k) ni2) ni3), eqv_ni (@cons nested_imp (Undecorated x) ni1) ni3 *) injection len; intros; assumption. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) assumption. (* Goal: le_ni (@cons nested_imp (Decorated x0 k0) (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2))) (@cons nested_imp (Undecorated x0) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4))) *) (* Goal: le_ni (@cons nested_imp (Decorated x0 k0) (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2))) (@cons nested_imp (Decorated x0 k0) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4))) *) apply Le_NI_Cons_DN. (* Goal: le_ni (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4)) *) apply ih. (* Goal: forall (ni3 : nested_imps) (_ : eqv_ni NNil ni3), eqv_ni NNil ni3 *) (* Goal: forall (x : nimp) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Undecorated x) ni2) ni3), eqv_ni (@cons nested_imp (Undecorated x) ni1) ni3 *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Undecorated x) ni2) ni3), eqv_ni (@cons nested_imp (Decorated x k) ni1) ni3 *) (* Goal: forall (x : nimp) (k k' : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Decorated x k') ni2) ni3), eqv_ni (@cons nested_imp (Decorated x k) ni1) ni3 *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Decorated x k) ni2) ni3), eqv_ni (@cons nested_imp (Undecorated x) ni1) ni3 *) injection len; intros; assumption. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) assumption. (* Goal: le_ni (@cons nested_imp (Decorated x0 k0) (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2))) (@cons nested_imp (Decorated x0 k0) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4))) *) apply Le_NI_Cons_DD. (* Goal: le_ni (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4)) *) apply ih. (* Goal: forall (ni3 : nested_imps) (_ : eqv_ni NNil ni3), eqv_ni NNil ni3 *) (* Goal: forall (x : nimp) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Undecorated x) ni2) ni3), eqv_ni (@cons nested_imp (Undecorated x) ni1) ni3 *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Undecorated x) ni2) ni3), eqv_ni (@cons nested_imp (Decorated x k) ni1) ni3 *) (* Goal: forall (x : nimp) (k k' : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Decorated x k') ni2) ni3), eqv_ni (@cons nested_imp (Decorated x k) ni1) ni3 *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Decorated x k) ni2) ni3), eqv_ni (@cons nested_imp (Undecorated x) ni1) ni3 *) injection len; intros; assumption. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) assumption. Qed. Lemma le_ni_app_dn : forall (ni1 ni2 ni3 ni4 : nested_imps) (x : nimp) (k : kripke_tree), length ni1 = length ni3 -> le_ni (ni1 ++ ni2) (ni3 ++ ni4) -> le_ni (ni1 ++ Decorated x k :: ni2) (ni3 ++ Undecorated x :: ni4). (* Goal: forall (ni1 ni2 ni3 ni4 : nested_imps) (x : nimp) (k : kripke_tree) (_ : @eq nat (@length nested_imp ni1) (@length nested_imp ni3)) (_ : le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4)), le_ni (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4)) *) intros ni1 ni2 ni3 ni4 x k. (* Goal: forall (_ : @eq nat (@length nested_imp ni1) (@length nested_imp ni3)) (_ : le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4)), le_ni (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4)) *) generalize ni3; clear ni3. (* Goal: forall (ni3 : nested_imps) (_ : @eq nat (@length nested_imp ni1) (@length nested_imp ni3)) (_ : le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4)), le_ni (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4)) *) elim ni1; clear ni1. (* Goal: forall (ni3 : nested_imps) (_ : @eq nat (@length nested_imp (@cons nested_imp y ni1)) (@length nested_imp ni3)) (_ : le_ni (@app nested_imp (@cons nested_imp y ni1) ni2) (@app nested_imp ni3 ni4)), le_ni (@app nested_imp (@cons nested_imp y ni1) (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4)) *) intros ni3; case ni3; clear ni3. (* Goal: forall (_ : @eq nat (@length nested_imp (@nil nested_imp)) (@length nested_imp (@nil nested_imp))) (_ : le_ni (@app nested_imp (@nil nested_imp) ni2) (@app nested_imp (@nil nested_imp) ni4)), le_ni (@app nested_imp (@nil nested_imp) (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp (@nil nested_imp) (@cons nested_imp (Decorated x k) ni4)) *) (* Goal: forall (n : nested_imp) (l : list nested_imp) (_ : @eq nat (@length nested_imp (@nil nested_imp)) (@length nested_imp (@cons nested_imp n l))) (_ : le_ni (@app nested_imp (@nil nested_imp) ni2) (@app nested_imp (@cons nested_imp n l) ni4)), le_ni (@app nested_imp (@nil nested_imp) (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp (@cons nested_imp n l) (@cons nested_imp (Decorated x k) ni4)) *) (* Goal: forall (a : nested_imp) (l : list nested_imp) (_ : forall (ni3 : nested_imps) (_ : @eq nat (@length nested_imp l) (@length nested_imp ni3)) (_ : le_ni (@app nested_imp l ni2) (@app nested_imp ni3 ni4)), le_ni (@app nested_imp l (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4))) (ni3 : nested_imps) (_ : @eq nat (@length nested_imp (@cons nested_imp a l)) (@length nested_imp ni3)) (_ : le_ni (@app nested_imp (@cons nested_imp a l) ni2) (@app nested_imp ni3 ni4)), le_ni (@app nested_imp (@cons nested_imp a l) (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4)) *) simpl in |- *; intros len le. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) apply Le_NI_Cons_DN; assumption. (* Goal: forall (n : nested_imp) (l : list nested_imp) (_ : @eq nat (@length nested_imp (@nil nested_imp)) (@length nested_imp (@cons nested_imp n l))) (_ : le_ni (@app nested_imp (@nil nested_imp) ni2) (@app nested_imp (@cons nested_imp n l) ni4)), le_ni (@app nested_imp (@nil nested_imp) (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp (@cons nested_imp n l) (@cons nested_imp (Decorated x k) ni4)) *) (* Goal: forall (a : nested_imp) (l : list nested_imp) (_ : forall (ni3 : nested_imps) (_ : @eq nat (@length nested_imp l) (@length nested_imp ni3)) (_ : le_ni (@app nested_imp l ni2) (@app nested_imp ni3 ni4)), le_ni (@app nested_imp l (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4))) (ni3 : nested_imps) (_ : @eq nat (@length nested_imp (@cons nested_imp a l)) (@length nested_imp ni3)) (_ : le_ni (@app nested_imp (@cons nested_imp a l) ni2) (@app nested_imp ni3 ni4)), le_ni (@app nested_imp (@cons nested_imp a l) (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4)) *) intros y ni3 len le. (* Goal: le_ni (@app nested_imp (@nil nested_imp) (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp (@cons nested_imp y ni3) (@cons nested_imp (Decorated x k) ni4)) *) (* Goal: forall (a : nested_imp) (l : list nested_imp) (_ : forall (ni3 : nested_imps) (_ : @eq nat (@length nested_imp l) (@length nested_imp ni3)) (_ : le_ni (@app nested_imp l ni2) (@app nested_imp ni3 ni4)), le_ni (@app nested_imp l (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4))) (ni3 : nested_imps) (_ : @eq nat (@length nested_imp (@cons nested_imp a l)) (@length nested_imp ni3)) (_ : le_ni (@app nested_imp (@cons nested_imp a l) ni2) (@app nested_imp ni3 ni4)), le_ni (@app nested_imp (@cons nested_imp a l) (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4)) *) inversion_clear len. (* Goal: forall (a : nested_imp) (l : list nested_imp) (_ : forall (ni3 : nested_imps) (_ : @eq nat (@length nested_imp l) (@length nested_imp ni3)) (_ : le_ni (@app nested_imp l ni2) (@app nested_imp ni3 ni4)), le_ni (@app nested_imp l (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4))) (ni3 : nested_imps) (_ : @eq nat (@length nested_imp (@cons nested_imp a l)) (@length nested_imp ni3)) (_ : le_ni (@app nested_imp (@cons nested_imp a l) ni2) (@app nested_imp ni3 ni4)), le_ni (@app nested_imp (@cons nested_imp a l) (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4)) *) intros y ni1 ih. (* Goal: forall (ni3 : nested_imps) (_ : @eq nat (@length nested_imp (@cons nested_imp y ni1)) (@length nested_imp ni3)) (_ : le_ni (@app nested_imp (@cons nested_imp y ni1) ni2) (@app nested_imp ni3 ni4)), le_ni (@app nested_imp (@cons nested_imp y ni1) (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4)) *) intros ni3; case ni3; clear ni3. (* Goal: le_ni (@app nested_imp (@nil nested_imp) (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp (@cons nested_imp y ni3) (@cons nested_imp (Decorated x k) ni4)) *) (* Goal: forall (a : nested_imp) (l : list nested_imp) (_ : forall (ni3 : nested_imps) (_ : @eq nat (@length nested_imp l) (@length nested_imp ni3)) (_ : le_ni (@app nested_imp l ni2) (@app nested_imp ni3 ni4)), le_ni (@app nested_imp l (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4))) (ni3 : nested_imps) (_ : @eq nat (@length nested_imp (@cons nested_imp a l)) (@length nested_imp ni3)) (_ : le_ni (@app nested_imp (@cons nested_imp a l) ni2) (@app nested_imp ni3 ni4)), le_ni (@app nested_imp (@cons nested_imp a l) (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4)) *) simpl in |- *; intros len le; inversion_clear len. (* Goal: forall (n : nested_imp) (l : list nested_imp) (_ : @eq nat (@length nested_imp (@cons nested_imp y ni1)) (@length nested_imp (@cons nested_imp n l))) (_ : le_ni (@app nested_imp (@cons nested_imp y ni1) ni2) (@app nested_imp (@cons nested_imp n l) ni4)), le_ni (@app nested_imp (@cons nested_imp y ni1) (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp (@cons nested_imp n l) (@cons nested_imp (Decorated x k) ni4)) *) simpl in |- *; intros y' ni3 len le. (* Goal: le_ni (@cons nested_imp y (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2))) (@cons nested_imp y' (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4))) *) inversion_clear le. (* Goal: le_ni (@cons nested_imp (Undecorated x0) (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2))) (@cons nested_imp (Undecorated x0) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4))) *) (* Goal: le_ni (@cons nested_imp (Decorated x0 k0) (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2))) (@cons nested_imp (Undecorated x0) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4))) *) (* Goal: le_ni (@cons nested_imp (Decorated x0 k0) (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2))) (@cons nested_imp (Decorated x0 k0) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4))) *) apply Le_NI_Cons_NN. (* Goal: le_ni (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4)) *) apply ih. (* Goal: forall (ni3 : nested_imps) (_ : eqv_ni NNil ni3), eqv_ni NNil ni3 *) (* Goal: forall (x : nimp) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Undecorated x) ni2) ni3), eqv_ni (@cons nested_imp (Undecorated x) ni1) ni3 *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Undecorated x) ni2) ni3), eqv_ni (@cons nested_imp (Decorated x k) ni1) ni3 *) (* Goal: forall (x : nimp) (k k' : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Decorated x k') ni2) ni3), eqv_ni (@cons nested_imp (Decorated x k) ni1) ni3 *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Decorated x k) ni2) ni3), eqv_ni (@cons nested_imp (Undecorated x) ni1) ni3 *) injection len; intros; assumption. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) assumption. (* Goal: le_ni (@cons nested_imp (Decorated x0 k0) (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2))) (@cons nested_imp (Undecorated x0) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4))) *) (* Goal: le_ni (@cons nested_imp (Decorated x0 k0) (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2))) (@cons nested_imp (Decorated x0 k0) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4))) *) apply Le_NI_Cons_DN. (* Goal: le_ni (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4)) *) apply ih. (* Goal: forall (ni3 : nested_imps) (_ : eqv_ni NNil ni3), eqv_ni NNil ni3 *) (* Goal: forall (x : nimp) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Undecorated x) ni2) ni3), eqv_ni (@cons nested_imp (Undecorated x) ni1) ni3 *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Undecorated x) ni2) ni3), eqv_ni (@cons nested_imp (Decorated x k) ni1) ni3 *) (* Goal: forall (x : nimp) (k k' : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Decorated x k') ni2) ni3), eqv_ni (@cons nested_imp (Decorated x k) ni1) ni3 *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Decorated x k) ni2) ni3), eqv_ni (@cons nested_imp (Undecorated x) ni1) ni3 *) injection len; intros; assumption. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) assumption. (* Goal: le_ni (@cons nested_imp (Decorated x0 k0) (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2))) (@cons nested_imp (Decorated x0 k0) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4))) *) apply Le_NI_Cons_DD. (* Goal: le_ni (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4)) *) apply ih. (* Goal: forall (ni3 : nested_imps) (_ : eqv_ni NNil ni3), eqv_ni NNil ni3 *) (* Goal: forall (x : nimp) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Undecorated x) ni2) ni3), eqv_ni (@cons nested_imp (Undecorated x) ni1) ni3 *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Undecorated x) ni2) ni3), eqv_ni (@cons nested_imp (Decorated x k) ni1) ni3 *) (* Goal: forall (x : nimp) (k k' : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Decorated x k') ni2) ni3), eqv_ni (@cons nested_imp (Decorated x k) ni1) ni3 *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Decorated x k) ni2) ni3), eqv_ni (@cons nested_imp (Undecorated x) ni1) ni3 *) injection len; intros; assumption. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) assumption. Qed. Lemma le_ni_app_dd : forall (ni1 ni2 ni3 ni4 : nested_imps) (x : nimp) (k : kripke_tree), length ni1 = length ni3 -> le_ni (ni1 ++ ni2) (ni3 ++ ni4) -> le_ni (ni1 ++ Decorated x k :: ni2) (ni3 ++ Decorated x k :: ni4). (* Goal: forall (ni1 ni2 ni3 ni4 : nested_imps) (x : nimp) (k : kripke_tree) (_ : @eq nat (@length nested_imp ni1) (@length nested_imp ni3)) (_ : le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4)), le_ni (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4)) *) intros ni1 ni2 ni3 ni4 x k. (* Goal: forall (_ : @eq nat (@length nested_imp ni1) (@length nested_imp ni3)) (_ : le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4)), le_ni (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4)) *) generalize ni3; clear ni3. (* Goal: forall (ni3 : nested_imps) (_ : @eq nat (@length nested_imp ni1) (@length nested_imp ni3)) (_ : le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4)), le_ni (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4)) *) elim ni1; clear ni1. (* Goal: forall (ni3 : nested_imps) (_ : @eq nat (@length nested_imp (@cons nested_imp y ni1)) (@length nested_imp ni3)) (_ : le_ni (@app nested_imp (@cons nested_imp y ni1) ni2) (@app nested_imp ni3 ni4)), le_ni (@app nested_imp (@cons nested_imp y ni1) (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4)) *) intros ni3; case ni3; clear ni3. (* Goal: forall (_ : @eq nat (@length nested_imp (@nil nested_imp)) (@length nested_imp (@nil nested_imp))) (_ : le_ni (@app nested_imp (@nil nested_imp) ni2) (@app nested_imp (@nil nested_imp) ni4)), le_ni (@app nested_imp (@nil nested_imp) (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp (@nil nested_imp) (@cons nested_imp (Decorated x k) ni4)) *) (* Goal: forall (n : nested_imp) (l : list nested_imp) (_ : @eq nat (@length nested_imp (@nil nested_imp)) (@length nested_imp (@cons nested_imp n l))) (_ : le_ni (@app nested_imp (@nil nested_imp) ni2) (@app nested_imp (@cons nested_imp n l) ni4)), le_ni (@app nested_imp (@nil nested_imp) (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp (@cons nested_imp n l) (@cons nested_imp (Decorated x k) ni4)) *) (* Goal: forall (a : nested_imp) (l : list nested_imp) (_ : forall (ni3 : nested_imps) (_ : @eq nat (@length nested_imp l) (@length nested_imp ni3)) (_ : le_ni (@app nested_imp l ni2) (@app nested_imp ni3 ni4)), le_ni (@app nested_imp l (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4))) (ni3 : nested_imps) (_ : @eq nat (@length nested_imp (@cons nested_imp a l)) (@length nested_imp ni3)) (_ : le_ni (@app nested_imp (@cons nested_imp a l) ni2) (@app nested_imp ni3 ni4)), le_ni (@app nested_imp (@cons nested_imp a l) (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4)) *) simpl in |- *; intros len le. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) apply Le_NI_Cons_DD; assumption. (* Goal: forall (n : nested_imp) (l : list nested_imp) (_ : @eq nat (@length nested_imp (@nil nested_imp)) (@length nested_imp (@cons nested_imp n l))) (_ : le_ni (@app nested_imp (@nil nested_imp) ni2) (@app nested_imp (@cons nested_imp n l) ni4)), le_ni (@app nested_imp (@nil nested_imp) (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp (@cons nested_imp n l) (@cons nested_imp (Decorated x k) ni4)) *) (* Goal: forall (a : nested_imp) (l : list nested_imp) (_ : forall (ni3 : nested_imps) (_ : @eq nat (@length nested_imp l) (@length nested_imp ni3)) (_ : le_ni (@app nested_imp l ni2) (@app nested_imp ni3 ni4)), le_ni (@app nested_imp l (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4))) (ni3 : nested_imps) (_ : @eq nat (@length nested_imp (@cons nested_imp a l)) (@length nested_imp ni3)) (_ : le_ni (@app nested_imp (@cons nested_imp a l) ni2) (@app nested_imp ni3 ni4)), le_ni (@app nested_imp (@cons nested_imp a l) (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4)) *) intros y ni3 len le. (* Goal: le_ni (@app nested_imp (@nil nested_imp) (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp (@cons nested_imp y ni3) (@cons nested_imp (Decorated x k) ni4)) *) (* Goal: forall (a : nested_imp) (l : list nested_imp) (_ : forall (ni3 : nested_imps) (_ : @eq nat (@length nested_imp l) (@length nested_imp ni3)) (_ : le_ni (@app nested_imp l ni2) (@app nested_imp ni3 ni4)), le_ni (@app nested_imp l (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4))) (ni3 : nested_imps) (_ : @eq nat (@length nested_imp (@cons nested_imp a l)) (@length nested_imp ni3)) (_ : le_ni (@app nested_imp (@cons nested_imp a l) ni2) (@app nested_imp ni3 ni4)), le_ni (@app nested_imp (@cons nested_imp a l) (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4)) *) inversion_clear len. (* Goal: forall (a : nested_imp) (l : list nested_imp) (_ : forall (ni3 : nested_imps) (_ : @eq nat (@length nested_imp l) (@length nested_imp ni3)) (_ : le_ni (@app nested_imp l ni2) (@app nested_imp ni3 ni4)), le_ni (@app nested_imp l (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4))) (ni3 : nested_imps) (_ : @eq nat (@length nested_imp (@cons nested_imp a l)) (@length nested_imp ni3)) (_ : le_ni (@app nested_imp (@cons nested_imp a l) ni2) (@app nested_imp ni3 ni4)), le_ni (@app nested_imp (@cons nested_imp a l) (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4)) *) intros y ni1 ih. (* Goal: forall (ni3 : nested_imps) (_ : @eq nat (@length nested_imp (@cons nested_imp y ni1)) (@length nested_imp ni3)) (_ : le_ni (@app nested_imp (@cons nested_imp y ni1) ni2) (@app nested_imp ni3 ni4)), le_ni (@app nested_imp (@cons nested_imp y ni1) (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4)) *) intros ni3; case ni3; clear ni3. (* Goal: le_ni (@app nested_imp (@nil nested_imp) (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp (@cons nested_imp y ni3) (@cons nested_imp (Decorated x k) ni4)) *) (* Goal: forall (a : nested_imp) (l : list nested_imp) (_ : forall (ni3 : nested_imps) (_ : @eq nat (@length nested_imp l) (@length nested_imp ni3)) (_ : le_ni (@app nested_imp l ni2) (@app nested_imp ni3 ni4)), le_ni (@app nested_imp l (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4))) (ni3 : nested_imps) (_ : @eq nat (@length nested_imp (@cons nested_imp a l)) (@length nested_imp ni3)) (_ : le_ni (@app nested_imp (@cons nested_imp a l) ni2) (@app nested_imp ni3 ni4)), le_ni (@app nested_imp (@cons nested_imp a l) (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4)) *) simpl in |- *; intros len le; inversion_clear len. (* Goal: forall (n : nested_imp) (l : list nested_imp) (_ : @eq nat (@length nested_imp (@cons nested_imp y ni1)) (@length nested_imp (@cons nested_imp n l))) (_ : le_ni (@app nested_imp (@cons nested_imp y ni1) ni2) (@app nested_imp (@cons nested_imp n l) ni4)), le_ni (@app nested_imp (@cons nested_imp y ni1) (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp (@cons nested_imp n l) (@cons nested_imp (Decorated x k) ni4)) *) simpl in |- *; intros y' ni3 len le. (* Goal: le_ni (@cons nested_imp y (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2))) (@cons nested_imp y' (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4))) *) inversion_clear le. (* Goal: le_ni (@cons nested_imp (Undecorated x0) (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2))) (@cons nested_imp (Undecorated x0) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4))) *) (* Goal: le_ni (@cons nested_imp (Decorated x0 k0) (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2))) (@cons nested_imp (Undecorated x0) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4))) *) (* Goal: le_ni (@cons nested_imp (Decorated x0 k0) (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2))) (@cons nested_imp (Decorated x0 k0) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4))) *) apply Le_NI_Cons_NN. (* Goal: le_ni (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4)) *) apply ih. (* Goal: forall (ni3 : nested_imps) (_ : eqv_ni NNil ni3), eqv_ni NNil ni3 *) (* Goal: forall (x : nimp) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Undecorated x) ni2) ni3), eqv_ni (@cons nested_imp (Undecorated x) ni1) ni3 *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Undecorated x) ni2) ni3), eqv_ni (@cons nested_imp (Decorated x k) ni1) ni3 *) (* Goal: forall (x : nimp) (k k' : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Decorated x k') ni2) ni3), eqv_ni (@cons nested_imp (Decorated x k) ni1) ni3 *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Decorated x k) ni2) ni3), eqv_ni (@cons nested_imp (Undecorated x) ni1) ni3 *) injection len; intros; assumption. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) assumption. (* Goal: le_ni (@cons nested_imp (Decorated x0 k0) (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2))) (@cons nested_imp (Undecorated x0) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4))) *) (* Goal: le_ni (@cons nested_imp (Decorated x0 k0) (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2))) (@cons nested_imp (Decorated x0 k0) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4))) *) apply Le_NI_Cons_DN. (* Goal: le_ni (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4)) *) apply ih. (* Goal: forall (ni3 : nested_imps) (_ : eqv_ni NNil ni3), eqv_ni NNil ni3 *) (* Goal: forall (x : nimp) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Undecorated x) ni2) ni3), eqv_ni (@cons nested_imp (Undecorated x) ni1) ni3 *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Undecorated x) ni2) ni3), eqv_ni (@cons nested_imp (Decorated x k) ni1) ni3 *) (* Goal: forall (x : nimp) (k k' : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Decorated x k') ni2) ni3), eqv_ni (@cons nested_imp (Decorated x k) ni1) ni3 *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Decorated x k) ni2) ni3), eqv_ni (@cons nested_imp (Undecorated x) ni1) ni3 *) injection len; intros; assumption. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) assumption. (* Goal: le_ni (@cons nested_imp (Decorated x0 k0) (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2))) (@cons nested_imp (Decorated x0 k0) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4))) *) apply Le_NI_Cons_DD. (* Goal: le_ni (@app nested_imp ni1 (@cons nested_imp (Decorated x k) ni2)) (@app nested_imp ni3 (@cons nested_imp (Decorated x k) ni4)) *) apply ih. (* Goal: forall (ni3 : nested_imps) (_ : eqv_ni NNil ni3), eqv_ni NNil ni3 *) (* Goal: forall (x : nimp) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Undecorated x) ni2) ni3), eqv_ni (@cons nested_imp (Undecorated x) ni1) ni3 *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Undecorated x) ni2) ni3), eqv_ni (@cons nested_imp (Decorated x k) ni1) ni3 *) (* Goal: forall (x : nimp) (k k' : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Decorated x k') ni2) ni3), eqv_ni (@cons nested_imp (Decorated x k) ni1) ni3 *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : forall (ni3 : nested_imps) (_ : eqv_ni ni2 ni3), eqv_ni ni1 ni3) (ni3 : nested_imps) (_ : eqv_ni (@cons nested_imp (Decorated x k) ni2) ni3), eqv_ni (@cons nested_imp (Undecorated x) ni1) ni3 *) injection len; intros; assumption. (* Goal: le_ni (@app nested_imp ni1 ni2) (@app nested_imp ni3 ni4) *) assumption. Qed.
(* File: NSearch.v (last edited on 27/10/2000) (c) Klaus Weich *) Require Export Disjunct. Require Export NWeight. Require Export Lt_Ks. Require Export NRules. Definition nsearch_invariant (n : nat) := forall (goal : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist), nweight_Sequent work ds ni ai < n -> REGULAR normal_form ai -> a_ai_disj a ai -> a_goal_disj a goal -> nsearch_spec goal work ds ni ai a context. Lemma nsearch_aux : forall n : nat, nsearch_invariant n. (* Goal: forall n : nat, nsearch_invariant n *) intros n; elim n; clear n. (* n=0 *) (* Goal: nsearch_invariant (S n) *) unfold nsearch_invariant in |- *. (* Goal: forall (goal : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist) (_ : lt (nweight_Sequent work ds ni ai) O) (_ : REGULAR normal_form ai) (_ : a_ai_disj a ai) (_ : a_goal_disj a goal), nsearch_spec goal work ds ni ai a context *) (* Goal: forall (n : nat) (_ : nsearch_invariant n), nsearch_invariant (S n) *) intros goal work ds ni ai a context lt_nweight ai_reg a_ai_disj a_goal_disj. (* Goal: nsearch_spec goal work ds ni ai a context *) (* Goal: forall (n : nat) (_ : nsearch_invariant n), nsearch_invariant (S n) *) elimtype False. (* Goal: False *) (* Goal: forall (n : nat) (_ : nsearch_invariant n), nsearch_invariant (S n) *) apply (lt_n_O (nweight_Sequent work ds ni ai)); assumption. (* n>0 *) (* Goal: forall (n : nat) (_ : nsearch_invariant n), nsearch_invariant (S n) *) intros n ih_n. (* Goal: nsearch_invariant (S n) *) unfold nsearch_invariant in |- *. (* Goal: forall (goal : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist) (_ : lt (nweight_Sequent work ds ni ai) (S n)) (_ : REGULAR normal_form ai) (_ : a_ai_disj a ai) (_ : a_goal_disj a goal), nsearch_spec goal work ds ni ai a context *) intros goal work ds ni ai a. (* Goal: forall (context : flist) (_ : lt (nweight_Sequent work ds ni ai) (S n)) (_ : REGULAR normal_form ai) (_ : a_ai_disj a ai) (_ : a_goal_disj a goal), nsearch_spec goal work ds ni ai a context *) elim ai; clear ai. (* Goal: forall (t : avl_tree nf_list) (i : is_avl nf_list t) (context : flist) (_ : lt (nweight_Sequent work ds ni (AVL_intro nf_list t i)) (S n)) (_ : REGULAR normal_form (AVL_intro nf_list t i)) (_ : a_ai_disj a (AVL_intro nf_list t i)) (_ : a_goal_disj a goal), nsearch_spec goal work ds ni (AVL_intro nf_list t i) a context *) intros ai avl_ai. (* Goal: forall (context : flist) (_ : lt (nweight_Sequent work ds ni (AVL_intro nf_list ai avl_ai)) (S n)) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_ai_disj a (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj a goal), nsearch_spec goal work ds ni (AVL_intro nf_list ai avl_ai) a context *) elim a; clear a. (* Goal: forall (t : avl_tree unit) (i : is_avl unit t) (context : flist) (_ : lt (nweight_Sequent work ds ni (AVL_intro nf_list ai avl_ai)) (S n)) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_ai_disj (AVL_intro unit t i) (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit t i) goal), nsearch_spec goal work ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit t i) context *) intros a avl_a. (* Goal: forall (context : flist) (_ : lt (nweight_Sequent work ds ni (AVL_intro nf_list ai avl_ai)) (S n)) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_ai_disj (AVL_intro unit a avl_a) (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a avl_a) goal), nsearch_spec goal work ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) intros context lt_nweight ai_reg a_ai_disj a_goal_disj. generalize ds ni ai avl_ai a avl_a ai_reg a_goal_disj a_ai_disj lt_nweight; clear lt_nweight ai_reg a_ai_disj a_goal_disj avl_ai avl_a ds ni ai a. (* Goal: forall (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a : avl_tree unit) (avl_a : is_avl unit a) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a avl_a) goal) (_ : a_ai_disj (AVL_intro unit a avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent work ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal work ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) elim work; clear work. (* work=nf_nil *) (* Goal: forall (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a : avl_tree unit) (avl_a : is_avl unit a) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a avl_a) goal) (_ : a_ai_disj (AVL_intro unit a avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent (@nil normal_form) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@nil normal_form) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (a : normal_form) (l : list normal_form) (_ : forall (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent l ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal l ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context) (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context *) fold nf_nil in |- *. (* Goal: forall (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a : avl_tree unit) (avl_a : is_avl unit a) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a avl_a) goal) (_ : a_ai_disj (AVL_intro unit a avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent nf_nil ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (a : normal_form) (l : list normal_form) (_ : forall (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent l ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal l ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context) (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context *) intros ds; case ds; clear ds. (* ds=nil *) (* Goal: forall (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a : avl_tree unit) (avl_a : is_avl unit a) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a avl_a) goal) (_ : a_ai_disj (AVL_intro unit a avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent nf_nil (@nil disj) ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil (@nil disj) ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (d : disj) (l : list disj) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a : avl_tree unit) (avl_a : is_avl unit a) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a avl_a) goal) (_ : a_ai_disj (AVL_intro unit a avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (a : normal_form) (l : list normal_form) (_ : forall (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent l ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal l ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context) (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context *) fold DNil in |- *. (* Goal: forall (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a : avl_tree unit) (avl_a : is_avl unit a) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a avl_a) goal) (_ : a_ai_disj (AVL_intro unit a avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent nf_nil DNil ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (d : disj) (l : list disj) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a : avl_tree unit) (avl_a : is_avl unit a) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a avl_a) goal) (_ : a_ai_disj (AVL_intro unit a avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (a : normal_form) (l : list normal_form) (_ : forall (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent l ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal l ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context) (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context *) intros ni ai avl_ai a avl_a ai_reg a_goal_disj a_ai_disj. (* Goal: forall _ : lt (nweight_Sequent nf_nil DNil ni (AVL_intro nf_list ai avl_ai)) (S n), nsearch_spec goal nf_nil DNil ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (d : disj) (l : list disj) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a : avl_tree unit) (avl_a : is_avl unit a) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a avl_a) goal) (_ : a_ai_disj (AVL_intro unit a avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (a : normal_form) (l : list normal_form) (_ : forall (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent l ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal l ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context) (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context *) pattern ni in |- *. (* Goal: (fun n0 : nested_imps => forall _ : lt (nweight_Sequent nf_nil DNil n0 (AVL_intro nf_list ai avl_ai)) (S n), nsearch_spec goal nf_nil DNil n0 (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context) ni *) (* Goal: forall (d : disj) (l : list disj) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a : avl_tree unit) (avl_a : is_avl unit a) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a avl_a) goal) (_ : a_ai_disj (AVL_intro unit a avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (a : normal_form) (l : list normal_form) (_ : forall (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent l ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal l ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context) (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context *) apply My_Lt_Ks_rec; clear ni. (* Goal: forall (ni2 : nested_imps) (dni2 : decorated_nested_imps) (_ : forall (ni1 : nested_imps) (dni1 : decorated_nested_imps) (_ : Lt_Ks ni1 dni1 ni2 dni2) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni2 ni2) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni2 ni2) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (d : disj) (l : list disj) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a : avl_tree unit) (avl_a : is_avl unit a) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a avl_a) goal) (_ : a_ai_disj (AVL_intro unit a avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (a : normal_form) (l : list normal_form) (_ : forall (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent l ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal l ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context) (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context *) intros ni dni. (* Goal: forall (_ : forall (ni1 : nested_imps) (dni1 : decorated_nested_imps) (_ : Lt_Ks ni1 dni1 ni dni) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni ni) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni ni) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (d : disj) (l : list disj) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a : avl_tree unit) (avl_a : is_avl unit a) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a avl_a) goal) (_ : a_ai_disj (AVL_intro unit a avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (a : normal_form) (l : list normal_form) (_ : forall (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent l ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal l ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context) (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context *) case ni; clear ni. (* Goal: forall (_ : forall (ni1 : nested_imps) (dni1 : decorated_nested_imps) (_ : Lt_Ks ni1 dni1 (@nil nested_imp) dni) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni (@nil nested_imp)) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni (@nil nested_imp)) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nested_imp) (l : list nested_imp) (_ : forall (ni1 : nested_imps) (dni1 : decorated_nested_imps) (_ : Lt_Ks ni1 dni1 (@cons nested_imp n0 l) dni) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni (@cons nested_imp n0 l)) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni (@cons nested_imp n0 l)) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (d : disj) (l : list disj) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a : avl_tree unit) (avl_a : is_avl unit a) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a avl_a) goal) (_ : a_ai_disj (AVL_intro unit a avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (a : normal_form) (l : list normal_form) (_ : forall (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent l ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal l ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context) (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context *) fold NNil in |- *. (* Goal: forall (_ : forall (ni1 : nested_imps) (dni1 : decorated_nested_imps) (_ : Lt_Ks ni1 dni1 NNil dni) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni NNil) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni NNil) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nested_imp) (l : list nested_imp) (_ : forall (ni1 : nested_imps) (dni1 : decorated_nested_imps) (_ : Lt_Ks ni1 dni1 (@cons nested_imp n0 l) dni) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni (@cons nested_imp n0 l)) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni (@cons nested_imp n0 l)) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (d : disj) (l : list disj) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a : avl_tree unit) (avl_a : is_avl unit a) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a avl_a) goal) (_ : a_ai_disj (AVL_intro unit a avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (a : normal_form) (l : list normal_form) (_ : forall (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent l ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal l ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context) (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context *) intros ih lt_nweight. (* Goal: nsearch_spec goal nf_nil DNil (rev_app dni NNil) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nested_imp) (l : list nested_imp) (_ : forall (ni1 : nested_imps) (dni1 : decorated_nested_imps) (_ : Lt_Ks ni1 dni1 (@cons nested_imp n0 l) dni) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni (@cons nested_imp n0 l)) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni (@cons nested_imp n0 l)) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (d : disj) (l : list disj) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a : avl_tree unit) (avl_a : is_avl unit a) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a avl_a) goal) (_ : a_ai_disj (AVL_intro unit a avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (a : normal_form) (l : list normal_form) (_ : forall (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent l ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal l ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context) (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context *) apply fail; assumption. (* ni'= *) (* Goal: forall (n0 : nimp) (l : list nested_imp) (_ : forall (ni1 : nested_imps) (dni1 : decorated_nested_imps) (_ : Lt_Ks ni1 dni1 (@cons nested_imp (Undecorated n0) l) dni) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni (@cons nested_imp (Undecorated n0) l)) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni (@cons nested_imp (Undecorated n0) l)) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (k : kripke_tree) (l : list nested_imp) (_ : forall (ni1 : nested_imps) (dni1 : decorated_nested_imps) (_ : Lt_Ks ni1 dni1 (@cons nested_imp (Decorated n0 k) l) dni) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni (@cons nested_imp (Decorated n0 k) l)) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni (@cons nested_imp (Decorated n0 k) l)) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (d : disj) (l : list disj) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a : avl_tree unit) (avl_a : is_avl unit a) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a avl_a) goal) (_ : a_ai_disj (AVL_intro unit a avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (a : normal_form) (l : list normal_form) (_ : forall (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent l ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal l ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context) (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context *) intros x; case x; clear x. (* Goal: forall (n0 : nimp) (l : list nested_imp) (_ : forall (ni1 : nested_imps) (dni1 : decorated_nested_imps) (_ : Lt_Ks ni1 dni1 (@cons nested_imp (Undecorated n0) l) dni) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni (@cons nested_imp (Undecorated n0) l)) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni (@cons nested_imp (Undecorated n0) l)) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (k : kripke_tree) (l : list nested_imp) (_ : forall (ni1 : nested_imps) (dni1 : decorated_nested_imps) (_ : Lt_Ks ni1 dni1 (@cons nested_imp (Decorated n0 k) l) dni) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni (@cons nested_imp (Decorated n0 k) l)) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni (@cons nested_imp (Decorated n0 k) l)) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (d : disj) (l : list disj) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a : avl_tree unit) (avl_a : is_avl unit a) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a avl_a) goal) (_ : a_ai_disj (AVL_intro unit a avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (a : normal_form) (l : list normal_form) (_ : forall (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent l ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal l ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context) (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context *) intros x; case x; clear x. (* Goal: forall (i i0 : Int) (n0 : normal_form) (l : list nested_imp) (_ : forall (ni1 : nested_imps) (dni1 : decorated_nested_imps) (_ : Lt_Ks ni1 dni1 (@cons nested_imp (Undecorated (NImp i i0 n0)) l) dni) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni (@cons nested_imp (Undecorated (NImp i i0 n0)) l)) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni (@cons nested_imp (Undecorated (NImp i i0 n0)) l)) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (k : kripke_tree) (l : list nested_imp) (_ : forall (ni1 : nested_imps) (dni1 : decorated_nested_imps) (_ : Lt_Ks ni1 dni1 (@cons nested_imp (Decorated n0 k) l) dni) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni (@cons nested_imp (Decorated n0 k) l)) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni (@cons nested_imp (Decorated n0 k) l)) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (d : disj) (l : list disj) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a : avl_tree unit) (avl_a : is_avl unit a) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a avl_a) goal) (_ : a_ai_disj (AVL_intro unit a avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (a : normal_form) (l : list normal_form) (_ : forall (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent l ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal l ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context) (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context *) intros a0 a1 b ni ih lt_nweight. (* Goal: nsearch_spec goal nf_nil DNil (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (k : kripke_tree) (l : list nested_imp) (_ : forall (ni1 : nested_imps) (dni1 : decorated_nested_imps) (_ : Lt_Ks ni1 dni1 (@cons nested_imp (Decorated n0 k) l) dni) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni (@cons nested_imp (Decorated n0 k) l)) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni (@cons nested_imp (Decorated n0 k) l)) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (d : disj) (l : list disj) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a : avl_tree unit) (avl_a : is_avl unit a) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a avl_a) goal) (_ : a_ai_disj (AVL_intro unit a avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (a : normal_form) (l : list normal_form) (_ : forall (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent l ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal l ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context) (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context *) apply left_nimp; try assumption. (* Goal: forall (ni1 : nested_imps) (_ : le_ni ni1 (rev_app dni ni)), nsearch_spec goal (@cons normal_form b nf_nil) DNil ni1 (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (ni1 : nested_imps) (k : kripke_tree) (_ : le_ni ni1 (rev_app (@cons (prod nimp kripke_tree) (@pair nimp kripke_tree (NImp a0 a1 b) k) dni) ni)), nsearch_spec goal nf_nil DNil ni1 (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (k : kripke_tree) (l : list nested_imp) (_ : forall (ni1 : nested_imps) (dni1 : decorated_nested_imps) (_ : Lt_Ks ni1 dni1 (@cons nested_imp (Decorated n0 k) l) dni) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni (@cons nested_imp (Decorated n0 k) l)) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni (@cons nested_imp (Decorated n0 k) l)) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (d : disj) (l : list disj) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a : avl_tree unit) (avl_a : is_avl unit a) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a avl_a) goal) (_ : a_ai_disj (AVL_intro unit a avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (a : normal_form) (l : list normal_form) (_ : forall (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent l ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal l ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context) (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context *) intros ni1 le1; clear ih. (* Goal: nsearch_spec a1 (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) nf_nil)) DNil ni1 (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) (@cons form (Atom a0) context) *) (* Goal: forall (ni1 : nested_imps) (_ : le_ni ni1 (rev_app dni ni)), nsearch_spec goal (@cons normal_form b nf_nil) DNil ni1 (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (ni1 : nested_imps) (k : kripke_tree) (_ : le_ni ni1 (rev_app (@cons (prod nimp kripke_tree) (@pair nimp kripke_tree (NImp a0 a1 b) k) dni) ni)), nsearch_spec goal nf_nil DNil ni1 (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (k : kripke_tree) (l : list nested_imp) (_ : forall (ni1 : nested_imps) (dni1 : decorated_nested_imps) (_ : Lt_Ks ni1 dni1 (@cons nested_imp (Decorated n0 k) l) dni) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni (@cons nested_imp (Decorated n0 k) l)) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni (@cons nested_imp (Decorated n0 k) l)) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (d : disj) (l : list disj) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a : avl_tree unit) (avl_a : is_avl unit a) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a avl_a) goal) (_ : a_ai_disj (AVL_intro unit a avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (a : normal_form) (l : list normal_form) (_ : forall (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent l ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal l ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context) (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context *) elim (lookup_dec unit a1 a avl_a). (* Goal: forall (d : unit) (_ : lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) intros d; case d; clear d. (* Goal: forall _ : lookup unit i a tt, nsearch_spec goal (@cons normal_form (NAtom i) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (NAtom i) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i i0 : Int) (_ : lt (nweight_Sequent (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i : Int) (n0 : normal_form) (_ : lt (nweight_Sequent (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) intros lookup. (* Goal: nsearch_spec goal (@cons normal_form (NAtom i) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall _ : not (Equal goal i), nsearch_spec goal (@cons normal_form (NAtom i) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i i0 : Int) (_ : lt (nweight_Sequent (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i : Int) (n0 : normal_form) (_ : lt (nweight_Sequent (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) apply nax; try assumption. (* Goal: in_ngamma (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) nf_nil)) DNil ni1 (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) (NAtom a1) *) (* Goal: forall _ : forall d : unit, not (lookup unit a1 a d), nsearch_spec a1 (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) nf_nil)) DNil ni1 (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) (@cons form (Atom a0) context) *) (* Goal: forall (ni1 : nested_imps) (_ : le_ni ni1 (rev_app dni ni)), nsearch_spec goal (@cons normal_form b nf_nil) DNil ni1 (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (ni1 : nested_imps) (k : kripke_tree) (_ : le_ni ni1 (rev_app (@cons (prod nimp kripke_tree) (@pair nimp kripke_tree (NImp a0 a1 b) k) dni) ni)), nsearch_spec goal nf_nil DNil ni1 (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (k : kripke_tree) (l : list nested_imp) (_ : forall (ni1 : nested_imps) (dni1 : decorated_nested_imps) (_ : Lt_Ks ni1 dni1 (@cons nested_imp (Decorated n0 k) l) dni) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni (@cons nested_imp (Decorated n0 k) l)) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni (@cons nested_imp (Decorated n0 k) l)) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (d : disj) (l : list disj) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a : avl_tree unit) (avl_a : is_avl unit a) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a avl_a) goal) (_ : a_ai_disj (AVL_intro unit a avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (a : normal_form) (l : list normal_form) (_ : forall (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent l ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal l ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context) (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context *) apply In_Atoms; assumption. (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (NAtom i) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i i0 : Int) (_ : lt (nweight_Sequent (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i : Int) (n0 : normal_form) (_ : lt (nweight_Sequent (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) intros not_lookup. (* Goal: nsearch_spec goal (@app normal_form bs work) ds ni (AVL_intro nf_list ai' avl_ai') (AVL_intro unit a' avl_a') context *) (* Goal: forall _ : forall d : nf_list, not (lookup nf_list i ai d), nsearch_spec goal (@cons normal_form (NAtom i) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i i0 : Int) (_ : lt (nweight_Sequent (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i : Int) (n0 : normal_form) (_ : lt (nweight_Sequent (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) apply ih_n; try assumption. (* Goal: lt (nweight_Sequent (@cons normal_form (AImp a1 b) (@cons normal_form (NAtom a0) nf_nil)) DNil ni1 (AVL_intro nf_list ai avl_ai)) n *) (* Goal: Disjunct.a_goal_disj (AVL_intro unit a avl_a) a1 *) (* Goal: forall (ni1 : nested_imps) (_ : le_ni ni1 (rev_app dni ni)), nsearch_spec goal (@cons normal_form b nf_nil) DNil ni1 (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (ni1 : nested_imps) (k : kripke_tree) (_ : le_ni ni1 (rev_app (@cons (prod nimp kripke_tree) (@pair nimp kripke_tree (NImp a0 a1 b) k) dni) ni)), nsearch_spec goal nf_nil DNil ni1 (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (k : kripke_tree) (l : list nested_imp) (_ : forall (ni1 : nested_imps) (dni1 : decorated_nested_imps) (_ : Lt_Ks ni1 dni1 (@cons nested_imp (Decorated n0 k) l) dni) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni (@cons nested_imp (Decorated n0 k) l)) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni (@cons nested_imp (Decorated n0 k) l)) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (d : disj) (l : list disj) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a : avl_tree unit) (avl_a : is_avl unit a) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a avl_a) goal) (_ : a_ai_disj (AVL_intro unit a avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (a : normal_form) (l : list normal_form) (_ : forall (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent l ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal l ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context) (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context *) apply nweight_sequent_nimp_left with ni dni; try assumption. (* Goal: eqv_ni ni ni1 *) (* Goal: lt (nweight_Sequent nf_nil (@cons (prod Int Int) (@pair Int Int i j) ds) ni (AVL_intro nf_list ai avl_ai)) (S n) *) (* Goal: forall (ni2 : nested_imps) (_ : eqv_ni ni2 ni), nsearch_spec goal (@cons normal_form (NAtom j) nf_nil) ds ni2 (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) (@cons form (Atom j) context) *) (* Goal: forall (a : normal_form) (l : list normal_form) (_ : forall (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent l ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal l ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context) (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context *) apply le_eqv; assumption. (* Goal: Disjunct.a_goal_disj (AVL_intro unit a avl_a) a1 *) (* Goal: forall (ni1 : nested_imps) (_ : le_ni ni1 (rev_app dni ni)), nsearch_spec goal (@cons normal_form b nf_nil) DNil ni1 (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (ni1 : nested_imps) (k : kripke_tree) (_ : le_ni ni1 (rev_app (@cons (prod nimp kripke_tree) (@pair nimp kripke_tree (NImp a0 a1 b) k) dni) ni)), nsearch_spec goal nf_nil DNil ni1 (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (k : kripke_tree) (l : list nested_imp) (_ : forall (ni1 : nested_imps) (dni1 : decorated_nested_imps) (_ : Lt_Ks ni1 dni1 (@cons nested_imp (Decorated n0 k) l) dni) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni (@cons nested_imp (Decorated n0 k) l)) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni (@cons nested_imp (Decorated n0 k) l)) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (d : disj) (l : list disj) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a : avl_tree unit) (avl_a : is_avl unit a) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a avl_a) goal) (_ : a_ai_disj (AVL_intro unit a avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (a : normal_form) (l : list normal_form) (_ : forall (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent l ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal l ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context) (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context *) exact (not_lookup tt). (* Goal: forall (ni1 : nested_imps) (_ : le_ni ni1 (rev_app dni ni)), nsearch_spec goal (@cons normal_form b nf_nil) DNil ni1 (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (ni1 : nested_imps) (k : kripke_tree) (_ : le_ni ni1 (rev_app (@cons (prod nimp kripke_tree) (@pair nimp kripke_tree (NImp a0 a1 b) k) dni) ni)), nsearch_spec goal nf_nil DNil ni1 (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (k : kripke_tree) (l : list nested_imp) (_ : forall (ni1 : nested_imps) (dni1 : decorated_nested_imps) (_ : Lt_Ks ni1 dni1 (@cons nested_imp (Decorated n0 k) l) dni) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni (@cons nested_imp (Decorated n0 k) l)) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni (@cons nested_imp (Decorated n0 k) l)) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (d : disj) (l : list disj) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a : avl_tree unit) (avl_a : is_avl unit a) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a avl_a) goal) (_ : a_ai_disj (AVL_intro unit a avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (a : normal_form) (l : list normal_form) (_ : forall (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent l ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal l ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context) (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context *) intros ni1 le1; clear ih. (* Goal: nsearch_spec goal (@app normal_form bs work) ds ni (AVL_intro nf_list ai' avl_ai') (AVL_intro unit a' avl_a') context *) (* Goal: forall _ : forall d : nf_list, not (lookup nf_list i ai d), nsearch_spec goal (@cons normal_form (NAtom i) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i i0 : Int) (_ : lt (nweight_Sequent (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i : Int) (n0 : normal_form) (_ : lt (nweight_Sequent (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) apply ih_n; try assumption. (* Goal: lt (nweight_Sequent (@cons normal_form b nf_nil) DNil ni1 (AVL_intro nf_list ai avl_ai)) n *) (* Goal: forall (ni1 : nested_imps) (k : kripke_tree) (_ : le_ni ni1 (rev_app (@cons (prod nimp kripke_tree) (@pair nimp kripke_tree (NImp a0 a1 b) k) dni) ni)), nsearch_spec goal nf_nil DNil ni1 (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (k : kripke_tree) (l : list nested_imp) (_ : forall (ni1 : nested_imps) (dni1 : decorated_nested_imps) (_ : Lt_Ks ni1 dni1 (@cons nested_imp (Decorated n0 k) l) dni) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni (@cons nested_imp (Decorated n0 k) l)) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni (@cons nested_imp (Decorated n0 k) l)) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (d : disj) (l : list disj) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a : avl_tree unit) (avl_a : is_avl unit a) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a avl_a) goal) (_ : a_ai_disj (AVL_intro unit a avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (a : normal_form) (l : list normal_form) (_ : forall (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent l ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal l ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context) (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context *) apply nweight_sequent_nimp_right with a0 a1 ni dni; try assumption. (* Goal: eqv_ni (rev_app dni ni) ni1 *) (* Goal: forall (ni1 : nested_imps) (k : kripke_tree) (_ : le_ni ni1 (rev_app (@cons (prod nimp kripke_tree) (@pair nimp kripke_tree (NImp a0 a1 b) k) dni) ni)), nsearch_spec goal nf_nil DNil ni1 (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (k : kripke_tree) (l : list nested_imp) (_ : forall (ni1 : nested_imps) (dni1 : decorated_nested_imps) (_ : Lt_Ks ni1 dni1 (@cons nested_imp (Decorated n0 k) l) dni) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni (@cons nested_imp (Decorated n0 k) l)) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni (@cons nested_imp (Decorated n0 k) l)) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (d : disj) (l : list disj) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a : avl_tree unit) (avl_a : is_avl unit a) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a avl_a) goal) (_ : a_ai_disj (AVL_intro unit a avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (a : normal_form) (l : list normal_form) (_ : forall (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent l ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal l ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context) (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context *) apply ge_eqv; assumption. (* Goal: forall (ni1 : nested_imps) (k : kripke_tree) (_ : le_ni ni1 (rev_app (@cons (prod nimp kripke_tree) (@pair nimp kripke_tree (NImp a0 a1 b) k) dni) ni)), nsearch_spec goal nf_nil DNil ni1 (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (k : kripke_tree) (l : list nested_imp) (_ : forall (ni1 : nested_imps) (dni1 : decorated_nested_imps) (_ : Lt_Ks ni1 dni1 (@cons nested_imp (Decorated n0 k) l) dni) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni (@cons nested_imp (Decorated n0 k) l)) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni (@cons nested_imp (Decorated n0 k) l)) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (d : disj) (l : list disj) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a : avl_tree unit) (avl_a : is_avl unit a) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a avl_a) goal) (_ : a_ai_disj (AVL_intro unit a avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (a : normal_form) (l : list normal_form) (_ : forall (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent l ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal l ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context) (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context *) intros ni1 k le1. (* Goal: nsearch_spec goal nf_nil DNil ni1 (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (k : kripke_tree) (l : list nested_imp) (_ : forall (ni1 : nested_imps) (dni1 : decorated_nested_imps) (_ : Lt_Ks ni1 dni1 (@cons nested_imp (Decorated n0 k) l) dni) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni (@cons nested_imp (Decorated n0 k) l)) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni (@cons nested_imp (Decorated n0 k) l)) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (d : disj) (l : list disj) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a : avl_tree unit) (avl_a : is_avl unit a) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a avl_a) goal) (_ : a_ai_disj (AVL_intro unit a avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (a : normal_form) (l : list normal_form) (_ : forall (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent l ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal l ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context) (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context *) apply ih with (ni1 := ni1) (dni1 := DNI_NIL); clear ih; try assumption. (* Goal: Lt_Ks ni1 DNI_NIL (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni) dni *) (* Goal: lt (nweight_Sequent nf_nil DNil (rev_app DNI_NIL ni1) (AVL_intro nf_list ai avl_ai)) (S n) *) (* Goal: forall (n0 : nimp) (k : kripke_tree) (l : list nested_imp) (_ : forall (ni1 : nested_imps) (dni1 : decorated_nested_imps) (_ : Lt_Ks ni1 dni1 (@cons nested_imp (Decorated n0 k) l) dni) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni (@cons nested_imp (Decorated n0 k) l)) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni (@cons nested_imp (Decorated n0 k) l)) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (d : disj) (l : list disj) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a : avl_tree unit) (avl_a : is_avl unit a) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a avl_a) goal) (_ : a_ai_disj (AVL_intro unit a avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (a : normal_form) (l : list normal_form) (_ : forall (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent l ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal l ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context) (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context *) apply lt_ks_shift_nd with k; assumption. (* Goal: lt (nweight_Sequent nf_nil DNil (rev_app DNI_NIL ni1) (AVL_intro nf_list ai avl_ai)) (S n) *) (* Goal: forall (n0 : nimp) (k : kripke_tree) (l : list nested_imp) (_ : forall (ni1 : nested_imps) (dni1 : decorated_nested_imps) (_ : Lt_Ks ni1 dni1 (@cons nested_imp (Decorated n0 k) l) dni) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni (@cons nested_imp (Decorated n0 k) l)) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni (@cons nested_imp (Decorated n0 k) l)) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (d : disj) (l : list disj) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a : avl_tree unit) (avl_a : is_avl unit a) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a avl_a) goal) (_ : a_ai_disj (AVL_intro unit a avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (a : normal_form) (l : list normal_form) (_ : forall (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent l ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal l ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context) (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context *) simpl in |- *. rewrite (nweight_sequent_eqv nf_nil DNil ni1 (rev_app dni (Undecorated (NImp a0 a1 b) :: ni)) (AVL_intro nf_list ai avl_ai)). (* Goal: lt (S (nweight_Sequent (@cons normal_form b work) ds ni (AVL_intro nf_list ai avl_ai))) (S n) *) (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) assumption. (* Goal: eqv_ni ni1 (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) *) (* Goal: forall (n0 : nimp) (k : kripke_tree) (l : list nested_imp) (_ : forall (ni1 : nested_imps) (dni1 : decorated_nested_imps) (_ : Lt_Ks ni1 dni1 (@cons nested_imp (Decorated n0 k) l) dni) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni (@cons nested_imp (Decorated n0 k) l)) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni (@cons nested_imp (Decorated n0 k) l)) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (d : disj) (l : list disj) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a : avl_tree unit) (avl_a : is_avl unit a) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a avl_a) goal) (_ : a_ai_disj (AVL_intro unit a avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (a : normal_form) (l : list normal_form) (_ : forall (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent l ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal l ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context) (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context *) apply eqv_ni_trans with (rev_app dni (Decorated (NImp a0 a1 b) k :: ni)). (* Goal: eqv_ni ni ni1 *) (* Goal: lt (nweight_Sequent nf_nil (@cons (prod Int Int) (@pair Int Int i j) ds) ni (AVL_intro nf_list ai avl_ai)) (S n) *) (* Goal: forall (ni2 : nested_imps) (_ : eqv_ni ni2 ni), nsearch_spec goal (@cons normal_form (NAtom j) nf_nil) ds ni2 (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) (@cons form (Atom j) context) *) (* Goal: forall (a : normal_form) (l : list normal_form) (_ : forall (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent l ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal l ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context) (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context *) apply le_eqv; assumption. (* Goal: eqv_ni (rev_app dni (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni)) (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) *) (* Goal: forall (n0 : nimp) (k : kripke_tree) (l : list nested_imp) (_ : forall (ni1 : nested_imps) (dni1 : decorated_nested_imps) (_ : Lt_Ks ni1 dni1 (@cons nested_imp (Decorated n0 k) l) dni) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni (@cons nested_imp (Decorated n0 k) l)) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni (@cons nested_imp (Decorated n0 k) l)) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (d : disj) (l : list disj) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a : avl_tree unit) (avl_a : is_avl unit a) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a avl_a) goal) (_ : a_ai_disj (AVL_intro unit a avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (a : normal_form) (l : list normal_form) (_ : forall (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent l ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal l ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context) (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context *) apply le_eqv. (* Goal: le_ni (rev_app dni (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni)) (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) *) (* Goal: forall (n0 : nimp) (k : kripke_tree) (l : list nested_imp) (_ : forall (ni1 : nested_imps) (dni1 : decorated_nested_imps) (_ : Lt_Ks ni1 dni1 (@cons nested_imp (Decorated n0 k) l) dni) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni (@cons nested_imp (Decorated n0 k) l)) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni (@cons nested_imp (Decorated n0 k) l)) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (d : disj) (l : list disj) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a : avl_tree unit) (avl_a : is_avl unit a) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a avl_a) goal) (_ : a_ai_disj (AVL_intro unit a avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (a : normal_form) (l : list normal_form) (_ : forall (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent l ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal l ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context) (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context *) rewrite (rev_app_app dni (Decorated (NImp a0 a1 b) k :: ni)). (* Goal: le_ni (@app nested_imp (rev_app dni NNil) (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni)) (rev_app dni (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) *) (* Goal: forall (n0 : nimp) (k : kripke_tree) (l : list nested_imp) (_ : forall (ni1 : nested_imps) (dni1 : decorated_nested_imps) (_ : Lt_Ks ni1 dni1 (@cons nested_imp (Decorated n0 k) l) dni) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni (@cons nested_imp (Decorated n0 k) l)) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni (@cons nested_imp (Decorated n0 k) l)) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (d : disj) (l : list disj) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a : avl_tree unit) (avl_a : is_avl unit a) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a avl_a) goal) (_ : a_ai_disj (AVL_intro unit a avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (a : normal_form) (l : list normal_form) (_ : forall (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent l ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal l ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context) (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context *) rewrite (rev_app_app dni (Undecorated (NImp a0 a1 b) :: ni)). (* Goal: le_ni (@app nested_imp (rev_app dni NNil) (@cons nested_imp (Decorated (NImp a0 a1 b) k) ni)) (@app nested_imp (rev_app dni NNil) (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni)) *) (* Goal: forall (n0 : nimp) (k : kripke_tree) (l : list nested_imp) (_ : forall (ni1 : nested_imps) (dni1 : decorated_nested_imps) (_ : Lt_Ks ni1 dni1 (@cons nested_imp (Decorated n0 k) l) dni) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni (@cons nested_imp (Decorated n0 k) l)) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni (@cons nested_imp (Decorated n0 k) l)) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (d : disj) (l : list disj) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a : avl_tree unit) (avl_a : is_avl unit a) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a avl_a) goal) (_ : a_ai_disj (AVL_intro unit a avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (a : normal_form) (l : list normal_form) (_ : forall (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent l ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal l ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context) (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context *) apply le_ni_app_dn. (* Goal: @eq nested_imps NNil NNil *) (* Goal: lt (nweight_Sequent work DNil NNil AI_Nil) (S (nweight_Sequent work DNil NNil AI_Nil)) *) (* Goal: REGULAR normal_form AI_Nil *) (* Goal: a_ai_disj ANil AI_Nil *) (* Goal: a_goal_disj ANil goal *) (* Goal: deco_sound work DNil NNil AI_Nil ANil *) (* Goal: nsound work DNil NNil AI_Nil ANil context *) (* Goal: nminimal work DNil NNil AI_Nil ANil context *) trivial. (* Goal: le_ni (@app nested_imp (rev_app dni NNil) ni) (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: forall (n0 : nimp) (k : kripke_tree) (l : list nested_imp) (_ : forall (ni1 : nested_imps) (dni1 : decorated_nested_imps) (_ : Lt_Ks ni1 dni1 (@cons nested_imp (Decorated n0 k) l) dni) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni (@cons nested_imp (Decorated n0 k) l)) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni (@cons nested_imp (Decorated n0 k) l)) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (d : disj) (l : list disj) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a : avl_tree unit) (avl_a : is_avl unit a) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a avl_a) goal) (_ : a_ai_disj (AVL_intro unit a avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (a : normal_form) (l : list normal_form) (_ : forall (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent l ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal l ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context) (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context *) apply le_ni_refl. (* Goal: forall (n0 : nimp) (k : kripke_tree) (l : list nested_imp) (_ : forall (ni1 : nested_imps) (dni1 : decorated_nested_imps) (_ : Lt_Ks ni1 dni1 (@cons nested_imp (Decorated n0 k) l) dni) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni1 ni1) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context) (_ : lt (nweight_Sequent nf_nil DNil (rev_app dni (@cons nested_imp (Decorated n0 k) l)) (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil DNil (rev_app dni (@cons nested_imp (Decorated n0 k) l)) (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (d : disj) (l : list disj) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a : avl_tree unit) (avl_a : is_avl unit a) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a avl_a) goal) (_ : a_ai_disj (AVL_intro unit a avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (a : normal_form) (l : list normal_form) (_ : forall (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent l ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal l ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context) (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context *) intros x k ni ih lt_nweight. (* Goal: lt (S (nweight_Sequent (@cons normal_form b work) ds ni (AVL_intro nf_list ai avl_ai))) (S n) *) (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) apply shift_ni_dni; try assumption. (* Goal: lt (S (nweight_Sequent (@cons normal_form b work) ds ni (AVL_intro nf_list ai avl_ai))) (S n) *) (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) apply ih; try assumption. (* Goal: Lt_Ks ni (@cons (prod nimp kripke_tree) (@pair nimp kripke_tree x k) dni) (@cons nested_imp (Decorated x k) ni) dni *) (* Goal: forall (d : disj) (l : list disj) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a : avl_tree unit) (avl_a : is_avl unit a) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a avl_a) goal) (_ : a_ai_disj (AVL_intro unit a avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil (@cons disj d l) ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (a : normal_form) (l : list normal_form) (_ : forall (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent l ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal l ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context) (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context *) apply lt_ks_shift_dd. (* ds=(cons (d0,d1) ds) *) (* Goal: forall (d : unit) (_ : lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) intros d; case d; clear d. (* Goal: forall (i i0 : Int) (l : list disj) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a : avl_tree unit) (avl_a : is_avl unit a) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a avl_a) goal) (_ : a_ai_disj (AVL_intro unit a avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent nf_nil (@cons disj (@pair Int Int i i0) l) ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal nf_nil (@cons disj (@pair Int Int i i0) l) ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (a : normal_form) (l : list normal_form) (_ : forall (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent l ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal l ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context) (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context *) intros i j ds ni ai avl_ai a avl_a ai_reg a_goal_disj a_ai_disj lt_nweight. (* Goal: lt (S (nweight_Sequent (@cons normal_form b work) ds ni (AVL_intro nf_list ai avl_ai))) (S n) *) (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) apply left_disj; try assumption. (* Goal: forall (ni1 : nested_imps) (_ : le_ni ni1 NNil) (_ : deco_sound work DNil ni1 AI_Nil ANil) (_ : nsearch_spec_result_aux goal work DNil ni1 AI_Nil ANil context), nsearch_spec_result_aux goal work DNil NNil AI_Nil ANil context *) (* Goal: lt (nweight_Sequent work DNil NNil AI_Nil) (S (nweight_Sequent work DNil NNil AI_Nil)) *) (* Goal: REGULAR normal_form AI_Nil *) (* Goal: a_ai_disj ANil AI_Nil *) (* Goal: a_goal_disj ANil goal *) (* Goal: deco_sound work DNil NNil AI_Nil ANil *) (* Goal: nsound work DNil NNil AI_Nil ANil context *) (* Goal: nminimal work DNil NNil AI_Nil ANil context *) intros ni1 le1. (* Goal: nsearch_spec goal (@app normal_form bs work) ds ni (AVL_intro nf_list ai' avl_ai') (AVL_intro unit a' avl_a') context *) (* Goal: forall _ : forall d : nf_list, not (lookup nf_list i ai d), nsearch_spec goal (@cons normal_form (NAtom i) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i i0 : Int) (_ : lt (nweight_Sequent (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i : Int) (n0 : normal_form) (_ : lt (nweight_Sequent (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) apply ih_n; try assumption. (* Goal: lt (nweight_Sequent (@cons normal_form (NAtom i) nf_nil) ds ni1 (AVL_intro nf_list ai avl_ai)) n *) (* Goal: forall (ni2 : nested_imps) (_ : eqv_ni ni2 ni), nsearch_spec goal (@cons normal_form (NAtom j) nf_nil) ds ni2 (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) (@cons form (Atom j) context) *) (* Goal: forall (a : normal_form) (l : list normal_form) (_ : forall (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent l ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal l ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context) (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context *) apply nweight_sequent_left_disj_left with j ni. (* Goal: eqv_ni ni ni1 *) (* Goal: lt (nweight_Sequent nf_nil (@cons (prod Int Int) (@pair Int Int i j) ds) ni (AVL_intro nf_list ai avl_ai)) (S n) *) (* Goal: forall (ni2 : nested_imps) (_ : eqv_ni ni2 ni), nsearch_spec goal (@cons normal_form (NAtom j) nf_nil) ds ni2 (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) (@cons form (Atom j) context) *) (* Goal: forall (a : normal_form) (l : list normal_form) (_ : forall (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent l ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal l ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context) (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context *) apply le_eqv; assumption. (* Goal: lt (S (nweight_Sequent (@cons normal_form b work) ds ni (AVL_intro nf_list ai avl_ai))) (S n) *) (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) assumption. (* Goal: forall (ni1 : nested_imps) (_ : le_ni ni1 NNil) (_ : deco_sound work DNil ni1 AI_Nil ANil) (_ : nsearch_spec_result_aux goal work DNil ni1 AI_Nil ANil context), nsearch_spec_result_aux goal work DNil NNil AI_Nil ANil context *) (* Goal: lt (nweight_Sequent work DNil NNil AI_Nil) (S (nweight_Sequent work DNil NNil AI_Nil)) *) (* Goal: REGULAR normal_form AI_Nil *) (* Goal: a_ai_disj ANil AI_Nil *) (* Goal: a_goal_disj ANil goal *) (* Goal: deco_sound work DNil NNil AI_Nil ANil *) (* Goal: nsound work DNil NNil AI_Nil ANil context *) (* Goal: nminimal work DNil NNil AI_Nil ANil context *) intros ni1 le1. (* Goal: nsearch_spec goal (@app normal_form bs work) ds ni (AVL_intro nf_list ai' avl_ai') (AVL_intro unit a' avl_a') context *) (* Goal: forall _ : forall d : nf_list, not (lookup nf_list i ai d), nsearch_spec goal (@cons normal_form (NAtom i) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i i0 : Int) (_ : lt (nweight_Sequent (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i : Int) (n0 : normal_form) (_ : lt (nweight_Sequent (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) apply ih_n; try assumption. (* Goal: lt (nweight_Sequent (@cons normal_form (NAtom j) nf_nil) ds ni1 (AVL_intro nf_list ai avl_ai)) n *) (* Goal: forall (a : normal_form) (l : list normal_form) (_ : forall (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent l ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal l ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context) (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context *) apply nweight_sequent_left_disj_right with i ni. (* Goal: lt (S (nweight_Sequent (@cons normal_form b work) ds ni (AVL_intro nf_list ai avl_ai))) (S n) *) (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) apply eqv_sym; assumption. (* Goal: lt (S (nweight_Sequent (@cons normal_form b work) ds ni (AVL_intro nf_list ai avl_ai))) (S n) *) (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) assumption. (* work=(cons .. *) (* Goal: forall (a : normal_form) (l : list normal_form) (_ : forall (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent l ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal l ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context) (ds : disjs) (ni : nested_imps) (ai : avl_tree nf_list) (avl_ai : is_avl nf_list ai) (a0 : avl_tree unit) (avl_a : is_avl unit a0) (_ : REGULAR normal_form (AVL_intro nf_list ai avl_ai)) (_ : a_goal_disj (AVL_intro unit a0 avl_a) goal) (_ : a_ai_disj (AVL_intro unit a0 avl_a) (AVL_intro nf_list ai avl_ai)) (_ : lt (nweight_Sequent (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form a l) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a0 avl_a) context *) intros c work ih_work ds ni ai avl_ai a avl_a ai_reg a_goal_disj a_ai_disj. (* Goal: forall _ : lt (nweight_Sequent (@cons normal_form c work) ds ni (AVL_intro nf_list ai avl_ai)) (S n), nsearch_spec goal (@cons normal_form c work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) case c; clear c. (* a=NFalsum*) (* Goal: forall _ : lt (nweight_Sequent (@cons normal_form NFalsum work) ds ni (AVL_intro nf_list ai avl_ai)) (S n), nsearch_spec goal (@cons normal_form NFalsum work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i : Int) (_ : lt (nweight_Sequent (@cons normal_form (NAtom i) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NAtom i) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i i0 : Int) (_ : lt (nweight_Sequent (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i : Int) (n0 : normal_form) (_ : lt (nweight_Sequent (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) intros lt_nweight. (* Goal: forall _ : Equal goal i, nsearch_spec goal (@cons normal_form (NAtom i) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall _ : not (Equal goal i), nsearch_spec goal (@cons normal_form (NAtom i) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i i0 : Int) (_ : lt (nweight_Sequent (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i : Int) (n0 : normal_form) (_ : lt (nweight_Sequent (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) clear ih_work ih_n. (* Goal: lt (S (nweight_Sequent (@cons normal_form b work) ds ni (AVL_intro nf_list ai avl_ai))) (S n) *) (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) apply nefq; assumption. (* a=(NAtom i) *) (* Goal: forall (i : Int) (_ : lt (nweight_Sequent (@cons normal_form (NAtom i) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NAtom i) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i i0 : Int) (_ : lt (nweight_Sequent (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i : Int) (n0 : normal_form) (_ : lt (nweight_Sequent (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) intros i lt_nweight. (* Goal: nsearch_spec goal (@cons normal_form (NAtom i) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i i0 : Int) (_ : lt (nweight_Sequent (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i : Int) (n0 : normal_form) (_ : lt (nweight_Sequent (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) elim (equal_dec goal i). (* Goal: forall _ : Equal goal i, nsearch_spec goal (@cons normal_form (NAtom i) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall _ : not (Equal goal i), nsearch_spec goal (@cons normal_form (NAtom i) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i i0 : Int) (_ : lt (nweight_Sequent (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i : Int) (n0 : normal_form) (_ : lt (nweight_Sequent (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) clear ih_work ih_n. (* Goal: forall _ : Equal goal i, nsearch_spec goal (@cons normal_form (NAtom i) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall _ : not (Equal goal i), nsearch_spec goal (@cons normal_form (NAtom i) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i i0 : Int) (_ : lt (nweight_Sequent (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i : Int) (n0 : normal_form) (_ : lt (nweight_Sequent (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) intros equal_goal. (* Goal: nsearch_spec goal (@cons normal_form (NAtom i) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall _ : not (Equal goal i), nsearch_spec goal (@cons normal_form (NAtom i) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i i0 : Int) (_ : lt (nweight_Sequent (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i : Int) (n0 : normal_form) (_ : lt (nweight_Sequent (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) apply nax; try assumption. (* Goal: in_ngamma (@cons normal_form (NAtom i) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) (NAtom goal) *) (* Goal: forall _ : not (Equal goal i), nsearch_spec goal (@cons normal_form (NAtom i) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i i0 : Int) (_ : lt (nweight_Sequent (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i : Int) (n0 : normal_form) (_ : lt (nweight_Sequent (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) rewrite (equal_eq goal i equal_goal). (* Goal: in_ngamma (@cons normal_form (NAtom i) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) (NAtom i) *) (* Goal: forall _ : not (Equal goal i), nsearch_spec goal (@cons normal_form (NAtom i) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i i0 : Int) (_ : lt (nweight_Sequent (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i : Int) (n0 : normal_form) (_ : lt (nweight_Sequent (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) apply in_ngamma_cons_work_head. (* Goal: forall _ : not (Equal goal i), nsearch_spec goal (@cons normal_form (NAtom i) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i i0 : Int) (_ : lt (nweight_Sequent (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i : Int) (n0 : normal_form) (_ : lt (nweight_Sequent (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) intros not_equal_goal. (* Goal: nsearch_spec goal (@cons normal_form (NAtom i) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i i0 : Int) (_ : lt (nweight_Sequent (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i : Int) (n0 : normal_form) (_ : lt (nweight_Sequent (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) elim (insert_avl unit i (fun x : unit => tt) tt a avl_a). (* Goal: forall (t : avl_tree unit) (_ : lookup_dec_spec unit i a) (_ : is_avl unit t) (_ : lin_ins_spec unit i (fun _ : unit => tt) tt a t) (_ : equiv_ins unit i (fun _ : unit => tt) tt a t) (_ : sumbool (@eq nat (height_avl unit t) (height_avl unit a)) (@eq nat (height_avl unit t) (S (height_avl unit a)))), nsearch_spec goal (@cons normal_form (NAtom i) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i i0 : Int) (_ : lt (nweight_Sequent (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i : Int) (n0 : normal_form) (_ : lt (nweight_Sequent (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) intros a' lookup_dec_a avl_a' lin_ins equiv_ins height_dec; clear height_dec. (* Goal: nsearch_spec goal (@cons normal_form (NAtom i) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i i0 : Int) (_ : lt (nweight_Sequent (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i : Int) (n0 : normal_form) (_ : lt (nweight_Sequent (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) elim lookup_dec_a; clear lookup_dec_a lin_ins. (* Goal: forall (d : unit) (_ : lookup unit i a d), nsearch_spec goal (@cons normal_form (NAtom i) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (NAtom i) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i i0 : Int) (_ : lt (nweight_Sequent (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i : Int) (n0 : normal_form) (_ : lt (nweight_Sequent (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) clear ih_n. (* Goal: forall (d : unit) (_ : lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) intros d; case d; clear d. (* Goal: forall _ : lookup unit i a tt, nsearch_spec goal (@cons normal_form (NAtom i) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (NAtom i) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i i0 : Int) (_ : lt (nweight_Sequent (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i : Int) (n0 : normal_form) (_ : lt (nweight_Sequent (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) intros lookup. (* Goal: lt (S (nweight_Sequent (@cons normal_form b work) ds ni (AVL_intro nf_list ai avl_ai))) (S n) *) (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) apply contradiction_atoms; try assumption. (* Goal: lt (S (nweight_Sequent (@cons normal_form b work) ds ni (AVL_intro nf_list ai avl_ai))) (S n) *) (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) apply ih_work; clear ih_work; assumption. (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (NAtom i) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i i0 : Int) (_ : lt (nweight_Sequent (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i : Int) (n0 : normal_form) (_ : lt (nweight_Sequent (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) intros not_lookup. (* Goal: nsearch_spec goal (@cons normal_form (NAtom i) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i i0 : Int) (_ : lt (nweight_Sequent (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i : Int) (n0 : normal_form) (_ : lt (nweight_Sequent (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) elim (delete_avl nf_list i ai avl_ai). intros ai' lookup_dec_ai' avl_ai' lin_del equiv_del height_dec; clear height_dec. (* Goal: nsearch_spec goal (@cons normal_form (NAtom i) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i i0 : Int) (_ : lt (nweight_Sequent (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i : Int) (n0 : normal_form) (_ : lt (nweight_Sequent (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) elim lookup_dec_ai'; clear lookup_dec_ai'. (* Goal: forall (d : nf_list) (_ : lookup nf_list i ai d), nsearch_spec goal (@cons normal_form (NAtom i) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall _ : forall d : nf_list, not (lookup nf_list i ai d), nsearch_spec goal (@cons normal_form (NAtom i) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i i0 : Int) (_ : lt (nweight_Sequent (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i : Int) (n0 : normal_form) (_ : lt (nweight_Sequent (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) intros bs lookup_bs; clear ih_work. apply left_p_imp_ai with bs (AVL_intro nf_list ai' avl_ai') (AVL_intro unit a' avl_a'); (* Goal: lt (S (nweight_Sequent (@cons normal_form b work) ds ni (AVL_intro nf_list ai avl_ai))) (S n) *) (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) try assumption. (* Goal: nsearch_spec goal (@app normal_form bs work) ds ni (AVL_intro nf_list ai' avl_ai') (AVL_intro unit a' avl_a') context *) (* Goal: forall _ : forall d : nf_list, not (lookup nf_list i ai d), nsearch_spec goal (@cons normal_form (NAtom i) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i i0 : Int) (_ : lt (nweight_Sequent (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i : Int) (n0 : normal_form) (_ : lt (nweight_Sequent (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) apply ih_n; try assumption. apply lt_le_trans with (nweight_Sequent work ds ni (AVL_intro nf_list ai avl_ai)). (* Goal: lt (S (nweight_Sequent (@cons normal_form b work) ds ni (AVL_intro nf_list ai avl_ai))) (S n) *) (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) apply nweight_shift_ai_work with i; try assumption. (* Goal: LIN_DEL nf_list i bs (AVL_intro nf_list ai avl_ai) (AVL_intro nf_list ai' avl_ai') *) (* Goal: le (nweight_Sequent work ds ni (AVL_intro nf_list ai avl_ai)) n *) (* Goal: REGULAR normal_form (AVL_intro nf_list ai' avl_ai') *) (* Goal: Disjunct.a_ai_disj (AVL_intro unit a' avl_a') (AVL_intro nf_list ai' avl_ai') *) (* Goal: Disjunct.a_goal_disj (AVL_intro unit a' avl_a') goal *) (* Goal: forall _ : forall d : nf_list, not (lookup nf_list i ai d), nsearch_spec goal (@cons normal_form (NAtom i) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i i0 : Int) (_ : lt (nweight_Sequent (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i : Int) (n0 : normal_form) (_ : lt (nweight_Sequent (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) unfold LIN_DEL in |- *. (* Goal: lt (S (nweight_Sequent (@cons normal_form b work) ds ni (AVL_intro nf_list ai avl_ai))) (S n) *) (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) apply lin_del; assumption. (* Goal: le (nweight_Sequent work ds ni (AVL_intro nf_list ai avl_ai)) n *) (* Goal: REGULAR normal_form (AVL_intro nf_list ai' avl_ai') *) (* Goal: Disjunct.a_ai_disj (AVL_intro unit a' avl_a') (AVL_intro nf_list ai' avl_ai') *) (* Goal: Disjunct.a_goal_disj (AVL_intro unit a' avl_a') goal *) (* Goal: forall _ : forall d : nf_list, not (lookup nf_list i ai d), nsearch_spec goal (@cons normal_form (NAtom i) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i i0 : Int) (_ : lt (nweight_Sequent (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i : Int) (n0 : normal_form) (_ : lt (nweight_Sequent (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) inversion_clear lt_nweight. (* Goal: le (nweight_Sequent work ds ni (AVL_intro nf_list ai avl_ai)) (nweight_Sequent (@cons normal_form (NAtom i) work) ds ni (AVL_intro nf_list ai avl_ai)) *) (* Goal: le (nweight_Sequent work ds ni (AVL_intro nf_list ai avl_ai)) n *) (* Goal: REGULAR normal_form (AVL_intro nf_list ai' avl_ai') *) (* Goal: Disjunct.a_ai_disj (AVL_intro unit a' avl_a') (AVL_intro nf_list ai' avl_ai') *) (* Goal: Disjunct.a_goal_disj (AVL_intro unit a' avl_a') goal *) (* Goal: forall _ : forall d : nf_list, not (lookup nf_list i ai d), nsearch_spec goal (@cons normal_form (NAtom i) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i i0 : Int) (_ : lt (nweight_Sequent (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i : Int) (n0 : normal_form) (_ : lt (nweight_Sequent (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) apply le_n. (* Goal: le (nweight_Sequent work ds ni (AVL_intro nf_list ai avl_ai)) n *) (* Goal: REGULAR normal_form (AVL_intro nf_list ai' avl_ai') *) (* Goal: Disjunct.a_ai_disj (AVL_intro unit a' avl_a') (AVL_intro nf_list ai' avl_ai') *) (* Goal: Disjunct.a_goal_disj (AVL_intro unit a' avl_a') goal *) (* Goal: forall _ : forall d : nf_list, not (lookup nf_list i ai d), nsearch_spec goal (@cons normal_form (NAtom i) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i i0 : Int) (_ : lt (nweight_Sequent (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i : Int) (n0 : normal_form) (_ : lt (nweight_Sequent (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) apply le_Sn_le. (* Goal: lt (S (nweight_Sequent (@cons normal_form b work) ds ni (AVL_intro nf_list ai avl_ai))) (S n) *) (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) assumption. (* side premisses: Apply ih_n. *) (* Goal: lt (S (nweight_Sequent (@cons normal_form b work) ds ni (AVL_intro nf_list ai avl_ai))) (S n) *) (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) apply regular_EQUIV_DEL with i (AVL_intro nf_list ai avl_ai); assumption. apply disjs_delete_ai with i (AVL_intro unit a avl_a) (AVL_intro nf_list ai avl_ai); (* Goal: lt (S (nweight_Sequent (@cons normal_form b work) ds ni (AVL_intro nf_list ai avl_ai))) (S n) *) (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) assumption. (* Goal: lt (S (nweight_Sequent (@cons normal_form b work) ds ni (AVL_intro nf_list ai avl_ai))) (S n) *) (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) apply goal_disj_insert_a with i (AVL_intro unit a avl_a); assumption. (* Goal: forall _ : forall d : nf_list, not (lookup nf_list i ai d), nsearch_spec goal (@cons normal_form (NAtom i) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i i0 : Int) (_ : lt (nweight_Sequent (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i : Int) (n0 : normal_form) (_ : lt (nweight_Sequent (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) intros not_lookup_bs. (* Goal: lt (S (nweight_Sequent (@cons normal_form b work) ds ni (AVL_intro nf_list ai avl_ai))) (S n) *) (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) apply rule_shift_work_a with (AVL_intro unit a' avl_a'); try assumption. (* Goal: lt (S (nweight_Sequent (@cons normal_form b work) ds ni (AVL_intro nf_list ai avl_ai))) (S n) *) (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) apply ih_work; clear ih_work; try assumption. (* side premisses: Apply ih_work. *) (* Goal: lt (S (nweight_Sequent (@cons normal_form b work) ds ni (AVL_intro nf_list ai avl_ai))) (S n) *) (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) apply goal_disj_insert_a with i (AVL_intro unit a avl_a); assumption. (* Goal: lt (S (nweight_Sequent (@cons normal_form b work) ds ni (AVL_intro nf_list ai avl_ai))) (S n) *) (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) apply disjs_insert_a with i (AVL_intro unit a avl_a); assumption. (* a=(OrF (Atom i) (Atom j)) *) (* Goal: forall (i i0 : Int) (_ : lt (nweight_Sequent (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NDisj i i0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (i : Int) (n0 : normal_form) (_ : lt (nweight_Sequent (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) intros i j lt_nweight. (* Goal: lt (S (nweight_Sequent (@cons normal_form b work) ds ni (AVL_intro nf_list ai avl_ai))) (S n) *) (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) apply rule_shift_work_ds; try assumption. (* Goal: lt (S (nweight_Sequent (@cons normal_form b work) ds ni (AVL_intro nf_list ai avl_ai))) (S n) *) (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) apply ih_work; clear ih_work; try assumption. rewrite <- (nweight_shift_work_ds i j work ds ni (AVL_intro nf_list ai avl_ai)) (* Goal: lt (S (nweight_Sequent (@cons normal_form b work) ds ni (AVL_intro nf_list ai avl_ai))) (S n) *) (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) ; assumption. (* a=(AImp i b) *) (* Goal: forall (i : Int) (n0 : normal_form) (_ : lt (nweight_Sequent (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (AImp i n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) intros i b lt_nweight. (* Goal: nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) elim (lookup_dec unit i a avl_a). (* Goal: forall (d : unit) (_ : lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) intros d; case d; clear d. (* Goal: forall _ : lookup unit i a tt, nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) intros lookup_i. (* Goal: nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) clear ih_work. (* Goal: lt (S (nweight_Sequent (@cons normal_form b work) ds ni (AVL_intro nf_list ai avl_ai))) (S n) *) (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) apply left_p_imp_work; try assumption. (* Goal: lt (S (nweight_Sequent (@cons normal_form b work) ds ni (AVL_intro nf_list ai avl_ai))) (S n) *) (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) apply ih_n; clear ih_n; try assumption. (* Goal: lt (nweight_Sequent (@cons normal_form b work) ds ni (AVL_intro nf_list ai avl_ai)) n *) (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) apply lt_S_n. (* Goal: lt (S (nweight_Sequent (@cons normal_form b work) ds ni (AVL_intro nf_list ai avl_ai))) (S n) *) (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) assumption. (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) intros not_lookup_i. (* Goal: nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) elim (insert_avl nf_list i (cons b) nf_nil ai avl_ai). (* Goal: forall (t : avl_tree nf_list) (_ : lookup_dec_spec nf_list i ai) (_ : is_avl nf_list t) (_ : lin_ins_spec nf_list i (@cons normal_form b) nf_nil ai t) (_ : equiv_ins nf_list i (@cons normal_form b) nf_nil ai t) (_ : sumbool (@eq nat (height_avl nf_list t) (height_avl nf_list ai)) (@eq nat (height_avl nf_list t) (S (height_avl nf_list ai)))), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) intros ai' lookup_dec avl_ai' lin_ins equiv_ins height_dec; clear height_dec. (* Goal: nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) elim lookup_dec; clear lookup_dec. (* Goal: forall (d : nf_list) (_ : lookup nf_list i ai d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall _ : forall d : nf_list, not (lookup nf_list i ai d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) intros bs lookup_bs. apply rule_shift_work_ai_old with bs (AVL_intro nf_list ai' avl_ai'); (* Goal: lt (S (nweight_Sequent (@cons normal_form b work) ds ni (AVL_intro nf_list ai avl_ai))) (S n) *) (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) try assumption. (* Goal: lt (S (nweight_Sequent (@cons normal_form b work) ds ni (AVL_intro nf_list ai avl_ai))) (S n) *) (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) apply ih_work; clear ih_work; try assumption. (* Goal: lt (S (nweight_Sequent (@cons normal_form b work) ds ni (AVL_intro nf_list ai avl_ai))) (S n) *) (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) apply regular_EQUIV_INS with i b (AVL_intro nf_list ai avl_ai); assumption. (* Goal: lt (S (nweight_Sequent (@cons normal_form b work) ds ni (AVL_intro nf_list ai avl_ai))) (S n) *) (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) apply disjs_insert_ai with i b (AVL_intro nf_list ai avl_ai); assumption. rewrite <- (nweight_shift_work_ai i b work ds ni (AVL_intro nf_list ai avl_ai) (* Goal: lt (S (nweight_Sequent (@cons normal_form b work) ds ni (AVL_intro nf_list ai avl_ai))) (S n) *) (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (AVL_intro nf_list ai' avl_ai')); assumption. (* Goal: forall _ : forall d : nf_list, not (lookup nf_list i ai d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) intros notlookup_bs. apply rule_shift_work_ai_new with (AVL_intro nf_list ai' avl_ai'); (* Goal: lt (S (nweight_Sequent (@cons normal_form b work) ds ni (AVL_intro nf_list ai avl_ai))) (S n) *) (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) try assumption. (* Goal: lt (S (nweight_Sequent (@cons normal_form b work) ds ni (AVL_intro nf_list ai avl_ai))) (S n) *) (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) apply ih_work; clear ih_work; try assumption. (* Goal: lt (S (nweight_Sequent (@cons normal_form b work) ds ni (AVL_intro nf_list ai avl_ai))) (S n) *) (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) apply regular_EQUIV_INS with i b (AVL_intro nf_list ai avl_ai); assumption. (* Goal: lt (S (nweight_Sequent (@cons normal_form b work) ds ni (AVL_intro nf_list ai avl_ai))) (S n) *) (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) apply disjs_insert_ai with i b (AVL_intro nf_list ai avl_ai); assumption. rewrite <- (nweight_shift_work_ai i b work ds ni (AVL_intro nf_list ai avl_ai) (* Goal: lt (S (nweight_Sequent (@cons normal_form b work) ds ni (AVL_intro nf_list ai avl_ai))) (S n) *) (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (AVL_intro nf_list ai' avl_ai')); assumption. (* a=(NImp x) *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) intros x lt_nweight. (* Goal: lt (S (nweight_Sequent (@cons normal_form b work) ds ni (AVL_intro nf_list ai avl_ai))) (S n) *) (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) apply rule_shift_work_ni0; try assumption. (* Goal: lt (S (nweight_Sequent (@cons normal_form b work) ds ni (AVL_intro nf_list ai avl_ai))) (S n) *) (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) apply ih_work; clear ih_work; try assumption. rewrite <- (nweight_shift_work_ni0 x work ds ni (AVL_intro nf_list ai avl_ai)) (* Goal: lt (S (nweight_Sequent (@cons normal_form b work) ds ni (AVL_intro nf_list ai avl_ai))) (S n) *) (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) ; assumption. Qed. Theorem nsearch : forall (goal : Int) (work : nf_list) (context : flist), (forall (n : nat) (a : normal_form), my_nth normal_form n work a -> Derivable context (nf2form a)) -> (forall (a : form) (k : kripke_tree), Is_Monotone_kripke_tree k -> (forall b : normal_form, In b work -> forces_t k (nf2form b)) -> In a context -> forces_t k a) -> nsearch_spec_result_aux goal work DNil NNil AI_Nil ANil context. (* Goal: forall (goal : Int) (work : nf_list) (context : flist) (_ : forall (n : nat) (a : normal_form) (_ : my_nth normal_form n work a), Derivable context (nf2form a)) (_ : forall (a : form) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forall (b : normal_form) (_ : @In normal_form b work), forces_t k (nf2form b)) (_ : @In form a context), forces_t k a), nsearch_spec_result_aux goal work DNil NNil AI_Nil ANil context *) intros goal work context sound minimal. elim (nsearch_aux (S (nweight_Sequent work DNil NNil AI_Nil)) goal work DNil NNil AI_Nil ANil context). (* Goal: forall (ni1 : nested_imps) (_ : le_ni ni1 NNil) (_ : deco_sound work DNil ni1 AI_Nil ANil) (_ : nsearch_spec_result_aux goal work DNil ni1 AI_Nil ANil context), nsearch_spec_result_aux goal work DNil NNil AI_Nil ANil context *) (* Goal: lt (nweight_Sequent work DNil NNil AI_Nil) (S (nweight_Sequent work DNil NNil AI_Nil)) *) (* Goal: REGULAR normal_form AI_Nil *) (* Goal: a_ai_disj ANil AI_Nil *) (* Goal: a_goal_disj ANil goal *) (* Goal: deco_sound work DNil NNil AI_Nil ANil *) (* Goal: nsound work DNil NNil AI_Nil ANil context *) (* Goal: nminimal work DNil NNil AI_Nil ANil context *) intros ni1 le1. (* Goal: forall (_ : deco_sound work DNil ni1 AI_Nil ANil) (_ : nsearch_spec_result_aux goal work DNil ni1 AI_Nil ANil context), nsearch_spec_result_aux goal work DNil NNil AI_Nil ANil context *) (* Goal: lt (nweight_Sequent work DNil NNil AI_Nil) (S (nweight_Sequent work DNil NNil AI_Nil)) *) (* Goal: REGULAR normal_form AI_Nil *) (* Goal: a_ai_disj ANil AI_Nil *) (* Goal: a_goal_disj ANil goal *) (* Goal: deco_sound work DNil NNil AI_Nil ANil *) (* Goal: nsound work DNil NNil AI_Nil ANil context *) (* Goal: nminimal work DNil NNil AI_Nil ANil context *) cut (ni1 = NNil). (* Goal: forall (_ : @eq nested_imps ni1 NNil) (_ : deco_sound work DNil ni1 AI_Nil ANil) (_ : nsearch_spec_result_aux goal work DNil ni1 AI_Nil ANil context), nsearch_spec_result_aux goal work DNil NNil AI_Nil ANil context *) (* Goal: @eq nested_imps ni1 NNil *) (* Goal: lt (nweight_Sequent work DNil NNil AI_Nil) (S (nweight_Sequent work DNil NNil AI_Nil)) *) (* Goal: REGULAR normal_form AI_Nil *) (* Goal: a_ai_disj ANil AI_Nil *) (* Goal: a_goal_disj ANil goal *) (* Goal: deco_sound work DNil NNil AI_Nil ANil *) (* Goal: nsound work DNil NNil AI_Nil ANil context *) (* Goal: nminimal work DNil NNil AI_Nil ANil context *) intros claim. (* Goal: forall (_ : deco_sound work DNil ni1 AI_Nil ANil) (_ : nsearch_spec_result_aux goal work DNil ni1 AI_Nil ANil context), nsearch_spec_result_aux goal work DNil NNil AI_Nil ANil context *) (* Goal: @eq nested_imps ni1 NNil *) (* Goal: lt (nweight_Sequent work DNil NNil AI_Nil) (S (nweight_Sequent work DNil NNil AI_Nil)) *) (* Goal: REGULAR normal_form AI_Nil *) (* Goal: a_ai_disj ANil AI_Nil *) (* Goal: a_goal_disj ANil goal *) (* Goal: deco_sound work DNil NNil AI_Nil ANil *) (* Goal: nsound work DNil NNil AI_Nil ANil context *) (* Goal: nminimal work DNil NNil AI_Nil ANil context *) rewrite claim. (* Goal: lt (S (nweight_Sequent (@cons normal_form b work) ds ni (AVL_intro nf_list ai avl_ai))) (S n) *) (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) intros; assumption. (* Goal: @eq nested_imps ni1 NNil *) (* Goal: lt (nweight_Sequent work DNil NNil AI_Nil) (S (nweight_Sequent work DNil NNil AI_Nil)) *) (* Goal: REGULAR normal_form AI_Nil *) (* Goal: a_ai_disj ANil AI_Nil *) (* Goal: a_goal_disj ANil goal *) (* Goal: deco_sound work DNil NNil AI_Nil ANil *) (* Goal: nsound work DNil NNil AI_Nil ANil context *) (* Goal: nminimal work DNil NNil AI_Nil ANil context *) inversion_clear le1. (* Goal: @eq nested_imps NNil NNil *) (* Goal: lt (nweight_Sequent work DNil NNil AI_Nil) (S (nweight_Sequent work DNil NNil AI_Nil)) *) (* Goal: REGULAR normal_form AI_Nil *) (* Goal: a_ai_disj ANil AI_Nil *) (* Goal: a_goal_disj ANil goal *) (* Goal: deco_sound work DNil NNil AI_Nil ANil *) (* Goal: nsound work DNil NNil AI_Nil ANil context *) (* Goal: nminimal work DNil NNil AI_Nil ANil context *) trivial. (* Goal: lt (nweight_Sequent work DNil NNil AI_Nil) (S (nweight_Sequent work DNil NNil AI_Nil)) *) (* Goal: REGULAR normal_form AI_Nil *) (* Goal: a_ai_disj ANil AI_Nil *) (* Goal: a_goal_disj ANil goal *) (* Goal: deco_sound work DNil NNil AI_Nil ANil *) (* Goal: nsound work DNil NNil AI_Nil ANil context *) (* Goal: nminimal work DNil NNil AI_Nil ANil context *) apply lt_n_Sn. (* Goal: REGULAR normal_form AI_Nil *) (* Goal: a_ai_disj ANil AI_Nil *) (* Goal: a_goal_disj ANil goal *) (* Goal: deco_sound work DNil NNil AI_Nil ANil *) (* Goal: nsound work DNil NNil AI_Nil ANil context *) (* Goal: nminimal work DNil NNil AI_Nil ANil context *) unfold AI_Nil in |- *. (* Goal: REGULAR normal_form (AVL_NIL nf_list) *) (* Goal: a_ai_disj ANil AI_Nil *) (* Goal: a_goal_disj ANil goal *) (* Goal: deco_sound work DNil NNil AI_Nil ANil *) (* Goal: nsound work DNil NNil AI_Nil ANil context *) (* Goal: nminimal work DNil NNil AI_Nil ANil context *) unfold nf_list in |- *. (* Goal: REGULAR normal_form (AVL_NIL (list normal_form)) *) (* Goal: a_ai_disj ANil AI_Nil *) (* Goal: a_goal_disj ANil goal *) (* Goal: deco_sound work DNil NNil AI_Nil ANil *) (* Goal: nsound work DNil NNil AI_Nil ANil context *) (* Goal: nminimal work DNil NNil AI_Nil ANil context *) apply regular_AVL_NIL. (* Goal: a_ai_disj ANil AI_Nil *) (* Goal: a_goal_disj ANil goal *) (* Goal: deco_sound work DNil NNil AI_Nil ANil *) (* Goal: nsound work DNil NNil AI_Nil ANil context *) (* Goal: nminimal work DNil NNil AI_Nil ANil context *) unfold a_ai_disj in |- *. (* Goal: forall (i : Int) (_ : LOOKUP unit i ANil tt) (bs : nf_list) (_ : LOOKUP nf_list i AI_Nil bs), False *) (* Goal: a_goal_disj ANil goal *) (* Goal: deco_sound work DNil NNil AI_Nil ANil *) (* Goal: nsound work DNil NNil AI_Nil ANil context *) (* Goal: nminimal work DNil NNil AI_Nil ANil context *) intros i lookup_i bs lookup_bs. (* Goal: False *) (* Goal: a_goal_disj ANil goal *) (* Goal: deco_sound work DNil NNil AI_Nil ANil *) (* Goal: nsound work DNil NNil AI_Nil ANil context *) (* Goal: nminimal work DNil NNil AI_Nil ANil context *) inversion_clear lookup_i. (* Goal: a_goal_disj ANil goal *) (* Goal: deco_sound work DNil NNil AI_Nil ANil *) (* Goal: nsound work DNil NNil AI_Nil ANil context *) (* Goal: nminimal work DNil NNil AI_Nil ANil context *) unfold a_goal_disj in |- *. (* Goal: forall _ : LOOKUP unit goal ANil tt, False *) (* Goal: deco_sound work DNil NNil AI_Nil ANil *) (* Goal: nsound work DNil NNil AI_Nil ANil context *) (* Goal: nminimal work DNil NNil AI_Nil ANil context *) intros lookup_goal. (* Goal: False *) (* Goal: deco_sound work DNil NNil AI_Nil ANil *) (* Goal: nsound work DNil NNil AI_Nil ANil context *) (* Goal: nminimal work DNil NNil AI_Nil ANil context *) inversion_clear lookup_goal. (* Goal: deco_sound work DNil NNil AI_Nil ANil *) (* Goal: nsound work DNil NNil AI_Nil ANil context *) (* Goal: nminimal work DNil NNil AI_Nil ANil context *) unfold deco_sound in |- *. (* Goal: forall (k : kripke_tree) (i0 i1 : Int) (b : normal_form) (_ : @In nested_imp (Decorated (NImp i0 i1 b) k) NNil), k_deco_sound k i0 i1 work DNil NNil AI_Nil ANil *) (* Goal: nsound work DNil NNil AI_Nil ANil context *) (* Goal: nminimal work DNil NNil AI_Nil ANil context *) intros k i0 i1 b in_k. (* Goal: k_deco_sound k i0 i1 work DNil NNil AI_Nil ANil *) (* Goal: nsound work DNil NNil AI_Nil ANil context *) (* Goal: nminimal work DNil NNil AI_Nil ANil context *) inversion_clear in_k. (* Goal: nsound work DNil NNil AI_Nil ANil context *) (* Goal: nminimal work DNil NNil AI_Nil ANil context *) unfold nsound in |- *. (* Goal: forall (c : normal_form) (_ : in_ngamma work DNil NNil AI_Nil ANil c), Derivable context (nf2form c) *) (* Goal: nminimal work DNil NNil AI_Nil ANil context *) intros a in_ngamma. (* Goal: Derivable context (nf2form a) *) (* Goal: nminimal work DNil NNil AI_Nil ANil context *) elim in_ngamma; clear in_ngamma a. (* Goal: forall (n : nat) (c : normal_form) (_ : my_nth normal_form n work c), Derivable context (nf2form c) *) (* Goal: forall (n : nat) (i j : Int) (_ : my_nth disj n DNil (@pair Int Int i j)), Derivable context (nf2form (NDisj i j)) *) (* Goal: forall (n : nat) (x : nimp) (_ : my_nth nimp n (nested_imps2nimps NNil) x), Derivable context (nf2form (NImp_NF x)) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i AI_Nil bs) (_ : my_nth normal_form n bs b), Derivable context (nf2form (AImp i b)) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i ANil tt), Derivable context (nf2form (NAtom i)) *) (* Goal: nminimal work DNil NNil AI_Nil ANil context *) intros n a nth. (* Goal: lt (S (nweight_Sequent (@cons normal_form b work) ds ni (AVL_intro nf_list ai avl_ai))) (S n) *) (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) apply sound with n; assumption. (* Goal: forall (n : nat) (i j : Int) (_ : my_nth disj n DNil (@pair Int Int i j)), Derivable context (nf2form (NDisj i j)) *) (* Goal: forall (n : nat) (x : nimp) (_ : my_nth nimp n (nested_imps2nimps NNil) x), Derivable context (nf2form (NImp_NF x)) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i AI_Nil bs) (_ : my_nth normal_form n bs b), Derivable context (nf2form (AImp i b)) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i ANil tt), Derivable context (nf2form (NAtom i)) *) (* Goal: nminimal work DNil NNil AI_Nil ANil context *) intros n i j nth; elimtype False; inversion_clear nth. (* Goal: forall (n : nat) (x : nimp) (_ : my_nth nimp n (nested_imps2nimps NNil) x), Derivable context (nf2form (NImp_NF x)) *) (* Goal: forall (i : Int) (b : normal_form) (n : nat) (bs : nf_list) (_ : LOOKUP nf_list i AI_Nil bs) (_ : my_nth normal_form n bs b), Derivable context (nf2form (AImp i b)) *) (* Goal: forall (i : Int) (_ : LOOKUP unit i ANil tt), Derivable context (nf2form (NAtom i)) *) (* Goal: nminimal work DNil NNil AI_Nil ANil context *) intros n x nth; elimtype False; inversion_clear nth. (* Goal: False *) (* Goal: a_goal_disj ANil goal *) (* Goal: deco_sound work DNil NNil AI_Nil ANil *) (* Goal: nsound work DNil NNil AI_Nil ANil context *) (* Goal: nminimal work DNil NNil AI_Nil ANil context *) intros i b n bs lookup_i nth; elimtype False; inversion_clear lookup_i. (* Goal: forall (i : Int) (_ : LOOKUP unit i ANil tt), Derivable context (nf2form (NAtom i)) *) (* Goal: nminimal work DNil NNil AI_Nil ANil context *) intros i lookup; elimtype False; inversion_clear lookup. (* Goal: nminimal work DNil NNil AI_Nil ANil context *) unfold nminimal in |- *. (* Goal: forall (c : form) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma work DNil NNil AI_Nil ANil k) (_ : @In form c context), forces_t k c *) intros a k k_is_mon k_forces_gamma in_a. (* Goal: lt (S (nweight_Sequent (@cons normal_form b work) ds ni (AVL_intro nf_list ai avl_ai))) (S n) *) (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) apply minimal; try assumption. (* Goal: forall (b : normal_form) (_ : @In normal_form b work), forces_t k (nf2form b) *) intros b in_b. (* Goal: forces_t k (nf2form b) *) elim (in_nth normal_form b work in_b). (* Goal: forall (x : nat) (_ : my_nth normal_form x work b), forces_t k (nf2form b) *) intros n nth. (* Goal: forces_t k (nf2form b) *) apply k_forces_gamma. (* Goal: lt (S (nweight_Sequent (@cons normal_form b work) ds ni (AVL_intro nf_list ai avl_ai))) (S n) *) (* Goal: forall _ : forall d : unit, not (lookup unit i a d), nsearch_spec goal (@cons normal_form (AImp i b) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) (* Goal: forall (n0 : nimp) (_ : lt (nweight_Sequent (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai)) (S n)), nsearch_spec goal (@cons normal_form (NImp_NF n0) work) ds ni (AVL_intro nf_list ai avl_ai) (AVL_intro unit a avl_a) context *) apply In_Work with n; assumption. Qed.
(* File: Rules.v (last edited on 27/10/2000) (c) Klaus Weich *) Require Export Minimal. Require Export Sound. Require Export NSearch. Inductive search_spec_aux (goal : form) (gamma : flist) (work : nf_list) (context : flist) : Set := | derivable : Derivable context goal -> search_spec_aux goal gamma work context | refutable : forall k : kripke_tree, Is_Monotone_kripke_tree k -> forces_gamma gamma work k -> (forces_t k goal -> False) -> search_spec_aux goal gamma work context. Definition search_spec (goal : form) (gamma : flist) (work : nf_list) (context : flist) (i : Int) := below_form goal i -> below_list gamma i -> below_list context i -> sound gamma work context -> minimal gamma work context -> search_spec_aux goal gamma work context. (**********************************************************************) Lemma rule_shift_gamma_work : forall (goal : form) (l : list Int) (a : normal_form) (gamma : flist) (work : nf_list) (context : flist) (j : Int), search_spec goal gamma (nvimp l a :: work) context j -> search_spec goal (vimp l (nf2form a) :: gamma) work context j. (* Goal: forall (goal : form) (l : list Int) (a : form) (gamma : flist) (work : nf_list) (context : flist) (j : Int) (_ : search_spec goal (@cons form (vimp l a) gamma) work context j), search_spec goal (@cons form (vimp l (OrF a Falsum)) gamma) work context j *) intros goal l a gamma work context j spec0. (* Goal: search_spec goal (@cons form (vimp l (nf2form a)) gamma) work context j *) rewrite (vimp_eq_nvimp l a). (* Goal: search_spec goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context j *) unfold search_spec in |- *. (* Goal: forall (_ : below_form goal j) (_ : below_list (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) j) (_ : below_list context j) (_ : sound (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context) (_ : minimal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) intros below_goal below_gamma below_context sound0 minimal0. (* Goal: search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) elim spec0; clear spec0; try assumption. (* Goal: forall _ : Derivable context goal, search_spec_aux goal (@cons form (vimp l (Imp (Imp Falsum b) c)) gamma) work context *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l c) gamma) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp Falsum b) c)) gamma) work context *) (* Goal: below_list (@cons form (vimp l c) gamma) j *) (* Goal: sound (@cons form (vimp l c) gamma) work context *) (* Goal: minimal (@cons form (vimp l c) gamma) work context *) intros der_goal; apply derivable; assumption. (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) intros k k_is_mon k_forces_gamma k_notforces_goal. (* Goal: search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) apply refutable with k; try assumption. (* Goal: forces_gamma (@cons form (nf2form (nvimp l a)) gamma) work k *) (* Goal: below_list gamma j *) (* Goal: sound gamma (@cons normal_form (nvimp l a) work) context *) (* Goal: minimal gamma (@cons normal_form (nvimp l a) work) context *) apply forces_gamma_shift_work_gamma; assumption. (* Goal: below_list gamma j *) (* Goal: sound gamma (@cons normal_form (nvimp l a) work) context *) (* Goal: minimal gamma (@cons normal_form (nvimp l a) work) context *) apply below_cons_list_tail with (nf2form (nvimp l a)); assumption. (* Goal: sound gamma (@cons normal_form (nvimp l a) work) context *) (* Goal: minimal gamma (@cons normal_form (nvimp l a) work) context *) apply sound_shift_gamma_work; assumption. (* Goal: minimal gamma (@cons normal_form (nvimp l a) work) context *) apply minimal_shift_gamma_work; assumption. Qed. (*********************************************************************) Lemma search_spec_subst_gamma_pos : forall (goal : form) (gamma : flist) (work : nf_list) (context : flist) (j j1 : Int) (a b c : form), Less j j1 -> (below_form c j -> below_form a j /\ below_form b j1 /\ subst_form j a b = c) -> (forall k : kripke_tree, Is_Monotone_kripke_tree k -> forces_t k b -> forces_t k (Imp (Atom j) a) -> forces_t k c) -> search_spec goal (b :: Imp (Atom j) a :: gamma) work (b :: Imp (Atom j) a :: context) j1 -> search_spec goal (c :: gamma) work context j. (* Goal: forall (goal : form) (gamma : flist) (work : nf_list) (context : flist) (j j1 : Int) (a b c : form) (_ : Less j j1) (_ : forall _ : below_form c j, and (below_form a j) (and (below_form b j1) (@eq form (subst_form j a b) c))) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k b) (_ : forces_t k (Imp (Atom j) a)), forces_t k c) (_ : search_spec goal (@cons form b (@cons form (Imp (Atom j) a) gamma)) work (@cons form b (@cons form (Imp (Atom j) a) context)) j1), search_spec goal (@cons form c gamma) work context j *) intros goal gamma work context j j1 a b c less1 below_x forces0 spec0. (* Goal: search_spec goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context j *) unfold search_spec in |- *. (* Goal: forall (_ : below_form goal j) (_ : below_list (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) j) (_ : below_list context j) (_ : sound (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context) (_ : minimal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) intros below_goal below_gamma below_context sound0 minimal0. (* Goal: search_spec_aux goal (@cons form c gamma) work context *) generalize (below_cons_list_head c gamma j below_gamma). (* Goal: forall _ : below_form (vimp l (OrF a b)) j, and (below_form a j) (and (below_form (vimp l (OrF (Atom j) b)) j1) (@eq form (subst_form j a (vimp l (OrF (Atom j) b))) (vimp l (OrF a b)))) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (OrF (Atom j) b))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (OrF a b)) *) intros below_c. (* Goal: search_spec_aux goal (@cons form c gamma) work context *) generalize (below_x below_c); clear below_x; intros below_x. (* Goal: search_spec_aux goal (@cons form c gamma) work context *) elim below_x; clear below_x; intros below_a below_x. (* Goal: search_spec_aux goal (@cons form c gamma) work context *) elim below_x; clear below_x; intros below_b eq_c. generalize (below_cons_list_tail c gamma j below_gamma); clear below_gamma; intros below_gamma. (* Goal: search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) elim spec0; clear spec0; try assumption. (* Goal: forall _ : Derivable (@cons form b (@cons form (Imp (Atom j) a) context)) goal, search_spec_aux goal (@cons form c gamma) work context *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form b (@cons form (Imp (Atom j) a) gamma)) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form c gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form b (@cons form (Imp (Atom j) a) gamma)) j1 *) (* Goal: below_list (@cons form b (@cons form (Imp (Atom j) a) context)) j1 *) (* Goal: sound (@cons form b (@cons form (Imp (Atom j) a) gamma)) work (@cons form b (@cons form (Imp (Atom j) a) context)) *) (* Goal: minimal (@cons form b (@cons form (Imp (Atom j) a) gamma)) work (@cons form b (@cons form (Imp (Atom j) a) context)) *) clear minimal0 forces0. (* Goal: forall _ : Derivable (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) goal, search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) intros derivable_i. (* Goal: search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) apply derivable. (* Goal: Derivable context goal *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form b (@cons form (Imp (Atom j) a) gamma)) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form c gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form b (@cons form (Imp (Atom j) a) gamma)) j1 *) (* Goal: below_list (@cons form b (@cons form (Imp (Atom j) a) context)) j1 *) (* Goal: sound (@cons form b (@cons form (Imp (Atom j) a) gamma)) work (@cons form b (@cons form (Imp (Atom j) a) context)) *) (* Goal: minimal (@cons form b (@cons form (Imp (Atom j) a) gamma)) work (@cons form b (@cons form (Imp (Atom j) a) context)) *) apply derivable_cut with (subst_form j a (Imp (Atom j) a)). (* Goal: @eq form (vimp l (subst_form j a (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) simpl in |- *. (* Goal: @eq flist (@cons form (Imp (subst_form j a a) (if equal_dec j j then a else Atom j)) (subst_list j a context)) (@cons form (Imp a a) context) *) (* Goal: @eq form (subst_form j a (Atom j)) a *) (* Goal: Derivable (subst_list j a (@cons form (Imp a (Atom j)) context)) (subst_form j a (Atom j)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (Imp a (Atom j)) gamma) work k) (_ : forall _ : forces_t k (Atom j), False), search_spec_aux a gamma work context *) (* Goal: below_list (@cons form (Imp a (Atom j)) gamma) j1 *) (* Goal: below_list (@cons form (Imp a (Atom j)) context) j1 *) (* Goal: sound (@cons form (Imp a (Atom j)) gamma) work (@cons form (Imp a (Atom j)) context) *) (* Goal: minimal (@cons form (Imp a (Atom j)) gamma) work (@cons form (Imp a (Atom j)) context) *) rewrite (subst_form_below j a a); try assumption. (* Goal: @eq form (vimp l (Imp (Imp (if equal_dec j j then a else Atom j) b) c)) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) rewrite (equal_dec_refl j form a (Atom j)). (* Goal: Derivable fnil (Imp a a) *) (* Goal: Derivable (@cons form (Imp a a) context) a *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (Imp a (Atom j)) gamma) work k) (_ : forall _ : forces_t k (Atom j), False), search_spec_aux a gamma work context *) (* Goal: below_list (@cons form (Imp a (Atom j)) gamma) j1 *) (* Goal: below_list (@cons form (Imp a (Atom j)) context) j1 *) (* Goal: sound (@cons form (Imp a (Atom j)) gamma) work (@cons form (Imp a (Atom j)) context) *) (* Goal: minimal (@cons form (Imp a (Atom j)) gamma) work (@cons form (Imp a (Atom j)) context) *) apply derivable_a_imp_a. (* Goal: Derivable (@cons form (subst_form j a (Imp (Atom j) a)) context) goal *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form b (@cons form (Imp (Atom j) a) gamma)) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form c gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form b (@cons form (Imp (Atom j) a) gamma)) j1 *) (* Goal: below_list (@cons form b (@cons form (Imp (Atom j) a) context)) j1 *) (* Goal: sound (@cons form b (@cons form (Imp (Atom j) a) gamma)) work (@cons form b (@cons form (Imp (Atom j) a) context)) *) (* Goal: minimal (@cons form b (@cons form (Imp (Atom j) a) gamma)) work (@cons form b (@cons form (Imp (Atom j) a) context)) *) apply derivable_cut_merge with c. (* Goal: Derivable (@cons form (subst_form j b (vimp l (Imp (Atom a) (Imp b (Atom j))))) context) (subst_form j b (vimp l (Imp (Imp (Atom a) (Atom j)) c))) *) (* Goal: Derivable (@cons form (subst_form j b (vimp l (Imp (Imp (Atom a) (Atom j)) c))) (@cons form (subst_form j b (vimp l (Imp (Atom a) (Imp b (Atom j))))) context)) goal *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) apply derivable_weak. (* Goal: Derivable context (vimp l (Imp (Imp (Atom a) b) c)) *) (* Goal: Derivable (@cons form (subst_form j b (vimp l (Imp (Imp (Atom a) (Atom j)) c))) (@cons form (subst_form j b (vimp l (Imp (Atom a) (Imp b (Atom j))))) context)) goal *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) apply sound0. (* Goal: in_gamma (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma) work (vimp (@cons Int a l) (Imp b (Atom j))) *) (* Goal: forces_t k x *) apply in_gamma_cons_gamma_head. (* Goal: Derivable (@cons form c (@cons form (subst_form j a (Imp (Atom j) a)) context)) goal *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form b (@cons form (Imp (Atom j) a) gamma)) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form c gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form b (@cons form (Imp (Atom j) a) gamma)) j1 *) (* Goal: below_list (@cons form b (@cons form (Imp (Atom j) a) context)) j1 *) (* Goal: sound (@cons form b (@cons form (Imp (Atom j) a) gamma)) work (@cons form b (@cons form (Imp (Atom j) a) context)) *) (* Goal: minimal (@cons form b (@cons form (Imp (Atom j) a) gamma)) work (@cons form b (@cons form (Imp (Atom j) a) context)) *) rewrite <- eq_c. (* Goal: Derivable (@cons form (subst_form j a b) (@cons form (subst_form j a (Imp (Atom j) a)) context)) goal *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form b (@cons form (Imp (Atom j) a) gamma)) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form c gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form b (@cons form (Imp (Atom j) a) gamma)) j1 *) (* Goal: below_list (@cons form b (@cons form (Imp (Atom j) a) context)) j1 *) (* Goal: sound (@cons form b (@cons form (Imp (Atom j) a) gamma)) work (@cons form b (@cons form (Imp (Atom j) a) context)) *) (* Goal: minimal (@cons form b (@cons form (Imp (Atom j) a) gamma)) work (@cons form b (@cons form (Imp (Atom j) a) context)) *) rewrite <- (subst_form_below j a goal); try assumption. (* Goal: Derivable (@cons form (subst_form j a b) (@cons form (subst_form j a (Imp (Atom j) a)) context)) (subst_form j a goal) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form b (@cons form (Imp (Atom j) a) gamma)) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form c gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form b (@cons form (Imp (Atom j) a) gamma)) j1 *) (* Goal: below_list (@cons form b (@cons form (Imp (Atom j) a) context)) j1 *) (* Goal: sound (@cons form b (@cons form (Imp (Atom j) a) gamma)) work (@cons form b (@cons form (Imp (Atom j) a) context)) *) (* Goal: minimal (@cons form b (@cons form (Imp (Atom j) a) gamma)) work (@cons form b (@cons form (Imp (Atom j) a) context)) *) rewrite <- (subst_list_below j a context); try assumption. change (Derivable (subst_list j a (b :: Imp (Atom j) a :: context)) (subst_form j a goal)) in |- *. (* Goal: Derivable (subst_list j b (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp l (Imp (Atom a) (Imp b (Atom j)))) context))) (subst_form j b goal) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) apply derivable_subst; assumption. (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) clear minimal0 sound0 below_context below_gamma below_goal. (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) intros k k_is_mon k_forces_gamma k_notforces_goal. (* Goal: search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) apply refutable with k; try assumption. (* Goal: forces_gamma (@cons form c gamma) work k *) apply forces_gamma_cons_gamma_weak2 with b (Imp (Atom j) a); try assumption. (* Goal: forall (_ : forces_t k (vimp l (Imp (Imp (Atom a) (Atom j)) c))) (_ : forces_t k (vimp (@cons Int a l) (Imp b (Atom j)))), forces_t k (vimp l (Imp (Imp (Atom a) b) c)) *) intros forces1 forces2. (* Goal: forces_t k c *) apply forces0; assumption. (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_form_less_below_form with j; assumption. (* Goal: below_list (@cons form b (@cons form (Imp (Atom j) a) gamma)) j1 *) (* Goal: below_list (@cons form b (@cons form (Imp (Atom j) a) context)) j1 *) (* Goal: sound (@cons form b (@cons form (Imp (Atom j) a) gamma)) work (@cons form b (@cons form (Imp (Atom j) a) context)) *) (* Goal: minimal (@cons form b (@cons form (Imp (Atom j) a) gamma)) work (@cons form b (@cons form (Imp (Atom j) a) context)) *) clear minimal0 sound0 forces0. (* Goal: below_list (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) apply below_cons_list. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) assumption. (* Goal: below_list (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) apply below_cons_list. (* Goal: below_form (Imp (Atom j) b) j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) split. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) assumption. (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_form_less_below_form with j; assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_list_less_below_list with j; assumption. (* Goal: below_list (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) apply below_cons_list. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) assumption. (* Goal: below_list (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) apply below_cons_list. (* Goal: below_form (Imp (Atom j) b) j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) split. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) assumption. (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_form_less_below_form with j; assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_list_less_below_list with j; assumption. (* Goal: sound (@cons form b (@cons form (Imp (Atom j) a) gamma)) work (@cons form b (@cons form (Imp (Atom j) a) context)) *) (* Goal: minimal (@cons form b (@cons form (Imp (Atom j) a) gamma)) work (@cons form b (@cons form (Imp (Atom j) a) context)) *) clear minimal0 below_context below_gamma below_goal forces0. (* Goal: sound (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma) work (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) apply sound_cons_gamma_cons_context. (* Goal: sound (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma) work (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) apply sound_cons_gamma_cons_context. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply sound_cons_gamma_tail with c; assumption. (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) clear sound0 below_context below_gamma below_goal below_b below_a. (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) unfold minimal in |- *. (* Goal: forall (a0 : form) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work k) (_ : @In form a0 (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context))), forces_t k a0 *) intros x k k_is_mon k_forces_gamma in_x. (* Goal: forces_t k x *) inversion_clear in_x. (* Goal: forces_t k x *) (* Goal: forces_t k x *) rewrite <- H; clear H x. (* Goal: forces_t k (vimp (@cons Int a l) (Imp b (Atom j))) *) (* Goal: forces_t k x *) apply k_forces_gamma. (* Goal: in_gamma (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma) work (vimp (@cons Int a l) (Imp b (Atom j))) *) (* Goal: forces_t k x *) apply in_gamma_cons_gamma_head. (* Goal: forces_t k x *) inversion_clear H. (* Goal: forces_t k x *) (* Goal: forces_t k x *) rewrite <- H0; clear H0 x. (* Goal: forces_t k (vimp (@cons Int a l) (Imp b (Atom j))) *) (* Goal: forces_t k x *) apply k_forces_gamma. (* Goal: in_gamma (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (vimp (@cons Int a l) (Imp b (Atom j))) *) (* Goal: forces_t k x *) apply in_gamma_cons_gamma_tail. (* Goal: in_gamma (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma) work (vimp (@cons Int a l) (Imp b (Atom j))) *) (* Goal: forces_t k x *) apply in_gamma_cons_gamma_head. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply minimal0; try assumption. (* Goal: forces_gamma (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work k *) clear H0 x. (* Goal: forces_gamma (@cons form c gamma) work k *) apply forces_gamma_cons_gamma_weak2 with b (Imp (Atom j) a); try assumption. (* Goal: forall (_ : forces_t k (vimp l (Imp (Imp (Atom a) (Atom j)) c))) (_ : forces_t k (vimp (@cons Int a l) (Imp b (Atom j)))), forces_t k (vimp l (Imp (Imp (Atom a) b) c)) *) intros forces1 forces2. (* Goal: forces_t k c *) apply forces0; assumption. Qed. (* Lemma search_spec_subst_gamma : (goal:form; gamma:flist; work:nf_list; context:flist; j,j1:Int; a,b,c,d:form) (Less j j1) ->((below_form c j) -> (below_form a j) /\ (below_form b j1) /\ (below_form d j1) /\ (subst_form j a b)=c /\ (subst_form j a d)=(Imp a a)) ->((k:kripke_tree) (Is_Monotone_kripke_tree k) ->(forces_t k b)->(forces_t k d)->(forces_t k c)) ->(search_spec goal (cons b (cons d gamma)) work (cons b (cons d context)) j1) ->(search_spec goal (cons c gamma) work context j). Intros goal gamma work context j j1 a b c d less1 below_x forces0 spec0. Unfold search_spec. Intros below_goal below_gamma below_context sound0 minimal0. Generalize (below_cons_list_head c gamma j below_gamma). Intros below_c. Generalize (below_x below_c); Clear below_x; Intros below_x. Elim below_x; Clear below_x; Intros below_a below_x. Elim below_x; Clear below_x; Intros below_b below_x. Elim below_x; Clear below_x; Intros below_d below_x. Elim below_x; Clear below_x; Intros eq_c eq_d. Generalize (below_cons_list_tail c gamma j below_gamma); Clear below_gamma; Intros below_gamma. Elim spec0; Clear spec0; Try Assumption. Clear minimal0 forces0. Intros derivable_i. Apply derivable. Apply derivable_cut with (subst_form j a d). Rewrite eq_d. Apply derivable_a_imp_a. Apply derivable_cut_merge with c. Apply derivable_weak. Apply sound0. Apply in_gamma_cons_gamma_head. Rewrite <- eq_c. Rewrite <- (subst_form_below j a goal); Try Assumption. Rewrite <- (subst_list_below j a context); Try Assumption. Change (Derivable (subst_list j a (cons b (cons d context))) (subst_form j a goal)). Apply derivable_subst; Assumption. Clear minimal0 sound0 below_context below_gamma below_goal. Intros k k_is_mon k_forces_gamma k_notforces_goal. Apply refutable with k; Try Assumption. Apply forces_gamma_cons_gamma_weak2 with b d; Try Assumption. Intros forces1 forces2. Apply forces0; Assumption. Apply below_form_less_below_form with j; Assumption. Clear minimal0 sound0 forces0. Apply below_cons_list. Assumption. Apply below_cons_list. Assumption. Apply below_list_less_below_list with j; Assumption. Apply below_cons_list. Assumption. Apply below_cons_list. Assumption. Apply below_list_less_below_list with j; Assumption. Clear minimal0 below_context below_gamma below_goal forces0. Apply sound_cons_gamma_cons_context. Apply sound_cons_gamma_cons_context. Apply sound_cons_gamma_tail with c; Assumption. Clear sound0 below_context below_gamma below_goal below_b below_a. Unfold minimal. Intros x k k_is_mon k_forces_gamma in_x. Inversion_clear in_x. Rewrite <- H; Clear H x. Apply k_forces_gamma. Apply in_gamma_cons_gamma_head. Inversion_clear H. Rewrite <- H0; Clear H0 x. Apply k_forces_gamma. Apply in_gamma_cons_gamma_tail. Apply in_gamma_cons_gamma_head. Apply minimal0; Try Assumption. Clear H0 x. Apply forces_gamma_cons_gamma_weak2 with b d; Try Assumption. Intros forces1 forces1. Apply forces0; Assumption. Save. *) Lemma rule_vimp_a_gamma : forall (goal : form) (l : list Int) (a : form) (gamma : flist) (work : nf_list) (context : flist) (j j1 : Int), Less j j1 -> search_spec goal (vimp (j :: nil) a :: gamma) (nvimp l (NAtom j) :: work) (vimp l (Atom j) :: Imp (Atom j) a :: context) j1 -> search_spec goal (vimp l a :: gamma) work context j. (* Goal: forall (goal : form) (l : list Int) (a : form) (gamma : flist) (work : nf_list) (context : flist) (j j1 : Int) (_ : Less j j1) (_ : search_spec goal (@cons form (vimp (@cons Int j (@nil Int)) a) gamma) (@cons normal_form (nvimp l (NAtom j)) work) (@cons form (vimp l (Atom j)) (@cons form (Imp (Atom j) a) context)) j1), search_spec goal (@cons form (vimp l a) gamma) work context j *) intros goal l a gamma work context j j1 less1 spec0. apply search_spec_subst_gamma_pos with (j1 := j1) (a := a) (b := vimp l (Atom j)); (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) try assumption. (* Goal: forall _ : below_form (vimp l (OrF a b)) j, and (below_form a j) (and (below_form (vimp l (OrF (Atom j) b)) j1) (@eq form (subst_form j a (vimp l (OrF (Atom j) b))) (vimp l (OrF a b)))) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (OrF (Atom j) b))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (OrF a b)) *) intros below_c. (* Goal: and (below_form a j) (and (below_form (vimp l (Atom j)) j1) (@eq form (subst_form j a (vimp l (Atom j))) (vimp l a))) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Atom j))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l a) *) (* Goal: search_spec goal (@cons form (vimp l (Atom j)) (@cons form (Imp (Atom j) a) gamma)) work (@cons form (vimp l (Atom j)) (@cons form (Imp (Atom j) a) context)) j1 *) generalize (below_vimp_tail j l a below_c). (* Goal: forall _ : forall (i : Int) (_ : @In Int i l), Less i j, and (below_form a j) (and (below_form (vimp l (Atom j)) j1) (@eq form (subst_form j a (vimp l (Atom j))) (vimp l a))) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Atom j))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l a) *) (* Goal: search_spec goal (@cons form (vimp l (Atom j)) (@cons form (Imp (Atom j) a) gamma)) work (@cons form (vimp l (Atom j)) (@cons form (Imp (Atom j) a) context)) j1 *) generalize (below_vimp_head j l a below_c); clear below_c. (* Goal: forall (_ : below_form a j) (_ : forall (i : Int) (_ : @In Int i l), Less i j), and (below_form a j) (and (below_form (vimp l (Atom j)) j1) (@eq form (subst_form j a (vimp l (Atom j))) (vimp l a))) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Atom j))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l a) *) (* Goal: search_spec goal (@cons form (vimp l (Atom j)) (@cons form (Imp (Atom j) a) gamma)) work (@cons form (vimp l (Atom j)) (@cons form (Imp (Atom j) a) context)) j1 *) intros below_a below_l. (* Goal: below_form (Imp (Atom j) b) j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) split. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) assumption. (* Goal: below_form (Imp (Atom j) b) j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) split. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_vimp_split; try assumption. (* Goal: forall (i : Int) (_ : @In Int i l), Less i j1 *) (* Goal: below_form (Imp a (Atom j)) j1 *) (* Goal: @eq form (subst_form j b (vimp l (Imp a (Atom j)))) (vimp l (Imp a b)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp a (Atom j)))) (_ : forces_t k (Imp (Atom j) b)), forces_t k (vimp l (Imp a b)) *) intros i in0. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply less_trans with j; try assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_l; assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) rewrite (subst_vimp_head j a l (Atom j)); try assumption. (* Goal: @eq form (vimp l (subst_form j a (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) simpl in |- *. (* Goal: @eq form (vimp l (Imp (Imp (if equal_dec j j then a else Atom j) b) c)) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) rewrite (equal_dec_refl j form a (Atom j)). (* Goal: @eq form (vimp l (Imp (Imp a b) c)) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) trivial. (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) intros k k_is_mon forces1 forces2. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply forces_vimp with (Atom j); try assumption. (* Goal: forall (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (Imp a (Atom j))), forces_t2 k k' (Imp a b) *) intros k' suc1 forces_j. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply (forces2 k'); assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply rule_shift_gamma_work with (a := NAtom j); assumption. Qed. Lemma rule_vimp_imp_gamma : forall (goal : form) (l : list Int) (a b : form) (gamma : flist) (work : nf_list) (context : flist) (j j1 : Int), Less j j1 -> search_spec goal (vimp l (Imp a (Atom j)) :: vimp (j :: nil) b :: gamma) work (vimp l (Imp a (Atom j)) :: Imp (Atom j) b :: context) j1 -> search_spec goal (vimp l (Imp a b) :: gamma) work context j. (* Goal: forall (goal : form) (l : list Int) (a b : form) (gamma : flist) (work : nf_list) (context : flist) (j j1 : Int) (_ : Less j j1) (_ : search_spec goal (@cons form (vimp l (OrF (Atom j) b)) (@cons form (vimp (@cons Int j (@nil Int)) a) gamma)) work (@cons form (vimp l (OrF (Atom j) b)) (@cons form (Imp (Atom j) a) context)) j1), search_spec goal (@cons form (vimp l (OrF a b)) gamma) work context j *) intros goal l a b gamma work context j j1 less1 spec0. apply search_spec_subst_gamma_pos with (j1 := j1) (a := b) (b := vimp l (Imp a (Atom j))); try assumption; clear spec0. (* Goal: forall _ : below_form (vimp l (OrF a b)) j, and (below_form a j) (and (below_form (vimp l (OrF (Atom j) b)) j1) (@eq form (subst_form j a (vimp l (OrF (Atom j) b))) (vimp l (OrF a b)))) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (OrF (Atom j) b))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (OrF a b)) *) intros below_c. (* Goal: and (below_form b j) (and (below_form (vimp l (Imp a (Atom j))) j1) (@eq form (subst_form j b (vimp l (Imp a (Atom j)))) (vimp l (Imp a b)))) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp a (Atom j)))) (_ : forces_t k (Imp (Atom j) b)), forces_t k (vimp l (Imp a b)) *) generalize (below_vimp_tail j l (Imp a b) below_c). (* Goal: forall _ : forall (i : Int) (_ : @In Int i l), Less i j, and (below_form b j) (and (below_form (vimp l (Imp a (Atom j))) j1) (@eq form (subst_form j b (vimp l (Imp a (Atom j)))) (vimp l (Imp a b)))) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp a (Atom j)))) (_ : forces_t k (Imp (Atom j) b)), forces_t k (vimp l (Imp a b)) *) generalize (below_vimp_head j l (Imp a b) below_c); clear below_c. intros below_ab below_l; elim below_ab; clear below_ab; intros below_a below_b. (* Goal: below_form (Imp (Atom j) b) j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) split. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) assumption. (* Goal: below_form (Imp (Atom j) b) j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) split. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_vimp_split; try assumption. (* Goal: forall (i : Int) (_ : @In Int i l), Less i j1 *) (* Goal: below_form (Imp a (Atom j)) j1 *) (* Goal: @eq form (subst_form j b (vimp l (Imp a (Atom j)))) (vimp l (Imp a b)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp a (Atom j)))) (_ : forces_t k (Imp (Atom j) b)), forces_t k (vimp l (Imp a b)) *) intros i in0. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply less_trans with j; try assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_l; assumption. (* Goal: below_form (Imp (Atom j) b) j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) split. (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_form_less_below_form with j; assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) rewrite (subst_vimp_head j b l (Imp a (Atom j))); try assumption. (* Goal: @eq form (vimp l (subst_form j a (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) simpl in |- *. (* Goal: Derivable context (vimp l (Imp (Imp (if equal_dec j a then b else Atom a) (if equal_dec j j then b else Atom j)) c)) *) (* Goal: Derivable (@cons form (subst_form j b (vimp l (Imp (Imp (Atom a) (Atom j)) c))) (@cons form (subst_form j b (vimp l (Imp (Atom a) (Imp b (Atom j))))) context)) goal *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) rewrite (equal_dec_refl j form b (Atom j)). (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) rewrite (subst_form_below j b a); try assumption. (* Goal: @eq form (vimp l (Imp (Imp a b) c)) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) trivial. (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) intros k k_is_mon forces1 forces2. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply forces_vimp with (Imp a (Atom j)); try assumption. (* Goal: forall (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (Imp a (Atom j))), forces_t2 k k' (Imp a b) *) intros k' suc1 forces_j. (* Goal: @eq form (vimp l (subst_form j a (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) unfold forces_t2 in |- *; simpl in |- *. (* Goal: forall (k'0 : kripke_tree) (_ : Suc k'0 k) (_ : Suc k'0 k') (_ : forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k'0 a), forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k'0 b *) intros k'' suc2 suc3 forces_a. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply (forces2 k''); try assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply (forces_j k''); assumption. Qed. (****************************************************) (* *) (* rules for goal = ... *) (* *) (****************************************************) Lemma rule_gamma_falsum : forall (gamma : flist) (work : nf_list) (context : flist) (i j : Int), Less i j -> search_spec (Atom i) gamma work context j -> search_spec Falsum gamma work context i. (* Goal: forall (gamma : flist) (work : nf_list) (context : flist) (i j : Int) (_ : Less i j) (_ : search_spec (Atom i) gamma work context j), search_spec Falsum gamma work context i *) intros gamma work context i j less_ij spec0. (* Goal: search_spec goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context j *) unfold search_spec in |- *. (* Goal: forall (_ : below_form goal j) (_ : below_list (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) j) (_ : below_list context j) (_ : sound (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context) (_ : minimal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) intros below_goal below_gamma below_context sound0 minimal0. (* Goal: search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) elim spec0; clear spec0; try assumption. (* Goal: forall _ : Derivable (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) goal, search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) intros derivable_i. (* Goal: search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) apply derivable. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply snd_order_inst with i; assumption. (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma gamma work k) (_ : forall _ : forces_t k (Atom i), False), search_spec_aux Falsum gamma work context *) (* Goal: below_list gamma j *) (* Goal: below_list context j *) intros k k_is_mon k_forces_gamma k_notforces_i. (* Goal: search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) apply refutable with k; try assumption. (* Goal: @eq form (vimp l (Imp (Imp a b) c)) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) trivial. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_list_less_below_list with i; assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_list_less_below_list with i; assumption. Qed. Lemma rule_gamma_a_imp_b : forall (a b : form) (gamma : flist) (work : nf_list) (context : flist) (j : Int), search_spec b (a :: gamma) work (a :: context) j -> search_spec (Imp a b) gamma work context j. (* Goal: forall (a b : form) (gamma : flist) (work : nf_list) (context : flist) (j : Int) (_ : search_spec b (@cons form a gamma) work (@cons form a context) j), search_spec (Imp a b) gamma work context j *) intros a b gamma work context j spec0. (* Goal: search_spec goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context j *) unfold search_spec in |- *. (* Goal: forall (_ : below_form goal j) (_ : below_list (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) j) (_ : below_list context j) (_ : sound (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context) (_ : minimal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) intros below_goal below_gamma below_context sound0 minimal0. (* Goal: search_spec_aux (Imp a b) gamma work context *) elim below_goal; clear below_goal; intros below_a below_b. (* Goal: search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) elim spec0; clear spec0; try assumption. (* Goal: forall _ : Derivable (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) goal, search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) intros derivable_i. (* Goal: search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) apply derivable. (* Goal: Derivable context (Imp a b) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form a gamma) work k) (_ : forall _ : forces_t k b, False), search_spec_aux (Imp a b) gamma work context *) (* Goal: below_list (@cons form a gamma) j *) (* Goal: below_list (@cons form a context) j *) (* Goal: sound (@cons form a gamma) work (@cons form a context) *) (* Goal: minimal (@cons form a gamma) work (@cons form a context) *) elim derivable_i; clear derivable_i; intros t der_t. (* Goal: Derivable context (Imp a b) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form a gamma) work k) (_ : forall _ : forces_t k b, False), search_spec_aux (Imp a b) gamma work context *) (* Goal: below_list (@cons form a gamma) j *) (* Goal: below_list (@cons form a context) j *) (* Goal: sound (@cons form a gamma) work (@cons form a context) *) (* Goal: minimal (@cons form a gamma) work (@cons form a context) *) apply Derivable_Intro with (Abs a t). (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply ImpIntro; assumption. (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form a gamma) work k) (_ : forall _ : forces_t k b, False), search_spec_aux (Imp a b) gamma work context *) (* Goal: below_list (@cons form a gamma) j *) (* Goal: below_list (@cons form a context) j *) (* Goal: sound (@cons form a gamma) work (@cons form a context) *) (* Goal: minimal (@cons form a gamma) work (@cons form a context) *) intros k k_is_mon k_forces_gamma k_notforces_b. (* Goal: search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) apply refutable with k; try assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply forces_gamma_cons_gamma_tail with a; assumption. (* Goal: forall _ : forces_t2 k k'' (Imp a b), forces_t2 k k'' c *) intros forces_ab. (* Goal: False *) (* Goal: below_list (@cons form a gamma) j *) (* Goal: below_list (@cons form a context) j *) (* Goal: sound (@cons form a gamma) work (@cons form a context) *) (* Goal: minimal (@cons form a gamma) work (@cons form a context) *) apply k_notforces_b. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply forces_a_a_imp_b__forces_b_t with a; try assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply forces_gamma_cons_gamma_head with gamma work; assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_cons_list; assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_cons_list; assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply sound_cons_gamma_cons_context; assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply minimal_cons_gamma_cons_context; assumption. Qed. Lemma rule_gamma_a : forall (a : form) (gamma : flist) (work : nf_list) (context : flist) (j j1 : Int), Less j j1 -> search_spec (Atom j) (Imp a (Atom j) :: gamma) work (Imp a (Atom j) :: context) j1 -> search_spec a gamma work context j. (* Goal: forall (a : form) (gamma : flist) (work : nf_list) (context : flist) (j j1 : Int) (_ : Less j j1) (_ : search_spec (Atom j) (@cons form (Imp a (Atom j)) gamma) work (@cons form (Imp a (Atom j)) context) j1), search_spec a gamma work context j *) intros a gamma work context j j1 less1 spec0. (* Goal: search_spec goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context j *) unfold search_spec in |- *. (* Goal: forall (_ : below_form goal j) (_ : below_list (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) j) (_ : below_list context j) (_ : sound (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context) (_ : minimal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) intros below_goal below_gamma below_context sound0 minimal0. (* Goal: search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) elim spec0; clear spec0; try assumption. (* Goal: forall _ : Derivable context (vimp l (Imp (Imp Falsum b) c)), Derivable context (vimp l c) *) (* Goal: minimal (@cons form (vimp l c) gamma) work context *) intros der. (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) clear minimal0 sound0. (* Goal: search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) apply derivable. (* Goal: Derivable context a *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (Imp a (Atom j)) gamma) work k) (_ : forall _ : forces_t k (Atom j), False), search_spec_aux a gamma work context *) (* Goal: below_list (@cons form (Imp a (Atom j)) gamma) j1 *) (* Goal: below_list (@cons form (Imp a (Atom j)) context) j1 *) (* Goal: sound (@cons form (Imp a (Atom j)) gamma) work (@cons form (Imp a (Atom j)) context) *) (* Goal: minimal (@cons form (Imp a (Atom j)) gamma) work (@cons form (Imp a (Atom j)) context) *) apply derivable_cut with (Imp a a). (* Goal: Derivable fnil (Imp a a) *) (* Goal: Derivable (@cons form (Imp a a) context) a *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (Imp a (Atom j)) gamma) work k) (_ : forall _ : forces_t k (Atom j), False), search_spec_aux a gamma work context *) (* Goal: below_list (@cons form (Imp a (Atom j)) gamma) j1 *) (* Goal: below_list (@cons form (Imp a (Atom j)) context) j1 *) (* Goal: sound (@cons form (Imp a (Atom j)) gamma) work (@cons form (Imp a (Atom j)) context) *) (* Goal: minimal (@cons form (Imp a (Atom j)) gamma) work (@cons form (Imp a (Atom j)) context) *) apply derivable_a_imp_a. apply derivable_eq with (subst_list j a (Imp a (Atom j) :: context)) (subst_form j a (Atom j)). (* Goal: @eq form (vimp l (subst_form j a (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) simpl in |- *. (* Goal: @eq flist (@cons form (Imp (subst_form j a a) (if equal_dec j j then a else Atom j)) (subst_list j a context)) (@cons form (Imp a a) context) *) (* Goal: @eq form (subst_form j a (Atom j)) a *) (* Goal: Derivable (subst_list j a (@cons form (Imp a (Atom j)) context)) (subst_form j a (Atom j)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (Imp a (Atom j)) gamma) work k) (_ : forall _ : forces_t k (Atom j), False), search_spec_aux a gamma work context *) (* Goal: below_list (@cons form (Imp a (Atom j)) gamma) j1 *) (* Goal: below_list (@cons form (Imp a (Atom j)) context) j1 *) (* Goal: sound (@cons form (Imp a (Atom j)) gamma) work (@cons form (Imp a (Atom j)) context) *) (* Goal: minimal (@cons form (Imp a (Atom j)) gamma) work (@cons form (Imp a (Atom j)) context) *) rewrite (subst_form_below j a a); try assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) rewrite (subst_list_below j a context); try assumption. (* Goal: @eq form (vimp l (Imp (Imp (if equal_dec j j then a else Atom j) b) c)) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) rewrite (equal_dec_refl j form a (Atom j)). (* Goal: @eq form (vimp l (Imp (Imp a b) c)) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) trivial. (* Goal: @eq form (vimp l (subst_form j a (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) simpl in |- *. (* Goal: @eq form (if equal_dec j j then a else Atom j) a *) (* Goal: Derivable (subst_list j a (@cons form (Imp a (Atom j)) context)) (subst_form j a (Atom j)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (Imp a (Atom j)) gamma) work k) (_ : forall _ : forces_t k (Atom j), False), search_spec_aux a gamma work context *) (* Goal: below_list (@cons form (Imp a (Atom j)) gamma) j1 *) (* Goal: below_list (@cons form (Imp a (Atom j)) context) j1 *) (* Goal: sound (@cons form (Imp a (Atom j)) gamma) work (@cons form (Imp a (Atom j)) context) *) (* Goal: minimal (@cons form (Imp a (Atom j)) gamma) work (@cons form (Imp a (Atom j)) context) *) apply equal_dec_refl. (* Goal: Derivable (subst_list j b (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp l (Imp (Atom a) (Imp b (Atom j)))) context))) (subst_form j b goal) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) apply derivable_subst; assumption. (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) clear minimal0 sound0. (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (Imp a (Atom j)) gamma) work k) (_ : forall _ : forces_t k (Atom j), False), search_spec_aux a gamma work context *) (* Goal: below_list (@cons form (Imp a (Atom j)) gamma) j1 *) (* Goal: below_list (@cons form (Imp a (Atom j)) context) j1 *) (* Goal: sound (@cons form (Imp a (Atom j)) gamma) work (@cons form (Imp a (Atom j)) context) *) (* Goal: minimal (@cons form (Imp a (Atom j)) gamma) work (@cons form (Imp a (Atom j)) context) *) intros k k_is_mon k_forces_gamma k_notforces_j. (* Goal: search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) apply refutable with k; try assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply forces_gamma_cons_gamma_tail with (Imp a (Atom j)); assumption. (* Goal: forall _ : forces_t2 k k''' (Atom a), forces_t2 k k''' (Atom j) *) intros forces_a. (* Goal: False *) (* Goal: below_list (@cons form (Imp a (Atom j)) gamma) j1 *) (* Goal: below_list (@cons form (Imp a (Atom j)) context) j1 *) (* Goal: sound (@cons form (Imp a (Atom j)) gamma) work (@cons form (Imp a (Atom j)) context) *) (* Goal: minimal (@cons form (Imp a (Atom j)) gamma) work (@cons form (Imp a (Atom j)) context) *) apply k_notforces_j. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply forces_a_a_imp_b__forces_b_t with a; try assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply forces_gamma_cons_gamma_head with gamma work; assumption. (* Goal: below_list (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) apply below_cons_list. (* Goal: below_form (Imp (Atom j) b) j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) split. (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_form_less_below_form with j; assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_list_less_below_list with j; assumption. (* Goal: below_list (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) apply below_cons_list. (* Goal: below_form (Imp (Atom j) b) j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) split. (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_form_less_below_form with j; assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_list_less_below_list with j; assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply sound_cons_gamma_cons_context; assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply minimal_cons_gamma_cons_context; assumption. Qed. (***********************************************************************) (***********************************************************************) (*****************************************************) (* rules for ...(cons (vimp l (AndF a b)) gamma)... *) Lemma rule_vimp_conj_gamma : forall (goal : form) (l : list Int) (b0 b1 : form) (gamma : flist) (work : nf_list) (context : flist) (j : Int), search_spec goal (vimp l b0 :: vimp l b1 :: gamma) work context j -> search_spec goal (vimp l (AndF b0 b1) :: gamma) work context j. (* Goal: forall (goal : form) (l : list Int) (b0 b1 : form) (gamma : flist) (work : nf_list) (context : flist) (j : Int) (_ : search_spec goal (@cons form (vimp l b0) (@cons form (vimp l b1) gamma)) work context j), search_spec goal (@cons form (vimp l (AndF b0 b1)) gamma) work context j *) intros goal l b0 b1 gamma work context j spec0. (* Goal: search_spec goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context j *) unfold search_spec in |- *. (* Goal: forall (_ : below_form goal j) (_ : below_list (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) j) (_ : below_list context j) (_ : sound (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context) (_ : minimal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) intros below_goal below_gamma below_context sound0 minimal0. (* Goal: search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) elim spec0; clear spec0; try assumption. (* Goal: forall _ : Derivable context goal, search_spec_aux goal (@cons form (vimp l (Imp (Imp Falsum b) c)) gamma) work context *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l c) gamma) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp Falsum b) c)) gamma) work context *) (* Goal: below_list (@cons form (vimp l c) gamma) j *) (* Goal: sound (@cons form (vimp l c) gamma) work context *) (* Goal: minimal (@cons form (vimp l c) gamma) work context *) intros der_goal; apply derivable; assumption. (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) intros k k_is_mon k_forces_gamma k_notforces_goal. (* Goal: search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) apply refutable with k; try assumption. apply forces_gamma_cons_gamma_weak2 with (vimp l b0) (vimp l b1); (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) try assumption. (* Goal: forall (_ : forces_t k (vimp l b0)) (_ : forces_t k (vimp l b1)), forces_t k (vimp l (AndF b0 b1)) *) (* Goal: below_list (@cons form (vimp l b0) (@cons form (vimp l b1) gamma)) j *) (* Goal: sound (@cons form (vimp l b0) (@cons form (vimp l b1) gamma)) work context *) (* Goal: minimal (@cons form (vimp l b0) (@cons form (vimp l b1) gamma)) work context *) intros forces_ab0 forces_ab1. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply forces_vimp2 with b0 b1; try assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) intros; split; assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_list_weak2 with (vimp l (AndF b0 b1)); try assumption. (* Goal: forall _ : below_form (vimp l (AndF b0 b1)) j, and (below_form (vimp l b0) j) (below_form (vimp l b1) j) *) (* Goal: sound (@cons form (vimp l b0) (@cons form (vimp l b1) gamma)) work context *) (* Goal: minimal (@cons form (vimp l b0) (@cons form (vimp l b1) gamma)) work context *) intros below_ab0b1. (* Goal: below_form (Imp (Atom j) b) j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) split. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_vimp with (AndF b0 b1); try assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) intros j' below_b0b1; elim below_b0b1; clear below_b0b1; intros; assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_vimp with (AndF b0 b1); try assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) intros j' below_b0b1; elim below_b0b1; clear below_b0b1; intros; assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply sound_cons_gamma_weak2 with (vimp l (AndF b0 b1)); try assumption. (* Goal: forall _ : Derivable context (vimp l (Imp (Imp Falsum b) c)), Derivable context (vimp l c) *) (* Goal: minimal (@cons form (vimp l c) gamma) work context *) intros der. (* Goal: below_form (Imp (Atom j) b) j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) split. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply derivable_vimp with (AndF b0 b1); try assumption. (* Goal: forall (context : flist) (_ : Derivable context (Imp (Imp Falsum b) c)), Derivable context c *) (* Goal: Derivable context (vimp l (Imp (Imp Falsum b) c)) *) (* Goal: minimal (@cons form (vimp l c) gamma) work context *) intros context' der'. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply (derivable_a_and_b__derivable_a b0 b1 context'); assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply derivable_vimp with (AndF b0 b1); try assumption. (* Goal: forall (context : flist) (_ : Derivable context (Imp (Imp Falsum b) c)), Derivable context c *) (* Goal: Derivable context (vimp l (Imp (Imp Falsum b) c)) *) (* Goal: minimal (@cons form (vimp l c) gamma) work context *) intros context' der'. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply (derivable_a_and_b__derivable_b b0 b1 context'); assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply minimal_cons_gamma_weak2 with (vimp l (AndF b0 b1)); try assumption. (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l b0)) (_ : forces_t k (vimp l b1)), forces_t k (vimp l (AndF b0 b1)) *) intros k k_is_mon forces_b0 forces_b1. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply forces_vimp2 with b0 b1; try assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) intros; split; assumption. Qed. Lemma rule_vimp_conj_gamma_new : forall (goal : form) (l : list Int) (b0 b1 : form) (gamma : flist) (work : nf_list) (context : flist) (j j1 : Int), Less j j1 -> search_spec goal (vimp (j :: nil) b0 :: vimp (j :: nil) b1 :: gamma) (nvimp l (NAtom j) :: work) (vimp l (Atom j) :: Imp (Atom j) (AndF b0 b1) :: context) j1 -> search_spec goal (vimp l (AndF b0 b1) :: gamma) work context j. (* Goal: forall (goal : form) (l : list Int) (b0 b1 : form) (gamma : flist) (work : nf_list) (context : flist) (j j1 : Int) (_ : Less j j1) (_ : search_spec goal (@cons form (vimp (@cons Int j (@nil Int)) b0) (@cons form (vimp (@cons Int j (@nil Int)) b1) gamma)) (@cons normal_form (nvimp l (NAtom j)) work) (@cons form (vimp l (Atom j)) (@cons form (Imp (Atom j) (AndF b0 b1)) context)) j1), search_spec goal (@cons form (vimp l (AndF b0 b1)) gamma) work context j *) intros goal l b0 b1 gamma work context j j1 less1 spec0. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply rule_vimp_a_gamma with j1; try assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply rule_vimp_conj_gamma; assumption. Qed. (****************************************************) (* rules for ...(cons (vimp l (OrF a b)) gamma)... *) Lemma rule_vimp_falsum_or_a_gamma : forall (goal : form) (l : list Int) (a : form) (gamma : flist) (work : nf_list) (context : flist) (j : Int), search_spec goal (vimp l a :: gamma) work context j -> search_spec goal (vimp l (OrF Falsum a) :: gamma) work context j. (* Goal: forall (goal : form) (l : list Int) (a : form) (gamma : flist) (work : nf_list) (context : flist) (j : Int) (_ : search_spec goal (@cons form (vimp l a) gamma) work context j), search_spec goal (@cons form (vimp l (OrF a Falsum)) gamma) work context j *) intros goal l a gamma work context j spec0. (* Goal: search_spec goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context j *) unfold search_spec in |- *. (* Goal: forall (_ : below_form goal j) (_ : below_list (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) j) (_ : below_list context j) (_ : sound (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context) (_ : minimal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) intros below_goal below_gamma below_context sound0 minimal0. (* Goal: search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) elim spec0; clear spec0; try assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) intros derivable_i; apply derivable; assumption. (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) intros k k_is_mon k_forces_gamma k_notforces_goal. (* Goal: search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) apply refutable with k; try assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply forces_gamma_cons_gamma_weak with (vimp l a); try assumption. (* Goal: forall _ : forces_t k (vimp l a), forces_t k (vimp l (OrF a Falsum)) *) (* Goal: below_list (@cons form (vimp l a) gamma) j *) (* Goal: sound (@cons form (vimp l a) gamma) work context *) (* Goal: minimal (@cons form (vimp l a) gamma) work context *) intros forces_la. (* Goal: forces_t k (vimp l (OrF a Falsum)) *) (* Goal: below_list (@cons form (vimp l a) gamma) j *) (* Goal: sound (@cons form (vimp l a) gamma) work context *) (* Goal: minimal (@cons form (vimp l a) gamma) work context *) apply forces_vimp with a. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) intros; right; assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_list_weak with (vimp l (OrF Falsum a)); try assumption. (* Goal: forall _ : below_form (vimp l (Imp (Imp a b) c)) j, and (below_form a j) (and (below_form (vimp l (Imp (Imp (Atom j) b) c)) j1) (@eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)))) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) intros below_x. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_vimp with (OrF Falsum a); try assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) intros j0 below_or; elim below_or; intros; assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply sound_cons_gamma_weak with (vimp l (OrF Falsum a)); try assumption. (* Goal: forall _ : Derivable context (vimp l (Imp (Imp Falsum b) c)), Derivable context (vimp l c) *) (* Goal: minimal (@cons form (vimp l c) gamma) work context *) intros der. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply derivable_vimp with (OrF Falsum a); try assumption. (* Goal: forall (context : flist) (_ : Derivable context (OrF a Falsum)), Derivable context a *) (* Goal: minimal (@cons form (vimp l a) gamma) work context *) intros context0 der0. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply derivable_falsum_or_a__derivable_a; assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply minimal_cons_gamma_weak with (vimp l (OrF Falsum a)); try assumption. (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l a)), forces_t k (vimp l (OrF a Falsum)) *) intros k k_is_mon k_forces_la. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply forces_vimp with a; try assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) intros; right; assumption. Qed. Lemma rule_vimp_a_or_falsum_gamma : forall (goal : form) (l : list Int) (a : form) (gamma : flist) (work : nf_list) (context : flist) (j : Int), search_spec goal (vimp l a :: gamma) work context j -> search_spec goal (vimp l (OrF a Falsum) :: gamma) work context j. (* Goal: forall (goal : form) (l : list Int) (a : form) (gamma : flist) (work : nf_list) (context : flist) (j : Int) (_ : search_spec goal (@cons form (vimp l a) gamma) work context j), search_spec goal (@cons form (vimp l (OrF a Falsum)) gamma) work context j *) intros goal l a gamma work context j spec0. (* Goal: search_spec goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context j *) unfold search_spec in |- *. (* Goal: forall (_ : below_form goal j) (_ : below_list (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) j) (_ : below_list context j) (_ : sound (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context) (_ : minimal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) intros below_goal below_gamma below_context sound0 minimal0. (* Goal: search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) elim spec0; clear spec0; try assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) intros derivable_i; apply derivable; assumption. (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) intros k k_is_mon k_forces_gamma k_notforces_goal. (* Goal: search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) apply refutable with k; try assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply forces_gamma_cons_gamma_weak with (vimp l a); try assumption. (* Goal: forall _ : forces_t k (vimp l a), forces_t k (vimp l (OrF a Falsum)) *) (* Goal: below_list (@cons form (vimp l a) gamma) j *) (* Goal: sound (@cons form (vimp l a) gamma) work context *) (* Goal: minimal (@cons form (vimp l a) gamma) work context *) intros forces_la. (* Goal: forces_t k (vimp l (OrF a Falsum)) *) (* Goal: below_list (@cons form (vimp l a) gamma) j *) (* Goal: sound (@cons form (vimp l a) gamma) work context *) (* Goal: minimal (@cons form (vimp l a) gamma) work context *) apply forces_vimp with a. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) intros; left; assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_list_weak with (vimp l (OrF a Falsum)); try assumption. (* Goal: forall _ : below_form (vimp l (Imp (Imp a b) c)) j, and (below_form a j) (and (below_form (vimp l (Imp (Imp (Atom j) b) c)) j1) (@eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)))) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) intros below_x. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_vimp with (OrF a Falsum); try assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) intros j0 below_or; elim below_or; intros; assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply sound_cons_gamma_weak with (vimp l (OrF a Falsum)); try assumption. (* Goal: forall _ : Derivable context (vimp l (Imp (Imp Falsum b) c)), Derivable context (vimp l c) *) (* Goal: minimal (@cons form (vimp l c) gamma) work context *) intros der. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply derivable_vimp with (OrF a Falsum); try assumption. (* Goal: forall (context : flist) (_ : Derivable context (OrF a Falsum)), Derivable context a *) (* Goal: minimal (@cons form (vimp l a) gamma) work context *) intros context0 der0. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply derivable_a_or_falsum__derivable_a; assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply minimal_cons_gamma_weak with (vimp l (OrF a Falsum)); try assumption. (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l a)), forces_t k (vimp l (OrF a Falsum)) *) intros k k_is_mon k_forces_la. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply forces_vimp with a; try assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) intros; left; assumption. Qed. Lemma rule_vimp_atom_or_a_gamma : forall (goal : form) (l : list Int) (i : Int) (a : form) (gamma : flist) (work : nf_list) (context : flist) (j j1 : Int), Less j j1 -> search_spec goal (Imp (Atom j) a :: gamma) (nvimp l (NDisj i j) :: work) (vimp l (OrF (Atom i) (Atom j)) :: Imp (Atom j) a :: context) j1 -> search_spec goal (vimp l (OrF (Atom i) a) :: gamma) work context j. (* Goal: forall (goal : form) (l : list Int) (i : Int) (a : form) (gamma : flist) (work : nf_list) (context : flist) (j j1 : Int) (_ : Less j j1) (_ : search_spec goal (@cons form (Imp (Atom j) a) gamma) (@cons normal_form (nvimp l (NDisj i j)) work) (@cons form (vimp l (OrF (Atom i) (Atom j))) (@cons form (Imp (Atom j) a) context)) j1), search_spec goal (@cons form (vimp l (OrF (Atom i) a)) gamma) work context j *) intros goal l i a gamma work context j j1 less1 spec0. apply search_spec_subst_gamma_pos with (j1 := j1) (a := a) (b := vimp l (OrF (Atom i) (Atom j))); (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) try assumption. (* Goal: forall _ : below_form (vimp l (OrF a b)) j, and (below_form a j) (and (below_form (vimp l (OrF (Atom j) b)) j1) (@eq form (subst_form j a (vimp l (OrF (Atom j) b))) (vimp l (OrF a b)))) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (OrF (Atom j) b))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (OrF a b)) *) intros below_c. (* Goal: and (below_form a j) (and (below_form (vimp l (OrF (Atom i) (Atom j))) j1) (@eq form (subst_form j a (vimp l (OrF (Atom i) (Atom j)))) (vimp l (OrF (Atom i) a)))) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (OrF (Atom i) (Atom j)))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (OrF (Atom i) a)) *) (* Goal: search_spec goal (@cons form (vimp l (OrF (Atom i) (Atom j))) (@cons form (Imp (Atom j) a) gamma)) work (@cons form (vimp l (OrF (Atom i) (Atom j))) (@cons form (Imp (Atom j) a) context)) j1 *) generalize (below_vimp_tail j l (OrF (Atom i) a) below_c). (* Goal: forall _ : forall (i : Int) (_ : @In Int i l), Less i j, and (below_form a j) (and (below_form (vimp l (OrF (Atom i) (Atom j))) j1) (@eq form (subst_form j a (vimp l (OrF (Atom i) (Atom j)))) (vimp l (OrF (Atom i) a)))) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (OrF (Atom i) (Atom j)))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (OrF (Atom i) a)) *) (* Goal: search_spec goal (@cons form (vimp l (OrF (Atom i) (Atom j))) (@cons form (Imp (Atom j) a) gamma)) work (@cons form (vimp l (OrF (Atom i) (Atom j))) (@cons form (Imp (Atom j) a) context)) j1 *) generalize (below_vimp_head j l (OrF (Atom i) a) below_c); clear below_c. (* Goal: forall (_ : below_form (OrF (Atom i) a) j) (_ : forall (i : Int) (_ : @In Int i l), Less i j), and (below_form a j) (and (below_form (vimp l (OrF (Atom i) (Atom j))) j1) (@eq form (subst_form j a (vimp l (OrF (Atom i) (Atom j)))) (vimp l (OrF (Atom i) a)))) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (OrF (Atom i) (Atom j)))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (OrF (Atom i) a)) *) (* Goal: search_spec goal (@cons form (vimp l (OrF (Atom i) (Atom j))) (@cons form (Imp (Atom j) a) gamma)) work (@cons form (vimp l (OrF (Atom i) (Atom j))) (@cons form (Imp (Atom j) a) context)) j1 *) intros below_c below_l; elim below_c; clear below_c; intros below_i below_a. (* Goal: below_form (Imp (Atom j) b) j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) split. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) assumption. (* Goal: below_form (Imp (Atom j) b) j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) split. (* Goal: below_form (Imp (Atom j) b) j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_vimp_split. (* Goal: forall (i : Int) (_ : @In Int i l), Less i j1 *) (* Goal: below_form (Imp (Imp a (Atom j)) c) j1 *) (* Goal: below_list context j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp a (Atom j)) c)) gamma) work (@cons form (vimp l (Imp (Imp a (Atom j)) c)) context) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp a (Atom j)) c)) gamma) work (@cons form (vimp l (Imp (Imp a (Atom j)) c)) context) *) intros i0 in0. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply less_trans with j; try assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_l; assumption. (* Goal: below_form (Imp (Atom j) b) j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) split. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_form_less_below_form with j; try assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) rewrite (subst_vimp_head j a l (OrF (Atom i) (Atom j))); try assumption. change (vimp l (OrF (subst_form j a (Atom i)) (subst_form j a (Atom j))) = vimp l (OrF (Atom i) a)) in |- *. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) rewrite (subst_form_below j a (Atom i)); try assumption. (* Goal: @eq form (vimp l (subst_form j a (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) simpl in |- *. (* Goal: @eq form (vimp l (Imp (Imp (if equal_dec j j then a else Atom j) b) c)) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) rewrite (equal_dec_refl j form a (Atom j)). (* Goal: @eq form (vimp l (Imp (Imp a b) c)) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) trivial. (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) intros k k_is_mon forces1 forces2. (* Goal: forces_t k (vimp l (OrF (Atom i) a)) *) (* Goal: search_spec goal (@cons form (vimp l (OrF (Atom i) (Atom j))) (@cons form (Imp (Atom j) a) gamma)) work (@cons form (vimp l (OrF (Atom i) (Atom j))) (@cons form (Imp (Atom j) a) context)) j1 *) apply forces_vimp with (OrF (Atom i) (Atom j)). (* Goal: forall (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (OrF (Atom i) (Atom j))), forces_t2 k k' (OrF (Atom i) a) *) (* Goal: forces_t k (vimp l (OrF (Atom i) (Atom j))) *) (* Goal: search_spec goal (@cons form (vimp l (OrF (Atom i) (Atom j))) (@cons form (Imp (Atom j) a) gamma)) work (@cons form (vimp l (OrF (Atom i) (Atom j))) (@cons form (Imp (Atom j) a) context)) j1 *) intros k' suc1 forces_ij. (* Goal: forces_t2 k k' (OrF (Atom i) a) *) (* Goal: forces_t k (vimp l (OrF (Atom i) (Atom j))) *) (* Goal: search_spec goal (@cons form (vimp l (OrF (Atom i) (Atom j))) (@cons form (Imp (Atom j) a) gamma)) work (@cons form (vimp l (OrF (Atom i) (Atom j))) (@cons form (Imp (Atom j) a) context)) j1 *) elim forces_ij; clear forces_ij. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) intros; left; assumption. (* Goal: forall _ : forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' (Atom j), forces_t2 k k' (OrF (Atom i) a) *) (* Goal: forces_t k (vimp l (OrF (Atom i) (Atom j))) *) (* Goal: search_spec goal (@cons form (vimp l (OrF (Atom i) (Atom j))) (@cons form (Imp (Atom j) a) gamma)) work (@cons form (vimp l (OrF (Atom i) (Atom j))) (@cons form (Imp (Atom j) a) context)) j1 *) intros; right. (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' a *) (* Goal: forall _ : forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' b, forces_t2 k k' (OrF a b) *) (* Goal: forces_t k (vimp l (OrF (Atom j) b)) *) change (forces_t2 k k' a) in |- *. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply (forces2 k'); assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply rule_shift_gamma_work with (a := NDisj i j); assumption. Qed. Lemma rule_vimp_a_or_b_gamma : forall (goal : form) (l : list Int) (a b : form) (gamma : flist) (work : nf_list) (context : flist) (j j1 : Int), Less j j1 -> search_spec goal (vimp l (OrF (Atom j) b) :: vimp (j :: nil) a :: gamma) work (vimp l (OrF (Atom j) b) :: Imp (Atom j) a :: context) j1 -> search_spec goal (vimp l (OrF a b) :: gamma) work context j. (* Goal: forall (goal : form) (l : list Int) (a b : form) (gamma : flist) (work : nf_list) (context : flist) (j j1 : Int) (_ : Less j j1) (_ : search_spec goal (@cons form (vimp l (OrF (Atom j) b)) (@cons form (vimp (@cons Int j (@nil Int)) a) gamma)) work (@cons form (vimp l (OrF (Atom j) b)) (@cons form (Imp (Atom j) a) context)) j1), search_spec goal (@cons form (vimp l (OrF a b)) gamma) work context j *) intros goal l a b gamma work context j j1 less1 spec0. apply search_spec_subst_gamma_pos with (j1 := j1) (a := a) (b := vimp l (OrF (Atom j) b)); try assumption; clear spec0. (* Goal: forall _ : below_form (vimp l (OrF a b)) j, and (below_form a j) (and (below_form (vimp l (OrF (Atom j) b)) j1) (@eq form (subst_form j a (vimp l (OrF (Atom j) b))) (vimp l (OrF a b)))) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (OrF (Atom j) b))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (OrF a b)) *) intros below_c. (* Goal: and (below_form a j) (and (below_form (vimp l (OrF (Atom j) b)) j1) (@eq form (subst_form j a (vimp l (OrF (Atom j) b))) (vimp l (OrF a b)))) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (OrF (Atom j) b))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (OrF a b)) *) generalize (below_vimp_tail j l (OrF a b) below_c). (* Goal: forall _ : forall (i : Int) (_ : @In Int i l), Less i j, and (below_form a j) (and (below_form (vimp l (OrF (Atom j) b)) j1) (@eq form (subst_form j a (vimp l (OrF (Atom j) b))) (vimp l (OrF a b)))) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (OrF (Atom j) b))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (OrF a b)) *) generalize (below_vimp_head j l (OrF a b) below_c); clear below_c. intros below_ab below_l; elim below_ab; clear below_ab; intros below_a below_b. (* Goal: below_form (Imp (Atom j) b) j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) split. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) assumption. (* Goal: below_form (Imp (Atom j) b) j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) split. (* Goal: below_form (Imp (Atom j) b) j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_vimp_split. (* Goal: forall (i : Int) (_ : @In Int i l), Less i j1 *) (* Goal: below_form (Imp (Imp a (Atom j)) c) j1 *) (* Goal: below_list context j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp a (Atom j)) c)) gamma) work (@cons form (vimp l (Imp (Imp a (Atom j)) c)) context) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp a (Atom j)) c)) gamma) work (@cons form (vimp l (Imp (Imp a (Atom j)) c)) context) *) intros i0 in0. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply less_trans with j; try assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_l; assumption. (* Goal: below_form (Imp (Atom j) b) j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) split. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_form_less_below_form with j; try assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) rewrite (subst_vimp_head j a l (OrF (Atom j) b)); try assumption. (* Goal: @eq form (vimp l (subst_form j a (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) simpl in |- *. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) rewrite (subst_form_below j a b); try assumption. (* Goal: @eq form (vimp l (Imp (Imp (if equal_dec j j then a else Atom j) b) c)) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) rewrite (equal_dec_refl j form a (Atom j)). (* Goal: @eq form (vimp l (Imp (Imp a b) c)) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) trivial. (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) intros k k_is_mon forces1 forces2. (* Goal: forces_t k (vimp l (OrF a b)) *) apply forces_vimp with (OrF (Atom j) b). (* Goal: forall (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (OrF (Atom j) b)), forces_t2 k k' (OrF a b) *) (* Goal: forces_t k (vimp l (OrF (Atom j) b)) *) intros k' suc1 forces_jb. (* Goal: forces_t2 k k' (OrF a b) *) (* Goal: forces_t k (vimp l (OrF (Atom j) b)) *) elim forces_jb; clear forces_jb. (* Goal: forall _ : forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' (Atom j), forces_t2 k k' (OrF a b) *) (* Goal: forall _ : forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' b, forces_t2 k k' (OrF a b) *) (* Goal: forces_t k (vimp l (OrF (Atom j) b)) *) intros; left. (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' a *) (* Goal: forall _ : forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' b, forces_t2 k k' (OrF a b) *) (* Goal: forces_t k (vimp l (OrF (Atom j) b)) *) change (forces_t2 k k' a) in |- *. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply (forces2 k'); assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) intros; right; assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) assumption. Qed. (**********************************************************) (* rules for ...(cons (vimp l (Imp Falsum b)) gamma)... *) Lemma rule_vimp_falsum_imp_b_gamma : forall (goal : form) (l : list Int) (b : form) (gamma : flist) (work : nf_list) (context : flist) (j : Int), search_spec goal gamma work context j -> search_spec goal (vimp l (Imp Falsum b) :: gamma) work context j. (* Goal: forall (goal : form) (l : list Int) (b : form) (gamma : flist) (work : nf_list) (context : flist) (j : Int) (_ : search_spec goal gamma work context j), search_spec goal (@cons form (vimp l (Imp Falsum b)) gamma) work context j *) intros goal l b gamma work context j spec0. (* Goal: search_spec goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context j *) unfold search_spec in |- *. (* Goal: forall (_ : below_form goal j) (_ : below_list (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) j) (_ : below_list context j) (_ : sound (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context) (_ : minimal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) intros below_goal below_gamma below_context sound0 minimal0. (* Goal: search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) elim spec0; clear spec0; try assumption. (* Goal: forall _ : Derivable context goal, search_spec_aux goal (@cons form (vimp l (Imp (Imp Falsum b) c)) gamma) work context *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l c) gamma) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp Falsum b) c)) gamma) work context *) (* Goal: below_list (@cons form (vimp l c) gamma) j *) (* Goal: sound (@cons form (vimp l c) gamma) work context *) (* Goal: minimal (@cons form (vimp l c) gamma) work context *) intros der_goal; apply derivable; assumption. (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) intros k k_is_mon k_forces_gamma k_notforces_goal. (* Goal: search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) apply refutable with k; try assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply forces_gamma_cons_gamma; try assumption. (* Goal: forces_t k (vimp l (Imp Falsum b)) *) apply forces_vimp0. (* Goal: forall (k' : kripke_tree) (_ : Suc k' k), forces_t2 k k' (Imp Falsum b) *) intros k' suc1. (* Goal: @eq form (vimp l (subst_form j a (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) unfold forces_t in |- *; unfold forces_t2 in |- *; simpl in |- *. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) intros; elimtype False; assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_cons_list_tail with (vimp l (Imp Falsum b)); assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply sound_cons_gamma_tail with (vimp l (Imp Falsum b)); assumption. (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) unfold minimal in |- *. (* Goal: forall (a : form) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma gamma work k) (_ : @In form a context), forces_t k a *) intros c k k_is_mon k_forces_gamma in_c. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply minimal0; try assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply forces_gamma_cons_gamma; try assumption. (* Goal: forces_t k (vimp l (Imp Falsum b)) *) apply forces_vimp0. (* Goal: forall (k' : kripke_tree) (_ : Suc k' k), forces_t2 k k' (Imp Falsum b) *) intros k' suc1. (* Goal: @eq form (vimp l (subst_form j a (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) unfold forces_t in |- *; unfold forces_t2 in |- *; simpl in |- *. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) intros; elimtype False; assumption. Qed. (**********************************************************) (* rules for ...(cons (vimp l (Imp (Atom i) b)) gamma)... *) Lemma rule_vimp_atom_imp_b_gamma : forall (goal : form) (l : list Int) (i : Int) (b : form) (gamma : flist) (work : nf_list) (context : flist) (j : Int), search_spec goal (vimp (i :: l) b :: gamma) work context j -> search_spec goal (vimp l (Imp (Atom i) b) :: gamma) work context j. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) intros; assumption. Qed. (*****************************************************) (* rules for ...(cons (Imp (AndF a0 a1) b) gamma)... *) Lemma rule_vimp_and_imp_gamma : forall (goal : form) (l : list Int) (a0 a1 b : form) (gamma : flist) (work : nf_list) (context : flist) (j : Int), search_spec goal (vimp l (Imp a0 (Imp a1 b)) :: gamma) work context j -> search_spec goal (vimp l (Imp (AndF a0 a1) b) :: gamma) work context j. (* Goal: forall (goal : form) (l : list Int) (a0 a1 b : form) (gamma : flist) (work : nf_list) (context : flist) (j : Int) (_ : search_spec goal (@cons form (vimp l (Imp a0 b)) (@cons form (vimp l (Imp a1 b)) gamma)) work context j), search_spec goal (@cons form (vimp l (Imp (OrF a0 a1) b)) gamma) work context j *) intros goal l a0 a1 b gamma work context j spec0. (* Goal: search_spec goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context j *) unfold search_spec in |- *. (* Goal: forall (_ : below_form goal j) (_ : below_list (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) j) (_ : below_list context j) (_ : sound (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context) (_ : minimal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) intros below_goal below_gamma below_context sound0 minimal0. (* Goal: search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) elim spec0; clear spec0; try assumption. (* Goal: forall _ : Derivable context goal, search_spec_aux goal (@cons form (vimp l (Imp (Imp Falsum b) c)) gamma) work context *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l c) gamma) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp Falsum b) c)) gamma) work context *) (* Goal: below_list (@cons form (vimp l c) gamma) j *) (* Goal: sound (@cons form (vimp l c) gamma) work context *) (* Goal: minimal (@cons form (vimp l c) gamma) work context *) intros der_goal; apply derivable; assumption. (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) intros k k_is_mon k_forces_gamma k_notforces_goal. (* Goal: search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) apply refutable with k; try assumption. apply forces_gamma_cons_gamma_weak with (vimp l (Imp a0 (Imp a1 b))); (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) try assumption. (* Goal: forall _ : forces_t k (vimp l (Imp a0 (Imp a1 b))), forces_t k (vimp l (Imp (AndF a0 a1) b)) *) (* Goal: below_list (@cons form (vimp l (Imp a0 (Imp a1 b))) gamma) j *) (* Goal: sound (@cons form (vimp l (Imp a0 (Imp a1 b))) gamma) work context *) (* Goal: minimal (@cons form (vimp l (Imp a0 (Imp a1 b))) gamma) work context *) intros forces_a0a1b. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply forces_vimp with (Imp a0 (Imp a1 b)); try assumption. (* Goal: forall (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (Imp (Imp a (Atom j)) c)), forces_t2 k k' (Imp (Imp a Falsum) c) *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp a (Atom j)) c)) gamma) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp a (Atom j)) c)) context) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp a (Atom j)) c)) gamma) work (@cons form (vimp l (Imp (Imp a (Atom j)) c)) context) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp a (Atom j)) c)) gamma) work (@cons form (vimp l (Imp (Imp a (Atom j)) c)) context) *) intros k' suc1 forces1. unfold forces_t2 in |- *; apply forces_a0_imp_a1_imp_b__forces_a0_and_a1_imp_b; (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) try assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply kripke_tree_kripke_model; assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_list_weak with (vimp l (Imp (AndF a0 a1) b)); try assumption. (* Goal: forall _ : below_form (vimp l (Imp (AndF a0 a1) b)) j, below_form (vimp l (Imp a0 (Imp a1 b))) j *) (* Goal: sound (@cons form (vimp l (Imp a0 (Imp a1 b))) gamma) work context *) (* Goal: minimal (@cons form (vimp l (Imp a0 (Imp a1 b))) gamma) work context *) intros below_lab. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_vimp with (Imp (AndF a0 a1) b); try assumption. (* Goal: forall (j : Int) (_ : below_form (Imp (Imp Falsum b) c) j), below_form c j *) (* Goal: sound (@cons form (vimp l c) gamma) work context *) (* Goal: minimal (@cons form (vimp l c) gamma) work context *) intros j' below_ab; elim below_ab; clear below_ab; intros below_a below_b. (* Goal: below_form (Imp a1 b) j' *) (* Goal: sound (@cons form (vimp l (Imp a0 b)) (@cons form (vimp l (Imp a1 b)) gamma)) work context *) (* Goal: minimal (@cons form (vimp l (Imp a0 b)) (@cons form (vimp l (Imp a1 b)) gamma)) work context *) elim below_a; clear below_a; intros below_a0 below_a1. (* Goal: below_form (Imp (Atom j) b) j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) split. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) split; assumption. apply sound_cons_gamma_weak with (vimp l (Imp (AndF a0 a1) b)); (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) try assumption. (* Goal: forall _ : Derivable context (vimp l (Imp (Imp Falsum b) c)), Derivable context (vimp l c) *) (* Goal: minimal (@cons form (vimp l c) gamma) work context *) intros der. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply derivable_vimp with (Imp (AndF a0 a1) b); try assumption. (* Goal: forall (context : flist) (_ : Derivable context (Imp (Imp Falsum b) c)), Derivable context c *) (* Goal: Derivable context (vimp l (Imp (Imp Falsum b) c)) *) (* Goal: minimal (@cons form (vimp l c) gamma) work context *) intros context' der'. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply derivable_a0_and_a1_imp_b__derivable_a0_imp_a1_imp_b; assumption. apply minimal_cons_gamma_weak with (vimp l (Imp (AndF a0 a1) b)); (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) try assumption. (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l c)), forces_t k (vimp l (Imp (Imp Falsum b) c)) *) intros k k_is_mon forces1. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply forces_vimp with (Imp a0 (Imp a1 b)); try assumption. (* Goal: forall (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (Imp a0 (Imp a1 b))), forces_t2 k k' (Imp (AndF a0 a1) b) *) intros k' suc1 forces'. unfold forces_t2 in |- *; apply forces_a0_imp_a1_imp_b__forces_a0_and_a1_imp_b; (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) try assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply kripke_tree_kripke_model; assumption. Qed. (**************************************************************) (* rules for ...(cons (vimp l (Imp (OrF a0 a1) b)) gamma)... *) Lemma rule_vimp_or_imp_gamma : forall (goal : form) (l : list Int) (a0 a1 b : form) (gamma : flist) (work : nf_list) (context : flist) (j : Int), search_spec goal (vimp l (Imp a0 b) :: vimp l (Imp a1 b) :: gamma) work context j -> search_spec goal (vimp l (Imp (OrF a0 a1) b) :: gamma) work context j. (* Goal: forall (goal : form) (l : list Int) (a0 a1 b : form) (gamma : flist) (work : nf_list) (context : flist) (j : Int) (_ : search_spec goal (@cons form (vimp l (Imp a0 b)) (@cons form (vimp l (Imp a1 b)) gamma)) work context j), search_spec goal (@cons form (vimp l (Imp (OrF a0 a1) b)) gamma) work context j *) intros goal l a0 a1 b gamma work context j spec0. (* Goal: search_spec goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context j *) unfold search_spec in |- *. (* Goal: forall (_ : below_form goal j) (_ : below_list (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) j) (_ : below_list context j) (_ : sound (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context) (_ : minimal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) intros below_goal below_gamma below_context sound0 minimal0. (* Goal: search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) elim spec0; clear spec0; try assumption. (* Goal: forall _ : Derivable context goal, search_spec_aux goal (@cons form (vimp l (Imp (Imp Falsum b) c)) gamma) work context *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l c) gamma) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp Falsum b) c)) gamma) work context *) (* Goal: below_list (@cons form (vimp l c) gamma) j *) (* Goal: sound (@cons form (vimp l c) gamma) work context *) (* Goal: minimal (@cons form (vimp l c) gamma) work context *) intros der_goal; apply derivable; assumption. (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) intros k k_is_mon k_forces_gamma k_notforces_goal. (* Goal: search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) apply refutable with k; try assumption. apply forces_gamma_cons_gamma_weak2 with (vimp l (Imp a0 b)) (vimp l (Imp a1 b)); (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) try assumption. (* Goal: forall (_ : forces_t k (vimp l (Imp (Imp (Atom a) (Atom j)) c))) (_ : forces_t k (vimp (@cons Int a l) (Imp b (Atom j)))), forces_t k (vimp l (Imp (Imp (Atom a) b) c)) *) intros forces1 forces2. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply forces_vimp2 with (Imp a0 b) (Imp a1 b); try assumption. (* Goal: forall (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (Imp a0 b)) (_ : forces_t2 k k' (Imp a1 b)), forces_t2 k k' (Imp (OrF a0 a1) b) *) intros k' suc1 forces_a0b forces_a1b. unfold forces_t2 in |- *; apply forces_a0_imp_b_and_a1_imp_b__forces_a0_or_a1_imp_b; (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) try assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_list_weak2 with (vimp l (Imp (OrF a0 a1) b)); try assumption. (* Goal: forall _ : below_form (vimp l (Imp (OrF a0 a1) b)) j, and (below_form (vimp l (Imp a0 b)) j) (below_form (vimp l (Imp a1 b)) j) *) (* Goal: sound (@cons form (vimp l (Imp a0 b)) (@cons form (vimp l (Imp a1 b)) gamma)) work context *) (* Goal: minimal (@cons form (vimp l (Imp a0 b)) (@cons form (vimp l (Imp a1 b)) gamma)) work context *) intros below1. (* Goal: below_form (Imp (Atom j) b) j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) split. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_vimp with (Imp (OrF a0 a1) b); try assumption. (* Goal: forall (j : Int) (_ : below_form (Imp (Imp Falsum b) c) j), below_form c j *) (* Goal: sound (@cons form (vimp l c) gamma) work context *) (* Goal: minimal (@cons form (vimp l c) gamma) work context *) intros j' below_ab; elim below_ab; clear below_ab; intros below_a below_b. (* Goal: below_form (Imp a1 b) j' *) (* Goal: sound (@cons form (vimp l (Imp a0 b)) (@cons form (vimp l (Imp a1 b)) gamma)) work context *) (* Goal: minimal (@cons form (vimp l (Imp a0 b)) (@cons form (vimp l (Imp a1 b)) gamma)) work context *) elim below_a; clear below_a; intros below_a0 below_a1. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) split; assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_vimp with (Imp (OrF a0 a1) b); try assumption. (* Goal: forall (j : Int) (_ : below_form (Imp (Imp Falsum b) c) j), below_form c j *) (* Goal: sound (@cons form (vimp l c) gamma) work context *) (* Goal: minimal (@cons form (vimp l c) gamma) work context *) intros j' below_ab; elim below_ab; clear below_ab; intros below_a below_b. (* Goal: below_form (Imp a1 b) j' *) (* Goal: sound (@cons form (vimp l (Imp a0 b)) (@cons form (vimp l (Imp a1 b)) gamma)) work context *) (* Goal: minimal (@cons form (vimp l (Imp a0 b)) (@cons form (vimp l (Imp a1 b)) gamma)) work context *) elim below_a; clear below_a; intros below_a0 below_a1. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) split; assumption. apply sound_cons_gamma_weak2 with (vimp l (Imp (OrF a0 a1) b)); (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) try assumption. (* Goal: forall _ : Derivable context (vimp l (Imp (Imp Falsum b) c)), Derivable context (vimp l c) *) (* Goal: minimal (@cons form (vimp l c) gamma) work context *) intros der. (* Goal: below_form (Imp (Atom j) b) j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) split. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply derivable_vimp with (Imp (OrF a0 a1) b); try assumption. (* Goal: forall (context : flist) (_ : Derivable context (Imp (Imp Falsum b) c)), Derivable context c *) (* Goal: Derivable context (vimp l (Imp (Imp Falsum b) c)) *) (* Goal: minimal (@cons form (vimp l c) gamma) work context *) intros context' der'. apply (derivable_a0_or_a1_imp_b__derivable_a0_imp_b context' a0 a1 b der'); (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply derivable_vimp with (Imp (OrF a0 a1) b); try assumption. (* Goal: forall (context : flist) (_ : Derivable context (Imp (Imp Falsum b) c)), Derivable context c *) (* Goal: Derivable context (vimp l (Imp (Imp Falsum b) c)) *) (* Goal: minimal (@cons form (vimp l c) gamma) work context *) intros context' der'. apply (derivable_a0_or_a1_imp_b__derivable_a1_imp_b context' a0 a1 b der'); (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) assumption. apply minimal_cons_gamma_weak2 with (vimp l (Imp (OrF a0 a1) b)); (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) try assumption. (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) intros k k_is_mon forces1 forces2. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply forces_vimp2 with (Imp a0 b) (Imp a1 b); try assumption. (* Goal: forall (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (Imp a0 b)) (_ : forces_t2 k k' (Imp a1 b)), forces_t2 k k' (Imp (OrF a0 a1) b) *) intros k' suc1 forces_a0b forces_a1b. unfold forces_t2 in |- *; apply forces_a0_imp_b_and_a1_imp_b__forces_a0_or_a1_imp_b; (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) try assumption. Qed. Lemma rule_vimp_or_imp_gamma_new : forall (goal : form) (l : list Int) (a0 a1 b : form) (gamma : flist) (work : nf_list) (context : flist) (j j1 : Int), Less j j1 -> search_spec goal (vimp l (Imp a0 (Atom j)) :: vimp l (Imp a1 (Atom j)) :: vimp (j :: nil) b :: gamma) work (vimp l (Imp (OrF a0 a1) (Atom j)) :: Imp (Atom j) b :: context) j1 -> search_spec goal (vimp l (Imp (OrF a0 a1) b) :: gamma) work context j. (* Goal: forall (goal : form) (l : list Int) (a0 a1 b : form) (gamma : flist) (work : nf_list) (context : flist) (j j1 : Int) (_ : Less j j1) (_ : search_spec goal (@cons form (vimp l (Imp a0 (Atom j))) (@cons form (vimp l (Imp a1 (Atom j))) (@cons form (vimp (@cons Int j (@nil Int)) b) gamma))) work (@cons form (vimp l (Imp (OrF a0 a1) (Atom j))) (@cons form (Imp (Atom j) b) context)) j1), search_spec goal (@cons form (vimp l (Imp (OrF a0 a1) b)) gamma) work context j *) intros goal l a0 a1 b gamma work context j j1 less1 spec0. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply rule_vimp_imp_gamma with j1; try assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply rule_vimp_or_imp_gamma; assumption. Qed. (*************************************************************) (* rules for ...(cons (vimp l (Imp (Imp a b) c)) gamma)... *) Lemma rule_vimp_falsum_imp_imp_gamma : forall (goal : form) (l : list Int) (b c : form) (gamma : flist) (work : nf_list) (context : flist) (j : Int), search_spec goal (vimp l c :: gamma) work context j -> search_spec goal (vimp l (Imp (Imp Falsum b) c) :: gamma) work context j. (* Goal: forall (goal : form) (l : list Int) (b c : form) (gamma : flist) (work : nf_list) (context : flist) (j : Int) (_ : search_spec goal (@cons form (vimp l c) gamma) work context j), search_spec goal (@cons form (vimp l (Imp (Imp Falsum b) c)) gamma) work context j *) intros goal l b c gamma work context j spec0. (* Goal: search_spec goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context j *) unfold search_spec in |- *. (* Goal: forall (_ : below_form goal j) (_ : below_list (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) j) (_ : below_list context j) (_ : sound (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context) (_ : minimal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) intros below_goal below_gamma below_context sound0 minimal0. (* Goal: search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) elim spec0; clear spec0; try assumption. (* Goal: forall _ : Derivable context goal, search_spec_aux goal (@cons form (vimp l (Imp (Imp Falsum b) c)) gamma) work context *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l c) gamma) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp Falsum b) c)) gamma) work context *) (* Goal: below_list (@cons form (vimp l c) gamma) j *) (* Goal: sound (@cons form (vimp l c) gamma) work context *) (* Goal: minimal (@cons form (vimp l c) gamma) work context *) intros der_goal; apply derivable; assumption. (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) intros k k_is_mon k_forces_gamma k_notforces_goal. (* Goal: search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) apply refutable with k; try assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply forces_gamma_cons_gamma_weak with (vimp l c); try assumption. (* Goal: forall _ : forces_t k (vimp l (Imp (Imp a (Atom j)) c)), forces_t k (vimp l (Imp (Imp a Falsum) c)) *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp a (Atom j)) c)) gamma) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp a (Atom j)) c)) context) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp a (Atom j)) c)) gamma) work (@cons form (vimp l (Imp (Imp a (Atom j)) c)) context) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp a (Atom j)) c)) gamma) work (@cons form (vimp l (Imp (Imp a (Atom j)) c)) context) *) intros forces_lc. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply forces_vimp with c; try assumption. (* Goal: forall context : flist, Derivable context (Imp b b) *) (* Goal: Derivable (@cons form (subst_form j b (vimp l (Imp (Atom a) (Imp b (Atom j))))) context) goal *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) intros. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) unfold forces_t2 in |- *; apply forces_b__forces_a_imp_b; try assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply kripke_tree_kripke_model; assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_list_weak with (vimp l (Imp (Imp Falsum b) c)); try assumption. (* Goal: forall _ : below_form (vimp l (Imp (Imp a Falsum) c)) j, search_spec_aux goal (@cons form (vimp l (Imp (Imp a Falsum) c)) gamma) work context *) intros below_lc. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_vimp with (Imp (Imp Falsum b) c); try assumption. (* Goal: forall (j : Int) (_ : below_form (Imp (Imp Falsum b) c) j), below_form c j *) (* Goal: sound (@cons form (vimp l c) gamma) work context *) (* Goal: minimal (@cons form (vimp l c) gamma) work context *) intros j' below_ab; elim below_ab; clear below_ab; intros below_a below_b. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) assumption. apply sound_cons_gamma_weak with (vimp l (Imp (Imp Falsum b) c)); (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) try assumption. (* Goal: forall _ : Derivable context (vimp l (Imp (Imp Falsum b) c)), Derivable context (vimp l c) *) (* Goal: minimal (@cons form (vimp l c) gamma) work context *) intros der. (* Goal: Derivable context (vimp l c) *) (* Goal: minimal (@cons form (vimp l c) gamma) work context *) apply derivable_vimp with (Imp (Imp Falsum b) c). (* Goal: forall (context : flist) (_ : Derivable context (Imp (Imp Falsum b) c)), Derivable context c *) (* Goal: Derivable context (vimp l (Imp (Imp Falsum b) c)) *) (* Goal: minimal (@cons form (vimp l c) gamma) work context *) intros context' der'. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply derivable_falsum_imp_b_imp_c__derivable_c with b; assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) assumption. apply minimal_cons_gamma_weak with (vimp l (Imp (Imp Falsum b) c)); (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) try assumption. (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l c)), forces_t k (vimp l (Imp (Imp Falsum b) c)) *) intros k k_is_mon forces1. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply forces_vimp with c; try assumption. (* Goal: forall context : flist, Derivable context (Imp b b) *) (* Goal: Derivable (@cons form (subst_form j b (vimp l (Imp (Atom a) (Imp b (Atom j))))) context) goal *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) intros. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) unfold forces_t2 in |- *; apply forces_b__forces_a_imp_b; try assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply kripke_tree_kripke_model; assumption. Qed. Lemma rule_vimp_imp_falsum_imp_gamma : forall (goal : form) (l : list Int) (a c : form) (gamma : flist) (work : nf_list) (context : flist) (j j1 : Int), Less j j1 -> search_spec goal (vimp l (Imp (Imp a (Atom j)) c) :: gamma) work (vimp l (Imp (Imp a (Atom j)) c) :: context) j1 -> search_spec goal (vimp l (Imp (Imp a Falsum) c) :: gamma) work context j. (* Goal: forall (goal : form) (l : list Int) (a c : form) (gamma : flist) (work : nf_list) (context : flist) (j j1 : Int) (_ : Less j j1) (_ : search_spec goal (@cons form (vimp l (Imp (Imp a (Atom j)) c)) gamma) work (@cons form (vimp l (Imp (Imp a (Atom j)) c)) context) j1), search_spec goal (@cons form (vimp l (Imp (Imp a Falsum) c)) gamma) work context j *) intros goal l a c gamma work context j j1 less1 spec0. (* Goal: search_spec goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context j *) unfold search_spec in |- *. (* Goal: forall (_ : below_form goal j) (_ : below_list (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) j) (_ : below_list context j) (_ : sound (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context) (_ : minimal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) intros below_goal below_gamma below_context sound0 minimal0. generalize (below_cons_list_head (vimp l (Imp (Imp a Falsum) c)) gamma j below_gamma). (* Goal: forall _ : below_form (vimp l (Imp (Imp a Falsum) c)) j, search_spec_aux goal (@cons form (vimp l (Imp (Imp a Falsum) c)) gamma) work context *) intros below_lc. generalize (below_cons_list_tail (vimp l (Imp (Imp a Falsum) c)) gamma j below_gamma). (* Goal: forall _ : below_list gamma j, search_spec_aux goal (@cons form (vimp l (Imp (Imp a Falsum) c)) gamma) work context *) clear below_gamma; intros below_gamma. (* Goal: search_spec_aux goal (@cons form (vimp l (Imp (Imp a Falsum) c)) gamma) work context *) elim (below_vimp_head j l (Imp (Imp a Falsum) c) below_lc). (* Goal: forall (_ : below_form (Imp a Falsum) j) (_ : below_form c j), search_spec_aux goal (@cons form (vimp l (Imp (Imp a Falsum) c)) gamma) work context *) intros below_a_falsum; elim below_a_falsum; clear below_a_falsum. (* Goal: forall (_ : below_form a j) (_ : below_form Falsum j) (_ : below_form c j), search_spec_aux goal (@cons form (vimp l (Imp (Imp a Falsum) c)) gamma) work context *) intros below_a below_falsum below_c. generalize (below_vimp_tail j l (Imp (Imp a Falsum) c) below_lc); clear below_lc. (* Goal: forall _ : forall (i : Int) (_ : @In Int i l), Less i j, search_spec_aux goal (@cons form (vimp l (Imp (Imp a Falsum) c)) gamma) work context *) intros below_l. (* Goal: search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) elim spec0; clear spec0; try assumption. (* Goal: forall _ : Derivable (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) goal, search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) clear minimal0. (* Goal: forall _ : Derivable (@cons form (vimp l (Imp (Imp a (Atom j)) c)) context) goal, search_spec_aux goal (@cons form (vimp l (Imp (Imp a Falsum) c)) gamma) work context *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l (Imp (Imp a (Atom j)) c)) gamma) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp a Falsum) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp a (Atom j)) c)) gamma) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp a (Atom j)) c)) context) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp a (Atom j)) c)) gamma) work (@cons form (vimp l (Imp (Imp a (Atom j)) c)) context) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp a (Atom j)) c)) gamma) work (@cons form (vimp l (Imp (Imp a (Atom j)) c)) context) *) intros der_goal. (* Goal: search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) apply derivable. (* Goal: Derivable context goal *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l (Imp (Imp a (Atom j)) c)) gamma) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp a Falsum) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp a (Atom j)) c)) gamma) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp a (Atom j)) c)) context) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp a (Atom j)) c)) gamma) work (@cons form (vimp l (Imp (Imp a (Atom j)) c)) context) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp a (Atom j)) c)) gamma) work (@cons form (vimp l (Imp (Imp a (Atom j)) c)) context) *) apply derivable_cut_merge with (vimp l (Imp (Imp a Falsum) c)). (* Goal: Derivable context (vimp l (Imp (Imp (Atom a) b) c)) *) (* Goal: Derivable (@cons form (subst_form j b (vimp l (Imp (Imp (Atom a) (Atom j)) c))) (@cons form (subst_form j b (vimp l (Imp (Atom a) (Imp b (Atom j))))) context)) goal *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) apply sound0. (* Goal: in_gamma (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma) work (vimp (@cons Int a l) (Imp b (Atom j))) *) (* Goal: forces_t k x *) apply in_gamma_cons_gamma_head. apply derivable_eq with (subst_list j Falsum (vimp l (Imp (Imp a (Atom j)) c) :: context)) (subst_form j Falsum goal). (* Goal: @eq form (vimp l (subst_form j a (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) simpl in |- *. (* Goal: @eq flist (@cons form (subst_form j Falsum (vimp l (Imp (Imp a (Atom j)) c))) (subst_list j Falsum context)) (@cons form (vimp l (Imp (Imp a Falsum) c)) context) *) (* Goal: @eq form (subst_form j Falsum goal) goal *) (* Goal: Derivable (subst_list j Falsum (@cons form (vimp l (Imp (Imp a (Atom j)) c)) context)) (subst_form j Falsum goal) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l (Imp (Imp a (Atom j)) c)) gamma) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp a Falsum) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp a (Atom j)) c)) gamma) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp a (Atom j)) c)) context) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp a (Atom j)) c)) gamma) work (@cons form (vimp l (Imp (Imp a (Atom j)) c)) context) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp a (Atom j)) c)) gamma) work (@cons form (vimp l (Imp (Imp a (Atom j)) c)) context) *) rewrite (subst_vimp_head j Falsum l (Imp (Imp a (Atom j)) c)). (* Goal: @eq form (vimp l (subst_form j a (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) simpl in |- *. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) rewrite (subst_form_below j Falsum a); try assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) rewrite (subst_form_below j Falsum c); try assumption. (* Goal: @eq flist (@cons form (vimp l (Imp (Imp a (if equal_dec j j then Falsum else Atom j)) c)) (subst_list j Falsum context)) (@cons form (vimp l (Imp (Imp a Falsum) c)) context) *) (* Goal: forall (i : Int) (_ : @In Int i l), Less i j *) (* Goal: @eq form (subst_form j Falsum goal) goal *) (* Goal: Derivable (subst_list j Falsum (@cons form (vimp l (Imp (Imp a (Atom j)) c)) context)) (subst_form j Falsum goal) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l (Imp (Imp a (Atom j)) c)) gamma) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp a Falsum) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp a (Atom j)) c)) gamma) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp a (Atom j)) c)) context) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp a (Atom j)) c)) gamma) work (@cons form (vimp l (Imp (Imp a (Atom j)) c)) context) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp a (Atom j)) c)) gamma) work (@cons form (vimp l (Imp (Imp a (Atom j)) c)) context) *) rewrite (equal_dec_refl j form Falsum (Atom j)). (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) rewrite (subst_list_below j Falsum context); try assumption. (* Goal: @eq form (vimp l (Imp (Imp a b) c)) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) trivial. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply subst_form_below; assumption. (* Goal: Derivable (subst_list j b (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp l (Imp (Atom a) (Imp b (Atom j)))) context))) (subst_form j b goal) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) apply derivable_subst; assumption. (* Goal: forall _ : Derivable (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) goal, search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) clear minimal0. (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) intros k k_is_mon k_forces_gamma k_notforces_goal. (* Goal: search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) apply refutable with k; try assumption. apply forces_gamma_cons_gamma_weak with (vimp l (Imp (Imp a (Atom j)) c)); (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) try assumption. (* Goal: forall _ : forces_t k (vimp l (Imp (Imp a (Atom j)) c)), forces_t k (vimp l (Imp (Imp a Falsum) c)) *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp a (Atom j)) c)) gamma) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp a (Atom j)) c)) context) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp a (Atom j)) c)) gamma) work (@cons form (vimp l (Imp (Imp a (Atom j)) c)) context) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp a (Atom j)) c)) gamma) work (@cons form (vimp l (Imp (Imp a (Atom j)) c)) context) *) intros forces_lc. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply forces_vimp with (Imp (Imp a (Atom j)) c); try assumption. (* Goal: forall (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (Imp (Imp a (Atom j)) c)), forces_t2 k k' (Imp (Imp a Falsum) c) *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp a (Atom j)) c)) gamma) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp a (Atom j)) c)) context) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp a (Atom j)) c)) gamma) work (@cons form (vimp l (Imp (Imp a (Atom j)) c)) context) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp a (Atom j)) c)) gamma) work (@cons form (vimp l (Imp (Imp a (Atom j)) c)) context) *) intros k' suc1 forces1. apply forces_a_imp_b_imp_c__forces_a_imp_falsum_imp_c_t2 with (Atom j); (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) assumption. (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_form_less_below_form with j; assumption. (* Goal: below_list (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) apply below_cons_list. (* Goal: below_form (Imp (Atom j) b) j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_vimp_split. (* Goal: forall (i : Int) (_ : @In Int i l), Less i j1 *) (* Goal: below_form (Imp (Imp a (Atom j)) c) j1 *) (* Goal: below_list context j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp a (Atom j)) c)) gamma) work (@cons form (vimp l (Imp (Imp a (Atom j)) c)) context) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp a (Atom j)) c)) gamma) work (@cons form (vimp l (Imp (Imp a (Atom j)) c)) context) *) intros i0 in0. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply less_trans with j; try assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_l; assumption. (* Goal: below_form (Imp (Atom j) b) j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) split. (* Goal: below_form (Imp (Atom j) b) j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) split. (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_form_less_below_form with j; assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) assumption. (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_form_less_below_form with j; assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_list_less_below_list with j; assumption. (* Goal: below_list (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) apply below_cons_list. (* Goal: below_form (Imp (Atom j) b) j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_vimp_split. (* Goal: forall (i : Int) (_ : @In Int i l), Less i j1 *) (* Goal: below_form (Imp (Imp a (Atom j)) c) j1 *) (* Goal: below_list context j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp a (Atom j)) c)) gamma) work (@cons form (vimp l (Imp (Imp a (Atom j)) c)) context) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp a (Atom j)) c)) gamma) work (@cons form (vimp l (Imp (Imp a (Atom j)) c)) context) *) intros i0 in0. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply less_trans with j; try assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_l; assumption. (* Goal: below_form (Imp (Atom j) b) j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) split. (* Goal: below_form (Imp (Atom j) b) j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) split. (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_form_less_below_form with j; assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) assumption. (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_form_less_below_form with j; assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_list_less_below_list with j; assumption. (* Goal: sound (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma) work (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) apply sound_cons_gamma_cons_context. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply sound_cons_gamma_tail with (vimp l (Imp (Imp a Falsum) c)); assumption. (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) unfold minimal in |- *. (* Goal: forall (a0 : form) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work k) (_ : @In form a0 (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context))), forces_t k a0 *) intros x k k_is_mon k_forces_gamma in_x. (* Goal: forces_t k x *) inversion_clear in_x. (* Goal: forces_t k x *) (* Goal: forces_t k x *) rewrite <- H; clear H x. (* Goal: forces_t k (vimp (@cons Int a l) (Imp b (Atom j))) *) (* Goal: forces_t k x *) apply k_forces_gamma. (* Goal: in_gamma (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma) work (vimp (@cons Int a l) (Imp b (Atom j))) *) (* Goal: forces_t k x *) apply in_gamma_cons_gamma_head. (* Goal: forces_t k x *) apply minimal0; try assumption; clear H. apply forces_gamma_cons_gamma_weak with (vimp l (Imp (Imp a (Atom j)) c)); (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) try assumption. (* Goal: forall _ : forces_t k (vimp l (Imp (Imp a (Atom j)) c)), forces_t k (vimp l (Imp (Imp a Falsum) c)) *) intros forces1. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply forces_vimp with (Imp (Imp a (Atom j)) c); try assumption. (* Goal: forall (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (Imp (Imp a (Atom j)) c)), forces_t2 k k' (Imp (Imp a Falsum) c) *) intros k' suc1 forces2. apply forces_a_imp_b_imp_c__forces_a_imp_falsum_imp_c_t2 with (Atom j); (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) assumption. Qed. Lemma rule_atom_imp_atom_imp_c_gamma : forall (goal : form) (l : list Int) (a b : Int) (c : form) (gamma : flist) (work : nf_list) (context : flist) (j j1 : Int), Less j j1 -> search_spec goal (Imp (Atom j) c :: gamma) (nvimp l (NImp_NF (NImp a b (NAtom j))) :: work) (vimp l (Imp (Imp (Atom a) (Atom b)) (Atom j)) :: Imp (Atom j) c :: context) j1 -> search_spec goal (vimp l (Imp (Imp (Atom a) (Atom b)) c) :: gamma) work context j. (* Goal: forall (goal : form) (l : list Int) (a b c : form) (gamma : flist) (work : nf_list) (context : flist) (j j1 : Int) (_ : Less j j1) (_ : search_spec goal (@cons form (vimp l (Imp (Imp (Atom j) b) c)) (@cons form (Imp (Atom j) a) gamma)) work (@cons form (vimp l (Imp (Imp (Atom j) b) c)) (@cons form (Imp (Atom j) a) context)) j1), search_spec goal (@cons form (vimp l (Imp (Imp a b) c)) gamma) work context j *) intros goal l a b c gamma work context j j1 less1 spec0. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply rule_vimp_imp_gamma with j1; try assumption. apply rule_shift_gamma_work with (a := NImp_NF (NImp a b (NAtom j))); (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) assumption. Qed. Lemma rule_atom_imp_b_imp_c_gamma : forall (goal : form) (l : list Int) (a : Int) (b c : form) (gamma : flist) (work : nf_list) (context : flist) (j j1 : Int), Less j j1 -> search_spec goal (vimp l (Imp (Imp (Atom a) (Atom j)) c) :: vimp (a :: l) (Imp b (Atom j)) :: gamma) work (vimp l (Imp (Imp (Atom a) (Atom j)) c) :: vimp (a :: l) (Imp b (Atom j)) :: context) j1 -> search_spec goal (vimp l (Imp (Imp (Atom a) b) c) :: gamma) work context j. (* Goal: forall (goal : form) (l : list Int) (a b c : form) (gamma : flist) (work : nf_list) (context : flist) (j j1 : Int) (_ : Less j j1) (_ : search_spec goal (@cons form (vimp l (Imp (Imp (Atom j) b) c)) (@cons form (Imp (Atom j) a) gamma)) work (@cons form (vimp l (Imp (Imp (Atom j) b) c)) (@cons form (Imp (Atom j) a) context)) j1), search_spec goal (@cons form (vimp l (Imp (Imp a b) c)) gamma) work context j *) intros goal l a b c gamma work context j j1 less1 spec0. (* Goal: search_spec goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context j *) unfold search_spec in |- *. (* Goal: forall (_ : below_form goal j) (_ : below_list (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) j) (_ : below_list context j) (_ : sound (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context) (_ : minimal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) intros below_goal below_gamma below_context sound0 minimal0. generalize (below_cons_list_head (vimp l (Imp (Imp (Atom a) b) c)) gamma j below_gamma). generalize (below_cons_list_tail (vimp l (Imp (Imp (Atom a) b) c)) gamma j below_gamma); clear below_gamma. (* Goal: forall (_ : below_list gamma j) (_ : below_form (vimp l (Imp (Imp (Atom a) b) c)) j), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) intros below_gamma below_x. (* Goal: search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) generalize (below_vimp_head j l (Imp (Imp (Atom a) b) c) below_x). generalize (below_vimp_tail j l (Imp (Imp (Atom a) b) c) below_x); clear below_x. (* Goal: forall (_ : forall (i : Int) (_ : @In Int i l), Less i j) (_ : below_form (Imp (Imp (Atom a) b) c) j), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) intros below_l below_x. (* Goal: search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) elim below_x; clear below_x; intros below_x below_c. (* Goal: search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) elim below_x; clear below_x; intros below_a below_b. (* Goal: search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) elim spec0; clear spec0; try assumption. (* Goal: forall _ : Derivable (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) goal, search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) clear minimal0. (* Goal: forall _ : Derivable (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) goal, search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) intros derivable_i. (* Goal: search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) apply derivable. apply derivable_cut with (subst_form j b (vimp l (Imp (Atom a) (Imp b (Atom j))))). rewrite (subst_vimp_head j b l (Imp (Atom a) (Imp b (Atom j)))); (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) try assumption. (* Goal: @eq form (vimp l (subst_form j a (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) simpl in |- *. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) rewrite (subst_form_below j b b); try assumption. (* Goal: Derivable context (vimp l (Imp (Imp (if equal_dec j a then b else Atom a) (if equal_dec j j then b else Atom j)) c)) *) (* Goal: Derivable (@cons form (subst_form j b (vimp l (Imp (Imp (Atom a) (Atom j)) c))) (@cons form (subst_form j b (vimp l (Imp (Atom a) (Imp b (Atom j))))) context)) goal *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) rewrite (equal_dec_refl j form b (Atom j)). change (Derivable fnil (vimp l (Imp (subst_form j b (Atom a)) (Imp b b)))) in |- *. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) rewrite (subst_form_below j b (Atom a)); try assumption. (* Goal: Derivable fnil (vimp l (Imp (Atom a) (Imp b b))) *) (* Goal: Derivable (@cons form (subst_form j b (vimp l (Imp (Atom a) (Imp b (Atom j))))) context) goal *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) change (Derivable fnil (vimp (a :: l) (Imp b b))) in |- *. (* Goal: Derivable fnil (vimp (@cons Int a l) (Imp b b)) *) (* Goal: Derivable (@cons form (subst_form j b (vimp l (Imp (Atom a) (Imp b (Atom j))))) context) goal *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) apply derivable_vimp0. (* Goal: forall context : flist, Derivable context (Imp b b) *) (* Goal: Derivable (@cons form (subst_form j b (vimp l (Imp (Atom a) (Imp b (Atom j))))) context) goal *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) intros. (* Goal: Derivable context0 (Imp b b) *) (* Goal: Derivable (@cons form (subst_form j b (vimp l (Imp (Atom a) (Imp b (Atom j))))) context) goal *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) apply Derivable_Intro with (Abs b (Var 0)). (* Goal: derives context0 (Abs b (Var O)) (Imp b b) *) (* Goal: Derivable (@cons form (subst_form j b (vimp l (Imp (Atom a) (Imp b (Atom j))))) context) goal *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) apply ImpIntro. (* Goal: derives (@cons form b context0) (Var O) b *) (* Goal: Derivable (@cons form (subst_form j b (vimp l (Imp (Atom a) (Imp b (Atom j))))) context) goal *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) apply ByAssumption. (* Goal: my_nth form O (@cons form b context0) b *) (* Goal: Derivable (@cons form (subst_form j b (vimp l (Imp (Atom a) (Imp b (Atom j))))) context) goal *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) apply My_NthO. apply derivable_cut_merge with (subst_form j b (vimp l (Imp (Imp (Atom a) (Atom j)) c))). (* Goal: Derivable (@cons form (subst_form j b (vimp l (Imp (Atom a) (Imp b (Atom j))))) context) (subst_form j b (vimp l (Imp (Imp (Atom a) (Atom j)) c))) *) (* Goal: Derivable (@cons form (subst_form j b (vimp l (Imp (Imp (Atom a) (Atom j)) c))) (@cons form (subst_form j b (vimp l (Imp (Atom a) (Imp b (Atom j))))) context)) goal *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) apply derivable_weak. rewrite (subst_vimp_head j b l (Imp (Imp (Atom a) (Atom j)) c)); (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) try assumption. (* Goal: @eq form (vimp l (subst_form j a (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) simpl in |- *. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) rewrite (subst_form_below j b c); try assumption. (* Goal: Derivable context (vimp l (Imp (Imp (if equal_dec j a then b else Atom a) (if equal_dec j j then b else Atom j)) c)) *) (* Goal: Derivable (@cons form (subst_form j b (vimp l (Imp (Imp (Atom a) (Atom j)) c))) (@cons form (subst_form j b (vimp l (Imp (Atom a) (Imp b (Atom j))))) context)) goal *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) rewrite (equal_dec_refl j form b (Atom j)). change (Derivable context (vimp l (Imp (Imp (subst_form j b (Atom a)) b) c))) in |- *. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) rewrite (subst_form_below j b (Atom a)); try assumption. (* Goal: Derivable context (vimp l (Imp (Imp (Atom a) b) c)) *) (* Goal: Derivable (@cons form (subst_form j b (vimp l (Imp (Imp (Atom a) (Atom j)) c))) (@cons form (subst_form j b (vimp l (Imp (Atom a) (Imp b (Atom j))))) context)) goal *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) apply sound0. (* Goal: in_gamma (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma) work (vimp (@cons Int a l) (Imp b (Atom j))) *) (* Goal: forces_t k x *) apply in_gamma_cons_gamma_head. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) rewrite <- (subst_form_below j b goal); try assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) rewrite <- (subst_list_below j b context); try assumption. change (Derivable (subst_list j b (vimp l (Imp (Imp (Atom a) (Atom j)) c) :: vimp l (Imp (Atom a) (Imp b (Atom j))) :: context)) (subst_form j b goal)) in |- *. (* Goal: Derivable (subst_list j b (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp l (Imp (Atom a) (Imp b (Atom j)))) context))) (subst_form j b goal) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) apply derivable_subst; assumption. (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) clear minimal0 sound0 below_context below_gamma below_goal. (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work k) (_ : forall _ : forces_t k goal, False), search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) intros k k_is_mon k_forces_gamma k_notforces_goal. (* Goal: search_spec_aux goal (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work context *) (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) apply refutable with k; try assumption. apply forces_gamma_cons_gamma_weak2 with (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) (vimp (a :: l) (Imp b (Atom j))); try assumption. (* Goal: forall (_ : forces_t k (vimp l (Imp (Imp (Atom a) (Atom j)) c))) (_ : forces_t k (vimp (@cons Int a l) (Imp b (Atom j)))), forces_t k (vimp l (Imp (Imp (Atom a) b) c)) *) intros forces1 forces2. apply forces_vimp2 with (Imp (Imp (Atom a) (Atom j)) c) (Imp (Atom a) (Imp b (Atom j))); (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) try assumption. (* Goal: forall (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (Imp (Imp (Atom a) (Atom j)) c)) (_ : forces_t2 k k' (Imp (Atom a) (Imp b (Atom j)))), forces_t2 k k' (Imp (Imp (Atom a) b) c) *) intros k' suc1 forces_ajc forces_abj. (* Goal: @eq form (vimp l (subst_form j a (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) unfold forces_t2 in |- *; simpl in |- *. (* Goal: forall (k'0 : kripke_tree) (_ : Suc k'0 k) (_ : Suc k'0 k') (_ : forall (k' : kripke_tree) (_ : Suc k' k) (_ : Suc k' k'0) (_ : forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' a), forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' b), forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k'0 c *) intros k'' suc2 suc3. (* Goal: forall _ : forall (k' : kripke_tree) (_ : Suc k' k) (_ : Suc k' k'') (_ : forces0_t (Atms k') a), forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' b, forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k'' c *) change (forces_t2 k k'' (Imp (Atom a) b) -> forces_t2 k k'' c) in |- *. (* Goal: forall _ : forces_t2 k k'' (Imp a b), forces_t2 k k'' c *) intros forces_ab. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply (forces_ajc k''); try assumption. (* Goal: forall (k' : kripke_tree) (_ : Suc k' k) (_ : Suc k' k'') (_ : forces0_t (Atms k') j), (fix forces (A : Set) (World : forall _ : A, Type) (le : forall (_ : A) (_ : A), Type) (forces0 : forall (_ : A) (_ : Int), Prop) (k : A) (a : form) {struct a} : Prop := match a with | Falsum => False | Atom i => forces0 k i | AndF a0 a1 => and (forces A World le forces0 k a0) (forces A World le forces0 k a1) | OrF a0 a1 => or (forces A World le forces0 k a0) (forces A World le forces0 k a1) | Imp a0 a1 => forall (k'0 : A) (_ : World k'0) (_ : le k k'0) (_ : forces A World le forces0 k'0 a0), forces A World le forces0 k'0 a1 end) kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' b *) intros k''' suc4 suc5. (* Goal: forall _ : forces0_t (Atms k''') a, forces0_t (Atms k''') j *) change (forces_t2 k k''' (Atom a) -> forces_t2 k k''' (Atom j)) in |- *. (* Goal: forall _ : forces_t2 k k''' (Atom a), forces_t2 k k''' (Atom j) *) intros forces_a. (* Goal: forces_t2 k k''' (Atom j) *) generalize (forces_abj k''' suc4). (* Goal: @eq form (vimp l (subst_form j a (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) simpl in |- *. (* Goal: forall _ : forall (_ : Suc k''' k') (_ : forces0_t (Atms k''') a) (k' : kripke_tree) (_ : Suc k' k) (_ : Suc k' k''') (_ : (fix forces (A : Set) (World : forall _ : A, Type) (le : forall (_ : A) (_ : A), Type) (forces0 : forall (_ : A) (_ : Int), Prop) (k : A) (a : form) {struct a} : Prop := match a with | Falsum => False | Atom i => forces0 k i | AndF a0 a1 => and (forces A World le forces0 k a0) (forces A World le forces0 k a1) | OrF a0 a1 => or (forces A World le forces0 k a0) (forces A World le forces0 k a1) | Imp a0 a1 => forall (k'0 : A) (_ : World k'0) (_ : le k k'0) (_ : forces A World le forces0 k'0 a0), forces A World le forces0 k'0 a1 end) kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' b), forces0_t (Atms k') j, forces_t2 k k''' (Atom j) *) fold forces in |- *. (* Goal: forall _ : forall (_ : Suc k''' k') (_ : forces0_t (Atms k''') a) (k' : kripke_tree) (_ : Suc k' k) (_ : Suc k' k''') (_ : forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' b), forces0_t (Atms k') j, forces_t2 k k''' (Atom j) *) clear forces_abj; intros forces_abj. (* Goal: forces_t2 k k''' (Atom j) *) unfold forces_t2 in |- *. (* Goal: @eq form (vimp l (subst_form j a (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) simpl in |- *. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply forces_abj; try assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) unfold Suc in |- *; apply succs_trans with k''; try assumption. (* Goal: Suc k''' k''' *) (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k''' b *) unfold Suc in |- *; apply successor_refl. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply forces_ab; try assumption. (* Goal: below_form goal j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) clear minimal0 sound0. (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_form_less_below_form with j; assumption. (* Goal: below_list (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) apply below_cons_list. (* Goal: below_form (Imp (Atom j) b) j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_vimp_split. (* Goal: forall (i : Int) (_ : @In Int i l), Less i j1 *) (* Goal: below_form (Imp (Imp (Atom a) (Atom j)) c) j1 *) (* Goal: below_list (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma) j1 *) (* Goal: below_list (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) intros i0 in0; apply less_trans with j. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_l; assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) assumption. (* Goal: below_form (Imp (Atom j) b) j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) split. (* Goal: below_form (Imp (Atom j) b) j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) split. (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_form_less_below_form with j; assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) assumption. (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_form_less_below_form with j; assumption. (* Goal: below_list (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) apply below_cons_list. (* Goal: @eq form (vimp l (subst_form j a (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) simpl in |- *. (* Goal: below_form (Imp (Atom j) b) j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_vimp_split. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) intros i0 in0; apply less_trans with j; try assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_l; assumption. (* Goal: below_form (Imp (Atom j) b) j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) split. (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_form_less_below_form with j; assumption. (* Goal: below_form (Imp (Atom j) b) j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) split. (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_form_less_below_form with j; assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_list_less_below_list with j; assumption. (* Goal: below_list (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) apply below_cons_list. (* Goal: below_form (Imp (Atom j) b) j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_vimp_split. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) intros i0 in0; apply less_trans with j; try assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_l; assumption. (* Goal: below_form (Imp (Atom j) b) j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) split. (* Goal: below_form (Imp (Atom j) b) j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) split. (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_form_less_below_form with j; assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) assumption. (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_form_less_below_form with j; assumption. (* Goal: below_list (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context) j1 *) (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) apply below_cons_list. (* Goal: @eq form (vimp l (subst_form j a (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) simpl in |- *. (* Goal: below_form (Imp (Atom j) b) j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_vimp_split. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) intros i0 in0; apply less_trans with j; try assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_l; assumption. (* Goal: below_form (Imp (Atom j) b) j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) split. (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_form_less_below_form with j; assumption. (* Goal: below_form (Imp (Atom j) b) j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) split. (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_form_less_below_form with j; assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_list_less_below_list with j; assumption. (* Goal: sound (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) clear minimal0 below_context below_gamma below_goal. (* Goal: sound (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma) work (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) apply sound_cons_gamma_cons_context. (* Goal: sound (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma) work (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context) *) (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) apply sound_cons_gamma_cons_context. apply sound_cons_gamma_tail with (vimp l (Imp (Imp (Atom a) b) c)); (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) assumption. (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) clear sound0 below_context below_gamma below_goal below_b below_a. (* Goal: minimal (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context)) *) unfold minimal in |- *. (* Goal: forall (a0 : form) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work k) (_ : @In form a0 (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) context))), forces_t k a0 *) intros x k k_is_mon k_forces_gamma in_x. (* Goal: forces_t k x *) inversion_clear in_x. (* Goal: forces_t k x *) (* Goal: forces_t k x *) rewrite <- H; clear H x. (* Goal: forces_t k (vimp (@cons Int a l) (Imp b (Atom j))) *) (* Goal: forces_t k x *) apply k_forces_gamma. (* Goal: in_gamma (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma) work (vimp (@cons Int a l) (Imp b (Atom j))) *) (* Goal: forces_t k x *) apply in_gamma_cons_gamma_head. (* Goal: forces_t k x *) inversion_clear H. (* Goal: forces_t k x *) (* Goal: forces_t k x *) rewrite <- H0; clear H0 x. (* Goal: forces_t k (vimp (@cons Int a l) (Imp b (Atom j))) *) (* Goal: forces_t k x *) apply k_forces_gamma. (* Goal: in_gamma (@cons form (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma)) work (vimp (@cons Int a l) (Imp b (Atom j))) *) (* Goal: forces_t k x *) apply in_gamma_cons_gamma_tail. (* Goal: in_gamma (@cons form (vimp (@cons Int a l) (Imp b (Atom j))) gamma) work (vimp (@cons Int a l) (Imp b (Atom j))) *) (* Goal: forces_t k x *) apply in_gamma_cons_gamma_head. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply minimal0; try assumption. (* Goal: forces_gamma (@cons form (vimp l (Imp (Imp (Atom a) b) c)) gamma) work k *) clear H0 x. apply forces_gamma_cons_gamma_weak2 with (vimp l (Imp (Imp (Atom a) (Atom j)) c)) (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) (vimp (a :: l) (Imp b (Atom j))); try assumption. (* Goal: forall (_ : forces_t k (vimp l (Imp (Imp (Atom a) (Atom j)) c))) (_ : forces_t k (vimp (@cons Int a l) (Imp b (Atom j)))), forces_t k (vimp l (Imp (Imp (Atom a) b) c)) *) intros forces1 forces2. apply forces_vimp2 with (Imp (Imp (Atom a) (Atom j)) c) (Imp (Atom a) (Imp b (Atom j))); (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) try assumption. (* Goal: forall (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (Imp (Imp (Atom a) (Atom j)) c)) (_ : forces_t2 k k' (Imp (Atom a) (Imp b (Atom j)))), forces_t2 k k' (Imp (Imp (Atom a) b) c) *) intros k' suc1 forces_ajc forces_abj. (* Goal: @eq form (vimp l (subst_form j a (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) unfold forces_t2 in |- *; simpl in |- *. (* Goal: forall (k'0 : kripke_tree) (_ : Suc k'0 k) (_ : Suc k'0 k') (_ : forall (k' : kripke_tree) (_ : Suc k' k) (_ : Suc k' k'0) (_ : forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' a), forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' b), forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k'0 c *) intros k'' suc2 suc3. (* Goal: forall _ : forall (k' : kripke_tree) (_ : Suc k' k) (_ : Suc k' k'') (_ : forces0_t (Atms k') a), forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' b, forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k'' c *) change (forces_t2 k k'' (Imp (Atom a) b) -> forces_t2 k k'' c) in |- *. (* Goal: forall _ : forces_t2 k k'' (Imp a b), forces_t2 k k'' c *) intros forces_ab. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply (forces_ajc k''); try assumption. (* Goal: forall (k' : kripke_tree) (_ : Suc k' k) (_ : Suc k' k'') (_ : forces0_t (Atms k') j), (fix forces (A : Set) (World : forall _ : A, Type) (le : forall (_ : A) (_ : A), Type) (forces0 : forall (_ : A) (_ : Int), Prop) (k : A) (a : form) {struct a} : Prop := match a with | Falsum => False | Atom i => forces0 k i | AndF a0 a1 => and (forces A World le forces0 k a0) (forces A World le forces0 k a1) | OrF a0 a1 => or (forces A World le forces0 k a0) (forces A World le forces0 k a1) | Imp a0 a1 => forall (k'0 : A) (_ : World k'0) (_ : le k k'0) (_ : forces A World le forces0 k'0 a0), forces A World le forces0 k'0 a1 end) kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' b *) intros k''' suc4 suc5. (* Goal: forall _ : forces0_t (Atms k''') a, forces0_t (Atms k''') j *) change (forces_t2 k k''' (Atom a) -> forces_t2 k k''' (Atom j)) in |- *. (* Goal: forall _ : forces_t2 k k''' (Atom a), forces_t2 k k''' (Atom j) *) intros forces_a. (* Goal: forces_t2 k k''' (Atom j) *) generalize (forces_abj k''' suc4). (* Goal: @eq form (vimp l (subst_form j a (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) simpl in |- *. (* Goal: forall _ : forall (_ : Suc k''' k') (_ : forces0_t (Atms k''') a) (k' : kripke_tree) (_ : Suc k' k) (_ : Suc k' k''') (_ : (fix forces (A : Set) (World : forall _ : A, Type) (le : forall (_ : A) (_ : A), Type) (forces0 : forall (_ : A) (_ : Int), Prop) (k : A) (a : form) {struct a} : Prop := match a with | Falsum => False | Atom i => forces0 k i | AndF a0 a1 => and (forces A World le forces0 k a0) (forces A World le forces0 k a1) | OrF a0 a1 => or (forces A World le forces0 k a0) (forces A World le forces0 k a1) | Imp a0 a1 => forall (k'0 : A) (_ : World k'0) (_ : le k k'0) (_ : forces A World le forces0 k'0 a0), forces A World le forces0 k'0 a1 end) kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' b), forces0_t (Atms k') j, forces_t2 k k''' (Atom j) *) fold forces in |- *. (* Goal: forall _ : forall (_ : Suc k''' k') (_ : forces0_t (Atms k''') a) (k' : kripke_tree) (_ : Suc k' k) (_ : Suc k' k''') (_ : forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' b), forces0_t (Atms k') j, forces_t2 k k''' (Atom j) *) clear forces_abj; intros forces_abj. (* Goal: forces_t2 k k''' (Atom j) *) unfold forces_t2 in |- *. (* Goal: @eq form (vimp l (subst_form j a (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) simpl in |- *. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply forces_abj; try assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) unfold Suc in |- *; apply succs_trans with k''; try assumption. (* Goal: Suc k''' k''' *) (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k''' b *) unfold Suc in |- *; apply successor_refl. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply forces_ab; try assumption. Qed. Lemma rule_a_imp_b_imp_c_gamma : forall (goal : form) (l : list Int) (a b c : form) (gamma : flist) (work : nf_list) (context : flist) (j j1 : Int), Less j j1 -> search_spec goal (vimp l (Imp (Imp (Atom j) b) c) :: Imp (Atom j) a :: gamma) work (vimp l (Imp (Imp (Atom j) b) c) :: Imp (Atom j) a :: context) j1 -> search_spec goal (vimp l (Imp (Imp a b) c) :: gamma) work context j. (* Goal: forall (goal : form) (l : list Int) (a b c : form) (gamma : flist) (work : nf_list) (context : flist) (j j1 : Int) (_ : Less j j1) (_ : search_spec goal (@cons form (vimp l (Imp (Imp (Atom j) b) c)) (@cons form (Imp (Atom j) a) gamma)) work (@cons form (vimp l (Imp (Imp (Atom j) b) c)) (@cons form (Imp (Atom j) a) context)) j1), search_spec goal (@cons form (vimp l (Imp (Imp a b) c)) gamma) work context j *) intros goal l a b c gamma work context j j1 less1 spec0. apply search_spec_subst_gamma_pos with (j1 := j1) (a := a) (b := vimp l (Imp (Imp (Atom j) b) c)); try assumption; clear spec0. (* Goal: forall _ : below_form (vimp l (Imp (Imp a b) c)) j, and (below_form a j) (and (below_form (vimp l (Imp (Imp (Atom j) b) c)) j1) (@eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)))) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) intros below_x. (* Goal: and (below_form a j) (and (below_form (vimp l (Imp (Imp (Atom j) b) c)) j1) (@eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)))) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) generalize (below_vimp_tail j l (Imp (Imp a b) c) below_x). (* Goal: forall _ : forall (i : Int) (_ : @In Int i l), Less i j, and (below_form a j) (and (below_form (vimp l (Imp (Imp (Atom j) b) c)) j1) (@eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)))) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) generalize (below_vimp_head j l (Imp (Imp a b) c) below_x); clear below_x. (* Goal: forall (_ : below_form (Imp (Imp a b) c) j) (_ : forall (i : Int) (_ : @In Int i l), Less i j), and (below_form a j) (and (below_form (vimp l (Imp (Imp (Atom j) b) c)) j1) (@eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)))) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) intros below_x below_l. (* Goal: and (below_form a j) (and (below_form (vimp l (Imp (Imp (Atom j) b) c)) j1) (@eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)))) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) elim below_x; clear below_x; intros below_ab below_c. (* Goal: and (below_form a j) (and (below_form (vimp l (Imp (Imp (Atom j) b) c)) j1) (@eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)))) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) elim below_ab; clear below_ab; intros below_a below_b. (* Goal: below_form (Imp (Atom j) b) j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) split. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) assumption. (* Goal: below_form (Imp (Atom j) b) j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) split. (* Goal: below_form (Imp (Atom j) b) j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_vimp_split. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) intros i0 in0; apply less_trans with j; try assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_l; assumption. (* Goal: below_form (Imp (Atom j) b) j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) split. (* Goal: below_form (Imp (Atom j) b) j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) split. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) assumption. (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_form_less_below_form with j; assumption. (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply below_form_less_below_form with j; assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) rewrite (subst_vimp_head j a l (Imp (Imp (Atom j) b) c)); try assumption. (* Goal: @eq form (vimp l (subst_form j a (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) simpl in |- *. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) rewrite (subst_form_below j a b); try assumption. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) rewrite (subst_form_below j a c); try assumption. (* Goal: @eq form (vimp l (Imp (Imp (if equal_dec j j then a else Atom j) b) c)) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) rewrite (equal_dec_refl j form a (Atom j)). (* Goal: @eq form (vimp l (Imp (Imp a b) c)) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) trivial. (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) intros k k_is_mon forces1 forces2. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply forces_vimp with (Imp (Imp (Atom j) b) c); try assumption. (* Goal: forall (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (Imp (Imp (Atom j) b) c)), forces_t2 k k' (Imp (Imp a b) c) *) intros k' suc1 forces_jbc. (* Goal: @eq form (vimp l (subst_form j a (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) unfold forces_t2 in |- *; simpl in |- *. (* Goal: forall (k'0 : kripke_tree) (_ : Suc k'0 k) (_ : Suc k'0 k') (_ : forall (k' : kripke_tree) (_ : Suc k' k) (_ : Suc k' k'0) (_ : forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' a), forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' b), forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k'0 c *) intros k'' suc2 suc3. (* Goal: forall _ : forall (k' : kripke_tree) (_ : Suc k' k) (_ : Suc k' k'') (_ : forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' a), forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' b, forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k'' c *) change (forces_t2 k k'' (Imp a b) -> forces_t2 k k'' c) in |- *. (* Goal: forall _ : forces_t2 k k'' (Imp a b), forces_t2 k k'' c *) intros forces_ab. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply (forces_jbc k''); try assumption. (* Goal: forall (k' : kripke_tree) (_ : Suc k' k) (_ : Suc k' k'') (_ : forces0_t (Atms k') j), (fix forces (A : Set) (World : forall _ : A, Type) (le : forall (_ : A) (_ : A), Type) (forces0 : forall (_ : A) (_ : Int), Prop) (k : A) (a : form) {struct a} : Prop := match a with | Falsum => False | Atom i => forces0 k i | AndF a0 a1 => and (forces A World le forces0 k a0) (forces A World le forces0 k a1) | OrF a0 a1 => or (forces A World le forces0 k a0) (forces A World le forces0 k a1) | Imp a0 a1 => forall (k'0 : A) (_ : World k'0) (_ : le k k'0) (_ : forces A World le forces0 k'0 a0), forces A World le forces0 k'0 a1 end) kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' b *) intros k''' suc4 suc5. (* Goal: forall _ : forces0_t (Atms k''') j, (fix forces (A : Set) (World : forall _ : A, Type) (le : forall (_ : A) (_ : A), Type) (forces0 : forall (_ : A) (_ : Int), Prop) (k : A) (a : form) {struct a} : Prop := match a with | Falsum => False | Atom i => forces0 k i | AndF a0 a1 => and (forces A World le forces0 k a0) (forces A World le forces0 k a1) | OrF a0 a1 => or (forces A World le forces0 k a0) (forces A World le forces0 k a1) | Imp a0 a1 => forall (k' : A) (_ : World k') (_ : le k k') (_ : forces A World le forces0 k' a0), forces A World le forces0 k' a1 end) kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k''' b *) change (forces_t2 k k''' (Atom j) -> forces_t2 k k''' b) in |- *. (* Goal: forall _ : forces_t2 k k''' (Atom j), forces_t2 k k''' b *) intros forces_j. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply (forces_ab k'''); try assumption. (* Goal: (fix forces (A : Set) (World : forall _ : A, Type) (le : forall (_ : A) (_ : A), Type) (forces0 : forall (_ : A) (_ : Int), Prop) (k : A) (a : form) {struct a} : Prop := match a with | Falsum => False | Atom i => forces0 k i | AndF a0 a1 => and (forces A World le forces0 k a0) (forces A World le forces0 k a1) | OrF a0 a1 => or (forces A World le forces0 k a0) (forces A World le forces0 k a1) | Imp a0 a1 => forall (k' : A) (_ : World k') (_ : le k k') (_ : forces A World le forces0 k' a0), forces A World le forces0 k' a1 end) kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k''' a *) change (forces_t2 k k''' a) in |- *. (* Goal: below_form (Atom j) j1 *) (* Goal: below_form b j1 *) (* Goal: below_form c j1 *) (* Goal: @eq form (subst_form j a (vimp l (Imp (Imp (Atom j) b) c))) (vimp l (Imp (Imp a b) c)) *) (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (vimp l (Imp (Imp (Atom j) b) c))) (_ : forces_t k (Imp (Atom j) a)), forces_t k (vimp l (Imp (Imp a b) c)) *) apply (forces2 k'''); assumption. Qed.
(* File: In_Gamma.v (last edited on 27/10/2000) (c) Klaus Weich *) Require Export In_NGamma. Inductive in_gamma (gamma : flist) (work : nf_list) : form -> Set := | In_Gamma : forall (n : nat) (a : form), my_nth form n gamma a -> in_gamma gamma work a | In_Work1 : forall (n : nat) (a : normal_form), my_nth normal_form n work a -> in_gamma gamma work (nf2form a). Lemma in_gamma_cons_gamma_tail : forall (a : form) (gamma : flist) (work : nf_list) (c : form), in_gamma gamma work c -> in_gamma (a :: gamma) work c. (* Goal: forall (a : normal_form) (gamma : flist) (work : nf_list) (c : form) (_ : in_gamma gamma (@cons normal_form a work) c), in_gamma (@cons form (nf2form a) gamma) work c *) intros a gamma work c in_gamma0. (* Goal: sumor (in_gamma gamma work c) (@eq form c (nf2form a)) *) elim in_gamma0; clear in_gamma0 c. (* Goal: forall (n : nat) (a0 : form) (_ : my_nth form n gamma a0), sumor (in_gamma gamma work a0) (@eq form a0 (nf2form a)) *) (* Goal: forall (n : nat) (a0 : normal_form) (_ : my_nth normal_form n (@cons normal_form a work) a0), sumor (in_gamma gamma work (nf2form a0)) (@eq form (nf2form a0) (nf2form a)) *) intros n c nth. (* Goal: in_gamma (@cons form a gamma) work c *) (* Goal: forall (n : nat) (a0 : normal_form) (_ : my_nth normal_form n work a0), in_gamma (@cons form a gamma) work (nf2form a0) *) apply In_Gamma with (S n). (* Goal: my_nth normal_form (S n) (@cons normal_form a work) c *) apply My_NthS; assumption. (* Goal: forall (n : nat) (a0 : form) (_ : my_nth form n gamma a0), sumor (in_gamma gamma work a0) (@eq form a0 (nf2form a)) *) (* Goal: forall (n : nat) (a0 : normal_form) (_ : my_nth normal_form n (@cons normal_form a work) a0), sumor (in_gamma gamma work (nf2form a0)) (@eq form (nf2form a0) (nf2form a)) *) intros n c nth. (* Goal: in_gamma (@cons form a gamma) work (nf2form c) *) apply In_Work1 with n; assumption. Qed. Lemma in_gamma_cons_gamma_head : forall (a : form) (gamma : flist) (work : nf_list), in_gamma (a :: gamma) work a. (* Goal: forall (a : normal_form) (gamma : flist) (work : nf_list), in_gamma gamma (@cons normal_form a work) (nf2form a) *) intros a gamma work. (* Goal: in_gamma (@cons form a gamma) work a *) apply In_Gamma with 0. (* Goal: my_nth normal_form O (@cons normal_form a work) a *) apply My_NthO. Qed. Lemma in_gamma_cons_gamma_rev : forall (a : form) (gamma : flist) (work : nf_list) (c : form), in_gamma (a :: gamma) work c -> in_gamma gamma work c + {c = a}. (* Goal: forall (a : normal_form) (gamma : flist) (work : nf_list) (c : form) (_ : in_gamma gamma (@cons normal_form a work) c), in_gamma (@cons form (nf2form a) gamma) work c *) intros a gamma work c in_gamma0. (* Goal: sumor (in_gamma gamma work c) (@eq form c (nf2form a)) *) elim in_gamma0; clear in_gamma0 c. (* Goal: forall (n : nat) (a0 : normal_form) (_ : my_nth normal_form n (@cons normal_form a work) a0), sumor (in_gamma gamma work (nf2form a0)) (@eq form (nf2form a0) (nf2form a)) *) intros n c; case n; clear n. (* Goal: forall _ : my_nth normal_form O (@cons normal_form a work) c, sumor (in_gamma gamma work (nf2form c)) (@eq form (nf2form c) (nf2form a)) *) (* Goal: forall (n : nat) (_ : my_nth normal_form (S n) (@cons normal_form a work) c), sumor (in_gamma gamma work (nf2form c)) (@eq form (nf2form c) (nf2form a)) *) intros nth. (* Goal: sumor (in_gamma gamma work (nf2form c)) (@eq form (nf2form c) (nf2form a)) *) (* Goal: forall (n : nat) (_ : my_nth normal_form (S n) (@cons normal_form a work) c), sumor (in_gamma gamma work (nf2form c)) (@eq form (nf2form c) (nf2form a)) *) right; inversion_clear nth; trivial. (* Goal: forall (n : nat) (_ : my_nth normal_form (S n) (@cons normal_form a work) c), sumor (in_gamma gamma work (nf2form c)) (@eq form (nf2form c) (nf2form a)) *) intros n nth. (* Goal: sumor (in_gamma gamma work c) (@eq form c a) *) (* Goal: forall (n : nat) (a0 : normal_form) (_ : my_nth normal_form n work a0), sumor (in_gamma gamma work (nf2form a0)) (@eq form (nf2form a0) a) *) left; apply In_Gamma with n. (* Goal: my_nth normal_form n work c *) inversion_clear nth; assumption. (* Goal: forall (n : nat) (a0 : form) (_ : my_nth form n gamma a0), sumor (in_gamma gamma work a0) (@eq form a0 (nf2form a)) *) (* Goal: forall (n : nat) (a0 : normal_form) (_ : my_nth normal_form n (@cons normal_form a work) a0), sumor (in_gamma gamma work (nf2form a0)) (@eq form (nf2form a0) (nf2form a)) *) intros n c nth. (* Goal: in_gamma (@cons form a gamma) work (nf2form c) *) left; apply In_Work1 with n; assumption. Qed. Lemma in_gamma_cons_work_tail : forall (a : normal_form) (gamma : flist) (work : nf_list) (c : form), in_gamma gamma work c -> in_gamma gamma (a :: work) c. (* Goal: forall (a : normal_form) (gamma : flist) (work : nf_list) (c : form) (_ : in_gamma gamma (@cons normal_form a work) c), in_gamma (@cons form (nf2form a) gamma) work c *) intros a gamma work c in_gamma0. (* Goal: sumor (in_gamma gamma work c) (@eq form c (nf2form a)) *) elim in_gamma0; clear in_gamma0 c. (* Goal: forall (n : nat) (a0 : form) (_ : my_nth form n gamma a0), sumor (in_gamma gamma work a0) (@eq form a0 (nf2form a)) *) (* Goal: forall (n : nat) (a0 : normal_form) (_ : my_nth normal_form n (@cons normal_form a work) a0), sumor (in_gamma gamma work (nf2form a0)) (@eq form (nf2form a0) (nf2form a)) *) intros n c nth. (* Goal: in_gamma gamma (@cons normal_form a work) c *) (* Goal: forall (n : nat) (a0 : normal_form) (_ : my_nth normal_form n work a0), in_gamma gamma (@cons normal_form a work) (nf2form a0) *) apply In_Gamma with n; assumption. (* Goal: forall (n : nat) (a0 : form) (_ : my_nth form n gamma a0), sumor (in_gamma gamma work a0) (@eq form a0 (nf2form a)) *) (* Goal: forall (n : nat) (a0 : normal_form) (_ : my_nth normal_form n (@cons normal_form a work) a0), sumor (in_gamma gamma work (nf2form a0)) (@eq form (nf2form a0) (nf2form a)) *) intros n c nth. (* Goal: in_gamma gamma (@cons normal_form a work) (nf2form c) *) apply In_Work1 with (S n). (* Goal: my_nth normal_form (S n) (@cons normal_form a work) c *) apply My_NthS; assumption. Qed. Lemma in_gamma_cons_work_head : forall (a : normal_form) (gamma : flist) (work : nf_list), in_gamma gamma (a :: work) (nf2form a). (* Goal: forall (a : normal_form) (gamma : flist) (work : nf_list), in_gamma gamma (@cons normal_form a work) (nf2form a) *) intros a gamma work. (* Goal: in_gamma gamma (@cons normal_form a work) (nf2form a) *) apply In_Work1 with 0. (* Goal: my_nth normal_form O (@cons normal_form a work) a *) apply My_NthO. Qed. Lemma in_gamma_cons_work_rev : forall (a : normal_form) (gamma : flist) (work : nf_list) (c : form), in_gamma gamma (a :: work) c -> in_gamma gamma work c + {c = nf2form a}. (* Goal: forall (a : normal_form) (gamma : flist) (work : nf_list) (c : form) (_ : in_gamma gamma (@cons normal_form a work) c), in_gamma (@cons form (nf2form a) gamma) work c *) intros a gamma work c in_gamma0. (* Goal: sumor (in_gamma gamma work c) (@eq form c (nf2form a)) *) elim in_gamma0; clear in_gamma0 c. (* Goal: forall (n : nat) (a0 : form) (_ : my_nth form n gamma a0), sumor (in_gamma gamma work a0) (@eq form a0 (nf2form a)) *) (* Goal: forall (n : nat) (a0 : normal_form) (_ : my_nth normal_form n (@cons normal_form a work) a0), sumor (in_gamma gamma work (nf2form a0)) (@eq form (nf2form a0) (nf2form a)) *) intros n c nth. (* Goal: in_gamma gamma (@cons normal_form a work) c *) (* Goal: forall (n : nat) (a0 : normal_form) (_ : my_nth normal_form n work a0), in_gamma gamma (@cons normal_form a work) (nf2form a0) *) left; apply In_Gamma with n; assumption. (* Goal: forall (n : nat) (a0 : normal_form) (_ : my_nth normal_form n (@cons normal_form a work) a0), sumor (in_gamma gamma work (nf2form a0)) (@eq form (nf2form a0) (nf2form a)) *) intros n c; case n; clear n. (* Goal: forall _ : my_nth normal_form O (@cons normal_form a work) c, sumor (in_gamma gamma work (nf2form c)) (@eq form (nf2form c) (nf2form a)) *) (* Goal: forall (n : nat) (_ : my_nth normal_form (S n) (@cons normal_form a work) c), sumor (in_gamma gamma work (nf2form c)) (@eq form (nf2form c) (nf2form a)) *) intros nth. (* Goal: sumor (in_gamma gamma work (nf2form c)) (@eq form (nf2form c) (nf2form a)) *) (* Goal: forall (n : nat) (_ : my_nth normal_form (S n) (@cons normal_form a work) c), sumor (in_gamma gamma work (nf2form c)) (@eq form (nf2form c) (nf2form a)) *) right; inversion_clear nth; trivial. (* Goal: forall (n : nat) (_ : my_nth normal_form (S n) (@cons normal_form a work) c), sumor (in_gamma gamma work (nf2form c)) (@eq form (nf2form c) (nf2form a)) *) intros n nth. (* Goal: sumor (in_gamma gamma work (nf2form c)) (@eq form (nf2form c) (nf2form a)) *) left; apply In_Work1 with n. (* Goal: my_nth normal_form n work c *) inversion_clear nth; assumption. Qed. (********************************************************************) Lemma in_gamma_shift_gamma_work : forall (a : normal_form) (gamma : flist) (work : nf_list) (c : form), in_gamma (nf2form a :: gamma) work c -> in_gamma gamma (a :: work) c. (* Goal: forall (a : normal_form) (gamma : flist) (work : nf_list) (c : form) (_ : in_gamma gamma (@cons normal_form a work) c), in_gamma (@cons form (nf2form a) gamma) work c *) intros a gamma work c in_gamma0. elim (in_gamma_cons_gamma_rev (nf2form a) gamma work c in_gamma0); clear in_gamma0. (* Goal: forall _ : in_gamma gamma work c, in_gamma (@cons form (nf2form a) gamma) work c *) (* Goal: forall _ : @eq form c (nf2form a), in_gamma (@cons form (nf2form a) gamma) work c *) intros in_gamma0. (* Goal: in_gamma gamma (@cons normal_form a work) c *) (* Goal: forall _ : @eq form c (nf2form a), in_gamma gamma (@cons normal_form a work) c *) apply in_gamma_cons_work_tail; assumption. intros eq_c; rewrite eq_c; clear eq_c c. (* Goal: in_gamma gamma (@cons normal_form a work) (nf2form a) *) apply in_gamma_cons_work_head. Qed. Lemma in_gamma_shift_work_gamma : forall (a : normal_form) (gamma : flist) (work : nf_list) (c : form), in_gamma gamma (a :: work) c -> in_gamma (nf2form a :: gamma) work c. (* Goal: forall (a : normal_form) (gamma : flist) (work : nf_list) (c : form) (_ : in_gamma gamma (@cons normal_form a work) c), in_gamma (@cons form (nf2form a) gamma) work c *) intros a gamma work c in_gamma0. (* Goal: in_gamma (@cons form (nf2form a) gamma) work c *) elim (in_gamma_cons_work_rev a gamma work c in_gamma0); clear in_gamma0. (* Goal: forall _ : in_gamma gamma work c, in_gamma (@cons form (nf2form a) gamma) work c *) (* Goal: forall _ : @eq form c (nf2form a), in_gamma (@cons form (nf2form a) gamma) work c *) intros in_gamma0. (* Goal: in_gamma (@cons form (nf2form a) gamma) work c *) (* Goal: forall _ : @eq form c (nf2form a), in_gamma (@cons form (nf2form a) gamma) work c *) apply in_gamma_cons_gamma_tail; assumption. intros eq_c; rewrite eq_c; clear eq_c c. (* Goal: in_gamma (@cons form (nf2form a) gamma) work (nf2form a) *) apply in_gamma_cons_gamma_head. Qed.
(* File: Normal_Form.v (last edited on 27/10/2000) (c) Klaus Weich *) Require Export Forms. (******* Normal forms ***********************************************) Inductive normal_form : Set := | NFalsum : normal_form | NAtom : Int -> normal_form | NDisj : Int -> Int -> normal_form | AImp : Int -> normal_form -> normal_form | NImp_NF : nimp -> normal_form with nimp : Set := NImp : Int -> Int -> normal_form -> nimp. Fixpoint nf2form (x : normal_form) : form := match x with | NFalsum => Falsum | NAtom i => Atom i | NDisj i j => OrF (Atom i) (Atom j) | AImp i b => Imp (Atom i) (nf2form b) | NImp_NF x => nimp2form x end with nimp2form (x : nimp) : form := match x with | NImp i j b => Imp (Imp (Atom i) (Atom j)) (nf2form b) end. Definition nf_list := list normal_form. Definition nf_nil := nil (A:=normal_form). Fixpoint nvimp (l : list Int) : normal_form -> normal_form := match l with | nil => fun a : normal_form => a | i :: l => fun a : normal_form => nvimp l (AImp i a) end. Lemma vimp2nform : forall (l : list Int) (a : normal_form), {b : normal_form | nf2form b = vimp l (nf2form a)}. (* Goal: forall (l : list Int) (a : normal_form), @eq form (vimp l (nf2form a)) (nf2form (nvimp l a)) *) intros l; elim l; clear l. (* Goal: forall a : normal_form, @sig normal_form (fun b : normal_form => @eq normal_form b (nvimp (@nil Int) a)) *) (* Goal: forall (a : Int) (l : list Int) (_ : forall a0 : normal_form, @sig normal_form (fun b : normal_form => @eq normal_form b (nvimp l a0))) (a0 : normal_form), @sig normal_form (fun b : normal_form => @eq normal_form b (nvimp (@cons Int a l) a0)) *) intros a; exists a; trivial. (* Goal: forall (a : Int) (l : list Int) (_ : forall a0 : normal_form, @eq form (vimp l (nf2form a0)) (nf2form (nvimp l a0))) (a0 : normal_form), @eq form (vimp (@cons Int a l) (nf2form a0)) (nf2form (nvimp (@cons Int a l) a0)) *) intros i l ih a. (* Goal: @sig normal_form (fun b : normal_form => @eq normal_form b (nvimp (@cons Int i l) a)) *) elim (ih (AImp i a)); clear ih. (* Goal: forall (x : normal_form) (_ : @eq normal_form x (nvimp l (AImp i a))), @sig normal_form (fun b : normal_form => @eq normal_form b (nvimp (@cons Int i l) a)) *) intros b nf_b. (* Goal: @sig normal_form (fun b : normal_form => @eq normal_form b (nvimp (@cons Int i l) a)) *) exists b; assumption. Qed. Lemma vimp2nvimp : forall (l : list Int) (a : normal_form), {b : normal_form | b = nvimp l a}. (* Goal: forall (l : list Int) (a : normal_form), @eq form (vimp l (nf2form a)) (nf2form (nvimp l a)) *) intros l; elim l; clear l. (* Goal: forall a : normal_form, @sig normal_form (fun b : normal_form => @eq normal_form b (nvimp (@nil Int) a)) *) (* Goal: forall (a : Int) (l : list Int) (_ : forall a0 : normal_form, @sig normal_form (fun b : normal_form => @eq normal_form b (nvimp l a0))) (a0 : normal_form), @sig normal_form (fun b : normal_form => @eq normal_form b (nvimp (@cons Int a l) a0)) *) intros a; exists a; trivial. (* Goal: forall (a : Int) (l : list Int) (_ : forall a0 : normal_form, @eq form (vimp l (nf2form a0)) (nf2form (nvimp l a0))) (a0 : normal_form), @eq form (vimp (@cons Int a l) (nf2form a0)) (nf2form (nvimp (@cons Int a l) a0)) *) intros i l ih a. (* Goal: @sig normal_form (fun b : normal_form => @eq normal_form b (nvimp (@cons Int i l) a)) *) elim (ih (AImp i a)); clear ih. (* Goal: forall (x : normal_form) (_ : @eq normal_form x (nvimp l (AImp i a))), @sig normal_form (fun b : normal_form => @eq normal_form b (nvimp (@cons Int i l) a)) *) intros b nf_b. (* Goal: @sig normal_form (fun b : normal_form => @eq normal_form b (nvimp (@cons Int i l) a)) *) exists b; assumption. Qed. Lemma vimp_eq_nvimp : forall (l : list Int) (a : normal_form), vimp l (nf2form a) = nf2form (nvimp l a). (* Goal: forall (l : list Int) (a : normal_form), @eq form (vimp l (nf2form a)) (nf2form (nvimp l a)) *) intros l; elim l; clear l. (* Goal: forall a : normal_form, @eq form (vimp (@nil Int) (nf2form a)) (nf2form (nvimp (@nil Int) a)) *) (* Goal: forall (a : Int) (l : list Int) (_ : forall a0 : normal_form, @eq form (vimp l (nf2form a0)) (nf2form (nvimp l a0))) (a0 : normal_form), @eq form (vimp (@cons Int a l) (nf2form a0)) (nf2form (nvimp (@cons Int a l) a0)) *) intros a; trivial. (* Goal: forall (a : Int) (l : list Int) (_ : forall a0 : normal_form, @eq form (vimp l (nf2form a0)) (nf2form (nvimp l a0))) (a0 : normal_form), @eq form (vimp (@cons Int a l) (nf2form a0)) (nf2form (nvimp (@cons Int a l) a0)) *) intros i l ih a. (* Goal: @eq form (vimp (@cons Int i l) (nf2form a)) (nf2form (nvimp (@cons Int i l) a)) *) apply (ih (AImp i a)). Qed.
(* File: Forces_Gamma.v (last edited on 27/10/2000) (c) Klaus Weich *) Require Export In_Gamma. Require Export Forces_NGamma. Definition forces_gamma (gamma : flist) (work : nf_list) (k : kripke_tree) := forall a : form, in_gamma gamma work a -> forces_t k a. Lemma forces_gamma_cons_gamma : forall (gamma : flist) (work : nf_list) (k : kripke_tree) (a : form), forces_t k a -> forces_gamma gamma work k -> forces_gamma (a :: gamma) work k. (* Goal: forall (gamma : flist) (work : nf_list) (k : kripke_tree) (a : form) (_ : forces_t k a) (_ : forces_gamma gamma work k), forces_gamma (@cons form a gamma) work k *) intros gamma work k a forces_a forces_gamma0. (* Goal: forces_gamma (@cons form (nf2form a) gamma) work k *) unfold forces_gamma in |- *. (* Goal: forall (a : form) (_ : in_gamma gamma work a), forces_t k a *) intros c in_gamma0. (* Goal: forces_t k c *) elim (in_gamma_cons_gamma_rev a gamma work c in_gamma0); clear in_gamma0. (* Goal: forall _ : in_gamma gamma work c, forces_t k c *) (* Goal: forall _ : @eq form c a, forces_t k c *) intros in_gamma0. (* Goal: forces_t k c *) (* Goal: forall _ : @eq form c a, forces_t k c *) apply forces_gamma0; assumption. intros eq_c; rewrite eq_c; assumption. Qed. Lemma forces_gamma_cons_gamma_tail : forall (gamma : flist) (work : nf_list) (k : kripke_tree) (a : form), forces_gamma (a :: gamma) work k -> forces_gamma gamma work k. (* Goal: forall (gamma : flist) (work : nf_list) (k : kripke_tree) (a : form) (_ : forces_gamma (@cons form a gamma) work k), forces_t k a *) intros gamma work k a forces_gamma0. (* Goal: forces_gamma (@cons form (nf2form a) gamma) work k *) unfold forces_gamma in |- *. (* Goal: forall (a : form) (_ : in_gamma gamma work a), forces_t k a *) intros c in_gamma0. (* Goal: forces_t k c *) apply forces_gamma0. (* Goal: in_gamma (@cons form a gamma) work c *) apply in_gamma_cons_gamma_tail; assumption. Qed. Lemma forces_gamma_cons_gamma_head : forall (gamma : flist) (work : nf_list) (k : kripke_tree) (a : form), forces_gamma (a :: gamma) work k -> forces_t k a. (* Goal: forall (gamma : flist) (work : nf_list) (k : kripke_tree) (a : form) (_ : forces_gamma (@cons form a gamma) work k), forces_t k a *) intros gamma work k a forces_gamma0. (* Goal: forces_t k c *) apply forces_gamma0. (* Goal: in_gamma (@cons form a gamma) work a *) apply in_gamma_cons_gamma_head; assumption. Qed. (*********************************************************************) Lemma forces_gamma_shift_gamma_work : forall (a : normal_form) (gamma : flist) (work : nf_list) (k : kripke_tree), forces_gamma (nf2form a :: gamma) work k -> forces_gamma gamma (a :: work) k. (* Goal: forall (a : normal_form) (gamma : flist) (work : nf_list) (k : kripke_tree) (_ : forces_gamma gamma (@cons normal_form a work) k), forces_gamma (@cons form (nf2form a) gamma) work k *) intros a gamma work k forces_gamma0. (* Goal: forces_gamma (@cons form (nf2form a) gamma) work k *) unfold forces_gamma in |- *. (* Goal: forall (a0 : form) (_ : in_gamma (@cons form (nf2form a) gamma) work a0), forces_t k a0 *) intros c in_gamma. (* Goal: forces_t k c *) apply forces_gamma0. (* Goal: In_Gamma.in_gamma (@cons form (nf2form a) gamma) work c *) apply in_gamma_shift_work_gamma; assumption. Qed. Lemma forces_gamma_shift_work_gamma : forall (a : normal_form) (gamma : flist) (work : nf_list) (k : kripke_tree), forces_gamma gamma (a :: work) k -> forces_gamma (nf2form a :: gamma) work k. (* Goal: forall (a : normal_form) (gamma : flist) (work : nf_list) (k : kripke_tree) (_ : forces_gamma gamma (@cons normal_form a work) k), forces_gamma (@cons form (nf2form a) gamma) work k *) intros a gamma work k forces_gamma0. (* Goal: forces_gamma (@cons form (nf2form a) gamma) work k *) unfold forces_gamma in |- *. (* Goal: forall (a0 : form) (_ : in_gamma (@cons form (nf2form a) gamma) work a0), forces_t k a0 *) intros c in_gamma. (* Goal: forces_t k c *) apply forces_gamma0. (* Goal: In_Gamma.in_gamma gamma (@cons normal_form a work) c *) apply in_gamma_shift_gamma_work; assumption. Qed. (*********************************************************************) Lemma forces_gamma_cons_gamma_weak : forall (gamma : flist) (work : nf_list) (k : kripke_tree) (a b : form), (forces_t k a -> forces_t k b) -> forces_gamma (a :: gamma) work k -> forces_gamma (b :: gamma) work k. (* Goal: forall (gamma : flist) (work : nf_list) (k : kripke_tree) (a b : form) (_ : forall _ : forces_t k a, forces_t k b) (_ : forces_gamma (@cons form a gamma) work k), forces_gamma (@cons form b gamma) work k *) intros gamma work k a b forces_ab forces_gamma0. (* Goal: forces_gamma (@cons form c gamma) work k *) apply forces_gamma_cons_gamma. (* Goal: forces_t k b *) (* Goal: forces_gamma gamma work k *) apply forces_ab. (* Goal: forces_t k a *) (* Goal: forces_gamma gamma work k *) apply forces_gamma_cons_gamma_head with gamma work; assumption. (* Goal: forces_gamma (@cons form b gamma) work k *) apply forces_gamma_cons_gamma_tail with a; assumption. Qed. Lemma forces_gamma_cons_gamma_weak2 : forall (gamma : flist) (work : nf_list) (k : kripke_tree) (a b c : form), (forces_t k a -> forces_t k b -> forces_t k c) -> forces_gamma (a :: b :: gamma) work k -> forces_gamma (c :: gamma) work k. (* Goal: forall (gamma : flist) (work : nf_list) (k : kripke_tree) (a b c : form) (_ : forall (_ : forces_t k a) (_ : forces_t k b), forces_t k c) (_ : forces_gamma (@cons form a (@cons form b gamma)) work k), forces_gamma (@cons form c gamma) work k *) intros gamma work k a b c forces_abc forces_gamma0. (* Goal: forces_gamma (@cons form c gamma) work k *) apply forces_gamma_cons_gamma. (* Goal: forces_t k c *) (* Goal: forces_gamma gamma work k *) apply forces_abc. (* Goal: forces_t k a *) (* Goal: forces_t k b *) (* Goal: forces_gamma gamma work k *) apply forces_gamma_cons_gamma_head with (b :: gamma) work; assumption. (* Goal: forces_t k b *) (* Goal: forces_gamma gamma work k *) apply forces_gamma_cons_gamma_head with gamma work. (* Goal: forces_gamma (@cons form b gamma) work k *) apply forces_gamma_cons_gamma_tail with a; assumption. (* Goal: forces_gamma gamma work k *) apply forces_gamma_cons_gamma_tail with b. (* Goal: forces_gamma (@cons form b gamma) work k *) apply forces_gamma_cons_gamma_tail with a; assumption. Qed.
(* File: NSound.v (last edited on 27/10/2000) (c) Klaus Weich *) Require Export Le_Ks. Require Export Derivable_Tools. Definition nsound (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist) := forall c : normal_form, in_ngamma work ds ni ai a c -> Derivable context (nf2form c). Lemma nsound_eqv : forall (work : nf_list) (ds : disjs) (ni1 ni2 : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist), eqv_ni ni1 ni2 -> nsound work ds ni1 ai a context -> nsound work ds ni2 ai a context. (* Goal: forall (work : nf_list) (ds : disjs) (ni1 ni2 : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist) (_ : eqv_ni ni1 ni2) (_ : nsound work ds ni1 ai a context), nsound work ds ni2 ai a context *) intros work ds ni1 ni2 ai a context eq12 sound. (* Goal: nsound (@cons normal_form c work) ds ni ai a context *) unfold nsound in |- *. (* Goal: forall (c : normal_form) (_ : in_ngamma work ds ni ai' a c), Derivable context (nf2form c) *) intros c in_ngamma. (* Goal: Derivable context (nf2form b) *) apply sound. (* Goal: In_NGamma.in_ngamma work ds ni1 ai a c *) apply in_ngamma_eqv with ni2. (* Goal: eqv_ni ni2 ni1 *) (* Goal: In_NGamma.in_ngamma work ds ni2 ai a c *) apply eqv_sym; assumption. (* Goal: In_NGamma.in_ngamma work ds ni2 ai a c *) assumption. Qed. Lemma nsound_le : forall (work : nf_list) (ds : disjs) (ni1 ni2 : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist), le_ni ni1 ni2 -> nsound work ds ni1 ai a context -> nsound work ds ni2 ai a context. (* Goal: forall (work : nf_list) (ds : disjs) (ni1 ni2 : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist) (_ : le_ni ni2 ni1) (_ : nsound work ds ni1 ai a context), nsound work ds ni2 ai a context *) intros work ds ni1 ni2 ai a context le sound. (* Goal: nsound (@cons normal_form c work) ds ni ai a context *) unfold nsound in |- *. (* Goal: forall (c : normal_form) (_ : in_ngamma work ds ni ai' a c), Derivable context (nf2form c) *) intros c in_ngamma. (* Goal: Derivable context (nf2form b) *) apply sound. (* Goal: In_NGamma.in_ngamma work ds ni2 ai a c *) apply in_ngamma_ge with ni2; assumption. Qed. Lemma nsound_ge : forall (work : nf_list) (ds : disjs) (ni1 ni2 : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist), le_ni ni2 ni1 -> nsound work ds ni1 ai a context -> nsound work ds ni2 ai a context. (* Goal: forall (work : nf_list) (ds : disjs) (ni1 ni2 : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist) (_ : le_ni ni2 ni1) (_ : nsound work ds ni1 ai a context), nsound work ds ni2 ai a context *) intros work ds ni1 ni2 ai a context le sound. (* Goal: nsound (@cons normal_form c work) ds ni ai a context *) unfold nsound in |- *. (* Goal: forall (c : normal_form) (_ : in_ngamma work ds ni ai' a c), Derivable context (nf2form c) *) intros c in_ngamma. (* Goal: Derivable context (nf2form b) *) apply sound. (* Goal: In_NGamma.in_ngamma work ds ni2 ai a c *) apply in_ngamma_le with ni2; assumption. Qed. (***********************************************************************) Lemma nsound_shift_work_ds : forall (i j : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist), nsound (NDisj i j :: work) ds ni ai a context -> nsound work ((i, j) :: ds) ni ai a context. (* Goal: forall (i j : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist) (_ : nsound (@cons normal_form (NDisj i j) work) ds ni ai a context), nsound work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) intros i j work ds ni ai a context sound. (* Goal: nsound (@cons normal_form c work) ds ni ai a context *) unfold nsound in |- *. (* Goal: forall (c : normal_form) (_ : in_ngamma work ds ni ai' a c), Derivable context (nf2form c) *) intros c in_ngamma. (* Goal: Derivable context (nf2form b) *) apply sound. (* Goal: In_NGamma.in_ngamma work ds ni2 ai a c *) apply in_ngamma_shift_ds_work; assumption. Qed. Lemma nsound_shift_work_ni : forall (x : nested_imp) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist), nsound (NImp_NF (nested_imp2nimp x) :: work) ds ni ai a context -> nsound work ds (x :: ni) ai a context. (* Goal: forall (x : nested_imp) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist) (_ : nsound (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds ni ai a context), nsound work ds (@cons nested_imp x ni) ai a context *) intros x work ds ni ai a context sound. (* Goal: nsound (@cons normal_form c work) ds ni ai a context *) unfold nsound in |- *. (* Goal: forall (c : normal_form) (_ : in_ngamma work ds ni ai' a c), Derivable context (nf2form c) *) intros c in_ngamma. (* Goal: Derivable context (nf2form b) *) apply sound. (* Goal: In_NGamma.in_ngamma work ds ni2 ai a c *) apply in_ngamma_shift_ni_work; assumption. Qed. Lemma nsound_shift_work_ai : forall (i : Int) (b : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai ai' : atomic_imps) (a : atoms) (context : flist), EQUIV_INS nf_list i (cons b) nf_nil ai ai' -> nsound (AImp i b :: work) ds ni ai a context -> nsound work ds ni ai' a context. (* Goal: forall (i : Int) (b : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai ai' : atomic_imps) (a : atoms) (context : flist) (_ : EQUIV_INS nf_list i (@cons normal_form b) nf_nil ai ai') (_ : nsound (@cons normal_form (AImp i b) work) ds ni ai a context), nsound work ds ni ai' a context *) intros i b work ds ni ai ai' a context equiv_ins sound. (* Goal: nsound (@cons normal_form c work) ds ni ai a context *) unfold nsound in |- *. (* Goal: forall (c : normal_form) (_ : in_ngamma work ds ni ai' a c), Derivable context (nf2form c) *) intros c in_ngamma. (* Goal: Derivable context (nf2form b) *) apply sound. (* Goal: In_NGamma.in_ngamma work ds ni2 ai a c *) apply in_ngamma_shift_ai_work with ai'; assumption. Qed. Lemma nsound_shift_work_a : forall (i : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a a' : atoms) (context : flist), EQUIV_INS unit i (fun _ : unit => tt) tt a a' -> nsound (NAtom i :: work) ds ni ai a context -> nsound work ds ni ai a' context. (* Goal: forall (i : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a a' : atoms) (context : flist) (_ : EQUIV_INS unit i (fun _ : unit => tt) tt a a') (_ : nsound (@cons normal_form (NAtom i) work) ds ni ai a context), nsound work ds ni ai a' context *) intros i work ds ni ai a a' context equiv_ins sound. (* Goal: nsound (@cons normal_form c work) ds ni ai a context *) unfold nsound in |- *. (* Goal: forall (c : normal_form) (_ : in_ngamma work ds ni ai' a c), Derivable context (nf2form c) *) intros c in_ngamma. (* Goal: Derivable context (nf2form b) *) apply sound. (* Goal: In_NGamma.in_ngamma work ds ni2 ai a c *) apply in_ngamma_shift_a_work with a'; assumption. Qed. Lemma nsound_shift_work_ni_x_ni : forall (x : nested_imp) (work : nf_list) (ds : disjs) (ni1 ni2 : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist), nsound (NImp_NF (nested_imp2nimp x) :: work) ds (ni1 ++ ni2) ai a context -> nsound work ds (ni1 ++ x :: ni2) ai a context. (* Goal: forall (x : nested_imp) (work : nf_list) (ds : disjs) (ni1 ni2 : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist) (_ : nsound work ds (@app nested_imp ni1 (@cons nested_imp x ni2)) ai a context), nsound (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds (@app nested_imp ni1 ni2) ai a context *) intros x work ds ni1 ni2 ai a context sound. (* Goal: nsound (@cons normal_form c work) ds ni ai a context *) unfold nsound in |- *. (* Goal: forall (c : normal_form) (_ : in_ngamma work ds ni ai' a c), Derivable context (nf2form c) *) intros c in_ngamma. (* Goal: Derivable context (nf2form b) *) apply sound. (* Goal: In_NGamma.in_ngamma work ds ni2 ai a c *) apply in_ngamma_shift_ni_x_ni_work; assumption. Qed. Lemma nsound_shift_ni_x_ni_work : forall (x : nested_imp) (work : nf_list) (ds : disjs) (ni1 ni2 : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist), nsound work ds (ni1 ++ x :: ni2) ai a context -> nsound (NImp_NF (nested_imp2nimp x) :: work) ds (ni1 ++ ni2) ai a context. (* Goal: forall (x : nested_imp) (work : nf_list) (ds : disjs) (ni1 ni2 : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist) (_ : nsound work ds (@app nested_imp ni1 (@cons nested_imp x ni2)) ai a context), nsound (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds (@app nested_imp ni1 ni2) ai a context *) intros x work ds ni1 ni2 ai a context sound. (* Goal: nsound (@cons normal_form c work) ds ni ai a context *) unfold nsound in |- *. (* Goal: forall (c : normal_form) (_ : in_ngamma work ds ni ai' a c), Derivable context (nf2form c) *) intros c in_ngamma. (* Goal: Derivable context (nf2form b) *) apply sound. (* Goal: In_NGamma.in_ngamma work ds ni2 ai a c *) apply in_ngamma_shift_work_ni_x_ni; assumption. Qed. (***********************************************************************) Remark nsound_app_work : forall (bs work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist), (forall (n : nat) (b : normal_form), my_nth normal_form n bs b -> Derivable context (nf2form b)) -> nsound work ds ni ai a context -> nsound (bs ++ work) ds ni ai a context. (* Goal: forall (bs work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist) (_ : forall (n : nat) (b : normal_form) (_ : my_nth normal_form n bs b), Derivable context (nf2form b)) (_ : nsound work ds ni ai a context), nsound (@app normal_form bs work) ds ni ai a context *) intros bs work ds ni ai a context der_bs sound. (* Goal: nsound (@cons normal_form c work) ds ni ai a context *) unfold nsound in |- *. (* Goal: forall (c : normal_form) (_ : in_ngamma work ds ni ai' a c), Derivable context (nf2form c) *) intros c in_ngamma. (* Goal: Derivable context (nf2form c) *) elim (in_ngamma_work_app_rev bs work ds ni ai a c in_ngamma); clear in_ngamma. (* Goal: forall _ : in_ngamma work ds ni ai a c0, Derivable context (nf2form c0) *) (* Goal: forall _ : @eq normal_form c0 c, Derivable context (nf2form c0) *) intros in_ngamma. (* Goal: In_NGamma.in_ngamma work ds ni2 ai a c *) apply sound; assumption. (* Goal: forall _ : @sig nat (fun n : nat => my_nth normal_form n bs c), Derivable context (nf2form c) *) intros nth; elim nth; clear nth. (* Goal: forall (x : nat) (_ : my_nth normal_form x bs c), Derivable context (nf2form c) *) intros n nth. (* Goal: In_NGamma.in_ngamma work ds ni2 ai a c *) apply der_bs with n; assumption. Qed. Lemma nsound_cons_ds_tail : forall (work : nf_list) (i j : Int) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist), nsound work ((i, j) :: ds) ni ai a context -> nsound work ds ni ai a context. (* Goal: forall (work : nf_list) (i j : Int) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist) (_ : nsound work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context), nsound work ds ni ai a context *) intros work i j ds ni ai a context sound. (* Goal: nsound (@cons normal_form c work) ds ni ai a context *) unfold nsound in |- *. (* Goal: forall (c : normal_form) (_ : in_ngamma work ds ni ai' a c), Derivable context (nf2form c) *) intros c in_ngamma. (* Goal: Derivable context (nf2form b) *) apply sound. (* Goal: In_NGamma.in_ngamma work ds ni2 ai a c *) apply in_ngamma_cons_ds_tail; assumption. Qed. Remark nsound_del_ai : forall (i : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai ai' : atomic_imps) (a : atoms) (context : flist), EQUIV_DEL nf_list i ai ai' -> nsound work ds ni ai a context -> nsound work ds ni ai' a context. (* Goal: forall (i : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai ai' : atomic_imps) (a : atoms) (context : flist) (_ : EQUIV_DEL nf_list i ai ai') (_ : nsound work ds ni ai a context), nsound work ds ni ai' a context *) intros i work ds ni ai ai' a context equiv_del sound. (* Goal: nsound (@cons normal_form c work) ds ni ai a context *) unfold nsound in |- *. (* Goal: forall (c : normal_form) (_ : in_ngamma work ds ni ai' a c), Derivable context (nf2form c) *) intros c in_ngamma. (* Goal: Derivable context (nf2form b) *) apply sound. (* Goal: In_NGamma.in_ngamma work ds ni2 ai a c *) apply in_ngamma_del_ai_tail with i ai'; assumption. Qed. (***********************************************************************) Lemma nsound_cons_work_cons_context : forall (c : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist), nsound work ds ni ai a context -> nsound (c :: work) ds ni ai a (nf2form c :: context). (* Goal: forall (c : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist) (_ : nsound work ds ni ai a context), nsound (@cons normal_form c work) ds ni ai a (@cons form (nf2form c) context) *) intros c work ds ni ai a context sound. (* Goal: nsound (@cons normal_form c work) ds ni ai a context *) unfold nsound in |- *. (* Goal: forall (c0 : normal_form) (_ : in_ngamma (@cons normal_form c work) ds ni ai a c0), Derivable (@cons form (nf2form c) context) (nf2form c0) *) intros c0 in_gamma. (* Goal: Derivable (@cons form (nf2form c) context) (nf2form c0) *) elim (in_ngamma_cons_work_rev c work ds ni ai a c0 in_gamma); clear in_gamma. (* Goal: forall _ : in_ngamma work ds ni ai a c0, Derivable (@cons form (nf2form c) context) (nf2form c0) *) (* Goal: forall _ : @eq normal_form c0 c, Derivable (@cons form (nf2form c) context) (nf2form c0) *) intros in_gamma. (* Goal: Derivable (@cons form (nf2form c) context) (nf2form c0) *) (* Goal: forall _ : @eq normal_form c0 c, Derivable (@cons form (nf2form c) context) (nf2form c0) *) apply derivable_weak. (* Goal: In_NGamma.in_ngamma work ds ni2 ai a c *) apply sound; assumption. intros eq; rewrite eq; clear eq. (* Goal: Derivable (@cons form (nf2form c) context) (nf2form c) *) apply Derivable_Intro with (Var 0). (* Goal: derives (@cons form (nf2form c) context) (Var O) (nf2form c) *) apply ByAssumption. (* Goal: my_nth form O (@cons form (nf2form c) context) (nf2form c) *) apply My_NthO. Qed. (**********************************************************************) Lemma nsound_cons_work_weak : forall (b c : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist), (Derivable context (nf2form b) -> Derivable context (nf2form c)) -> nsound (b :: work) ds ni ai a context -> nsound (c :: work) ds ni ai a context. (* Goal: forall (b c : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist) (_ : forall _ : Derivable context (nf2form b), Derivable context (nf2form c)) (_ : nsound (@cons normal_form b work) ds ni ai a context), nsound (@cons normal_form c work) ds ni ai a context *) intros b c work ds ni ai a context der_ab sound. (* Goal: nsound (@cons normal_form c work) ds ni ai a context *) unfold nsound in |- *. (* Goal: forall (c0 : normal_form) (_ : in_ngamma (@cons normal_form c work) ds ni ai a c0), Derivable context (nf2form c0) *) intros c0 in_ngamma. elim (in_ngamma_cons_work_rev c work ds ni ai a c0 in_ngamma); clear in_ngamma. (* Goal: forall _ : in_ngamma work ds ni ai a c0, Derivable context (nf2form c0) *) (* Goal: forall _ : @eq normal_form c0 c, Derivable context (nf2form c0) *) intros in_ngamma. (* Goal: Derivable context (nf2form b) *) apply sound. (* Goal: In_NGamma.in_ngamma work ds ni2 ai a c *) apply in_ngamma_cons_work_tail; assumption. intros eq; rewrite eq; clear eq c0. (* Goal: Derivable context (nf2form c) *) apply der_ab. (* Goal: Derivable context (nf2form b) *) apply sound. (* Goal: in_ngamma (@cons normal_form b work) ds ni ai a b *) apply in_ngamma_cons_work_head. Qed. Lemma nsound_shift_work_ai_strength : forall (i : Int) (bs work : nf_list) (ds : disjs) (ni : nested_imps) (ai ai' : atomic_imps) (a a' : atoms) (context : flist), EQUIV_INS unit i (fun _ : unit => tt) tt a a' -> LOOKUP nf_list i ai bs -> EQUIV_DEL nf_list i ai ai' -> nsound work ds ni ai a' context -> nsound (bs ++ work) ds ni ai' a' context. (* Goal: forall (i : Int) (bs work : nf_list) (ds : disjs) (ni : nested_imps) (ai ai' : atomic_imps) (a a' : atoms) (context : flist) (_ : EQUIV_INS unit i (fun _ : unit => tt) tt a a') (_ : LOOKUP nf_list i ai bs) (_ : EQUIV_DEL nf_list i ai ai') (_ : nsound work ds ni ai a' context), nsound (@app normal_form bs work) ds ni ai' a' context *) intros i bs work ds ni ai ai' a a' context equiv_ins lookup equiv_del sound. (* Goal: In_NGamma.in_ngamma work ds ni2 ai a c *) apply nsound_app_work; try assumption. (* Goal: forall (n : nat) (b : normal_form) (_ : my_nth normal_form n bs b), Derivable context (nf2form b) *) (* Goal: nsound work ds ni ai' a' context *) intros n b nth. (* Goal: Derivable context (nf2form b) *) (* Goal: nsound work ds ni ai' a' context *) apply derivable_a_a_imp_b__derivable_b with (Atom i). (* Goal: Derivable context (Atom i) *) (* Goal: Derivable context (Imp (Atom i) (nf2form b)) *) (* Goal: nsound work ds ni ai' a' context *) apply sound with (c := NAtom i). (* Goal: In_NGamma.in_ngamma work ds ni2 ai a c *) apply in_ngamma_ins_a_head with a; assumption. (* Goal: Derivable context (Imp (Atom i) (nf2form b)) *) (* Goal: nsound work ds ni ai' a' context *) apply sound with (c := AImp i b). (* Goal: In_NGamma.in_ngamma work ds ni2 ai a c *) apply In_Atomic_Imps with (i := i) (b := b) (n := n) (bs := bs); assumption. (* Goal: In_NGamma.in_ngamma work ds ni2 ai a c *) apply nsound_del_ai with i ai; assumption. Qed.
(* File: Kripke_Trees.v (last edited on 25/10/2000) (c) Klaus Weich *) Require Export AvlTrees. Require Export Trees. Require Export Derivations. (******* Kripke_Model ****************************************) Inductive Kripke_Model (A : Set) (World : A -> Type) (le : A -> A -> Type) (forces0 : A -> Int -> Prop) : Type := kripke_model : (forall k : A, World k -> le k k) -> (forall k0 k1 k2 : A, World k0 -> World k1 -> World k2 -> le k0 k1 -> le k1 k2 -> le k0 k2) -> (forall k0 k1 : A, World k0 -> World k1 -> le k0 k1 -> forall i : Int, forces0 k0 i -> forces0 k1 i) -> Kripke_Model A World le forces0. Fixpoint forces (A : Set) (World : A -> Type) (le : A -> A -> Type) (forces0 : A -> Int -> Prop) (k : A) (a : form) {struct a} : Prop := match a with | Falsum => False | Atom i => forces0 k i | AndF a0 a1 => forces A World le forces0 k a0 /\ forces A World le forces0 k a1 | OrF a0 a1 => forces A World le forces0 k a0 \/ forces A World le forces0 k a1 | Imp a0 a1 => forall k' : A, World k' -> le k k' -> forces A World le forces0 k' a0 -> forces A World le forces0 k' a1 end. Lemma forces_mon : forall (A : Set) (World : A -> Type) (le : A -> A -> Type) (forces0 : A -> Int -> Prop), Kripke_Model A World le forces0 -> forall (k : A) (a : form), World k -> forces A World le forces0 k a -> forall k' : A, World k' -> le k k' -> forces A World le forces0 k' a. (* Goal: forall (A : Set) (World : forall _ : A, Type) (le : forall (_ : A) (_ : A), Type) (forces0 : forall (_ : A) (_ : Int), Prop) (_ : Kripke_Model A World le forces0) (k : A) (a : form) (_ : World k) (_ : forces A World le forces0 k a) (k' : A) (_ : World k') (_ : le k k'), forces A World le forces0 k' a *) intros A World le forces0 kripke k a w; elim a; clear a. (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k (Imp a b) *) simpl in |- *. (* Goal: forall (i : Int) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces0_t (Atms k') i) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces0_t (Atms k') i *) (* Goal: forall (f : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f) (f0 : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f0) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f0) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (AndF f f0)) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' (AndF f f0) *) (* Goal: forall (f : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f) (f0 : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f0) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f0) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (OrF f f0)) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' (OrF f f0) *) (* Goal: forall (f : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f) (f0 : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f0) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f0) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (Imp f f0)) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' (Imp f f0) *) trivial. (* Goal: forall (_ : Suc k'' K) (_ : Suc k'' k') (_ : forces_t2 K k'' a), forces_t2 K k'' b *) intros. (* Goal: forces A World le forces0 k'' a1 *) elim kripke. (* Goal: forall (_ : forall (k : A) (_ : World k), le k k) (_ : forall (k0 k1 k2 : A) (_ : World k0) (_ : World k1) (_ : World k2) (_ : le k0 k1) (_ : le k1 k2), le k0 k2) (_ : forall (k0 k1 : A) (_ : World k0) (_ : World k1) (_ : le k0 k1) (i : Int) (_ : forces0 k0 i), forces0 k1 i), forces A World le forces0 k'' a1 *) intros refl trans mon. (* Goal: forces A World le forces0 k' (Atom i) *) (* Goal: forall (f : form) (_ : forall (_ : forces A World le forces0 k f) (k' : A) (_ : World k') (_ : le k k'), forces A World le forces0 k' f) (f0 : form) (_ : forall (_ : forces A World le forces0 k f0) (k' : A) (_ : World k') (_ : le k k'), forces A World le forces0 k' f0) (_ : forces A World le forces0 k (AndF f f0)) (k' : A) (_ : World k') (_ : le k k'), forces A World le forces0 k' (AndF f f0) *) (* Goal: forall (f : form) (_ : forall (_ : forces A World le forces0 k f) (k' : A) (_ : World k') (_ : le k k'), forces A World le forces0 k' f) (f0 : form) (_ : forall (_ : forces A World le forces0 k f0) (k' : A) (_ : World k') (_ : le k k'), forces A World le forces0 k' f0) (_ : forces A World le forces0 k (OrF f f0)) (k' : A) (_ : World k') (_ : le k k'), forces A World le forces0 k' (OrF f f0) *) (* Goal: forall (f : form) (_ : forall (_ : forces A World le forces0 k f) (k' : A) (_ : World k') (_ : le k k'), forces A World le forces0 k' f) (f0 : form) (_ : forall (_ : forces A World le forces0 k f0) (k' : A) (_ : World k') (_ : le k k'), forces A World le forces0 k' f0) (_ : forces A World le forces0 k (Imp f f0)) (k' : A) (_ : World k') (_ : le k k'), forces A World le forces0 k' (Imp f f0) *) simpl in |- *; apply (mon k k'); assumption. (* Goal: forall (f : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f) (f0 : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f0) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f0) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (Imp f f0)) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' (Imp f f0) *) intros a ih_a b ih_b. (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k (Imp a b) *) simpl in |- *. (* Goal: forall (_ : and (forces A World le forces0 k a) (forces A World le forces0 k b)) (k' : A) (_ : World k') (_ : le k k'), and (forces A World le forces0 k' a) (forces A World le forces0 k' b) *) (* Goal: forall (f : form) (_ : forall (_ : forces A World le forces0 k f) (k' : A) (_ : World k') (_ : le k k'), forces A World le forces0 k' f) (f0 : form) (_ : forall (_ : forces A World le forces0 k f0) (k' : A) (_ : World k') (_ : le k k'), forces A World le forces0 k' f0) (_ : forces A World le forces0 k (OrF f f0)) (k' : A) (_ : World k') (_ : le k k'), forces A World le forces0 k' (OrF f f0) *) (* Goal: forall (f : form) (_ : forall (_ : forces A World le forces0 k f) (k' : A) (_ : World k') (_ : le k k'), forces A World le forces0 k' f) (f0 : form) (_ : forall (_ : forces A World le forces0 k f0) (k' : A) (_ : World k') (_ : le k k'), forces A World le forces0 k' f0) (_ : forces A World le forces0 k (Imp f f0)) (k' : A) (_ : World k') (_ : le k k'), forces A World le forces0 k' (Imp f f0) *) intros u0; elim u0; clear u0; intros u0 u1. (* Goal: forall (k' : A) (_ : World k') (_ : le k k'), and (forces A World le forces0 k' a) (forces A World le forces0 k' b) *) (* Goal: forall (f : form) (_ : forall (_ : forces A World le forces0 k f) (k' : A) (_ : World k') (_ : le k k'), forces A World le forces0 k' f) (f0 : form) (_ : forall (_ : forces A World le forces0 k f0) (k' : A) (_ : World k') (_ : le k k'), forces A World le forces0 k' f0) (_ : forces A World le forces0 k (OrF f f0)) (k' : A) (_ : World k') (_ : le k k'), forces A World le forces0 k' (OrF f f0) *) (* Goal: forall (f : form) (_ : forall (_ : forces A World le forces0 k f) (k' : A) (_ : World k') (_ : le k k'), forces A World le forces0 k' f) (f0 : form) (_ : forall (_ : forces A World le forces0 k f0) (k' : A) (_ : World k') (_ : le k k'), forces A World le forces0 k' f0) (_ : forces A World le forces0 k (Imp f f0)) (k' : A) (_ : World k') (_ : le k k'), forces A World le forces0 k' (Imp f f0) *) intros; split. (* Goal: forces A World le forces0 k' a *) (* Goal: forall (k' : A) (_ : World k') (_ : le k k'), or (forces A World le forces0 k' a) (forces A World le forces0 k' b) *) (* Goal: forall (f : form) (_ : forall (_ : forces A World le forces0 k f) (k' : A) (_ : World k') (_ : le k k'), forces A World le forces0 k' f) (f0 : form) (_ : forall (_ : forces A World le forces0 k f0) (k' : A) (_ : World k') (_ : le k k'), forces A World le forces0 k' f0) (_ : forces A World le forces0 k (Imp f f0)) (k' : A) (_ : World k') (_ : le k k'), forces A World le forces0 k' (Imp f f0) *) apply ih_a; assumption. (* Goal: forces A World le forces0 k' b *) (* Goal: forall (f : form) (_ : forall (_ : forces A World le forces0 k f) (k' : A) (_ : World k') (_ : le k k'), forces A World le forces0 k' f) (f0 : form) (_ : forall (_ : forces A World le forces0 k f0) (k' : A) (_ : World k') (_ : le k k'), forces A World le forces0 k' f0) (_ : forces A World le forces0 k (Imp f f0)) (k' : A) (_ : World k') (_ : le k k'), forces A World le forces0 k' (Imp f f0) *) apply ih_b; assumption. (* Goal: forall (f : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f) (f0 : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f0) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f0) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (Imp f f0)) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' (Imp f f0) *) intros a ih_a b ih_b. (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k (Imp a b) *) simpl in |- *. (* Goal: forall (_ : or (forces A World le forces0 k a) (forces A World le forces0 k b)) (k' : A) (_ : World k') (_ : le k k'), or (forces A World le forces0 k' a) (forces A World le forces0 k' b) *) (* Goal: forall (f : form) (_ : forall (_ : forces A World le forces0 k f) (k' : A) (_ : World k') (_ : le k k'), forces A World le forces0 k' f) (f0 : form) (_ : forall (_ : forces A World le forces0 k f0) (k' : A) (_ : World k') (_ : le k k'), forces A World le forces0 k' f0) (_ : forces A World le forces0 k (Imp f f0)) (k' : A) (_ : World k') (_ : le k k'), forces A World le forces0 k' (Imp f f0) *) intros u0; elim u0; clear u0; intros u0. (* Goal: forall (k' : A) (_ : World k') (_ : le k k'), or (forces A World le forces0 k' a) (forces A World le forces0 k' b) *) (* Goal: forall (k' : A) (_ : World k') (_ : le k k'), or (forces A World le forces0 k' a) (forces A World le forces0 k' b) *) (* Goal: forall (f : form) (_ : forall (_ : forces A World le forces0 k f) (k' : A) (_ : World k') (_ : le k k'), forces A World le forces0 k' f) (f0 : form) (_ : forall (_ : forces A World le forces0 k f0) (k' : A) (_ : World k') (_ : le k k'), forces A World le forces0 k' f0) (_ : forces A World le forces0 k (Imp f f0)) (k' : A) (_ : World k') (_ : le k k'), forces A World le forces0 k' (Imp f f0) *) intros; left. (* Goal: forces A World le forces0 k' a *) (* Goal: forall (k' : A) (_ : World k') (_ : le k k'), or (forces A World le forces0 k' a) (forces A World le forces0 k' b) *) (* Goal: forall (f : form) (_ : forall (_ : forces A World le forces0 k f) (k' : A) (_ : World k') (_ : le k k'), forces A World le forces0 k' f) (f0 : form) (_ : forall (_ : forces A World le forces0 k f0) (k' : A) (_ : World k') (_ : le k k'), forces A World le forces0 k' f0) (_ : forces A World le forces0 k (Imp f f0)) (k' : A) (_ : World k') (_ : le k k'), forces A World le forces0 k' (Imp f f0) *) apply ih_a; assumption. (* Goal: forall (k' : A) (_ : World k') (_ : le k k'), or (forces A World le forces0 k' a) (forces A World le forces0 k' b) *) (* Goal: forall (f : form) (_ : forall (_ : forces A World le forces0 k f) (k' : A) (_ : World k') (_ : le k k'), forces A World le forces0 k' f) (f0 : form) (_ : forall (_ : forces A World le forces0 k f0) (k' : A) (_ : World k') (_ : le k k'), forces A World le forces0 k' f0) (_ : forces A World le forces0 k (Imp f f0)) (k' : A) (_ : World k') (_ : le k k'), forces A World le forces0 k' (Imp f f0) *) intros; right. (* Goal: forces A World le forces0 k' b *) (* Goal: forall (f : form) (_ : forall (_ : forces A World le forces0 k f) (k' : A) (_ : World k') (_ : le k k'), forces A World le forces0 k' f) (f0 : form) (_ : forall (_ : forces A World le forces0 k f0) (k' : A) (_ : World k') (_ : le k k'), forces A World le forces0 k' f0) (_ : forces A World le forces0 k (Imp f f0)) (k' : A) (_ : World k') (_ : le k k'), forces A World le forces0 k' (Imp f f0) *) apply ih_b; assumption. (* Goal: forall (f : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f) (f0 : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f0) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f0) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (Imp f f0)) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' (Imp f f0) *) intros a ih_a b ih_b. (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k (Imp a b) *) simpl in |- *. (* Goal: forall (_ : Suc k'' K) (_ : Suc k'' k') (_ : forces_t2 K k'' a), forces_t2 K k'' b *) intros. (* Goal: forces A World le forces0 k'0 b *) apply H. (* Goal: Suc k'' k *) assumption. (* Goal: forces A World le forces0 k'' a1 *) elim kripke. (* Goal: forall (_ : forall (k : A) (_ : World k), le k k) (_ : forall (k0 k1 k2 : A) (_ : World k0) (_ : World k1) (_ : World k2) (_ : le k0 k1) (_ : le k1 k2), le k0 k2) (_ : forall (k0 k1 : A) (_ : World k0) (_ : World k1) (_ : le k0 k1) (i : Int) (_ : forces0 k0 i), forces0 k1 i), forces A World le forces0 k'' a1 *) intros refl trans mon. (* Goal: Suc k'' k *) apply (trans k k' k'0); assumption. (* Goal: Suc k'' k *) assumption. Qed. Lemma soundness : forall (t : proof_term) (context : flist) (a : form), derives context t a -> forall (A : Set) (World : A -> Type) (le : A -> A -> Type) (forces0 : A -> Int -> Prop), Kripke_Model A World le forces0 -> forall k : A, World k -> (forall c : form, In c context -> forces A World le forces0 k c) -> forces A World le forces0 k a. (* Goal: forall (t : proof_term) (context : flist) (a : form) (_ : derives context t a) (A : Set) (World : forall _ : A, Type) (le : forall (_ : A) (_ : A), Type) (forces0 : forall (_ : A) (_ : Int), Prop) (_ : Kripke_Model A World le forces0) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k a *) intros t context a der_t A World le forces0 kripke_model0. (* Goal: forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k a *) elim der_t; clear der_t t a context. (* t=(Var n) *) (* Goal: forall (context : flist) (n : nat) (a : form) (_ : my_nth form n context a) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k a *) (* Goal: forall (context : flist) (t : proof_term) (a : form) (_ : derives context t Falsum) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k Falsum) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k a *) (* Goal: forall (context : flist) (a : form) (r : proof_term) (b : form) (_ : derives (@cons form a context) r b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c (@cons form a context)), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (Imp a b) *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (Imp a b)) (_ : derives context s a) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k a) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k a) (_ : derives context s b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (AndF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (AndF a b)) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k a *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (AndF a b)) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k a) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (OrF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (OrF a b) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 context), forces A World le forces0 k c0), forces A World le forces0 k (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 (@cons form a context)), forces A World le forces0 k c0), forces A World le forces0 k c) (_ : derives (@cons form b context) t c) (_ : forall (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 (@cons form b context)), forces A World le forces0 k c0), forces A World le forces0 k c) (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 context), forces A World le forces0 k c0), forces A World le forces0 k c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c (@cons form a context)), forces A World le forces0 k c), forces A World le forces0 k b *) intros context n a nth k world forces_context. (* Goal: forces A World le forces0 k c *) apply forces_context. (* Goal: Suc k'' k *) apply nth_in with n; assumption. (* t=(Efq r b) *) (* Goal: forall (context : flist) (t : proof_term) (a : form) (_ : derives context t Falsum) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k Falsum) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k a *) (* Goal: forall (context : flist) (a : form) (r : proof_term) (b : form) (_ : derives (@cons form a context) r b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c (@cons form a context)), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (Imp a b) *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (Imp a b)) (_ : derives context s a) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k a) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k a) (_ : derives context s b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (AndF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (AndF a b)) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k a *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (AndF a b)) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k a) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (OrF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (OrF a b) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 context), forces A World le forces0 k c0), forces A World le forces0 k (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 (@cons form a context)), forces A World le forces0 k c0), forces A World le forces0 k c) (_ : derives (@cons form b context) t c) (_ : forall (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 (@cons form b context)), forces A World le forces0 k c0), forces A World le forces0 k c) (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 context), forces A World le forces0 k c0), forces A World le forces0 k c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c (@cons form a context)), forces A World le forces0 k c), forces A World le forces0 k b *) intros context r a der_t ih k world forces_context. (* Goal: (fix forces (A : Set) (World : forall _ : A, Type) (le : forall (_ : A) (_ : A), Type) (forces0 : forall (_ : A) (_ : Int), Prop) (k : A) (a : form) {struct a} : Prop := match a with | Falsum => False | Atom i => forces0 k i | AndF a0 a1 => and (forces A World le forces0 k a0) (forces A World le forces0 k a1) | OrF a0 a1 => or (forces A World le forces0 k a0) (forces A World le forces0 k a1) | Imp a0 a1 => forall (k' : A) (_ : World k') (_ : le k k') (_ : forces A World le forces0 k' a0), forces A World le forces0 k' a1 end) kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k''' b *) elimtype False. (* Goal: forces A World le forces0 k a *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (OrF a b) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 context), forces A World le forces0 k c0), forces A World le forces0 k (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 (@cons form a context)), forces A World le forces0 k c0), forces A World le forces0 k c) (_ : derives (@cons form b context) t c) (_ : forall (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 (@cons form b context)), forces A World le forces0 k c0), forces A World le forces0 k c) (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 context), forces A World le forces0 k c0), forces A World le forces0 k c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c (@cons form a context)), forces A World le forces0 k c), forces A World le forces0 k b *) apply (ih k world forces_context). (* t=(Abs a0 r) *) (* Goal: forall (context : flist) (a : form) (r : proof_term) (b : form) (_ : derives (@cons form a context) r b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c (@cons form a context)), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (Imp a b) *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (Imp a b)) (_ : derives context s a) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k a) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k a) (_ : derives context s b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (AndF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (AndF a b)) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k a *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (AndF a b)) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k a) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (OrF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (OrF a b) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 context), forces A World le forces0 k c0), forces A World le forces0 k (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 (@cons form a context)), forces A World le forces0 k c0), forces A World le forces0 k c) (_ : derives (@cons form b context) t c) (_ : forall (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 (@cons form b context)), forces A World le forces0 k c0), forces A World le forces0 k c) (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 context), forces A World le forces0 k c0), forces A World le forces0 k c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c (@cons form a context)), forces A World le forces0 k c), forces A World le forces0 k b *) intros context a r b der_t ih k world forces_context. (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k (Imp a b) *) simpl in |- *. (* Goal: forall (k' : A) (_ : World k') (_ : le k k') (_ : forces A World le forces0 k' a), forces A World le forces0 k' b *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (Imp a b)) (_ : derives context s a) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k a) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k a) (_ : derives context s b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (AndF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (AndF a b)) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k a *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (AndF a b)) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k a) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (OrF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (OrF a b) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 context), forces A World le forces0 k c0), forces A World le forces0 k (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 (@cons form a context)), forces A World le forces0 k c0), forces A World le forces0 k c) (_ : derives (@cons form b context) t c) (_ : forall (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 (@cons form b context)), forces A World le forces0 k c0), forces A World le forces0 k c) (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 context), forces A World le forces0 k c0), forces A World le forces0 k c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c (@cons form a context)), forces A World le forces0 k c), forces A World le forces0 k b *) intros k' world_k' le_k' forces_a0. (* Goal: forces A World le forces0 k' b *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (Imp a b)) (_ : derives context s a) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k a) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k a) (_ : derives context s b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (AndF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (AndF a b)) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k a *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (AndF a b)) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k a) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (OrF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (OrF a b) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 context), forces A World le forces0 k c0), forces A World le forces0 k (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 (@cons form a context)), forces A World le forces0 k c0), forces A World le forces0 k c) (_ : derives (@cons form b context) t c) (_ : forall (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 (@cons form b context)), forces A World le forces0 k c0), forces A World le forces0 k c) (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 context), forces A World le forces0 k c0), forces A World le forces0 k c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c (@cons form a context)), forces A World le forces0 k c), forces A World le forces0 k b *) apply (ih k' world_k'). (* Goal: forall (c : form) (_ : @In form c context), forces A World le forces0 k c *) intros c in_c. (* Goal: forces A World le forces0 k' c *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (Imp a b)) (_ : derives context s a) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k a) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k a) (_ : derives context s b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (AndF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (AndF a b)) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k a *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (AndF a b)) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k a) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (OrF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (OrF a b) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 context), forces A World le forces0 k c0), forces A World le forces0 k (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 (@cons form a context)), forces A World le forces0 k c0), forces A World le forces0 k c) (_ : derives (@cons form b context) t c) (_ : forall (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 (@cons form b context)), forces A World le forces0 k c0), forces A World le forces0 k c) (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 context), forces A World le forces0 k c0), forces A World le forces0 k c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c (@cons form a context)), forces A World le forces0 k c), forces A World le forces0 k b *) inversion_clear in_c. (* Goal: forces A World le forces0 k' c *) (* Goal: forces A World le forces0 k' c *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (Imp a b)) (_ : derives context s a) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k a) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k a) (_ : derives context s b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (AndF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (AndF a b)) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k a *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (AndF a b)) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k a) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (OrF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (OrF a b) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 context), forces A World le forces0 k c0), forces A World le forces0 k (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 (@cons form a context)), forces A World le forces0 k c0), forces A World le forces0 k c) (_ : derives (@cons form b context) t c) (_ : forall (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 (@cons form b context)), forces A World le forces0 k c0), forces A World le forces0 k c) (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 context), forces A World le forces0 k c0), forces A World le forces0 k c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c (@cons form a context)), forces A World le forces0 k c), forces A World le forces0 k b *) rewrite <- H. (* Goal: Suc k'' k *) assumption. (* Goal: Suc k'' k *) apply forces_mon with k; try assumption. (* Goal: Suc k'' k *) apply forces_context; assumption. (* t=(App r s) *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k a) (_ : derives context s b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (AndF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (AndF a b)) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k a *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (AndF a b)) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k a) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (OrF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (OrF a b) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 context), forces A World le forces0 k c0), forces A World le forces0 k (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 (@cons form a context)), forces A World le forces0 k c0), forces A World le forces0 k c) (_ : derives (@cons form b context) t c) (_ : forall (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 (@cons form b context)), forces A World le forces0 k c0), forces A World le forces0 k c) (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 context), forces A World le forces0 k c0), forces A World le forces0 k c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c (@cons form a context)), forces A World le forces0 k c), forces A World le forces0 k b *) intros context r s a b der_r ih_r der_s ih_s k world forces_context. (* Goal: forces A World le forces0 k b *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k a) (_ : derives context s b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (AndF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (AndF a b)) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k a *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (AndF a b)) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k a) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (OrF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (OrF a b) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 context), forces A World le forces0 k c0), forces A World le forces0 k (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 (@cons form a context)), forces A World le forces0 k c0), forces A World le forces0 k c) (_ : derives (@cons form b context) t c) (_ : forall (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 (@cons form b context)), forces A World le forces0 k c0), forces A World le forces0 k c) (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 context), forces A World le forces0 k c0), forces A World le forces0 k c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c (@cons form a context)), forces A World le forces0 k c), forces A World le forces0 k b *) apply (ih_r k world forces_context k). (* Goal: Suc k'' k *) assumption. (* Goal: le k k *) (* Goal: (fix forces (A : Set) (World : forall _ : A, Type) (le : forall (_ : A) (_ : A), Type) (forces0 : forall (_ : A) (_ : Int), Prop) (k : A) (a : form) {struct a} : Prop := match a with | Falsum => False | Atom i => forces0 k i | AndF a0 a1 => and (forces A World le forces0 k a0) (forces A World le forces0 k a1) | OrF a0 a1 => or (forces A World le forces0 k a0) (forces A World le forces0 k a1) | Imp a0 a1 => forall (k' : A) (_ : World k') (_ : le k k') (_ : forces A World le forces0 k' a0), forces A World le forces0 k' a1 end) A World le forces0 k a *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k a) (_ : derives context s b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (AndF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (AndF a b)) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k a *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (AndF a b)) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k a) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (OrF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (OrF a b) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 context), forces A World le forces0 k c0), forces A World le forces0 k (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 (@cons form a context)), forces A World le forces0 k c0), forces A World le forces0 k c) (_ : derives (@cons form b context) t c) (_ : forall (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 (@cons form b context)), forces A World le forces0 k c0), forces A World le forces0 k c) (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 context), forces A World le forces0 k c0), forces A World le forces0 k c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c (@cons form a context)), forces A World le forces0 k c), forces A World le forces0 k b *) elim kripke_model0; auto. (* Goal: forces A World le forces0 k b *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (AndF a b)) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k a *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (AndF a b)) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k a) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (OrF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (OrF a b) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 context), forces A World le forces0 k c0), forces A World le forces0 k (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 (@cons form a context)), forces A World le forces0 k c0), forces A World le forces0 k c) (_ : derives (@cons form b context) t c) (_ : forall (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 (@cons form b context)), forces A World le forces0 k c0), forces A World le forces0 k c) (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 context), forces A World le forces0 k c0), forces A World le forces0 k c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c (@cons form a context)), forces A World le forces0 k c), forces A World le forces0 k b *) apply (ih_s k world forces_context). (* t=(Pair r s) *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k a) (_ : derives context s b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (AndF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (AndF a b)) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k a *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (AndF a b)) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k a) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (OrF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (OrF a b) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 context), forces A World le forces0 k c0), forces A World le forces0 k (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 (@cons form a context)), forces A World le forces0 k c0), forces A World le forces0 k c) (_ : derives (@cons form b context) t c) (_ : forall (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 (@cons form b context)), forces A World le forces0 k c0), forces A World le forces0 k c) (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 context), forces A World le forces0 k c0), forces A World le forces0 k c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c (@cons form a context)), forces A World le forces0 k c), forces A World le forces0 k b *) intros context r s a b der_r ih_r der_s ih_s k world forces_context. (* Goal: and (forces_t2 k k' b0) (forces_t2 k k' b1) *) split. (* Goal: forces A World le forces0 k a *) (* Goal: forces A World le forces0 k b *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (AndF a b)) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k a *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (AndF a b)) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k a) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (OrF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (OrF a b) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 context), forces A World le forces0 k c0), forces A World le forces0 k (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 (@cons form a context)), forces A World le forces0 k c0), forces A World le forces0 k c) (_ : derives (@cons form b context) t c) (_ : forall (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 (@cons form b context)), forces A World le forces0 k c0), forces A World le forces0 k c) (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 context), forces A World le forces0 k c0), forces A World le forces0 k c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c (@cons form a context)), forces A World le forces0 k c), forces A World le forces0 k b *) apply (ih_r k world forces_context). (* Goal: forces A World le forces0 k b *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (AndF a b)) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k a *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (AndF a b)) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k a) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (OrF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (OrF a b) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 context), forces A World le forces0 k c0), forces A World le forces0 k (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 (@cons form a context)), forces A World le forces0 k c0), forces A World le forces0 k c) (_ : derives (@cons form b context) t c) (_ : forall (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 (@cons form b context)), forces A World le forces0 k c0), forces A World le forces0 k c) (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 context), forces A World le forces0 k c0), forces A World le forces0 k c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c (@cons form a context)), forces A World le forces0 k c), forces A World le forces0 k b *) apply (ih_s k world forces_context). (* t=(PrL r) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c (@cons form a context)), forces A World le forces0 k c), forces A World le forces0 k b *) intros context r a b der_r ih k world forces_context. (* Goal: forces A World le forces0 k b *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k a) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (OrF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (OrF a b) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 context), forces A World le forces0 k c0), forces A World le forces0 k (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 (@cons form a context)), forces A World le forces0 k c0), forces A World le forces0 k c) (_ : derives (@cons form b context) t c) (_ : forall (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 (@cons form b context)), forces A World le forces0 k c0), forces A World le forces0 k c) (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 context), forces A World le forces0 k c0), forces A World le forces0 k c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c (@cons form a context)), forces A World le forces0 k c), forces A World le forces0 k b *) generalize (ih k world forces_context). (* Goal: Suc k'' k *) intros u0; elim u0; intros; assumption. (* t=(PrR r) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c (@cons form a context)), forces A World le forces0 k c), forces A World le forces0 k b *) intros context r a b der_r ih k world forces_context. (* Goal: forces A World le forces0 k b *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k a) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (OrF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (OrF a b) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 context), forces A World le forces0 k c0), forces A World le forces0 k (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 (@cons form a context)), forces A World le forces0 k c0), forces A World le forces0 k c) (_ : derives (@cons form b context) t c) (_ : forall (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 (@cons form b context)), forces A World le forces0 k c0), forces A World le forces0 k c) (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 context), forces A World le forces0 k c0), forces A World le forces0 k c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c (@cons form a context)), forces A World le forces0 k c), forces A World le forces0 k b *) generalize (ih k world forces_context). (* Goal: Suc k'' k *) intros u0; elim u0; intros; assumption. (* t=(OrFL r b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c (@cons form a context)), forces A World le forces0 k c), forces A World le forces0 k b *) intros context r a b der_r ih k world forces_context. (* Goal: forces_t2 K k' (OrF a b) *) (* Goal: forall _ : forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' b, forces_t2 K k' (OrF a b) *) (* Goal: forall (f : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f) (f0 : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f0) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f0) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (Imp f f0)) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' (Imp f f0) *) left. (* Goal: forces A World le forces0 k a *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k (OrF a b) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 context), forces A World le forces0 k c0), forces A World le forces0 k (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 (@cons form a context)), forces A World le forces0 k c0), forces A World le forces0 k c) (_ : derives (@cons form b context) t c) (_ : forall (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 (@cons form b context)), forces A World le forces0 k c0), forces A World le forces0 k c) (k : A) (_ : World k) (_ : forall (c0 : form) (_ : @In form c0 context), forces A World le forces0 k c0), forces A World le forces0 k c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c (@cons form a context)), forces A World le forces0 k c), forces A World le forces0 k b *) apply (ih k world forces_context). (* t=(OrFR r b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c (@cons form a context)), forces A World le forces0 k c), forces A World le forces0 k b *) intros context r a b der_r ih k world forces_context. (* Goal: forces_t2 K k' (OrF a b) *) (* Goal: forall (f : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f) (f0 : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f0) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f0) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (Imp f f0)) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' (Imp f f0) *) right. (* Goal: Suc k'' k *) apply ih; assumption. (* t=(Cas r s t) *) intros context r s t a b c der_r ih_r der_s ih_s der_t ih_t k world forces_context. (* Goal: forces A World le forces0 k c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c (@cons form a context)), forces A World le forces0 k c), forces A World le forces0 k b *) generalize (ih_r k world forces_context); clear ih_r. (* Goal: forall _ : forces A World le forces0 k (OrF a b), forces A World le forces0 k c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c (@cons form a context)), forces A World le forces0 k c), forces A World le forces0 k b *) intro u0; elim u0; clear u0. (* Goal: forall _ : forces A World le forces0 k' a0, forces A World le forces0 k' b *) (* Goal: forall _ : forces A World le forces0 k' a1, forces A World le forces0 k' b *) intro forces_a0. (* Goal: forces A World le forces0 k c *) (* Goal: forall _ : forces A World le forces0 k b, forces A World le forces0 k c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c (@cons form a context)), forces A World le forces0 k c), forces A World le forces0 k b *) apply ih_s; clear ih_s ih_t. (* Goal: Suc k'' k *) assumption. (* Goal: forall (c : form) (_ : @In form c (@cons form a context)), forces A World le forces0 k c *) (* Goal: forall _ : forces A World le forces0 k b, forces A World le forces0 k c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c (@cons form a context)), forces A World le forces0 k c), forces A World le forces0 k b *) intros c0 in_c0. (* Goal: forces A World le forces0 k c0 *) (* Goal: forall _ : forces A World le forces0 k b, forces A World le forces0 k c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c (@cons form a context)), forces A World le forces0 k c), forces A World le forces0 k b *) inversion_clear in_c0. (* Goal: Suc k'' k *) rewrite <- H; assumption. (* Goal: Suc k'' k *) apply forces_context; assumption. (* Goal: forall _ : forces A World le forces0 k b, forces A World le forces0 k c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c (@cons form a context)), forces A World le forces0 k c), forces A World le forces0 k b *) intros forces_b. (* Goal: forces A World le forces0 k c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c (@cons form a context)), forces A World le forces0 k c), forces A World le forces0 k b *) apply ih_t; clear ih_s ih_t. (* Goal: Suc k'' k *) assumption. (* Goal: forces A World le forces0 k c0 *) (* Goal: forall _ : forces A World le forces0 k b, forces A World le forces0 k c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c (@cons form a context)), forces A World le forces0 k c), forces A World le forces0 k b *) intros c0 in_c0; inversion_clear in_c0. (* Goal: Suc k'' k *) rewrite <- H; assumption. (* Goal: Suc k'' k *) apply forces_context; assumption. (* t=(Shift r) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c context), forces A World le forces0 k c), forces A World le forces0 k b) (k : A) (_ : World k) (_ : forall (c : form) (_ : @In form c (@cons form a context)), forces A World le forces0 k c), forces A World le forces0 k b *) intros context r a b der_r ih k world forces_context. (* Goal: forces_t k (vimp l (Imp (Atom i) b)) *) apply ih. (* Goal: Suc k'' k *) assumption. (* Goal: forall (c : form) (_ : @In form c context), forces A World le forces0 k c *) intros c in_c. (* Goal: forces A World le forces0 k c *) apply forces_context. (* Goal: Suc k'' k *) right; assumption. Qed. Lemma forces_b__forces_a_imp_b : forall (A : Set) (World : A -> Type) (le : A -> A -> Type) (forces0 : A -> Int -> Prop), Kripke_Model A World le forces0 -> forall k : A, World k -> forall b : form, forces A World le forces0 k b -> forall a : form, forces A World le forces0 k (Imp a b). (* Goal: forall (A : Set) (World : forall _ : A, Type) (le : forall (_ : A) (_ : A), Type) (forces0 : forall (_ : A) (_ : Int), Prop) (_ : Kripke_Model A World le forces0) (k : A) (_ : World k) (b : form) (_ : forces A World le forces0 k b) (a : form), forces A World le forces0 k (Imp a b) *) intros A World le forces0 kripke k w b forces_b. (* Goal: forall a : form, forces A World le forces0 k (Imp a b) *) intros a. (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k (Imp a b) *) simpl in |- *. (* Goal: forall (k' : A) (_ : World k') (_ : le k k') (_ : forces A World le forces0 k' a), forces A World le forces0 k' b *) intros k' w' le_k_k' forces_a. (* Goal: Suc k'' k *) apply forces_mon with (k := k); assumption. Qed. Lemma forces_a0_imp_a1_imp_b__forces_a0_and_a1_imp_b : forall (A : Set) (World : A -> Type) (le : A -> A -> Type) (forces0 : A -> Int -> Prop), Kripke_Model A World le forces0 -> forall k : A, World k -> forall a0 a1 b : form, forces A World le forces0 k (Imp a0 (Imp a1 b)) -> forces A World le forces0 k (Imp (AndF a0 a1) b). (* Goal: forall (A : Set) (World : forall _ : A, Type) (le : forall (_ : A) (_ : A), Type) (forces0 : forall (_ : A) (_ : Int), Prop) (_ : Kripke_Model A World le forces0) (k : A) (_ : World k) (a0 a1 b : form) (_ : forces A World le forces0 k (Imp a0 (Imp a1 b))), forces A World le forces0 k (Imp (AndF a0 a1) b) *) intros A World le forces0 kripke k world a0 a1 b forces_a0_a1_b. (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k (Imp a b) *) simpl in |- *. (* Goal: forall (k' : A) (_ : World k') (_ : le k k') (_ : and (forces A World le forces0 k' a0) (forces A World le forces0 k' a1)), forces A World le forces0 k' b *) intros k' u0 u1 forces_a0_and_a1. (* Goal: forces A World le forces0 k' b *) elim forces_a0_and_a1; clear forces_a0_and_a1. (* Goal: forall (_ : forces A World le forces0 k' a0) (_ : forces A World le forces0 k' a1), forces A World le forces0 k' b *) intros forces_a0 forces_a1. (* Goal: forces A World le forces0 k' b *) apply (forces_a0_a1_b k' u0 u1). (* Goal: (fix forces (A : Set) (World : forall _ : A, Type) (le : forall (_ : A) (_ : A), Type) (forces0 : forall (_ : A) (_ : Int), Prop) (k : A) (a : form) {struct a} : Prop := match a with | Falsum => False | Atom i => forces0 k i | AndF a0 a1 => and (forces A World le forces0 k a0) (forces A World le forces0 k a1) | OrF a0 a1 => or (forces A World le forces0 k a0) (forces A World le forces0 k a1) | Imp a0 a1 => forall (k' : A) (_ : World k') (_ : le k k') (_ : forces A World le forces0 k' a0), forces A World le forces0 k' a1 end) A World le forces0 k' a0 *) (* Goal: World k' *) (* Goal: le k' k' *) (* Goal: (fix forces (A : Set) (World : forall _ : A, Type) (le : forall (_ : A) (_ : A), Type) (forces0 : forall (_ : A) (_ : Int), Prop) (k : A) (a : form) {struct a} : Prop := match a with | Falsum => False | Atom i => forces0 k i | AndF a0 a1 => and (forces A World le forces0 k a0) (forces A World le forces0 k a1) | OrF a0 a1 => or (forces A World le forces0 k a0) (forces A World le forces0 k a1) | Imp a0 a1 => forall (k' : A) (_ : World k') (_ : le k k') (_ : forces A World le forces0 k' a0), forces A World le forces0 k' a1 end) A World le forces0 k' a1 *) apply forces_a0. (* Goal: World k' *) (* Goal: (fix forces (A : Set) (World : forall _ : A, Type) (le : forall (_ : A) (_ : A), Type) (forces0 : forall (_ : A) (_ : Int), Prop) (k : A) (a : form) {struct a} : Prop := match a with | Falsum => False | Atom i => forces0 k i | AndF a0 a1 => and (forces A World le forces0 k a0) (forces A World le forces0 k a1) | OrF a0 a1 => or (forces A World le forces0 k a0) (forces A World le forces0 k a1) | Imp a0 a1 => forall (k' : A) (_ : World k') (_ : le k k') (_ : forces A World le forces0 k' a0), forces A World le forces0 k' a1 end) A World le forces0 k' a1 *) apply u0. (* Goal: forces A World le forces0 k'' a1 *) elim kripke. (* Goal: forall (_ : forall (k : A) (_ : World k), le k k) (_ : forall (k0 k1 k2 : A) (_ : World k0) (_ : World k1) (_ : World k2) (_ : le k0 k1) (_ : le k1 k2), le k0 k2) (_ : forall (k0 k1 : A) (_ : World k0) (_ : World k1) (_ : le k0 k1) (i : Int) (_ : forces0 k0 i), forces0 k1 i), forces A World le forces0 k'' a1 *) intros refl trans mon. (* Goal: le k' k' *) (* Goal: forces A World le forces0 k' a0 *) apply refl. (* Goal: World k' *) (* Goal: (fix forces (A : Set) (World : forall _ : A, Type) (le : forall (_ : A) (_ : A), Type) (forces0 : forall (_ : A) (_ : Int), Prop) (k : A) (a : form) {struct a} : Prop := match a with | Falsum => False | Atom i => forces0 k i | AndF a0 a1 => and (forces A World le forces0 k a0) (forces A World le forces0 k a1) | OrF a0 a1 => or (forces A World le forces0 k a0) (forces A World le forces0 k a1) | Imp a0 a1 => forall (k' : A) (_ : World k') (_ : le k k') (_ : forces A World le forces0 k' a0), forces A World le forces0 k' a1 end) A World le forces0 k' a1 *) apply u0. (* Goal: (fix forces (A : Set) (World : forall _ : A, Type) (le : forall (_ : A) (_ : A), Type) (forces0 : forall (_ : A) (_ : Int), Prop) (k : A) (a : form) {struct a} : Prop := match a with | Falsum => False | Atom i => forces0 k i | AndF a0 a1 => and (forces A World le forces0 k a0) (forces A World le forces0 k a1) | OrF a0 a1 => or (forces A World le forces0 k a0) (forces A World le forces0 k a1) | Imp a0 a1 => forall (k' : A) (_ : World k') (_ : le k k') (_ : forces A World le forces0 k' a0), forces A World le forces0 k' a1 end) A World le forces0 k' a1 *) apply forces_a1. Qed. Lemma forces_a0_imp_c_and_a1_imp_c_and_c_imp_b__forces_a0_or_a1_imp_b : forall (A : Set) (World : A -> Type) (le : A -> A -> Type) (forces0 : A -> Int -> Prop) (k : A) (a0 a1 c b : form), forces A World le forces0 k (Imp a0 c) -> forces A World le forces0 k (Imp a1 c) -> forces A World le forces0 k (Imp c b) -> forces A World le forces0 k (Imp (OrF a0 a1) b). (* Goal: forall (A : Set) (World : forall _ : A, Type) (le : forall (_ : A) (_ : A), Type) (forces0 : forall (_ : A) (_ : Int), Prop) (k : A) (a0 a1 c b : form) (_ : forces A World le forces0 k (Imp a0 c)) (_ : forces A World le forces0 k (Imp a1 c)) (_ : forces A World le forces0 k (Imp c b)), forces A World le forces0 k (Imp (OrF a0 a1) b) *) intros A World le forces0 k a0 a1 c b forces_a0_c forces_a1_c forces_c_b. (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k (Imp a b) *) simpl in |- *. (* Goal: forall (k' : A) (_ : World k') (_ : le k k') (_ : or (forces A World le forces0 k' a0) (forces A World le forces0 k' a1)), forces A World le forces0 k' b *) intros k' u0 u1 forces_a0_or_a1. (* Goal: forces A World le forces0 k' b *) elim forces_a0_or_a1; clear forces_a0_or_a1. (* Goal: forall _ : forces A World le forces0 k' a0, forces A World le forces0 k' b *) (* Goal: forall _ : forces A World le forces0 k' a1, forces A World le forces0 k' b *) intro forces_a0. (* Goal: forces A World le forces0 k' b *) apply (forces_c_b k' u0 u1). (* Goal: (fix forces (A : Set) (World : forall _ : A, Type) (le : forall (_ : A) (_ : A), Type) (forces0 : forall (_ : A) (_ : Int), Prop) (k : A) (a : form) {struct a} : Prop := match a with | Falsum => False | Atom i => forces0 k i | AndF a0 a1 => and (forces A World le forces0 k a0) (forces A World le forces0 k a1) | OrF a0 a1 => or (forces A World le forces0 k a0) (forces A World le forces0 k a1) | Imp a0 a1 => forall (k' : A) (_ : World k') (_ : le k k') (_ : forces A World le forces0 k' a0), forces A World le forces0 k' a1 end) A World le forces0 k' c *) (* Goal: forall _ : forces A World le forces0 k' a1, forces A World le forces0 k' b *) apply (forces_a0_c k' u0 u1 forces_a0). (* Goal: forall _ : forces A World le forces0 k' a1, forces A World le forces0 k' b *) intro forces_a1. (* Goal: forces A World le forces0 k' b *) apply (forces_c_b k' u0 u1). (* Goal: (fix forces (A : Set) (World : forall _ : A, Type) (le : forall (_ : A) (_ : A), Type) (forces0 : forall (_ : A) (_ : Int), Prop) (k : A) (a : form) {struct a} : Prop := match a with | Falsum => False | Atom i => forces0 k i | AndF a0 a1 => and (forces A World le forces0 k a0) (forces A World le forces0 k a1) | OrF a0 a1 => or (forces A World le forces0 k a0) (forces A World le forces0 k a1) | Imp a0 a1 => forall (k' : A) (_ : World k') (_ : le k k') (_ : forces A World le forces0 k' a0), forces A World le forces0 k' a1 end) A World le forces0 k' c *) apply (forces_a1_c k' u0 u1 forces_a1). Qed. Lemma forces_a0_imp_b_and_a1_imp_b__forces_a0_or_a1_imp_b : forall (A : Set) (World : A -> Type) (le : A -> A -> Type) (forces0 : A -> Int -> Prop) (k : A) (a0 a1 b : form), forces A World le forces0 k (Imp a0 b) -> forces A World le forces0 k (Imp a1 b) -> forces A World le forces0 k (Imp (OrF a0 a1) b). (* Goal: forall (A : Set) (World : forall _ : A, Type) (le : forall (_ : A) (_ : A), Type) (forces0 : forall (_ : A) (_ : Int), Prop) (k : A) (a0 a1 b : form) (_ : forces A World le forces0 k (Imp a0 b)) (_ : forces A World le forces0 k (Imp a1 b)), forces A World le forces0 k (Imp (OrF a0 a1) b) *) intros A World le forces0 k a0 a1 b forces_a0_b forces_a1_b. (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k (Imp a b) *) simpl in |- *. (* Goal: forall (k' : A) (_ : World k') (_ : le k k') (_ : or (forces A World le forces0 k' a0) (forces A World le forces0 k' a1)), forces A World le forces0 k' b *) intros k' u0 u1 forces_a0_or_a1. (* Goal: forces A World le forces0 k' b *) elim forces_a0_or_a1; clear forces_a0_or_a1. (* Goal: forall _ : forces A World le forces0 k' a0, forces A World le forces0 k' b *) (* Goal: forall _ : forces A World le forces0 k' a1, forces A World le forces0 k' b *) intro forces_a0. (* Goal: forces A World le forces0 k' b *) (* Goal: forall _ : forces A World le forces0 k' a1, forces A World le forces0 k' b *) apply (forces_a0_b k' u0 u1 forces_a0). (* Goal: forall _ : forces A World le forces0 k' a1, forces A World le forces0 k' b *) intro forces_a1. (* Goal: forces A World le forces0 k' b *) apply (forces_a1_b k' u0 u1 forces_a1). Qed. Lemma forces_a1_imp_b__forces_a0_imp_a1_imp_b : forall (A : Set) (World : A -> Type) (le : A -> A -> Type) (forces0 : A -> Int -> Prop), Kripke_Model A World le forces0 -> forall k : A, World k -> forall a0 : form, forces A World le forces0 k a0 -> forall a1 b : form, forces A World le forces0 k (Imp a1 b) -> forces A World le forces0 k (Imp (Imp a0 a1) b). (* Goal: forall (A : Set) (World : forall _ : A, Type) (le : forall (_ : A) (_ : A), Type) (forces0 : forall (_ : A) (_ : Int), Prop) (_ : Kripke_Model A World le forces0) (k : A) (_ : World k) (a0 : form) (_ : forces A World le forces0 k a0) (a1 b : form) (_ : forces A World le forces0 k (Imp a1 b)), forces A World le forces0 k (Imp (Imp a0 a1) b) *) intros A World le forces0 kripke k w a0 forces_a0 a1 b forces_a1_b. (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k (Imp a b) *) simpl in |- *. (* Goal: forall (k' : A) (_ : World k') (_ : le k k') (_ : and (forces A World le forces0 k' a0) (forces A World le forces0 k' a1)), forces A World le forces0 k' b *) intros k' w' le_k_k' forces_a0_a1. (* Goal: forces A World le forces0 k' b *) apply (forces_a1_b k'). (* Goal: Suc k'' k *) assumption. (* Goal: Suc k'' k *) assumption. (* Goal: (fix forces (A : Set) (World : forall _ : A, Type) (le : forall (_ : A) (_ : A), Type) (forces0 : forall (_ : A) (_ : Int), Prop) (k : A) (a : form) {struct a} : Prop := match a with | Falsum => False | Atom i => forces0 k i | AndF a0 a1 => and (forces A World le forces0 k a0) (forces A World le forces0 k a1) | OrF a0 a1 => or (forces A World le forces0 k a0) (forces A World le forces0 k a1) | Imp a0 a1 => forall (k' : A) (_ : World k') (_ : le k k') (_ : forces A World le forces0 k' a0), forces A World le forces0 k' a1 end) A World le forces0 k' a1 *) change (forces A World le forces0 k' a1) in |- *. (* Goal: forces A World le forces0 k' a1 *) apply (forces_a0_a1 k'). (* Goal: Suc k'' k *) assumption. (* Goal: forces A World le forces0 k'' a1 *) elim kripke. (* Goal: forall (_ : forall (k : A) (_ : World k), le k k) (_ : forall (k0 k1 k2 : A) (_ : World k0) (_ : World k1) (_ : World k2) (_ : le k0 k1) (_ : le k1 k2), le k0 k2) (_ : forall (k0 k1 : A) (_ : World k0) (_ : World k1) (_ : le k0 k1) (i : Int) (_ : forces0 k0 i), forces0 k1 i), forces A World le forces0 k'' a1 *) intros refl trans mon. (* Goal: le k' k' *) (* Goal: forces A World le forces0 k' a0 *) apply refl. (* Goal: Suc k'' k *) assumption. (* Goal: Suc k'' k *) apply forces_mon with (k := k); assumption. Qed. Lemma forces_a0_imp_a1_imp_b__forces_a1_imp_b : forall (A : Set) (World : A -> Type) (le : A -> A -> Type) (forces0 : A -> Int -> Prop), Kripke_Model A World le forces0 -> forall k : A, World k -> forall a0 : form, forces A World le forces0 k a0 -> forall a1 b : form, forces A World le forces0 k (Imp (Imp a0 a1) b) -> forces A World le forces0 k (Imp a1 b). (* Goal: forall (A : Set) (World : forall _ : A, Type) (le : forall (_ : A) (_ : A), Type) (forces0 : forall (_ : A) (_ : Int), Prop) (_ : Kripke_Model A World le forces0) (k : A) (_ : World k) (a0 : form) (_ : forces A World le forces0 k a0) (a1 b : form) (_ : forces A World le forces0 k (Imp (Imp a0 a1) b)), forces A World le forces0 k (Imp a1 b) *) intros A World le forces0 kripke k w a0 forces_a0 a1 b forces_a0a1_b. (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k (Imp a b) *) simpl in |- *. (* Goal: forall (k' : A) (_ : World k') (_ : le k k') (_ : forces A World le forces0 k' a1), forces A World le forces0 k' b *) intros k' w' le_k_k' forces_a1. (* Goal: forces A World le forces0 k' b *) apply (forces_a0a1_b k'). (* Goal: Suc k'' k *) assumption. (* Goal: Suc k'' k *) assumption. (* Goal: forall (k'0 : A) (_ : World k'0) (_ : le k' k'0) (_ : (fix forces (A : Set) (World : forall _ : A, Type) (le : forall (_ : A) (_ : A), Type) (forces0 : forall (_ : A) (_ : Int), Prop) (k : A) (a : form) {struct a} : Prop := match a with | Falsum => False | Atom i => forces0 k i | AndF a0 a1 => and (forces A World le forces0 k a0) (forces A World le forces0 k a1) | OrF a0 a1 => or (forces A World le forces0 k a0) (forces A World le forces0 k a1) | Imp a0 a1 => forall (k' : A) (_ : World k') (_ : le k k') (_ : forces A World le forces0 k' a0), forces A World le forces0 k' a1 end) A World le forces0 k'0 a0), (fix forces (A : Set) (World : forall _ : A, Type) (le : forall (_ : A) (_ : A), Type) (forces0 : forall (_ : A) (_ : Int), Prop) (k : A) (a : form) {struct a} : Prop := match a with | Falsum => False | Atom i => forces0 k i | AndF a0 a1 => and (forces A World le forces0 k a0) (forces A World le forces0 k a1) | OrF a0 a1 => or (forces A World le forces0 k a0) (forces A World le forces0 k a1) | Imp a0 a1 => forall (k' : A) (_ : World k') (_ : le k k') (_ : forces A World le forces0 k' a0), forces A World le forces0 k' a1 end) A World le forces0 k'0 a1 *) change (forces A World le forces0 k' (Imp a0 a1)) in |- *. (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k (Imp a b) *) simpl in |- *. (* Goal: forall (k'0 : A) (_ : World k'0) (_ : le k' k'0) (_ : forces A World le forces0 k'0 a0), forces A World le forces0 k'0 a1 *) intros k'' w'' le'' forces_a0''. (* Goal: forces A World le forces0 k'' a1 *) elim kripke. (* Goal: forall (_ : forall (k : A) (_ : World k), le k k) (_ : forall (k0 k1 k2 : A) (_ : World k0) (_ : World k1) (_ : World k2) (_ : le k0 k1) (_ : le k1 k2), le k0 k2) (_ : forall (k0 k1 : A) (_ : World k0) (_ : World k1) (_ : le k0 k1) (i : Int) (_ : forces0 k0 i), forces0 k1 i), forces A World le forces0 k'' a1 *) intros refl trans mon. (* Goal: Suc k'' k *) apply forces_mon with (k := k'); assumption. Qed. Lemma forces_a0_imp_b__forces_a0_and_a1_imp_b : forall (A : Set) (World : A -> Type) (le : A -> A -> Type) (forces0 : A -> Int -> Prop) (k : A) (a0 b : form), forces A World le forces0 k (Imp a0 b) -> forall a1 : form, forces A World le forces0 k (Imp (AndF a0 a1) b). (* Goal: forall (A : Set) (World : forall _ : A, Type) (le : forall (_ : A) (_ : A), Type) (forces0 : forall (_ : A) (_ : Int), Prop) (k : A) (a0 b : form) (_ : forces A World le forces0 k (Imp a0 b)) (a1 : form), forces A World le forces0 k (Imp (AndF a0 a1) b) *) intros A World le forces0 k a0 b forces_a0_b a1. (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k (Imp a b) *) simpl in |- *. (* Goal: forall (k' : A) (_ : World k') (_ : le k k') (_ : and (forces A World le forces0 k' a0) (forces A World le forces0 k' a1)), forces A World le forces0 k' b *) intros k' w' le_k_k' forces_a0_a1. (* Goal: forces A World le forces0 k' b *) apply (forces_a0_b k'). (* Goal: Suc k'' k *) assumption. (* Goal: Suc k'' k *) assumption. (* Goal: (fix forces (A : Set) (World : forall _ : A, Type) (le : forall (_ : A) (_ : A), Type) (forces0 : forall (_ : A) (_ : Int), Prop) (k : A) (a : form) {struct a} : Prop := match a with | Falsum => False | Atom i => forces0 k i | AndF a0 a1 => and (forces A World le forces0 k a0) (forces A World le forces0 k a1) | OrF a0 a1 => or (forces A World le forces0 k a0) (forces A World le forces0 k a1) | Imp a0 a1 => forall (k' : A) (_ : World k') (_ : le k k') (_ : forces A World le forces0 k' a0), forces A World le forces0 k' a1 end) A World le forces0 k' a0 *) change (forces A World le forces0 k' a0) in |- *. (* Goal: forall (i : Int) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces0_t (Atms k') i) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces0_t (Atms k') i *) (* Goal: forall (f : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f) (f0 : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f0) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f0) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (AndF f f0)) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' (AndF f f0) *) (* Goal: forall (f : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f) (f0 : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f0) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f0) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (OrF f f0)) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' (OrF f f0) *) (* Goal: forall (f : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f) (f0 : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f0) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f0) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (Imp f f0)) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' (Imp f f0) *) elim forces_a0_a1; trivial. Qed. Lemma forces_a1_imp_b__forces_a0_and_a1_imp_b : forall (A : Set) (World : A -> Type) (le : A -> A -> Type) (forces0 : A -> Int -> Prop) (k : A) (a1 b : form), forces A World le forces0 k (Imp a1 b) -> forall a0 : form, forces A World le forces0 k (Imp (AndF a0 a1) b). (* Goal: forall (A : Set) (World : forall _ : A, Type) (le : forall (_ : A) (_ : A), Type) (forces0 : forall (_ : A) (_ : Int), Prop) (k : A) (a1 b : form) (_ : forces A World le forces0 k (Imp a1 b)) (a0 : form), forces A World le forces0 k (Imp (AndF a0 a1) b) *) intros A World le forces0 k a1 b forces_a1_b a0. (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k (Imp a b) *) simpl in |- *. (* Goal: forall (k' : A) (_ : World k') (_ : le k k') (_ : and (forces A World le forces0 k' a0) (forces A World le forces0 k' a1)), forces A World le forces0 k' b *) intros k' w' le_k_k' forces_a0_a1. (* Goal: forces A World le forces0 k' b *) apply (forces_a1_b k'). (* Goal: Suc k'' k *) assumption. (* Goal: Suc k'' k *) assumption. (* Goal: (fix forces (A : Set) (World : forall _ : A, Type) (le : forall (_ : A) (_ : A), Type) (forces0 : forall (_ : A) (_ : Int), Prop) (k : A) (a : form) {struct a} : Prop := match a with | Falsum => False | Atom i => forces0 k i | AndF a0 a1 => and (forces A World le forces0 k a0) (forces A World le forces0 k a1) | OrF a0 a1 => or (forces A World le forces0 k a0) (forces A World le forces0 k a1) | Imp a0 a1 => forall (k' : A) (_ : World k') (_ : le k k') (_ : forces A World le forces0 k' a0), forces A World le forces0 k' a1 end) A World le forces0 k' a1 *) change (forces A World le forces0 k' a1) in |- *. (* Goal: forall (i : Int) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces0_t (Atms k') i) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces0_t (Atms k') i *) (* Goal: forall (f : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f) (f0 : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f0) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f0) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (AndF f f0)) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' (AndF f f0) *) (* Goal: forall (f : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f) (f0 : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f0) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f0) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (OrF f f0)) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' (OrF f f0) *) (* Goal: forall (f : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f) (f0 : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f0) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f0) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (Imp f f0)) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' (Imp f f0) *) elim forces_a0_a1; trivial. Qed. (******* kripke_trees ****************************************) Definition atoms := AVL unit. Definition ANil := AVL_NIL unit. Definition kripke_tree := Tree atoms. Definition Kripke_Forest := Forest atoms. Definition forces0_t (A : atoms) (i : Int) := LOOKUP unit i A tt. Definition Is_Monotone_kripke_tree := Is_Monotone_Tree atoms Int forces0_t. Definition Is_Monotone_Kripke_Forest := Is_Monotone_Forest atoms Int forces0_t. Definition Suc (k0 k1 : kripke_tree) := Successor atoms k0 k1. Definition Atms (k : kripke_tree) := root atoms k. Definition Succs (k0 : kripke_tree) := successors atoms k0. Lemma kripke_tree_kripke_model : forall k : kripke_tree, Is_Monotone_kripke_tree k -> Kripke_Model kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i). (* Goal: forall (_ : Suc k'' K) (_ : Suc k'' k') (_ : forces_t2 K k'' a), forces_t2 K k'' b *) intros. (* Goal: Kripke_Model kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) *) apply kripke_model. (* Goal: forall (k0 k1 : kripke_tree) (_ : Suc k0 k) (_ : Suc k1 k) (_ : Suc k1 k0) (i : Int) (_ : forces0_t (Atms k0) i), forces0_t (Atms k1) i *) unfold Suc in |- *. (* Goal: forall (_ : Suc k'' K) (_ : Suc k'' k') (_ : forces_t2 K k'' a), forces_t2 K k'' b *) intros. (* Goal: Successor atoms t1 t1 *) (* Goal: Suc k' t1 *) (* Goal: Is_Monotone_kripke_tree k *) (* Goal: Suc k' k *) apply succs_refl. (* Goal: forall (k0 k1 : kripke_tree) (_ : Suc k0 k) (_ : Suc k1 k) (_ : Suc k1 k0) (i : Int) (_ : forces0_t (Atms k0) i), forces0_t (Atms k1) i *) unfold Suc in |- *. (* Goal: forall (_ : Suc k'' K) (_ : Suc k'' k') (_ : forces_t2 K k'' a), forces_t2 K k'' b *) intros. (* Goal: Suc k'' k *) apply succs_trans with (t1 := k1); assumption. (* Goal: forall (k0 k1 : kripke_tree) (_ : Suc k0 k) (_ : Suc k1 k) (_ : Suc k1 k0) (i : Int) (_ : forces0_t (Atms k0) i), forces0_t (Atms k1) i *) unfold Suc in |- *. (* Goal: forall (k0 k1 : kripke_tree) (_ : Successor atoms k0 k) (_ : Successor atoms k1 k) (_ : Successor atoms k1 k0) (i : Int) (_ : forces0_t (Atms k0) i), forces0_t (Atms k1) i *) unfold Atms in |- *. (* Goal: forall (k0 k1 : kripke_tree) (_ : Successor atoms k0 k) (_ : Successor atoms k1 k) (_ : Successor atoms k1 k0) (i : Int) (_ : forces0_t (root atoms k0) i), forces0_t (root atoms k1) i *) intros k0 k1 suc0 suc1 suc1' i forces_k1. (* Goal: forces0_t (root atoms k1) i *) cut (Is_Monotone atoms Int forces0_t k). (* Goal: forall _ : Is_Monotone atoms Int forces0_t k, forces0_t (root atoms k1) i *) (* Goal: Is_Monotone atoms Int forces0_t k *) intro is_mon_k. (* Goal: forces0_t (root atoms k1) i *) (* Goal: Is_Monotone atoms Int forces0_t k *) inversion_clear is_mon_k. (* Goal: Suc k'' k *) apply H0 with (t0 := k0); assumption. (* Goal: Is_Monotone atoms Int forces0_t k *) apply is_monotone_tree_is_monotone. (* Goal: Suc k'' k *) assumption. Qed. Lemma kripke_tree_succ : forall K : kripke_tree, Is_Monotone_kripke_tree K -> forall k : kripke_tree, Suc k K -> Is_Monotone_kripke_tree k. (* Goal: Is_Monotone_kripke_tree k' *) (* Goal: Suc k' k' *) unfold Is_Monotone_kripke_tree in |- *. (* Goal: forall (K : kripke_tree) (_ : Is_Monotone_Tree atoms Int forces0_t K) (k : kripke_tree) (_ : Suc k K), Is_Monotone_Tree atoms Int forces0_t k *) intros K mon k suc. (* Goal: Suc k'' k *) apply is_monotone_tree_successor with K; assumption. Qed. Definition forces_t2 (K k : kripke_tree) (a : form) := forces kripke_tree (fun k0 : kripke_tree => Suc k0 K) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k a. Lemma forces_t2_is_local : forall (a : form) (k : kripke_tree), Is_Monotone_kripke_tree k -> forall k' : kripke_tree, Suc k' k -> forces_t2 k k' a -> forall K : kripke_tree, Is_Monotone_kripke_tree K -> Suc k' K -> forces_t2 K k' a. (* Goal: forall (a : form) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' a) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' a *) intros a; elim a; clear a. (* Goal: forces_t2 k k (Imp (AndF a0 a1) b) *) unfold forces_t2 in |- *. (* Goal: forall (i : Int) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces0_t (Atms k') i) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces0_t (Atms k') i *) (* Goal: forall (f : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f) (f0 : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f0) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f0) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (AndF f f0)) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' (AndF f f0) *) (* Goal: forall (f : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f) (f0 : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f0) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f0) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (OrF f f0)) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' (OrF f f0) *) (* Goal: forall (f : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f) (f0 : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f0) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f0) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (Imp f f0)) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' (Imp f f0) *) simpl in |- *; trivial. (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k (Imp a b) *) unfold forces_t2 in |- *; simpl in |- *. (* Goal: forall (i : Int) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces0_t (Atms k') i) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces0_t (Atms k') i *) (* Goal: forall (f : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f) (f0 : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f0) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f0) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (AndF f f0)) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' (AndF f f0) *) (* Goal: forall (f : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f) (f0 : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f0) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f0) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (OrF f f0)) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' (OrF f f0) *) (* Goal: forall (f : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f) (f0 : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f0) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f0) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (Imp f f0)) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' (Imp f f0) *) trivial. (* Goal: forall (f : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f) (f0 : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f0) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f0) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (OrF f f0)) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' (OrF f f0) *) (* Goal: forall (f : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f) (f0 : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f0) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f0) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (Imp f f0)) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' (Imp f f0) *) intros a ih_a b ih_b k mon_k k' suc_k'_k forces_k_k'_ab K mon_K suc_k'_K. (* Goal: forces_t2 K k' (AndF a b) *) (* Goal: forall (f : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f) (f0 : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f0) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f0) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (OrF f f0)) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' (OrF f f0) *) (* Goal: forall (f : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f) (f0 : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f0) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f0) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (Imp f f0)) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' (Imp f f0) *) elim forces_k_k'_ab. (* Goal: forall (_ : Suc k' k) (_ : Suc k' k) (_ : forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' a), forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' b *) fold (forces_t2 k k' a) in |- *. (* Goal: forall (_ : Suc k' k) (_ : Suc k' k) (_ : forces_t2 k k' a), forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' b *) fold (forces_t2 k k' b) in |- *. (* Goal: forall (_ : forces_t2 k k' a) (_ : forces_t2 k k' b), forces_t2 K k' (AndF a b) *) (* Goal: forall (f : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f) (f0 : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f0) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f0) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (OrF f f0)) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' (OrF f f0) *) (* Goal: forall (f : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f) (f0 : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f0) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f0) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (Imp f f0)) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' (Imp f f0) *) clear forces_k_k'_ab. (* Goal: forall (_ : forces_t2 k k' a) (_ : forces_t2 k k' b), forces_t2 K k' (AndF a b) *) (* Goal: forall (f : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f) (f0 : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f0) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f0) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (OrF f f0)) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' (OrF f f0) *) (* Goal: forall (f : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f) (f0 : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f0) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f0) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (Imp f f0)) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' (Imp f f0) *) intros u0 u1. (* Goal: and (forces_t2 k k' b0) (forces_t2 k k' b1) *) split. (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 K) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' a *) (* Goal: forall _ : forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' b, forces_t2 K k' (OrF a b) *) (* Goal: forall (f : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f) (f0 : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f0) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f0) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (Imp f f0)) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' (Imp f f0) *) change (forces_t2 K k' a) in |- *. (* Goal: Suc k'' k *) apply ih_a with (k := k); assumption. (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 K) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' b *) (* Goal: forall (f : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f) (f0 : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f0) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f0) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (Imp f f0)) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' (Imp f f0) *) change (forces_t2 K k' b) in |- *. (* Goal: Suc k'' k *) apply ih_b with (k := k); assumption. (* Goal: forall (f : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f) (f0 : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f0) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f0) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (OrF f f0)) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' (OrF f f0) *) (* Goal: forall (f : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f) (f0 : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f0) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f0) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (Imp f f0)) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' (Imp f f0) *) intros a ih_a b ih_b k mon_k k' suc_k'_k forces_k_k'_ab K mon_K suc_k'_K. (* Goal: forall (_ : forces_t2 k k' a) (_ : forces_t2 k k' b), forces_t2 K k' (AndF a b) *) (* Goal: forall (f : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f) (f0 : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f0) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f0) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (OrF f f0)) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' (OrF f f0) *) (* Goal: forall (f : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f) (f0 : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f0) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f0) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (Imp f f0)) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' (Imp f f0) *) elim forces_k_k'_ab; clear forces_k_k'_ab. (* Goal: forall (_ : Suc k' k) (_ : Suc k' k) (_ : forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' a), forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' b *) fold (forces_t2 k k' a) in |- *. (* Goal: forall _ : forces_t2 k k' a, forces_t2 K k' (OrF a b) *) (* Goal: forall _ : forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' b, forces_t2 K k' (OrF a b) *) (* Goal: forall (f : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f) (f0 : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f0) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f0) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (Imp f f0)) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' (Imp f f0) *) intro u0. (* Goal: forces_t2 K k' (OrF a b) *) (* Goal: forall _ : forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' b, forces_t2 K k' (OrF a b) *) (* Goal: forall (f : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f) (f0 : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f0) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f0) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (Imp f f0)) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' (Imp f f0) *) left. (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 K) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' a *) (* Goal: forall _ : forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' b, forces_t2 K k' (OrF a b) *) (* Goal: forall (f : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f) (f0 : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f0) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f0) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (Imp f f0)) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' (Imp f f0) *) change (forces_t2 K k' a) in |- *. (* Goal: Suc k'' k *) apply ih_a with (k := k); assumption. (* Goal: forall (_ : Suc k' k) (_ : Suc k' k) (_ : forces_t2 k k' a), forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' b *) fold (forces_t2 k k' b) in |- *. (* Goal: forall _ : forces_t2 k k' b, forces_t2 K k' (OrF a b) *) (* Goal: forall (f : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f) (f0 : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f0) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f0) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (Imp f f0)) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' (Imp f f0) *) intros u0. (* Goal: forces_t2 K k' (OrF a b) *) (* Goal: forall (f : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f) (f0 : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f0) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f0) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (Imp f f0)) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' (Imp f f0) *) right. (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 K) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' b *) (* Goal: forall (f : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f) (f0 : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f0) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f0) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (Imp f f0)) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' (Imp f f0) *) change (forces_t2 K k' b) in |- *. (* Goal: Suc k'' k *) apply ih_b with (k := k); assumption. (* Goal: forall (f : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f) (f0 : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f0) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f0) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (Imp f f0)) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' (Imp f f0) *) intros a ih_a b ih_b. (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (Imp a b)) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' (Imp a b) *) intros k mon_k k' suc_k'_k forces_k_k'_ab K mon_K suc_k_K. (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k (Imp a b) *) unfold forces_t2 in |- *; simpl in |- *. (* Goal: forall (k'0 : kripke_tree) (_ : Suc k'0 K) (_ : Suc k'0 k') (_ : forces kripke_tree (fun k0 : kripke_tree => Suc k0 K) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k'0 a), forces kripke_tree (fun k0 : kripke_tree => Suc k0 K) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k'0 b *) intros k''. (* Goal: forall (_ : Suc k'' K) (_ : Suc k'' k') (_ : forces kripke_tree (fun k0 : kripke_tree => Suc k0 K) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k'' a), forces kripke_tree (fun k0 : kripke_tree => Suc k0 K) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k'' b *) fold (forces_t2 K k'' a) in |- *. (* Goal: forall (_ : Suc k'' K) (_ : Suc k'' k') (_ : forces_t2 K k'' a), forces kripke_tree (fun k0 : kripke_tree => Suc k0 K) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k'' b *) fold (forces_t2 K k'' b) in |- *. (* Goal: forall (_ : Suc k'' K) (_ : Suc k'' k') (_ : forces_t2 K k'' a), forces_t2 K k'' b *) intros. (* Goal: forces_t2 K k'' b *) apply ih_b with (k := k); clear ih_b. (* Goal: Suc k'' k *) assumption. (* Goal: Suc k'' k *) unfold Suc in |- *; apply succs_trans with k'; assumption. (* Goal: forall (_ : forces_t2 k k' a) (_ : forces_t2 k k' b), forces_t2 K k' (AndF a b) *) (* Goal: forall (f : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f) (f0 : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f0) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f0) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (OrF f f0)) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' (OrF f f0) *) (* Goal: forall (f : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f) (f0 : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f0) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f0) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (Imp f f0)) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' (Imp f f0) *) apply (forces_k_k'_ab k''); clear forces_k_k'_ab. (* Goal: Suc k'' k *) unfold Suc in |- *; apply succs_trans with k'; assumption. (* Goal: Suc k'' k *) assumption. (* Goal: (fix forces (A : Set) (World : forall _ : A, Type) (le : forall (_ : A) (_ : A), Type) (forces0 : forall (_ : A) (_ : Int), Prop) (k : A) (a : form) {struct a} : Prop := match a with | Falsum => False | Atom i => forces0 k i | AndF a0 a1 => and (forces A World le forces0 k a0) (forces A World le forces0 k a1) | OrF a0 a1 => or (forces A World le forces0 k a0) (forces A World le forces0 k a1) | Imp a0 a1 => forall (k' : A) (_ : World k') (_ : le k k') (_ : forces A World le forces0 k' a0), forces A World le forces0 k' a1 end) kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k'' a *) (* Goal: Is_Monotone_kripke_tree K *) (* Goal: Suc k'' K *) change (forces_t2 k k'' a) in |- *. (* Goal: forces_t2 k k'' a *) (* Goal: Is_Monotone_kripke_tree K *) (* Goal: Suc k'' K *) apply ih_a with (k := K); clear ih_a. (* Goal: Suc k'' k *) assumption. (* Goal: Suc k'' k *) assumption. (* Goal: Suc k'' k *) assumption. (* Goal: Suc k'' k *) assumption. (* Goal: Suc k'' k *) unfold Suc in |- *; apply succs_trans with k'; assumption. (* Goal: Suc k'' k *) assumption. (* Goal: Suc k'' k *) assumption. Qed. Definition forces_t (k : kripke_tree) := forces_t2 k k. Lemma forces_t_imp : forall k : kripke_tree, Is_Monotone_kripke_tree k -> forall a b : form, (forces_t k a -> forces_t k b) -> (forall k' : kripke_tree, In_Forest atoms k' (Succs k) -> forces_t k' (Imp a b)) -> forces_t k (Imp a b). (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (a b : form) (_ : forall _ : forces_t k a, forces_t k b) (_ : forall (k' : kripke_tree) (_ : In_Forest atoms k' (Succs k)), forces_t k' (Imp a b)), forces_t k (Imp a b) *) intros k mon a b forces_a_b foreach_succs. (* Goal: forces_t k (Imp (AndF a0 a1) b) *) unfold forces_t in |- *. (* Goal: forces_t2 k k (Imp (AndF a0 a1) b) *) unfold forces_t2 in |- *. (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k (Imp a b) *) simpl in |- *. (* Goal: forall (k' : kripke_tree) (_ : Suc k' k) (_ : Suc k' k) (_ : forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' a), forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' b *) intro k'. (* Goal: forall (_ : Suc k' k) (_ : Suc k' k) (_ : forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' a), forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' b *) fold (forces_t2 k k' a) in |- *. (* Goal: forall (_ : Suc k' k) (_ : Suc k' k) (_ : forces_t2 k k' a), forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' b *) fold (forces_t2 k k' b) in |- *. (* Goal: forall (_ : Suc k' k) (_ : Suc k' k) (_ : forces_t2 k k' a), forces_t2 k k' b *) intros suc_k'_k; clear suc_k'_k. (* Goal: forall (_ : Suc k' k) (_ : forces_t2 k k' a), forces_t2 k k' b *) intros suc_k'_k. (* Goal: forall _ : forces_t2 k k' a, forces_t2 k k' b *) inversion_clear suc_k'_k. (* Goal: Suc k'' k *) assumption. (* Goal: forall _ : forces_t2 k k' a, forces_t2 k k' b *) intro forces_a. (* Goal: forces_t2 k k' b *) apply forces_t2_is_local with (k := t1). (* Goal: Is_Monotone_kripke_tree k' *) (* Goal: Suc k' k' *) unfold Is_Monotone_kripke_tree in |- *. (* Goal: Is_Monotone_Tree atoms Int forces0_t k' *) (* Goal: Suc k' k' *) apply is_monotone_tree_successor with k. (* Goal: Suc k'' k *) assumption. (* Goal: Successor atoms t1 k *) (* Goal: Suc k' t1 *) (* Goal: Is_Monotone_kripke_tree k *) (* Goal: Suc k' k *) apply successor_trans with t1. (* Goal: Suc k'' k *) assumption. (* Goal: Successor atoms t1 t1 *) (* Goal: Suc k' t1 *) (* Goal: Is_Monotone_kripke_tree k *) (* Goal: Suc k' k *) apply succs_refl. (* Goal: Suc k'' k *) assumption. (* Goal: forces_t2 t1 k' b *) (* Goal: Is_Monotone_kripke_tree k *) (* Goal: Suc k' k *) apply (foreach_succs t1 H k'). (* Goal: Suc k'' k *) assumption. (* Goal: Suc k'' k *) assumption. (* Goal: (fix forces (A : Set) (World : forall _ : A, Type) (le : forall (_ : A) (_ : A), Type) (forces0 : forall (_ : A) (_ : Int), Prop) (k : A) (a : form) {struct a} : Prop := match a with | Falsum => False | Atom i => forces0 k i | AndF a0 a1 => and (forces A World le forces0 k a0) (forces A World le forces0 k a1) | OrF a0 a1 => or (forces A World le forces0 k a0) (forces A World le forces0 k a1) | Imp a0 a1 => forall (k' : A) (_ : World k') (_ : le k k') (_ : forces A World le forces0 k' a0), forces A World le forces0 k' a1 end) kripke_tree (fun k0 : kripke_tree => Suc k0 t1) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' a *) (* Goal: Is_Monotone_kripke_tree k *) (* Goal: Suc k' k *) change (forces_t2 t1 k' a) in |- *. (* Goal: forces_t2 k' k' a *) apply forces_t2_is_local with (k := k). (* Goal: Suc k'' k *) assumption. (* Goal: Successor atoms t1 k *) (* Goal: Suc k' t1 *) (* Goal: Is_Monotone_kripke_tree k *) (* Goal: Suc k' k *) unfold Suc in |- *; apply successor_trans with t1. (* Goal: Suc k'' k *) assumption. (* Goal: Suc k'' k *) assumption. (* Goal: Suc k'' k *) assumption. (* Goal: Is_Monotone_kripke_tree k' *) (* Goal: Suc k' k' *) unfold Is_Monotone_kripke_tree in |- *. (* Goal: Is_Monotone_Tree atoms Int forces0_t k' *) (* Goal: Suc k' k' *) apply is_monotone_tree_successor with k. (* Goal: Suc k'' k *) assumption. (* Goal: Successor atoms t1 k *) (* Goal: Suc k' t1 *) (* Goal: Is_Monotone_kripke_tree k *) (* Goal: Suc k' k *) apply successor_trans with t1. (* Goal: Suc k'' k *) assumption. (* Goal: Successor atoms t1 t1 *) (* Goal: Suc k' t1 *) (* Goal: Is_Monotone_kripke_tree k *) (* Goal: Suc k' k *) apply succs_refl. (* Goal: Suc k'' k *) assumption. (* Goal: Suc k'' k *) assumption. (* Goal: Successor atoms t1 k *) (* Goal: Suc k' t1 *) (* Goal: Is_Monotone_kripke_tree k *) (* Goal: Suc k' k *) unfold Suc in |- *; apply successor_trans with t1. (* Goal: Suc k'' k *) assumption. (* Goal: Suc k'' k *) assumption. Qed. Lemma forces_t_mon : forall k : kripke_tree, Is_Monotone_kripke_tree k -> forall a : form, forces_t k a -> forall k' : kripke_tree, Suc k' k -> forces_t k' a. (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (a : form) (_ : forces_t k a) (k' : kripke_tree) (_ : Suc k' k), forces_t k' a *) intros k mon a forces_a k' suc. (* Goal: forces_t k (Imp (AndF a0 a1) b) *) unfold forces_t in |- *. (* Goal: forces_t2 k' k' a *) apply forces_t2_is_local with (k := k). (* Goal: Suc k'' k *) assumption. (* Goal: Suc k'' k *) assumption. (* Goal: forces_t2 k k (Imp (AndF a0 a1) b) *) unfold forces_t2 in |- *. (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' a *) (* Goal: Is_Monotone_kripke_tree k' *) (* Goal: Suc k' k' *) apply forces_mon with (k := k). (* Goal: Kripke_Model kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) *) (* Goal: Suc k k *) (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k a0 *) (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k (Imp (Imp a0 a1) b) *) apply (kripke_tree_kripke_model k mon). (* Goal: Successor atoms t1 t1 *) (* Goal: Suc k' t1 *) (* Goal: Is_Monotone_kripke_tree k *) (* Goal: Suc k' k *) unfold Suc in |- *; apply succs_refl. (* Goal: Suc k'' k *) assumption. (* Goal: Suc k'' k *) assumption. (* Goal: Suc k'' k *) assumption. (* Goal: Is_Monotone_kripke_tree k' *) (* Goal: Suc k' k' *) unfold Is_Monotone_kripke_tree in |- *. (* Goal: Is_Monotone_Tree atoms Int forces0_t k' *) (* Goal: Suc k' k' *) apply is_monotone_tree_successor with k. (* Goal: Suc k'' k *) assumption. (* Goal: Suc k'' k *) assumption. (* Goal: Successor atoms t1 t1 *) (* Goal: Suc k' t1 *) (* Goal: Is_Monotone_kripke_tree k *) (* Goal: Suc k' k *) unfold Suc in |- *; apply succs_refl. Qed. Lemma soundness_t : forall (t : proof_term) (context : flist) (a : form), derives context t a -> forall k : kripke_tree, Is_Monotone_kripke_tree k -> (forall c : form, In c context -> forces_t k c) -> forces_t k a. (* Goal: forall (t : proof_term) (context : flist) (a : form) (_ : derives context t a) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forall (c : form) (_ : @In form c context), forces_t k c), forces_t k a *) intros t context a der_t k mon forces_context. (* Goal: forces_t k (Imp (AndF a0 a1) b) *) unfold forces_t in |- *. (* Goal: forces_t2 k k (Imp (AndF a0 a1) b) *) unfold forces_t2 in |- *. (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k a *) apply soundness with t context. (* Goal: Suc k'' k *) assumption. (* Goal: Kripke_Model kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) *) (* Goal: Suc k k *) (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k a0 *) (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k (Imp (Imp a0 a1) b) *) apply (kripke_tree_kripke_model k mon). (* Goal: Successor atoms t1 t1 *) (* Goal: Suc k' t1 *) (* Goal: Is_Monotone_kripke_tree k *) (* Goal: Suc k' k *) unfold Suc in |- *; apply succs_refl. (* Goal: forall (c : form) (_ : @In form c context), forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k c *) exact forces_context. Qed. Lemma forces_b__forces_a_imp_b_t : forall k : kripke_tree, Is_Monotone_kripke_tree k -> forall b : form, forces_t k b -> forall a : form, forces_t k (Imp a b). (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (b : form) (_ : forces_t k b) (a : form), forces_t k (Imp a b) *) intros k mon b forces_b a. (* Goal: forces_t k (Imp (AndF a0 a1) b) *) unfold forces_t in |- *. (* Goal: forces_t2 k k (Imp (AndF a0 a1) b) *) unfold forces_t2 in |- *. (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k (Imp a b) *) apply forces_b__forces_a_imp_b. (* Goal: Kripke_Model kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) *) (* Goal: Suc k k *) (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k a0 *) (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k (Imp (Imp a0 a1) b) *) apply (kripke_tree_kripke_model k mon). (* Goal: Successor atoms t1 t1 *) (* Goal: Suc k' t1 *) (* Goal: Is_Monotone_kripke_tree k *) (* Goal: Suc k' k *) unfold Suc in |- *; apply succs_refl. (* Goal: Suc k'' k *) assumption. Qed. Lemma forces_a0_imp_a1_imp_b__forces_a0_and_a1_imp_b_t : forall k : kripke_tree, Is_Monotone_kripke_tree k -> forall a0 a1 b : form, forces_t k (Imp a0 (Imp a1 b)) -> forces_t k (Imp (AndF a0 a1) b). (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (a0 a1 b : form) (_ : forces_t k (Imp a0 (Imp a1 b))), forces_t k (Imp (AndF a0 a1) b) *) intros k mon a0 a1 b forces_a0_a1_b. (* Goal: forces_t k (Imp (AndF a0 a1) b) *) unfold forces_t in |- *. (* Goal: forces_t2 k k (Imp (AndF a0 a1) b) *) unfold forces_t2 in |- *. (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k (Imp (AndF a0 a1) b) *) apply forces_a0_imp_a1_imp_b__forces_a0_and_a1_imp_b. (* Goal: Kripke_Model kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) *) (* Goal: Suc k k *) (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k a0 *) (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k (Imp (Imp a0 a1) b) *) apply (kripke_tree_kripke_model k mon). (* Goal: Successor atoms t1 t1 *) (* Goal: Suc k' t1 *) (* Goal: Is_Monotone_kripke_tree k *) (* Goal: Suc k' k *) unfold Suc in |- *; apply succs_refl. (* Goal: Suc k'' k *) assumption. Qed. Lemma forces_a0_imp_c_and_a1_imp_c_and_c_imp_b__forces_a0_or_a1_imp_b_t : forall (k : kripke_tree) (a0 a1 c b : form), forces_t k (Imp a0 c) -> forces_t k (Imp a1 c) -> forces_t k (Imp c b) -> forces_t k (Imp (OrF a0 a1) b). (* Goal: forall (k : kripke_tree) (a0 a1 c b : form) (_ : forces_t k (Imp a0 c)) (_ : forces_t k (Imp a1 c)) (_ : forces_t k (Imp c b)), forces_t k (Imp (OrF a0 a1) b) *) intros k a0 a1 c b forces_a0_c forces_a1_c forces_c_b. (* Goal: forces_t k (Imp (AndF a0 a1) b) *) unfold forces_t in |- *. (* Goal: forces_t2 k k (Imp (AndF a0 a1) b) *) unfold forces_t2 in |- *. apply forces_a0_imp_c_and_a1_imp_c_and_c_imp_b__forces_a0_or_a1_imp_b with c; (* Goal: Suc k'' k *) assumption. Qed. Lemma forces_a1_imp_b__forces_a0_imp_a1_imp_b_t : forall k : kripke_tree, Is_Monotone_kripke_tree k -> forall a0 : form, forces_t k a0 -> forall a1 b : form, forces_t k (Imp a1 b) -> forces_t k (Imp (Imp a0 a1) b). (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (a0 : form) (_ : forces_t k a0) (a1 b : form) (_ : forces_t k (Imp a1 b)), forces_t k (Imp (Imp a0 a1) b) *) intros k mon a0 forces_a0 a1 b forces_a1_b. (* Goal: forces_t k (Imp (AndF a0 a1) b) *) unfold forces_t in |- *. (* Goal: forces_t2 k k (Imp (AndF a0 a1) b) *) unfold forces_t2 in |- *. (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k (Imp (Imp a0 a1) b) *) apply forces_a1_imp_b__forces_a0_imp_a1_imp_b. (* Goal: Kripke_Model kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) *) (* Goal: Suc k k *) (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k a0 *) (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k (Imp (Imp a0 a1) b) *) apply (kripke_tree_kripke_model k mon). (* Goal: Successor atoms t1 t1 *) (* Goal: Suc k' t1 *) (* Goal: Is_Monotone_kripke_tree k *) (* Goal: Suc k' k *) unfold Suc in |- *; apply succs_refl. (* Goal: Suc k'' k *) assumption. (* Goal: Suc k'' k *) assumption. Qed. Lemma forces_a0_imp_a1_imp_b__forces_a1_imp_b_t : forall k : kripke_tree, Is_Monotone_kripke_tree k -> forall a0 : form, forces_t k a0 -> forall a1 b : form, forces_t k (Imp (Imp a0 a1) b) -> forces_t k (Imp a1 b). (* Goal: forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (a0 : form) (_ : forces_t k a0) (a1 b : form) (_ : forces_t k (Imp (Imp a0 a1) b)), forces_t k (Imp a1 b) *) intros k mon a0 forces_a0 a1 b forces_a0a1_b. (* Goal: forces_t k (Imp (AndF a0 a1) b) *) unfold forces_t in |- *. (* Goal: forces_t2 k k (Imp (AndF a0 a1) b) *) unfold forces_t2 in |- *. (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k (Imp a1 b) *) apply forces_a0_imp_a1_imp_b__forces_a1_imp_b with a0. (* Goal: Kripke_Model kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) *) (* Goal: Suc k k *) (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k a0 *) (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k (Imp (Imp a0 a1) b) *) apply (kripke_tree_kripke_model k mon). (* Goal: Successor atoms t1 t1 *) (* Goal: Suc k' t1 *) (* Goal: Is_Monotone_kripke_tree k *) (* Goal: Suc k' k *) unfold Suc in |- *; apply succs_refl. (* Goal: Suc k'' k *) assumption. (* Goal: Suc k'' k *) assumption. Qed. Lemma forces_a0_imp_b__forces_a0_and_a1_imp_b_t : forall (k : kripke_tree) (a0 b : form), forces_t k (Imp a0 b) -> forall a1 : form, forces_t k (Imp (AndF a0 a1) b). (* Goal: forall (k : kripke_tree) (a0 b : form) (_ : forces_t k (Imp a0 b)) (a1 : form), forces_t k (Imp (AndF a0 a1) b) *) intros k a0 b forces_a0_b a1. (* Goal: forces_t k (Imp (AndF a0 a1) b) *) unfold forces_t in |- *. (* Goal: forces_t2 k k (Imp (AndF a0 a1) b) *) unfold forces_t2 in |- *. (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k (Imp (AndF a0 a1) b) *) apply forces_a0_imp_b__forces_a0_and_a1_imp_b. (* Goal: Suc k'' k *) assumption. Qed. Lemma forces_a1_imp_b__forces_a0_and_a1_imp_b_t : forall (k : kripke_tree) (a1 b : form), forces_t k (Imp a1 b) -> forall a0 : form, forces_t k (Imp (AndF a0 a1) b). (* Goal: forall (k : kripke_tree) (a1 b : form) (_ : forces_t k (Imp a1 b)) (a0 : form), forces_t k (Imp (AndF a0 a1) b) *) intros k a1 b forces_a1_b a0. (* Goal: forces_t k (Imp (AndF a0 a1) b) *) unfold forces_t in |- *. (* Goal: forces_t2 k k (Imp (AndF a0 a1) b) *) unfold forces_t2 in |- *. (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k (Imp (AndF a0 a1) b) *) apply forces_a1_imp_b__forces_a0_and_a1_imp_b. (* Goal: Suc k'' k *) assumption. Qed. (*****************************************************************) Lemma forces_a_a_imp_b__forces_b_t : forall (k : kripke_tree) (a b : form), forces_t k a -> forces_t k (Imp a b) -> forces_t k b. (* Goal: forall (k : kripke_tree) (a b : form) (_ : forces_t k a) (_ : forces_t k (Imp a b)), forces_t k b *) intros k a b forces_a forces_ab. (* Goal: forces_t k b *) apply (forces_ab k). (* Goal: Suc k k *) (* Goal: forall (a : Int) (l : list Int) (_ : forall (b : form) (_ : forall (k' : kripke_tree) (_ : Suc k' k), forces_t2 k k' b), forces_t k (vimp l b)) (b : form) (_ : forall (k' : kripke_tree) (_ : Suc k' k), forces_t2 k k' b), forces_t k (vimp (@cons Int a l) b) *) unfold Suc in |- *; apply successor_refl. (* Goal: Suc k k *) (* Goal: forall (a : Int) (l : list Int) (_ : forall (b : form) (_ : forall (k' : kripke_tree) (_ : Suc k' k), forces_t2 k k' b), forces_t k (vimp l b)) (b : form) (_ : forall (k' : kripke_tree) (_ : Suc k' k), forces_t2 k k' b), forces_t k (vimp (@cons Int a l) b) *) unfold Suc in |- *; apply successor_refl. (* Goal: Suc k'' k *) assumption. Qed. Lemma forces_a_imp_b0_a_imp_b1__forces_a_imp_a0_and_a1 : forall (a b0 b1 : form) (k : kripke_tree), forces_t k (Imp a b0) -> forces_t k (Imp a b1) -> forces_t k (Imp a (AndF b0 b1)). (* Goal: forall (a b0 b1 : form) (k : kripke_tree) (_ : forces_t k (Imp a b0)) (_ : forces_t k (Imp a b1)), forces_t k (Imp a (AndF b0 b1)) *) intros a b0 b1 k forces_ab0 forces_ab1. (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k (Imp a b) *) unfold forces_t in |- *; unfold forces_t2 in |- *; simpl in |- *. (* Goal: forall (k' : kripke_tree) (_ : Suc k' k) (_ : Suc k' k) (_ : forall (k'0 : kripke_tree) (_ : Suc k'0 k) (_ : Suc k'0 k') (_ : forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k'0 a), False), forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' c *) intros k' suc_k' suc_k''. (* Goal: forall _ : forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' a, and (forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' b0) (forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' b1) *) change (forces_t2 k k' a -> forces_t2 k k' b0 /\ forces_t2 k k' b1) in |- *. (* Goal: forall _ : forces_t2 k k' a, and (forces_t2 k k' b0) (forces_t2 k k' b1) *) intros forces_a. (* Goal: and (forces_t2 k k' b0) (forces_t2 k k' b1) *) split. (* Goal: Suc k'' k *) apply (forces_ab0 k'); assumption. (* Goal: Suc k'' k *) apply (forces_ab1 k'); assumption. Qed. Lemma forces_a_imp_b__forces_a_imp_falsum_or_b : forall (k : kripke_tree) (a b : form), forces_t k (Imp a b) -> forces_t k (Imp a (OrF Falsum b)). (* Goal: forall (k : kripke_tree) (a b : form) (_ : forces_t k (Imp a b)), forces_t k (Imp a (OrF b Falsum)) *) intros k a b forces_ab. (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k (Imp a b) *) unfold forces_t in |- *; unfold forces_t2 in |- *; simpl in |- *. (* Goal: forall (k' : kripke_tree) (_ : Suc k' k) (_ : Suc k' k) (_ : forall (k'0 : kripke_tree) (_ : Suc k'0 k) (_ : Suc k'0 k') (_ : forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k'0 a), False), forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' c *) intros k' suc_k' suc_k''. (* Goal: forall _ : forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' a, or False (forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' b) *) change (forces_t2 k k' a -> False \/ forces_t2 k k' b) in |- *. (* Goal: forces_t2 K k' (OrF a b) *) (* Goal: forall (f : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f) (f0 : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f0) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f0) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (Imp f f0)) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' (Imp f f0) *) intros forces_a; right. (* Goal: Suc k'' k *) apply (forces_ab k'); assumption. Qed. Lemma forces_a_imp_b__forces_a_imp_b_or_falsum : forall (k : kripke_tree) (a b : form), forces_t k (Imp a b) -> forces_t k (Imp a (OrF b Falsum)). (* Goal: forall (k : kripke_tree) (a b : form) (_ : forces_t k (Imp a b)), forces_t k (Imp a (OrF b Falsum)) *) intros k a b forces_ab. (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k (Imp a b) *) unfold forces_t in |- *; unfold forces_t2 in |- *; simpl in |- *. (* Goal: forall (k' : kripke_tree) (_ : Suc k' k) (_ : Suc k' k) (_ : forall (k'0 : kripke_tree) (_ : Suc k'0 k) (_ : Suc k'0 k') (_ : forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k'0 a), False), forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' c *) intros k' suc_k' suc_k''. (* Goal: forall _ : forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' a, or (forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' b) False *) change (forces_t2 k k' a -> forces_t2 k k' b \/ False) in |- *. (* Goal: forces_t2 K k' (OrF a b) *) (* Goal: forall _ : forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' b, forces_t2 K k' (OrF a b) *) (* Goal: forall (f : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f) (f0 : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' f0) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' f0) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (Imp f f0)) (K : kripke_tree) (_ : Is_Monotone_kripke_tree K) (_ : Suc k' K), forces_t2 K k' (Imp f f0) *) intros forces_a; left. (* Goal: Suc k'' k *) apply (forces_ab k'); assumption. Qed. Lemma forces_a_imp_falsum_imp_b1_t : forall (k : kripke_tree) (a b1 : form), forces_t k (Imp a (Imp Falsum b1)). (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k (Imp a b) *) unfold forces_t in |- *; unfold forces_t2 in |- *; simpl in |- *. (* Goal: Suc k'' k *) intros; elimtype False; assumption. Qed. Lemma forces_a_imp_b_imp_c__forces_a_imp_falsum_imp_c : forall (k : kripke_tree) (a b c : form), forces_t k (Imp (Imp a b) c) -> forces_t k (Imp (Imp a Falsum) c). (* Goal: forall (k : kripke_tree) (a b c : form) (_ : forces_t k (Imp (Imp a b) c)), forces_t k (Imp (Imp a Falsum) c) *) intros k a b c forces_abc. (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k (Imp a b) *) unfold forces_t in |- *; unfold forces_t2 in |- *; simpl in |- *. (* Goal: forall (k' : kripke_tree) (_ : Suc k' k) (_ : Suc k' k) (_ : forall (k'0 : kripke_tree) (_ : Suc k'0 k) (_ : Suc k'0 k') (_ : forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k'0 a), False), forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' c *) intros k' suc_k' suc_k''. (* Goal: forall _ : forall (k'0 : kripke_tree) (_ : Suc k'0 k) (_ : Suc k'0 k') (_ : forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k'0 a), False, forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' c *) change (forces_t2 k k' (Imp a Falsum) -> forces_t2 k k' c) in |- *. (* Goal: forall _ : forces_t2 k k'' (Imp a Falsum), forces_t2 k k'' c *) intros forces1. (* Goal: Suc k'' k *) apply (forces_abc k'); try assumption. (* Goal: forall (k'0 : kripke_tree) (_ : Suc k'0 k) (_ : Suc k'0 k') (_ : (fix forces (A : Set) (World : forall _ : A, Type) (le : forall (_ : A) (_ : A), Type) (forces0 : forall (_ : A) (_ : Int), Prop) (k : A) (a : form) {struct a} : Prop := match a with | Falsum => False | Atom i => forces0 k i | AndF a0 a1 => and (forces A World le forces0 k a0) (forces A World le forces0 k a1) | OrF a0 a1 => or (forces A World le forces0 k a0) (forces A World le forces0 k a1) | Imp a0 a1 => forall (k' : A) (_ : World k') (_ : le k k') (_ : forces A World le forces0 k' a0), forces A World le forces0 k' a1 end) kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k'0 a), (fix forces (A : Set) (World : forall _ : A, Type) (le : forall (_ : A) (_ : A), Type) (forces0 : forall (_ : A) (_ : Int), Prop) (k : A) (a : form) {struct a} : Prop := match a with | Falsum => False | Atom i => forces0 k i | AndF a0 a1 => and (forces A World le forces0 k a0) (forces A World le forces0 k a1) | OrF a0 a1 => or (forces A World le forces0 k a0) (forces A World le forces0 k a1) | Imp a0 a1 => forall (k' : A) (_ : World k') (_ : le k k') (_ : forces A World le forces0 k' a0), forces A World le forces0 k' a1 end) kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k'0 b *) intros k'' suc3 suc4 forces_a. (* Goal: (fix forces (A : Set) (World : forall _ : A, Type) (le : forall (_ : A) (_ : A), Type) (forces0 : forall (_ : A) (_ : Int), Prop) (k : A) (a : form) {struct a} : Prop := match a with | Falsum => False | Atom i => forces0 k i | AndF a0 a1 => and (forces A World le forces0 k a0) (forces A World le forces0 k a1) | OrF a0 a1 => or (forces A World le forces0 k a0) (forces A World le forces0 k a1) | Imp a0 a1 => forall (k' : A) (_ : World k') (_ : le k k') (_ : forces A World le forces0 k' a0), forces A World le forces0 k' a1 end) kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k''' b *) elimtype False. (* Goal: Suc k'' k *) apply (forces1 k''); assumption. Qed. Lemma forces_vimp : forall (k : kripke_tree) (l : list Int) (a b : form), (forall k' : kripke_tree, Suc k' k -> forces_t2 k k' a -> forces_t2 k k' b) -> forces_t k (vimp l a) -> forces_t k (vimp l b). (* Goal: forall (k : kripke_tree) (l : list Int) (b : form) (_ : forall (k' : kripke_tree) (_ : Suc k' k), forces_t2 k k' b), forces_t k (vimp l b) *) intros k l. (* Goal: forall (b : form) (_ : forall (k' : kripke_tree) (_ : Suc k' k), forces_t2 k k' b), forces_t k (vimp l b) *) elim l; clear l. (* Goal: forall (a b : form) (_ : forall (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' a), forces_t2 k k' b) (_ : forces_t k (vimp (@nil Int) a)), forces_t k (vimp (@nil Int) b) *) (* Goal: forall (a : Int) (l : list Int) (_ : forall (a0 b : form) (_ : forall (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' a0), forces_t2 k k' b) (_ : forces_t k (vimp l a0)), forces_t k (vimp l b)) (a0 b : form) (_ : forall (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' a0), forces_t2 k k' b) (_ : forces_t k (vimp (@cons Int a l) a0)), forces_t k (vimp (@cons Int a l) b) *) intros a b forces_ab forces_a. (* Goal: Suc k'' k *) apply forces_ab with (k' := k); try assumption. (* Goal: Suc k k *) (* Goal: forall (a : Int) (l : list Int) (_ : forall (b : form) (_ : forall (k' : kripke_tree) (_ : Suc k' k), forces_t2 k k' b), forces_t k (vimp l b)) (b : form) (_ : forall (k' : kripke_tree) (_ : Suc k' k), forces_t2 k k' b), forces_t k (vimp (@cons Int a l) b) *) unfold Suc in |- *; apply successor_refl. (* Goal: forall (a : Int) (l : list Int) (_ : forall (a0 b : form) (_ : forall (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' a0), forces_t2 k k' b) (_ : forces_t k (vimp l a0)), forces_t k (vimp l b)) (a0 b : form) (_ : forall (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' a0), forces_t2 k k' b) (_ : forces_t k (vimp (@cons Int a l) a0)), forces_t k (vimp (@cons Int a l) b) *) simpl in |- *; intros i l ih a b forces_ab forces_a. (* Goal: Suc k'' k *) apply ih with (a := Imp (Atom i) a); try assumption. (* Goal: forall (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (Imp (Atom i) a)), forces_t2 k k' (Imp (Atom i) b) *) intros k' suc1 forces_ia. (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k (Imp a b) *) unfold forces_t in |- *; unfold forces_t2 in |- *; simpl in |- *. (* Goal: forall (k'0 : kripke_tree) (_ : Suc k'0 k) (_ : Suc k'0 k') (_ : forces0_t (Atms k'0) i), forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k'0 b *) intros k'' suc2 suc3 forces_i. (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k'' b *) change (forces_t2 k k'' b) in |- *. (* Goal: forces_t2 k k'' b *) apply forces_ab. (* Goal: Suc k'' k *) assumption. (* Goal: Suc k'' k *) apply (forces_ia k''); assumption. Qed. Lemma forces_vimp2 : forall (k : kripke_tree) (l : list Int) (a b c : form), (forall k' : kripke_tree, Suc k' k -> forces_t2 k k' a -> forces_t2 k k' b -> forces_t2 k k' c) -> forces_t k (vimp l a) -> forces_t k (vimp l b) -> forces_t k (vimp l c). (* Goal: forall (k : kripke_tree) (l : list Int) (b : form) (_ : forall (k' : kripke_tree) (_ : Suc k' k), forces_t2 k k' b), forces_t k (vimp l b) *) intros k l. (* Goal: forall (b : form) (_ : forall (k' : kripke_tree) (_ : Suc k' k), forces_t2 k k' b), forces_t k (vimp l b) *) elim l; clear l. (* Goal: forall (a b c : form) (_ : forall (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' a) (_ : forces_t2 k k' b), forces_t2 k k' c) (_ : forces_t k (vimp (@nil Int) a)) (_ : forces_t k (vimp (@nil Int) b)), forces_t k (vimp (@nil Int) c) *) (* Goal: forall (a : Int) (l : list Int) (_ : forall (a0 b c : form) (_ : forall (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' a0) (_ : forces_t2 k k' b), forces_t2 k k' c) (_ : forces_t k (vimp l a0)) (_ : forces_t k (vimp l b)), forces_t k (vimp l c)) (a0 b c : form) (_ : forall (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' a0) (_ : forces_t2 k k' b), forces_t2 k k' c) (_ : forces_t k (vimp (@cons Int a l) a0)) (_ : forces_t k (vimp (@cons Int a l) b)), forces_t k (vimp (@cons Int a l) c) *) intros a b c forces_abc forces_a forces_b. (* Goal: Suc k'' k *) apply forces_abc with (k' := k); try assumption. (* Goal: Suc k k *) (* Goal: forall (a : Int) (l : list Int) (_ : forall (b : form) (_ : forall (k' : kripke_tree) (_ : Suc k' k), forces_t2 k k' b), forces_t k (vimp l b)) (b : form) (_ : forall (k' : kripke_tree) (_ : Suc k' k), forces_t2 k k' b), forces_t k (vimp (@cons Int a l) b) *) unfold Suc in |- *; apply successor_refl. (* Goal: forall (a : Int) (l : list Int) (_ : forall (a0 b c : form) (_ : forall (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' a0) (_ : forces_t2 k k' b), forces_t2 k k' c) (_ : forces_t k (vimp l a0)) (_ : forces_t k (vimp l b)), forces_t k (vimp l c)) (a0 b c : form) (_ : forall (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' a0) (_ : forces_t2 k k' b), forces_t2 k k' c) (_ : forces_t k (vimp (@cons Int a l) a0)) (_ : forces_t k (vimp (@cons Int a l) b)), forces_t k (vimp (@cons Int a l) c) *) simpl in |- *; intros i l ih a b c forces_abc forces_a forces_b. (* Goal: Suc k'' k *) apply ih with (a := Imp (Atom i) a) (b := Imp (Atom i) b); try assumption. (* Goal: forall (k' : kripke_tree) (_ : Suc k' k) (_ : forces_t2 k k' (Imp (Atom i) a)) (_ : forces_t2 k k' (Imp (Atom i) b)), forces_t2 k k' (Imp (Atom i) c) *) intros k' suc1 forces_ia forces_ib. (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k (Imp a b) *) unfold forces_t in |- *; unfold forces_t2 in |- *; simpl in |- *. (* Goal: forall (k'0 : kripke_tree) (_ : Suc k'0 k) (_ : Suc k'0 k') (_ : forces0_t (Atms k'0) i), forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k'0 b *) intros k'' suc2 suc3 forces_i. (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k'' c *) change (forces_t2 k k'' c) in |- *. (* Goal: forces_t2 k k'' c *) apply forces_abc. (* Goal: Suc k'' k *) assumption. (* Goal: Suc k'' k *) apply (forces_ia k''); assumption. (* Goal: Suc k'' k *) apply (forces_ib k''); assumption. Qed. Lemma forces_vimp0 : forall (k : kripke_tree) (l : list Int) (b : form), (forall k' : kripke_tree, Suc k' k -> forces_t2 k k' b) -> forces_t k (vimp l b). (* Goal: forall (k : kripke_tree) (l : list Int) (b : form) (_ : forall (k' : kripke_tree) (_ : Suc k' k), forces_t2 k k' b), forces_t k (vimp l b) *) intros k l. (* Goal: forall (b : form) (_ : forall (k' : kripke_tree) (_ : Suc k' k), forces_t2 k k' b), forces_t k (vimp l b) *) elim l; clear l. (* Goal: forall (b : form) (_ : forall (k' : kripke_tree) (_ : Suc k' k), forces_t2 k k' b), forces_t k (vimp (@nil Int) b) *) (* Goal: forall (a : Int) (l : list Int) (_ : forall (b : form) (_ : forall (k' : kripke_tree) (_ : Suc k' k), forces_t2 k k' b), forces_t k (vimp l b)) (b : form) (_ : forall (k' : kripke_tree) (_ : Suc k' k), forces_t2 k k' b), forces_t k (vimp (@cons Int a l) b) *) intros b forces_ab. (* Goal: Suc k'' k *) apply forces_ab with (k' := k); try assumption. (* Goal: Suc k k *) (* Goal: forall (a : Int) (l : list Int) (_ : forall (b : form) (_ : forall (k' : kripke_tree) (_ : Suc k' k), forces_t2 k k' b), forces_t k (vimp l b)) (b : form) (_ : forall (k' : kripke_tree) (_ : Suc k' k), forces_t2 k k' b), forces_t k (vimp (@cons Int a l) b) *) unfold Suc in |- *; apply successor_refl. (* Goal: forall (a : Int) (l : list Int) (_ : forall (b : form) (_ : forall (k' : kripke_tree) (_ : Suc k' k), forces_t2 k k' b), forces_t k (vimp l b)) (b : form) (_ : forall (k' : kripke_tree) (_ : Suc k' k), forces_t2 k k' b), forces_t k (vimp (@cons Int a l) b) *) simpl in |- *; intros i l ih b forces_ab. (* Goal: forces_t k (vimp l (Imp (Atom i) b)) *) apply ih. (* Goal: forall (k' : kripke_tree) (_ : Suc k' k), forces_t2 k k' (Imp (Atom i) b) *) intros k' suc1. (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k (Imp a b) *) unfold forces_t in |- *; unfold forces_t2 in |- *; simpl in |- *. (* Goal: forall (k'0 : kripke_tree) (_ : Suc k'0 k) (_ : Suc k'0 k') (_ : forces0_t (Atms k'0) i), forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k'0 b *) intros k'' suc2 suc3 forces_i. (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k'' b *) change (forces_t2 k k'' b) in |- *. (* Goal: forces_t2 k k'' b *) apply forces_ab. (* Goal: Suc k'' k *) assumption. Qed. Lemma forces_a_imp_b_imp_c__forces_a_imp_falsum_imp_c_t2 : forall (k k' : kripke_tree) (a b c : form), Suc k' k -> forces_t2 k k' (Imp (Imp a b) c) -> forces_t2 k k' (Imp (Imp a Falsum) c). (* Goal: forall (k k' : kripke_tree) (a b c : form) (_ : Suc k' k) (_ : forces_t2 k k' (Imp (Imp a b) c)), forces_t2 k k' (Imp (Imp a Falsum) c) *) intros k k' a b c suc1 forces_abc. (* Goal: forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k (Imp a b) *) unfold forces_t in |- *; unfold forces_t2 in |- *; simpl in |- *. (* Goal: forall (k'0 : kripke_tree) (_ : Suc k'0 k) (_ : Suc k'0 k') (_ : forall (k' : kripke_tree) (_ : Suc k' k) (_ : Suc k' k'0) (_ : forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' a), False), forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k'0 c *) intros k'' suc_k' suc_k''. (* Goal: forall _ : forall (k' : kripke_tree) (_ : Suc k' k) (_ : Suc k' k'') (_ : forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' a), False, forces kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k'' c *) change (forces_t2 k k'' (Imp a Falsum) -> forces_t2 k k'' c) in |- *. (* Goal: forall _ : forces_t2 k k'' (Imp a Falsum), forces_t2 k k'' c *) intros forces1. (* Goal: Suc k'' k *) apply (forces_abc k''); try assumption. (* Goal: forall (k' : kripke_tree) (_ : Suc k' k) (_ : Suc k' k'') (_ : (fix forces (A : Set) (World : forall _ : A, Type) (le : forall (_ : A) (_ : A), Type) (forces0 : forall (_ : A) (_ : Int), Prop) (k : A) (a : form) {struct a} : Prop := match a with | Falsum => False | Atom i => forces0 k i | AndF a0 a1 => and (forces A World le forces0 k a0) (forces A World le forces0 k a1) | OrF a0 a1 => or (forces A World le forces0 k a0) (forces A World le forces0 k a1) | Imp a0 a1 => forall (k'0 : A) (_ : World k'0) (_ : le k k'0) (_ : forces A World le forces0 k'0 a0), forces A World le forces0 k'0 a1 end) kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' a), (fix forces (A : Set) (World : forall _ : A, Type) (le : forall (_ : A) (_ : A), Type) (forces0 : forall (_ : A) (_ : Int), Prop) (k : A) (a : form) {struct a} : Prop := match a with | Falsum => False | Atom i => forces0 k i | AndF a0 a1 => and (forces A World le forces0 k a0) (forces A World le forces0 k a1) | OrF a0 a1 => or (forces A World le forces0 k a0) (forces A World le forces0 k a1) | Imp a0 a1 => forall (k'0 : A) (_ : World k'0) (_ : le k k'0) (_ : forces A World le forces0 k'0 a0), forces A World le forces0 k'0 a1 end) kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k' b *) intros k''' suc3 suc4 forces_a. (* Goal: (fix forces (A : Set) (World : forall _ : A, Type) (le : forall (_ : A) (_ : A), Type) (forces0 : forall (_ : A) (_ : Int), Prop) (k : A) (a : form) {struct a} : Prop := match a with | Falsum => False | Atom i => forces0 k i | AndF a0 a1 => and (forces A World le forces0 k a0) (forces A World le forces0 k a1) | OrF a0 a1 => or (forces A World le forces0 k a0) (forces A World le forces0 k a1) | Imp a0 a1 => forall (k' : A) (_ : World k') (_ : le k k') (_ : forces A World le forces0 k' a0), forces A World le forces0 k' a1 end) kripke_tree (fun k0 : kripke_tree => Suc k0 k) (fun k0 k1 : kripke_tree => Suc k1 k0) (fun (k0 : kripke_tree) (i : Int) => forces0_t (Atms k0) i) k''' b *) elimtype False. (* Goal: Suc k'' k *) apply (forces1 k'''); assumption. Qed.
(* File: Disjunct.v (last edited on 27/10/2000) (c) Klaus Weich *) Require Export In_NGamma. Definition a_ai_disj (a : atoms) (ai : atomic_imps) := forall i : Int, LOOKUP unit i a tt -> forall bs : nf_list, LOOKUP nf_list i ai bs -> False. Definition a_goal_disj (a : atoms) (goal : Int) := LOOKUP unit goal a tt -> False. Lemma disjs_insert_ai : forall (i : Int) (b : normal_form) (a : atoms) (ai ai' : atomic_imps), a_ai_disj a ai -> (forall d : unit, ~ LOOKUP unit i a d) -> EQUIV_INS nf_list i (cons b) nf_nil ai ai' -> a_ai_disj a ai'. (* Goal: forall (i : Int) (b : normal_form) (a : atoms) (ai ai' : atomic_imps) (_ : a_ai_disj a ai) (_ : forall d : unit, not (LOOKUP unit i a d)) (_ : EQUIV_INS nf_list i (@cons normal_form b) nf_nil ai ai'), a_ai_disj a ai' *) intros i b a ai ai'. (* Goal: forall (_ : a_ai_disj a ai) (_ : EQUIV_INS unit i (fun _ : unit => tt) tt a a') (_ : forall bs : nf_list, not (LOOKUP nf_list i ai bs)), a_ai_disj a' ai *) elim a; clear a; intros a avl_a. (* Goal: forall (_ : a_ai_disj (AVL_intro unit a avl_a) ai) (_ : EQUIV_INS unit i (fun _ : unit => tt) tt (AVL_intro unit a avl_a) (AVL_intro unit a' avl_a')) (_ : forall bs : nf_list, not (LOOKUP nf_list i ai bs)), a_ai_disj (AVL_intro unit a' avl_a') ai *) elim ai; clear ai; intros ai avl_ai. (* Goal: forall (_ : a_ai_disj (AVL_intro unit a avl_a) (AVL_intro nf_list ai avl_ai)) (_ : EQUIV_INS unit i (fun _ : unit => tt) tt (AVL_intro unit a avl_a) (AVL_intro unit a' avl_a')) (_ : EQUIV_DEL nf_list i (AVL_intro nf_list ai avl_ai) ai'), a_ai_disj (AVL_intro unit a' avl_a') ai' *) elim ai'; clear ai'; intros ai' avl_ai'. (* Goal: forall (_ : a_ai_disj (AVL_intro unit a avl_a) (AVL_intro nf_list ai avl_ai)) (_ : EQUIV_INS unit i (fun _ : unit => tt) tt (AVL_intro unit a avl_a) (AVL_intro unit a' avl_a')) (_ : forall bs : nf_list, not (LOOKUP nf_list i (AVL_intro nf_list ai avl_ai) bs)), a_ai_disj (AVL_intro unit a' avl_a') (AVL_intro nf_list ai avl_ai) *) unfold a_ai_disj in |- *. (* Goal: forall (_ : forall (i : Int) (_ : LOOKUP unit i (AVL_intro unit a avl_a) tt) (bs : nf_list) (_ : LOOKUP nf_list i (AVL_intro nf_list ai avl_ai) bs), False) (_ : EQUIV_INS unit i (fun _ : unit => tt) tt (AVL_intro unit a avl_a) (AVL_intro unit a' avl_a')) (_ : forall bs : nf_list, not (LOOKUP nf_list i (AVL_intro nf_list ai avl_ai) bs)) (i : Int) (_ : LOOKUP unit i (AVL_intro unit a' avl_a') tt) (bs : nf_list) (_ : LOOKUP nf_list i (AVL_intro nf_list ai avl_ai) bs), False *) simpl in |- *. (* Goal: forall (_ : forall (i : Int) (_ : lookup unit i a tt) (bs : nf_list) (_ : lookup nf_list i ai bs), False) (_ : forall d : unit, not (lookup unit i a d)) (_ : equiv_ins nf_list i (@cons normal_form b) nf_nil ai ai') (i : Int) (_ : lookup unit i a tt) (bs : nf_list) (_ : lookup nf_list i ai' bs), False *) intros a_ai_disj0 not_lookup_i equiv_ins j lookup_j bs lookup_bs. (* Goal: False *) elim (equal_dec j i). (* Goal: forall _ : Equal j i, False *) (* Goal: forall _ : not (Equal j i), False *) intros equal_ji. (* Goal: False *) (* Goal: forall _ : not (Equal j i), False *) apply (not_lookup_i tt). (* Goal: lookup unit i a tt *) (* Goal: forall _ : not (Equal j i), False *) rewrite <- (equal_eq j i); assumption. (* Goal: forall _ : not (Equal j i), False *) intros not_equal_ji. (* Goal: False *) apply a_ai_disj0 with j bs; clear a_ai_disj0; try assumption. (* Goal: lookup unit i0 a tt *) (* Goal: lookup nf_list i0 ai bs0 *) inversion_clear equiv_ins. (* Goal: lookup unit i0 a tt *) (* Goal: lookup nf_list i0 ai bs0 *) apply H2; assumption. Qed. Lemma disjs_delete_ai : forall (i : Int) (a a' : atoms) (ai ai' : atomic_imps), a_ai_disj a ai -> EQUIV_INS unit i (fun _ : unit => tt) tt a a' -> EQUIV_DEL nf_list i ai ai' -> a_ai_disj a' ai'. (* Goal: forall (i : Int) (a a' : atoms) (ai ai' : atomic_imps) (_ : a_ai_disj a ai) (_ : EQUIV_INS unit i (fun _ : unit => tt) tt a a') (_ : EQUIV_DEL nf_list i ai ai'), a_ai_disj a' ai' *) intros i a a' ai ai'. (* Goal: forall (_ : a_ai_disj a ai) (_ : EQUIV_INS unit i (fun _ : unit => tt) tt a a') (_ : forall bs : nf_list, not (LOOKUP nf_list i ai bs)), a_ai_disj a' ai *) elim a; clear a; intros a avl_a. (* Goal: forall (_ : a_ai_disj (AVL_intro unit a avl_a) ai) (_ : EQUIV_INS unit i (fun _ : unit => tt) tt (AVL_intro unit a avl_a) a') (_ : forall bs : nf_list, not (LOOKUP nf_list i ai bs)), a_ai_disj a' ai *) elim a'; clear a'; intros a' avl_a'. (* Goal: forall (_ : a_ai_disj (AVL_intro unit a avl_a) ai) (_ : EQUIV_INS unit i (fun _ : unit => tt) tt (AVL_intro unit a avl_a) (AVL_intro unit a' avl_a')) (_ : forall bs : nf_list, not (LOOKUP nf_list i ai bs)), a_ai_disj (AVL_intro unit a' avl_a') ai *) elim ai; clear ai; intros ai avl_ai. (* Goal: forall (_ : a_ai_disj (AVL_intro unit a avl_a) (AVL_intro nf_list ai avl_ai)) (_ : EQUIV_INS unit i (fun _ : unit => tt) tt (AVL_intro unit a avl_a) (AVL_intro unit a' avl_a')) (_ : EQUIV_DEL nf_list i (AVL_intro nf_list ai avl_ai) ai'), a_ai_disj (AVL_intro unit a' avl_a') ai' *) elim ai'; clear ai'; intros ai' avl_ai'. (* Goal: forall (_ : a_ai_disj (AVL_intro unit a avl_a) (AVL_intro nf_list ai avl_ai)) (_ : EQUIV_INS unit i (fun _ : unit => tt) tt (AVL_intro unit a avl_a) (AVL_intro unit a' avl_a')) (_ : forall bs : nf_list, not (LOOKUP nf_list i (AVL_intro nf_list ai avl_ai) bs)), a_ai_disj (AVL_intro unit a' avl_a') (AVL_intro nf_list ai avl_ai) *) unfold a_ai_disj in |- *. (* Goal: forall (_ : forall (i : Int) (_ : LOOKUP unit i (AVL_intro unit a avl_a) tt) (bs : nf_list) (_ : LOOKUP nf_list i (AVL_intro nf_list ai avl_ai) bs), False) (_ : EQUIV_INS unit i (fun _ : unit => tt) tt (AVL_intro unit a avl_a) (AVL_intro unit a' avl_a')) (_ : forall bs : nf_list, not (LOOKUP nf_list i (AVL_intro nf_list ai avl_ai) bs)) (i : Int) (_ : LOOKUP unit i (AVL_intro unit a' avl_a') tt) (bs : nf_list) (_ : LOOKUP nf_list i (AVL_intro nf_list ai avl_ai) bs), False *) simpl in |- *. (* Goal: forall (_ : forall (i : Int) (_ : lookup unit i a tt) (bs : nf_list) (_ : lookup nf_list i ai bs), False) (_ : equiv_ins unit i (fun _ : unit => tt) tt a a') (_ : equiv_del nf_list i ai ai') (i : Int) (_ : lookup unit i a' tt) (bs : nf_list) (_ : lookup nf_list i ai' bs), False *) intros a_ai_disj0 equiv_ins equiv_del i0 lookup_j bs0 lookup_bs0. (* Goal: False *) elim (equal_dec i0 i). (* Goal: forall _ : Equal i0 i, False *) (* Goal: forall _ : not (Equal i0 i), False *) intro equal_i. (* Goal: lookup nf_list i0 ai bs0 *) inversion_clear equiv_del. (* Goal: False *) (* Goal: forall _ : not (Equal i0 i), False *) apply H with i0 bs0; assumption. (* Goal: forall _ : not (Equal i0 i), False *) intros not_equal_i. (* Goal: False *) apply a_ai_disj0 with i0 bs0. (* Goal: lookup unit i0 a tt *) (* Goal: lookup nf_list i0 ai bs0 *) inversion_clear equiv_ins. (* Goal: lookup unit i0 a tt *) (* Goal: lookup nf_list i0 ai bs0 *) apply H2; assumption. (* Goal: lookup nf_list i0 ai bs0 *) inversion_clear equiv_del. (* Goal: lookup nf_list i0 ai bs0 *) apply H1; assumption. Qed. Lemma goal_disj_insert_a : forall (i goal : Int) (a a' : atoms), a_goal_disj a goal -> (Equal goal i -> False) -> EQUIV_INS unit i (fun _ : unit => tt) tt a a' -> a_goal_disj a' goal. (* Goal: forall (i goal : Int) (a a' : atoms) (_ : a_goal_disj a goal) (_ : forall _ : Equal goal i, False) (_ : EQUIV_INS unit i (fun _ : unit => tt) tt a a'), a_goal_disj a' goal *) intros i goal a a'. (* Goal: forall (_ : a_ai_disj a ai) (_ : EQUIV_INS unit i (fun _ : unit => tt) tt a a') (_ : forall bs : nf_list, not (LOOKUP nf_list i ai bs)), a_ai_disj a' ai *) elim a; clear a; intros a avl_a. (* Goal: forall (_ : a_ai_disj (AVL_intro unit a avl_a) ai) (_ : EQUIV_INS unit i (fun _ : unit => tt) tt (AVL_intro unit a avl_a) a') (_ : forall bs : nf_list, not (LOOKUP nf_list i ai bs)), a_ai_disj a' ai *) elim a'; clear a'; intros a' avl_a'. (* Goal: forall (_ : a_goal_disj (AVL_intro unit a avl_a) goal) (_ : forall _ : Equal goal i, False) (_ : EQUIV_INS unit i (fun _ : unit => tt) tt (AVL_intro unit a avl_a) (AVL_intro unit a' avl_a')), a_goal_disj (AVL_intro unit a' avl_a') goal *) unfold a_goal_disj in |- *. (* Goal: forall (_ : forall (i : Int) (_ : LOOKUP unit i (AVL_intro unit a avl_a) tt) (bs : nf_list) (_ : LOOKUP nf_list i (AVL_intro nf_list ai avl_ai) bs), False) (_ : EQUIV_INS unit i (fun _ : unit => tt) tt (AVL_intro unit a avl_a) (AVL_intro unit a' avl_a')) (_ : forall bs : nf_list, not (LOOKUP nf_list i (AVL_intro nf_list ai avl_ai) bs)) (i : Int) (_ : LOOKUP unit i (AVL_intro unit a' avl_a') tt) (bs : nf_list) (_ : LOOKUP nf_list i (AVL_intro nf_list ai avl_ai) bs), False *) simpl in |- *. (* Goal: forall (_ : forall _ : lookup unit goal a tt, False) (_ : forall _ : Equal goal i, False) (_ : equiv_ins unit i (fun _ : unit => tt) tt a a') (_ : lookup unit goal a' tt), False *) intros a_goal_disj0 not_equal equiv_ins lookup. (* Goal: False *) apply a_goal_disj0. (* Goal: lookup unit i0 a tt *) (* Goal: lookup nf_list i0 ai bs0 *) inversion_clear equiv_ins. (* Goal: lookup unit i0 a tt *) (* Goal: lookup nf_list i0 ai bs0 *) apply H2; assumption. Qed. Lemma disjs_insert_a : forall (i : Int) (a a' : atoms) (ai : atomic_imps), a_ai_disj a ai -> EQUIV_INS unit i (fun _ : unit => tt) tt a a' -> (forall bs : nf_list, ~ LOOKUP nf_list i ai bs) -> a_ai_disj a' ai. (* Goal: forall (i : Int) (a a' : atoms) (ai : atomic_imps) (_ : a_ai_disj a ai) (_ : EQUIV_INS unit i (fun _ : unit => tt) tt a a') (_ : forall bs : nf_list, not (LOOKUP nf_list i ai bs)), a_ai_disj a' ai *) intros i a a' ai. (* Goal: forall (_ : a_ai_disj a ai) (_ : EQUIV_INS unit i (fun _ : unit => tt) tt a a') (_ : forall bs : nf_list, not (LOOKUP nf_list i ai bs)), a_ai_disj a' ai *) elim a; clear a; intros a avl_a. (* Goal: forall (_ : a_ai_disj (AVL_intro unit a avl_a) ai) (_ : EQUIV_INS unit i (fun _ : unit => tt) tt (AVL_intro unit a avl_a) a') (_ : forall bs : nf_list, not (LOOKUP nf_list i ai bs)), a_ai_disj a' ai *) elim a'; clear a'; intros a' avl_a'. (* Goal: forall (_ : a_ai_disj (AVL_intro unit a avl_a) ai) (_ : EQUIV_INS unit i (fun _ : unit => tt) tt (AVL_intro unit a avl_a) (AVL_intro unit a' avl_a')) (_ : forall bs : nf_list, not (LOOKUP nf_list i ai bs)), a_ai_disj (AVL_intro unit a' avl_a') ai *) elim ai; clear ai; intros ai avl_ai. (* Goal: forall (_ : a_ai_disj (AVL_intro unit a avl_a) (AVL_intro nf_list ai avl_ai)) (_ : EQUIV_INS unit i (fun _ : unit => tt) tt (AVL_intro unit a avl_a) (AVL_intro unit a' avl_a')) (_ : forall bs : nf_list, not (LOOKUP nf_list i (AVL_intro nf_list ai avl_ai) bs)), a_ai_disj (AVL_intro unit a' avl_a') (AVL_intro nf_list ai avl_ai) *) unfold a_ai_disj in |- *. (* Goal: forall (_ : forall (i : Int) (_ : LOOKUP unit i (AVL_intro unit a avl_a) tt) (bs : nf_list) (_ : LOOKUP nf_list i (AVL_intro nf_list ai avl_ai) bs), False) (_ : EQUIV_INS unit i (fun _ : unit => tt) tt (AVL_intro unit a avl_a) (AVL_intro unit a' avl_a')) (_ : forall bs : nf_list, not (LOOKUP nf_list i (AVL_intro nf_list ai avl_ai) bs)) (i : Int) (_ : LOOKUP unit i (AVL_intro unit a' avl_a') tt) (bs : nf_list) (_ : LOOKUP nf_list i (AVL_intro nf_list ai avl_ai) bs), False *) simpl in |- *. (* Goal: forall (_ : forall (i : Int) (_ : lookup unit i a tt) (bs : nf_list) (_ : lookup nf_list i ai bs), False) (_ : equiv_ins unit i (fun _ : unit => tt) tt a a') (_ : forall bs : nf_list, not (lookup nf_list i ai bs)) (i : Int) (_ : lookup unit i a' tt) (bs : nf_list) (_ : lookup nf_list i ai bs), False *) intros a_ai_disj0 equiv_ins not_lookup_bs i0 lookup_j bs0 lookup_bs0. (* Goal: False *) elim (equal_dec i0 i). (* Goal: forall _ : Equal i0 i, False *) (* Goal: forall _ : not (Equal i0 i), False *) intro equal_i. (* Goal: False *) (* Goal: forall _ : not (Equal i0 i), False *) apply (not_lookup_bs bs0). (* Goal: lookup nf_list i ai bs0 *) (* Goal: forall _ : not (Equal i0 i), False *) rewrite <- (equal_eq i0 i); assumption. (* Goal: forall _ : not (Equal i0 i), False *) intros not_equal_i. (* Goal: False *) apply a_ai_disj0 with i0 bs0. (* Goal: lookup unit i0 a tt *) (* Goal: lookup nf_list i0 ai bs0 *) inversion_clear equiv_ins. (* Goal: lookup unit i0 a tt *) (* Goal: lookup nf_list i0 ai bs0 *) apply H2; assumption. (* Goal: lookup nf_list i0 ai bs0 *) assumption. Qed.
(* File: My_Nth.v (last edited on 25/10/2000) (c) Klaus Weich *) Require Export List. Require Export Plus. Section My_Nth. Variable B : Set. Inductive my_nth : nat -> list B -> B -> Prop := | My_NthO : forall (l : list B) (a : B), my_nth 0 (a :: l) a | My_NthS : forall (n : nat) (l : list B) (b : B), my_nth n l b -> forall a : B, my_nth (S n) (a :: l) b. Lemma inv_nth_nil : forall (n : nat) (a : B), my_nth n nil a -> False. (* Goal: forall (n : nat) (l : list B) (b : B) (_ : my_nth n l b) (_ : @In B b l) (a : B), @In B b (@cons B a l) *) intros. (* Goal: my_nth n l b *) inversion H. Qed. Lemma inv_nthO : forall (a : B) (l : list B) (b : B), my_nth 0 (a :: l) b -> a = b. (* Goal: forall (n : nat) (l : list B) (b : B) (_ : my_nth n l b) (_ : @In B b l) (a : B), @In B b (@cons B a l) *) intros. (* Goal: my_nth n l b *) inversion H. (* Goal: @eq B b b *) trivial. Qed. Lemma inv_nthS : forall (n : nat) (a : B) (l : list B) (b : B), my_nth (S n) (a :: l) b -> my_nth n l b. (* Goal: forall (n : nat) (l : list B) (b : B) (_ : my_nth n l b) (_ : @In B b l) (a : B), @In B b (@cons B a l) *) intros. (* Goal: my_nth n l b *) inversion H. (* Goal: my_nth n l1 a *) (* Goal: forall (a0 : B) (l : list B) (_ : forall (n : nat) (_ : my_nth n (@app B l l1) a), inv_my_nth_app n l l1 a) (n : nat) (_ : my_nth n (@cons B a0 (@app B l l1)) a), inv_my_nth_app n (@cons B a0 l) l1 a *) assumption. Qed. Lemma my_nth_rec : forall P : nat -> list B -> B -> Set, (forall (l : list B) (a : B), P 0 (a :: l) a) -> (forall (n : nat) (l : list B) (b : B), my_nth n l b -> P n l b -> forall a : B, P (S n) (a :: l) b) -> forall (n : nat) (l : list B) (y : B), my_nth n l y -> P n l y. (* Goal: forall (P : forall (_ : nat) (_ : list B) (_ : B), Set) (_ : forall (l : list B) (a : B), P O (@cons B a l) a) (_ : forall (n : nat) (l : list B) (b : B) (_ : my_nth n l b) (_ : P n l b) (a : B), P (S n) (@cons B a l) b) (n : nat) (l : list B) (y : B) (_ : my_nth n l y), P n l y *) intros P base step n. (* Goal: forall (l : list B) (y : B) (_ : my_nth n l y), P n l y *) elim n; clear n. (* Goal: forall (l : list B) (y : B) (_ : my_nth O l y), P O l y *) (* Goal: forall (n : nat) (_ : forall (l : list B) (y : B) (_ : my_nth n l y), P n l y) (l : list B) (y : B) (_ : my_nth (S n) l y), P (S n) l y *) intros l; case l; clear l. (* Goal: forall (y : B) (_ : my_nth (S n) (@nil B) y), P (S n) (@nil B) y *) (* Goal: forall (b : B) (l : list B) (y : B) (_ : my_nth (S n) (@cons B b l) y), P (S n) (@cons B b l) y *) intros y nth; elimtype False. (* Goal: False *) (* Goal: forall (b : B) (l : list B) (y : B) (_ : my_nth O (@cons B b l) y), P O (@cons B b l) y *) (* Goal: forall (n : nat) (_ : forall (l : list B) (y : B) (_ : my_nth n l y), P n l y) (l : list B) (y : B) (_ : my_nth (S n) l y), P (S n) l y *) apply (inv_nth_nil 0 y nth). (* Goal: forall (b : B) (l : list B) (y : B) (_ : my_nth (S n) (@cons B b l) y), P (S n) (@cons B b l) y *) intros a l b nth. (* Goal: P O (@cons B a l) b *) (* Goal: forall (n : nat) (_ : forall (l : list B) (y : B) (_ : my_nth n l y), P n l y) (l : list B) (y : B) (_ : my_nth (S n) l y), P (S n) l y *) rewrite (inv_nthO a l b nth). (* Goal: P O (@cons B b l) b *) (* Goal: forall (n : nat) (_ : forall (l : list B) (y : B) (_ : my_nth n l y), P n l y) (l : list B) (y : B) (_ : my_nth (S n) l y), P (S n) l y *) apply base. (* Goal: forall (n : nat) (_ : forall (l : list B) (y : B) (_ : my_nth n l y), P n l y) (l : list B) (y : B) (_ : my_nth (S n) l y), P (S n) l y *) intros n ih l. (* Goal: forall _ : my_nth (S n) l a, nth_split a l *) case l; clear l. (* Goal: forall (y : B) (_ : my_nth (S n) (@nil B) y), P (S n) (@nil B) y *) (* Goal: forall (b : B) (l : list B) (y : B) (_ : my_nth (S n) (@cons B b l) y), P (S n) (@cons B b l) y *) intros y nth; elimtype False. (* Goal: False *) (* Goal: forall (b : B) (l : list B) (y : B) (_ : my_nth (S n) (@cons B b l) y), P (S n) (@cons B b l) y *) apply (inv_nth_nil (S n) y nth). (* Goal: forall (b : B) (l : list B) (y : B) (_ : my_nth (S n) (@cons B b l) y), P (S n) (@cons B b l) y *) intros a l b nth. (* Goal: P (S n) (@cons B a l) b *) apply step. (* Goal: my_nth n l b *) apply (inv_nthS n a l b nth). (* Goal: my_nth (Nat.add (@length B l0) n) (@app B l0 l1) a *) apply ih. (* Goal: my_nth n l b *) apply (inv_nthS n a l b nth). Qed. Lemma nth_in : forall (n : nat) (l : list B) (a : B), my_nth n l a -> In a l. (* Goal: forall (n : nat) (l : list B) (a : B) (_ : my_nth n l a), @In B a l *) intros n l a nth. (* Goal: @In B a l *) elim nth; clear nth. (* Goal: forall (n : nat) (l : list B) (b : B) (_ : my_nth n l b) (_ : @In B b l) (a : B), @In B b (@cons B a l) *) intros. (* Goal: @eq B b b *) simpl in |- *; left; trivial. (* Goal: forall (n : nat) (l : list B) (b : B) (_ : my_nth n l b) (_ : @In B b l) (a : B), @In B b (@cons B a l) *) intros. (* Goal: my_nth n l1 a *) (* Goal: forall (a0 : B) (l : list B) (_ : forall (n : nat) (_ : my_nth n (@app B l l1) a), inv_my_nth_app n l l1 a) (n : nat) (_ : my_nth n (@cons B a0 (@app B l l1)) a), inv_my_nth_app n (@cons B a0 l) l1 a *) simpl in |- *; right; assumption. Qed. Lemma nth_app0 : forall (n : nat) (l0 l1 : list B) (a : B), my_nth n l0 a -> my_nth n (l0 ++ l1) a. (* Goal: forall (n : nat) (l0 l1 : list B) (a : B) (_ : my_nth n l0 a), my_nth n (@app B l0 l1) a *) intros n l0. (* Goal: forall _ : my_nth n (@app B l0 l1) a, inv_my_nth_app n l0 l1 a *) generalize n; clear n. (* Goal: forall (n : nat) (l1 : list B) (a : B) (_ : my_nth n l0 a), my_nth n (@app B l0 l1) a *) elim l0; clear l0. (* Goal: forall (n : nat) (l1 : list B) (a : B) (_ : my_nth n (@nil B) a), my_nth n (@app B (@nil B) l1) a *) (* Goal: forall (a : B) (l : list B) (_ : forall (n : nat) (l1 : list B) (a0 : B) (_ : my_nth n l a0), my_nth n (@app B l l1) a0) (n : nat) (l1 : list B) (a0 : B) (_ : my_nth n (@cons B a l) a0), my_nth n (@app B (@cons B a l) l1) a0 *) intros n l1 a nth; elimtype False. (* Goal: False *) (* Goal: forall (a : B) (l : list B) (_ : forall (n : nat) (l1 : list B) (a0 : B) (_ : my_nth n l a0), my_nth n (@app B l l1) a0) (n : nat) (l1 : list B) (a0 : B) (_ : my_nth n (@cons B a l) a0), my_nth n (@app B (@cons B a l) l1) a0 *) apply (inv_nth_nil n a nth). (* Goal: forall (a : B) (l : list B) (_ : forall (n : nat) (l1 : list B) (a0 : B) (_ : my_nth n l a0), my_nth n (@app B l l1) a0) (n : nat) (l1 : list B) (a0 : B) (_ : my_nth n (@cons B a l) a0), my_nth n (@app B (@cons B a l) l1) a0 *) intros a0 l0 ih n. (* Goal: forall _ : my_nth n (@cons B a0 (@app B l0 l1)) a, inv_my_nth_app n (@cons B a0 l0) l1 a *) case n; clear n. (* Goal: forall (l1 : list B) (a : B) (_ : my_nth O (@cons B a0 l0) a), my_nth O (@app B (@cons B a0 l0) l1) a *) (* Goal: forall (n : nat) (l1 : list B) (a : B) (_ : my_nth (S n) (@cons B a0 l0) a), my_nth (S n) (@app B (@cons B a0 l0) l1) a *) intros l1 a nth. (* Goal: my_nth O (@app B (@cons B a0 l0) l1) a *) (* Goal: forall (n : nat) (l1 : list B) (a : B) (_ : my_nth (S n) (@cons B a0 l0) a), my_nth (S n) (@app B (@cons B a0 l0) l1) a *) rewrite (inv_nthO a0 l0 a nth). (* Goal: my_nth O (@app B (@cons B a l0) l1) a *) (* Goal: forall (n : nat) (l1 : list B) (a : B) (_ : my_nth (S n) (@cons B a0 l0) a), my_nth (S n) (@app B (@cons B a0 l0) l1) a *) simpl in |- *; apply My_NthO. (* Goal: forall (n : nat) (l1 : list B) (a : B) (_ : my_nth (S n) (@cons B a0 l0) a), my_nth (S n) (@app B (@cons B a0 l0) l1) a *) intros n l1 a nth. (* Goal: my_nth (S n) (@app B (@cons B a0 l0) l1) a *) simpl in |- *; apply My_NthS. (* Goal: my_nth (Nat.add (@length B l0) n) (@app B l0 l1) a *) apply ih. (* Goal: my_nth n l0 a *) apply (inv_nthS n a0 l0 a nth). Qed. Lemma nth_app1 : forall (n : nat) (l0 l1 : list B) (a : B), my_nth n l1 a -> my_nth (length l0 + n) (l0 ++ l1) a. (* Goal: forall (n : nat) (l1 : list B) (a : B) (_ : my_nth n l0 a), my_nth n (@app B l0 l1) a *) intros n l0; elim l0; clear l0. (* Goal: @eq B b b *) simpl in |- *; trivial. (* Goal: forall (a : B) (l : list B) (_ : forall (l1 : list B) (a0 : B) (_ : my_nth n l1 a0), my_nth (Nat.add (@length B l) n) (@app B l l1) a0) (l1 : list B) (a0 : B) (_ : my_nth n l1 a0), my_nth (Nat.add (@length B (@cons B a l)) n) (@app B (@cons B a l) l1) a0 *) intros a0 l0 ih l1 a nth. (* Goal: my_nth (Nat.add (@length B (@cons B a0 l0)) n) (@app B (@cons B a0 l0) l1) a *) simpl in |- *. (* Goal: my_nth (S (Nat.add (@length B l0) n)) (@cons B a0 (@app B l0 l1)) a *) apply My_NthS. (* Goal: my_nth (Nat.add (@length B l0) n) (@app B l0 l1) a *) apply ih. (* Goal: my_nth n l1 a *) (* Goal: forall (a0 : B) (l : list B) (_ : forall (n : nat) (_ : my_nth n (@app B l l1) a), inv_my_nth_app n l l1 a) (n : nat) (_ : my_nth n (@cons B a0 (@app B l l1)) a), inv_my_nth_app n (@cons B a0 l) l1 a *) assumption. Qed. Inductive inv_my_nth_app (n : nat) (l0 l1 : list B) (a : B) : Set := | Inv_Nth_App0 : my_nth n l0 a -> inv_my_nth_app n l0 l1 a | Inv_Nth_App1 : forall n' : nat, my_nth n' l1 a -> inv_my_nth_app n l0 l1 a. Lemma inv_nth_app : forall (n : nat) (l0 l1 : list B) (a : B), my_nth n (l0 ++ l1) a -> inv_my_nth_app n l0 l1 a. (* Goal: forall (n : nat) (l0 l1 : list B) (a : B) (_ : my_nth n (@app B l0 l1) a), inv_my_nth_app n l0 l1 a *) intros n l0 l1 a. (* Goal: forall _ : my_nth n (@app B l0 l1) a, inv_my_nth_app n l0 l1 a *) generalize n; clear n. (* Goal: my_nth (Nat.add (@length B (@cons B a0 l0)) n) (@app B (@cons B a0 l0) l1) a *) elim l0; clear l0; simpl in |- *. (* Goal: forall (x : nat) (_ : my_nth x l b), @ex nat (fun n : nat => my_nth n (@cons B a l) b) *) intros n nth. (* Goal: inv_my_nth_app n (@nil B) l1 a *) (* Goal: forall (a0 : B) (l : list B) (_ : forall (n : nat) (_ : my_nth n (@app B l l1) a), inv_my_nth_app n l l1 a) (n : nat) (_ : my_nth n (@cons B a0 (@app B l l1)) a), inv_my_nth_app n (@cons B a0 l) l1 a *) right with n. (* Goal: my_nth n l1 a *) (* Goal: forall (a0 : B) (l : list B) (_ : forall (n : nat) (_ : my_nth n (@app B l l1) a), inv_my_nth_app n l l1 a) (n : nat) (_ : my_nth n (@cons B a0 (@app B l l1)) a), inv_my_nth_app n (@cons B a0 l) l1 a *) assumption. (* Goal: forall (a0 : B) (l : list B) (_ : forall (n : nat) (_ : my_nth n (@app B l l1) a), inv_my_nth_app n l l1 a) (n : nat) (_ : my_nth n (@cons B a0 (@app B l l1)) a), inv_my_nth_app n (@cons B a0 l) l1 a *) intros a0 l0 ih_l0 n. (* Goal: forall _ : my_nth n (@cons B a0 (@app B l0 l1)) a, inv_my_nth_app n (@cons B a0 l0) l1 a *) case n; clear n. (* Goal: forall _ : my_nth O (@cons B a0 (@app B l0 l1)) a, inv_my_nth_app O (@cons B a0 l0) l1 a *) (* Goal: forall (n : nat) (_ : my_nth (S n) (@cons B a0 (@app B l0 l1)) a), inv_my_nth_app (S n) (@cons B a0 l0) l1 a *) intros nth. (* Goal: inv_my_nth_app (S n) (@cons B a0 l0) l1 a *) (* Goal: forall (n' : nat) (_ : my_nth n' l1 a), inv_my_nth_app (S n) (@cons B a0 l0) l1 a *) (* Goal: my_nth n (@app B l0 l1) a *) left. (* Goal: my_nth O (@cons B a0 l0) a *) (* Goal: forall (n : nat) (_ : my_nth (S n) (@cons B a0 (@app B l0 l1)) a), inv_my_nth_app (S n) (@cons B a0 l0) l1 a *) rewrite (inv_nthO a0 (l0 ++ l1) a nth). (* Goal: my_nth O (@cons B b l) b *) (* Goal: @ex nat (fun n : nat => my_nth n (@cons B a l) b) *) apply My_NthO. (* Goal: forall (x : nat) (_ : my_nth x l b), @ex nat (fun n : nat => my_nth n (@cons B a l) b) *) intros n nth. (* Goal: inv_my_nth_app (S n) (@cons B a0 l0) l1 a *) elim (ih_l0 n). (* Goal: forall _ : my_nth n l0 a, inv_my_nth_app (S n) (@cons B a0 l0) l1 a *) (* Goal: forall (n' : nat) (_ : my_nth n' l1 a), inv_my_nth_app (S n) (@cons B a0 l0) l1 a *) (* Goal: my_nth n (@app B l0 l1) a *) intros nth_l0. (* Goal: inv_my_nth_app (S n) (@cons B a0 l0) l1 a *) (* Goal: forall (n' : nat) (_ : my_nth n' l1 a), inv_my_nth_app (S n) (@cons B a0 l0) l1 a *) (* Goal: my_nth n (@app B l0 l1) a *) left. (* Goal: my_nth n l1 a *) (* Goal: forall (a0 : B) (l : list B) (_ : forall (n : nat) (_ : my_nth n (@app B l l1) a), inv_my_nth_app n l l1 a) (n : nat) (_ : my_nth n (@cons B a0 (@app B l l1)) a), inv_my_nth_app n (@cons B a0 l) l1 a *) apply My_NthS; assumption. (* Goal: forall (n' : nat) (_ : my_nth n' l1 a), inv_my_nth_app (S n) (@cons B a0 l0) l1 a *) (* Goal: my_nth n (@app B l0 l1) a *) intros n' nth_l1. (* Goal: my_nth n l1 a *) (* Goal: forall (a0 : B) (l : list B) (_ : forall (n : nat) (_ : my_nth n (@app B l l1) a), inv_my_nth_app n l l1 a) (n : nat) (_ : my_nth n (@cons B a0 (@app B l l1)) a), inv_my_nth_app n (@cons B a0 l) l1 a *) right with n'; assumption. (* Goal: my_nth n l1 a *) (* Goal: forall (a0 : B) (l : list B) (_ : forall (n : nat) (_ : my_nth n (@app B l l1) a), inv_my_nth_app n l l1 a) (n : nat) (_ : my_nth n (@cons B a0 (@app B l l1)) a), inv_my_nth_app n (@cons B a0 l) l1 a *) apply inv_nthS with a0; assumption. Qed. Inductive nth_split (a : B) (l : list B) : Set := Nth_Split_Intro : forall l1 l2 : list B, l = l1 ++ a :: l2 -> nth_split a l. Lemma my_nth_split : forall (n : nat) (l : list B) (a : B), my_nth n l a -> nth_split a l. (* Goal: forall (l : list B) (y : B) (_ : my_nth n l y), P n l y *) intros n; elim n; clear n. (* Goal: forall (l : list B) (a : B) (_ : my_nth O l a), nth_split a l *) (* Goal: forall (n : nat) (_ : forall (l : list B) (a : B) (_ : my_nth n l a), nth_split a l) (l : list B) (a : B) (_ : my_nth (S n) l a), nth_split a l *) intros l a nth. (* Goal: nth_split a l *) (* Goal: forall (n : nat) (_ : forall (l : list B) (a : B) (_ : my_nth n l a), nth_split a l) (l : list B) (a : B) (_ : my_nth (S n) l a), nth_split a l *) apply Nth_Split_Intro with (nil (A:=B)) (tail l). (* Goal: @eq (list B) l (@app B (@nil B) (@cons B a (@tl B l))) *) (* Goal: forall (n : nat) (_ : forall (l : list B) (a : B) (_ : my_nth n l a), nth_split a l) (l : list B) (a : B) (_ : my_nth (S n) l a), nth_split a l *) inversion_clear nth. (* Goal: @eq B b b *) simpl in |- *; trivial. (* Goal: forall (n : nat) (_ : forall (l : list B) (a : B) (_ : my_nth n l a), nth_split a l) (l : list B) (a : B) (_ : my_nth (S n) l a), nth_split a l *) intros n ih l a. (* Goal: forall _ : my_nth (S n) l a, nth_split a l *) case l; clear l. (* Goal: @eq (list B) l (@app B (@nil B) (@cons B a (@tl B l))) *) (* Goal: forall (n : nat) (_ : forall (l : list B) (a : B) (_ : my_nth n l a), nth_split a l) (l : list B) (a : B) (_ : my_nth (S n) l a), nth_split a l *) intros nth; elimtype False; inversion_clear nth. (* Goal: forall (b : B) (l : list B) (_ : my_nth (S n) (@cons B b l) a), nth_split a (@cons B b l) *) intros a0 l nth. (* Goal: nth_split a (@cons B a0 l) *) elim (ih l a); clear ih. (* Goal: forall (l1 l2 : list B) (_ : @eq (list B) l (@app B l1 (@cons B a l2))), nth_split a (@cons B a0 l) *) (* Goal: my_nth n l a *) intros l1 l2 H. (* Goal: nth_split a (@cons B a0 l) *) (* Goal: my_nth n l a *) apply Nth_Split_Intro with (a0 :: l1) l2. (* Goal: @eq B b b *) rewrite H; simpl in |- *; trivial. (* Goal: my_nth n l1 a *) (* Goal: forall (a0 : B) (l : list B) (_ : forall (n : nat) (_ : my_nth n (@app B l l1) a), inv_my_nth_app n l l1 a) (n : nat) (_ : my_nth n (@cons B a0 (@app B l l1)) a), inv_my_nth_app n (@cons B a0 l) l1 a *) inversion_clear nth; assumption. Qed. Lemma in_nth : forall (a : B) (l : list B), In a l -> exists n : nat, my_nth n l a. (* Goal: forall (a : B) (l : list B) (_ : @In B a l), @ex nat (fun n : nat => my_nth n l a) *) intros b l; elim l; clear l. (* Goal: forall _ : @In B b (@nil B), @ex nat (fun n : nat => my_nth n (@nil B) b) *) (* Goal: forall (a : B) (l : list B) (_ : forall _ : @In B b l, @ex nat (fun n : nat => my_nth n l b)) (_ : @In B b (@cons B a l)), @ex nat (fun n : nat => my_nth n (@cons B a l) b) *) intros in_b; inversion_clear in_b. (* Goal: forall (a : B) (l : list B) (_ : forall _ : @In B b l, @ex nat (fun n : nat => my_nth n l b)) (_ : @In B b (@cons B a l)), @ex nat (fun n : nat => my_nth n (@cons B a l) b) *) intros a l ih in_a. (* Goal: @ex nat (fun n : nat => my_nth n (@cons B a l) b) *) inversion_clear in_a. (* Goal: @ex nat (fun n : nat => my_nth n (@cons B a l) b) *) (* Goal: @ex nat (fun n : nat => my_nth n (@cons B a l) b) *) exists 0. (* Goal: my_nth O (@cons B a l) b *) (* Goal: @ex nat (fun n : nat => my_nth n (@cons B a l) b) *) rewrite H. (* Goal: my_nth O (@cons B b l) b *) (* Goal: @ex nat (fun n : nat => my_nth n (@cons B a l) b) *) apply My_NthO. (* Goal: my_nth n l1 a *) (* Goal: forall (a0 : B) (l : list B) (_ : forall (n : nat) (_ : my_nth n (@app B l l1) a), inv_my_nth_app n l l1 a) (n : nat) (_ : my_nth n (@cons B a0 (@app B l l1)) a), inv_my_nth_app n (@cons B a0 l) l1 a *) elim ih; try assumption. (* Goal: forall (x : nat) (_ : my_nth x l b), @ex nat (fun n : nat => my_nth n (@cons B a l) b) *) intros n nth. (* Goal: @ex nat (fun n : nat => my_nth n (@cons B a l) b) *) exists (S n). (* Goal: my_nth n l1 a *) (* Goal: forall (a0 : B) (l : list B) (_ : forall (n : nat) (_ : my_nth n (@app B l l1) a), inv_my_nth_app n l l1 a) (n : nat) (_ : my_nth n (@cons B a0 (@app B l l1)) a), inv_my_nth_app n (@cons B a0 l) l1 a *) apply My_NthS; assumption. Qed. End My_Nth.
(* File: Rev_App.v (last edited on 27/10/2000) (c) Klaus Weich *) Require Export In_NGamma. (*******************************************************************) (* Decorated nested implications are pairs of a nested implication *) (* and a counter-model of the premisses. *) Definition decorated_nested_imp := (nimp * kripke_tree)%type. Definition decorated_nested_imps := list decorated_nested_imp. Definition DNI_NIL := nil (A:=decorated_nested_imp). Definition decorated_nested_imp2nimp (x : decorated_nested_imp) := match x with | (x0, _) => x0 end. Definition decorated_nested_imp2k (x : decorated_nested_imp) := match x with | (_, k) => k end. Definition decorated_nested_imp2form (x : decorated_nested_imp) := nimp2form (decorated_nested_imp2nimp x). Fixpoint rev_app (ds : decorated_nested_imps) : nested_imps -> nested_imps := match ds with | nil => fun ni : nested_imps => ni | (x, k) :: ds => fun ni : nested_imps => rev_app ds (Decorated x k :: ni) end. Lemma rev_app_app : forall (dni : decorated_nested_imps) (ni : nested_imps), rev_app dni ni = rev_app dni NNil ++ ni. (* Goal: forall (dni : decorated_nested_imps) (ni : nested_imps), rev_app_spec dni ni *) intros dni; elim dni; clear dni. (* Goal: forall ni : nested_imps, @eq nested_imps (rev_app (@nil decorated_nested_imp) ni) (@app nested_imp (rev_app (@nil decorated_nested_imp) NNil) ni) *) (* Goal: forall (a : decorated_nested_imp) (l : list decorated_nested_imp) (_ : forall ni : nested_imps, @eq nested_imps (rev_app l ni) (@app nested_imp (rev_app l NNil) ni)) (ni : nested_imps), @eq nested_imps (rev_app (@cons decorated_nested_imp a l) ni) (@app nested_imp (rev_app (@cons decorated_nested_imp a l) NNil) ni) *) intros ni; simpl in |- *. (* Goal: @eq nested_imps ni ni *) (* Goal: forall (a : decorated_nested_imp) (l : list decorated_nested_imp) (_ : forall ni : nested_imps, @eq nested_imps (rev_app l ni) (@app nested_imp (rev_app l NNil) ni)) (ni : nested_imps), @eq nested_imps (rev_app (@cons decorated_nested_imp a l) ni) (@app nested_imp (rev_app (@cons decorated_nested_imp a l) NNil) ni) *) trivial. (* Goal: forall (a : decorated_nested_imp) (l : list decorated_nested_imp) (_ : forall ni : nested_imps, @eq nested_imps (rev_app l ni) (@app nested_imp (rev_app l NNil) ni)) (ni : nested_imps), @eq nested_imps (rev_app (@cons decorated_nested_imp a l) ni) (@app nested_imp (rev_app (@cons decorated_nested_imp a l) NNil) ni) *) intros a; case a; clear a. (* Goal: forall (n : nimp) (k : kripke_tree) (l : list decorated_nested_imp) (_ : forall ni : nested_imps, @eq nested_imps (rev_app l ni) (@app nested_imp (rev_app l NNil) ni)) (ni : nested_imps), @eq nested_imps (rev_app (@cons decorated_nested_imp (@pair nimp kripke_tree n k) l) ni) (@app nested_imp (rev_app (@cons decorated_nested_imp (@pair nimp kripke_tree n k) l) NNil) ni) *) intros x k dni ih ni. (* Goal: @eq nested_imps (rev_app (@cons decorated_nested_imp (@pair nimp kripke_tree x k) dni) ni) (@app nested_imp (rev_app (@cons decorated_nested_imp (@pair nimp kripke_tree x k) dni) NNil) ni) *) simpl in |- *. (* Goal: @eq nested_imps (rev_app dni (@cons nested_imp (Decorated x k) ni)) (@app nested_imp (rev_app dni (@cons nested_imp (Decorated x k) NNil)) ni) *) rewrite (ih (Decorated x k :: ni)). (* Goal: @eq nested_imps (@app nested_imp (rev_app dni NNil) (@cons nested_imp (Decorated x k) ni)) (@app nested_imp (rev_app dni (@cons nested_imp (Decorated x k) NNil)) ni) *) rewrite (ih (Decorated x k :: NNil)). symmetry in |- *. (* Goal: @eq nested_imps (@app nested_imp (@app nested_imp (rev_app dni NNil) (@cons nested_imp (Decorated x k) NNil)) ni) (@app nested_imp (rev_app dni NNil) (@cons nested_imp (Decorated x k) ni)) *) apply (app_ass (rev_app dni NNil) (Decorated x k :: NNil) ni). Qed. Lemma in_app_or_ni : forall (x : nested_imp) (ni1 ni2 : nested_imps), In x (ni1 ++ ni2) -> In x ni1 \/ In x ni2. (* Goal: forall (x : nested_imp) (ni1 ni2 : nested_imps) (_ : @In nested_imp x ni2), @In nested_imp x (@app nested_imp ni1 ni2) *) intros x ni1 ni2 in_x. (* Goal: or (@In nested_imp x ni1) (@In nested_imp x ni2) *) apply in_app_or. (* Goal: forall (dni_ni : nested_imps) (_ : @eq nested_imps dni_ni (rev_app dni (@cons nested_imp (Decorated n k) ni))), A *) assumption. Qed. Lemma in_ni0_in_nini : forall (x : nested_imp) (ni1 ni2 : nested_imps), In x ni1 -> In x (ni1 ++ ni2). (* Goal: forall (x : nested_imp) (ni1 ni2 : nested_imps) (_ : @In nested_imp x ni2), @In nested_imp x (@app nested_imp ni1 ni2) *) intros x ni1 ni2 in_x. (* Goal: @In nested_imp x (@app nested_imp ni1 ni2) *) apply in_or_app. (* Goal: forall (dni_ni : nested_imps) (_ : @eq nested_imps dni_ni (rev_app dni (@cons nested_imp (Decorated n k) ni))), A *) left; assumption. Qed. Lemma in_ni1_in_nini : forall (x : nested_imp) (ni1 ni2 : nested_imps), In x ni2 -> In x (ni1 ++ ni2). (* Goal: forall (x : nested_imp) (ni1 ni2 : nested_imps) (_ : @In nested_imp x ni2), @In nested_imp x (@app nested_imp ni1 ni2) *) intros x ni1 ni2 in_x. (* Goal: @In nested_imp x (@app nested_imp ni1 ni2) *) apply in_or_app. (* Goal: forall (dni_ni : nested_imps) (_ : @eq nested_imps dni_ni (rev_app dni (@cons nested_imp (Decorated n k) ni))), A *) right; assumption. Qed. Lemma in_ni_x_ni_rev : forall (x x' : nested_imp) (ni1 ni2 : nested_imps), In x (ni1 ++ x' :: ni2) -> In x (ni1 ++ ni2) \/ x = x'. (* Goal: forall (x x' : nested_imp) (ni1 ni2 : nested_imps) (_ : @In nested_imp x (@app nested_imp ni1 (@cons nested_imp x' ni2))), or (@In nested_imp x (@app nested_imp ni1 ni2)) (@eq nested_imp x x') *) intros x x' ni1 ni2 in_ni_x_ni. (* Goal: or (@In nested_imp x (@app nested_imp ni1 ni2)) (@eq nested_imp x x') *) elim (in_app_or_ni x ni1 (x' :: ni2) in_ni_x_ni); clear in_ni_x_ni. (* Goal: forall (dni_ni : nested_imps) (_ : @eq nested_imps dni_ni (rev_app dni (@cons nested_imp (Decorated n k) ni))), A *) intros in_ni1; left; apply in_ni0_in_nini; assumption. (* Goal: forall _ : @In nested_imp x (@cons nested_imp x' ni2), or (@In nested_imp x (@app nested_imp ni1 ni2)) (@eq nested_imp x x') *) intros in_ni2; inversion_clear in_ni2. (* Goal: or (@In nested_imp x (@app nested_imp ni1 ni2)) (@eq nested_imp x x') *) (* Goal: or (@In nested_imp x (@app nested_imp ni1 ni2)) (@eq nested_imp x x') *) right. (* Goal: forall (dni_ni : nested_imps) (_ : @eq nested_imps dni_ni (rev_app dni (@cons nested_imp (Decorated n k) ni))), A *) symmetry in |- *; assumption. (* Goal: forall (dni_ni : nested_imps) (_ : @eq nested_imps dni_ni (rev_app dni (@cons nested_imp (Decorated n k) ni))), A *) left; apply in_ni1_in_nini; assumption. Qed. Lemma in_ni_x_ni_tail : forall (x x' : nested_imp) (ni1 ni2 : nested_imps), In x (ni1 ++ ni2) -> In x (ni1 ++ x' :: ni2). (* Goal: forall (x x' : nested_imp) (ni1 ni2 : nested_imps) (_ : @In nested_imp x (@app nested_imp ni1 ni2)), @In nested_imp x (@app nested_imp ni1 (@cons nested_imp x' ni2)) *) intros x x' ni1 ni2 in_nini. (* Goal: @In nested_imp x (@app nested_imp ni1 (@cons nested_imp x' ni2)) *) elim (in_app_or_ni x ni1 ni2 in_nini); clear in_nini. (* Goal: forall (dni_ni : nested_imps) (_ : @eq nested_imps dni_ni (rev_app dni (@cons nested_imp (Decorated n k) ni))), A *) intros in_ni1; apply in_ni0_in_nini; assumption. (* Goal: forall (dni_ni : nested_imps) (_ : @eq nested_imps dni_ni (rev_app dni (@cons nested_imp (Decorated n k) ni))), A *) intros in_ni2; apply in_ni1_in_nini; right; assumption. Qed. (***********************************************************************) Lemma rev_app_lemma0 : forall (dni : decorated_nested_imps) (ni : nested_imps), {dni_ni : nested_imps | dni_ni = rev_app dni ni}. (* Goal: forall (dni : decorated_nested_imps) (ni : nested_imps), rev_app_spec dni ni *) intros dni; elim dni; clear dni. (* Goal: @eq nested_imps ni ni *) (* Goal: forall (a : decorated_nested_imp) (l : list decorated_nested_imp) (_ : forall ni : nested_imps, @eq nested_imps (rev_app l ni) (@app nested_imp (rev_app l NNil) ni)) (ni : nested_imps), @eq nested_imps (rev_app (@cons decorated_nested_imp a l) ni) (@app nested_imp (rev_app (@cons decorated_nested_imp a l) NNil) ni) *) intros ni; exists ni; trivial. (* Goal: forall (a : decorated_nested_imp) (l : list decorated_nested_imp) (_ : forall (ni : nested_imps) (_ : forall (dni_ni : nested_imps) (_ : @eq nested_imps dni_ni (rev_app l ni)), A), A) (ni : nested_imps) (_ : forall (dni_ni : nested_imps) (_ : @eq nested_imps dni_ni (rev_app (@cons decorated_nested_imp a l) ni)), A), A *) intros x; case x; clear x. (* Goal: forall (n : nimp) (k : kripke_tree) (l : list decorated_nested_imp) (_ : forall (ni : nested_imps) (_ : forall (dni_ni : nested_imps) (_ : @eq nested_imps dni_ni (rev_app l ni)), A), A) (ni : nested_imps) (_ : forall (dni_ni : nested_imps) (_ : @eq nested_imps dni_ni (rev_app (@cons decorated_nested_imp (@pair nimp kripke_tree n k) l) ni)), A), A *) intros n k dni ih ni. (* Goal: A *) apply (ih (Decorated n k :: ni)). Qed. Inductive rev_app_spec (dni : decorated_nested_imps) (ni : nested_imps) : Set := Rev_App_Spec_Intro : forall dni_ni : nested_imps, dni_ni = rev_app dni ni -> rev_app_spec dni ni. Lemma rev_app_lemma1 : forall (dni : decorated_nested_imps) (ni : nested_imps), rev_app_spec dni ni. (* Goal: forall (dni : decorated_nested_imps) (ni : nested_imps), rev_app_spec dni ni *) intros dni; elim dni; clear dni. (* Goal: @eq nested_imps ni ni *) (* Goal: forall (a : decorated_nested_imp) (l : list decorated_nested_imp) (_ : forall ni : nested_imps, @eq nested_imps (rev_app l ni) (@app nested_imp (rev_app l NNil) ni)) (ni : nested_imps), @eq nested_imps (rev_app (@cons decorated_nested_imp a l) ni) (@app nested_imp (rev_app (@cons decorated_nested_imp a l) NNil) ni) *) intros ni; exists ni; trivial. (* Goal: forall (a : decorated_nested_imp) (l : list decorated_nested_imp) (_ : forall (ni : nested_imps) (_ : forall (dni_ni : nested_imps) (_ : @eq nested_imps dni_ni (rev_app l ni)), A), A) (ni : nested_imps) (_ : forall (dni_ni : nested_imps) (_ : @eq nested_imps dni_ni (rev_app (@cons decorated_nested_imp a l) ni)), A), A *) intros x; case x; clear x. (* Goal: forall (n : nimp) (k : kripke_tree) (l : list decorated_nested_imp) (_ : forall (ni : nested_imps) (_ : forall (dni_ni : nested_imps) (_ : @eq nested_imps dni_ni (rev_app l ni)), A), A) (ni : nested_imps) (_ : forall (dni_ni : nested_imps) (_ : @eq nested_imps dni_ni (rev_app (@cons decorated_nested_imp (@pair nimp kripke_tree n k) l) ni)), A), A *) intros n k dni ih ni. (* Goal: rev_app_spec (@cons decorated_nested_imp (@pair nimp kripke_tree n k) dni) ni *) elim (ih (Decorated n k :: ni)). (* Goal: forall (dni_ni : nested_imps) (_ : @eq nested_imps dni_ni (rev_app dni (@cons nested_imp (Decorated n k) ni))), rev_app_spec (@cons decorated_nested_imp (@pair nimp kripke_tree n k) dni) ni *) intros dni_ni eq. (* Goal: forall (dni_ni : nested_imps) (_ : @eq nested_imps dni_ni (rev_app dni (@cons nested_imp (Decorated n k) ni))), A *) exists dni_ni; assumption. Qed. Lemma rev_app_lemma2 : forall (A : Set) (dni : decorated_nested_imps) (ni : nested_imps), (forall dni_ni : nested_imps, dni_ni = rev_app dni ni -> A) -> A. (* Goal: forall (A : Set) (dni : decorated_nested_imps) (ni : nested_imps) (_ : forall (dni_ni : nested_imps) (_ : @eq nested_imps dni_ni (rev_app dni ni)), A), A *) intros A dni; elim dni; clear dni. (* Goal: @eq nested_imps ni ni *) (* Goal: forall (a : decorated_nested_imp) (l : list decorated_nested_imp) (_ : forall ni : nested_imps, @eq nested_imps (rev_app l ni) (@app nested_imp (rev_app l NNil) ni)) (ni : nested_imps), @eq nested_imps (rev_app (@cons decorated_nested_imp a l) ni) (@app nested_imp (rev_app (@cons decorated_nested_imp a l) NNil) ni) *) intros ni sk; apply (sk ni); trivial. (* Goal: forall (a : decorated_nested_imp) (l : list decorated_nested_imp) (_ : forall (ni : nested_imps) (_ : forall (dni_ni : nested_imps) (_ : @eq nested_imps dni_ni (rev_app l ni)), A), A) (ni : nested_imps) (_ : forall (dni_ni : nested_imps) (_ : @eq nested_imps dni_ni (rev_app (@cons decorated_nested_imp a l) ni)), A), A *) intros x; case x; clear x. (* Goal: forall (n : nimp) (k : kripke_tree) (l : list decorated_nested_imp) (_ : forall (ni : nested_imps) (_ : forall (dni_ni : nested_imps) (_ : @eq nested_imps dni_ni (rev_app l ni)), A), A) (ni : nested_imps) (_ : forall (dni_ni : nested_imps) (_ : @eq nested_imps dni_ni (rev_app (@cons decorated_nested_imp (@pair nimp kripke_tree n k) l) ni)), A), A *) intros n k dni ih ni. (* Goal: forall _ : forall (dni_ni : nested_imps) (_ : @eq nested_imps dni_ni (rev_app (@cons decorated_nested_imp (@pair nimp kripke_tree n k) dni) ni)), A, A *) intros sk. (* Goal: A *) apply (ih (Decorated n k :: ni)). (* Goal: forall (dni_ni : nested_imps) (_ : @eq nested_imps dni_ni (rev_app dni (@cons nested_imp (Decorated n k) ni))), A *) assumption. (* Intros A dni ni sk. Apply (sk (rev_app dni ni)). Trivial. *) Qed.
(* File: niMinimal.v (last edited on 27/10/2000) (c) Klaus Weich *) Require Export Forces_NGamma. Require Export Derivable_Tools. Definition nminimal (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist) := forall (c : form) (k : kripke_tree), Is_Monotone_kripke_tree k -> forces_ngamma work ds ni ai a k -> In c context -> forces_t k c. (*********************************************************************) Lemma nminimal_derivable_forces : forall (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist) (k : kripke_tree), Is_Monotone_kripke_tree k -> forces_ngamma work ds ni ai a k -> nminimal work ds ni ai a context -> forall c : form, Derivable context c -> forces_t k c. (* Goal: forall (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma work ds ni ai a k) (_ : nminimal work ds ni ai a context) (c : form) (_ : Derivable context c), forces_t k c *) intros work ds ni ai a context k k_is_mon k_forces_ngamma mon c der_c. (* Goal: forces_t k c *) elim der_c; clear der_c. (* Goal: forall (t : proof_term) (_ : derives context t c), forces_t k c *) intros t der_t. (* Goal: forces_t k c *) apply soundness_t with t context; try assumption. (* Goal: forall (c : form) (_ : @In form c context), forces_t k c *) intros c0 in_c0. (* Goal: forces_t k c0 *) apply mon; assumption. Qed. (*********************************************************************) Lemma nminimal_eqv : forall (work : nf_list) (ds : disjs) (ni1 ni2 : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist), eqv_ni ni1 ni2 -> nminimal work ds ni1 ai a context -> nminimal work ds ni2 ai a context. (* Goal: forall (work : nf_list) (ds : disjs) (ni1 ni2 : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist) (_ : eqv_ni ni1 ni2) (_ : nminimal work ds ni1 ai a context), nminimal work ds ni2 ai a context *) intros work ds ni1 ni2 ai a context eq12 mon. (* Goal: nminimal (@cons normal_form c work) ds ni ai a (@cons form (nf2form c) context) *) unfold nminimal in |- *. (* Goal: forall (c : form) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma work ds ni2 ai a k) (_ : @In form c context), forces_t k c *) intros c k k_is_mon k_forces in_a. (* Goal: forces_t k c0 *) apply mon; try assumption. (* Goal: forces_ngamma work ds ni1 ai a k *) apply forces_ngamma_eqv with ni2; assumption. Qed. (************************************************************************) Lemma nminimal_shift_work_ds : forall (i j : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist), nminimal (NDisj i j :: work) ds ni ai a context -> nminimal work ((i, j) :: ds) ni ai a context. (* Goal: forall (i j : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist) (_ : nminimal (@cons normal_form (NDisj i j) work) ds ni ai a context), nminimal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context *) intros i j work ds ni ai a context mon. (* Goal: nminimal (@cons normal_form c work) ds ni ai a (@cons form (nf2form c) context) *) unfold nminimal in |- *. (* Goal: forall (c : form) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma work ds ni ai a' k) (_ : @In form c context), forces_t k c *) intros c k k_is_mon k_forces_ngamma in_a. (* Goal: forces_t k c0 *) apply mon; try assumption. (* Goal: forces_ngamma (@cons normal_form (NDisj i j) work) ds ni ai a k *) apply forces_ngamma_shift_ds_work; assumption. Qed. Lemma nminimal_shift_work_ni : forall (x : nested_imp) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist), nminimal (NImp_NF (nested_imp2nimp x) :: work) ds ni ai a context -> nminimal work ds (x :: ni) ai a context. (* Goal: forall (x : nested_imp) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist) (_ : nminimal (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds ni ai a context), nminimal work ds (@cons nested_imp x ni) ai a context *) intros x work ds ni ai a context mon. (* Goal: nminimal (@cons normal_form c work) ds ni ai a (@cons form (nf2form c) context) *) unfold nminimal in |- *. (* Goal: forall (c : form) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma work ds ni ai a' k) (_ : @In form c context), forces_t k c *) intros c k k_is_mon k_forces_ngamma in_a. (* Goal: forces_t k c0 *) apply mon; try assumption. (* Goal: forces_ngamma (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds ni ai a k *) apply forces_ngamma_shift_ni_work; assumption. Qed. Lemma nminimal_shift_work_ai_new : forall (i : Int) (b : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai ai' : atomic_imps) (a : atoms) (context : flist), (forall bs : nf_list, LOOKUP nf_list i ai bs -> False) -> EQUIV_INS nf_list i (cons b) nf_nil ai ai' -> nminimal (AImp i b :: work) ds ni ai a context -> nminimal work ds ni ai' a context. (* Goal: forall (i : Int) (b : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai ai' : atomic_imps) (a : atoms) (context : flist) (_ : forall (bs : nf_list) (_ : LOOKUP nf_list i ai bs), False) (_ : EQUIV_INS nf_list i (@cons normal_form b) nf_nil ai ai') (_ : nminimal (@cons normal_form (AImp i b) work) ds ni ai a context), nminimal work ds ni ai' a context *) intros i b work ds ni ai ai' a context lookup equiv_ins mon. (* Goal: nminimal (@cons normal_form c work) ds ni ai a (@cons form (nf2form c) context) *) unfold nminimal in |- *. (* Goal: forall (c : form) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma work ds ni ai a' k) (_ : @In form c context), forces_t k c *) intros c k k_is_mon k_forces_ngamma in_a. (* Goal: forces_t k c0 *) apply mon; try assumption. (* Goal: forces_ngamma (@cons normal_form (AImp i b) work) ds ni ai a k *) apply forces_ngamma_shift_ai_work_new with ai'; assumption. Qed. Lemma nminimal_shift_work_ai_old : forall (i : Int) (b : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (bs : nf_list) (ai ai' : atomic_imps) (a : atoms) (context : flist), LOOKUP nf_list i ai bs -> EQUIV_INS nf_list i (cons b) nf_nil ai ai' -> nminimal (AImp i b :: work) ds ni ai a context -> nminimal work ds ni ai' a context. (* Goal: forall (i : Int) (b : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (bs : nf_list) (ai ai' : atomic_imps) (a : atoms) (context : flist) (_ : LOOKUP nf_list i ai bs) (_ : EQUIV_INS nf_list i (@cons normal_form b) nf_nil ai ai') (_ : nminimal (@cons normal_form (AImp i b) work) ds ni ai a context), nminimal work ds ni ai' a context *) intros i b work ds ni bs ai ai' a context notlookup equiv_ins mon. (* Goal: nminimal (@cons normal_form c work) ds ni ai a (@cons form (nf2form c) context) *) unfold nminimal in |- *. (* Goal: forall (c : form) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma work ds ni ai a' k) (_ : @In form c context), forces_t k c *) intros c k k_is_mon k_forces_ngamma in_a. (* Goal: forces_t k c0 *) apply mon; try assumption. (* Goal: forces_ngamma (@cons normal_form (AImp i b) work) ds ni ai a k *) apply forces_ngamma_shift_ai_work_old with bs ai'; assumption. Qed. Lemma nminimal_shift_work_a : forall (i : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a a' : atoms) (context : flist), EQUIV_INS unit i (fun _ : unit => tt) tt a a' -> nminimal (NAtom i :: work) ds ni ai a context -> nminimal work ds ni ai a' context. (* Goal: forall (i : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a a' : atoms) (context : flist) (_ : EQUIV_INS unit i (fun _ : unit => tt) tt a a') (_ : nminimal (@cons normal_form (NAtom i) work) ds ni ai a context), nminimal work ds ni ai a' context *) intros i work ds ni ai a a' context equiv_ins mon. (* Goal: nminimal (@cons normal_form c work) ds ni ai a (@cons form (nf2form c) context) *) unfold nminimal in |- *. (* Goal: forall (c : form) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma work ds ni ai a' k) (_ : @In form c context), forces_t k c *) intros c k k_is_mon k_forces_ngamma in_a. (* Goal: forces_t k c0 *) apply mon; try assumption. (* Goal: forces_ngamma (@cons normal_form (NAtom i) work) ds ni ai a k *) apply forces_ngamma_shift_a_work with a'; assumption. Qed. Lemma nminimal_shift_work_ni_x_ni : forall (x : nested_imp) (work : nf_list) (ds : disjs) (ni1 ni2 : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist), nminimal (NImp_NF (nested_imp2nimp x) :: work) ds (ni1 ++ ni2) ai a context -> nminimal work ds (ni1 ++ x :: ni2) ai a context. (* Goal: forall (x : nested_imp) (work : nf_list) (ds : disjs) (ni1 ni2 : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist) (_ : nminimal work ds (@app nested_imp ni1 (@cons nested_imp x ni2)) ai a context), nminimal (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds (@app nested_imp ni1 ni2) ai a context *) intros x work ds ni1 ni2 ai a context min. (* Goal: nminimal (@cons normal_form c work) ds ni ai a (@cons form (nf2form c) context) *) unfold nminimal in |- *. (* Goal: forall (c : form) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@app normal_form bs work) ds ni ai' a k) (_ : @In form c context), forces_t k c *) intros c k k_is_mon k_forces_ngamma in_c. (* Goal: forces_t k c0 *) apply min; try assumption. (* Goal: forces_ngamma (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds (@app nested_imp ni1 ni2) ai a k *) apply forces_ngamma_shift_ni_x_ni_work; assumption. Qed. Lemma nminimal_shift_ni_x_ni_work : forall (x : nested_imp) (work : nf_list) (ds : disjs) (ni1 ni2 : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist), nminimal work ds (ni1 ++ x :: ni2) ai a context -> nminimal (NImp_NF (nested_imp2nimp x) :: work) ds (ni1 ++ ni2) ai a context. (* Goal: forall (x : nested_imp) (work : nf_list) (ds : disjs) (ni1 ni2 : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist) (_ : nminimal work ds (@app nested_imp ni1 (@cons nested_imp x ni2)) ai a context), nminimal (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds (@app nested_imp ni1 ni2) ai a context *) intros x work ds ni1 ni2 ai a context min. (* Goal: nminimal (@cons normal_form c work) ds ni ai a (@cons form (nf2form c) context) *) unfold nminimal in |- *. (* Goal: forall (c : form) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@app normal_form bs work) ds ni ai' a k) (_ : @In form c context), forces_t k c *) intros c k k_is_mon k_forces_ngamma in_c. (* Goal: forces_t k c0 *) apply min; try assumption. (* Goal: forces_ngamma work ds (@app nested_imp ni1 (@cons nested_imp x ni2)) ai a k *) apply forces_ngamma_shift_work_ni_x_ni; assumption. Qed. (********************************************************************) Lemma nminimal_cons_work_strength : forall (b c : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist), (forall k : kripke_tree, Is_Monotone_kripke_tree k -> forces_ngamma (c :: work) ds ni ai a k -> forces_t k (nf2form b)) -> nminimal (b :: work) ds ni ai a context -> nminimal (c :: work) ds ni ai a context. (* Goal: forall (b c : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (nf2form c)), forces_t k (nf2form b)) (_ : nminimal (@cons normal_form b work) ds ni ai a context), nminimal (@cons normal_form c work) ds ni ai a context *) intros b c work ds ni ai a context forces_cb minimal. (* Goal: nminimal (@cons normal_form c work) ds ni ai a (@cons form (nf2form c) context) *) unfold nminimal in |- *. (* Goal: forall (c0 : form) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form c work) ds ni ai a k) (_ : @In form c0 (@cons form (nf2form c) context)), forces_t k c0 *) intros c0 k k_is_mon k_forces_ngamma in_c0. (* Goal: forces_t k c0 *) apply minimal; try assumption. (* Goal: forces_ngamma (@cons normal_form (NDisj i j) work) ds ni ai a k *) apply forces_ngamma_cons_work_weak with c; try assumption. (* Goal: forall _ : forces_t k (nf2form c), forces_t k (nf2form b) *) intros forces_c. (* Goal: forces_t k (nf2form b) *) apply forces_cb; assumption. Qed. Lemma nminimal_cons_work_weak : forall (b c : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist), (forall k : kripke_tree, Is_Monotone_kripke_tree k -> forces_t k (nf2form c) -> forces_t k (nf2form b)) -> nminimal (b :: work) ds ni ai a context -> nminimal (c :: work) ds ni ai a context. (* Goal: forall (b c : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (nf2form c)), forces_t k (nf2form b)) (_ : nminimal (@cons normal_form b work) ds ni ai a context), nminimal (@cons normal_form c work) ds ni ai a context *) intros b c work ds ni ai a context forces_cb minimal. (* Goal: nminimal (@cons normal_form c work) ds ni ai a (@cons form (nf2form c) context) *) unfold nminimal in |- *. (* Goal: forall (c0 : form) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form c work) ds ni ai a k) (_ : @In form c0 (@cons form (nf2form c) context)), forces_t k c0 *) intros c0 k k_is_mon k_forces_ngamma in_c0. (* Goal: forces_t k c0 *) apply minimal; try assumption. (* Goal: forces_ngamma (@cons normal_form (NDisj i j) work) ds ni ai a k *) apply forces_ngamma_cons_work_weak with c; try assumption. (* Goal: forall _ : forces_t k (nf2form c), forces_t k (nf2form b) *) intros forces_c. (* Goal: forces_t k (nf2form b) *) apply forces_cb; assumption. Qed. Lemma nminimal_shift_work_ai_weak : forall (i : Int) (bs work : nf_list) (ds : disjs) (ni : nested_imps) (ai ai' : atomic_imps) (a : atoms) (context : flist), LOOKUP nf_list i ai bs -> EQUIV_DEL nf_list i ai ai' -> nminimal work ds ni ai a context -> nminimal (bs ++ work) ds ni ai' a context. (* Goal: forall (i : Int) (bs work : nf_list) (ds : disjs) (ni : nested_imps) (ai ai' : atomic_imps) (a : atoms) (context : flist) (_ : LOOKUP nf_list i ai bs) (_ : EQUIV_DEL nf_list i ai ai') (_ : nminimal work ds ni ai a context), nminimal (@app normal_form bs work) ds ni ai' a context *) intros i bs work ds ni ai ai' a context lookup equiv_del min. (* Goal: nminimal (@cons normal_form c work) ds ni ai a (@cons form (nf2form c) context) *) unfold nminimal in |- *. (* Goal: forall (c : form) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@app normal_form bs work) ds ni ai' a k) (_ : @In form c context), forces_t k c *) intros c k k_is_mon k_forces_ngamma in_c. (* Goal: forces_t k c0 *) apply min; try assumption. (* Goal: forces_ngamma work ds ni ai a k *) apply forces_ngamma_del_ai_rev with i bs ai'; try assumption. (* Goal: forall (n : nat) (b : normal_form) (_ : my_nth normal_form n bs b), forces_t k (nf2form (AImp i b)) *) (* Goal: forces_ngamma work ds ni ai' a k *) intros n b nth. (* Goal: forces_t k (nf2form (AImp i b)) *) (* Goal: forces_ngamma work ds ni ai' a k *) simpl in |- *; apply forces_b__forces_a_imp_b_t; try assumption. (* Goal: forces_t k (nf2form c) *) (* Goal: forces_t k c0 *) apply k_forces_ngamma. (* Goal: in_ngamma (@app normal_form bs work) ds ni ai' a b *) (* Goal: forces_ngamma work ds ni ai' a k *) apply In_Work with n. (* Goal: my_nth normal_form n (@app normal_form bs work) b *) (* Goal: forces_ngamma work ds ni ai' a k *) apply nth_app0; assumption. (* Goal: forces_ngamma work ds ni ai' a k *) apply forces_ngamma_app_work_tail with bs; assumption. Qed. Lemma nminimal_shift_ds_work_context : forall (work : nf_list) (c : normal_form) (i j : Int) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist), (forall k : kripke_tree, Is_Monotone_kripke_tree k -> forces_t k (nf2form c) -> forces_t k (OrF (Atom i) (Atom j))) -> nminimal work ((i, j) :: ds) ni ai a context -> nminimal (c :: work) ds ni ai a (nf2form c :: context). (* Goal: forall (work : nf_list) (c : normal_form) (i j : Int) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (nf2form c)), forces_t k (OrF (Atom i) (Atom j))) (_ : nminimal work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a context), nminimal (@cons normal_form c work) ds ni ai a (@cons form (nf2form c) context) *) intros work c i j ds ni ai a context forces_ij mon. (* Goal: nminimal (@cons normal_form c work) ds ni ai a (@cons form (nf2form c) context) *) unfold nminimal in |- *. (* Goal: forall (c0 : form) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form c work) ds ni ai a k) (_ : @In form c0 (@cons form (nf2form c) context)), forces_t k c0 *) intros c0 k k_is_mon k_forces_ngamma in_context. (* Goal: forces_t k c0 *) inversion_clear in_context. (* Goal: forces_t k c0 *) (* Goal: forces_t k c0 *) rewrite <- H; clear H c0. (* Goal: forces_t k (nf2form c) *) (* Goal: forces_t k c0 *) apply k_forces_ngamma. (* Goal: in_ngamma (@cons normal_form c work) ds ni ai a c *) (* Goal: forces_t k c0 *) apply in_ngamma_cons_work_head. (* Goal: forces_t k c0 *) apply mon; try assumption. (* Goal: forces_ngamma work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a k *) apply forces_ngamma_shift_work_ds. (* Goal: forces_ngamma (@cons normal_form (NDisj i j) work) ds ni ai a k *) apply forces_ngamma_cons_work_weak with c; try assumption. (* Goal: forall _ : forces_t k (nf2form c), forces_t k (nf2form (NDisj i j)) *) intro forces_c. (* Goal: forces_t k (nf2form (NDisj i j)) *) apply forces_ij; assumption. Qed. Lemma nminimal_cons_work_cons_context : forall (c : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist), nminimal work ds ni ai a context -> nminimal (c :: work) ds ni ai a (nf2form c :: context). (* Goal: forall (c : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (context : flist) (_ : nminimal work ds ni ai a context), nminimal (@cons normal_form c work) ds ni ai a (@cons form (nf2form c) context) *) intros c work ds ni ai a context min. (* Goal: nminimal (@cons normal_form c work) ds ni ai a (@cons form (nf2form c) context) *) unfold nminimal in |- *. (* Goal: forall (c0 : form) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form c work) ds ni ai a k) (_ : @In form c0 (@cons form (nf2form c) context)), forces_t k c0 *) intros c0 k k_is_mon k_forces_ngamma in_c0. (* Goal: forces_t k c0 *) inversion_clear in_c0. (* Goal: forces_t k c0 *) (* Goal: forces_t k c0 *) rewrite <- H. (* Goal: forces_t k (nf2form c) *) (* Goal: forces_t k c0 *) apply k_forces_ngamma. (* Goal: in_ngamma (@cons normal_form c work) ds ni ai a c *) (* Goal: forces_t k c0 *) apply in_ngamma_cons_work_head. (* Goal: forces_t k c0 *) apply min; try assumption. (* Goal: forces_ngamma work ds ni ai a k *) apply forces_ngamma_cons_work_tail with c. (* Goal: forces_ngamma (@cons normal_form c work) ds ni ai a k *) assumption. Qed.
(* File: Minimal.v (last edited on 27/10/2000) (c) Klaus Weich *) Require Export Forces_Gamma. Require Export Derivable_Tools. Definition minimal (gamma : flist) (work : nf_list) (context : flist) := forall (a : form) (k : kripke_tree), Is_Monotone_kripke_tree k -> forces_gamma gamma work k -> In a context -> forces_t k a. Lemma minimal_derivable_forces : forall (gamma : flist) (work : nf_list) (context : flist) (k : kripke_tree), Is_Monotone_kripke_tree k -> forces_gamma gamma work k -> minimal gamma work context -> forall a : form, Derivable context a -> forces_t k a. (* Goal: forall (gamma : flist) (work : nf_list) (context : flist) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma gamma work k) (_ : minimal gamma work context) (a : form) (_ : Derivable context a), forces_t k a *) intros gamma work context k k_is_mon k_forces_gamma minimal0 a der_a. (* Goal: forces_t k a *) elim der_a; clear der_a. (* Goal: forall (t : proof_term) (_ : derives context t a), forces_t k a *) intros t der_t. (* Goal: forces_t k a *) apply soundness_t with t context; try assumption. (* Goal: forall (c : form) (_ : @In form c context), forces_t k c *) intros c in_c. (* Goal: forces_t k c *) apply minimal0; assumption. Qed. (*************************************************************************) Lemma minimal_shift_gamma_work : forall (a : normal_form) (gamma : flist) (work : nf_list) (context : flist), minimal (nf2form a :: gamma) work context -> minimal gamma (a :: work) context. (* Goal: forall (a : normal_form) (gamma : flist) (work : nf_list) (context : flist) (_ : minimal gamma (@cons normal_form a work) context), minimal (@cons form (nf2form a) gamma) work context *) intros a gamma work context minimal0. (* Goal: minimal (@cons form b (@cons form c gamma)) work context *) unfold minimal in |- *. (* Goal: forall (a0 : form) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form a gamma) work k) (_ : @In form a0 (@cons form a context)), forces_t k a0 *) intros b k k_is_mon k_forces_gamma in_b. (* Goal: forces_t k d *) apply minimal0; try assumption. (* Goal: forces_gamma (@cons form (nf2form a) gamma) work k *) apply forces_gamma_shift_work_gamma; assumption. Qed. Lemma minimal_shift_work_gamma : forall (a : normal_form) (gamma : flist) (work : nf_list) (context : flist), minimal gamma (a :: work) context -> minimal (nf2form a :: gamma) work context. (* Goal: forall (a : normal_form) (gamma : flist) (work : nf_list) (context : flist) (_ : minimal gamma (@cons normal_form a work) context), minimal (@cons form (nf2form a) gamma) work context *) intros a gamma work context minimal0. (* Goal: minimal (@cons form b (@cons form c gamma)) work context *) unfold minimal in |- *. (* Goal: forall (a0 : form) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form a gamma) work k) (_ : @In form a0 (@cons form a context)), forces_t k a0 *) intros b k k_is_mon k_forces_gamma in_b. (* Goal: forces_t k d *) apply minimal0; try assumption. (* Goal: forces_gamma gamma (@cons normal_form a work) k *) apply forces_gamma_shift_gamma_work; assumption. Qed. (*************************************************************************) Lemma minimal_cons_gamma_cons_context : forall (gamma : flist) (work : nf_list) (context : flist) (a : form), minimal gamma work context -> minimal (a :: gamma) work (a :: context). (* Goal: forall (gamma : flist) (work : nf_list) (context : flist) (a : form) (_ : minimal gamma work context), minimal (@cons form a gamma) work (@cons form a context) *) intros gamma work context a minimal0. (* Goal: minimal (@cons form b (@cons form c gamma)) work context *) unfold minimal in |- *. (* Goal: forall (a0 : form) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form a gamma) work k) (_ : @In form a0 (@cons form a context)), forces_t k a0 *) intros b k k_is_mon k_forces_gamma in_b. (* Goal: forces_t k b *) inversion_clear in_b. (* Goal: forces_t k b *) (* Goal: forces_t k b *) apply k_forces_gamma. (* Goal: in_gamma (@cons form a gamma) work b *) (* Goal: forces_t k b *) rewrite H. (* Goal: in_gamma (@cons form b gamma) work b *) (* Goal: forces_t k b *) apply in_gamma_cons_gamma_head. (* Goal: forces_t k b *) apply minimal0. (* Goal: @In form b context *) assumption. (* Goal: @In form b context *) apply forces_gamma_cons_gamma_tail with a; assumption. (* Goal: @In form b context *) assumption. Qed. (*************************************************************************) Lemma minimal_cons_gamma_weak : forall (gamma : flist) (work : nf_list) (context : flist) (a b : form), (forall k : kripke_tree, Is_Monotone_kripke_tree k -> forces_t k b -> forces_t k a) -> minimal (a :: gamma) work context -> minimal (b :: gamma) work context. (* Goal: forall (gamma : flist) (work : nf_list) (context : flist) (a b : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k b), forces_t k a) (_ : minimal (@cons form a gamma) work context), minimal (@cons form b gamma) work context *) intros gamma work context a b forces_ba minimal0. (* Goal: minimal (@cons form b (@cons form c gamma)) work context *) unfold minimal in |- *. (* Goal: forall (a : form) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form b gamma) work k) (_ : @In form a context), forces_t k a *) intros c k k_is_mon k_forces_gamma in_c. (* Goal: forces_t k d *) apply minimal0; try assumption. (* Goal: @In form b context *) apply forces_gamma_cons_gamma_weak with b; try assumption. (* Goal: @In form b context *) intros; apply forces_ba; assumption. Qed. Lemma minimal_cons_gamma_weak2 : forall (gamma : flist) (work : nf_list) (context : flist) (a b c : form), (forall k : kripke_tree, Is_Monotone_kripke_tree k -> forces_t k b -> forces_t k c -> forces_t k a) -> minimal (a :: gamma) work context -> minimal (b :: c :: gamma) work context. (* Goal: forall (gamma : flist) (work : nf_list) (context : flist) (a b c : form) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k b) (_ : forces_t k c), forces_t k a) (_ : minimal (@cons form a gamma) work context), minimal (@cons form b (@cons form c gamma)) work context *) intros gamma work context a b c forces_bca minimal0. (* Goal: minimal (@cons form b (@cons form c gamma)) work context *) unfold minimal in |- *. (* Goal: forall (a : form) (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_gamma (@cons form b (@cons form c gamma)) work k) (_ : @In form a context), forces_t k a *) intros d k k_is_mon k_forces_gamma in_d. (* Goal: forces_t k d *) apply minimal0; try assumption. (* Goal: @In form b context *) apply forces_gamma_cons_gamma_weak2 with b c; try assumption. (* Goal: @In form b context *) intros; apply forces_bca; assumption. Qed.
(* File: Trees.v (last edited on 25/10/2000) (c) Klaus Weich *) Require Export My_Arith. Require Import Le. (****** Tree stuff ********************************************) Section Trees. Variable A : Set. Inductive Tree : Set := node : A -> Forest -> Tree with Forest : Set := | Nil_Forest : Forest | Cons_Forest : Tree -> Forest -> Forest. Fixpoint height_tree (t : Tree) : nat := match t with | node a succs => S (height_forest succs) end with height_forest (succs : Forest) : nat := match succs with | Nil_Forest => 0 | Cons_Forest t0 succs => max (height_tree t0) (height_forest succs) end. (* Inductive Tree : Set := | node : A -> (list Tree) -> Tree. Fixpoint height_tree [t:Tree] : nat := Cases t of | (node a succs) => (S (height_forest succs)) end with height_forest[succs:(list Tree)] : nat := Cases succs of | nil => O | (cons t0 succs) => (max (height_tree t0) (height_forest succs)) end. Does not work!! *) Definition root (t : Tree) := match t with | node a _ => a end. Definition successors (t : Tree) := match t with | node _ succs => succs end. Inductive In_Forest (t0 : Tree) : Forest -> Prop := | in_forest_head : forall succs : Forest, In_Forest t0 (Cons_Forest t0 succs) | in_forest_tail : forall (t1 : Tree) (succs : Forest), In_Forest t0 succs -> In_Forest t0 (Cons_Forest t1 succs). Lemma height_in_le : forall (t : Tree) (succs : Forest), In_Forest t succs -> height_tree t <= height_forest succs. (* Goal: forall (t : Tree) (succs : Forest) (_ : In_Forest t succs), le (height_tree t) (height_forest succs) *) intros t succs in_t. (* Goal: le (height_tree t) (height_forest succs) *) elim in_t; clear in_t succs. (* Goal: forall succs : Forest, le (height_tree t) (height_forest (Cons_Forest t succs)) *) (* Goal: forall (t1 : Tree) (succs : Forest) (_ : In_Forest t succs) (_ : le (height_tree t) (height_forest succs)), le (height_tree t) (height_forest (Cons_Forest t1 succs)) *) intros succs. (* Goal: forall (_ : In_Forest t1 (successors (node a succs))) (_ : P (root (node a succs)) i), P (root t1) i *) simpl in |- *. (* Goal: le (height_tree t) (max (height_tree t) (height_forest succs)) *) (* Goal: forall (t1 : Tree) (succs : Forest) (_ : In_Forest t succs) (_ : le (height_tree t) (height_forest succs)), le (height_tree t) (height_forest (Cons_Forest t1 succs)) *) apply le_n_max1. (* Goal: forall (t1 : Tree) (succs : Forest) (_ : In_Forest t succs) (_ : le (height_tree t) (height_forest succs)), le (height_tree t) (height_forest (Cons_Forest t1 succs)) *) intros t1 succs in_t le_t. (* Goal: le (height_tree t) (height_forest (Cons_Forest t1 succs)) *) apply le_trans with (height_forest succs). (* Goal: In_Forest t1 succs *) (* Goal: Is_Monotone_Forest a succs *) assumption. (* Goal: forall (_ : In_Forest t1 (successors (node a succs))) (_ : P (root (node a succs)) i), P (root t1) i *) simpl in |- *. (* Goal: le (height_forest succs) (max (height_tree t1) (height_forest succs)) *) apply le_n_max2. Qed. Lemma My_Tree_ind : forall P : Tree -> Prop, (forall (a : A) (succs : Forest), (forall t : Tree, In_Forest t succs -> P t) -> P (node a succs)) -> forall t : Tree, P t. (* Goal: forall (P : forall _ : Tree, Set) (_ : forall (a : A) (succs : Forest) (_ : forall (t : Tree) (_ : In_Forest t succs), P t), P (node a succs)) (t : Tree), P t *) intros P step. (* Goal: forall t : Tree, P t *) cut (forall (n : nat) (t : Tree), height_tree t <= n -> P t). (* Goal: forall (_ : forall (n : nat) (t : Tree) (_ : le (height_tree t) n), P t) (t : Tree), P t *) (* Goal: forall (n : nat) (t : Tree) (_ : le (height_tree t) n), P t *) intro claim. (* Goal: forall t : Tree, P t *) (* Goal: forall (n : nat) (t : Tree) (_ : le (height_tree t) n), P t *) intro t. (* Goal: P t *) (* Goal: forall (n : nat) (t : Tree) (_ : le (height_tree t) n), P t *) apply claim with (height_tree t). (* Goal: forall (t : Tree) (_ : Is_Monotone_Tree t) (_ : P (root t) i), P (root t) i *) (* Goal: forall (t0 t1 : Tree) (_ : In_Forest t1 (successors t0)) (t2 : Tree) (_ : Successor t2 t1) (_ : forall (_ : Is_Monotone_Tree t1) (_ : P (root t1) i), P (root t2) i) (_ : Is_Monotone_Tree t0) (_ : P (root t0) i), P (root t2) i *) trivial. (* Goal: forall (n : nat) (t : Tree) (_ : le (height_tree t) n), P t *) intros n; elim n; clear n. (* Goal: forall (t : Tree) (_ : le (height_tree t) O), P t *) (* Goal: forall (n : nat) (_ : forall (t : Tree) (_ : le (height_tree t) n), P t) (t : Tree) (_ : le (height_tree t) (S n)), P t *) intros t; elim t; clear t. (* Goal: forall (a : A) (f : Forest) (_ : le (height_tree (node a f)) (S n)), P (node a f) *) intros a succs u0. (* Goal: P (node a succs) *) (* Goal: forall (n : nat) (_ : forall (t : Tree) (_ : le (height_tree t) n), P t) (t : Tree) (_ : le (height_tree t) (S n)), P t *) elimtype False. (* Goal: False *) (* Goal: forall (n : nat) (_ : forall (t : Tree) (_ : le (height_tree t) n), P t) (t : Tree) (_ : le (height_tree t) (S n)), P t *) inversion_clear u0. (* Goal: forall (n : nat) (_ : forall (t : Tree) (_ : le (height_tree t) n), P t) (t : Tree) (_ : le (height_tree t) (S n)), P t *) intros n ih t. (* Goal: forall _ : le (height_tree t) (S n), P t *) elim t; clear t. (* Goal: forall (a : A) (f : Forest) (_ : le (height_tree (node a f)) (S n)), P (node a f) *) intros a succs u0. (* Goal: P (node a succs) *) apply step; clear step. (* Goal: forall (t : Tree) (_ : In_Forest t succs), P t *) intros t in_t. (* Goal: P t *) apply ih; clear ih P. (* Goal: le (height_tree t) n *) apply le_S_n. (* Goal: le (S (height_tree t)) (S n) *) apply le_trans with (S (height_forest succs)). (* Goal: le (S (height_tree t)) (S (height_forest succs)) *) (* Goal: le (S (height_forest succs)) (S n) *) apply le_n_S. (* Goal: In_Forest t1 succs *) (* Goal: Is_Monotone_Forest a succs *) apply height_in_le; assumption. (* Goal: In_Forest t1 succs *) (* Goal: Is_Monotone_Forest a succs *) assumption. Qed. Lemma My_Tree_rec : forall P : Tree -> Set, (forall (a : A) (succs : Forest), (forall t : Tree, In_Forest t succs -> P t) -> P (node a succs)) -> forall t : Tree, P t. (* Goal: forall (P : forall _ : Tree, Set) (_ : forall (a : A) (succs : Forest) (_ : forall (t : Tree) (_ : In_Forest t succs), P t), P (node a succs)) (t : Tree), P t *) intros P step. (* Goal: forall t : Tree, P t *) cut (forall (n : nat) (t : Tree), height_tree t <= n -> P t). (* Goal: forall (_ : forall (n : nat) (t : Tree) (_ : le (height_tree t) n), P t) (t : Tree), P t *) (* Goal: forall (n : nat) (t : Tree) (_ : le (height_tree t) n), P t *) intro claim. (* Goal: forall t : Tree, P t *) (* Goal: forall (n : nat) (t : Tree) (_ : le (height_tree t) n), P t *) intro t. (* Goal: P t *) (* Goal: forall (n : nat) (t : Tree) (_ : le (height_tree t) n), P t *) apply claim with (height_tree t). (* Goal: forall (t : Tree) (_ : Is_Monotone_Tree t) (_ : P (root t) i), P (root t) i *) (* Goal: forall (t0 t1 : Tree) (_ : In_Forest t1 (successors t0)) (t2 : Tree) (_ : Successor t2 t1) (_ : forall (_ : Is_Monotone_Tree t1) (_ : P (root t1) i), P (root t2) i) (_ : Is_Monotone_Tree t0) (_ : P (root t0) i), P (root t2) i *) trivial. (* Goal: forall (n : nat) (t : Tree) (_ : le (height_tree t) n), P t *) intros n; elim n; clear n. (* Goal: forall (t : Tree) (_ : le (height_tree t) O), P t *) (* Goal: forall (n : nat) (_ : forall (t : Tree) (_ : le (height_tree t) n), P t) (t : Tree) (_ : le (height_tree t) (S n)), P t *) intros t; elim t; clear t. (* Goal: forall (a : A) (f : Forest) (_ : le (height_tree (node a f)) (S n)), P (node a f) *) intros a succs u0. (* Goal: P (node a succs) *) (* Goal: forall (n : nat) (_ : forall (t : Tree) (_ : le (height_tree t) n), P t) (t : Tree) (_ : le (height_tree t) (S n)), P t *) elimtype False. (* Goal: False *) (* Goal: forall (n : nat) (_ : forall (t : Tree) (_ : le (height_tree t) n), P t) (t : Tree) (_ : le (height_tree t) (S n)), P t *) inversion_clear u0. (* Goal: forall (n : nat) (_ : forall (t : Tree) (_ : le (height_tree t) n), P t) (t : Tree) (_ : le (height_tree t) (S n)), P t *) intros n ih t. (* Goal: forall _ : le (height_tree t) (S n), P t *) elim t; clear t. (* Goal: forall (a : A) (f : Forest) (_ : le (height_tree (node a f)) (S n)), P (node a f) *) intros a succs u0. (* Goal: P (node a succs) *) apply step; clear step. (* Goal: forall (t : Tree) (_ : In_Forest t succs), P t *) intros t in_t. (* Goal: P t *) apply ih; clear ih P. (* Goal: le (height_tree t) n *) apply le_S_n. (* Goal: le (S (height_tree t)) (S n) *) apply le_trans with (S (height_forest succs)). (* Goal: le (S (height_tree t)) (S (height_forest succs)) *) (* Goal: le (S (height_forest succs)) (S n) *) apply le_n_S. (* Goal: In_Forest t1 succs *) (* Goal: Is_Monotone_Forest a succs *) apply height_in_le; assumption. (* Goal: In_Forest t1 succs *) (* Goal: Is_Monotone_Forest a succs *) assumption. Qed. (* Successor relation *) Inductive Successor : Tree -> Tree -> Prop := | successor_refl : forall t : Tree, Successor t t | successor_trans : forall t0 t1 : Tree, In_Forest t1 (successors t0) -> forall t2 : Tree, Successor t2 t1 -> Successor t2 t0. Lemma succs_trans : forall t1 t2 : Tree, Successor t2 t1 -> forall t0 : Tree, Successor t1 t0 -> Successor t2 t0. (* Goal: forall (t1 t2 : Tree) (_ : Successor t2 t1) (t0 : Tree) (_ : Successor t1 t0), Successor t2 t0 *) intros t1 t2 u0 t0 u1. (* Goal: Successor t2 t0 *) generalize u0; clear u0. (* Goal: forall _ : Successor t2 t1, Successor t2 t0 *) elim u1; clear u1 t0 t1. (* Goal: forall (t : Tree) (_ : Is_Monotone_Tree t) (_ : P (root t) i), P (root t) i *) (* Goal: forall (t0 t1 : Tree) (_ : In_Forest t1 (successors t0)) (t2 : Tree) (_ : Successor t2 t1) (_ : forall (_ : Is_Monotone_Tree t1) (_ : P (root t1) i), P (root t2) i) (_ : Is_Monotone_Tree t0) (_ : P (root t0) i), P (root t2) i *) trivial. (* Goal: forall (t0 t1 : Tree) (_ : In_Forest t1 (successors t0)) (t3 : Tree) (_ : Successor t3 t1) (_ : forall _ : Successor t2 t3, Successor t2 t1) (_ : Successor t2 t3), Successor t2 t0 *) intros t0 t1 in_t1 t3 suc_t3_t1 ih suc_t2_t3. (* Goal: Successor t2 t0 *) apply (successor_trans t0 t1 in_t1 t2). (* Goal: In_Forest t1 succs *) (* Goal: Is_Monotone_Forest a succs *) apply ih; assumption. Qed. Lemma succs_refl : forall t : Tree, Successor t t. (* Goal: forall _ : forall (t : Tree) (_ : In_Forest t Nil_Forest), P t, P (node a Nil_Forest) *) (* Goal: forall (t : Tree) (f : Forest) (_ : forall (t0 : Tree) (_ : In_Forest t0 (Cons_Forest t f)), P t0), P (node a (Cons_Forest t f)) *) intros. (* Goal: Successor t1 t1 *) (* Goal: P (root t1) i *) apply successor_refl. Qed. Lemma Succs_Tree_ind : forall P : Tree -> Prop, (forall a : A, P (node a Nil_Forest)) -> (forall t0 t1 : Tree, Successor t0 t1 -> P t0 -> P t1) -> forall t : Tree, P t. (* Goal: forall (P : forall _ : Tree, Prop) (_ : forall a : A, P (node a Nil_Forest)) (_ : forall (t0 t1 : Tree) (_ : Successor t0 t1) (_ : P t0), P t1) (t : Tree), P t *) intros P leaf step t. (* Goal: P t *) apply My_Tree_ind. (* Goal: forall (a : A) (succs : Forest) (_ : forall (t : Tree) (_ : In_Forest t succs), P t), P (node a succs) *) intros a succs; case succs; clear succs. (* Goal: forall _ : forall (t : Tree) (_ : In_Forest t Nil_Forest), P t, P (node a Nil_Forest) *) (* Goal: forall (t : Tree) (f : Forest) (_ : forall (t0 : Tree) (_ : In_Forest t0 (Cons_Forest t f)), P t0), P (node a (Cons_Forest t f)) *) intros. (* Goal: P (node a Nil_Forest) *) (* Goal: forall (t : Tree) (f : Forest) (_ : forall (t0 : Tree) (_ : In_Forest t0 (Cons_Forest t f)), P t0), P (node a (Cons_Forest t f)) *) apply leaf. (* Goal: forall (t : Tree) (f : Forest) (_ : forall (t0 : Tree) (_ : In_Forest t0 (Cons_Forest t f)), P t0), P (node a (Cons_Forest t f)) *) intros t0 succs ih. (* Goal: P (node a (Cons_Forest t0 succs)) *) apply step with t0. (* Goal: Successor t0 (node a (Cons_Forest t0 succs)) *) (* Goal: P t0 *) apply successor_trans with t0. (* Goal: forall (_ : In_Forest t1 (successors (node a succs))) (_ : P (root (node a succs)) i), P (root t1) i *) simpl in |- *. (* Goal: In_Forest t0 (Cons_Forest t0 succs) *) apply in_forest_head. (* Goal: Successor t1 t1 *) (* Goal: P (root t1) i *) apply successor_refl. (* Goal: P (root t1) i *) apply ih. (* Goal: In_Forest t0 (Cons_Forest t0 succs) *) apply in_forest_head. Qed. (* In_tree *) (* ------- *) Inductive In_tree : A -> Tree -> Prop := | in_leave : forall (a : A) (succs : Forest), In_tree a (node a succs) | in_succs : forall (succs : Forest) (t : Tree), In_Forest t succs -> forall a : A, In_tree a t -> forall a' : A, In_tree a (node a' succs). Lemma in_successor_in : forall (a : A) (t : Tree), In_tree a t -> forall t' : Tree, Successor t t' -> In_tree a t'. (* Goal: forall (a : A) (t : Tree) (_ : In_tree a t) (t' : Tree) (_ : Successor t t'), In_tree a t' *) intros a t in_t t' suc. (* Goal: In_tree a t' *) generalize in_t; clear in_t. (* Goal: forall _ : In_tree a t, In_tree a t' *) elim suc; clear suc. (* Goal: forall (t : Tree) (_ : Is_Monotone_Tree t) (_ : P (root t) i), P (root t) i *) (* Goal: forall (t0 t1 : Tree) (_ : In_Forest t1 (successors t0)) (t2 : Tree) (_ : Successor t2 t1) (_ : forall (_ : Is_Monotone_Tree t1) (_ : P (root t1) i), P (root t2) i) (_ : Is_Monotone_Tree t0) (_ : P (root t0) i), P (root t2) i *) trivial. (* Goal: forall (t0 t1 : Tree) (_ : In_Forest t1 (successors t0)) (t2 : Tree) (_ : Successor t2 t1) (_ : forall _ : In_tree a t2, In_tree a t1) (_ : In_tree a t2), In_tree a t0 *) clear t t'. (* Goal: forall (t0 t1 : Tree) (_ : In_Forest t1 (successors t0)) (t2 : Tree) (_ : Successor t2 t1) (_ : forall _ : In_tree a t2, In_tree a t1) (_ : In_tree a t2), In_tree a t0 *) intros t0 t1 in_t1 t2 suc_t2 ih in_t2. (* Goal: forall _ : Is_Monotone_Forest a succs, P (root t1) i *) generalize in_t1; clear in_t1. (* Goal: forall _ : In_Forest t1 (successors t0), In_tree a t0 *) elim t0; clear t0. (* Goal: forall (a0 : A) (f : Forest) (_ : In_Forest t1 (successors (node a0 f))), In_tree a (node a0 f) *) intros a' succs in_t1. (* Goal: In_tree a (node a' succs) *) apply in_succs with (t := t1). (* Goal: In_Forest t1 succs *) (* Goal: Is_Monotone_Forest a succs *) assumption. (* Goal: P (root t1) i *) apply ih. (* Goal: In_Forest t1 succs *) (* Goal: Is_Monotone_Forest a succs *) assumption. Qed. (********************************************************************) (* Monotone Trees *) Variable I : Set. Variable P : A -> I -> Prop. Inductive Is_Monotone_Tree : Tree -> Prop := is_monotone_tree_intro : forall (a : A) (succs : Forest), Is_Monotone_Forest a succs -> Is_Monotone_Tree (node a succs) with Is_Monotone_Forest : A -> Forest -> Prop := | is_monotone_forest_nil : forall a : A, Is_Monotone_Forest a Nil_Forest | is_monotone_forest_cons : forall (a : A) (t : Tree) (succs : Forest), (forall i : I, P a i -> P (root t) i) -> Is_Monotone_Tree t -> Is_Monotone_Forest a succs -> Is_Monotone_Forest a (Cons_Forest t succs). Lemma is_monotone_tree_successor : forall t : Tree, Is_Monotone_Tree t -> forall t0 : Tree, Successor t0 t -> Is_Monotone_Tree t0. (* Goal: forall (t : Tree) (_ : Is_Monotone_Tree t) (t0 : Tree) (_ : Successor t0 t), Is_Monotone_Tree t0 *) intros t is_mon_t t0 suc_t0. (* Goal: Is_Monotone_Tree t0 *) generalize is_mon_t; clear is_mon_t. (* Goal: forall _ : Is_Monotone_Tree t, Is_Monotone_Tree t0 *) elim suc_t0; clear suc_t0 t0. (* Goal: forall (t : Tree) (_ : Is_Monotone_Tree t) (_ : P (root t) i), P (root t) i *) (* Goal: forall (t0 t1 : Tree) (_ : In_Forest t1 (successors t0)) (t2 : Tree) (_ : Successor t2 t1) (_ : forall (_ : Is_Monotone_Tree t1) (_ : P (root t1) i), P (root t2) i) (_ : Is_Monotone_Tree t0) (_ : P (root t0) i), P (root t2) i *) trivial. (* Goal: forall (t0 t1 : Tree) (_ : In_Forest t1 (successors t0)) (t2 : Tree) (_ : Successor t2 t1) (_ : forall _ : Is_Monotone_Tree t1, Is_Monotone_Tree t2) (_ : Is_Monotone_Tree t0), Is_Monotone_Tree t2 *) intros t0 t1 in_t1 t2 suc_t2 ih is_mon_t0. (* Goal: Is_Monotone_Tree t2 *) apply ih; clear ih suc_t2 t2. (* Goal: forall _ : Is_Monotone_Forest a succs, P (root t1) i *) generalize in_t1; clear in_t1. (* Goal: forall _ : In_Forest t1 (successors t0), Is_Monotone_Tree t1 *) inversion_clear is_mon_t0. (* Goal: forall (_ : In_Forest t1 (successors (node a succs))) (_ : P (root (node a succs)) i), P (root t1) i *) simpl in |- *. (* Goal: forall _ : P (root t0) i, P (root t1) i *) generalize H; clear H. (* Goal: forall (_ : In_Forest t1 succs) (_ : Is_Monotone_Forest a succs), P (root t1) i *) elim succs; clear succs. (* Goal: forall (_ : Is_Monotone_Forest a Nil_Forest) (_ : In_Forest t1 Nil_Forest), Is_Monotone_Tree t1 *) (* Goal: forall (t : Tree) (f : Forest) (_ : forall (_ : Is_Monotone_Forest a f) (_ : In_Forest t1 f), Is_Monotone_Tree t1) (_ : Is_Monotone_Forest a (Cons_Forest t f)) (_ : In_Forest t1 (Cons_Forest t f)), Is_Monotone_Tree t1 *) intros H in_t1. (* Goal: P (root t1) i *) inversion_clear in_t1. (* Goal: forall (t : Tree) (f : Forest) (_ : forall (_ : Is_Monotone_Forest a f) (_ : In_Forest t1 f), Is_Monotone_Tree t1) (_ : Is_Monotone_Forest a (Cons_Forest t f)) (_ : In_Forest t1 (Cons_Forest t f)), Is_Monotone_Tree t1 *) intros t2 succs ih H in_t1. (* Goal: P (root t1) i *) inversion_clear in_t1. (* Goal: In_Forest t1 succs *) (* Goal: Is_Monotone_Forest a succs *) inversion_clear H; assumption. (* Goal: P (root t1) i *) apply ih. (* Goal: In_Forest t1 succs *) (* Goal: Is_Monotone_Forest a succs *) inversion_clear H; assumption. (* Goal: In_Forest t1 succs *) (* Goal: Is_Monotone_Forest a succs *) assumption. Qed. Inductive Is_Monotone (t : Tree) : Prop := is_monotone_intro : (forall t0 : Tree, Successor t0 t -> forall i : I, P (root t0) i -> forall t1 : Tree, Successor t1 t0 -> P (root t1) i) -> Is_Monotone t. Lemma is_monotone_successor : forall T : Tree, Is_Monotone T -> forall t : Tree, Successor t T -> Is_Monotone t. (* Goal: forall (T : Tree) (_ : Is_Monotone T) (t : Tree) (_ : Successor t T), Is_Monotone t *) intros T mon_T t suc_t. (* Goal: Is_Monotone t *) apply is_monotone_intro. (* Goal: forall (t0 : Tree) (_ : Successor t0 t) (i : I) (_ : P (root t0) i) (t1 : Tree) (_ : Successor t1 t0), P (root t1) i *) intros t0 suc_t0 i Pa t1 suc_1. (* Goal: P (root t1) i *) inversion_clear mon_T. (* Goal: P (root t1) i *) apply H with t0. (* Goal: In_Forest t1 succs *) (* Goal: Is_Monotone_Forest a succs *) apply succs_trans with t; assumption. (* Goal: In_Forest t1 succs *) (* Goal: Is_Monotone_Forest a succs *) assumption. (* Goal: In_Forest t1 succs *) (* Goal: Is_Monotone_Forest a succs *) assumption. Qed. Lemma is_monotone_tree_is_monotone : forall t : Tree, Is_Monotone_Tree t -> Is_Monotone t. (* Goal: forall (t : Tree) (_ : Is_Monotone_Tree t), Is_Monotone t *) intros t H. (* Goal: Is_Monotone t *) apply is_monotone_intro. (* Goal: forall (t0 : Tree) (_ : Successor t0 t) (i : I) (_ : P (root t0) i) (t1 : Tree) (_ : Successor t1 t0), P (root t1) i *) intros t0 suc_t0. (* Goal: forall (i : I) (_ : P (root t0) i) (t1 : Tree) (_ : Successor t1 t0), P (root t1) i *) generalize (is_monotone_tree_successor t H t0 suc_t0); clear H suc_t0 t. (* Goal: forall (_ : Is_Monotone_Tree t0) (i : I) (_ : P (root t0) i) (t1 : Tree) (_ : Successor t1 t0), P (root t1) i *) intros H i P0 t1 suc_t1. (* Goal: P (root t1) i *) generalize P0; clear P0. (* Goal: forall _ : P (root t0) i, P (root t1) i *) generalize H; clear H. (* Goal: forall (_ : Is_Monotone_Tree t0) (_ : P (root t0) i), P (root t1) i *) elim suc_t1; clear suc_t1 t0 t1. (* Goal: forall (t : Tree) (_ : Is_Monotone_Tree t) (_ : P (root t) i), P (root t) i *) (* Goal: forall (t0 t1 : Tree) (_ : In_Forest t1 (successors t0)) (t2 : Tree) (_ : Successor t2 t1) (_ : forall (_ : Is_Monotone_Tree t1) (_ : P (root t1) i), P (root t2) i) (_ : Is_Monotone_Tree t0) (_ : P (root t0) i), P (root t2) i *) trivial. (* Goal: forall (t0 t1 : Tree) (_ : In_Forest t1 (successors t0)) (t2 : Tree) (_ : Successor t2 t1) (_ : forall (_ : Is_Monotone_Tree t1) (_ : P (root t1) i), P (root t2) i) (_ : Is_Monotone_Tree t0) (_ : P (root t0) i), P (root t2) i *) intros t0 t1 in_t1 t2 suc_t2 ih H P0. (* Goal: P (root t2) i *) apply ih; clear ih. (* Goal: Is_Monotone_Tree t1 *) (* Goal: P (root t1) i *) apply is_monotone_tree_successor with t0. (* Goal: In_Forest t1 succs *) (* Goal: Is_Monotone_Forest a succs *) assumption. (* Goal: Successor t1 t0 *) (* Goal: P (root t1) i *) apply successor_trans with t1. (* Goal: In_Forest t1 succs *) (* Goal: Is_Monotone_Forest a succs *) assumption. (* Goal: Successor t1 t1 *) (* Goal: P (root t1) i *) apply successor_refl. (* Goal: P (root t1) i *) generalize P0; clear P0. (* Goal: forall _ : Is_Monotone_Forest a succs, P (root t1) i *) generalize in_t1; clear in_t1. (* Goal: forall (_ : In_Forest t1 (successors t0)) (_ : P (root t0) i), P (root t1) i *) inversion_clear H. (* Goal: forall (_ : In_Forest t1 (successors (node a succs))) (_ : P (root (node a succs)) i), P (root t1) i *) simpl in |- *. (* Goal: forall (_ : In_Forest t1 succs) (_ : P a i), P (root t1) i *) intros in_t1 Pa. (* Goal: P (root t1) i *) generalize H0; clear H0. (* Goal: forall _ : Is_Monotone_Forest a succs, P (root t1) i *) generalize in_t1; clear in_t1. (* Goal: forall (_ : In_Forest t1 succs) (_ : Is_Monotone_Forest a succs), P (root t1) i *) elim succs; clear succs. (* Goal: forall (_ : In_Forest t1 Nil_Forest) (_ : Is_Monotone_Forest a Nil_Forest), P (root t1) i *) (* Goal: forall (t : Tree) (f : Forest) (_ : forall (_ : In_Forest t1 f) (_ : Is_Monotone_Forest a f), P (root t1) i) (_ : In_Forest t1 (Cons_Forest t f)) (_ : Is_Monotone_Forest a (Cons_Forest t f)), P (root t1) i *) intros in_t1 H0. (* Goal: P (root t1) i *) inversion_clear in_t1. (* Goal: forall (t : Tree) (f : Forest) (_ : forall (_ : In_Forest t1 f) (_ : Is_Monotone_Forest a f), P (root t1) i) (_ : In_Forest t1 (Cons_Forest t f)) (_ : Is_Monotone_Forest a (Cons_Forest t f)), P (root t1) i *) intros t3 succs ih in_t1 H0. (* Goal: P (root t1) i *) inversion_clear in_t1. (* Goal: P (root t3) i *) (* Goal: P (root t1) i *) inversion_clear H0. (* Goal: In_Forest t1 succs *) (* Goal: Is_Monotone_Forest a succs *) apply H; assumption. (* Goal: P (root t1) i *) apply ih. (* Goal: In_Forest t1 succs *) (* Goal: Is_Monotone_Forest a succs *) assumption. (* Goal: In_Forest t1 succs *) (* Goal: Is_Monotone_Forest a succs *) inversion_clear H0; assumption. Qed. End Trees.
(* File: NWeight.v (last edited on 27/10/2000) (c) Klaus Weich *) Require Export Lt. Require Export Le. Require Export Regular_Avl. Require Export Le_Ks. (*********************************************************************) Fixpoint nweight (a : form) : nat := match a with | Atom _ => 0 | Falsum => 0 | AndF a0 a1 => S (nweight a0 + nweight a1) | OrF a0 a1 => S (nweight a0 + nweight a1) | Imp a0 a1 => S (nweight a0 + nweight a1) end. (******************************************************************) Definition nweight_work := fold_right (fun (a : normal_form) (n : nat) => nweight (nf2form a) + n) 0. Remark nweight_work_app : forall bs work : nf_list, nweight_work (bs ++ work) = nweight_work bs + nweight_work work. (* Goal: forall bs work : nf_list, @eq nat (nweight_work (@app normal_form bs work)) (Nat.add (nweight_work bs) (nweight_work work)) *) intros bs work; elim bs; clear bs. (* Goal: le (S (Nat.add W (Nat.add ds n))) (Nat.add (S W) (Nat.add ds n)) *) simpl in |- *; trivial. (* Goal: forall (a : normal_form) (l : list normal_form) (_ : @eq nat (nweight_work (@app normal_form l work)) (Nat.add (nweight_work l) (nweight_work work))), @eq nat (nweight_work (@app normal_form (@cons normal_form a l) work)) (Nat.add (nweight_work (@cons normal_form a l)) (nweight_work work)) *) intros b bs ih. (* Goal: le (S (nweight_work (@cons normal_form b bs))) (nweight_bs (@cons normal_form b bs)) *) unfold nweight_work in |- *. (* Goal: le (S (Nat.add (nweight_work (@cons normal_form (NAtom j) work)) (Nat.add (nweight_ds ds) n))) (Nat.add (nweight_work work) (Nat.add (nweight_ds (@cons (prod Int Int) (@pair Int Int i j) ds)) n)) *) simpl in |- *. (* Goal: @eq nat (S (Nat.add (nweight_work work) (Nat.add (nweight_ds ds) n))) (Nat.add (nweight_work work) (S (Nat.add (nweight_ds ds) n))) *) fold nweight_work in |- *. (* Goal: @eq nat (Nat.add (nweight (nf2form b)) (nweight_work (@app normal_form bs work))) (Nat.add (Nat.add (nweight (nf2form b)) (nweight_work bs)) (nweight_work work)) *) rewrite ih. (* Goal: @eq nat (Nat.add x (Nat.add ni ai)) (Nat.add (Nat.add x ni) ai) *) apply plus_assoc. Qed. Definition nweight_disj (d : disj) := nweight (disj2form d). Definition nweight_ds := fold_right (fun (d : disj) (n : nat) => nweight_disj d + n) 0. Definition nweight_nestedimp (x : nested_imp) := nweight (nested_imp2form x). Definition nweight_ni := fold_right (fun (x : nested_imp) (n : nat) => nweight_nestedimp x + n) 0. Definition nweight_decoratednestedimp (x : decorated_nested_imp) := match x with | (x0, _) => nweight (nimp2form x0) end. Definition nweight_dni := fold_right (fun (x : decorated_nested_imp) (n : nat) => nweight_decoratednestedimp x + n) 0. Definition nweight_atomicimp (a : normal_form) := S (nweight (nf2form a)). Definition nweight_bs := fold_right (fun (b : normal_form) (n : nat) => nweight_atomicimp b + n) 0. Definition nweight_ibs (x : Int * nf_list) := match x with | (_, bs) => nweight_bs bs end. Definition nweight_ai (ai : atomic_imps) := fold_right (fun (x : Int * nf_list) (n : nat) => nweight_ibs x + n) 0 (LIN_AVL nf_list ai). (***************************************************************************) Remark nweight_ai_perm : forall (l0 l1 : list (Int * nf_list)) (x : Int * nf_list), fold_right (fun (x : Int * nf_list) (n : nat) => nweight_ibs x + n) 0 (l0 ++ x :: l1) = fold_right (fun (x : Int * nf_list) (n : nat) => nweight_ibs x + n) 0 (x :: l0 ++ l1). (* Goal: forall (l0 l1 : list (prod Int nf_list)) (x : prod Int nf_list), @eq nat (@fold_right nat (prod Int nf_list) (fun (x0 : prod Int nf_list) (n : nat) => Nat.add (nweight_ibs x0) n) O (@app (prod Int nf_list) l0 (@cons (prod Int nf_list) x l1))) (@fold_right nat (prod Int nf_list) (fun (x0 : prod Int nf_list) (n : nat) => Nat.add (nweight_ibs x0) n) O (@cons (prod Int nf_list) x (@app (prod Int nf_list) l0 l1))) *) intros l0 l1 x. (* Goal: @eq nat (@fold_right nat (prod Int nf_list) (fun (x : prod Int nf_list) (n : nat) => Nat.add (nweight_ibs x) n) O (@app (prod Int nf_list) l0 (@cons (prod Int nf_list) x l1))) (@fold_right nat (prod Int nf_list) (fun (x : prod Int nf_list) (n : nat) => Nat.add (nweight_ibs x) n) O (@cons (prod Int nf_list) x (@app (prod Int nf_list) l0 l1))) *) apply fold_right_perm. (* Goal: forall (i : Int) (b : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai ai' : atomic_imps) (_ : LIN_INS nf_list i (@cons normal_form b) nf_nil ai ai'), @eq nat (nweight_Sequent (@cons normal_form (AImp i b) work) ds ni ai) (nweight_Sequent work ds ni ai') *) intros. (* Goal: @eq nat (Nat.add (nweight_ibs a) (Nat.add (nweight_ibs b) c)) (Nat.add (nweight_ibs b) (Nat.add (nweight_ibs a) c)) *) apply plus_permute. Qed. Remark nweight_ai_ins : forall (i : Int) (b : normal_form) (ai ai' : atomic_imps), LIN_INS nf_list i (cons b) nf_nil ai ai' -> nweight (nf2form (AImp i b)) + nweight_ai ai = nweight_ai ai'. (* Goal: forall (i : Int) (b : normal_form) (ai ai' : atomic_imps) (_ : LIN_INS nf_list i (@cons normal_form b) nf_nil ai ai'), @eq nat (Nat.add (nweight (nf2form (AImp i b))) (nweight_ai ai)) (nweight_ai ai') *) intros i b ai ai'. (* Goal: forall _ : LIN_INS nf_list i (@cons normal_form b) nf_nil ai ai', @eq nat (Nat.add (nweight (nf2form (AImp i b))) (nweight_ai ai)) (nweight_ai ai') *) elim ai; clear ai. (* Goal: forall (t : avl_tree nf_list) (i0 : is_avl nf_list t) (_ : LIN_INS nf_list i (@cons normal_form b) nf_nil (AVL_intro nf_list t i0) ai'), @eq nat (Nat.add (nweight (nf2form (AImp i b))) (nweight_ai (AVL_intro nf_list t i0))) (nweight_ai ai') *) elim ai'; clear ai'. (* Goal: forall (t : avl_tree nf_list) (i0 : is_avl nf_list t) (t0 : avl_tree nf_list) (i1 : is_avl nf_list t0) (_ : LIN_INS nf_list i (@cons normal_form b) nf_nil (AVL_intro nf_list t0 i1) (AVL_intro nf_list t i0)), @eq nat (Nat.add (nweight (nf2form (AImp i b))) (nweight_ai (AVL_intro nf_list t0 i1))) (nweight_ai (AVL_intro nf_list t i0)) *) intros t' avl_t' t avl_t. (* Goal: le (S (Nat.add (nweight_work (@cons normal_form (NAtom j) work)) (Nat.add (nweight_ds ds) n))) (Nat.add (nweight_work work) (Nat.add (nweight_ds (@cons (prod Int Int) (@pair Int Int i j) ds)) n)) *) simpl in |- *. (* Goal: forall _ : lin_ins_spec nf_list i (@cons normal_form b) nf_nil t t', @eq nat (S (Nat.add (nweight (nf2form b)) (nweight_ai (AVL_intro nf_list t avl_t)))) (nweight_ai (AVL_intro nf_list t' avl_t')) *) intro lin_ins. (* Goal: lt (Nat.add (nweight_work bs) (nweight_ai (AVL_intro nf_list t' avl_t'))) (nweight_ai (AVL_intro nf_list t avl_t)) *) unfold nweight_ai in |- *. (* Goal: @eq nat (S (Nat.add (nweight (nf2form b)) (@fold_right nat (prod Int nf_list) (fun (x : prod Int nf_list) (n : nat) => Nat.add (nweight_ibs x) n) O (LIN_AVL nf_list (AVL_intro nf_list t avl_t))))) (@fold_right nat (prod Int nf_list) (fun (x : prod Int nf_list) (n : nat) => Nat.add (nweight_ibs x) n) O (LIN_AVL nf_list (AVL_intro nf_list t' avl_t'))) *) unfold LIN_AVL in |- *. (* Goal: @eq nat (S (Nat.add (nweight (nf2form b)) (@fold_right nat (prod Int nf_list) (fun (x : prod Int nf_list) (n : nat) => Nat.add (nweight_ibs x) n) O (lin_avl nf_list t)))) (@fold_right nat (prod Int nf_list) (fun (x : prod Int nf_list) (n : nat) => Nat.add (nweight_ibs x) n) O (lin_avl nf_list t')) *) clear avl_t' avl_t. (* Goal: @eq nat (S (Nat.add (nweight (nf2form b)) (@fold_right nat (prod Int nf_list) (fun (x : prod Int nf_list) (n : nat) => Nat.add (nweight_ibs x) n) O (lin_avl nf_list t)))) (@fold_right nat (prod Int nf_list) (fun (x : prod Int nf_list) (n : nat) => Nat.add (nweight_ibs x) n) O (lin_avl nf_list t')) *) inversion_clear lin_ins. (* Goal: @eq nat (S (Nat.add (nweight (nf2form b)) (@fold_right nat (prod Int nf_list) (fun (x : prod Int nf_list) (n : nat) => Nat.add (nweight_ibs x) n) O (lin_avl nf_list t)))) (@fold_right nat (prod Int nf_list) (fun (x : prod Int nf_list) (n : nat) => Nat.add (nweight_ibs x) n) O (lin_avl nf_list t')) *) rewrite H. (* Goal: @eq nat (S (Nat.add (nweight (nf2form b)) (@fold_right nat (prod Int nf_list) (fun (x : prod Int nf_list) (n : nat) => Nat.add (nweight_ibs x) n) O (@app (prod Int nf_list) l0 (@cons (prod Int nf_list) (@pair Int nf_list i d) l1))))) (@fold_right nat (prod Int nf_list) (fun (x : prod Int nf_list) (n : nat) => Nat.add (nweight_ibs x) n) O (lin_avl nf_list t')) *) rewrite H0. (* Goal: @eq nat (S (Nat.add (nweight (nf2form b)) (@fold_right nat (prod Int nf_list) (fun (x : prod Int nf_list) (n : nat) => Nat.add (nweight_ibs x) n) O (@app (prod Int nf_list) l0 (@cons (prod Int nf_list) (@pair Int nf_list i d) l1))))) (@fold_right nat (prod Int nf_list) (fun (x : prod Int nf_list) (n : nat) => Nat.add (nweight_ibs x) n) O (@app (prod Int nf_list) l0 (@cons (prod Int nf_list) (@pair Int nf_list i (@cons normal_form b d)) l1))) *) clear H H0. transitivity (fold_right (fun (x : Int * nf_list) (n : nat) => nweight_ibs x + n) 0 ((i, b :: nf_nil) :: l0 ++ l1)). (* Goal: le (S (Nat.add (nweight_work (@cons normal_form (NAtom j) work)) (Nat.add (nweight_ds ds) n))) (Nat.add (nweight_work work) (Nat.add (nweight_ds (@cons (prod Int Int) (@pair Int Int i j) ds)) n)) *) simpl in |- *. (* Goal: @eq nat (S (Nat.add (nweight (nf2form b)) (@fold_right nat (prod Int nf_list) (fun (x : prod Int nf_list) (n : nat) => Nat.add (nweight_ibs x) n) O (@app (prod Int nf_list) l0 l1)))) (S (Nat.add (Nat.add (nweight (nf2form b)) O) (@fold_right nat (prod Int nf_list) (fun (x : prod Int nf_list) (n : nat) => Nat.add (nweight_ibs x) n) O (@app (prod Int nf_list) l0 l1)))) *) (* Goal: @eq nat (@fold_right nat (prod Int nf_list) (fun (x : prod Int nf_list) (n : nat) => Nat.add (nweight_ibs x) n) O (@cons (prod Int (list normal_form)) (@pair Int (list normal_form) i (@cons normal_form b nf_nil)) (@app (prod Int nf_list) l0 l1))) (@fold_right nat (prod Int nf_list) (fun (x : prod Int nf_list) (n : nat) => Nat.add (nweight_ibs x) n) O (@app (prod Int nf_list) l0 (@cons (prod Int nf_list) (@pair Int nf_list i (@cons normal_form b nf_nil)) l1))) *) (* Goal: @eq nat (S (Nat.add (nweight (nf2form b)) (@fold_right nat (prod Int nf_list) (fun (x : prod Int nf_list) (n : nat) => Nat.add (nweight_ibs x) n) O (lin_avl nf_list t)))) (@fold_right nat (prod Int nf_list) (fun (x : prod Int nf_list) (n : nat) => Nat.add (nweight_ibs x) n) O (lin_avl nf_list t')) *) rewrite (plus_O (nweight (nf2form b))). (* Goal: @eq nat (Nat.add (nweight_ni ni2) n) (Nat.add (nweight_ni ni2) n) *) trivial. symmetry in |- *. (* Goal: @eq nat (@fold_right nat (prod Int nf_list) (fun (x : prod Int nf_list) (n : nat) => Nat.add (nweight_ibs x) n) O (@app (prod Int nf_list) l0 (@cons (prod Int nf_list) (@pair Int nf_list i (@cons normal_form b d)) l1))) (@fold_right nat (prod Int nf_list) (fun (x : prod Int nf_list) (n : nat) => Nat.add (nweight_ibs x) n) O (@cons (prod Int (list normal_form)) (@pair Int (list normal_form) i (@cons normal_form b d)) (@app (prod Int nf_list) l0 l1))) *) apply nweight_ai_perm. (* Goal: @eq nat (S (Nat.add (nweight (nf2form b)) (@fold_right nat (prod Int nf_list) (fun (x : prod Int nf_list) (n : nat) => Nat.add (nweight_ibs x) n) O (lin_avl nf_list t)))) (@fold_right nat (prod Int nf_list) (fun (x : prod Int nf_list) (n : nat) => Nat.add (nweight_ibs x) n) O (lin_avl nf_list t')) *) rewrite H. (* Goal: @eq nat (S (Nat.add (nweight (nf2form b)) (@fold_right nat (prod Int nf_list) (fun (x : prod Int nf_list) (n : nat) => Nat.add (nweight_ibs x) n) O (@app (prod Int nf_list) l0 (@cons (prod Int nf_list) (@pair Int nf_list i d) l1))))) (@fold_right nat (prod Int nf_list) (fun (x : prod Int nf_list) (n : nat) => Nat.add (nweight_ibs x) n) O (lin_avl nf_list t')) *) rewrite H0. (* Goal: @eq nat (S (Nat.add (nweight (nf2form b)) (@fold_right nat (prod Int nf_list) (fun (x : prod Int nf_list) (n : nat) => Nat.add (nweight_ibs x) n) O (@app (prod Int nf_list) l0 (@cons (prod Int nf_list) (@pair Int nf_list i d) l1))))) (@fold_right nat (prod Int nf_list) (fun (x : prod Int nf_list) (n : nat) => Nat.add (nweight_ibs x) n) O (@app (prod Int nf_list) l0 (@cons (prod Int nf_list) (@pair Int nf_list i (@cons normal_form b d)) l1))) *) clear H H0. transitivity (fold_right (fun (x : Int * nf_list) (n : nat) => nweight_ibs x + n) 0 ((i, b :: d) :: l0 ++ l1)). change (S (nweight (nf2form b) + fold_right (fun (x : Int * nf_list) (n : nat) => nweight_ibs x + n) 0 (l0 ++ (i, d) :: l1)) = S (nweight (nf2form b) + nweight_bs d + fold_right (fun (x : Int * nf_list) (n : nat) => nweight_ibs x + n) 0 (l0 ++ l1))) in |- *. (* Goal: @eq nat (S (Nat.add (Nat.add b W) (Nat.add ds n))) (S (Nat.add W (Nat.add ds (Nat.add b n)))) *) apply S_reg. (* Goal: @eq nat (Nat.add (nweight (nf2form b)) (@fold_right nat (prod Int nf_list) (fun (x : prod Int nf_list) (n : nat) => Nat.add (nweight_ibs x) n) O (@app (prod Int nf_list) l0 (@cons (prod Int nf_list) (@pair Int nf_list i d) l1)))) (Nat.add (Nat.add (nweight (nf2form b)) (nweight_bs d)) (@fold_right nat (prod Int nf_list) (fun (x : prod Int nf_list) (n : nat) => Nat.add (nweight_ibs x) n) O (@app (prod Int nf_list) l0 l1))) *) (* Goal: @eq nat (@fold_right nat (prod Int nf_list) (fun (x : prod Int nf_list) (n : nat) => Nat.add (nweight_ibs x) n) O (@cons (prod Int (list normal_form)) (@pair Int (list normal_form) i (@cons normal_form b d)) (@app (prod Int nf_list) l0 l1))) (@fold_right nat (prod Int nf_list) (fun (x : prod Int nf_list) (n : nat) => Nat.add (nweight_ibs x) n) O (@app (prod Int nf_list) l0 (@cons (prod Int nf_list) (@pair Int nf_list i (@cons normal_form b d)) l1))) *) generalize (nweight (nf2form b)); clear b; intro b. rewrite (plus_assoc_reverse b (nweight_bs d) (fold_right (fun (x : Int * nf_list) (n : nat) => nweight_ibs x + n) 0 (l0 ++ l1))). (* Goal: @eq nat (Nat.add W (Nat.add b (Nat.add ds n))) (Nat.add W (Nat.add ds (Nat.add b n))) *) apply plus_reg. change (fold_right (fun (x : Int * nf_list) (n : nat) => nweight_ibs x + n) 0 (l0 ++ (i, d) :: l1) = fold_right (fun (x : Int * nf_list) (n : nat) => nweight_ibs x + n) 0 ((i, d) :: l0 ++ l1)) in |- *. (* Goal: @eq nat (@fold_right nat (prod Int nf_list) (fun (x : prod Int nf_list) (n : nat) => Nat.add (nweight_ibs x) n) O (@app (prod Int nf_list) l0 (@cons (prod Int nf_list) (@pair Int nf_list i (@cons normal_form b d)) l1))) (@fold_right nat (prod Int nf_list) (fun (x : prod Int nf_list) (n : nat) => Nat.add (nweight_ibs x) n) O (@cons (prod Int (list normal_form)) (@pair Int (list normal_form) i (@cons normal_form b d)) (@app (prod Int nf_list) l0 l1))) *) apply nweight_ai_perm. symmetry in |- *. (* Goal: @eq nat (@fold_right nat (prod Int nf_list) (fun (x : prod Int nf_list) (n : nat) => Nat.add (nweight_ibs x) n) O (@app (prod Int nf_list) l0 (@cons (prod Int nf_list) (@pair Int nf_list i (@cons normal_form b d)) l1))) (@fold_right nat (prod Int nf_list) (fun (x : prod Int nf_list) (n : nat) => Nat.add (nweight_ibs x) n) O (@cons (prod Int (list normal_form)) (@pair Int (list normal_form) i (@cons normal_form b d)) (@app (prod Int nf_list) l0 l1))) *) apply nweight_ai_perm. Qed. Remark nweight_ai_del : forall (i : Int) (bs : nf_list) (ai ai' : atomic_imps), REGULAR normal_form ai -> LOOKUP nf_list i ai bs -> LIN_DEL nf_list i bs ai ai' -> nweight_work bs + nweight_ai ai' < nweight_ai ai. (* Goal: forall (i : Int) (bs : nf_list) (ai ai' : atomic_imps) (_ : REGULAR normal_form ai) (_ : LOOKUP nf_list i ai bs) (_ : LIN_DEL nf_list i bs ai ai'), lt (Nat.add (nweight_work bs) (nweight_ai ai')) (nweight_ai ai) *) intros i bs ai ai'. (* Goal: forall (_ : REGULAR normal_form ai) (_ : LOOKUP nf_list i ai bs) (_ : LIN_DEL nf_list i bs ai ai'), lt (Nat.add (nweight_work bs) (nweight_ai ai')) (nweight_ai ai) *) elim ai; clear ai; intros t avl_t. (* Goal: forall (_ : REGULAR normal_form (AVL_intro nf_list t avl_t)) (_ : LOOKUP nf_list i (AVL_intro nf_list t avl_t) bs) (_ : LIN_DEL nf_list i bs (AVL_intro nf_list t avl_t) ai'), lt (Nat.add (nweight_work bs) (nweight_ai ai')) (nweight_ai (AVL_intro nf_list t avl_t)) *) elim ai'; clear ai'; intros t' avl_t'. (* Goal: le (S (Nat.add (nweight_work (@cons normal_form (NAtom j) work)) (Nat.add (nweight_ds ds) n))) (Nat.add (nweight_work work) (Nat.add (nweight_ds (@cons (prod Int Int) (@pair Int Int i j) ds)) n)) *) simpl in |- *. (* Goal: forall (_ : Regular normal_form t) (_ : lookup nf_list i t bs) (_ : lin_del_spec nf_list i bs t t'), lt (Nat.add (nweight_work bs) (nweight_ai (AVL_intro nf_list t' avl_t'))) (nweight_ai (AVL_intro nf_list t avl_t)) *) intros reg_t lookup lin_del. (* Goal: lt (Nat.add (nweight_work bs) (nweight_ai (AVL_intro nf_list t' avl_t'))) (nweight_ai (AVL_intro nf_list t avl_t)) *) unfold nweight_ai in |- *. (* Goal: lt (Nat.add (nweight_work bs) (@fold_right nat (prod Int nf_list) (fun (x : prod Int nf_list) (n : nat) => Nat.add (nweight_ibs x) n) O (LIN_AVL nf_list (AVL_intro nf_list t' avl_t')))) (@fold_right nat (prod Int nf_list) (fun (x : prod Int nf_list) (n : nat) => Nat.add (nweight_ibs x) n) O (LIN_AVL nf_list (AVL_intro nf_list t avl_t))) *) inversion_clear lin_del. (* Goal: le (S (Nat.add (nweight_work (@cons normal_form (NAtom j) work)) (Nat.add (nweight_ds ds) n))) (Nat.add (nweight_work work) (Nat.add (nweight_ds (@cons (prod Int Int) (@pair Int Int i j) ds)) n)) *) simpl in |- *. (* Goal: lt (Nat.add (nweight_work bs) (@fold_right nat (prod Int nf_list) (fun (x : prod Int nf_list) (n : nat) => Nat.add (nweight_ibs x) n) O (lin_avl nf_list t'))) (@fold_right nat (prod Int nf_list) (fun (x : prod Int nf_list) (n : nat) => Nat.add (nweight_ibs x) n) O (lin_avl nf_list t)) *) rewrite H; clear H. (* Goal: lt (Nat.add (nweight_work bs) (@fold_right nat (prod Int nf_list) (fun (x : prod Int nf_list) (n : nat) => Nat.add (nweight_ibs x) n) O (lin_avl nf_list t'))) (@fold_right nat (prod Int nf_list) (fun (x : prod Int nf_list) (n : nat) => Nat.add (nweight_ibs x) n) O (@app (prod Int nf_list) l0 (@cons (prod Int nf_list) (@pair Int nf_list i bs) l1))) *) rewrite H0; clear H0. (* Goal: lt (Nat.add (nweight_work bs) (@fold_right nat (prod Int nf_list) (fun (x : prod Int nf_list) (n : nat) => Nat.add (nweight_ibs x) n) O (@app (prod Int nf_list) l0 l1))) (@fold_right nat (prod Int nf_list) (fun (x : prod Int nf_list) (n : nat) => Nat.add (nweight_ibs x) n) O (@app (prod Int nf_list) l0 (@cons (prod Int nf_list) (@pair Int nf_list i bs) l1))) *) rewrite (nweight_ai_perm l0 l1 (i, bs)). (* Goal: le (S (Nat.add (nweight_work (@cons normal_form (NAtom j) work)) (Nat.add (nweight_ds ds) n))) (Nat.add (nweight_work work) (Nat.add (nweight_ds (@cons (prod Int Int) (@pair Int Int i j) ds)) n)) *) simpl in |- *. (* Goal: lt (Nat.add (nweight_work bs) (@fold_right nat (prod Int nf_list) (fun (x : prod Int nf_list) (n : nat) => Nat.add (nweight_ibs x) n) O (@app (prod Int nf_list) l0 l1))) (Nat.add (nweight_bs bs) (@fold_right nat (prod Int nf_list) (fun (x : prod Int nf_list) (n : nat) => Nat.add (nweight_ibs x) n) O (@app (prod Int nf_list) l0 l1))) *) apply plus_lt_compat_r. (* Goal: lt (nweight_work bs) (nweight_bs bs) *) generalize (reg_t i bs lookup); clear reg_t lookup. (* Goal: forall _ : forall _ : @eq (list normal_form) bs (@nil normal_form), False, lt (nweight_work bs) (nweight_bs bs) *) case bs; clear bs. (* Goal: forall _ : forall _ : @eq (list normal_form) (@nil normal_form) (@nil normal_form), False, lt (nweight_work (@nil normal_form)) (nweight_bs (@nil normal_form)) *) (* Goal: forall (n : normal_form) (l : list normal_form) (_ : forall _ : @eq (list normal_form) (@cons normal_form n l) (@nil normal_form), False), lt (nweight_work (@cons normal_form n l)) (nweight_bs (@cons normal_form n l)) *) intros H; elimtype False. (* Goal: @eq nat (Nat.add (nweight_ni ni2) n) (Nat.add (nweight_ni ni2) n) *) apply H; trivial. (* Goal: forall (n : normal_form) (l : list normal_form) (_ : forall _ : @eq (list normal_form) (@cons normal_form n l) (@nil normal_form), False), lt (nweight_work (@cons normal_form n l)) (nweight_bs (@cons normal_form n l)) *) intros b bs H. (* Goal: lt (nweight_work (@cons normal_form b bs)) (nweight_bs (@cons normal_form b bs)) *) unfold lt in |- *. (* Goal: le (S (nweight_work (@cons normal_form b bs))) (nweight_bs (@cons normal_form b bs)) *) unfold nweight_work in |- *. (* Goal: le (S (@fold_right nat normal_form (fun (a : normal_form) (n : nat) => Nat.add (nweight (nf2form a)) n) O (@cons normal_form b bs))) (nweight_bs (@cons normal_form b bs)) *) unfold nweight_bs in |- *. (* Goal: le (S (Nat.add (nweight_work (@cons normal_form (NAtom j) work)) (Nat.add (nweight_ds ds) n))) (Nat.add (nweight_work work) (Nat.add (nweight_ds (@cons (prod Int Int) (@pair Int Int i j) ds)) n)) *) simpl in |- *. (* Goal: le (S (Nat.add (nweight (nf2form b)) (@fold_right nat normal_form (fun (a : normal_form) (n : nat) => Nat.add (nweight (nf2form a)) n) O bs))) (S (Nat.add (nweight (nf2form b)) (@fold_right nat normal_form (fun (b : normal_form) (n : nat) => S (Nat.add (nweight (nf2form b)) n)) O bs))) *) apply le_n_S. (* Goal: le (Nat.add (nweight (nf2form b)) (@fold_right nat normal_form (fun (a : normal_form) (n : nat) => Nat.add (nweight (nf2form a)) n) O bs)) (Nat.add (nweight (nf2form b)) (@fold_right nat normal_form (fun (b : normal_form) (n : nat) => S (Nat.add (nweight (nf2form b)) n)) O bs)) *) apply plus_le_compat_l. (* Goal: le (@fold_right nat normal_form (fun (a : normal_form) (n : nat) => Nat.add (nweight (nf2form a)) n) O bs) (@fold_right nat normal_form (fun (b : normal_form) (n : nat) => S (Nat.add (nweight (nf2form b)) n)) O bs) *) elim bs; clear H bs. (* Goal: le (S (Nat.add (nweight_work (@cons normal_form (NAtom j) work)) (Nat.add (nweight_ds ds) n))) (Nat.add (nweight_work work) (Nat.add (nweight_ds (@cons (prod Int Int) (@pair Int Int i j) ds)) n)) *) simpl in |- *. (* Goal: le O O *) (* Goal: forall (a : normal_form) (l : list normal_form) (_ : le (@fold_right nat normal_form (fun (a0 : normal_form) (n : nat) => Nat.add (nweight (nf2form a0)) n) O l) (@fold_right nat normal_form (fun (b : normal_form) (n : nat) => S (Nat.add (nweight (nf2form b)) n)) O l)), le (@fold_right nat normal_form (fun (a0 : normal_form) (n : nat) => Nat.add (nweight (nf2form a0)) n) O (@cons normal_form a l)) (@fold_right nat normal_form (fun (b : normal_form) (n : nat) => S (Nat.add (nweight (nf2form b)) n)) O (@cons normal_form a l)) *) apply le_O_n. (* Goal: forall (a : normal_form) (l : list normal_form) (_ : le (@fold_right nat normal_form (fun (a0 : normal_form) (n : nat) => Nat.add (nweight (nf2form a0)) n) O l) (@fold_right nat normal_form (fun (b : normal_form) (n : nat) => S (Nat.add (nweight (nf2form b)) n)) O l)), le (@fold_right nat normal_form (fun (a0 : normal_form) (n : nat) => Nat.add (nweight (nf2form a0)) n) O (@cons normal_form a l)) (@fold_right nat normal_form (fun (b : normal_form) (n : nat) => S (Nat.add (nweight (nf2form b)) n)) O (@cons normal_form a l)) *) intros b0 bs ih. (* Goal: le (S (Nat.add (nweight_work (@cons normal_form (NAtom j) work)) (Nat.add (nweight_ds ds) n))) (Nat.add (nweight_work work) (Nat.add (nweight_ds (@cons (prod Int Int) (@pair Int Int i j) ds)) n)) *) simpl in |- *. change (nweight (nf2form b0) + fold_right (fun (a : normal_form) (n : nat) => nweight (nf2form a) + n) 0 bs <= S (nweight (nf2form b0)) + fold_right (fun (b : normal_form) (n : nat) => S (nweight (nf2form b) + n)) 0 bs) in |- *. (* Goal: le (Nat.add (nweight (nf2form b0)) (@fold_right nat normal_form (fun (a : normal_form) (n : nat) => Nat.add (nweight (nf2form a)) n) O bs)) (Nat.add (S (nweight (nf2form b0))) (@fold_right nat normal_form (fun (b : normal_form) (n : nat) => S (Nat.add (nweight (nf2form b)) n)) O bs)) *) apply plus_le_compat. (* Goal: le (nweight (nf2form b0)) (S (nweight (nf2form b0))) *) (* Goal: le (@fold_right nat normal_form (fun (a : normal_form) (n : nat) => Nat.add (nweight (nf2form a)) n) O bs) (@fold_right nat normal_form (fun (b : normal_form) (n : nat) => S (Nat.add (nweight (nf2form b)) n)) O bs) *) apply le_n_Sn. (* Goal: LIN_INS nf_list i (@cons normal_form b) nf_nil ai ai' *) assumption. Qed. (*********************************************************************) Remark nweight_eqv_ni : forall ni1 ni2 : nested_imps, eqv_ni ni1 ni2 -> nweight_ni ni1 = nweight_ni ni2. (* Goal: forall (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2), @eq nat (nweight_ni ni1) (nweight_ni ni2) *) intros ni1 ni2 eqv12. (* Goal: @eq nat (nweight_ni ni1) (nweight_ni ni2) *) elim eqv12; clear eqv12 ni1 ni2. (* Goal: @eq nat (Nat.add (nweight_ni ni2) n) (Nat.add (nweight_ni ni2) n) *) trivial. (* Goal: forall (x : nimp) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : @eq nat (nweight_ni ni1) (nweight_ni ni2)), @eq nat (nweight_ni (@cons nested_imp (Undecorated x) ni1)) (nweight_ni (@cons nested_imp (Undecorated x) ni2)) *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : @eq nat (nweight_ni ni1) (nweight_ni ni2)), @eq nat (nweight_ni (@cons nested_imp (Decorated x k) ni1)) (nweight_ni (@cons nested_imp (Undecorated x) ni2)) *) (* Goal: forall (x : nimp) (k k' : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : @eq nat (nweight_ni ni1) (nweight_ni ni2)), @eq nat (nweight_ni (@cons nested_imp (Decorated x k) ni1)) (nweight_ni (@cons nested_imp (Decorated x k') ni2)) *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : @eq nat (nweight_ni ni1) (nweight_ni ni2)), @eq nat (nweight_ni (@cons nested_imp (Undecorated x) ni1)) (nweight_ni (@cons nested_imp (Decorated x k) ni2)) *) intros x ni1 ni2 eqv12 ih. (* Goal: @eq nat (nweight_ni (@cons nested_imp (Undecorated x) ni1)) (nweight_ni (@cons nested_imp (Decorated x k) ni2)) *) unfold nweight_ni in |- *. (* Goal: le (S (Nat.add (nweight_work (@cons normal_form (NAtom j) work)) (Nat.add (nweight_ds ds) n))) (Nat.add (nweight_work work) (Nat.add (nweight_ds (@cons (prod Int Int) (@pair Int Int i j) ds)) n)) *) simpl in |- *. (* Goal: @eq nat (Nat.add (nweight_nestedimp (Undecorated x)) (@fold_right nat nested_imp (fun (x : nested_imp) (n : nat) => Nat.add (nweight_nestedimp x) n) O ni1)) (Nat.add (nweight_nestedimp (Decorated x k)) (@fold_right nat nested_imp (fun (x : nested_imp) (n : nat) => Nat.add (nweight_nestedimp x) n) O ni2)) *) fold nweight_ni in |- *. (* Goal: @eq nat (Nat.add (nweight_ni ni2) n) (Nat.add (nweight_ni ni2) n) *) rewrite ih; trivial. (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : @eq nat (nweight_ni ni1) (nweight_ni ni2)), @eq nat (nweight_ni (@cons nested_imp (Undecorated x) ni1)) (nweight_ni (@cons nested_imp (Decorated x k) ni2)) *) intros x k ni1 ni2 eqv12 ih. (* Goal: @eq nat (nweight_ni (@cons nested_imp (Undecorated x) ni1)) (nweight_ni (@cons nested_imp (Decorated x k) ni2)) *) unfold nweight_ni in |- *. (* Goal: le (S (Nat.add (nweight_work (@cons normal_form (NAtom j) work)) (Nat.add (nweight_ds ds) n))) (Nat.add (nweight_work work) (Nat.add (nweight_ds (@cons (prod Int Int) (@pair Int Int i j) ds)) n)) *) simpl in |- *. (* Goal: @eq nat (Nat.add (nweight_nestedimp (Undecorated x)) (@fold_right nat nested_imp (fun (x : nested_imp) (n : nat) => Nat.add (nweight_nestedimp x) n) O ni1)) (Nat.add (nweight_nestedimp (Decorated x k)) (@fold_right nat nested_imp (fun (x : nested_imp) (n : nat) => Nat.add (nweight_nestedimp x) n) O ni2)) *) fold nweight_ni in |- *. (* Goal: @eq nat (Nat.add (nweight_ni ni2) n) (Nat.add (nweight_ni ni2) n) *) rewrite ih; trivial. (* Goal: forall (x : nimp) (k k' : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : @eq nat (nweight_ni ni1) (nweight_ni ni2)), @eq nat (nweight_ni (@cons nested_imp (Decorated x k) ni1)) (nweight_ni (@cons nested_imp (Decorated x k') ni2)) *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : @eq nat (nweight_ni ni1) (nweight_ni ni2)), @eq nat (nweight_ni (@cons nested_imp (Undecorated x) ni1)) (nweight_ni (@cons nested_imp (Decorated x k) ni2)) *) intros x k k' ni1 ni2 eqv12 ih. (* Goal: @eq nat (nweight_ni (@cons nested_imp (Undecorated x) ni1)) (nweight_ni (@cons nested_imp (Decorated x k) ni2)) *) unfold nweight_ni in |- *. (* Goal: le (S (Nat.add (nweight_work (@cons normal_form (NAtom j) work)) (Nat.add (nweight_ds ds) n))) (Nat.add (nweight_work work) (Nat.add (nweight_ds (@cons (prod Int Int) (@pair Int Int i j) ds)) n)) *) simpl in |- *. (* Goal: @eq nat (Nat.add (nweight_nestedimp (Undecorated x)) (@fold_right nat nested_imp (fun (x : nested_imp) (n : nat) => Nat.add (nweight_nestedimp x) n) O ni1)) (Nat.add (nweight_nestedimp (Decorated x k)) (@fold_right nat nested_imp (fun (x : nested_imp) (n : nat) => Nat.add (nweight_nestedimp x) n) O ni2)) *) fold nweight_ni in |- *. (* Goal: @eq nat (Nat.add (nweight_ni ni2) n) (Nat.add (nweight_ni ni2) n) *) rewrite ih; trivial. (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : eqv_ni ni1 ni2) (_ : @eq nat (nweight_ni ni1) (nweight_ni ni2)), @eq nat (nweight_ni (@cons nested_imp (Undecorated x) ni1)) (nweight_ni (@cons nested_imp (Decorated x k) ni2)) *) intros x k ni1 ni2 eqv12 ih. (* Goal: @eq nat (nweight_ni (@cons nested_imp (Undecorated x) ni1)) (nweight_ni (@cons nested_imp (Decorated x k) ni2)) *) unfold nweight_ni in |- *. (* Goal: le (S (Nat.add (nweight_work (@cons normal_form (NAtom j) work)) (Nat.add (nweight_ds ds) n))) (Nat.add (nweight_work work) (Nat.add (nweight_ds (@cons (prod Int Int) (@pair Int Int i j) ds)) n)) *) simpl in |- *. (* Goal: @eq nat (Nat.add (nweight_nestedimp (Undecorated x)) (@fold_right nat nested_imp (fun (x : nested_imp) (n : nat) => Nat.add (nweight_nestedimp x) n) O ni1)) (Nat.add (nweight_nestedimp (Decorated x k)) (@fold_right nat nested_imp (fun (x : nested_imp) (n : nat) => Nat.add (nweight_nestedimp x) n) O ni2)) *) fold nweight_ni in |- *. (* Goal: @eq nat (Nat.add (nweight_ni ni2) n) (Nat.add (nweight_ni ni2) n) *) rewrite ih; trivial. Qed. Remark nweight_rev_app : forall (dni : decorated_nested_imps) (ni : nested_imps), nweight_ni ni + nweight_dni dni = nweight_ni (rev_app dni ni). (* Goal: forall (dni : decorated_nested_imps) (ni : nested_imps), @eq nat (Nat.add (nweight_ni ni) (nweight_dni dni)) (nweight_ni (rev_app dni ni)) *) intros dni; elim dni; clear dni. (* Goal: le (S (Nat.add (nweight_work (@cons normal_form (NAtom j) work)) (Nat.add (nweight_ds ds) n))) (Nat.add (nweight_work work) (Nat.add (nweight_ds (@cons (prod Int Int) (@pair Int Int i j) ds)) n)) *) intros ni; unfold nweight_dni in |- *; simpl in |- *. (* Goal: @eq nat (Nat.add (nweight_ni ni) O) (nweight_ni ni) *) (* Goal: forall (a : decorated_nested_imp) (l : list decorated_nested_imp) (_ : forall ni : nested_imps, @eq nat (Nat.add (nweight_ni ni) (nweight_dni l)) (nweight_ni (rev_app l ni))) (ni : nested_imps), @eq nat (Nat.add (nweight_ni ni) (nweight_dni (@cons decorated_nested_imp a l))) (nweight_ni (rev_app (@cons decorated_nested_imp a l) ni)) *) apply plus_O. (* Goal: forall (a : decorated_nested_imp) (l : list decorated_nested_imp) (_ : forall ni : nested_imps, @eq nat (Nat.add (nweight_ni ni) (nweight_dni l)) (nweight_ni (rev_app l ni))) (ni : nested_imps), @eq nat (Nat.add (nweight_ni ni) (nweight_dni (@cons decorated_nested_imp a l))) (nweight_ni (rev_app (@cons decorated_nested_imp a l) ni)) *) intros x dni ih ni. (* Goal: @eq nat (Nat.add (nweight_ni ni) (nweight_dni (@cons decorated_nested_imp x dni))) (nweight_ni (rev_app (@cons decorated_nested_imp x dni) ni)) *) case x; clear x. (* Goal: forall (n : nimp) (k : kripke_tree), @eq nat (Nat.add (nweight_ni ni) (nweight_dni (@cons decorated_nested_imp (@pair nimp kripke_tree n k) dni))) (nweight_ni (rev_app (@cons decorated_nested_imp (@pair nimp kripke_tree n k) dni) ni)) *) intros n k. (* Goal: le (S (Nat.add (nweight_work (@cons normal_form (NAtom j) work)) (Nat.add (nweight_ds ds) n))) (Nat.add (nweight_work work) (Nat.add (nweight_ds (@cons (prod Int Int) (@pair Int Int i j) ds)) n)) *) simpl in |- *. (* Goal: @eq nat (Nat.add (nweight_ni ni) (Nat.add (nweight (nimp2form n)) (nweight_dni dni))) (nweight_ni (rev_app dni (@cons nested_imp (Decorated n k) ni))) *) rewrite <- (ih (Decorated n k :: ni)); clear ih. (* Goal: @eq nat (Nat.add (nweight_nestedimp (Undecorated x)) (@fold_right nat nested_imp (fun (x : nested_imp) (n : nat) => Nat.add (nweight_nestedimp x) n) O ni1)) (Nat.add (nweight_nestedimp (Decorated x k)) (@fold_right nat nested_imp (fun (x : nested_imp) (n : nat) => Nat.add (nweight_nestedimp x) n) O ni2)) *) unfold nweight_ni in |- *; simpl in |- *; fold nweight_ni in |- *. (* Goal: @eq nat (Nat.add (nweight_ni ni) (Nat.add (nweight (nimp2form n)) (nweight_dni dni))) (Nat.add (Nat.add (nweight_nestedimp (Decorated n k)) (nweight_ni ni)) (nweight_dni dni)) *) unfold nweight_nestedimp in |- *. (* Goal: @eq nat (Nat.add (nweight_ni ni) (Nat.add (nweight (nimp2form n)) (nweight_dni dni))) (Nat.add (Nat.add (nweight (nested_imp2form (Decorated n k))) (nweight_ni ni)) (nweight_dni dni)) *) unfold nested_imp2form in |- *. (* Goal: le (S (Nat.add (nweight_work (@cons normal_form (NAtom j) work)) (Nat.add (nweight_ds ds) n))) (Nat.add (nweight_work work) (Nat.add (nweight_ds (@cons (prod Int Int) (@pair Int Int i j) ds)) n)) *) simpl in |- *. (* Goal: @eq nat (Nat.add (nweight_ni ni) (Nat.add (nweight (nimp2form n)) (nweight_dni dni))) (Nat.add (Nat.add (nweight (nimp2form n)) (nweight_ni ni)) (nweight_dni dni)) *) generalize (nweight (nimp2form n)); clear n; intros n. (* Goal: @eq nat (Nat.add (Nat.add (nweight (nimp2form x)) W) (Nat.add ds (Nat.add (nweight_ni ni) ai))) (Nat.add W (Nat.add ds (Nat.add (Nat.add (nweight_nestedimp (Undecorated x)) (nweight_ni ni)) ai))) *) generalize (nweight_ni ni); clear ni; intros ni. (* Goal: @eq nat (Nat.add ni (Nat.add n (nweight_dni dni))) (Nat.add (Nat.add n ni) (nweight_dni dni)) *) generalize (nweight_dni dni); clear dni; intros dni. (* Goal: @eq nat (Nat.add ni (Nat.add n dni)) (Nat.add (Nat.add n ni) dni) *) rewrite (plus_assoc ni n dni). (* Goal: @eq nat (PeanoNat.Nat.add (PeanoNat.Nat.add ni n) dni) (Nat.add (Nat.add n ni) dni) *) rewrite (plus_comm ni n). (* Goal: @eq nat (Nat.add (nweight_ni ni2) n) (Nat.add (nweight_ni ni2) n) *) trivial. Qed. (**********************************************************************) Definition nweight_Sequent (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) := nweight_work work + (nweight_ds ds + (nweight_ni ni + nweight_ai ai)). Lemma nweight_shift_work_ni0 : forall (x : nimp) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps), nweight_Sequent (NImp_NF x :: work) ds ni ai = nweight_Sequent work ds (Undecorated x :: ni) ai. (* Goal: forall (x : nimp) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps), @eq nat (nweight_Sequent (@cons normal_form (NImp_NF x) work) ds ni ai) (nweight_Sequent work ds (@cons nested_imp (Undecorated x) ni) ai) *) intros x work ds ni ai. (* Goal: le (S (nweight_Sequent (@cons normal_form (NAtom j) work) ds ni2 ai)) (nweight_Sequent work (@cons (prod Int Int) (@pair Int Int i j) ds) ni1 ai) *) unfold nweight_Sequent in |- *. (* Goal: le (S (Nat.add (nweight_work (@cons normal_form (NAtom j) work)) (Nat.add (nweight_ds ds) n))) (Nat.add (nweight_work work) (Nat.add (nweight_ds (@cons (prod Int Int) (@pair Int Int i j) ds)) n)) *) simpl in |- *. (* Goal: @eq nat (Nat.add (Nat.add (nweight (nimp2form x)) (nweight_work work)) (Nat.add (nweight_ds ds) (Nat.add (nweight_ni ni) (nweight_ai ai)))) (Nat.add (nweight_work work) (Nat.add (nweight_ds ds) (Nat.add (Nat.add (nweight_nestedimp (Undecorated x)) (nweight_ni ni)) (nweight_ai ai)))) *) fold nimp2form in |- *. (* Goal: @eq nat (Nat.add (Nat.add (nweight (nimp2form x)) (nweight_work work)) (Nat.add (nweight_ds ds) (Nat.add (nweight_ni ni) (nweight_ai ai)))) (Nat.add (nweight_work work) (Nat.add (nweight_ds ds) (Nat.add (Nat.add (nweight_nestedimp (Undecorated x)) (nweight_ni ni)) (nweight_ai ai)))) *) generalize (nweight_ai ai); clear ai; intro ai. (* Goal: lt (Nat.add (nweight_work (@app normal_form bs work)) (Nat.add (nweight_ds ds) (Nat.add (nweight_ni ni) (nweight_ai ai')))) (Nat.add (nweight_work work) (Nat.add (nweight_ds ds) (Nat.add (nweight_ni ni) (nweight_ai ai)))) *) generalize (nweight_ds ds); clear ds; intro ds. (* Goal: lt (Nat.add (Nat.add (nweight_work bs) (nweight_work work)) (Nat.add ds (Nat.add ni (nweight_ai ai')))) (Nat.add (nweight_work work) (Nat.add ds (Nat.add ni (nweight_ai ai)))) *) generalize (nweight_work work); clear work; intro W. (* Goal: @eq nat (Nat.add (Nat.add (nweight (nimp2form x)) W) (Nat.add ds (Nat.add (nweight_ni ni) ai))) (Nat.add W (Nat.add ds (Nat.add (Nat.add (nweight_nestedimp (Undecorated x)) (nweight_ni ni)) ai))) *) generalize (nweight_ni ni); clear ni; intros ni. change (nweight (nimp2form x) + W + (ds + (ni + ai)) = W + (ds + (nweight (nimp2form x) + ni + ai))) in |- *. (* Goal: @eq nat (Nat.add (Nat.add (nweight (nimp2form x)) W) (Nat.add ds (Nat.add ni ai))) (Nat.add W (Nat.add ds (Nat.add (Nat.add (nweight (nimp2form x)) ni) ai))) *) generalize (nweight (nimp2form x)); clear x; intro x. (* Goal: @eq nat (Nat.add (Nat.add x W) (Nat.add ds (Nat.add ni ai))) (Nat.add W (Nat.add ds (Nat.add (Nat.add x ni) ai))) *) rewrite (plus_comm x W). (* Goal: @eq nat (Nat.add (PeanoNat.Nat.add W x) (Nat.add ds (Nat.add ni ai))) (Nat.add W (Nat.add ds (Nat.add (Nat.add x ni) ai))) *) rewrite (plus_assoc_reverse W x (ds + (ni + ai))). (* Goal: @eq nat (Nat.add W (Nat.add b (Nat.add ds n))) (Nat.add W (Nat.add ds (Nat.add b n))) *) apply plus_reg. (* Goal: @eq nat (Nat.add x (Nat.add ds (Nat.add ni ai))) (Nat.add ds (Nat.add (Nat.add x ni) ai)) *) rewrite (plus_assoc x ds (ni + ai)). (* Goal: @eq nat (PeanoNat.Nat.add (PeanoNat.Nat.add x ds) (Nat.add ni ai)) (Nat.add ds (Nat.add (Nat.add x ni) ai)) *) rewrite (plus_comm x ds). (* Goal: @eq nat (PeanoNat.Nat.add (PeanoNat.Nat.add ds x) (Nat.add ni ai)) (Nat.add ds (Nat.add (Nat.add x ni) ai)) *) rewrite (plus_assoc_reverse ds x (ni + ai)). (* Goal: @eq nat (Nat.add W (Nat.add b (Nat.add ds n))) (Nat.add W (Nat.add ds (Nat.add b n))) *) apply plus_reg. (* Goal: @eq nat (Nat.add x (Nat.add ni ai)) (Nat.add (Nat.add x ni) ai) *) apply plus_assoc. Qed. Lemma nweight_shift_work_ds : forall (i j : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps), nweight_Sequent (NDisj i j :: work) ds ni ai = nweight_Sequent work ((i, j) :: ds) ni ai. (* Goal: forall (i j : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps), @eq nat (nweight_Sequent (@cons normal_form (NDisj i j) work) ds ni ai) (nweight_Sequent work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai) *) intros i j work ds ni ai. (* Goal: le (S (nweight_Sequent (@cons normal_form (NAtom j) work) ds ni2 ai)) (nweight_Sequent work (@cons (prod Int Int) (@pair Int Int i j) ds) ni1 ai) *) unfold nweight_Sequent in |- *. (* Goal: @eq nat (Nat.add (nweight_work (@cons normal_form (NDisj i j) work)) (Nat.add (nweight_ds ds) (Nat.add (nweight_ni ni) (nweight_ai ai)))) (Nat.add (nweight_work work) (Nat.add (nweight_ds (@cons (prod Int Int) (@pair Int Int i j) ds)) (Nat.add (nweight_ni ni) (nweight_ai ai)))) *) generalize (nweight_ni ni + nweight_ai ai). (* Goal: forall n : nat, @eq nat (Nat.add (nweight_work (@cons normal_form (NDisj i j) work)) (Nat.add (nweight_ds ds) n)) (Nat.add (nweight_work work) (Nat.add (nweight_ds (@cons (prod Int Int) (@pair Int Int i j) ds)) n)) *) clear ni ai; intros n. (* Goal: le (S (Nat.add (nweight_work (@cons normal_form (NAtom j) work)) (Nat.add (nweight_ds ds) n))) (Nat.add (nweight_work work) (Nat.add (nweight_ds (@cons (prod Int Int) (@pair Int Int i j) ds)) n)) *) simpl in |- *. (* Goal: @eq nat (S (Nat.add (nweight_work work) (Nat.add (nweight_ds ds) n))) (Nat.add (nweight_work work) (S (Nat.add (nweight_ds ds) n))) *) fold nweight_work in |- *. (* Goal: @eq nat (S (Nat.add (nweight_work work) (Nat.add (nweight_ds ds) n))) (Nat.add (nweight_work work) (S (Nat.add (nweight_ds ds) n))) *) fold nweight_ds in |- *. (* Goal: @eq nat (S (Nat.add (nweight_work work) (Nat.add (nweight_ds ds) n))) (Nat.add (nweight_work work) (S (Nat.add (nweight_ds ds) n))) *) rewrite <- (plus_Snm_nSm (nweight_work work) (nweight_ds ds + n)). (* Goal: @eq nat (Nat.add (nweight_ni ni2) n) (Nat.add (nweight_ni ni2) n) *) trivial. Qed. Lemma nweight_shift_work_ai : forall (i : Int) (b : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai ai' : atomic_imps), LIN_INS nf_list i (cons b) nf_nil ai ai' -> nweight_Sequent (AImp i b :: work) ds ni ai = nweight_Sequent work ds ni ai'. (* Goal: forall (i : Int) (b : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai ai' : atomic_imps) (_ : LIN_INS nf_list i (@cons normal_form b) nf_nil ai ai'), @eq nat (nweight_Sequent (@cons normal_form (AImp i b) work) ds ni ai) (nweight_Sequent work ds ni ai') *) intros. (* Goal: le (S (nweight_Sequent (@cons normal_form (NAtom j) work) ds ni2 ai)) (nweight_Sequent work (@cons (prod Int Int) (@pair Int Int i j) ds) ni1 ai) *) unfold nweight_Sequent in |- *. (* Goal: @eq nat (Nat.add (nweight_work (@cons normal_form (AImp i b) work)) (Nat.add (nweight_ds ds) (Nat.add (nweight_ni ni) (nweight_ai ai)))) (Nat.add (nweight_work work) (Nat.add (nweight_ds ds) (Nat.add (nweight_ni ni) (nweight_ai ai')))) *) rewrite <- (nweight_ai_ins i b ai ai'). (* Goal: @eq nat (Nat.add (nweight_work (@cons normal_form (AImp i b) work)) (Nat.add (nweight_ds ds) (Nat.add (nweight_ni ni) (nweight_ai ai)))) (Nat.add (nweight_work work) (Nat.add (nweight_ds ds) (Nat.add (nweight_ni ni) (Nat.add (nweight (nf2form (AImp i b))) (nweight_ai ai))))) *) (* Goal: LIN_INS nf_list i (@cons normal_form b) nf_nil ai ai' *) generalize (nweight_ai ai); clear H ai ai'; intro ai. (* Goal: lt (Nat.add (nweight_work (@app normal_form bs work)) (Nat.add (nweight_ds ds) (Nat.add (nweight_ni ni) (nweight_ai ai')))) (Nat.add (nweight_work work) (Nat.add (nweight_ds ds) (Nat.add (nweight_ni ni) (nweight_ai ai)))) *) generalize (nweight_ds ds); clear ds; intro ds. (* Goal: lt (Nat.add (nweight_work (@app normal_form bs work)) (Nat.add ds (Nat.add (nweight_ni ni) (nweight_ai ai')))) (Nat.add (nweight_work work) (Nat.add ds (Nat.add (nweight_ni ni) (nweight_ai ai)))) *) generalize (nweight_ni ni); clear ni; intro ni. change (nweight (nf2form (AImp i b)) + nweight_work work + (ds + (ni + ai)) = nweight_work work + (ds + (ni + (nweight (nf2form (AImp i b)) + ai)))) in |- *. (* Goal: @eq nat (Nat.add (Nat.add (nweight (nf2form (AImp i b))) (nweight_work work)) (Nat.add ds (Nat.add ni ai))) (Nat.add (nweight_work work) (Nat.add ds (Nat.add ni (Nat.add (nweight (nf2form (AImp i b))) ai)))) *) (* Goal: LIN_INS nf_list i (@cons normal_form b) nf_nil ai ai' *) generalize (nweight_work work); clear work; intro work. (* Goal: @eq nat (Nat.add (Nat.add (nweight (nf2form (AImp i b))) work) (Nat.add ds (Nat.add ni ai))) (Nat.add work (Nat.add ds (Nat.add ni (Nat.add (nweight (nf2form (AImp i b))) ai)))) *) (* Goal: LIN_INS nf_list i (@cons normal_form b) nf_nil ai ai' *) generalize (nweight (nf2form (AImp i b))); clear i b; intro a. (* Goal: @eq nat (Nat.add (Nat.add a work) (Nat.add ds (Nat.add ni ai))) (Nat.add work (Nat.add ds (Nat.add ni (Nat.add a ai)))) *) (* Goal: LIN_INS nf_list i (@cons normal_form b) nf_nil ai ai' *) rewrite (plus_comm a work). (* Goal: @eq nat (Nat.add (PeanoNat.Nat.add work a) (Nat.add ds (Nat.add ni ai))) (Nat.add work (Nat.add ds (Nat.add ni (Nat.add a ai)))) *) (* Goal: LIN_INS nf_list i (@cons normal_form b) nf_nil ai ai' *) rewrite (plus_assoc_reverse work a (ds + (ni + ai))). (* Goal: @eq nat (Nat.add W (Nat.add b (Nat.add ds n))) (Nat.add W (Nat.add ds (Nat.add b n))) *) apply plus_reg. (* Goal: @eq nat (Nat.add a (Nat.add ds (Nat.add ni ai))) (Nat.add ds (Nat.add ni (Nat.add a ai))) *) (* Goal: LIN_INS nf_list i (@cons normal_form b) nf_nil ai ai' *) rewrite (plus_permute a ds (ni + ai)). (* Goal: @eq nat (Nat.add W (Nat.add b (Nat.add ds n))) (Nat.add W (Nat.add ds (Nat.add b n))) *) apply plus_reg. (* Goal: @eq nat (PeanoNat.Nat.add a (Nat.add ni ai)) (Nat.add ni (Nat.add a ai)) *) (* Goal: LIN_INS nf_list i (@cons normal_form b) nf_nil ai ai' *) rewrite (plus_permute a ni ai). (* Goal: @eq nat (Nat.add W (Nat.add b (Nat.add ds n))) (Nat.add W (Nat.add ds (Nat.add b n))) *) apply plus_reg. (* Goal: @eq nat (Nat.add (nweight_ni ni2) n) (Nat.add (nweight_ni ni2) n) *) trivial. (* Goal: LIN_INS nf_list i (@cons normal_form b) nf_nil ai ai' *) assumption. Qed. (*******************************************************************) Lemma nweight_shift_ai_work : forall (i : Int) (bs work : nf_list) (ds : disjs) (ni : nested_imps) (ai ai' : atomic_imps), LOOKUP nf_list i ai bs -> REGULAR normal_form ai -> LIN_DEL nf_list i bs ai ai' -> nweight_Sequent (bs ++ work) ds ni ai' < nweight_Sequent work ds ni ai. (* Goal: forall (i : Int) (bs work : nf_list) (ds : disjs) (ni : nested_imps) (ai ai' : atomic_imps) (_ : LOOKUP nf_list i ai bs) (_ : REGULAR normal_form ai) (_ : LIN_DEL nf_list i bs ai ai'), lt (nweight_Sequent (@app normal_form bs work) ds ni ai') (nweight_Sequent work ds ni ai) *) intros i bs work ds ni ai ai' lookup reg_ai lin_del. (* Goal: le (S (nweight_Sequent (@cons normal_form (NAtom j) work) ds ni2 ai)) (nweight_Sequent work (@cons (prod Int Int) (@pair Int Int i j) ds) ni1 ai) *) unfold nweight_Sequent in |- *. (* Goal: lt (Nat.add (nweight_work (@app normal_form bs work)) (Nat.add (nweight_ds ds) (Nat.add (nweight_ni ni) (nweight_ai ai')))) (Nat.add (nweight_work work) (Nat.add (nweight_ds ds) (Nat.add (nweight_ni ni) (nweight_ai ai)))) *) generalize (nweight_ds ds); clear ds; intro ds. (* Goal: lt (Nat.add (nweight_work (@app normal_form bs work)) (Nat.add ds (Nat.add (nweight_ni ni) (nweight_ai ai')))) (Nat.add (nweight_work work) (Nat.add ds (Nat.add (nweight_ni ni) (nweight_ai ai)))) *) generalize (nweight_ni ni); clear ni; intro ni. (* Goal: lt (Nat.add (nweight_work (@app normal_form bs work)) (Nat.add ds (Nat.add ni (nweight_ai ai')))) (Nat.add (nweight_work work) (Nat.add ds (Nat.add ni (nweight_ai ai)))) *) rewrite (nweight_work_app bs work). (* Goal: lt (Nat.add (Nat.add (nweight_work bs) (nweight_work work)) (Nat.add ds (Nat.add ni (nweight_ai ai')))) (Nat.add (nweight_work work) (Nat.add ds (Nat.add ni (nweight_ai ai)))) *) generalize (nweight_work work); clear work; intro W. (* Goal: lt (Nat.add (Nat.add (nweight_work bs) W) (Nat.add ds (Nat.add ni (nweight_ai ai')))) (Nat.add W (Nat.add ds (Nat.add ni (nweight_ai ai)))) *) rewrite (plus_comm (nweight_work bs) W). rewrite (plus_assoc_reverse W (nweight_work bs) (ds + (ni + nweight_ai ai'))) . (* Goal: lt (PeanoNat.Nat.add ni (PeanoNat.Nat.add (nweight_work bs) (nweight_ai ai'))) (Nat.add ni (nweight_ai ai)) *) apply plus_lt_compat_l. (* Goal: lt (Nat.add (nweight_work bs) (Nat.add ds (Nat.add ni (nweight_ai ai')))) (Nat.add ds (Nat.add ni (nweight_ai ai))) *) rewrite (plus_permute (nweight_work bs) ds (ni + nweight_ai ai')). (* Goal: lt (PeanoNat.Nat.add ni (PeanoNat.Nat.add (nweight_work bs) (nweight_ai ai'))) (Nat.add ni (nweight_ai ai)) *) apply plus_lt_compat_l. (* Goal: lt (PeanoNat.Nat.add (nweight_work bs) (Nat.add ni (nweight_ai ai'))) (Nat.add ni (nweight_ai ai)) *) rewrite (plus_permute (nweight_work bs) ni (nweight_ai ai')). (* Goal: lt (PeanoNat.Nat.add ni (PeanoNat.Nat.add (nweight_work bs) (nweight_ai ai'))) (Nat.add ni (nweight_ai ai)) *) apply plus_lt_compat_l. (* Goal: LIN_INS nf_list i (@cons normal_form b) nf_nil ai ai' *) apply nweight_ai_del with i; assumption. Qed. (*************************************************************************) Lemma nweight_sequent_eqv : forall (work : nf_list) (ds : disjs) (ni1 ni2 : nested_imps) (ai : atomic_imps), eqv_ni ni1 ni2 -> nweight_Sequent work ds ni1 ai = nweight_Sequent work ds ni2 ai. (* Goal: forall (work : nf_list) (ds : disjs) (ni1 ni2 : nested_imps) (ai : atomic_imps) (_ : eqv_ni ni1 ni2), @eq nat (nweight_Sequent work ds ni1 ai) (nweight_Sequent work ds ni2 ai) *) intros work ds ni1 ni2 ai eqv12. (* Goal: le (S (nweight_Sequent (@cons normal_form (NAtom j) work) ds ni2 ai)) (nweight_Sequent work (@cons (prod Int Int) (@pair Int Int i j) ds) ni1 ai) *) unfold nweight_Sequent in |- *. (* Goal: @eq nat (Nat.add W (Nat.add b (Nat.add ds n))) (Nat.add W (Nat.add ds (Nat.add b n))) *) apply plus_reg. (* Goal: @eq nat (Nat.add W (Nat.add b (Nat.add ds n))) (Nat.add W (Nat.add ds (Nat.add b n))) *) apply plus_reg. (* Goal: @eq nat (Nat.add (nweight_ni ni1) (nweight_ai ai)) (Nat.add (nweight_ni ni2) (nweight_ai ai)) *) generalize (nweight_ai ai); clear work ds ai. (* Goal: forall n : nat, @eq nat (Nat.add (nweight_ni ni1) n) (Nat.add (nweight_ni ni2) n) *) intros n. (* Goal: @eq nat (Nat.add (nweight_ni ni1) n) (Nat.add (nweight_ni ni2) n) *) rewrite (nweight_eqv_ni ni1 ni2 eqv12). (* Goal: @eq nat (Nat.add (nweight_ni ni2) n) (Nat.add (nweight_ni ni2) n) *) trivial. Qed. (*******************************************************************) Lemma nweight_sequent_nimp_left : forall (a0 a1 : Int) (b : normal_form) (work : nf_list) (ds : disjs) (ni1 ni2 : nested_imps) (dni1 : decorated_nested_imps) (ai : atomic_imps) (n : nat), eqv_ni (rev_app dni1 ni1) ni2 -> nweight_Sequent work ds (rev_app dni1 (Undecorated (NImp a0 a1 b) :: ni1)) ai < S n -> nweight_Sequent (AImp a1 b :: NAtom a0 :: work) ds ni2 ai < n. (* Goal: forall (a0 a1 : Int) (b : normal_form) (work : nf_list) (ds : disjs) (ni1 ni2 : nested_imps) (dni1 : decorated_nested_imps) (ai : atomic_imps) (n : nat) (_ : eqv_ni (rev_app dni1 ni1) ni2) (_ : lt (nweight_Sequent work ds (rev_app dni1 (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni1)) ai) (S n)), lt (nweight_Sequent (@cons normal_form b work) ds ni2 ai) n *) intros a0 a1 b work ds ni1 ni2 dni1 ai n eqv12 lt1. (* Goal: lt (nweight_Sequent (@cons normal_form (NAtom j) work) ds ni2 ai) n *) apply lt_S_n. apply eq_lt_trans with (nweight_Sequent work ds (rev_app dni1 (Undecorated (NImp a0 a1 b) :: ni1)) ai); try assumption; clear lt1. (* Goal: le (S (nweight_Sequent (@cons normal_form (NAtom j) work) ds ni2 ai)) (nweight_Sequent work (@cons (prod Int Int) (@pair Int Int i j) ds) ni1 ai) *) unfold nweight_Sequent in |- *. (* Goal: le (S (Nat.add (nweight_work (@cons normal_form (NAtom j) work)) (Nat.add (nweight_ds ds) (Nat.add (nweight_ni ni2) (nweight_ai ai))))) (Nat.add (nweight_work work) (Nat.add (nweight_ds (@cons (prod Int Int) (@pair Int Int i j) ds)) (Nat.add (nweight_ni ni1) (nweight_ai ai)))) *) generalize (nweight_ai ai); clear ai; intros ai. (* Goal: le (S (Nat.add W (Nat.add (nweight_ds ds) n))) (Nat.add W (S (Nat.add (nweight_ds ds) n))) *) generalize (nweight_ds ds); clear ds; intros ds. (* Goal: lt (S (Nat.add (nweight_work (@cons normal_form b work)) (Nat.add ds (Nat.add (nweight_ni ni2) ai)))) (Nat.add (nweight_work work) (Nat.add ds (Nat.add (nweight_ni (rev_app dni1 (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni1))) ai))) *) rewrite <- (nweight_rev_app dni1 (Undecorated (NImp a0 a1 b) :: ni1)). (* Goal: le (S (Nat.add (nweight_work (@cons normal_form (NAtom j) work)) (Nat.add (nweight_ds ds) n))) (Nat.add (nweight_work work) (Nat.add (nweight_ds (@cons (prod Int Int) (@pair Int Int i j) ds)) n)) *) simpl in |- *. (* Goal: lt (S (Nat.add (Nat.add (nweight (nf2form b)) (nweight_work work)) (Nat.add ds (Nat.add (nweight_ni ni2) ai)))) (Nat.add (nweight_work work) (Nat.add ds (S (S (Nat.add (Nat.add (Nat.add (nweight (nf2form b)) (nweight_ni ni1)) (nweight_dni dni1)) ai))))) *) fold nf2form in |- *. (* Goal: lt (S (Nat.add (Nat.add (nweight (nf2form b)) (nweight_work work)) (Nat.add ds (Nat.add (nweight_ni ni2) ai)))) (Nat.add (nweight_work work) (Nat.add ds (S (S (Nat.add (Nat.add (Nat.add (nweight (nf2form b)) (nweight_ni ni1)) (nweight_dni dni1)) ai))))) *) generalize (nweight (nf2form b)); clear b; intros b. (* Goal: lt (S (Nat.add (Nat.add b W) (Nat.add ds (Nat.add (nweight_ni ni2) ai)))) (Nat.add W (Nat.add ds (S (S (Nat.add (Nat.add (Nat.add b (nweight_ni ni1)) (nweight_dni dni1)) ai))))) *) rewrite (plus_assoc_reverse b (nweight_ni ni1) (nweight_dni dni1)). (* Goal: @eq nat (S (S (Nat.add (Nat.add b (nweight_work work)) (Nat.add ds (Nat.add (nweight_ni ni2) ai))))) (Nat.add (nweight_work work) (Nat.add ds (S (S (Nat.add (Nat.add b (Nat.add (nweight_ni ni1) (nweight_dni dni1))) ai))))) *) rewrite <- (nweight_eqv_ni (rev_app dni1 ni1) ni2 eqv12). (* Goal: @eq nat (S (S (Nat.add (Nat.add b (nweight_work work)) (Nat.add ds (Nat.add (nweight_ni (rev_app dni1 ni1)) ai))))) (Nat.add (nweight_work work) (Nat.add ds (S (S (Nat.add (Nat.add b (Nat.add (nweight_ni ni1) (nweight_dni dni1))) ai))))) *) rewrite <- (nweight_rev_app dni1 ni1). generalize (nweight_ni ni1 + nweight_dni dni1); clear eqv12 ni1 dni1 ni2 n; (* Goal: forall n : nat, @eq nat (Nat.add (nweight_ni ni1) n) (Nat.add (nweight_ni ni2) n) *) intros n. (* Goal: le (S (Nat.add (nweight_work work) (Nat.add (nweight_ds ds) n))) (Nat.add (nweight_work work) (S (Nat.add (nweight_ds ds) n))) *) generalize (nweight_work work); clear work; intros W. (* Goal: @eq nat (S (S (Nat.add (Nat.add b W) (Nat.add ds (Nat.add n ai))))) (Nat.add W (Nat.add ds (S (S (Nat.add (Nat.add b n) ai))))) *) rewrite (plus_assoc_reverse b n ai). (* Goal: forall n : nat, @eq nat (Nat.add (nweight_ni ni1) n) (Nat.add (nweight_ni ni2) n) *) generalize (n + ai); clear n ai; intros n. (* Goal: lt (S (Nat.add W (Nat.add ds (Nat.add b n)))) (Nat.add W (Nat.add ds (S (S (Nat.add b n))))) *) rewrite <- (plus_Snm_nSm ds (S (b + n))). (* Goal: le (S (Nat.add (nweight_work (@cons normal_form (NAtom j) work)) (Nat.add (nweight_ds ds) n))) (Nat.add (nweight_work work) (Nat.add (nweight_ds (@cons (prod Int Int) (@pair Int Int i j) ds)) n)) *) simpl in |- *. (* Goal: lt (S (Nat.add W (Nat.add ds (Nat.add b n)))) (Nat.add W (S (Nat.add ds (S (Nat.add b n))))) *) rewrite <- (plus_Snm_nSm ds (b + n)). (* Goal: le (S (Nat.add (nweight_work (@cons normal_form (NAtom j) work)) (Nat.add (nweight_ds ds) n))) (Nat.add (nweight_work work) (Nat.add (nweight_ds (@cons (prod Int Int) (@pair Int Int i j) ds)) n)) *) simpl in |- *. (* Goal: lt (S (Nat.add W (Nat.add ds (Nat.add b n)))) (Nat.add W (S (S (Nat.add ds (Nat.add b n))))) *) rewrite <- (plus_Snm_nSm W (S (ds + (b + n)))). (* Goal: le (S (Nat.add (nweight_work (@cons normal_form (NAtom j) work)) (Nat.add (nweight_ds ds) n))) (Nat.add (nweight_work work) (Nat.add (nweight_ds (@cons (prod Int Int) (@pair Int Int i j) ds)) n)) *) simpl in |- *. (* Goal: lt (S (Nat.add W (Nat.add ds (Nat.add b n)))) (S (Nat.add W (S (Nat.add ds (Nat.add b n))))) *) rewrite <- (plus_Snm_nSm W (ds + (b + n))). (* Goal: le (S (Nat.add (nweight_work (@cons normal_form (NAtom j) work)) (Nat.add (nweight_ds ds) n))) (Nat.add (nweight_work work) (Nat.add (nweight_ds (@cons (prod Int Int) (@pair Int Int i j) ds)) n)) *) simpl in |- *. (* Goal: @eq nat (S (Nat.add (Nat.add b W) (Nat.add ds n))) (S (Nat.add W (Nat.add ds (Nat.add b n)))) *) apply S_reg. (* Goal: @eq nat (S (Nat.add (Nat.add b W) (Nat.add ds n))) (S (Nat.add W (Nat.add ds (Nat.add b n)))) *) apply S_reg. (* Goal: lt (S (Nat.add (Nat.add b W) (Nat.add ds n))) (Nat.add W (Nat.add ds (S (S (Nat.add b n))))) *) rewrite (plus_comm b W). (* Goal: lt (S (Nat.add (PeanoNat.Nat.add W b) (Nat.add ds n))) (Nat.add W (Nat.add ds (S (S (Nat.add b n))))) *) rewrite (plus_assoc_reverse W b (ds + n)). (* Goal: @eq nat (Nat.add W (Nat.add b (Nat.add ds n))) (Nat.add W (Nat.add ds (Nat.add b n))) *) apply plus_reg. (* Goal: lt (S (Nat.add W (Nat.add b (Nat.add ds n)))) (Nat.add W (Nat.add ds (S (S (Nat.add b n))))) *) rewrite (plus_assoc b ds n). (* Goal: lt (S (Nat.add W (PeanoNat.Nat.add (PeanoNat.Nat.add b ds) n))) (Nat.add W (Nat.add ds (S (S (Nat.add b n))))) *) rewrite (plus_comm b ds). (* Goal: @eq nat (PeanoNat.Nat.add (PeanoNat.Nat.add ds b) n) (Nat.add ds (Nat.add b n)) *) apply plus_assoc_reverse. Qed. Lemma nweight_sequent_nimp_right : forall (a0 a1 : Int) (b : normal_form) (work : nf_list) (ds : disjs) (ni1 ni2 : nested_imps) (dni1 : decorated_nested_imps) (ai : atomic_imps) (n : nat), eqv_ni (rev_app dni1 ni1) ni2 -> nweight_Sequent work ds (rev_app dni1 (Undecorated (NImp a0 a1 b) :: ni1)) ai < S n -> nweight_Sequent (b :: work) ds ni2 ai < n. (* Goal: forall (a0 a1 : Int) (b : normal_form) (work : nf_list) (ds : disjs) (ni1 ni2 : nested_imps) (dni1 : decorated_nested_imps) (ai : atomic_imps) (n : nat) (_ : eqv_ni (rev_app dni1 ni1) ni2) (_ : lt (nweight_Sequent work ds (rev_app dni1 (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni1)) ai) (S n)), lt (nweight_Sequent (@cons normal_form b work) ds ni2 ai) n *) intros a0 a1 b work ds ni1 ni2 dni1 ai n eqv12 lt1. (* Goal: lt (nweight_Sequent (@cons normal_form (NAtom j) work) ds ni2 ai) n *) apply lt_S_n. apply lt_trans with (nweight_Sequent work ds (rev_app dni1 (Undecorated (NImp a0 a1 b) :: ni1)) ai); try assumption; clear lt1. (* Goal: le (S (nweight_Sequent (@cons normal_form (NAtom j) work) ds ni2 ai)) (nweight_Sequent work (@cons (prod Int Int) (@pair Int Int i j) ds) ni1 ai) *) unfold nweight_Sequent in |- *. (* Goal: le (S (Nat.add (nweight_work (@cons normal_form (NAtom j) work)) (Nat.add (nweight_ds ds) (Nat.add (nweight_ni ni2) (nweight_ai ai))))) (Nat.add (nweight_work work) (Nat.add (nweight_ds (@cons (prod Int Int) (@pair Int Int i j) ds)) (Nat.add (nweight_ni ni1) (nweight_ai ai)))) *) generalize (nweight_ai ai); clear ai; intros ai. (* Goal: le (S (Nat.add W (Nat.add (nweight_ds ds) n))) (Nat.add W (S (Nat.add (nweight_ds ds) n))) *) generalize (nweight_ds ds); clear ds; intros ds. (* Goal: lt (S (Nat.add (nweight_work (@cons normal_form b work)) (Nat.add ds (Nat.add (nweight_ni ni2) ai)))) (Nat.add (nweight_work work) (Nat.add ds (Nat.add (nweight_ni (rev_app dni1 (@cons nested_imp (Undecorated (NImp a0 a1 b)) ni1))) ai))) *) rewrite <- (nweight_rev_app dni1 (Undecorated (NImp a0 a1 b) :: ni1)). (* Goal: le (S (Nat.add (nweight_work (@cons normal_form (NAtom j) work)) (Nat.add (nweight_ds ds) n))) (Nat.add (nweight_work work) (Nat.add (nweight_ds (@cons (prod Int Int) (@pair Int Int i j) ds)) n)) *) simpl in |- *. (* Goal: lt (S (Nat.add (Nat.add (nweight (nf2form b)) (nweight_work work)) (Nat.add ds (Nat.add (nweight_ni ni2) ai)))) (Nat.add (nweight_work work) (Nat.add ds (S (S (Nat.add (Nat.add (Nat.add (nweight (nf2form b)) (nweight_ni ni1)) (nweight_dni dni1)) ai))))) *) fold nf2form in |- *. (* Goal: lt (S (Nat.add (Nat.add (nweight (nf2form b)) (nweight_work work)) (Nat.add ds (Nat.add (nweight_ni ni2) ai)))) (Nat.add (nweight_work work) (Nat.add ds (S (S (Nat.add (Nat.add (Nat.add (nweight (nf2form b)) (nweight_ni ni1)) (nweight_dni dni1)) ai))))) *) generalize (nweight (nf2form b)); clear b; intros b. (* Goal: le (S (Nat.add (nweight_work work) (Nat.add (nweight_ds ds) n))) (Nat.add (nweight_work work) (S (Nat.add (nweight_ds ds) n))) *) generalize (nweight_work work); clear work; intros W. (* Goal: lt (S (Nat.add (Nat.add b W) (Nat.add ds (Nat.add (nweight_ni ni2) ai)))) (Nat.add W (Nat.add ds (S (S (Nat.add (Nat.add (Nat.add b (nweight_ni ni1)) (nweight_dni dni1)) ai))))) *) rewrite (plus_assoc_reverse b (nweight_ni ni1) (nweight_dni dni1)). (* Goal: lt (S (Nat.add (Nat.add b W) (Nat.add ds (Nat.add (nweight_ni ni2) ai)))) (Nat.add W (Nat.add ds (S (S (Nat.add (Nat.add b (Nat.add (nweight_ni ni1) (nweight_dni dni1))) ai))))) *) rewrite (nweight_rev_app dni1 ni1). (* Goal: lt (S (Nat.add (Nat.add b W) (Nat.add ds (Nat.add (nweight_ni ni2) ai)))) (Nat.add W (Nat.add ds (S (S (Nat.add (Nat.add b (nweight_ni (rev_app dni1 ni1))) ai))))) *) rewrite (nweight_eqv_ni (rev_app dni1 ni1) ni2 eqv12). (* Goal: lt (S (Nat.add (Nat.add b W) (Nat.add ds (Nat.add (nweight_ni ni2) ai)))) (Nat.add W (Nat.add ds (S (S (Nat.add (Nat.add b (nweight_ni ni2)) ai))))) *) generalize (nweight_ni ni2); clear eqv12 ni2; intros ni2. (* Goal: lt (S (Nat.add (Nat.add b W) (Nat.add ds (Nat.add ni2 ai)))) (Nat.add W (Nat.add ds (S (S (Nat.add (Nat.add b ni2) ai))))) *) rewrite (plus_assoc_reverse b ni2 ai). (* Goal: forall n : nat, @eq nat (Nat.add (nweight_ni ni1) n) (Nat.add (nweight_ni ni2) n) *) generalize (ni2 + ai); clear ni1 dni1 ni2 ai n; intros n. (* Goal: lt (S (Nat.add (Nat.add b W) (Nat.add ds n))) (Nat.add W (Nat.add ds (S (S (Nat.add b n))))) *) rewrite (plus_comm b W). (* Goal: lt (S (Nat.add (PeanoNat.Nat.add W b) (Nat.add ds n))) (Nat.add W (Nat.add ds (S (S (Nat.add b n))))) *) rewrite (plus_assoc_reverse W b (ds + n)). (* Goal: lt (S (Nat.add W (Nat.add b (Nat.add ds n)))) (Nat.add W (Nat.add ds (S (S (Nat.add b n))))) *) rewrite (plus_assoc b ds n). (* Goal: lt (S (Nat.add W (PeanoNat.Nat.add (PeanoNat.Nat.add b ds) n))) (Nat.add W (Nat.add ds (S (S (Nat.add b n))))) *) rewrite (plus_comm b ds). (* Goal: lt (S (Nat.add W (PeanoNat.Nat.add (PeanoNat.Nat.add ds b) n))) (Nat.add W (Nat.add ds (S (S (Nat.add b n))))) *) rewrite (plus_assoc_reverse ds b n). (* Goal: lt (S (Nat.add W (Nat.add ds (Nat.add b n)))) (Nat.add W (Nat.add ds (S (S (Nat.add b n))))) *) rewrite <- (plus_Snm_nSm ds (S (b + n))). (* Goal: le (S (Nat.add (nweight_work (@cons normal_form (NAtom j) work)) (Nat.add (nweight_ds ds) n))) (Nat.add (nweight_work work) (Nat.add (nweight_ds (@cons (prod Int Int) (@pair Int Int i j) ds)) n)) *) simpl in |- *. (* Goal: lt (S (Nat.add W (Nat.add ds (Nat.add b n)))) (Nat.add W (S (Nat.add ds (S (Nat.add b n))))) *) rewrite <- (plus_Snm_nSm ds (b + n)). (* Goal: le (S (Nat.add (nweight_work (@cons normal_form (NAtom j) work)) (Nat.add (nweight_ds ds) n))) (Nat.add (nweight_work work) (Nat.add (nweight_ds (@cons (prod Int Int) (@pair Int Int i j) ds)) n)) *) simpl in |- *. (* Goal: lt (S (Nat.add W (Nat.add ds (Nat.add b n)))) (Nat.add W (S (S (Nat.add ds (Nat.add b n))))) *) rewrite <- (plus_Snm_nSm W (S (ds + (b + n)))). (* Goal: le (S (Nat.add (nweight_work (@cons normal_form (NAtom j) work)) (Nat.add (nweight_ds ds) n))) (Nat.add (nweight_work work) (Nat.add (nweight_ds (@cons (prod Int Int) (@pair Int Int i j) ds)) n)) *) simpl in |- *. (* Goal: lt (S (Nat.add W (Nat.add ds (Nat.add b n)))) (S (Nat.add W (S (Nat.add ds (Nat.add b n))))) *) rewrite <- (plus_Snm_nSm W (ds + (b + n))). (* Goal: le (S (Nat.add (nweight_work (@cons normal_form (NAtom j) work)) (Nat.add (nweight_ds ds) n))) (Nat.add (nweight_work work) (Nat.add (nweight_ds (@cons (prod Int Int) (@pair Int Int i j) ds)) n)) *) simpl in |- *. (* Goal: lt (S (Nat.add W (Nat.add ds (Nat.add b n)))) (S (S (Nat.add W (Nat.add ds (Nat.add b n))))) *) apply lt_n_Sn. Qed. Lemma nweight_sequent_left_disj_left : forall (i j : Int) (work : nf_list) (ds : disjs) (ni1 ni2 : nested_imps) (ai : atomic_imps) (n : nat), eqv_ni ni1 ni2 -> nweight_Sequent work ((i, j) :: ds) ni1 ai < S n -> nweight_Sequent (NAtom i :: work) ds ni2 ai < n. (* Goal: forall (i j : Int) (work : nf_list) (ds : disjs) (ni1 ni2 : nested_imps) (ai : atomic_imps) (n : nat) (_ : eqv_ni ni1 ni2) (_ : lt (nweight_Sequent work (@cons (prod Int Int) (@pair Int Int i j) ds) ni1 ai) (S n)), lt (nweight_Sequent (@cons normal_form (NAtom j) work) ds ni2 ai) n *) intros i j work ds ni1 ni2 ai n eqv12 lt1. (* Goal: lt (nweight_Sequent (@cons normal_form (NAtom j) work) ds ni2 ai) n *) apply lt_S_n. apply le_lt_trans with (nweight_Sequent work ((i, j) :: ds) ni1 ai); try assumption; clear lt1. (* Goal: le (S (nweight_Sequent (@cons normal_form (NAtom j) work) ds ni2 ai)) (nweight_Sequent work (@cons (prod Int Int) (@pair Int Int i j) ds) ni1 ai) *) unfold nweight_Sequent in |- *. (* Goal: le (S (Nat.add (nweight_work (@cons normal_form (NAtom j) work)) (Nat.add (nweight_ds ds) (Nat.add (nweight_ni ni2) (nweight_ai ai))))) (Nat.add (nweight_work work) (Nat.add (nweight_ds (@cons (prod Int Int) (@pair Int Int i j) ds)) (Nat.add (nweight_ni ni1) (nweight_ai ai)))) *) generalize (nweight_ai ai); clear ai; intros ai. (* Goal: le (S (Nat.add (nweight_work (@cons normal_form (NAtom j) work)) (Nat.add (nweight_ds ds) (Nat.add (nweight_ni ni2) ai)))) (Nat.add (nweight_work work) (Nat.add (nweight_ds (@cons (prod Int Int) (@pair Int Int i j) ds)) (Nat.add (nweight_ni ni1) ai))) *) rewrite (nweight_eqv_ni ni1 ni2 eqv12); clear eqv12. (* Goal: forall n : nat, @eq nat (Nat.add (nweight_ni ni1) n) (Nat.add (nweight_ni ni2) n) *) generalize (nweight_ni ni2 + ai); clear ni2 ai n; intros n. (* Goal: le (S (Nat.add (nweight_work (@cons normal_form (NAtom j) work)) (Nat.add (nweight_ds ds) n))) (Nat.add (nweight_work work) (Nat.add (nweight_ds (@cons (prod Int Int) (@pair Int Int i j) ds)) n)) *) simpl in |- *. (* Goal: le (S (Nat.add (nweight_work work) (Nat.add (nweight_ds ds) n))) (Nat.add (nweight_work work) (S (Nat.add (nweight_ds ds) n))) *) generalize (nweight_work work); clear work; intros W. (* Goal: le (S (Nat.add W (Nat.add (nweight_ds ds) n))) (Nat.add W (S (Nat.add (nweight_ds ds) n))) *) generalize (nweight_ds ds); clear ds; intros ds. (* Goal: le (S (Nat.add W (Nat.add ds n))) (Nat.add W (S (Nat.add ds n))) *) rewrite <- (plus_Snm_nSm W (ds + n)). (* Goal: le (S (Nat.add W (Nat.add ds n))) (Nat.add (S W) (Nat.add ds n)) *) simpl in |- *; trivial. Qed. Lemma nweight_sequent_left_disj_right : forall (i j : Int) (work : nf_list) (ds : disjs) (ni1 ni2 : nested_imps) (ai : atomic_imps) (n : nat), eqv_ni ni1 ni2 -> nweight_Sequent work ((i, j) :: ds) ni1 ai < S n -> nweight_Sequent (NAtom j :: work) ds ni2 ai < n. (* Goal: forall (i j : Int) (work : nf_list) (ds : disjs) (ni1 ni2 : nested_imps) (ai : atomic_imps) (n : nat) (_ : eqv_ni ni1 ni2) (_ : lt (nweight_Sequent work (@cons (prod Int Int) (@pair Int Int i j) ds) ni1 ai) (S n)), lt (nweight_Sequent (@cons normal_form (NAtom j) work) ds ni2 ai) n *) intros i j work ds ni1 ni2 ai n eqv12 lt1. (* Goal: lt (nweight_Sequent (@cons normal_form (NAtom j) work) ds ni2 ai) n *) apply lt_S_n. apply le_lt_trans with (nweight_Sequent work ((i, j) :: ds) ni1 ai); try assumption; clear lt1. (* Goal: le (S (nweight_Sequent (@cons normal_form (NAtom j) work) ds ni2 ai)) (nweight_Sequent work (@cons (prod Int Int) (@pair Int Int i j) ds) ni1 ai) *) unfold nweight_Sequent in |- *. (* Goal: le (S (Nat.add (nweight_work (@cons normal_form (NAtom j) work)) (Nat.add (nweight_ds ds) (Nat.add (nweight_ni ni2) (nweight_ai ai))))) (Nat.add (nweight_work work) (Nat.add (nweight_ds (@cons (prod Int Int) (@pair Int Int i j) ds)) (Nat.add (nweight_ni ni1) (nweight_ai ai)))) *) generalize (nweight_ai ai); clear ai; intros ai. (* Goal: le (S (Nat.add (nweight_work (@cons normal_form (NAtom j) work)) (Nat.add (nweight_ds ds) (Nat.add (nweight_ni ni2) ai)))) (Nat.add (nweight_work work) (Nat.add (nweight_ds (@cons (prod Int Int) (@pair Int Int i j) ds)) (Nat.add (nweight_ni ni1) ai))) *) rewrite (nweight_eqv_ni ni1 ni2 eqv12); clear eqv12. (* Goal: forall n : nat, @eq nat (Nat.add (nweight_ni ni1) n) (Nat.add (nweight_ni ni2) n) *) generalize (nweight_ni ni2 + ai); clear ni2 ai n; intros n. (* Goal: le (S (Nat.add (nweight_work (@cons normal_form (NAtom j) work)) (Nat.add (nweight_ds ds) n))) (Nat.add (nweight_work work) (Nat.add (nweight_ds (@cons (prod Int Int) (@pair Int Int i j) ds)) n)) *) simpl in |- *. (* Goal: le (S (Nat.add (nweight_work work) (Nat.add (nweight_ds ds) n))) (Nat.add (nweight_work work) (S (Nat.add (nweight_ds ds) n))) *) generalize (nweight_work work); clear work; intros W. (* Goal: le (S (Nat.add W (Nat.add (nweight_ds ds) n))) (Nat.add W (S (Nat.add (nweight_ds ds) n))) *) generalize (nweight_ds ds); clear ds; intros ds. (* Goal: le (S (Nat.add W (Nat.add ds n))) (Nat.add W (S (Nat.add ds n))) *) rewrite <- (plus_Snm_nSm W (ds + n)). (* Goal: le (S (Nat.add W (Nat.add ds n))) (Nat.add (S W) (Nat.add ds n)) *) simpl in |- *; trivial. Qed.
(* File: Regular_Avl.v (last edited on 27/10/2000) (c) Klaus Weich *) (* An AVL tree of lists is called regular iff, for each entry l, *) (* we have l\not= nil *) Require Import List. Require Import ML_Int. Require Import AvlTrees. Section Regular_Avl. Variable A : Set. Definition Regular (t : avl_tree (list A)) := forall (k : Int) (d : list A), lookup (list A) k t d -> d = nil -> False. Remark regular_nil : Regular (Avl_Nil (list A)). (* Goal: Regular t' *) unfold Regular in |- *. (* Goal: forall (k : Int) (d : list A) (_ : lookup (list A) k t' d) (_ : @eq (list A) d (@nil A)), False *) intros k d lookup eq_d. (* Goal: False *) inversion_clear lookup. Qed. Remark regular_equiv_del : forall (key : Int) (t t' : avl_tree (list A)), Regular t -> equiv_del (list A) key t t' -> Regular t'. (* Goal: forall (key : Int) (t t' : avl_tree (list A)) (_ : Regular t) (_ : equiv_del (list A) key t t'), Regular t' *) intros key t t' reg_t equiv_del. (* Goal: Regular t' *) unfold Regular in |- *. (* Goal: forall (k : Int) (d : list A) (_ : lookup (list A) k t' d) (_ : @eq (list A) d (@nil A)), False *) intros k d lookup eq_d. (* Goal: False *) elim (equal_dec k key). (* Goal: forall _ : Equal k key, False *) (* Goal: forall _ : not (Equal k key), False *) intros eq_k. (* Goal: AvlTrees.lookup (list A) k t d *) (* Goal: @eq (list A) d (@nil A) *) inversion_clear equiv_del. (* Goal: False *) (* Goal: forall _ : not (Equal k key), False *) apply H with k d; assumption. (* Goal: forall _ : not (Equal k key), False *) intros not_eq_k. (* Goal: False *) apply reg_t with k d. (* Goal: AvlTrees.lookup (list A) k t d *) (* Goal: @eq (list A) d (@nil A) *) inversion_clear equiv_del. (* Goal: AvlTrees.lookup (list A) k t d *) (* Goal: @eq (list A) d (@nil A) *) apply H1; assumption. (* Goal: @eq (list A) d (@nil A) *) assumption. Qed. Remark regular_equiv_ins : forall (key : Int) (data : A) (t t' : avl_tree (list A)), is_avl (list A) t -> is_avl (list A) t' -> Regular t -> equiv_ins (list A) key (cons data) nil t t' -> Regular t'. (* Goal: forall (key : Int) (data : A) (t t' : avl_tree (list A)) (_ : is_avl (list A) t) (_ : is_avl (list A) t') (_ : Regular t) (_ : equiv_ins (list A) key (@cons A data) (@nil A) t t'), Regular t' *) intros key data t t' avl_t avl_t' reg_t equiv_ins. (* Goal: Regular t' *) unfold Regular in |- *. (* Goal: forall (k : Int) (d : list A) (_ : lookup (list A) k t' d) (_ : @eq (list A) d (@nil A)), False *) intros k d lookup eq_d. (* Goal: False *) elim (equal_dec k key). (* Goal: forall _ : Equal k key, False *) (* Goal: forall _ : not (Equal k key), False *) intros eq_k. (* Goal: AvlTrees.lookup (list A) k t d *) (* Goal: @eq (list A) d (@nil A) *) inversion_clear equiv_ins. (* Goal: False *) (* Goal: forall _ : not (Equal k key), False *) clear H1 H2. (* Goal: False *) (* Goal: forall _ : not (Equal k key), False *) elim (lookup_dec (list A) k t avl_t). (* Goal: forall (d : list A) (_ : AvlTrees.lookup (list A) k t d), False *) (* Goal: forall _ : forall d : list A, not (AvlTrees.lookup (list A) k t d), False *) (* Goal: forall _ : not (Equal k key), False *) intros d0 lookup0. (* Goal: False *) (* Goal: forall _ : forall d : list A, not (AvlTrees.lookup (list A) k t d), False *) (* Goal: forall _ : not (Equal k key), False *) cut (d = data :: d0). (* Goal: forall _ : @eq (list A) d (@cons A data (@nil A)), False *) (* Goal: @eq (list A) d (@cons A data (@nil A)) *) (* Goal: forall _ : not (Equal k key), False *) rewrite eq_d. intro x; discriminate x. (* Goal: @eq (list A) d (@cons A data (@nil A)) *) (* Goal: forall _ : not (Equal k key), False *) apply (lookup_avl_equal (list A) k k t'). (* Goal: @eq (list A) d (@nil A) *) assumption. (* Goal: @eq (list A) d (@nil A) *) assumption. (* Goal: @eq (list A) d (@nil A) *) apply H; assumption. (* Goal: Equal k k *) (* Goal: forall _ : not (Equal k key), False *) apply equal_refl. (* Goal: forall _ : forall d : list A, not (AvlTrees.lookup (list A) k t d), False *) (* Goal: forall _ : not (Equal k key), False *) intros not_lookup0. (* Goal: False *) (* Goal: forall _ : not (Equal k key), False *) cut (d = data :: nil). (* Goal: forall _ : @eq (list A) d (@cons A data (@nil A)), False *) (* Goal: @eq (list A) d (@cons A data (@nil A)) *) (* Goal: forall _ : not (Equal k key), False *) rewrite eq_d. intro x; discriminate x. (* Goal: @eq (list A) d (@cons A data (@nil A)) *) (* Goal: forall _ : not (Equal k key), False *) apply (lookup_avl_equal (list A) k k t'). (* Goal: @eq (list A) d (@nil A) *) assumption. (* Goal: @eq (list A) d (@nil A) *) assumption. (* Goal: @eq (list A) d (@nil A) *) apply H0; assumption. (* Goal: Equal k k *) (* Goal: forall _ : not (Equal k key), False *) apply equal_refl. (* Goal: forall _ : not (Equal k key), False *) intros not_equal_k. (* Goal: False *) apply reg_t with k d. (* Goal: AvlTrees.lookup (list A) k t d *) (* Goal: @eq (list A) d (@nil A) *) inversion_clear equiv_ins. (* Goal: AvlTrees.lookup (list A) k t d *) (* Goal: @eq (list A) d (@nil A) *) clear H H0. (* Goal: @eq (list A) d (@nil A) *) apply H2; assumption. (* Goal: @eq (list A) d (@nil A) *) assumption. Qed. (***********************************************************************) Definition REGULAR (t : AVL (list A)) := match t with | AVL_intro t _ => Regular t end. Lemma regular_AVL_NIL : REGULAR (AVL_NIL (list A)). (* Goal: forall (_ : REGULAR (AVL_intro (list A) t avl_t)) (_ : EQUIV_INS (list A) key (@cons A data) (@nil A) (AVL_intro (list A) t avl_t) (AVL_intro (list A) t' avl_t')), REGULAR (AVL_intro (list A) t' avl_t') *) simpl in |- *. (* Goal: Regular (Avl_Nil (list A)) *) exact regular_nil. Qed. Lemma regular_EQUIV_DEL : forall (key : Int) (T T' : AVL (list A)), REGULAR T -> EQUIV_DEL (list A) key T T' -> REGULAR T'. (* Goal: forall (key : Int) (T T' : AVL (list A)) (_ : REGULAR T) (_ : EQUIV_DEL (list A) key T T'), REGULAR T' *) intros key T T'. (* Goal: forall (_ : REGULAR T) (_ : EQUIV_INS (list A) key (@cons A data) (@nil A) T T'), REGULAR T' *) elim T; clear T; intros t avl_t. (* Goal: forall (_ : REGULAR (AVL_intro (list A) t avl_t)) (_ : EQUIV_INS (list A) key (@cons A data) (@nil A) (AVL_intro (list A) t avl_t) T'), REGULAR T' *) elim T'; clear T'; intros t' avl_t'. (* Goal: forall (_ : REGULAR (AVL_intro (list A) t avl_t)) (_ : EQUIV_INS (list A) key (@cons A data) (@nil A) (AVL_intro (list A) t avl_t) (AVL_intro (list A) t' avl_t')), REGULAR (AVL_intro (list A) t' avl_t') *) simpl in |- *. (* Goal: forall (_ : Regular t) (_ : equiv_del (list A) key t t'), Regular t' *) intros reg_t equiv_del. (* Goal: @eq (list A) d (@nil A) *) apply regular_equiv_del with key t; assumption. Qed. Lemma regular_EQUIV_INS : forall (key : Int) (data : A) (T T' : AVL (list A)), REGULAR T -> EQUIV_INS (list A) key (cons data) nil T T' -> REGULAR T'. (* Goal: forall (key : Int) (data : A) (T T' : AVL (list A)) (_ : REGULAR T) (_ : EQUIV_INS (list A) key (@cons A data) (@nil A) T T'), REGULAR T' *) intros key data T T'. (* Goal: forall (_ : REGULAR T) (_ : EQUIV_INS (list A) key (@cons A data) (@nil A) T T'), REGULAR T' *) elim T; clear T; intros t avl_t. (* Goal: forall (_ : REGULAR (AVL_intro (list A) t avl_t)) (_ : EQUIV_INS (list A) key (@cons A data) (@nil A) (AVL_intro (list A) t avl_t) T'), REGULAR T' *) elim T'; clear T'; intros t' avl_t'. (* Goal: forall (_ : REGULAR (AVL_intro (list A) t avl_t)) (_ : EQUIV_INS (list A) key (@cons A data) (@nil A) (AVL_intro (list A) t avl_t) (AVL_intro (list A) t' avl_t')), REGULAR (AVL_intro (list A) t' avl_t') *) simpl in |- *. (* Goal: forall (_ : Regular t) (_ : equiv_ins (list A) key (@cons A data) (@nil A) t t'), Regular t' *) intros reg_t equiv_ins. (* Goal: @eq (list A) d (@nil A) *) apply regular_equiv_ins with key data t; assumption. Qed. End Regular_Avl.
(* File: Forms.v (last edited on 27/10/2000) (c) Klaus Weich *) Require Export ML_Int. Require Export My_Nth. (******* forms ***********************************************) Inductive form : Set := | Falsum : form | Atom : Int -> form | AndF : form -> form -> form | OrF : form -> form -> form | Imp : form -> form -> form. Definition flist := list form. Definition fnil := nil (A:=form). (* vimp qs a := vec(qs) imp a *) Fixpoint vimp (qs : list Int) : form -> form := match qs with | nil => fun a : form => a | q :: qs => fun a : form => vimp qs (Imp (Atom q) a) end. (*********************************************************************) (* Substitute (Atom i) by a in b: *) Fixpoint subst_form (i : Int) (a b : form) {struct b} : form := match b with | Falsum => Falsum | Atom j => match equal_dec i j with | left _ => a | right _ => Atom j end | OrF b0 b1 => OrF (subst_form i a b0) (subst_form i a b1) | AndF b0 b1 => AndF (subst_form i a b0) (subst_form i a b1) | Imp b0 b1 => Imp (subst_form i a b0) (subst_form i a b1) end. Definition subst_list (i : Int) (a : form) (l : flist) := map (subst_form i a) l. Lemma subst_nth : forall (i : Int) (g : form) (n : nat) (l : flist) (a : form), my_nth form n l a -> my_nth form n (subst_list i g l) (subst_form i g a). (* Goal: forall (i : Int) (g : form) (n : nat) (l : flist) (a : form) (_ : my_nth form n l a), my_nth form n (subst_list i g l) (subst_form i g a) *) intros i g n; elim n; clear n. (* Goal: forall (l : flist) (a : form) (_ : my_nth form O l a), my_nth form O (subst_list i g l) (subst_form i g a) *) (* Goal: forall (n : nat) (_ : forall (l : flist) (a : form) (_ : my_nth form n l a), my_nth form n (subst_list i g l) (subst_form i g a)) (l : flist) (a : form) (_ : my_nth form (S n) l a), my_nth form (S n) (subst_list i g l) (subst_form i g a) *) intros l a nth; inversion_clear nth. (* Goal: below_form Falsum int_null *) (* Goal: forall i : Int, @sig Int (fun j : Int => below_form (Atom i) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (AndF f f0) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (OrF f f0) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (Imp f f0) j) *) simpl in |- *. (* Goal: my_nth form O (@cons form (subst_form i g a) (subst_list i g l0)) (subst_form i g a) *) (* Goal: forall (n : nat) (_ : forall (l : flist) (a : form) (_ : my_nth form n l a), my_nth form n (subst_list i g l) (subst_form i g a)) (l : flist) (a : form) (_ : my_nth form (S n) l a), my_nth form (S n) (subst_list i g l) (subst_form i g a) *) apply My_NthO. (* Goal: forall (n : nat) (_ : forall (l : flist) (a : form) (_ : my_nth form n l a), my_nth form n (subst_list i g l) (subst_form i g a)) (l : flist) (a : form) (_ : my_nth form (S n) l a), my_nth form (S n) (subst_list i g l) (subst_form i g a) *) intros n ih l a nth. (* Goal: my_nth form (S n) (subst_list i g l) (subst_form i g a) *) inversion_clear nth. (* Goal: below_form Falsum int_null *) (* Goal: forall i : Int, @sig Int (fun j : Int => below_form (Atom i) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (AndF f f0) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (OrF f f0) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (Imp f f0) j) *) simpl in |- *. (* Goal: my_nth form (S n) (@cons form (subst_form i g a0) (subst_list i g l0)) (subst_form i g a) *) apply My_NthS. (* Goal: my_nth form n (subst_list i g l0) (subst_form i g a) *) apply ih. (* Goal: below_form a j *) assumption. Qed. (************************************************************************) Fixpoint below_form (a : form) (i : Int) {struct a} : Prop := match a with | Falsum => True | Atom j => Less j i | AndF a0 a1 => below_form a0 i /\ below_form a1 i | OrF a0 a1 => below_form a0 i /\ below_form a1 i | Imp a0 a1 => below_form a0 i /\ below_form a1 i end. Definition below_list (L : flist) (i : Int) := forall a : form, In a L -> below_form a i. (********************************************************************) Lemma below_form_less_below_form : forall (a : form) (i j : Int), below_form a i -> Less i j -> below_form a j. (* Goal: forall (a : form) (i j : Int) (_ : below_form a i) (_ : Less i j), below_form a j *) intros a i j. (* Goal: forall (_ : below_form a i) (_ : Less i j), below_form a j *) elim a; clear a. (* Goal: forall (b : form) (_ : forall (i : Int) (_ : @In Int i (@nil Int)), Less i j), @eq form (subst_form j a (vimp (@nil Int) b)) (vimp (@nil Int) (subst_form j a b)) *) (* Goal: forall (a0 : Int) (l : list Int) (_ : forall (b : form) (_ : forall (i : Int) (_ : @In Int i l), Less i j), @eq form (subst_form j a (vimp l b)) (vimp l (subst_form j a b))) (b : form) (_ : forall (i : Int) (_ : @In Int i (@cons Int a0 l)), Less i j), @eq form (subst_form j a (vimp (@cons Int a0 l) b)) (vimp (@cons Int a0 l) (subst_form j a b)) *) intros; trivial. (* Goal: below_form Falsum int_null *) (* Goal: forall i : Int, @sig Int (fun j : Int => below_form (Atom i) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (AndF f f0) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (OrF f f0) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (Imp f f0) j) *) simpl in |- *. (* Goal: forall (i0 : Int) (_ : Less i0 i) (_ : Less i j), Less i0 j *) (* Goal: forall (f : form) (_ : forall (_ : below_form f i) (_ : Less i j), below_form f j) (f0 : form) (_ : forall (_ : below_form f0 i) (_ : Less i j), below_form f0 j) (_ : below_form (AndF f f0) i) (_ : Less i j), below_form (AndF f f0) j *) (* Goal: forall (f : form) (_ : forall (_ : below_form f i) (_ : Less i j), below_form f j) (f0 : form) (_ : forall (_ : below_form f0 i) (_ : Less i j), below_form f0 j) (_ : below_form (OrF f f0) i) (_ : Less i j), below_form (OrF f f0) j *) (* Goal: forall (f : form) (_ : forall (_ : below_form f i) (_ : Less i j), below_form f j) (f0 : form) (_ : forall (_ : below_form f0 i) (_ : Less i j), below_form f0 j) (_ : below_form (Imp f f0) i) (_ : Less i j), below_form (Imp f f0) j *) intros i0 less_i0 less_i. (* Goal: below_form a j *) apply less_trans with i; assumption. (* Goal: forall (f : form) (_ : forall (_ : below_form f i) (_ : Less i j), below_form f j) (f0 : form) (_ : forall (_ : below_form f0 i) (_ : Less i j), below_form f0 j) (_ : below_form (Imp f f0) i) (_ : Less i j), below_form (Imp f f0) j *) intros a ih_a b ih_b below_ab less_ij. (* Goal: below_form (Imp a b) j *) elim below_ab; clear below_ab. (* Goal: forall (_ : below_form a i) (_ : below_form b i), below_form (Imp a b) j *) intros below_a below_b. (* Goal: below_form (Imp a b) j *) split. (* Goal: below_form a j *) apply ih_a; assumption. (* Goal: below_form a j *) apply ih_b; assumption. (* Goal: forall (f : form) (_ : forall (_ : below_form f i) (_ : Less i j), below_form f j) (f0 : form) (_ : forall (_ : below_form f0 i) (_ : Less i j), below_form f0 j) (_ : below_form (Imp f f0) i) (_ : Less i j), below_form (Imp f f0) j *) intros a ih_a b ih_b below_ab less_ij. (* Goal: below_form (Imp a b) j *) elim below_ab; clear below_ab. (* Goal: forall (_ : below_form a i) (_ : below_form b i), below_form (Imp a b) j *) intros below_a below_b. (* Goal: below_form (Imp a b) j *) split. (* Goal: below_form a j *) apply ih_a; assumption. (* Goal: below_form a j *) apply ih_b; assumption. (* Goal: forall (f : form) (_ : forall (_ : below_form f i) (_ : Less i j), below_form f j) (f0 : form) (_ : forall (_ : below_form f0 i) (_ : Less i j), below_form f0 j) (_ : below_form (Imp f f0) i) (_ : Less i j), below_form (Imp f f0) j *) intros a ih_a b ih_b below_ab less_ij. (* Goal: below_form (Imp a b) j *) elim below_ab; clear below_ab. (* Goal: forall (_ : below_form a i) (_ : below_form b i), below_form (Imp a b) j *) intros below_a below_b. (* Goal: below_form (Imp a b) j *) split. (* Goal: below_form a j *) apply ih_a; assumption. (* Goal: below_form a j *) apply ih_b; assumption. Qed. Lemma below_list_less_below_list : forall (l : flist) (i j : Int), below_list l i -> Less i j -> below_list l j. (* Goal: forall (l : flist) (i j : Int) (_ : below_list l i) (_ : Less i j), below_list l j *) intros l i j below_l less_ij. (* Goal: below_list l i *) unfold below_list in |- *. (* Goal: forall (a : form) (_ : @In form a l), below_form a j *) intros a in_a. (* Goal: below_form a j *) apply below_form_less_below_form with i. (* Goal: below_form a j *) apply below_l; assumption. (* Goal: below_form a j *) assumption. Qed. Lemma below_cons_list_head : forall (a : form) (l : flist) (i : Int), below_list (a :: l) i -> below_form a i. (* Goal: forall (a : form) (l : flist) (i : Int) (_ : below_list (@cons form a l) i), below_list l i *) intros a l i below_l. (* Goal: Less i0 j *) apply below_l. (* Goal: @In Int i (@cons Int i l) *) (* Goal: forall (i : Int) (_ : @In Int i l), Less i j *) left; trivial. Qed. Lemma below_cons_list_tail : forall (a : form) (l : flist) (i : Int), below_list (a :: l) i -> below_list l i. (* Goal: forall (a : form) (l : flist) (i : Int) (_ : below_list (@cons form a l) i), below_list l i *) intros a l i below_l. (* Goal: below_list l i *) unfold below_list in |- *. (* Goal: forall (a0 : form) (_ : @In form a0 (@cons form a l)), below_form a0 i *) intros b in_b. (* Goal: Less i0 j *) apply below_l. (* Goal: below_form a j *) right; assumption. Qed. Lemma below_cons_list : forall (a : form) (l : flist) (i : Int), below_form a i -> below_list l i -> below_list (a :: l) i. (* Goal: forall (a : form) (l : flist) (i : Int) (_ : below_form a i) (_ : below_list l i), below_list (@cons form a l) i *) intros a l i below_a below_l. (* Goal: below_list l i *) unfold below_list in |- *. (* Goal: forall (a0 : form) (_ : @In form a0 (@cons form a l)), below_form a0 i *) intros b in_b. (* Goal: below_form b i *) inversion_clear in_b. (* Goal: below_form a j *) rewrite <- H; assumption. (* Goal: below_form a j *) apply below_l; assumption. Qed. Lemma below_list_weak : forall (l : flist) (a b : form) (i : Int), (below_form a i -> below_form b i) -> below_list (a :: l) i -> below_list (b :: l) i. (* Goal: forall (l : flist) (a b : form) (i : Int) (_ : forall _ : below_form a i, below_form b i) (_ : below_list (@cons form a l) i), below_list (@cons form b l) i *) intros l a b i below_ab below_l. (* Goal: below_list l i *) unfold below_list in |- *. (* Goal: forall (a : form) (_ : @In form a (@cons form b (@cons form c l))), below_form a i *) (* Goal: below_form a i *) intros x in_x. (* Goal: below_form x i *) (* Goal: below_form a i *) inversion_clear in_x. (* Goal: below_form x i *) (* Goal: below_form x i *) rewrite <- H; clear H x. (* Goal: below_form b i *) (* Goal: below_form x i *) apply below_ab. (* Goal: Less i0 j *) apply below_l. (* Goal: @In Int i (@cons Int i l) *) (* Goal: forall (i : Int) (_ : @In Int i l), Less i j *) left; trivial. (* Goal: Less i0 j *) apply below_l. (* Goal: below_form a j *) right; assumption. Qed. Lemma below_list_weak2 : forall (l : flist) (a b c : form) (i : Int), (below_form a i -> below_form b i /\ below_form c i) -> below_list (a :: l) i -> below_list (b :: c :: l) i. (* Goal: forall (l : flist) (a b c : form) (i : Int) (_ : forall _ : below_form a i, and (below_form b i) (below_form c i)) (_ : below_list (@cons form a l) i), below_list (@cons form b (@cons form c l)) i *) intros l a b c i below_abc below_l. (* Goal: below_list (@cons form b (@cons form c l)) i *) elim below_abc; clear below_abc. (* Goal: forall (_ : below_form b i) (_ : below_form c i), below_list (@cons form b (@cons form c l)) i *) (* Goal: below_form a i *) intros below_b below_c. (* Goal: below_list l i *) unfold below_list in |- *. (* Goal: forall (a : form) (_ : @In form a (@cons form b (@cons form c l))), below_form a i *) (* Goal: below_form a i *) intros x in_x. (* Goal: below_form x i *) (* Goal: below_form a i *) inversion_clear in_x. (* Goal: below_form a j *) rewrite <- H; assumption. (* Goal: below_form x i *) (* Goal: below_form a i *) inversion_clear H. (* Goal: below_form a j *) rewrite <- H0; assumption. (* Goal: Less i0 j *) apply below_l. (* Goal: below_form a j *) right; assumption. (* Goal: Less i0 j *) apply below_l. (* Goal: @In Int i (@cons Int i l) *) (* Goal: forall (i : Int) (_ : @In Int i l), Less i j *) left; trivial. Qed. (********************************************************************) Lemma subst_form_below : forall (i : Int) (g a : form), below_form a i -> subst_form i g a = a. (* Goal: forall (_ : below_form a i) (_ : Less i j), below_form a j *) intros i g a; elim a; clear a. (* Goal: True *) (* Goal: forall i : Int, @sig Int (fun j : Int => below_form (Atom i) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (AndF f f0) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (OrF f f0) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (Imp f f0) j) *) trivial. (* Goal: forall (i0 : Int) (_ : below_form (Atom i0) i), @eq form (subst_form i g (Atom i0)) (Atom i0) *) (* Goal: forall (f : form) (_ : forall _ : below_form f i, @eq form (subst_form i g f) f) (f0 : form) (_ : forall _ : below_form f0 i, @eq form (subst_form i g f0) f0) (_ : below_form (AndF f f0) i), @eq form (subst_form i g (AndF f f0)) (AndF f f0) *) (* Goal: forall (f : form) (_ : forall _ : below_form f i, @eq form (subst_form i g f) f) (f0 : form) (_ : forall _ : below_form f0 i, @eq form (subst_form i g f0) f0) (_ : below_form (OrF f f0) i), @eq form (subst_form i g (OrF f f0)) (OrF f f0) *) (* Goal: forall (f : form) (_ : forall _ : below_form f i, @eq form (subst_form i g f) f) (f0 : form) (_ : forall _ : below_form f0 i, @eq form (subst_form i g f0) f0) (_ : below_form (Imp f f0) i), @eq form (subst_form i g (Imp f f0)) (Imp f f0) *) intros j. (* Goal: below_form Falsum int_null *) (* Goal: forall i : Int, @sig Int (fun j : Int => below_form (Atom i) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (AndF f f0) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (OrF f f0) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (Imp f f0) j) *) simpl in |- *. (* Goal: forall _ : Less j i, @eq form (if equal_dec i j then g else Atom j) (Atom j) *) (* Goal: forall (f : form) (_ : forall _ : below_form f i, @eq form (subst_form i g f) f) (f0 : form) (_ : forall _ : below_form f0 i, @eq form (subst_form i g f0) f0) (_ : below_form (AndF f f0) i), @eq form (subst_form i g (AndF f f0)) (AndF f f0) *) (* Goal: forall (f : form) (_ : forall _ : below_form f i, @eq form (subst_form i g f) f) (f0 : form) (_ : forall _ : below_form f0 i, @eq form (subst_form i g f0) f0) (_ : below_form (OrF f f0) i), @eq form (subst_form i g (OrF f f0)) (OrF f f0) *) (* Goal: forall (f : form) (_ : forall _ : below_form f i, @eq form (subst_form i g f) f) (f0 : form) (_ : forall _ : below_form f0 i, @eq form (subst_form i g f0) f0) (_ : below_form (Imp f f0) i), @eq form (subst_form i g (Imp f f0)) (Imp f f0) *) intros less_j. (* Goal: @eq form (if equal_dec i j then g else Atom j) (Atom j) *) (* Goal: forall (f : form) (_ : forall _ : below_form f i, @eq form (subst_form i g f) f) (f0 : form) (_ : forall _ : below_form f0 i, @eq form (subst_form i g f0) f0) (_ : below_form (AndF f f0) i), @eq form (subst_form i g (AndF f f0)) (AndF f f0) *) (* Goal: forall (f : form) (_ : forall _ : below_form f i, @eq form (subst_form i g f) f) (f0 : form) (_ : forall _ : below_form f0 i, @eq form (subst_form i g f0) f0) (_ : below_form (OrF f f0) i), @eq form (subst_form i g (OrF f f0)) (OrF f f0) *) (* Goal: forall (f : form) (_ : forall _ : below_form f i, @eq form (subst_form i g f) f) (f0 : form) (_ : forall _ : below_form f0 i, @eq form (subst_form i g f0) f0) (_ : below_form (Imp f f0) i), @eq form (subst_form i g (Imp f f0)) (Imp f f0) *) elim (equal_dec i j). (* Goal: forall _ : Equal i j, @eq form g (Atom j) *) (* Goal: forall _ : not (Equal i j), @eq form (Atom j) (Atom j) *) (* Goal: forall (f : form) (_ : forall _ : below_form f i, @eq form (subst_form i g f) f) (f0 : form) (_ : forall _ : below_form f0 i, @eq form (subst_form i g f0) f0) (_ : below_form (AndF f f0) i), @eq form (subst_form i g (AndF f f0)) (AndF f f0) *) (* Goal: forall (f : form) (_ : forall _ : below_form f i, @eq form (subst_form i g f) f) (f0 : form) (_ : forall _ : below_form f0 i, @eq form (subst_form i g f0) f0) (_ : below_form (OrF f f0) i), @eq form (subst_form i g (OrF f f0)) (OrF f f0) *) (* Goal: forall (f : form) (_ : forall _ : below_form f i, @eq form (subst_form i g f) f) (f0 : form) (_ : forall _ : below_form f0 i, @eq form (subst_form i g f0) f0) (_ : below_form (Imp f f0) i), @eq form (subst_form i g (Imp f f0)) (Imp f f0) *) intros equal_j. (* Goal: @eq form g (Atom j) *) (* Goal: forall _ : not (Equal i j), @eq form (Atom j) (Atom j) *) (* Goal: forall (f : form) (_ : forall _ : below_form f i, @eq form (subst_form i g f) f) (f0 : form) (_ : forall _ : below_form f0 i, @eq form (subst_form i g f0) f0) (_ : below_form (AndF f f0) i), @eq form (subst_form i g (AndF f f0)) (AndF f f0) *) (* Goal: forall (f : form) (_ : forall _ : below_form f i, @eq form (subst_form i g f) f) (f0 : form) (_ : forall _ : below_form f0 i, @eq form (subst_form i g f0) f0) (_ : below_form (OrF f f0) i), @eq form (subst_form i g (OrF f f0)) (OrF f f0) *) (* Goal: forall (f : form) (_ : forall _ : below_form f i, @eq form (subst_form i g f) f) (f0 : form) (_ : forall _ : below_form f0 i, @eq form (subst_form i g f0) f0) (_ : below_form (Imp f f0) i), @eq form (subst_form i g (Imp f f0)) (Imp f f0) *) elimtype False. (* Goal: False *) (* Goal: forall _ : not (Equal i j), @eq form (Atom j) (Atom j) *) (* Goal: forall (f : form) (_ : forall _ : below_form f i, @eq form (subst_form i g f) f) (f0 : form) (_ : forall _ : below_form f0 i, @eq form (subst_form i g f0) f0) (_ : below_form (AndF f f0) i), @eq form (subst_form i g (AndF f f0)) (AndF f f0) *) (* Goal: forall (f : form) (_ : forall _ : below_form f i, @eq form (subst_form i g f) f) (f0 : form) (_ : forall _ : below_form f0 i, @eq form (subst_form i g f0) f0) (_ : below_form (OrF f f0) i), @eq form (subst_form i g (OrF f f0)) (OrF f f0) *) (* Goal: forall (f : form) (_ : forall _ : below_form f i, @eq form (subst_form i g f) f) (f0 : form) (_ : forall _ : below_form f0 i, @eq form (subst_form i g f0) f0) (_ : below_form (Imp f f0) i), @eq form (subst_form i g (Imp f f0)) (Imp f f0) *) apply less_irrefl with i. (* Goal: below_form a j *) apply equal_less_less with j; assumption. (* Goal: True *) (* Goal: forall i : Int, @sig Int (fun j : Int => below_form (Atom i) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (AndF f f0) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (OrF f f0) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (Imp f f0) j) *) trivial. (* Goal: below_form Falsum int_null *) (* Goal: forall i : Int, @sig Int (fun j : Int => below_form (Atom i) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (AndF f f0) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (OrF f f0) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (Imp f f0) j) *) simpl in |- *. (* Goal: forall (f : form) (_ : forall _ : below_form f i, @eq form (subst_form i g f) f) (f0 : form) (_ : forall _ : below_form f0 i, @eq form (subst_form i g f0) f0) (_ : and (below_form f i) (below_form f0 i)), @eq form (Imp (subst_form i g f) (subst_form i g f0)) (Imp f f0) *) intros a ih_a b ih_b below_ab. (* Goal: @eq form (Imp (subst_form i g a) (subst_form i g b)) (Imp a b) *) rewrite ih_a. (* Goal: @eq form (Imp a (subst_form i g b)) (Imp a b) *) (* Goal: below_form a i *) rewrite ih_b. (* Goal: True *) (* Goal: forall i : Int, @sig Int (fun j : Int => below_form (Atom i) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (AndF f f0) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (OrF f f0) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (Imp f f0) j) *) trivial. (* Goal: True *) (* Goal: forall i : Int, @sig Int (fun j : Int => below_form (Atom i) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (AndF f f0) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (OrF f f0) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (Imp f f0) j) *) elim below_ab; trivial. (* Goal: True *) (* Goal: forall i : Int, @sig Int (fun j : Int => below_form (Atom i) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (AndF f f0) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (OrF f f0) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (Imp f f0) j) *) elim below_ab; trivial. (* Goal: below_form Falsum int_null *) (* Goal: forall i : Int, @sig Int (fun j : Int => below_form (Atom i) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (AndF f f0) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (OrF f f0) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (Imp f f0) j) *) simpl in |- *. (* Goal: forall (f : form) (_ : forall _ : below_form f i, @eq form (subst_form i g f) f) (f0 : form) (_ : forall _ : below_form f0 i, @eq form (subst_form i g f0) f0) (_ : and (below_form f i) (below_form f0 i)), @eq form (Imp (subst_form i g f) (subst_form i g f0)) (Imp f f0) *) intros a ih_a b ih_b below_ab. (* Goal: @eq form (Imp (subst_form i g a) (subst_form i g b)) (Imp a b) *) rewrite ih_a. (* Goal: @eq form (Imp a (subst_form i g b)) (Imp a b) *) (* Goal: below_form a i *) rewrite ih_b. (* Goal: True *) (* Goal: forall i : Int, @sig Int (fun j : Int => below_form (Atom i) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (AndF f f0) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (OrF f f0) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (Imp f f0) j) *) trivial. (* Goal: True *) (* Goal: forall i : Int, @sig Int (fun j : Int => below_form (Atom i) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (AndF f f0) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (OrF f f0) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (Imp f f0) j) *) elim below_ab; trivial. (* Goal: True *) (* Goal: forall i : Int, @sig Int (fun j : Int => below_form (Atom i) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (AndF f f0) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (OrF f f0) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (Imp f f0) j) *) elim below_ab; trivial. (* Goal: below_form Falsum int_null *) (* Goal: forall i : Int, @sig Int (fun j : Int => below_form (Atom i) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (AndF f f0) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (OrF f f0) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (Imp f f0) j) *) simpl in |- *. (* Goal: forall (f : form) (_ : forall _ : below_form f i, @eq form (subst_form i g f) f) (f0 : form) (_ : forall _ : below_form f0 i, @eq form (subst_form i g f0) f0) (_ : and (below_form f i) (below_form f0 i)), @eq form (Imp (subst_form i g f) (subst_form i g f0)) (Imp f f0) *) intros a ih_a b ih_b below_ab. (* Goal: @eq form (Imp (subst_form i g a) (subst_form i g b)) (Imp a b) *) rewrite ih_a. (* Goal: @eq form (Imp a (subst_form i g b)) (Imp a b) *) (* Goal: below_form a i *) rewrite ih_b. (* Goal: True *) (* Goal: forall i : Int, @sig Int (fun j : Int => below_form (Atom i) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (AndF f f0) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (OrF f f0) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (Imp f f0) j) *) trivial. (* Goal: True *) (* Goal: forall i : Int, @sig Int (fun j : Int => below_form (Atom i) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (AndF f f0) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (OrF f f0) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (Imp f f0) j) *) elim below_ab; trivial. (* Goal: True *) (* Goal: forall i : Int, @sig Int (fun j : Int => below_form (Atom i) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (AndF f f0) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (OrF f f0) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (Imp f f0) j) *) elim below_ab; trivial. Qed. Lemma subst_list_below : forall (i : Int) (g : form) (l : flist), below_list l i -> subst_list i g l = l. (* Goal: forall (i : Int) (g : form) (l : flist) (_ : below_list l i), @eq (list form) (subst_list i g l) l *) intros i g l; elim l; clear l. (* Goal: True *) (* Goal: forall i : Int, @sig Int (fun j : Int => below_form (Atom i) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (AndF f f0) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (OrF f f0) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (Imp f f0) j) *) trivial. (* Goal: forall (a : form) (l : list form) (_ : forall _ : below_list l i, @eq (list form) (subst_list i g l) l) (_ : below_list (@cons form a l) i), @eq (list form) (subst_list i g (@cons form a l)) (@cons form a l) *) simpl in |- *; intros a l ih below_l. (* Goal: @eq (list form) (@cons form (subst_form i g a) (subst_list i g l)) (@cons form a l) *) rewrite ih. (* Goal: @eq (list form) (@cons form (subst_form i g a) l) (@cons form a l) *) (* Goal: below_list l i *) rewrite (subst_form_below i g a). (* Goal: True *) (* Goal: forall i : Int, @sig Int (fun j : Int => below_form (Atom i) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (AndF f f0) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (OrF f f0) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (Imp f f0) j) *) trivial. (* Goal: below_form a i *) (* Goal: below_list l i *) apply (below_l a). (* Goal: @In Int i (@cons Int i l) *) (* Goal: forall (i : Int) (_ : @In Int i l), Less i j *) left; trivial. (* Goal: below_list l i *) unfold below_list in |- *. (* Goal: forall (a : form) (_ : @In form a l), below_form a i *) intros b in_l. (* Goal: below_form b i *) apply (below_l b). (* Goal: below_form a j *) right; assumption. Qed. Lemma below_vimp : forall (j : Int) (l : list Int) (a b : form), (forall j : Int, below_form a j -> below_form b j) -> below_form (vimp l a) j -> below_form (vimp l b) j. (* Goal: forall (j : Int) (l : list Int) (a b : form) (_ : forall (j0 : Int) (_ : below_form a j0), below_form b j0) (_ : below_form (vimp l a) j), below_form (vimp l b) j *) intros j l. (* Goal: forall (a b c : form) (_ : forall (j : Int) (_ : below_form a j) (_ : below_form b j), below_form c j) (_ : below_form (vimp l a) k) (_ : below_form (vimp l b) k), below_form (vimp l c) k *) elim l; clear l. (* Goal: forall (a b : form) (_ : forall (j : Int) (_ : below_form a j), below_form b j) (_ : below_form (vimp (@nil Int) a) j), below_form (vimp (@nil Int) b) j *) (* Goal: forall (a : Int) (l : list Int) (_ : forall (a0 b : form) (_ : forall (j : Int) (_ : below_form a0 j), below_form b j) (_ : below_form (vimp l a0) j), below_form (vimp l b) j) (a0 b : form) (_ : forall (j : Int) (_ : below_form a0 j), below_form b j) (_ : below_form (vimp (@cons Int a l) a0) j), below_form (vimp (@cons Int a l) b) j *) intros a b below_ab below_a. (* Goal: below_form a j *) apply below_ab; assumption. (* Goal: forall (a : Int) (l : list Int) (_ : forall (a0 b : form) (_ : forall (j : Int) (_ : below_form a0 j), below_form b j) (_ : below_form (vimp l a0) j), below_form (vimp l b) j) (a0 b : form) (_ : forall (j : Int) (_ : below_form a0 j), below_form b j) (_ : below_form (vimp (@cons Int a l) a0) j), below_form (vimp (@cons Int a l) b) j *) simpl in |- *; intros i l ih a b below_ab below_a. (* Goal: below_form a j *) apply ih with (a := Imp (Atom i) a); try assumption. (* Goal: forall (j : Int) (_ : below_form (Imp (Atom i) a) j), below_form (Imp (Atom i) b) j *) intros j' below_ia. (* Goal: below_form (Imp (Atom i) c) j' *) elim below_ia; clear below_ia; intros below_i below_a0. (* Goal: below_form (Imp a b) j *) split. (* Goal: below_form a j *) assumption. (* Goal: below_form a j *) apply below_ab; assumption. Qed. Lemma below_vimp2 : forall (j : Int) (l : list Int) (a b c : form), (forall j : Int, below_form a j -> below_form b j -> below_form c j) -> below_form (vimp l a) j -> below_form (vimp l b) j -> below_form (vimp l c) j. (* Goal: forall (j : Int) (l : list Int) (a b c : form) (_ : forall (j0 : Int) (_ : below_form a j0) (_ : below_form b j0), below_form c j0) (_ : below_form (vimp l a) j) (_ : below_form (vimp l b) j), below_form (vimp l c) j *) intros k l. (* Goal: forall (a b c : form) (_ : forall (j : Int) (_ : below_form a j) (_ : below_form b j), below_form c j) (_ : below_form (vimp l a) k) (_ : below_form (vimp l b) k), below_form (vimp l c) k *) elim l; clear l. (* Goal: forall (a b c : form) (_ : forall (j : Int) (_ : below_form a j) (_ : below_form b j), below_form c j) (_ : below_form (vimp (@nil Int) a) k) (_ : below_form (vimp (@nil Int) b) k), below_form (vimp (@nil Int) c) k *) (* Goal: forall (a : Int) (l : list Int) (_ : forall (a0 b c : form) (_ : forall (j : Int) (_ : below_form a0 j) (_ : below_form b j), below_form c j) (_ : below_form (vimp l a0) k) (_ : below_form (vimp l b) k), below_form (vimp l c) k) (a0 b c : form) (_ : forall (j : Int) (_ : below_form a0 j) (_ : below_form b j), below_form c j) (_ : below_form (vimp (@cons Int a l) a0) k) (_ : below_form (vimp (@cons Int a l) b) k), below_form (vimp (@cons Int a l) c) k *) intros a b c below_abc below_a below_b. (* Goal: below_form a j *) apply below_abc; assumption. (* Goal: forall (a : Int) (l : list Int) (_ : forall (a0 b c : form) (_ : forall (j : Int) (_ : below_form a0 j) (_ : below_form b j), below_form c j) (_ : below_form (vimp l a0) k) (_ : below_form (vimp l b) k), below_form (vimp l c) k) (a0 b c : form) (_ : forall (j : Int) (_ : below_form a0 j) (_ : below_form b j), below_form c j) (_ : below_form (vimp (@cons Int a l) a0) k) (_ : below_form (vimp (@cons Int a l) b) k), below_form (vimp (@cons Int a l) c) k *) simpl in |- *; intros i l ih a b c below_abc below_a below_b. (* Goal: below_form a j *) apply ih with (a := Imp (Atom i) a) (b := Imp (Atom i) b); try assumption. (* Goal: forall (j : Int) (_ : below_form (Imp (Atom i) a) j) (_ : below_form (Imp (Atom i) b) j), below_form (Imp (Atom i) c) j *) intros j' below_ia below_ib. (* Goal: below_form (Imp (Atom i) c) j' *) elim below_ia; clear below_ia; intros below_i below_a0. (* Goal: below_form (Imp (Atom i) c) j' *) elim below_ib; clear below_ib; intros below_i0 below_b0. (* Goal: below_form (Imp a b) j *) split. (* Goal: below_form a j *) assumption. (* Goal: below_form a j *) apply below_abc; assumption. Qed. Lemma below_vimp_head : forall (j : Int) (l : list Int) (a : form), below_form (vimp l a) j -> below_form a j. (* Goal: forall (a b c : form) (_ : forall (j : Int) (_ : below_form a j) (_ : below_form b j), below_form c j) (_ : below_form (vimp l a) k) (_ : below_form (vimp l b) k), below_form (vimp l c) k *) intros j l; elim l; clear l. (* Goal: below_form a j *) intros a below_la; assumption. (* Goal: forall (a : Int) (l : list Int) (_ : forall (a0 : form) (_ : below_form (vimp l a0) j), below_form a0 j) (a0 : form) (_ : below_form (vimp (@cons Int a l) a0) j), below_form a0 j *) intros i l ih a below_la. (* Goal: below_form a j *) elim (ih (Imp (Atom i) a)); clear ih. (* Goal: below_form a j *) intros; assumption. (* Goal: below_form a j *) assumption. Qed. Lemma below_vimp_split : forall (j : Int) (l : list Int) (a : form), (forall i : Int, In i l -> Less i j) -> below_form a j -> below_form (vimp l a) j. (* Goal: forall (a b c : form) (_ : forall (j : Int) (_ : below_form a j) (_ : below_form b j), below_form c j) (_ : below_form (vimp l a) k) (_ : below_form (vimp l b) k), below_form (vimp l c) k *) intros j l; elim l; clear l. (* Goal: below_form a j *) intros; assumption. (* Goal: forall (a : Int) (l : list Int) (_ : forall (a0 : form) (_ : forall (i : Int) (_ : @In Int i l), Less i j) (_ : below_form a0 j), below_form (vimp l a0) j) (a0 : form) (_ : forall (i : Int) (_ : @In Int i (@cons Int a l)), Less i j) (_ : below_form a0 j), below_form (vimp (@cons Int a l) a0) j *) intros i l ih a below_i below_a. (* Goal: below_form (vimp (@cons Int i l) a) j *) apply ih with (a := Imp (Atom i) a). (* Goal: forall (i : Int) (_ : @In Int i l), Less i j *) intros i0 in0. (* Goal: Less i j *) (* Goal: below_form a j *) apply below_i. (* Goal: below_form a j *) right; assumption. (* Goal: below_form (Imp a b) j *) split. (* Goal: below_form Falsum int_null *) (* Goal: forall i : Int, @sig Int (fun j : Int => below_form (Atom i) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (AndF f f0) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (OrF f f0) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (Imp f f0) j) *) simpl in |- *. (* Goal: Less i j *) (* Goal: below_form a j *) apply below_i. (* Goal: @In Int i (@cons Int i l) *) (* Goal: forall (i : Int) (_ : @In Int i l), Less i j *) left; trivial. (* Goal: below_form a j *) assumption. Qed. Lemma below_vimp_tail : forall (j : Int) (l : list Int) (a : form), below_form (vimp l a) j -> forall i : Int, In i l -> Less i j. (* Goal: forall (a b c : form) (_ : forall (j : Int) (_ : below_form a j) (_ : below_form b j), below_form c j) (_ : below_form (vimp l a) k) (_ : below_form (vimp l b) k), below_form (vimp l c) k *) intros j l; elim l; clear l. (* Goal: forall (a : form) (_ : below_form (vimp (@nil Int) a) j) (i : Int) (_ : @In Int i (@nil Int)), Less i j *) (* Goal: forall (a : Int) (l : list Int) (_ : forall (a0 : form) (_ : below_form (vimp l a0) j) (i : Int) (_ : @In Int i l), Less i j) (a0 : form) (_ : below_form (vimp (@cons Int a l) a0) j) (i : Int) (_ : @In Int i (@cons Int a l)), Less i j *) intros a below_la i0 in0; inversion_clear in0. (* Goal: forall (a : Int) (l : list Int) (_ : forall (a0 : form) (_ : below_form (vimp l a0) j) (i : Int) (_ : @In Int i l), Less i j) (a0 : form) (_ : below_form (vimp (@cons Int a l) a0) j) (i : Int) (_ : @In Int i (@cons Int a l)), Less i j *) simpl in |- *; intros i l ih a below_la i0 in0. (* Goal: Less i0 j *) inversion_clear in0. (* Goal: Less i0 j *) (* Goal: Less i0 j *) rewrite <- H; clear H i0. (* Goal: Less i j *) (* Goal: Less i0 j *) elim (below_vimp_head j l (Imp (Atom i) a) below_la). (* Goal: below_form a j *) intros; assumption. (* Goal: below_form a j *) apply ih with (a := Imp (Atom i) a); assumption. Qed. Lemma subst_vimp_head : forall (j : Int) (a : form) (l : list Int) (b : form), (forall i : Int, In i l -> Less i j) -> subst_form j a (vimp l b) = vimp l (subst_form j a b). (* Goal: forall (a b c : form) (_ : forall (j : Int) (_ : below_form a j) (_ : below_form b j), below_form c j) (_ : below_form (vimp l a) k) (_ : below_form (vimp l b) k), below_form (vimp l c) k *) intros j a l; elim l; clear l. (* Goal: forall (b : form) (_ : forall (i : Int) (_ : @In Int i (@nil Int)), Less i j), @eq form (subst_form j a (vimp (@nil Int) b)) (vimp (@nil Int) (subst_form j a b)) *) (* Goal: forall (a0 : Int) (l : list Int) (_ : forall (b : form) (_ : forall (i : Int) (_ : @In Int i l), Less i j), @eq form (subst_form j a (vimp l b)) (vimp l (subst_form j a b))) (b : form) (_ : forall (i : Int) (_ : @In Int i (@cons Int a0 l)), Less i j), @eq form (subst_form j a (vimp (@cons Int a0 l) b)) (vimp (@cons Int a0 l) (subst_form j a b)) *) intros; trivial. (* Goal: forall (a0 : Int) (l : list Int) (_ : forall (b : form) (_ : forall (i : Int) (_ : @In Int i l), Less i j), @eq form (subst_form j a (vimp l b)) (vimp l (subst_form j a b))) (b : form) (_ : forall (i : Int) (_ : @In Int i (@cons Int a0 l)), Less i j), @eq form (subst_form j a (vimp (@cons Int a0 l) b)) (vimp (@cons Int a0 l) (subst_form j a b)) *) intros i l ih b below_l. (* Goal: below_form Falsum int_null *) (* Goal: forall i : Int, @sig Int (fun j : Int => below_form (Atom i) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (AndF f f0) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (OrF f f0) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (Imp f f0) j) *) simpl in |- *. (* Goal: @eq form (subst_form j a (vimp l (Imp (Atom i) b))) (vimp l (Imp (Atom i) (subst_form j a b))) *) rewrite (ih (Imp (Atom i) b)); clear ih. change (vimp l (Imp (subst_form j a (Atom i)) (subst_form j a b)) = vimp l (Imp (Atom i) (subst_form j a b))) in |- *. (* Goal: @eq form (vimp l (Imp (subst_form j a (Atom i)) (subst_form j a b))) (vimp l (Imp (Atom i) (subst_form j a b))) *) (* Goal: forall (i : Int) (_ : @In Int i l), Less i j *) rewrite (subst_form_below j a (Atom i)). (* Goal: True *) (* Goal: forall i : Int, @sig Int (fun j : Int => below_form (Atom i) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (AndF f f0) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (OrF f f0) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (Imp f f0) j) *) trivial. (* Goal: below_form Falsum int_null *) (* Goal: forall i : Int, @sig Int (fun j : Int => below_form (Atom i) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (AndF f f0) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (OrF f f0) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (Imp f f0) j) *) simpl in |- *. (* Goal: Less i0 j *) apply below_l. (* Goal: @In Int i (@cons Int i l) *) (* Goal: forall (i : Int) (_ : @In Int i l), Less i j *) left; trivial. (* Goal: forall (i : Int) (_ : @In Int i l), Less i j *) intros i0 in0. (* Goal: Less i0 j *) apply below_l. (* Goal: below_form a j *) right; assumption. Qed. Lemma max_int_of_form : forall a : form, {j : Int | below_form a j}. (* Goal: forall (_ : below_form a i) (_ : Less i j), below_form a j *) intros a; elim a; clear a. (* Goal: @sig Int (fun j : Int => below_list (@nil form) j) *) (* Goal: forall (a : form) (l : list form) (_ : @sig Int (fun j : Int => below_list l j)), @sig Int (fun j : Int => below_list (@cons form a l) j) *) exists int_null. (* Goal: below_form Falsum int_null *) (* Goal: forall i : Int, @sig Int (fun j : Int => below_form (Atom i) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (AndF f f0) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (OrF f f0) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (Imp f f0) j) *) simpl in |- *. (* Goal: True *) (* Goal: forall i : Int, @sig Int (fun j : Int => below_form (Atom i) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (AndF f f0) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (OrF f f0) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (Imp f f0) j) *) trivial. (* Goal: forall i : Int, @sig Int (fun j : Int => below_form (Atom i) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (AndF f f0) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (OrF f f0) j) *) (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (Imp f f0) j) *) intros i; elim (int_succ i); intros i1 less1. (* Goal: below_form a j *) exists i1; assumption. (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (Imp f f0) j) *) intros a ih_a b ih_b. (* Goal: @sig Int (fun j : Int => below_form (Imp a b) j) *) elim ih_a; intros i1 below_a. (* Goal: @sig Int (fun j : Int => below_form (Imp a b) j) *) elim ih_b; intros i2 below_b. (* Goal: @sig Int (fun j : Int => below_list (@cons form a gamma) j) *) elim (max_int i1 i2). (* Goal: forall (j : Int) (_ : or (Less i1 j) (Equal i1 j)) (_ : or (Less i2 j) (Equal i2 j)), @sig Int (fun j0 : Int => below_list (@cons form a gamma) j0) *) intros j le1 le2. (* Goal: @sig Int (fun j : Int => below_list (@cons form a gamma) j) *) exists j. (* Goal: below_form (Imp a b) j *) split. (* Goal: below_form a j *) (* Goal: below_list gamma j *) elim le1. (* Goal: forall _ : Less i1 j, below_form a j *) (* Goal: forall _ : Equal i1 j, below_form a j *) (* Goal: below_list gamma j *) intro lt1. (* Goal: below_form a j *) apply below_form_less_below_form with i1; assumption. (* Goal: forall _ : Equal i1 j, below_form a j *) (* Goal: below_list gamma j *) intros eq1. (* Goal: below_form a j *) rewrite <- (equal_eq i1 j); assumption. (* Goal: below_list gamma j *) elim le2. (* Goal: forall _ : Less i2 j, below_list gamma j *) (* Goal: forall _ : Equal i2 j, below_list gamma j *) intro lt2. (* Goal: below_form a j *) apply below_form_less_below_form with i2; assumption. (* Goal: forall _ : Equal i2 j, below_list gamma j *) intros eq2. (* Goal: below_form a j *) rewrite <- (equal_eq i2 j); assumption. (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (Imp f f0) j) *) intros a ih_a b ih_b. (* Goal: @sig Int (fun j : Int => below_form (Imp a b) j) *) elim ih_a; intros i1 below_a. (* Goal: @sig Int (fun j : Int => below_form (Imp a b) j) *) elim ih_b; intros i2 below_b. (* Goal: @sig Int (fun j : Int => below_list (@cons form a gamma) j) *) elim (max_int i1 i2). (* Goal: forall (j : Int) (_ : or (Less i1 j) (Equal i1 j)) (_ : or (Less i2 j) (Equal i2 j)), @sig Int (fun j0 : Int => below_list (@cons form a gamma) j0) *) intros j le1 le2. (* Goal: @sig Int (fun j : Int => below_list (@cons form a gamma) j) *) exists j. (* Goal: below_form (Imp a b) j *) split. (* Goal: below_form a j *) (* Goal: below_list gamma j *) elim le1. (* Goal: forall _ : Less i1 j, below_form a j *) (* Goal: forall _ : Equal i1 j, below_form a j *) (* Goal: below_list gamma j *) intro lt1. (* Goal: below_form a j *) apply below_form_less_below_form with i1; assumption. (* Goal: forall _ : Equal i1 j, below_form a j *) (* Goal: below_list gamma j *) intros eq1. (* Goal: below_form a j *) rewrite <- (equal_eq i1 j); assumption. (* Goal: below_list gamma j *) elim le2. (* Goal: forall _ : Less i2 j, below_list gamma j *) (* Goal: forall _ : Equal i2 j, below_list gamma j *) intro lt2. (* Goal: below_form a j *) apply below_form_less_below_form with i2; assumption. (* Goal: forall _ : Equal i2 j, below_list gamma j *) intros eq2. (* Goal: below_form a j *) rewrite <- (equal_eq i2 j); assumption. (* Goal: forall (f : form) (_ : @sig Int (fun j : Int => below_form f j)) (f0 : form) (_ : @sig Int (fun j : Int => below_form f0 j)), @sig Int (fun j : Int => below_form (Imp f f0) j) *) intros a ih_a b ih_b. (* Goal: @sig Int (fun j : Int => below_form (Imp a b) j) *) elim ih_a; intros i1 below_a. (* Goal: @sig Int (fun j : Int => below_form (Imp a b) j) *) elim ih_b; intros i2 below_b. (* Goal: @sig Int (fun j : Int => below_list (@cons form a gamma) j) *) elim (max_int i1 i2). (* Goal: forall (j : Int) (_ : or (Less i1 j) (Equal i1 j)) (_ : or (Less i2 j) (Equal i2 j)), @sig Int (fun j0 : Int => below_list (@cons form a gamma) j0) *) intros j le1 le2. (* Goal: @sig Int (fun j : Int => below_list (@cons form a gamma) j) *) exists j. (* Goal: below_form (Imp a b) j *) split. (* Goal: below_form a j *) (* Goal: below_list gamma j *) elim le1. (* Goal: forall _ : Less i1 j, below_form a j *) (* Goal: forall _ : Equal i1 j, below_form a j *) (* Goal: below_list gamma j *) intro lt1. (* Goal: below_form a j *) apply below_form_less_below_form with i1; assumption. (* Goal: forall _ : Equal i1 j, below_form a j *) (* Goal: below_list gamma j *) intros eq1. (* Goal: below_form a j *) rewrite <- (equal_eq i1 j); assumption. (* Goal: below_list gamma j *) elim le2. (* Goal: forall _ : Less i2 j, below_list gamma j *) (* Goal: forall _ : Equal i2 j, below_list gamma j *) intro lt2. (* Goal: below_form a j *) apply below_form_less_below_form with i2; assumption. (* Goal: forall _ : Equal i2 j, below_list gamma j *) intros eq2. (* Goal: below_form a j *) rewrite <- (equal_eq i2 j); assumption. Qed. Lemma max_int_of_list : forall Gamma : flist, {j : Int | below_list Gamma j}. (* Goal: forall Gamma : flist, @sig Int (fun j : Int => below_list Gamma j) *) intros Gamma; elim Gamma; clear Gamma. (* Goal: @sig Int (fun j : Int => below_list (@nil form) j) *) (* Goal: forall (a : form) (l : list form) (_ : @sig Int (fun j : Int => below_list l j)), @sig Int (fun j : Int => below_list (@cons form a l) j) *) exists int_null. (* Goal: below_list (@nil form) int_null *) (* Goal: forall (a : form) (l : list form) (_ : @sig Int (fun j : Int => below_list l j)), @sig Int (fun j : Int => below_list (@cons form a l) j) *) unfold below_list in |- *; intros a in_a; inversion_clear in_a. (* Goal: forall (a : form) (l : list form) (_ : @sig Int (fun j : Int => below_list l j)), @sig Int (fun j : Int => below_list (@cons form a l) j) *) intros a gamma ih. (* Goal: @sig Int (fun j : Int => below_list (@cons form a gamma) j) *) elim (max_int_of_form a). (* Goal: forall (x : Int) (_ : below_form a x), @sig Int (fun j : Int => below_list (@cons form a gamma) j) *) intros i1 below_a. (* Goal: @sig Int (fun j : Int => below_list (@cons form a gamma) j) *) elim ih. (* Goal: forall (x : Int) (_ : below_list gamma x), @sig Int (fun j : Int => below_list (@cons form a gamma) j) *) intros i2 below_gamma. (* Goal: @sig Int (fun j : Int => below_list (@cons form a gamma) j) *) elim (max_int i1 i2). (* Goal: forall (j : Int) (_ : or (Less i1 j) (Equal i1 j)) (_ : or (Less i2 j) (Equal i2 j)), @sig Int (fun j0 : Int => below_list (@cons form a gamma) j0) *) intros j le1 le2. (* Goal: @sig Int (fun j : Int => below_list (@cons form a gamma) j) *) exists j. (* Goal: below_list (@cons form a gamma) j *) apply below_cons_list. (* Goal: below_form a j *) (* Goal: below_list gamma j *) elim le1. (* Goal: forall _ : Less i1 j, below_form a j *) (* Goal: forall _ : Equal i1 j, below_form a j *) (* Goal: below_list gamma j *) intro lt1. (* Goal: below_form a j *) apply below_form_less_below_form with i1; assumption. (* Goal: forall _ : Equal i1 j, below_form a j *) (* Goal: below_list gamma j *) intros eq1. (* Goal: below_form a j *) rewrite <- (equal_eq i1 j); assumption. (* Goal: below_list gamma j *) elim le2. (* Goal: forall _ : Less i2 j, below_list gamma j *) (* Goal: forall _ : Equal i2 j, below_list gamma j *) intro lt2. (* Goal: below_form a j *) apply below_list_less_below_list with i2; assumption. (* Goal: forall _ : Equal i2 j, below_list gamma j *) intros eq2. (* Goal: below_form a j *) rewrite <- (equal_eq i2 j); assumption. Qed.
(* File: Lt_Ks.v (last edited on 27/10/2000) (c) Klaus Weich *) Require Export Le. Require Export Lt. Require Export Le_Ks. Fixpoint count_undecs (n : nested_imps) : nat := match n with | nil => 0 | Undecorated _ :: n => S (count_undecs n) | Decorated _ _ :: n => count_undecs n end. Inductive Lt_Ks (ni1 : nested_imps) (dni1 : decorated_nested_imps) (ni2 : nested_imps) (dni2 : decorated_nested_imps) : Set := | lt_ks_count_undecs : le_ni (rev_app dni1 ni1) (rev_app dni2 ni2) -> count_undecs ni1 < count_undecs ni2 -> Lt_Ks ni1 dni1 ni2 dni2 | lt_ks_length : le_ni (rev_app dni1 ni1) (rev_app dni2 ni2) -> length ni1 < length ni2 -> Lt_Ks ni1 dni1 ni2 dni2. Lemma le_ni_le_count_undecs : forall ni1 ni2 : nested_imps, le_ni ni1 ni2 -> count_undecs ni1 <= count_undecs ni2. (* Goal: forall (ni1 ni2 : nested_imps) (_ : le_ni ni1 ni2), le (count_undecs ni1) (count_undecs ni2) *) intros ni1 ni2 le12. (* Goal: le (count_undecs ni1) (count_undecs ni2) *) elim le12; clear le12 ni1 ni2. (* Goal: @eq nat (@length nested_imp (rev_app dni NNil)) (@length nested_imp (rev_app dni NNil)) *) (* Goal: le_ni (@app nested_imp (rev_app dni NNil) ni) (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: lt (count_undecs ni1) (count_undecs (@cons nested_imp (Undecorated x) ni)) *) trivial. (* Goal: forall (x : nimp) (ni1 ni2 : nested_imps) (_ : le_ni ni1 ni2) (_ : le (count_undecs ni1) (count_undecs ni2)), le (count_undecs (@cons nested_imp (Undecorated x) ni1)) (count_undecs (@cons nested_imp (Undecorated x) ni2)) *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : le_ni ni1 ni2) (_ : le (count_undecs ni1) (count_undecs ni2)), le (count_undecs (@cons nested_imp (Decorated x k) ni1)) (count_undecs (@cons nested_imp (Undecorated x) ni2)) *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : le_ni ni1 ni2) (_ : le (count_undecs ni1) (count_undecs ni2)), le (count_undecs (@cons nested_imp (Decorated x k) ni1)) (count_undecs (@cons nested_imp (Decorated x k) ni2)) *) intros x ni1 ni2 le ih; simpl in |- *. (* Goal: Peano.le (S (count_undecs ni1)) (S (count_undecs ni2)) *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : le_ni ni1 ni2) (_ : le (count_undecs ni1) (count_undecs ni2)), le (count_undecs (@cons nested_imp (Decorated x k) ni1)) (count_undecs (@cons nested_imp (Undecorated x) ni2)) *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : le_ni ni1 ni2) (_ : le (count_undecs ni1) (count_undecs ni2)), le (count_undecs (@cons nested_imp (Decorated x k) ni1)) (count_undecs (@cons nested_imp (Decorated x k) ni2)) *) apply le_n_S; assumption. (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : le_ni ni1 ni2) (_ : le (count_undecs ni1) (count_undecs ni2)), le (count_undecs (@cons nested_imp (Decorated x k) ni1)) (count_undecs (@cons nested_imp (Decorated x k) ni2)) *) intros x k ni1 ni2 le ih; simpl in |- *. (* Goal: Peano.le (count_undecs ni1) (S (count_undecs ni2)) *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : le_ni ni1 ni2) (_ : le (count_undecs ni1) (count_undecs ni2)), le (count_undecs (@cons nested_imp (Decorated x k) ni1)) (count_undecs (@cons nested_imp (Decorated x k) ni2)) *) apply le_trans with (count_undecs ni2). (* Goal: lt (@length nested_imp ni1) (@length nested_imp ni) *) (* Goal: le (@length nested_imp ni) m *) assumption. (* Goal: Peano.le (count_undecs ni2) (S (count_undecs ni2)) *) (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : le_ni ni1 ni2) (_ : le (count_undecs ni1) (count_undecs ni2)), le (count_undecs (@cons nested_imp (Decorated x k) ni1)) (count_undecs (@cons nested_imp (Decorated x k) ni2)) *) apply le_n_Sn. (* Goal: forall (x : nimp) (k : kripke_tree) (ni1 ni2 : nested_imps) (_ : le_ni ni1 ni2) (_ : le (count_undecs ni1) (count_undecs ni2)), le (count_undecs (@cons nested_imp (Decorated x k) ni1)) (count_undecs (@cons nested_imp (Decorated x k) ni2)) *) intros x k ni1 ni2 le ih; simpl in |- *. (* Goal: lt (@length nested_imp ni1) (@length nested_imp ni) *) (* Goal: le (@length nested_imp ni) m *) assumption. Qed. Lemma count_undecs_rev_app : forall (dni : decorated_nested_imps) (ni : nested_imps), count_undecs (rev_app dni ni) = count_undecs ni. (* Goal: forall (dni : decorated_nested_imps) (ni : nested_imps), @eq nat (count_undecs (rev_app dni ni)) (count_undecs ni) *) intros dni; elim dni; clear dni. (* Goal: @eq nat (@length nested_imp (rev_app dni NNil)) (@length nested_imp (rev_app dni NNil)) *) (* Goal: le_ni (@app nested_imp (rev_app dni NNil) ni) (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: lt (count_undecs ni1) (count_undecs (@cons nested_imp (Undecorated x) ni)) *) intros; trivial. (* Goal: forall (a : decorated_nested_imp) (l : list decorated_nested_imp) (_ : forall ni : nested_imps, @eq nat (count_undecs (rev_app l ni)) (count_undecs ni)) (ni : nested_imps), @eq nat (count_undecs (rev_app (@cons decorated_nested_imp a l) ni)) (count_undecs ni) *) intros x; case x; clear x. (* Goal: forall (n : nimp) (k : kripke_tree) (l : list decorated_nested_imp) (_ : forall ni : nested_imps, @eq nat (count_undecs (rev_app l ni)) (count_undecs ni)) (ni : nested_imps), @eq nat (count_undecs (rev_app (@cons decorated_nested_imp (@pair nimp kripke_tree n k) l) ni)) (count_undecs ni) *) intros x k dni ih ni. (* Goal: le_ni (rev_app (@cons (prod nimp kripke_tree) (@pair nimp kripke_tree x k) dni) ni) (rev_app dni (@cons nested_imp (Undecorated x) ni)) *) (* Goal: lt (count_undecs ni1) (count_undecs (@cons nested_imp (Undecorated x) ni)) *) simpl in |- *. (* Goal: @eq nat (count_undecs (rev_app dni (@cons nested_imp (Decorated x k) ni))) (count_undecs ni) *) apply (ih (Decorated x k :: ni)). Qed. Lemma le_ks_le_count_undecs : forall (ni1 : nested_imps) (dni1 : decorated_nested_imps) (ni2 : nested_imps) (dni2 : decorated_nested_imps), le_ni (rev_app dni1 ni1) (rev_app dni2 ni2) -> count_undecs ni1 <= count_undecs ni2. (* Goal: forall (ni1 : nested_imps) (dni1 : decorated_nested_imps) (ni2 : nested_imps) (dni2 : decorated_nested_imps) (_ : le_ni (rev_app dni1 ni1) (rev_app dni2 ni2)), le (count_undecs ni1) (count_undecs ni2) *) intros ni1 dni1 ni2 dni2 le12. generalize (le_ni_le_count_undecs (rev_app dni1 ni1) (rev_app dni2 ni2) le12); clear le12. (* Goal: forall _ : le (count_undecs (rev_app dni1 ni1)) (count_undecs (rev_app dni2 ni2)), le (count_undecs ni1) (count_undecs ni2) *) rewrite (count_undecs_rev_app dni1 ni1). (* Goal: forall _ : le (count_undecs ni1) (count_undecs (rev_app dni2 ni2)), le (count_undecs ni1) (count_undecs ni2) *) rewrite (count_undecs_rev_app dni2 ni2). (* Goal: @eq nat (@length nested_imp (rev_app dni NNil)) (@length nested_imp (rev_app dni NNil)) *) (* Goal: le_ni (@app nested_imp (rev_app dni NNil) ni) (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: lt (count_undecs ni1) (count_undecs (@cons nested_imp (Undecorated x) ni)) *) trivial. Qed. Lemma My_Lt_Ks_rec : forall P : nested_imps -> Set, (forall (ni2 : nested_imps) (dni2 : decorated_nested_imps), (forall (ni1 : nested_imps) (dni1 : decorated_nested_imps), Lt_Ks ni1 dni1 ni2 dni2 -> P (rev_app dni1 ni1)) -> P (rev_app dni2 ni2)) -> forall ni : nested_imps, P ni. (* Goal: forall (P : forall _ : nested_imps, Set) (_ : forall (ni2 : nested_imps) (dni2 : decorated_nested_imps) (_ : forall (ni1 : nested_imps) (dni1 : decorated_nested_imps) (_ : Lt_Ks ni1 dni1 ni2 dni2), P (rev_app dni1 ni1)), P (rev_app dni2 ni2)) (ni : nested_imps), P ni *) intros P step. cut (forall (n m : nat) (ni : nested_imps) (dni : decorated_nested_imps), count_undecs ni < n -> length ni < m -> P (rev_app dni ni)). (* Goal: forall (_ : forall (n m : nat) (ni : nested_imps) (dni : decorated_nested_imps) (_ : lt (count_undecs ni) n) (_ : lt (@length nested_imp ni) m), P (rev_app dni ni)) (ni : nested_imps), P ni *) (* Goal: forall (n m : nat) (ni : nested_imps) (dni : decorated_nested_imps) (_ : lt (count_undecs ni) n) (_ : lt (@length nested_imp ni) m), P (rev_app dni ni) *) intros claim ni. apply claim with (n := S (count_undecs ni)) (m := S (length ni)) (ni := ni) (dni := DNI_NIL); clear claim. (* Goal: lt (@length nested_imp ni1) (S (@length nested_imp ni1)) *) (* Goal: P (rev_app dni1 ni1) *) apply lt_n_Sn. (* Goal: lt (@length nested_imp ni1) (S (@length nested_imp ni1)) *) (* Goal: P (rev_app dni1 ni1) *) apply lt_n_Sn. (* Goal: forall (n m : nat) (ni : nested_imps) (dni : decorated_nested_imps) (_ : lt (count_undecs ni) n) (_ : lt (@length nested_imp ni) m), P (rev_app dni ni) *) intros n; elim n; clear n. (* Goal: forall (m : nat) (ni : nested_imps) (dni : decorated_nested_imps) (_ : lt (count_undecs ni) O) (_ : lt (@length nested_imp ni) m), P (rev_app dni ni) *) (* Goal: forall (n : nat) (_ : forall (m : nat) (ni : nested_imps) (dni : decorated_nested_imps) (_ : lt (count_undecs ni) n) (_ : lt (@length nested_imp ni) m), P (rev_app dni ni)) (m : nat) (ni : nested_imps) (dni : decorated_nested_imps) (_ : lt (count_undecs ni) (S n)) (_ : lt (@length nested_imp ni) m), P (rev_app dni ni) *) intros m ni dni lt_nonref lt_length. (* Goal: P (rev_app dni ni) *) (* Goal: forall (n0 : nat) (_ : forall (ni : nested_imps) (dni : decorated_nested_imps) (_ : lt (count_undecs ni) (S n)) (_ : lt (@length nested_imp ni) n0), P (rev_app dni ni)) (ni : nested_imps) (dni : decorated_nested_imps) (_ : lt (count_undecs ni) (S n)) (_ : lt (@length nested_imp ni) (S n0)), P (rev_app dni ni) *) elimtype False. (* Goal: False *) (* Goal: forall (n : nat) (_ : forall (m : nat) (ni : nested_imps) (dni : decorated_nested_imps) (_ : lt (count_undecs ni) n) (_ : lt (@length nested_imp ni) m), P (rev_app dni ni)) (m : nat) (ni : nested_imps) (dni : decorated_nested_imps) (_ : lt (count_undecs ni) (S n)) (_ : lt (@length nested_imp ni) m), P (rev_app dni ni) *) inversion_clear lt_nonref. (* Goal: forall (n : nat) (_ : forall (m : nat) (ni : nested_imps) (dni : decorated_nested_imps) (_ : lt (count_undecs ni) n) (_ : lt (@length nested_imp ni) m), P (rev_app dni ni)) (m : nat) (ni : nested_imps) (dni : decorated_nested_imps) (_ : lt (count_undecs ni) (S n)) (_ : lt (@length nested_imp ni) m), P (rev_app dni ni) *) intros n ih m. (* Goal: forall (ni : nested_imps) (dni : decorated_nested_imps) (_ : lt (count_undecs ni) (S n)) (_ : lt (@length nested_imp ni) m), P (rev_app dni ni) *) elim m; clear m. (* Goal: forall (ni : nested_imps) (dni : decorated_nested_imps) (_ : lt (count_undecs ni) (S n)) (_ : lt (@length nested_imp ni) O), P (rev_app dni ni) *) (* Goal: forall (n0 : nat) (_ : forall (ni : nested_imps) (dni : decorated_nested_imps) (_ : lt (count_undecs ni) (S n)) (_ : lt (@length nested_imp ni) n0), P (rev_app dni ni)) (ni : nested_imps) (dni : decorated_nested_imps) (_ : lt (count_undecs ni) (S n)) (_ : lt (@length nested_imp ni) (S n0)), P (rev_app dni ni) *) intros ni dni lt_nonref lt_length. (* Goal: P (rev_app dni ni) *) (* Goal: forall (n0 : nat) (_ : forall (ni : nested_imps) (dni : decorated_nested_imps) (_ : lt (count_undecs ni) (S n)) (_ : lt (@length nested_imp ni) n0), P (rev_app dni ni)) (ni : nested_imps) (dni : decorated_nested_imps) (_ : lt (count_undecs ni) (S n)) (_ : lt (@length nested_imp ni) (S n0)), P (rev_app dni ni) *) elimtype False. (* Goal: False *) (* Goal: forall (n0 : nat) (_ : forall (ni : nested_imps) (dni : decorated_nested_imps) (_ : lt (count_undecs ni) (S n)) (_ : lt (@length nested_imp ni) n0), P (rev_app dni ni)) (ni : nested_imps) (dni : decorated_nested_imps) (_ : lt (count_undecs ni) (S n)) (_ : lt (@length nested_imp ni) (S n0)), P (rev_app dni ni) *) inversion_clear lt_length. (* Goal: forall (n0 : nat) (_ : forall (ni : nested_imps) (dni : decorated_nested_imps) (_ : lt (count_undecs ni) (S n)) (_ : lt (@length nested_imp ni) n0), P (rev_app dni ni)) (ni : nested_imps) (dni : decorated_nested_imps) (_ : lt (count_undecs ni) (S n)) (_ : lt (@length nested_imp ni) (S n0)), P (rev_app dni ni) *) intros m sih ni dni lt_nonref lt_length. (* Goal: P (rev_app dni ni) *) apply step; clear step. (* Goal: forall (ni1 : nested_imps) (dni1 : decorated_nested_imps) (_ : Lt_Ks ni1 dni1 ni dni), P (rev_app dni1 ni1) *) intros ni1 dni1 lt_ks. (* Goal: P (rev_app dni1 ni1) *) inversion_clear lt_ks. (* Goal: P (rev_app dni1 ni1) *) (* Goal: P (rev_app dni1 ni1) *) apply ih with (S (length ni1)); clear ih. (* Goal: lt (count_undecs ni1) n *) (* Goal: lt (@length nested_imp ni1) (S (@length nested_imp ni1)) *) (* Goal: P (rev_app dni1 ni1) *) apply lt_S_n. (* Goal: lt (@length nested_imp ni1) (@length nested_imp ni) *) (* Goal: le (@length nested_imp ni) m *) apply le_lt_trans with (count_undecs ni); assumption. (* Goal: lt (@length nested_imp ni1) (S (@length nested_imp ni1)) *) (* Goal: P (rev_app dni1 ni1) *) apply lt_n_Sn. (* Goal: P (rev_app dni1 ni1) *) apply sih. (* Goal: lt (count_undecs ni1) (count_undecs (@cons nested_imp (Undecorated x) ni)) *) apply le_lt_trans with (count_undecs ni). (* Goal: lt (@length nested_imp ni1) (@length nested_imp ni) *) (* Goal: le (@length nested_imp ni) m *) apply le_ks_le_count_undecs with dni1 dni; assumption. (* Goal: lt (@length nested_imp ni1) (@length nested_imp ni) *) (* Goal: le (@length nested_imp ni) m *) assumption. (* Goal: lt (@length nested_imp ni1) m *) apply lt_le_trans with (length ni). (* Goal: lt (@length nested_imp ni1) (@length nested_imp ni) *) (* Goal: le (@length nested_imp ni) m *) assumption. (* Goal: lt (@length nested_imp ni1) (@length nested_imp ni) *) (* Goal: le (@length nested_imp ni) m *) apply lt_n_Sm_le; assumption. Qed. Lemma lt_ks_shift_nd : forall (ni ni1 : nested_imps) (dni dni1 : decorated_nested_imps) (x : nimp) (k : kripke_tree), le_ni (rev_app dni1 ni1) (rev_app ((x, k) :: dni) ni) -> Lt_Ks ni1 dni1 (Undecorated x :: ni) dni. (* Goal: forall (ni ni1 : nested_imps) (dni dni1 : decorated_nested_imps) (x : nimp) (k : kripke_tree) (_ : le_ni (rev_app dni1 ni1) (rev_app (@cons (prod nimp kripke_tree) (@pair nimp kripke_tree x k) dni) ni)), Lt_Ks ni1 dni1 (@cons nested_imp (Undecorated x) ni) dni *) intros ni ni1 dni dni1 x k le. (* Goal: Lt_Ks ni1 dni1 (@cons nested_imp (Undecorated x) ni) dni *) apply lt_ks_count_undecs. (* Goal: lt (@length nested_imp ni1) (@length nested_imp ni) *) (* Goal: le (@length nested_imp ni) m *) apply le_ni_trans with (rev_app ((x, k) :: dni) ni); try assumption. (* Goal: le_ni (rev_app (@cons (prod nimp kripke_tree) (@pair nimp kripke_tree x k) dni) ni) (rev_app dni (@cons nested_imp (Undecorated x) ni)) *) (* Goal: lt (count_undecs ni1) (count_undecs (@cons nested_imp (Undecorated x) ni)) *) simpl in |- *. (* Goal: le_ni (rev_app dni (@cons nested_imp (Decorated x k) ni)) (rev_app dni (@cons nested_imp (Undecorated x) ni)) *) (* Goal: lt (count_undecs ni1) (count_undecs (@cons nested_imp (Undecorated x) ni)) *) rewrite (rev_app_app dni (Decorated x k :: ni)). (* Goal: le_ni (@app nested_imp (rev_app dni NNil) (@cons nested_imp (Decorated x k) ni)) (rev_app dni (@cons nested_imp (Undecorated x) ni)) *) (* Goal: lt (count_undecs ni1) (count_undecs (@cons nested_imp (Undecorated x) ni)) *) rewrite (rev_app_app dni (Undecorated x :: ni)). (* Goal: le_ni (@app nested_imp (rev_app dni NNil) (@cons nested_imp (Decorated x k) ni)) (@app nested_imp (rev_app dni NNil) (@cons nested_imp (Undecorated x) ni)) *) (* Goal: lt (count_undecs ni1) (count_undecs (@cons nested_imp (Undecorated x) ni)) *) apply le_ni_app_dn. (* Goal: @eq nat (@length nested_imp (rev_app dni NNil)) (@length nested_imp (rev_app dni NNil)) *) (* Goal: le_ni (@app nested_imp (rev_app dni NNil) ni) (@app nested_imp (rev_app dni NNil) ni) *) (* Goal: lt (count_undecs ni1) (count_undecs (@cons nested_imp (Undecorated x) ni)) *) trivial. (* Goal: le_ni (rev_app (@cons (prod nimp kripke_tree) (@pair nimp kripke_tree x k) dni) ni) (rev_app dni (@cons nested_imp (Decorated x k) ni)) *) (* Goal: lt (@length nested_imp ni) (@length nested_imp (@cons nested_imp (Decorated x k) ni)) *) apply le_ni_refl. (* Goal: lt (count_undecs ni1) (count_undecs (@cons nested_imp (Undecorated x) ni)) *) apply le_lt_trans with (count_undecs ni). (* Goal: lt (@length nested_imp ni1) (@length nested_imp ni) *) (* Goal: le (@length nested_imp ni) m *) apply le_ks_le_count_undecs with dni1 ((x, k) :: dni); assumption. (* Goal: lt (@length nested_imp ni1) (S (@length nested_imp ni1)) *) (* Goal: P (rev_app dni1 ni1) *) simpl in |- *; apply lt_n_Sn. Qed. Lemma lt_ks_shift_dd : forall (ni : nested_imps) (dni : decorated_nested_imps) (x : nimp) (k : kripke_tree), Lt_Ks ni ((x, k) :: dni) (Decorated x k :: ni) dni. (* Goal: forall (ni : nested_imps) (dni : decorated_nested_imps) (x : nimp) (k : kripke_tree), Lt_Ks ni (@cons (prod nimp kripke_tree) (@pair nimp kripke_tree x k) dni) (@cons nested_imp (Decorated x k) ni) dni *) intros ni dni x k. (* Goal: Lt_Ks ni (@cons (prod nimp kripke_tree) (@pair nimp kripke_tree x k) dni) (@cons nested_imp (Decorated x k) ni) dni *) apply lt_ks_length. (* Goal: le_ni (rev_app (@cons (prod nimp kripke_tree) (@pair nimp kripke_tree x k) dni) ni) (rev_app dni (@cons nested_imp (Decorated x k) ni)) *) (* Goal: lt (@length nested_imp ni) (@length nested_imp (@cons nested_imp (Decorated x k) ni)) *) apply le_ni_refl. (* Goal: lt (@length nested_imp ni1) (S (@length nested_imp ni1)) *) (* Goal: P (rev_app dni1 ni1) *) simpl in |- *; apply lt_n_Sn. Qed.
(* File: ML_int.v (last edited on 25/10/2000 (c) Klaus Weich *) (* Axiomisation of the ML type "int" *) Axiom Int : Set. Axiom Less : Int -> Int -> Prop. Axiom Equal : Int -> Int -> Prop. Axiom int_succ : forall x : Int, {y : Int | Less x y}. Axiom int_null : Int. Axiom equal_dec : forall x y : Int, {Equal x y} + {~ Equal x y}. Axiom less_dec : forall x y : Int, {Less x y} + {~ Less x y}. Axiom notequal_notless_greater : forall x y : Int, ~ Equal x y -> ~ Less x y -> Less y x. Axiom less_trans : forall x y z : Int, Less x y -> Less y z -> Less x z. Axiom equal_less_less : forall x y z : Int, Equal x y -> Less y z -> Less x z. Axiom less_equal_less : forall x y z : Int, Less x y -> Equal y z -> Less x z. Axiom equal_sym : forall x y : Int, Equal x y -> Equal y x. Axiom equal_trans : forall x y z : Int, Equal x y -> Equal y z -> Equal x z. Axiom equal_refl : forall x : Int, Equal x x. Axiom equal_eq : forall x y : Int, Equal x y -> x = y. Axiom less_irrefl : forall x : Int, Less x x -> False. Lemma equal_dec_refl : forall (i : Int) (A : Set) (a b : A), match equal_dec i i with | left _ => a | right _ => b end = a. (* Goal: forall (i : Int) (A : Set) (a b : A), @eq A (if equal_dec i i then a else b) a *) intros i A a b. (* Goal: @eq A (if equal_dec i i then a else b) a *) elim (equal_dec i i). (* Goal: forall _ : Equal i i, @eq A a a *) (* Goal: forall _ : not (Equal i i), @eq A b a *) intros; trivial. (* Goal: forall _ : not (Equal i i), @eq A b a *) intros notequal; elimtype False; apply notequal. (* Goal: Equal i0 i0 *) (* Goal: or (Less i1 i0) (Equal i1 i0) *) apply equal_refl. Qed. Inductive max_int_spec (i0 i1 : Int) : Set := Max_Int_Intro : forall j : Int, Less i0 j \/ Equal i0 j -> Less i1 j \/ Equal i1 j -> max_int_spec i0 i1. Lemma max_int : forall i0 i1 : Int, max_int_spec i0 i1. (* Goal: forall i0 i1 : Int, max_int_spec i0 i1 *) intros i0 i1. (* Goal: max_int_spec i0 i1 *) elim (equal_dec i0 i1). (* Goal: forall _ : Equal i0 i1, max_int_spec i0 i1 *) (* Goal: forall _ : not (Equal i0 i1), max_int_spec i0 i1 *) intros eq_i0_i1. (* Goal: max_int_spec i0 i1 *) exists i0. (* Goal: or (Less i0 i0) (Equal i0 i0) *) (* Goal: or (Less i1 i0) (Equal i1 i0) *) right. (* Goal: Equal i0 i0 *) (* Goal: or (Less i1 i0) (Equal i1 i0) *) apply equal_refl. (* Goal: or (Less i0 i0) (Equal i0 i0) *) (* Goal: or (Less i1 i0) (Equal i1 i0) *) right. (* Goal: Equal i1 i0 *) (* Goal: forall _ : not (Equal i0 i1), max_int_spec i0 i1 *) apply equal_sym; assumption. (* Goal: forall _ : not (Equal i0 i1), max_int_spec i0 i1 *) intros not_eq_i0_i1. (* Goal: max_int_spec i0 i1 *) elim (less_dec i0 i1). (* Goal: forall _ : Less i0 i1, max_int_spec i0 i1 *) (* Goal: forall _ : not (Less i0 i1), max_int_spec i0 i1 *) intros less_i0_i1. (* Goal: max_int_spec i0 i1 *) (* Goal: forall _ : not (Less i0 i1), max_int_spec i0 i1 *) exists i1. (* Goal: or (Less i0 i1) (Equal i0 i1) *) (* Goal: or (Less i1 i1) (Equal i1 i1) *) (* Goal: forall _ : not (Less i0 i1), max_int_spec i0 i1 *) left; assumption. (* Goal: or (Less i0 i0) (Equal i0 i0) *) (* Goal: or (Less i1 i0) (Equal i1 i0) *) right. (* Goal: Equal i0 i0 *) (* Goal: or (Less i1 i0) (Equal i1 i0) *) apply equal_refl. (* Goal: forall _ : not (Less i0 i1), max_int_spec i0 i1 *) intros ge_i0_i1. (* Goal: max_int_spec i0 i1 *) exists i0. (* Goal: or (Less i0 i0) (Equal i0 i0) *) (* Goal: or (Less i1 i0) (Equal i1 i0) *) right. (* Goal: Equal i0 i0 *) (* Goal: or (Less i1 i0) (Equal i1 i0) *) apply equal_refl. (* Goal: or (Less i1 i0) (Equal i1 i0) *) left. (* Goal: Less i1 i0 *) apply notequal_notless_greater; assumption. Qed.
(* File: Weight.v (last edited on 27/10/2000) (c) Klaus Weich *) Require Import Rules. Fixpoint weight (a : form) : nat := match a with | Falsum => 1 | Atom _ => 1 | AndF a b => S (weight a + weight b) | OrF Falsum b => S (weight b) | OrF (Atom _) b => S (weight b) | OrF a b => S (S (weight b + weight a)) | Imp a b => weight_neg a + weight b end with weight_neg (a : form) : nat := match a with | Falsum => 0 | Atom _ => 0 | AndF a b => S (weight_neg a + weight_neg b) | OrF a b => S (S (S (weight_neg a + weight_neg b))) | Imp Falsum b => 1 | Imp (Atom _) Falsum => 2 | Imp (Atom _) (Atom _) => 1 | Imp (Atom _) b => S (S (S (weight_neg b))) | Imp a b => S (S (S (S (weight_neg b + weight a)))) end. Fixpoint weight_goal (a : form) : nat := match a with | Falsum => 0 | Atom _ => 0 | AndF _ _ => 1 | OrF _ _ => 1 | Imp _ b => S (weight_goal b) end. Definition weight_gamma := fold_right (fun (a : form) (n : nat) => weight a + n) 0. (**********************************************************************) Lemma weight_ge_1 : forall a : form, 1 <= weight a. (* Goal: forall a : form, le (S O) (weight a) *) intros a; elim a; clear a. (* Goal: forall i : Int, le (S O) (weight (Atom i)) *) (* Goal: forall (f : form) (_ : le (S O) (weight f)) (f0 : form) (_ : le (S O) (weight f0)), le (S O) (weight (AndF f f0)) *) (* Goal: forall (f : form) (_ : le (S O) (weight f)) (f0 : form) (_ : le (S O) (weight f0)), le (S O) (weight (OrF f f0)) *) (* Goal: forall (f : form) (_ : le (S O) (weight f)) (f0 : form) (_ : le (S O) (weight f0)), le (S O) (weight (Imp f f0)) *) trivial. (* Goal: forall i : Int, le (S O) (weight (Atom i)) *) (* Goal: forall (f : form) (_ : le (S O) (weight f)) (f0 : form) (_ : le (S O) (weight f0)), le (S O) (weight (AndF f f0)) *) (* Goal: forall (f : form) (_ : le (S O) (weight f)) (f0 : form) (_ : le (S O) (weight f0)), le (S O) (weight (OrF f f0)) *) (* Goal: forall (f : form) (_ : le (S O) (weight f)) (f0 : form) (_ : le (S O) (weight f0)), le (S O) (weight (Imp f f0)) *) trivial. (* Goal: forall (f : form) (_ : le (S O) (weight f)) (f0 : form) (_ : le (S O) (weight f0)), le (S O) (weight (AndF f f0)) *) (* Goal: forall (f : form) (_ : le (S O) (weight f)) (f0 : form) (_ : le (S O) (weight f0)), le (S O) (weight (OrF f f0)) *) (* Goal: forall (f : form) (_ : le (S O) (weight f)) (f0 : form) (_ : le (S O) (weight f0)), le (S O) (weight (Imp f f0)) *) intros; simpl in |- *. (* Goal: le (S O) (S (Nat.add (weight f) (weight f0))) *) (* Goal: forall (f : form) (_ : le (S O) (weight f)) (f0 : form) (_ : le (S O) (weight f0)), le (S O) (weight (OrF f f0)) *) (* Goal: forall (f : form) (_ : le (S O) (weight f)) (f0 : form) (_ : le (S O) (weight f0)), le (S O) (weight (Imp f f0)) *) apply le_n_S. (* Goal: le O (weight_neg a) *) apply le_O_n. (* Goal: forall (f : form) (_ : le (S O) (weight f)) (f0 : form) (_ : le (S O) (weight f0)), le (S O) (weight (Imp f f0)) *) intros a ih_a b ih_b. (* Goal: le (S O) (weight (OrF a b)) *) (* Goal: forall (f : form) (_ : le (S O) (weight f)) (f0 : form) (_ : le (S O) (weight f0)), le (S O) (weight (Imp f f0)) *) clear ih_a ih_b. (* Goal: le O (weight_neg a) *) case a; clear a; intros; simpl in |- *; apply le_n_S; apply le_O_n. (* Goal: forall (f : form) (_ : le (S O) (weight f)) (f0 : form) (_ : le (S O) (weight f0)), le (S O) (weight (Imp f f0)) *) intros a ih_a b ih_b. (* Goal: le (S (Nat.add (Nat.add (Nat.add (weight a) (weight b)) (weight c)) (weight_gamma gamma))) (weight_gamma (@cons form d gamma)) *) simpl in |- *. (* Goal: le (S O) (Nat.add (weight_neg a) (weight b)) *) fold weight_neg in |- *. (* Goal: le (S O) (Nat.add (weight_neg a) (weight b)) *) apply le_trans with (weight b); try assumption. (* Goal: le (weight b) (Nat.add (weight_neg a) (weight b)) *) apply (plus_le_compat_r 0 (weight_neg a) (weight b)). (* Goal: le O (weight_neg a) *) apply le_O_n. Qed. Lemma weight_neg_le : forall (j : Int) (a : form), weight_neg (Imp (Atom j) a) <= S (S (S (weight_neg a))). (* Goal: forall (j : Int) (a : form), le (weight_neg (Imp (Atom j) a)) (S (S (S (weight_neg a)))) *) intros j a; case a; clear a. (* Goal: le (weight_neg (Imp (Atom j) Falsum)) (S (S (S (weight_neg Falsum)))) *) (* Goal: forall i : Int, le (weight_neg (Imp (Atom j) (Atom i))) (S (S (S (weight_neg (Atom i))))) *) (* Goal: forall f f0 : form, le (weight_neg (Imp (Atom j) (AndF f f0))) (S (S (S (weight_neg (AndF f f0))))) *) (* Goal: forall f f0 : form, le (weight_neg (Imp (Atom j) (OrF f f0))) (S (S (S (weight_neg (OrF f f0))))) *) (* Goal: forall f f0 : form, le (weight_neg (Imp (Atom j) (Imp f f0))) (S (S (S (weight_neg (Imp f f0))))) *) apply le_n_Sn. (* Goal: le (weight_neg (Imp (Atom j) Falsum)) (S (S (S (weight_neg Falsum)))) *) (* Goal: forall i : Int, le (weight_neg (Imp (Atom j) (Atom i))) (S (S (S (weight_neg (Atom i))))) *) (* Goal: forall f f0 : form, le (weight_neg (Imp (Atom j) (AndF f f0))) (S (S (S (weight_neg (AndF f f0))))) *) (* Goal: forall f f0 : form, le (weight_neg (Imp (Atom j) (OrF f f0))) (S (S (S (weight_neg (OrF f f0))))) *) (* Goal: forall f f0 : form, le (weight_neg (Imp (Atom j) (Imp f f0))) (S (S (S (weight_neg (Imp f f0))))) *) intros; apply le_trans with 2; apply le_n_Sn. (* Goal: forall f f0 : form, le (weight_neg (Imp (Atom j) (Imp f f0))) (S (S (S (weight_neg (Imp f f0))))) *) intros; apply le_n. (* Goal: forall f f0 : form, le (weight_neg (Imp (Atom j) (Imp f f0))) (S (S (S (weight_neg (Imp f f0))))) *) intros; apply le_n. (* Goal: forall f f0 : form, le (weight_neg (Imp (Atom j) (Imp f f0))) (S (S (S (weight_neg (Imp f f0))))) *) intros; apply le_n. Qed. Lemma weight_vimp : forall (l : list Int) (a : form), weight (vimp l a) = weight a. (* Goal: forall (l : list Int) (a : form), @eq nat (weight (vimp l a)) (weight a) *) intros l. (* Goal: forall a : form, @eq nat (weight (vimp l a)) (weight a) *) elim l; clear l. (* Goal: forall i : Int, le (S O) (weight (Atom i)) *) (* Goal: forall (f : form) (_ : le (S O) (weight f)) (f0 : form) (_ : le (S O) (weight f0)), le (S O) (weight (AndF f f0)) *) (* Goal: forall (f : form) (_ : le (S O) (weight f)) (f0 : form) (_ : le (S O) (weight f0)), le (S O) (weight (OrF f f0)) *) (* Goal: forall (f : form) (_ : le (S O) (weight f)) (f0 : form) (_ : le (S O) (weight f0)), le (S O) (weight (Imp f f0)) *) intro a; trivial. (* Goal: forall (a : Int) (l : list Int) (_ : forall a0 : form, @eq nat (weight (vimp l a0)) (weight a0)) (a0 : form), @eq nat (weight (vimp (@cons Int a l) a0)) (weight a0) *) intros i l ih a. (* Goal: le (S (Nat.add (Nat.add (Nat.add (weight a) (weight b)) (weight c)) (weight_gamma gamma))) (weight_gamma (@cons form d gamma)) *) simpl in |- *. (* Goal: @eq nat (weight (vimp l (Imp (Atom i) a))) (weight a) *) apply ih with (a := Imp (Atom i) a). Qed. Lemma weight_gamma_weak : forall (a b : form) (gamma : flist) (n : nat), weight a < weight b -> weight_gamma (b :: gamma) < S n -> weight_gamma (a :: gamma) < n. (* Goal: forall (a b c d : form) (gamma : flist) (n : nat) (_ : lt (Nat.add (Nat.add (weight a) (weight b)) (weight c)) (weight d)) (_ : lt (Nat.add (weight d) (weight_gamma gamma)) (S n)), lt (Nat.add (weight a) (Nat.add (weight b) (Nat.add (weight c) (weight_gamma gamma)))) n *) intros. (* Goal: le (S (Nat.add (Nat.add (Nat.add (weight a) (weight b)) (weight c)) (weight_gamma gamma))) (weight_gamma (@cons form d gamma)) *) simpl in |- *. (* Goal: lt (Nat.add (Nat.add (Nat.add (weight a) (weight b)) (weight c)) (weight_gamma gamma)) n *) apply lt_S_n. (* Goal: lt (S (Nat.add (weight a) (weight_gamma gamma))) (S n) *) apply le_lt_trans with (weight_gamma (b :: gamma)); try assumption. (* Goal: le (S (Nat.add (Nat.add (Nat.add (weight a) (weight b)) (weight c)) (weight_gamma gamma))) (weight_gamma (@cons form d gamma)) *) simpl in |- *. (* Goal: le (S (Nat.add (Nat.add (Nat.add (weight a) (weight b)) (weight c)) (weight_gamma gamma))) (Nat.add (weight d) (weight_gamma gamma)) *) apply lt_le_S. (* Goal: lt (Nat.add (Nat.add (Nat.add (weight a) (weight b)) (weight c)) (weight_gamma gamma)) (Nat.add (weight d) (weight_gamma gamma)) *) apply plus_lt_compat_r. (* Goal: lt (Nat.add (Nat.add (weight a) (weight b)) (weight c)) (weight d) *) assumption. Qed. Lemma weight_gamma_weak' : forall (a b : form) (gamma : flist) (n : nat), weight a < weight b -> weight b + weight_gamma gamma < S n -> weight a + weight_gamma gamma < n. (* Goal: forall (a b c d : form) (gamma : flist) (n : nat) (_ : lt (Nat.add (Nat.add (weight a) (weight b)) (weight c)) (weight d)) (_ : lt (Nat.add (weight d) (weight_gamma gamma)) (S n)), lt (Nat.add (weight a) (Nat.add (weight b) (Nat.add (weight c) (weight_gamma gamma)))) n *) intros. (* Goal: lt (Nat.add (Nat.add (weight a) (weight b)) (weight c)) (weight d) *) apply (weight_gamma_weak a b gamma n); assumption. Qed. Lemma weight_gamma_weak2 : forall (a b c : form) (gamma : flist) (n : nat), weight a + weight b < weight c -> weight_gamma (c :: gamma) < S n -> weight_gamma (a :: b :: gamma) < n. (* Goal: forall (a b c d : form) (gamma : flist) (n : nat) (_ : lt (Nat.add (Nat.add (weight a) (weight b)) (weight c)) (weight d)) (_ : lt (Nat.add (weight d) (weight_gamma gamma)) (S n)), lt (Nat.add (weight a) (Nat.add (weight b) (Nat.add (weight c) (weight_gamma gamma)))) n *) intros. (* Goal: le (S (Nat.add (Nat.add (Nat.add (weight a) (weight b)) (weight c)) (weight_gamma gamma))) (weight_gamma (@cons form d gamma)) *) simpl in |- *. (* Goal: lt (Nat.add (Nat.add (weight a) (weight b)) (Nat.add (weight c) (weight_gamma gamma))) n *) apply lt_plus_assoc_l. (* Goal: lt (Nat.add (Nat.add (Nat.add (weight a) (weight b)) (weight c)) (weight_gamma gamma)) n *) apply lt_S_n. (* Goal: lt (Nat.add (Nat.add (weight a) (weight b)) (weight c)) (weight d) *) apply le_lt_trans with (weight_gamma (c :: gamma)); try assumption. (* Goal: le (S (Nat.add (Nat.add (Nat.add (weight a) (weight b)) (weight c)) (weight_gamma gamma))) (weight_gamma (@cons form d gamma)) *) simpl in |- *. (* Goal: le (S (Nat.add (Nat.add (Nat.add (weight a) (weight b)) (weight c)) (weight_gamma gamma))) (Nat.add (weight d) (weight_gamma gamma)) *) apply lt_le_S. (* Goal: lt (Nat.add (Nat.add (Nat.add (weight a) (weight b)) (weight c)) (weight_gamma gamma)) (Nat.add (weight d) (weight_gamma gamma)) *) apply plus_lt_compat_r. (* Goal: lt (Nat.add (Nat.add (weight a) (weight b)) (weight c)) (weight d) *) assumption. Qed. Lemma weight_gamma_weak2' : forall (a b c : form) (gamma : flist) (n : nat), weight a + weight b < weight c -> weight c + weight_gamma gamma < S n -> weight a + (weight b + weight_gamma gamma) < n. (* Goal: forall (a b c d : form) (gamma : flist) (n : nat) (_ : lt (Nat.add (Nat.add (weight a) (weight b)) (weight c)) (weight d)) (_ : lt (Nat.add (weight d) (weight_gamma gamma)) (S n)), lt (Nat.add (weight a) (Nat.add (weight b) (Nat.add (weight c) (weight_gamma gamma)))) n *) intros. (* Goal: lt (Nat.add (Nat.add (weight a) (weight b)) (weight c)) (weight d) *) apply (weight_gamma_weak2 a b c gamma n); assumption. Qed. Lemma weight_gamma_weak3 : forall (a b c d : form) (gamma : flist) (n : nat), weight a + weight b + weight c < weight d -> weight_gamma (d :: gamma) < S n -> weight_gamma (a :: b :: c :: gamma) < n. (* Goal: forall (a b c d : form) (gamma : flist) (n : nat) (_ : lt (Nat.add (Nat.add (weight a) (weight b)) (weight c)) (weight d)) (_ : lt (Nat.add (weight d) (weight_gamma gamma)) (S n)), lt (Nat.add (weight a) (Nat.add (weight b) (Nat.add (weight c) (weight_gamma gamma)))) n *) intros. (* Goal: le (S (Nat.add (Nat.add (Nat.add (weight a) (weight b)) (weight c)) (weight_gamma gamma))) (weight_gamma (@cons form d gamma)) *) simpl in |- *. (* Goal: lt (Nat.add (Nat.add (weight a) (weight b)) (Nat.add (weight c) (weight_gamma gamma))) n *) apply lt_plus_assoc_l. (* Goal: lt (Nat.add (Nat.add (weight a) (weight b)) (Nat.add (weight c) (weight_gamma gamma))) n *) apply lt_plus_assoc_l. (* Goal: lt (Nat.add (Nat.add (Nat.add (weight a) (weight b)) (weight c)) (weight_gamma gamma)) n *) apply lt_S_n. (* Goal: lt (Nat.add (Nat.add (weight a) (weight b)) (weight c)) (weight d) *) apply le_lt_trans with (weight_gamma (d :: gamma)); try assumption. (* Goal: le (S (Nat.add (Nat.add (Nat.add (weight a) (weight b)) (weight c)) (weight_gamma gamma))) (weight_gamma (@cons form d gamma)) *) simpl in |- *. (* Goal: le (S (Nat.add (Nat.add (Nat.add (weight a) (weight b)) (weight c)) (weight_gamma gamma))) (Nat.add (weight d) (weight_gamma gamma)) *) apply lt_le_S. (* Goal: lt (Nat.add (Nat.add (Nat.add (weight a) (weight b)) (weight c)) (weight_gamma gamma)) (Nat.add (weight d) (weight_gamma gamma)) *) apply plus_lt_compat_r. (* Goal: lt (Nat.add (Nat.add (weight a) (weight b)) (weight c)) (weight d) *) assumption. Qed. Lemma weight_gamma_weak3' : forall (a b c d : form) (gamma : flist) (n : nat), weight a + weight b + weight c < weight d -> weight d + weight_gamma gamma < S n -> weight a + (weight b + (weight c + weight_gamma gamma)) < n. (* Goal: forall (a b c d : form) (gamma : flist) (n : nat) (_ : lt (Nat.add (Nat.add (weight a) (weight b)) (weight c)) (weight d)) (_ : lt (Nat.add (weight d) (weight_gamma gamma)) (S n)), lt (Nat.add (weight a) (Nat.add (weight b) (Nat.add (weight c) (weight_gamma gamma)))) n *) intros. (* Goal: lt (Nat.add (Nat.add (weight a) (weight b)) (weight c)) (weight d) *) apply (weight_gamma_weak3 a b c d gamma n); assumption. Qed.
(* File: Derivations.v (last edited on 1/11/2000) (c) Klaus Weich *) Require Export Forms. (******* Derivations *****************************************) Inductive proof_term : Set := | Var : nat -> proof_term | Efq : proof_term -> form -> proof_term | Abs : form -> proof_term -> proof_term | App : form -> proof_term -> proof_term -> proof_term | Pair : proof_term -> proof_term -> proof_term | PrL : form -> proof_term -> proof_term | PrR : form -> proof_term -> proof_term | OrFL : proof_term -> form -> proof_term | OrFR : proof_term -> form -> proof_term | Cas : form -> form -> proof_term -> proof_term -> proof_term -> proof_term | Shift : proof_term -> proof_term. Inductive derives : flist -> proof_term -> form -> Prop := | ByAssumption : forall (context : flist) (n : nat) (a : form), my_nth form n context a -> derives context (Var n) a | ByAbsurdity : forall (context : flist) (t : proof_term) (a : form), derives context t Falsum -> derives context (Efq t a) a | ImpIntro : forall (context : flist) (a : form) (r : proof_term) (b : form), derives (a :: context) r b -> derives context (Abs a r) (Imp a b) | ImpElim : forall (context : flist) (r s : proof_term) (a b : form), derives context r (Imp a b) -> derives context s a -> derives context (App a r s) b | AndFIntro : forall (context : flist) (r s : proof_term) (a b : form), derives context r a -> derives context s b -> derives context (Pair r s) (AndF a b) | AndFElimL : forall (context : flist) (r : proof_term) (a b : form), derives context r (AndF a b) -> derives context (PrL b r) a | AndFElimR : forall (context : flist) (r : proof_term) (a b : form), derives context r (AndF a b) -> derives context (PrR a r) b | OrFIntroL : forall (context : flist) (r : proof_term) (a b : form), derives context r a -> derives context (OrFL r b) (OrF a b) | OrFIntroR : forall (context : flist) (r : proof_term) (a b : form), derives context r b -> derives context (OrFR r a) (OrF a b) | OrFElim : forall (context : flist) (r s t : proof_term) (a b c : form), derives context r (OrF a b) -> derives (a :: context) s c -> derives (b :: context) t c -> derives context (Cas a b r s t) c | ShiftIntro : forall (context : flist) (r : proof_term) (a b : form), derives context r b -> derives (a :: context) (Shift r) b. Lemma derives_rec : forall P : flist -> proof_term -> form -> Set, (forall (context : flist) (n : nat) (a : form), my_nth form n context a -> P context (Var n) a) -> (forall (context : flist) (t : proof_term) (a : form), derives context t Falsum -> P context t Falsum -> P context (Efq t a) a) -> (forall (context : flist) (a : form) (r : proof_term) (b : form), derives (a :: context) r b -> P (a :: context) r b -> P context (Abs a r) (Imp a b)) -> (forall (context : flist) (r s : proof_term) (a b : form), derives context r (Imp a b) -> P context r (Imp a b) -> derives context s a -> P context s a -> P context (App a r s) b) -> (forall (context : flist) (r s : proof_term) (a b : form), derives context r a -> P context r a -> derives context s b -> P context s b -> P context (Pair r s) (AndF a b)) -> (forall (context : flist) (r : proof_term) (a b : form), derives context r (AndF a b) -> P context r (AndF a b) -> P context (PrL b r) a) -> (forall (context : flist) (r : proof_term) (a b : form), derives context r (AndF a b) -> P context r (AndF a b) -> P context (PrR a r) b) -> (forall (context : flist) (r : proof_term) (a b : form), derives context r a -> P context r a -> P context (OrFL r b) (OrF a b)) -> (forall (context : flist) (r : proof_term) (a b : form), derives context r b -> P context r b -> P context (OrFR r a) (OrF a b)) -> (forall (context : flist) (r s t : proof_term) (a b c : form), derives context r (OrF a b) -> P context r (OrF a b) -> derives (a :: context) s c -> P (a :: context) s c -> derives (b :: context) t c -> P (b :: context) t c -> P context (Cas a b r s t) c) -> (forall (context : flist) (r : proof_term) (a b : form), derives context r b -> P context r b -> P (a :: context) (Shift r) b) -> forall (context : flist) (t : proof_term) (a : form), derives context t a -> P context t a. (* Goal: forall (P : forall (_ : flist) (_ : proof_term) (_ : form), Set) (_ : forall (context : flist) (n : nat) (a : form) (_ : my_nth form n context a), P context (Var n) a) (_ : forall (context : flist) (t : proof_term) (a : form) (_ : derives context t Falsum) (_ : P context t Falsum), P context (Efq t a) a) (_ : forall (context : flist) (a : form) (r : proof_term) (b : form) (_ : derives (@cons form a context) r b) (_ : P (@cons form a context) r b), P context (Abs a r) (Imp a b)) (_ : forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : P context r (Imp a b)) (_ : derives context s a) (_ : P context s a), P context (App a r s) b) (_ : forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : P context r a) (_ : derives context s b) (_ : P context s b), P context (Pair r s) (AndF a b)) (_ : forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : P context r (AndF a b)), P context (PrL b r) a) (_ : forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : P context r (AndF a b)), P context (PrR a r) b) (_ : forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : P context r a), P context (OrFL r b) (OrF a b)) (_ : forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : P context r b), P context (OrFR r a) (OrF a b)) (_ : forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : P context r (OrF a b)) (_ : derives (@cons form a context) s c) (_ : P (@cons form a context) s c) (_ : derives (@cons form b context) t c) (_ : P (@cons form b context) t c), P context (Cas a b r s t) c) (_ : forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : P context r b), P (@cons form a context) (Shift r) b) (context : flist) (t : proof_term) (a : form) (_ : derives context t a), P context t a *) intros P var efq abs app pari prl prr orl orr cas shift context t. (* Goal: forall (a : form) (_ : derives context t a), P context t a *) generalize context; clear context. (* Goal: forall (context : flist) (a : form) (_ : derives context t a), P context t a *) elim t; clear t. (* Goal: forall (n : nat) (context : flist) (a : form) (_ : derives context (Var n) a), P context (Var n) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (Efq p f) a), P context (Efq p f) a *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Abs f p) a), P context (Abs f p) a *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (context : flist) (a : form) (_ : derives context (App f p p0) a), P context (App f p p0) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (context : flist) (a : form) (_ : derives context (Pair p p0) a), P context (Pair p p0) a *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (PrL f p) a), P context (PrL f p) a *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (PrR f p) a), P context (PrR f p) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFL p f) a), P context (OrFL p f) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFR p f) a), P context (OrFR p f) a *) (* Goal: forall (f f0 : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (p1 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p1 a), P context p1 a) (context : flist) (a : form) (_ : derives context (Cas f f0 p p0 p1) a), P context (Cas f f0 p p0 p1) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) intros n context a der. (* Goal: P context (Var n) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (Efq p f) a), P context (Efq p f) a *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Abs f p) a), P context (Abs f p) a *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (context : flist) (a : form) (_ : derives context (App f p p0) a), P context (App f p p0) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (context : flist) (a : form) (_ : derives context (Pair p p0) a), P context (Pair p p0) a *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (PrL f p) a), P context (PrL f p) a *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (PrR f p) a), P context (PrR f p) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFL p f) a), P context (OrFL p f) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFR p f) a), P context (OrFR p f) a *) (* Goal: forall (f f0 : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (p1 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p1 a), P context p1 a) (context : flist) (a : form) (_ : derives context (Cas f f0 p p0 p1) a), P context (Cas f f0 p p0 p1) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) apply var. (* Goal: derives context t a *) inversion_clear der; assumption. (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (Efq p f) a), P context (Efq p f) a *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Abs f p) a), P context (Abs f p) a *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (context : flist) (a : form) (_ : derives context (App f p p0) a), P context (App f p p0) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (context : flist) (a : form) (_ : derives context (Pair p p0) a), P context (Pair p p0) a *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (PrL f p) a), P context (PrL f p) a *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (PrR f p) a), P context (PrR f p) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFL p f) a), P context (OrFL p f) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFR p f) a), P context (OrFR p f) a *) (* Goal: forall (f f0 : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (p1 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p1 a), P context p1 a) (context : flist) (a : form) (_ : derives context (Cas f f0 p p0 p1) a), P context (Cas f f0 p p0 p1) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) intros t ih a context b der. (* Goal: P context (Efq t a) b *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Abs f p) a), P context (Abs f p) a *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (context : flist) (a : form) (_ : derives context (App f p p0) a), P context (App f p p0) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (context : flist) (a : form) (_ : derives context (Pair p p0) a), P context (Pair p p0) a *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (PrL f p) a), P context (PrL f p) a *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (PrR f p) a), P context (PrR f p) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFL p f) a), P context (OrFL p f) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFR p f) a), P context (OrFR p f) a *) (* Goal: forall (f f0 : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (p1 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p1 a), P context p1 a) (context : flist) (a : form) (_ : derives context (Cas f f0 p p0 p1) a), P context (Cas f f0 p p0 p1) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) cut (a = b). intros eq_a; rewrite eq_a. (* Goal: P context (Efq t b) b *) (* Goal: @eq form a b *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Abs f p) a), P context (Abs f p) a *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (context : flist) (a : form) (_ : derives context (App f p p0) a), P context (App f p p0) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (context : flist) (a : form) (_ : derives context (Pair p p0) a), P context (Pair p p0) a *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (PrL f p) a), P context (PrL f p) a *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (PrR f p) a), P context (PrR f p) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFL p f) a), P context (OrFL p f) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFR p f) a), P context (OrFR p f) a *) (* Goal: forall (f f0 : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (p1 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p1 a), P context p1 a) (context : flist) (a : form) (_ : derives context (Cas f f0 p p0 p1) a), P context (Cas f f0 p p0 p1) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) apply efq. (* Goal: derives context t a *) inversion_clear der; assumption. (* Goal: P context t a *) apply ih. (* Goal: derives context t a *) inversion_clear der; assumption. (* Goal: @eq form a b0 *) (* Goal: forall (f f0 : form) (_ : derives context (OrFR s a) (Imp f f0)), P context (OrFR s a) (Imp f f0) *) (* Goal: forall (f f0 : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (p1 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p1 a), P context p1 a) (context : flist) (a : form) (_ : derives context (Cas f f0 p p0 p1) a), P context (Cas f f0 p p0 p1) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) inversion_clear der; trivial. (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Abs f p) a), P context (Abs f p) a *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (context : flist) (a : form) (_ : derives context (App f p p0) a), P context (App f p p0) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (context : flist) (a : form) (_ : derives context (Pair p p0) a), P context (Pair p p0) a *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (PrL f p) a), P context (PrL f p) a *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (PrR f p) a), P context (PrR f p) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFL p f) a), P context (OrFL p f) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFR p f) a), P context (OrFR p f) a *) (* Goal: forall (f f0 : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (p1 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p1 a), P context p1 a) (context : flist) (a : form) (_ : derives context (Cas f f0 p p0 p1) a), P context (Cas f f0 p p0 p1) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) intros a t ih context b. (* Goal: forall _ : derives context (OrFR s a) b, P context (OrFR s a) b *) (* Goal: forall (f f0 : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (p1 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p1 a), P context p1 a) (context : flist) (a : form) (_ : derives context (Cas f f0 p p0 p1) a), P context (Cas f f0 p p0 p1) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) case b; clear b. (* Goal: forall _ : derives context (Abs a t) Falsum, P context (Abs a t) Falsum *) (* Goal: forall (i : Int) (_ : derives context (Abs a t) (Atom i)), P context (Abs a t) (Atom i) *) (* Goal: forall (f f0 : form) (_ : derives context (Abs a t) (AndF f f0)), P context (Abs a t) (AndF f f0) *) (* Goal: forall (f f0 : form) (_ : derives context (Abs a t) (OrF f f0)), P context (Abs a t) (OrF f f0) *) (* Goal: forall (f f0 : form) (_ : derives context (Abs a t) (Imp f f0)), P context (Abs a t) (Imp f f0) *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (context : flist) (a : form) (_ : derives context (App f p p0) a), P context (App f p p0) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (context : flist) (a : form) (_ : derives context (Pair p p0) a), P context (Pair p p0) a *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (PrL f p) a), P context (PrL f p) a *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (PrR f p) a), P context (PrR f p) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFL p f) a), P context (OrFL p f) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFR p f) a), P context (OrFR p f) a *) (* Goal: forall (f f0 : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (p1 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p1 a), P context p1 a) (context : flist) (a : form) (_ : derives context (Cas f f0 p p0 p1) a), P context (Cas f f0 p p0 p1) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) intros der_t; elimtype False; inversion_clear der_t. (* Goal: forall (i : Int) (_ : derives context (Abs a t) (Atom i)), P context (Abs a t) (Atom i) *) (* Goal: forall (f f0 : form) (_ : derives context (Abs a t) (AndF f f0)), P context (Abs a t) (AndF f f0) *) (* Goal: forall (f f0 : form) (_ : derives context (Abs a t) (OrF f f0)), P context (Abs a t) (OrF f f0) *) (* Goal: forall (f f0 : form) (_ : derives context (Abs a t) (Imp f f0)), P context (Abs a t) (Imp f f0) *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (context : flist) (a : form) (_ : derives context (App f p p0) a), P context (App f p p0) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (context : flist) (a : form) (_ : derives context (Pair p p0) a), P context (Pair p p0) a *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (PrL f p) a), P context (PrL f p) a *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (PrR f p) a), P context (PrR f p) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFL p f) a), P context (OrFL p f) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFR p f) a), P context (OrFR p f) a *) (* Goal: forall (f f0 : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (p1 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p1 a), P context p1 a) (context : flist) (a : form) (_ : derives context (Cas f f0 p p0 p1) a), P context (Cas f f0 p p0 p1) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) intros i der_t; elimtype False; inversion_clear der_t. (* Goal: forall (f f0 : form) (_ : derives context (Abs a t) (OrF f f0)), P context (Abs a t) (OrF f f0) *) (* Goal: forall (f f0 : form) (_ : derives context (Abs a t) (Imp f f0)), P context (Abs a t) (Imp f f0) *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (context : flist) (a : form) (_ : derives context (App f p p0) a), P context (App f p p0) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (context : flist) (a : form) (_ : derives context (Pair p p0) a), P context (Pair p p0) a *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (PrL f p) a), P context (PrL f p) a *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (PrR f p) a), P context (PrR f p) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFL p f) a), P context (OrFL p f) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFR p f) a), P context (OrFR p f) a *) (* Goal: forall (f f0 : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (p1 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p1 a), P context p1 a) (context : flist) (a : form) (_ : derives context (Cas f f0 p p0 p1) a), P context (Cas f f0 p p0 p1) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) intros b0 b1 der_t; elimtype False; inversion_clear der_t. (* Goal: forall (f f0 : form) (_ : derives context (Abs a t) (OrF f f0)), P context (Abs a t) (OrF f f0) *) (* Goal: forall (f f0 : form) (_ : derives context (Abs a t) (Imp f f0)), P context (Abs a t) (Imp f f0) *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (context : flist) (a : form) (_ : derives context (App f p p0) a), P context (App f p p0) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (context : flist) (a : form) (_ : derives context (Pair p p0) a), P context (Pair p p0) a *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (PrL f p) a), P context (PrL f p) a *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (PrR f p) a), P context (PrR f p) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFL p f) a), P context (OrFL p f) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFR p f) a), P context (OrFR p f) a *) (* Goal: forall (f f0 : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (p1 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p1 a), P context p1 a) (context : flist) (a : form) (_ : derives context (Cas f f0 p p0 p1) a), P context (Cas f f0 p p0 p1) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) intros b0 b1 der_t; elimtype False; inversion_clear der_t. (* Goal: forall (f f0 : form) (_ : derives context (Abs a t) (Imp f f0)), P context (Abs a t) (Imp f f0) *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (context : flist) (a : form) (_ : derives context (App f p p0) a), P context (App f p p0) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (context : flist) (a : form) (_ : derives context (Pair p p0) a), P context (Pair p p0) a *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (PrL f p) a), P context (PrL f p) a *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (PrR f p) a), P context (PrR f p) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFL p f) a), P context (OrFL p f) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFR p f) a), P context (OrFR p f) a *) (* Goal: forall (f f0 : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (p1 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p1 a), P context p1 a) (context : flist) (a : form) (_ : derives context (Cas f f0 p p0 p1) a), P context (Cas f f0 p p0 p1) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) intros b0 b1 der_t. (* Goal: P context (OrFR s a) (OrF b0 b1) *) (* Goal: forall (f f0 : form) (_ : derives context (OrFR s a) (Imp f f0)), P context (OrFR s a) (Imp f f0) *) (* Goal: forall (f f0 : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (p1 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p1 a), P context p1 a) (context : flist) (a : form) (_ : derives context (Cas f f0 p p0 p1) a), P context (Cas f f0 p p0 p1) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) cut (a = b0). intros eq_a; rewrite eq_a. (* Goal: P context (Abs b0 t) (Imp b0 b1) *) (* Goal: @eq form a b0 *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (context : flist) (a : form) (_ : derives context (App f p p0) a), P context (App f p p0) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (context : flist) (a : form) (_ : derives context (Pair p p0) a), P context (Pair p p0) a *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (PrL f p) a), P context (PrL f p) a *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (PrR f p) a), P context (PrR f p) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFL p f) a), P context (OrFL p f) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFR p f) a), P context (OrFR p f) a *) (* Goal: forall (f f0 : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (p1 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p1 a), P context p1 a) (context : flist) (a : form) (_ : derives context (Cas f f0 p p0 p1) a), P context (Cas f f0 p p0 p1) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) apply abs. (* Goal: derives (@cons form b0 context) t b1 *) (* Goal: @eq form a b0 *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (context : flist) (a : form) (_ : derives context (App f p p0) a), P context (App f p p0) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (context : flist) (a : form) (_ : derives context (Pair p p0) a), P context (Pair p p0) a *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (PrL f p) a), P context (PrL f p) a *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (PrR f p) a), P context (PrR f p) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFL p f) a), P context (OrFL p f) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFR p f) a), P context (OrFR p f) a *) (* Goal: forall (f f0 : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (p1 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p1 a), P context p1 a) (context : flist) (a : form) (_ : derives context (Cas f f0 p p0 p1) a), P context (Cas f f0 p p0 p1) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) inversion_clear der_t; assumption. (* Goal: P context t a *) apply ih. (* Goal: derives (@cons form b0 context) t b1 *) (* Goal: @eq form a b0 *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (context : flist) (a : form) (_ : derives context (App f p p0) a), P context (App f p p0) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (context : flist) (a : form) (_ : derives context (Pair p p0) a), P context (Pair p p0) a *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (PrL f p) a), P context (PrL f p) a *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (PrR f p) a), P context (PrR f p) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFL p f) a), P context (OrFL p f) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFR p f) a), P context (OrFR p f) a *) (* Goal: forall (f f0 : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (p1 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p1 a), P context p1 a) (context : flist) (a : form) (_ : derives context (Cas f f0 p p0 p1) a), P context (Cas f f0 p p0 p1) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) inversion_clear der_t; assumption. (* Goal: @eq form a b0 *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (context : flist) (a : form) (_ : derives context (App f p p0) a), P context (App f p p0) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (context : flist) (a : form) (_ : derives context (Pair p p0) a), P context (Pair p p0) a *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (PrL f p) a), P context (PrL f p) a *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (PrR f p) a), P context (PrR f p) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFL p f) a), P context (OrFL p f) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFR p f) a), P context (OrFR p f) a *) (* Goal: forall (f f0 : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (p1 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p1 a), P context p1 a) (context : flist) (a : form) (_ : derives context (Cas f f0 p p0 p1) a), P context (Cas f f0 p p0 p1) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) inversion_clear der_t; trivial. (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (context : flist) (a : form) (_ : derives context (App f p p0) a), P context (App f p p0) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (context : flist) (a : form) (_ : derives context (Pair p p0) a), P context (Pair p p0) a *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (PrL f p) a), P context (PrL f p) a *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (PrR f p) a), P context (PrR f p) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFL p f) a), P context (OrFL p f) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFR p f) a), P context (OrFR p f) a *) (* Goal: forall (f f0 : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (p1 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p1 a), P context p1 a) (context : flist) (a : form) (_ : derives context (Cas f f0 p p0 p1) a), P context (Cas f f0 p p0 p1) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) intros a s ih_s t ih_t context b der. (* Goal: P context (App a s t) b *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (context : flist) (a : form) (_ : derives context (Pair p p0) a), P context (Pair p p0) a *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (PrL f p) a), P context (PrL f p) a *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (PrR f p) a), P context (PrR f p) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFL p f) a), P context (OrFL p f) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFR p f) a), P context (OrFR p f) a *) (* Goal: forall (f f0 : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (p1 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p1 a), P context p1 a) (context : flist) (a : form) (_ : derives context (Cas f f0 p p0 p1) a), P context (Cas f f0 p p0 p1) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) apply app. (* Goal: derives context t a *) inversion_clear der; assumption. (* Goal: P (@cons form a context) s c *) (* Goal: derives (@cons form b context) t c *) (* Goal: P (@cons form b context) t c *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) apply ih_s. (* Goal: derives context t a *) inversion_clear der; assumption. (* Goal: derives context t a *) inversion_clear der; assumption. (* Goal: P (@cons form b context) t c *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) apply ih_t. (* Goal: derives context t a *) inversion_clear der; assumption. (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (context : flist) (a : form) (_ : derives context (Pair p p0) a), P context (Pair p p0) a *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (PrL f p) a), P context (PrL f p) a *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (PrR f p) a), P context (PrR f p) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFL p f) a), P context (OrFL p f) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFR p f) a), P context (OrFR p f) a *) (* Goal: forall (f f0 : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (p1 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p1 a), P context p1 a) (context : flist) (a : form) (_ : derives context (Cas f f0 p p0 p1) a), P context (Cas f f0 p p0 p1) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) intros s ih_s t ih_t context a. (* Goal: forall _ : derives context (Pair s t) a, P context (Pair s t) a *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (PrL f p) a), P context (PrL f p) a *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (PrR f p) a), P context (PrR f p) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFL p f) a), P context (OrFL p f) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFR p f) a), P context (OrFR p f) a *) (* Goal: forall (f f0 : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (p1 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p1 a), P context p1 a) (context : flist) (a : form) (_ : derives context (Cas f f0 p p0 p1) a), P context (Cas f f0 p p0 p1) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) case a; clear a. (* Goal: forall _ : derives (@nil form) (Shift t) a, P (@nil form) (Shift t) a *) (* Goal: forall (f : form) (l : list form) (_ : derives (@cons form f l) (Shift t) a), P (@cons form f l) (Shift t) a *) intros der; elimtype False; inversion_clear der. (* Goal: forall (i : Int) (_ : derives context (OrFR s a) (Atom i)), P context (OrFR s a) (Atom i) *) (* Goal: forall (f f0 : form) (_ : derives context (OrFR s a) (AndF f f0)), P context (OrFR s a) (AndF f f0) *) (* Goal: forall (f f0 : form) (_ : derives context (OrFR s a) (OrF f f0)), P context (OrFR s a) (OrF f f0) *) (* Goal: forall (f f0 : form) (_ : derives context (OrFR s a) (Imp f f0)), P context (OrFR s a) (Imp f f0) *) (* Goal: forall (f f0 : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (p1 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p1 a), P context p1 a) (context : flist) (a : form) (_ : derives context (Cas f f0 p p0 p1) a), P context (Cas f f0 p p0 p1) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) intros i der; elimtype False; inversion_clear der. (* Goal: forall (f f0 : form) (_ : derives context (Pair s t) (AndF f f0)), P context (Pair s t) (AndF f f0) *) (* Goal: forall (f f0 : form) (_ : derives context (Pair s t) (OrF f f0)), P context (Pair s t) (OrF f f0) *) (* Goal: forall (f f0 : form) (_ : derives context (Pair s t) (Imp f f0)), P context (Pair s t) (Imp f f0) *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (PrL f p) a), P context (PrL f p) a *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (PrR f p) a), P context (PrR f p) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFL p f) a), P context (OrFL p f) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFR p f) a), P context (OrFR p f) a *) (* Goal: forall (f f0 : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (p1 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p1 a), P context p1 a) (context : flist) (a : form) (_ : derives context (Cas f f0 p p0 p1) a), P context (Cas f f0 p p0 p1) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) intros a0 a1 der. (* Goal: P context (Pair s t) (AndF a0 a1) *) (* Goal: forall (f f0 : form) (_ : derives context (Pair s t) (OrF f f0)), P context (Pair s t) (OrF f f0) *) (* Goal: forall (f f0 : form) (_ : derives context (Pair s t) (Imp f f0)), P context (Pair s t) (Imp f f0) *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (PrL f p) a), P context (PrL f p) a *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (PrR f p) a), P context (PrR f p) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFL p f) a), P context (OrFL p f) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFR p f) a), P context (OrFR p f) a *) (* Goal: forall (f f0 : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (p1 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p1 a), P context p1 a) (context : flist) (a : form) (_ : derives context (Cas f f0 p p0 p1) a), P context (Cas f f0 p p0 p1) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) apply pari. (* Goal: derives context t a *) inversion_clear der; assumption. (* Goal: P (@cons form a context) s c *) (* Goal: derives (@cons form b context) t c *) (* Goal: P (@cons form b context) t c *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) apply ih_s. (* Goal: derives context t a *) inversion_clear der; assumption. (* Goal: derives context t a *) inversion_clear der; assumption. (* Goal: P (@cons form b context) t c *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) apply ih_t. (* Goal: derives context t a *) inversion_clear der; assumption. (* Goal: forall (f f0 : form) (_ : derives context (Pair s t) (Imp f f0)), P context (Pair s t) (Imp f f0) *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (PrL f p) a), P context (PrL f p) a *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (PrR f p) a), P context (PrR f p) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFL p f) a), P context (OrFL p f) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFR p f) a), P context (OrFR p f) a *) (* Goal: forall (f f0 : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (p1 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p1 a), P context p1 a) (context : flist) (a : form) (_ : derives context (Cas f f0 p p0 p1) a), P context (Cas f f0 p p0 p1) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) intros a0 a1 der; elimtype False; inversion_clear der. (* Goal: forall (f f0 : form) (_ : derives context (Pair s t) (Imp f f0)), P context (Pair s t) (Imp f f0) *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (PrL f p) a), P context (PrL f p) a *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (PrR f p) a), P context (PrR f p) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFL p f) a), P context (OrFL p f) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFR p f) a), P context (OrFR p f) a *) (* Goal: forall (f f0 : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (p1 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p1 a), P context p1 a) (context : flist) (a : form) (_ : derives context (Cas f f0 p p0 p1) a), P context (Cas f f0 p p0 p1) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) intros a0 a1 der; elimtype False; inversion_clear der. (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (PrR f p) a), P context (PrR f p) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFL p f) a), P context (OrFL p f) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFR p f) a), P context (OrFR p f) a *) (* Goal: forall (f f0 : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (p1 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p1 a), P context p1 a) (context : flist) (a : form) (_ : derives context (Cas f f0 p p0 p1) a), P context (Cas f f0 p p0 p1) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) intros a s ih context b der. (* Goal: P context (PrL a s) b *) (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (PrR f p) a), P context (PrR f p) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFL p f) a), P context (OrFL p f) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFR p f) a), P context (OrFR p f) a *) (* Goal: forall (f f0 : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (p1 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p1 a), P context p1 a) (context : flist) (a : form) (_ : derives context (Cas f f0 p p0 p1) a), P context (Cas f f0 p p0 p1) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) apply prl. (* Goal: derives context t a *) inversion_clear der; assumption. (* Goal: P context t a *) apply ih. (* Goal: derives context t a *) inversion_clear der; assumption. (* Goal: forall (f : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (PrR f p) a), P context (PrR f p) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFL p f) a), P context (OrFL p f) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFR p f) a), P context (OrFR p f) a *) (* Goal: forall (f f0 : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (p1 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p1 a), P context p1 a) (context : flist) (a : form) (_ : derives context (Cas f f0 p p0 p1) a), P context (Cas f f0 p p0 p1) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) intros a s ih context b der. (* Goal: P context (PrR a s) b *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFL p f) a), P context (OrFL p f) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFR p f) a), P context (OrFR p f) a *) (* Goal: forall (f f0 : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (p1 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p1 a), P context p1 a) (context : flist) (a : form) (_ : derives context (Cas f f0 p p0 p1) a), P context (Cas f f0 p p0 p1) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) apply prr. (* Goal: derives context t a *) inversion_clear der; assumption. (* Goal: P context t a *) apply ih. (* Goal: derives context t a *) inversion_clear der; assumption. (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFR p f) a), P context (OrFR p f) a *) (* Goal: forall (f f0 : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (p1 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p1 a), P context p1 a) (context : flist) (a : form) (_ : derives context (Cas f f0 p p0 p1) a), P context (Cas f f0 p p0 p1) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) intros s ih a context b. (* Goal: forall _ : derives context (OrFR s a) b, P context (OrFR s a) b *) (* Goal: forall (f f0 : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (p1 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p1 a), P context p1 a) (context : flist) (a : form) (_ : derives context (Cas f f0 p p0 p1) a), P context (Cas f f0 p p0 p1) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) case b; clear b. (* Goal: forall _ : derives (@nil form) (Shift t) a, P (@nil form) (Shift t) a *) (* Goal: forall (f : form) (l : list form) (_ : derives (@cons form f l) (Shift t) a), P (@cons form f l) (Shift t) a *) intros der; elimtype False; inversion_clear der. (* Goal: forall (i : Int) (_ : derives context (OrFR s a) (Atom i)), P context (OrFR s a) (Atom i) *) (* Goal: forall (f f0 : form) (_ : derives context (OrFR s a) (AndF f f0)), P context (OrFR s a) (AndF f f0) *) (* Goal: forall (f f0 : form) (_ : derives context (OrFR s a) (OrF f f0)), P context (OrFR s a) (OrF f f0) *) (* Goal: forall (f f0 : form) (_ : derives context (OrFR s a) (Imp f f0)), P context (OrFR s a) (Imp f f0) *) (* Goal: forall (f f0 : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (p1 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p1 a), P context p1 a) (context : flist) (a : form) (_ : derives context (Cas f f0 p p0 p1) a), P context (Cas f f0 p p0 p1) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) intros i der; elimtype False; inversion_clear der. (* Goal: forall (f f0 : form) (_ : derives context (OrFR s a) (Imp f f0)), P context (OrFR s a) (Imp f f0) *) (* Goal: forall (f f0 : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (p1 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p1 a), P context p1 a) (context : flist) (a : form) (_ : derives context (Cas f f0 p p0 p1) a), P context (Cas f f0 p p0 p1) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) intros b0 b1 der; elimtype False; inversion_clear der. (* Goal: forall (f f0 : form) (_ : derives context (OrFR s a) (OrF f f0)), P context (OrFR s a) (OrF f f0) *) (* Goal: forall (f f0 : form) (_ : derives context (OrFR s a) (Imp f f0)), P context (OrFR s a) (Imp f f0) *) (* Goal: forall (f f0 : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (p1 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p1 a), P context p1 a) (context : flist) (a : form) (_ : derives context (Cas f f0 p p0 p1) a), P context (Cas f f0 p p0 p1) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) intros b0 b1 der. (* Goal: P context (OrFL s a) (OrF b0 b1) *) (* Goal: forall (f f0 : form) (_ : derives context (OrFL s a) (Imp f f0)), P context (OrFL s a) (Imp f f0) *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFR p f) a), P context (OrFR p f) a *) (* Goal: forall (f f0 : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (p1 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p1 a), P context p1 a) (context : flist) (a : form) (_ : derives context (Cas f f0 p p0 p1) a), P context (Cas f f0 p p0 p1) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) cut (a = b1). intros eq_a; rewrite eq_a. (* Goal: P context (OrFL s b1) (OrF b0 b1) *) (* Goal: @eq form a b1 *) (* Goal: forall (f f0 : form) (_ : derives context (OrFL s a) (Imp f f0)), P context (OrFL s a) (Imp f f0) *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFR p f) a), P context (OrFR p f) a *) (* Goal: forall (f f0 : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (p1 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p1 a), P context p1 a) (context : flist) (a : form) (_ : derives context (Cas f f0 p p0 p1) a), P context (Cas f f0 p p0 p1) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) apply orl. (* Goal: derives context t a *) inversion_clear der; assumption. (* Goal: P context t a *) apply ih. (* Goal: derives context t a *) inversion_clear der; assumption. (* Goal: @eq form a b0 *) (* Goal: forall (f f0 : form) (_ : derives context (OrFR s a) (Imp f f0)), P context (OrFR s a) (Imp f f0) *) (* Goal: forall (f f0 : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (p1 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p1 a), P context p1 a) (context : flist) (a : form) (_ : derives context (Cas f f0 p p0 p1) a), P context (Cas f f0 p p0 p1) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) inversion_clear der; trivial. (* Goal: forall (f f0 : form) (_ : derives context (OrFR s a) (Imp f f0)), P context (OrFR s a) (Imp f f0) *) (* Goal: forall (f f0 : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (p1 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p1 a), P context p1 a) (context : flist) (a : form) (_ : derives context (Cas f f0 p p0 p1) a), P context (Cas f f0 p p0 p1) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) intros b0 b1 der; elimtype False; inversion_clear der. (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (f : form) (context : flist) (a : form) (_ : derives context (OrFR p f) a), P context (OrFR p f) a *) (* Goal: forall (f f0 : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (p1 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p1 a), P context p1 a) (context : flist) (a : form) (_ : derives context (Cas f f0 p p0 p1) a), P context (Cas f f0 p p0 p1) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) intros s ih a context b. (* Goal: forall _ : derives context (OrFR s a) b, P context (OrFR s a) b *) (* Goal: forall (f f0 : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (p1 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p1 a), P context p1 a) (context : flist) (a : form) (_ : derives context (Cas f f0 p p0 p1) a), P context (Cas f f0 p p0 p1) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) case b; clear b. (* Goal: forall _ : derives (@nil form) (Shift t) a, P (@nil form) (Shift t) a *) (* Goal: forall (f : form) (l : list form) (_ : derives (@cons form f l) (Shift t) a), P (@cons form f l) (Shift t) a *) intros der; elimtype False; inversion_clear der. (* Goal: forall (i : Int) (_ : derives context (OrFR s a) (Atom i)), P context (OrFR s a) (Atom i) *) (* Goal: forall (f f0 : form) (_ : derives context (OrFR s a) (AndF f f0)), P context (OrFR s a) (AndF f f0) *) (* Goal: forall (f f0 : form) (_ : derives context (OrFR s a) (OrF f f0)), P context (OrFR s a) (OrF f f0) *) (* Goal: forall (f f0 : form) (_ : derives context (OrFR s a) (Imp f f0)), P context (OrFR s a) (Imp f f0) *) (* Goal: forall (f f0 : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (p1 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p1 a), P context p1 a) (context : flist) (a : form) (_ : derives context (Cas f f0 p p0 p1) a), P context (Cas f f0 p p0 p1) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) intros i der; elimtype False; inversion_clear der. (* Goal: forall (f f0 : form) (_ : derives context (OrFR s a) (Imp f f0)), P context (OrFR s a) (Imp f f0) *) (* Goal: forall (f f0 : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (p1 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p1 a), P context p1 a) (context : flist) (a : form) (_ : derives context (Cas f f0 p p0 p1) a), P context (Cas f f0 p p0 p1) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) intros b0 b1 der; elimtype False; inversion_clear der. (* Goal: forall (f f0 : form) (_ : derives context (OrFR s a) (OrF f f0)), P context (OrFR s a) (OrF f f0) *) (* Goal: forall (f f0 : form) (_ : derives context (OrFR s a) (Imp f f0)), P context (OrFR s a) (Imp f f0) *) (* Goal: forall (f f0 : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (p1 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p1 a), P context p1 a) (context : flist) (a : form) (_ : derives context (Cas f f0 p p0 p1) a), P context (Cas f f0 p p0 p1) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) intros b0 b1 der. (* Goal: P context (OrFR s a) (OrF b0 b1) *) (* Goal: forall (f f0 : form) (_ : derives context (OrFR s a) (Imp f f0)), P context (OrFR s a) (Imp f f0) *) (* Goal: forall (f f0 : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (p1 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p1 a), P context p1 a) (context : flist) (a : form) (_ : derives context (Cas f f0 p p0 p1) a), P context (Cas f f0 p p0 p1) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) cut (a = b0). intros eq_a; rewrite eq_a. (* Goal: P context (OrFR s b0) (OrF b0 b1) *) (* Goal: @eq form a b0 *) (* Goal: forall (f f0 : form) (_ : derives context (OrFR s a) (Imp f f0)), P context (OrFR s a) (Imp f f0) *) (* Goal: forall (f f0 : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (p1 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p1 a), P context p1 a) (context : flist) (a : form) (_ : derives context (Cas f f0 p p0 p1) a), P context (Cas f f0 p p0 p1) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) apply orr. (* Goal: derives context t a *) inversion_clear der; assumption. (* Goal: P context t a *) apply ih. (* Goal: derives context t a *) inversion_clear der; assumption. (* Goal: @eq form a b0 *) (* Goal: forall (f f0 : form) (_ : derives context (OrFR s a) (Imp f f0)), P context (OrFR s a) (Imp f f0) *) (* Goal: forall (f f0 : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (p1 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p1 a), P context p1 a) (context : flist) (a : form) (_ : derives context (Cas f f0 p p0 p1) a), P context (Cas f f0 p p0 p1) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) inversion_clear der; trivial. (* Goal: forall (f f0 : form) (_ : derives context (OrFR s a) (Imp f f0)), P context (OrFR s a) (Imp f f0) *) (* Goal: forall (f f0 : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (p1 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p1 a), P context p1 a) (context : flist) (a : form) (_ : derives context (Cas f f0 p p0 p1) a), P context (Cas f f0 p p0 p1) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) intros b0 b1 der; elimtype False; inversion_clear der. (* Goal: forall (f f0 : form) (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (p0 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p0 a), P context p0 a) (p1 : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p1 a), P context p1 a) (context : flist) (a : form) (_ : derives context (Cas f f0 p p0 p1) a), P context (Cas f f0 p p0 p1) a *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) intros a b r ih_r s ih_s t ih_t context c der. (* Goal: P context (Cas a b r s t) c *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) apply cas. (* Goal: derives context t a *) inversion_clear der; assumption. (* Goal: P context r (OrF a b) *) (* Goal: derives (@cons form a context) s c *) (* Goal: P (@cons form a context) s c *) (* Goal: derives (@cons form b context) t c *) (* Goal: P (@cons form b context) t c *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) apply ih_r. (* Goal: derives context t a *) inversion_clear der; assumption. (* Goal: derives context t a *) inversion_clear der; assumption. (* Goal: P (@cons form a context) s c *) (* Goal: derives (@cons form b context) t c *) (* Goal: P (@cons form b context) t c *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) apply ih_s. (* Goal: derives context t a *) inversion_clear der; assumption. (* Goal: derives context t a *) inversion_clear der; assumption. (* Goal: P (@cons form b context) t c *) (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) apply ih_t. (* Goal: derives context t a *) inversion_clear der; assumption. (* Goal: forall (p : proof_term) (_ : forall (context : flist) (a : form) (_ : derives context p a), P context p a) (context : flist) (a : form) (_ : derives context (Shift p) a), P context (Shift p) a *) intros t ih context a. (* Goal: forall _ : derives context (Shift t) a, P context (Shift t) a *) case context; clear context. (* Goal: forall _ : derives (@nil form) (Shift t) a, P (@nil form) (Shift t) a *) (* Goal: forall (f : form) (l : list form) (_ : derives (@cons form f l) (Shift t) a), P (@cons form f l) (Shift t) a *) intros der; elimtype False; inversion_clear der. (* Goal: forall (f : form) (l : list form) (_ : derives (@cons form f l) (Shift t) a), P (@cons form f l) (Shift t) a *) intros b context der. (* Goal: P (@cons form b context) (Shift t) a *) apply shift. (* Goal: derives context t a *) inversion_clear der; assumption. (* Goal: P context t a *) apply ih. (* Goal: derives context t a *) inversion_clear der; assumption. Qed.
(* File: Derivable.v (last edited on 1/1/2000) (c) Klaus Weich *) Require Export Derivable_Def. Lemma derivable_eq : forall (context context' : flist) (a a' : form), context = context' -> a = a' -> Derivable context a -> Derivable context' a'. (* Goal: forall (context context' : flist) (a a' : form) (_ : @eq flist context context') (_ : @eq form a a') (_ : Derivable context a), Derivable context' a' *) intros context context' a a' eq_context eq_a. (* Goal: @eq flist (@cons form a context) (@app form (@cons form a l1) (@cons form c l2)) *) (* Goal: Derivable fnil c *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b)) (_ : derives context s a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (_ : derives context s b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) rewrite eq_context. (* Goal: forall _ : Derivable context' a, Derivable context' a' *) rewrite eq_a. (* Goal: forall (_ : @eq (list form) context (@app form l1 (@cons form c l2))) (_ : @eq form a d), @eq flist context (@app form l1 (@cons form c l2)) *) intros; assumption. Qed. Lemma derivable_subst : forall (i : Int) (g : form) (context : flist) (a : form), Derivable context a -> Derivable (subst_list i g context) (subst_form i g a). (* Goal: forall (i : Int) (g : form) (context : flist) (a : form) (_ : Derivable context a), Derivable (subst_list i g context) (subst_form i g a) *) intros i g context a der. (* Goal: Derivable context (Imp a b) *) elim der; clear der. (* Goal: forall (t : proof_term) (_ : derives context t (Imp (AndF a0 a1) b)), Derivable context (Imp a0 (Imp a1 b)) *) intros t der. (* Goal: Derivable (subst_list i g context) (subst_form i g a) *) elim der; clear der a t context. (* Goal: forall (context : flist) (n : nat) (a : form) (_ : my_nth form n context a), Derivable (subst_list i g context) (subst_form i g a) *) (* Goal: forall (context : flist) (t : proof_term) (a : form) (_ : derives context t Falsum) (_ : Derivable (subst_list i g context) (subst_form i g Falsum)), Derivable (subst_list i g context) (subst_form i g a) *) (* Goal: forall (context : flist) (a : form) (r : proof_term) (b : form) (_ : derives (@cons form a context) r b) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (Imp a b)) *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : Derivable (subst_list i g context) (subst_form i g (Imp a b))) (_ : derives context s a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g b) *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)) (_ : derives context s b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (AndF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *) intros context n a nth. (* Goal: Derivable (@app form l1 l2) a *) (* Goal: forall (n' : nat) (_ : my_nth form n' (@cons form b l2) a) (_ : Derivable fnil b), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (t : proof_term) (a : form) (_ : derives context t Falsum) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) Falsum) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (a : form) (r : proof_term) (b : form) (_ : derives (@cons form a context) r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b) *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b)) (_ : derives context s a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (_ : derives context s b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) apply Derivable_Intro with (Var n). (* Goal: derives (@cons form (Atom i) context') (Var O) (Atom i) *) apply ByAssumption. (* Goal: my_nth form n (subst_list i g context) (subst_form i g a) *) (* Goal: forall (context : flist) (t : proof_term) (a : form) (_ : derives context t Falsum) (_ : Derivable (subst_list i g context) (subst_form i g Falsum)), Derivable (subst_list i g context) (subst_form i g a) *) (* Goal: forall (context : flist) (a : form) (r : proof_term) (b : form) (_ : derives (@cons form a context) r b) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (Imp a b)) *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : Derivable (subst_list i g context) (subst_form i g (Imp a b))) (_ : derives context s a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g b) *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)) (_ : derives context s b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (AndF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *) apply subst_nth; assumption. (* Goal: forall (context : flist) (t : proof_term) (a : form) (_ : derives context t Falsum) (_ : Derivable (subst_list i g context) (subst_form i g Falsum)), Derivable (subst_list i g context) (subst_form i g a) *) (* Goal: forall (context : flist) (a : form) (r : proof_term) (b : form) (_ : derives (@cons form a context) r b) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (Imp a b)) *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : Derivable (subst_list i g context) (subst_form i g (Imp a b))) (_ : derives context s a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g b) *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)) (_ : derives context s b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (AndF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *) intros context t a der ih. (* Goal: Derivable (subst_list i g context) (subst_form i g (Imp a b)) *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : Derivable (subst_list i g context) (subst_form i g (Imp a b))) (_ : derives context s a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g b) *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)) (_ : derives context s b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (AndF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *) elim ih; clear ih. (* Goal: forall (t : proof_term) (_ : derives (subst_list i g (@cons form a context)) t (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (Imp a b)) *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : Derivable (subst_list i g context) (subst_form i g (Imp a b))) (_ : derives context s a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g b) *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)) (_ : derives context s b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (AndF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *) intros t1 der1. (* Goal: Derivable (subst_list i g context) (subst_form i g a) *) (* Goal: forall (context : flist) (a : form) (r : proof_term) (b : form) (_ : derives (@cons form a context) r b) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (Imp a b)) *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : Derivable (subst_list i g context) (subst_form i g (Imp a b))) (_ : derives context s a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g b) *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)) (_ : derives context s b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (AndF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *) apply Derivable_Intro with (Efq t1 (subst_form i g a)). (* Goal: derives (@app form l1 l2) (Efq t0 a) a *) (* Goal: forall (context : flist) (a : form) (r : proof_term) (b : form) (_ : derives (@cons form a context) r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b) *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b)) (_ : derives context s a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (_ : derives context s b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) apply ByAbsurdity; assumption. (* Goal: forall (context : flist) (a : form) (r : proof_term) (b : form) (_ : derives (@cons form a context) r b) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (Imp a b)) *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : Derivable (subst_list i g context) (subst_form i g (Imp a b))) (_ : derives context s a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g b) *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)) (_ : derives context s b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (AndF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *) intros context a t b der ih. (* Goal: Derivable (subst_list i g context) (subst_form i g (Imp a b)) *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : Derivable (subst_list i g context) (subst_form i g (Imp a b))) (_ : derives context s a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g b) *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)) (_ : derives context s b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (AndF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *) elim ih; clear ih. (* Goal: forall (t : proof_term) (_ : derives (subst_list i g (@cons form a context)) t (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (Imp a b)) *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : Derivable (subst_list i g context) (subst_form i g (Imp a b))) (_ : derives context s a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g b) *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)) (_ : derives context s b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (AndF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *) intros t1 der1. (* Goal: Derivable (subst_list i g context) (subst_form i g (Imp a b)) *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : Derivable (subst_list i g context) (subst_form i g (Imp a b))) (_ : derives context s a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g b) *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)) (_ : derives context s b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (AndF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *) apply Derivable_Intro with (Abs (subst_form i g a) t1). (* Goal: @eq form (subst_form i b (Atom i)) b *) simpl in |- *. (* Goal: derives context' (Abs (Atom i) t) (Imp (Atom i) a) *) apply ImpIntro; assumption. (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)) (_ : derives context s b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (AndF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *) intros context r s a b der_r ih_r der_s ih_s. (* Goal: Derivable (subst_list i g context) (subst_form i g (AndF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *) elim ih_r; clear ih_r. (* Goal: forall (t : proof_term) (_ : derives (subst_list i g context) t (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (AndF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *) intros r1 der_r1. (* Goal: Derivable (subst_list i g context) (subst_form i g (AndF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *) elim ih_s; clear ih_s. (* Goal: forall (t : proof_term) (_ : derives (subst_list i g context) t (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (AndF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *) intros s1 der_s1. (* Goal: Derivable (subst_list i g context) (subst_form i g b) *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)) (_ : derives context s b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (AndF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *) apply Derivable_Intro with (App (subst_form i g a) r1 s1). (* Goal: derives context (App a s t) b *) apply ImpElim; assumption. (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)) (_ : derives context s b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (AndF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *) intros context r s a b der_r ih_r der_s ih_s. (* Goal: Derivable (subst_list i g context) (subst_form i g (AndF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *) elim ih_r; clear ih_r. (* Goal: forall (t : proof_term) (_ : derives (subst_list i g context) t (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (AndF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *) intros r1 der_r1. (* Goal: Derivable (subst_list i g context) (subst_form i g (AndF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *) elim ih_s; clear ih_s. (* Goal: forall (t : proof_term) (_ : derives (subst_list i g context) t (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (AndF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *) intros s1 der_s1. (* Goal: Derivable (subst_list i g context) (subst_form i g (AndF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *) apply Derivable_Intro with (Pair r1 s1). (* Goal: derives (subst_list i g context) (Pair r1 s1) (subst_form i g (AndF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *) simpl in |- *; apply AndFIntro; assumption. (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *) intros context r a b der_r ih. (* Goal: forall (t : proof_term) (_ : derives (subst_list i g context) t (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (AndF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *) elim ih; clear ih; intros r1 der_r1. (* Goal: Derivable (subst_list i g context) (subst_form i g a) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *) apply Derivable_Intro with (PrL (subst_form i g b) r1). (* Goal: derives context (PrL b t) a *) apply AndFElimL; assumption. (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *) intros context r a b der_r ih. (* Goal: forall (t : proof_term) (_ : derives (subst_list i g context) t (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (AndF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *) elim ih; clear ih; intros r1 der_r1. (* Goal: Derivable (subst_list i g context) (subst_form i g b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *) apply Derivable_Intro with (PrR (subst_form i g a) r1). (* Goal: derives context (PrR a t) b *) apply AndFElimR; assumption. (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *) intros context r a b der_r ih. (* Goal: forall (t : proof_term) (_ : derives (subst_list i g context) t (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (AndF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *) elim ih; clear ih; intros r1 der_r1. (* Goal: Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *) apply Derivable_Intro with (OrFL r1 (subst_form i g b)). (* Goal: derives (subst_list i g context) (OrFL r1 (subst_form i g b)) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *) simpl in |- *; apply OrFIntroL; assumption. (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *) intros context r a b der_r ih. (* Goal: forall (t : proof_term) (_ : derives (subst_list i g context) t (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (AndF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *) elim ih; clear ih; intros r1 der_r1. (* Goal: Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *) apply Derivable_Intro with (OrFR r1 (subst_form i g a)). (* Goal: derives (subst_list i g context) (OrFR r1 (subst_form i g a)) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *) simpl in |- *; apply OrFIntroR; assumption. (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *) intros context r s t a b c der_r ih_r der_s ih_s der_t ih_t. (* Goal: forall (t : proof_term) (_ : derives (subst_list i g context) t (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (AndF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *) elim ih_r; clear ih_r; intros r1 der_r1. (* Goal: forall (t : proof_term) (_ : derives (subst_list i g context) t (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (AndF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *) elim ih_s; clear ih_s; intros s1 der_s1. (* Goal: Derivable (subst_list i g context) (subst_form i g c) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *) elim ih_t; clear ih_t; intros t1 der_t1. apply Derivable_Intro with (Cas (subst_form i g a) (subst_form i g b) r1 s1 t1). (* Goal: derives (@app form l1 l2) (Cas a b r0 s0 t0) c *) (* Goal: @eq flist (@cons form b context) (@app form (@cons form b l1) (@cons form d l2)) *) (* Goal: Derivable fnil d *) (* Goal: @eq flist (@cons form a context) (@app form (@cons form a l1) (@cons form d l2)) *) (* Goal: Derivable fnil d *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) apply OrFElim; assumption. (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *) intros context r a b der_r ih_r. (* Goal: forall (t : proof_term) (_ : derives (subst_list i g context) t (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (AndF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *) elim ih_r; clear ih_r; intros r1 der_r1. (* Goal: Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *) apply Derivable_Intro with (Shift r1). (* Goal: derives (subst_list i g (@cons form a context)) (Shift r1) (subst_form i g b) *) simpl in |- *; apply ShiftIntro; assumption. Qed. Lemma snd_order_inst : forall (context : flist) (i : Int), Derivable context (Atom i) -> below_list context i -> forall b : form, Derivable context b. (* Goal: forall (context : flist) (i : Int) (_ : Derivable context (Atom i)) (_ : below_list context i) (b : form), Derivable context b *) intros context i der below b. (* Goal: Derivable context b *) cut (subst_form i b (Atom i) = b). (* Goal: forall _ : @eq form (subst_form i b (Atom i)) b, Derivable context b *) (* Goal: @eq form (subst_form i b (Atom i)) b *) intro eq_b. (* Goal: Derivable context b *) (* Goal: @eq form (subst_form i b (Atom i)) b *) rewrite <- eq_b. (* Goal: Derivable context (subst_form i b (Atom i)) *) (* Goal: @eq form (subst_form i b (Atom i)) b *) rewrite <- (subst_list_below i b context). (* Goal: Derivable (subst_list i b context) (subst_form i b (Atom i)) *) (* Goal: below_list context i *) (* Goal: @eq form (subst_form i b (Atom i)) b *) apply derivable_subst; assumption. (* Goal: derives context t (Imp (Imp Falsum b) c) *) (* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *) assumption. (* Goal: @eq form (subst_form i b (Atom i)) b *) simpl in |- *. (* Goal: @eq form (if equal_dec i i then b else Atom i) b *) apply equal_dec_refl. Qed. Lemma derivable_weak : forall (context : flist) (a b : form), Derivable context a -> Derivable (b :: context) a. (* Goal: forall (context : flist) (a b : form) (_ : Derivable context a), Derivable (@cons form b context) a *) intros context a b der_a. (* Goal: Derivable context b *) elim der_a; clear der_a. (* Goal: forall (t : proof_term) (_ : derives (@cons form a context) t b), Derivable context (Imp a b) *) intros t der_t. (* Goal: Derivable (@cons form b context) a *) apply Derivable_Intro with (Shift t). (* Goal: derives context t (Imp (Imp Falsum b) c) *) (* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *) apply ShiftIntro; assumption. Qed. Lemma derivable_weak_list : forall (context1 context2 : flist) (a : form), Derivable context1 a -> Derivable (context2 ++ context1) a. (* Goal: forall (context1 context2 : flist) (a : form) (_ : Derivable context1 a), Derivable (@app form context2 context1) a *) intros context1 context2 a der1. (* Goal: Derivable (@app form context2 context1) a *) elim context2; clear context2. (* Goal: derives context t (Imp (Imp Falsum b) c) *) (* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *) assumption. (* Goal: forall (a0 : form) (l : list form) (_ : Derivable (@app form l context1) a), Derivable (@app form (@cons form a0 l) context1) a *) intros b context2 ih. (* Goal: derives context t (Imp (Imp Falsum b) c) *) (* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *) simpl in |- *; apply derivable_weak; assumption. Qed. Lemma derivable_cut_aux : forall (context : flist) (t : proof_term) (b : form), derives context t b -> forall (a : form) (l1 l2 : flist), context = l1 ++ a :: l2 -> Derivable fnil a -> Derivable (l1 ++ l2) b. (* Goal: forall (context : flist) (t : proof_term) (b : form) (_ : derives context t b) (a : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a l2))) (_ : Derivable fnil a), Derivable (@app form l1 l2) b *) intros context t b der_t. (* Goal: forall (a : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a l2))) (_ : Derivable fnil a), Derivable (@app form l1 l2) b *) elim der_t; clear der_t context t b. (* Goal: forall (context : flist) (n : nat) (a : form) (_ : my_nth form n context a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (t : proof_term) (a : form) (_ : derives context t Falsum) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) Falsum) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (a : form) (r : proof_term) (b : form) (_ : derives (@cons form a context) r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b) *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b)) (_ : derives context s a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (_ : derives context s b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) intros context n a nth b l1 l2 eq_context. (* Goal: forall _ : Derivable fnil b, Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (t : proof_term) (a : form) (_ : derives context t Falsum) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) Falsum) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (a : form) (r : proof_term) (b : form) (_ : derives (@cons form a context) r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b) *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b)) (_ : derives context s a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (_ : derives context s b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) rewrite eq_context in nth. (* Goal: forall _ : Derivable fnil b, Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (t : proof_term) (a : form) (_ : derives context t Falsum) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) Falsum) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (a : form) (r : proof_term) (b : form) (_ : derives (@cons form a context) r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b) *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b)) (_ : derives context s a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (_ : derives context s b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) elim (inv_nth_app form n l1 (b :: l2) a nth); clear nth. (* Goal: forall (_ : my_nth form n l1 a) (_ : Derivable fnil b), Derivable (@app form l1 l2) a *) (* Goal: forall (n' : nat) (_ : my_nth form n' (@cons form b l2) a) (_ : Derivable fnil b), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (t : proof_term) (a : form) (_ : derives context t Falsum) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) Falsum) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (a : form) (r : proof_term) (b : form) (_ : derives (@cons form a context) r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b) *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b)) (_ : derives context s a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (_ : derives context s b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) intros nth0 der_b. (* Goal: Derivable (@app form l1 l2) a *) (* Goal: forall (n' : nat) (_ : my_nth form n' (@cons form b l2) a) (_ : Derivable fnil b), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (t : proof_term) (a : form) (_ : derives context t Falsum) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) Falsum) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (a : form) (r : proof_term) (b : form) (_ : derives (@cons form a context) r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b) *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b)) (_ : derives context s a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (_ : derives context s b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) apply Derivable_Intro with (Var n). (* Goal: derives (@cons form (Atom i) context') (Var O) (Atom i) *) apply ByAssumption. (* Goal: derives context t (Imp (Imp Falsum b) c) *) (* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *) apply nth_app0; assumption. (* Goal: forall (n' : nat) (_ : my_nth form n' (@cons form b l2) a) (_ : Derivable fnil b), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (t : proof_term) (a : form) (_ : derives context t Falsum) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) Falsum) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (a : form) (r : proof_term) (b : form) (_ : derives (@cons form a context) r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b) *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b)) (_ : derives context s a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (_ : derives context s b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) clear n; intros n; case n; clear n. (* Goal: forall (_ : my_nth form O (@cons form b l2) a) (_ : Derivable fnil b), Derivable (@app form l1 l2) a *) (* Goal: forall (n : nat) (_ : my_nth form (S n) (@cons form b l2) a) (_ : Derivable fnil b), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (t : proof_term) (a : form) (_ : derives context t Falsum) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) Falsum) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (a : form) (r : proof_term) (b : form) (_ : derives (@cons form a context) r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b) *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b)) (_ : derives context s a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (_ : derives context s b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) intros nth_eq. (* Goal: forall _ : Derivable fnil b, Derivable (@app form l1 l2) a *) (* Goal: forall (n : nat) (_ : my_nth form (S n) (@cons form b l2) a) (_ : Derivable fnil b), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (t : proof_term) (a : form) (_ : derives context t Falsum) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) Falsum) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (a : form) (r : proof_term) (b : form) (_ : derives (@cons form a context) r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b) *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b)) (_ : derives context s a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (_ : derives context s b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) rewrite (inv_nthO form b l2 a nth_eq). (* Goal: forall _ : Derivable fnil a, Derivable (@app form l1 l2) a *) (* Goal: forall (n : nat) (_ : my_nth form (S n) (@cons form b l2) a) (_ : Derivable fnil b), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (t : proof_term) (a : form) (_ : derives context t Falsum) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) Falsum) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (a : form) (r : proof_term) (b : form) (_ : derives (@cons form a context) r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b) *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b)) (_ : derives context s a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (_ : derives context s b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) intros der_a. (* Goal: Derivable (@app form l1 l2) a *) (* Goal: forall (n : nat) (_ : my_nth form (S n) (@cons form b l2) a) (_ : Derivable fnil b), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (t : proof_term) (a : form) (_ : derives context t Falsum) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) Falsum) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (a : form) (r : proof_term) (b : form) (_ : derives (@cons form a context) r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b) *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b)) (_ : derives context s a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (_ : derives context s b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) rewrite (app_nil_end (l1 ++ l2)). (* Goal: Derivable (@app form (@app form l1 l2) (@nil form)) a *) (* Goal: forall (n : nat) (_ : my_nth form (S n) (@cons form b l2) a) (_ : Derivable fnil b), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (t : proof_term) (a : form) (_ : derives context t Falsum) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) Falsum) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (a : form) (r : proof_term) (b : form) (_ : derives (@cons form a context) r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b) *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b)) (_ : derives context s a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (_ : derives context s b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) apply derivable_weak_list. (* Goal: derives context t (Imp (Imp Falsum b) c) *) (* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *) assumption. (* Goal: forall (n : nat) (_ : my_nth form (S n) (@cons form b l2) a) (_ : Derivable fnil b), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (t : proof_term) (a : form) (_ : derives context t Falsum) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) Falsum) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (a : form) (r : proof_term) (b : form) (_ : derives (@cons form a context) r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b) *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b)) (_ : derives context s a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (_ : derives context s b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) intros n nth1 der_b. (* Goal: Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (t : proof_term) (a : form) (_ : derives context t Falsum) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) Falsum) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (a : form) (r : proof_term) (b : form) (_ : derives (@cons form a context) r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b) *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b)) (_ : derives context s a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (_ : derives context s b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) apply Derivable_Intro with (Var (length l1 + n)). (* Goal: derives (@cons form (Atom i) context') (Var O) (Atom i) *) apply ByAssumption. (* Goal: my_nth form (Nat.add (@length form l1) n) (@app form l1 l2) a *) (* Goal: forall (context : flist) (t : proof_term) (a : form) (_ : derives context t Falsum) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) Falsum) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (a : form) (r : proof_term) (b : form) (_ : derives (@cons form a context) r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b) *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b)) (_ : derives context s a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (_ : derives context s b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) apply nth_app1. (* Goal: derives context t (Imp (Imp Falsum b) c) *) (* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *) inversion_clear nth1; assumption. (* Goal: forall (context : flist) (t : proof_term) (a : form) (_ : derives context t Falsum) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) Falsum) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (a : form) (r : proof_term) (b : form) (_ : derives (@cons form a context) r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b) *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b)) (_ : derives context s a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (_ : derives context s b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) intros context t a der_t ih b l1 l2 eq_context der_b. (* Goal: derives context t (Imp (Imp Falsum b) c) *) (* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *) elim (ih b l1 l2); try assumption. (* Goal: forall (t : proof_term) (_ : derives (@app form (@cons form b l1) l2) t c), Derivable (@app form l1 l2) c *) (* Goal: @eq flist (@cons form b context) (@app form (@cons form b l1) (@cons form d l2)) *) (* Goal: Derivable fnil d *) (* Goal: @eq flist (@cons form a context) (@app form (@cons form a l1) (@cons form d l2)) *) (* Goal: Derivable fnil d *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) intros t0 der_t0. (* Goal: Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (a : form) (r : proof_term) (b : form) (_ : derives (@cons form a context) r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b) *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b)) (_ : derives context s a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (_ : derives context s b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) apply Derivable_Intro with (Efq t0 a). (* Goal: derives (@app form l1 l2) (Efq t0 a) a *) (* Goal: forall (context : flist) (a : form) (r : proof_term) (b : form) (_ : derives (@cons form a context) r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b) *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b)) (_ : derives context s a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (_ : derives context s b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) apply ByAbsurdity; assumption. (* Goal: forall (context : flist) (a : form) (r : proof_term) (b : form) (_ : derives (@cons form a context) r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b) *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b)) (_ : derives context s a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (_ : derives context s b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) intros context a t b der_t ih c l1 l2 eq_context der_c. (* Goal: Derivable (@app form l1 l2) (Imp a b) *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b)) (_ : derives context s a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (_ : derives context s b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) elim (ih c (a :: l1) l2); clear ih. (* Goal: forall (t : proof_term) (_ : derives (@app form (@cons form b l1) l2) t c), Derivable (@app form l1 l2) c *) (* Goal: @eq flist (@cons form b context) (@app form (@cons form b l1) (@cons form d l2)) *) (* Goal: Derivable fnil d *) (* Goal: @eq flist (@cons form a context) (@app form (@cons form a l1) (@cons form d l2)) *) (* Goal: Derivable fnil d *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) intros t0 der_t0. (* Goal: Derivable (@app form l1 l2) (Imp a b) *) (* Goal: @eq flist (@cons form a context) (@app form (@cons form a l1) (@cons form c l2)) *) (* Goal: Derivable fnil c *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b)) (_ : derives context s a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (_ : derives context s b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) apply Derivable_Intro with (Abs a t0). (* Goal: derives context' (Abs (Atom i) t) (Imp (Atom i) a) *) apply ImpIntro; assumption. (* Goal: @eq flist (@cons form a context) (@app form (@cons form a l1) (@cons form c l2)) *) (* Goal: Derivable fnil c *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b)) (_ : derives context s a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (_ : derives context s b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) rewrite eq_context. (* Goal: @eq flist (@cons form a context) (@app form fnil (@cons form a context)) *) (* Goal: Derivable fnil a *) trivial. (* Goal: derives context t (Imp (Imp Falsum b) c) *) (* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *) assumption. (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (_ : derives context s b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) intros context r s a b der_r ih_r der_s ih_s c l1 l2 eq_context der_c. (* Goal: derives context t (Imp (Imp Falsum b) c) *) (* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *) elim (ih_r c l1 l2); clear ih_r; try assumption. (* Goal: forall (t : proof_term) (_ : derives (@app form l1 l2) t b), Derivable (@cons form d (@app form l1 l2)) b *) (* Goal: @eq flist context (@app form l1 (@cons form c l2)) *) intros r0 der_r0. (* Goal: derives context t (Imp (Imp Falsum b) c) *) (* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *) elim (ih_s c l1 l2); clear ih_s; try assumption. (* Goal: forall (t : proof_term) (_ : derives (@app form (@cons form a l1) l2) t c), Derivable (@app form l1 l2) c *) (* Goal: @eq flist (@cons form a context) (@app form (@cons form a l1) (@cons form d l2)) *) (* Goal: Derivable fnil d *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) intros s0 der_s0. (* Goal: Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (_ : derives context s b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) apply Derivable_Intro with (App a r0 s0). (* Goal: derives context (App a s t) b *) apply ImpElim; assumption. (* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (_ : derives context s b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) intros context r s a b der_r ih_r der_s ih_s c l1 l2 eq_context der_c. (* Goal: derives context t (Imp (Imp Falsum b) c) *) (* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *) elim (ih_r c l1 l2); clear ih_r; try assumption. (* Goal: forall (t : proof_term) (_ : derives (@app form l1 l2) t b), Derivable (@cons form d (@app form l1 l2)) b *) (* Goal: @eq flist context (@app form l1 (@cons form c l2)) *) intros r0 der_r0. (* Goal: derives context t (Imp (Imp Falsum b) c) *) (* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *) elim (ih_s c l1 l2); clear ih_s; try assumption. (* Goal: forall (t : proof_term) (_ : derives (@app form (@cons form a l1) l2) t c), Derivable (@app form l1 l2) c *) (* Goal: @eq flist (@cons form a context) (@app form (@cons form a l1) (@cons form d l2)) *) (* Goal: Derivable fnil d *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) intros s0 der_s0. (* Goal: Derivable (@app form l1 l2) (AndF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) apply Derivable_Intro with (Pair r0 s0). (* Goal: derives context t (Imp (Imp Falsum b) c) *) (* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *) apply AndFIntro; assumption. (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) intros context r a b der_r ih_r c l1 l2 eq_context der_c. (* Goal: derives context t (Imp (Imp Falsum b) c) *) (* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *) elim (ih_r c l1 l2); clear ih_r; try assumption. (* Goal: forall (t : proof_term) (_ : derives (@app form l1 l2) t b), Derivable (@cons form d (@app form l1 l2)) b *) (* Goal: @eq flist context (@app form l1 (@cons form c l2)) *) intros r0 der_r0. (* Goal: Derivable (@app form l1 l2) a *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) apply Derivable_Intro with (PrL b r0). (* Goal: derives context (PrL b t) a *) apply AndFElimL; assumption. (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) intros context r a b der_r ih_r c l1 l2 eq_context der_c. (* Goal: derives context t (Imp (Imp Falsum b) c) *) (* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *) elim (ih_r c l1 l2); clear ih_r; try assumption. (* Goal: forall (t : proof_term) (_ : derives (@app form l1 l2) t b), Derivable (@cons form d (@app form l1 l2)) b *) (* Goal: @eq flist context (@app form l1 (@cons form c l2)) *) intros r0 der_r0. (* Goal: Derivable (@app form l1 l2) b *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) apply Derivable_Intro with (PrR a r0). (* Goal: derives context (PrR a t) b *) apply AndFElimR; assumption. (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) intros context r a b der_r ih_r c l1 l2 eq_context der_c. (* Goal: derives context t (Imp (Imp Falsum b) c) *) (* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *) elim (ih_r c l1 l2); clear ih_r; try assumption. (* Goal: forall (t : proof_term) (_ : derives (@app form l1 l2) t b), Derivable (@cons form d (@app form l1 l2)) b *) (* Goal: @eq flist context (@app form l1 (@cons form c l2)) *) intros r0 der_r0. (* Goal: Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) apply Derivable_Intro with (OrFL r0 b). (* Goal: derives context t (Imp (Imp Falsum b) c) *) (* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *) apply OrFIntroL; assumption. (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) intros context r a b der_r ih_r c l1 l2 eq_context der_c. (* Goal: derives context t (Imp (Imp Falsum b) c) *) (* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *) elim (ih_r c l1 l2); clear ih_r; try assumption. (* Goal: forall (t : proof_term) (_ : derives (@app form l1 l2) t b), Derivable (@cons form d (@app form l1 l2)) b *) (* Goal: @eq flist context (@app form l1 (@cons form c l2)) *) intros r0 der_r0. (* Goal: Derivable (@app form l1 l2) (OrF a b) *) (* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) apply Derivable_Intro with (OrFR r0 a). (* Goal: derives context t (Imp (Imp Falsum b) c) *) (* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *) apply OrFIntroR; assumption. intros context r s t a b c der_r ih_r der_s ih_s der_t ih_t d l1 l2 eq_context der_d; clear der_r der_s der_t. (* Goal: Derivable (@app form l1 l2) c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) elim (ih_r d l1 l2); try assumption; clear ih_r. (* Goal: forall (t : proof_term) (_ : derives (@app form l1 l2) t b), Derivable (@cons form d (@app form l1 l2)) b *) (* Goal: @eq flist context (@app form l1 (@cons form c l2)) *) intros r0 der_r0. (* Goal: Derivable (@app form l1 l2) c *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) elim (ih_s d (a :: l1) l2); clear ih_s. (* Goal: forall (t : proof_term) (_ : derives (@app form (@cons form a l1) l2) t c), Derivable (@app form l1 l2) c *) (* Goal: @eq flist (@cons form a context) (@app form (@cons form a l1) (@cons form d l2)) *) (* Goal: Derivable fnil d *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) intros s0 der_s0. (* Goal: Derivable (@app form l1 l2) c *) (* Goal: @eq flist (@cons form a context) (@app form (@cons form a l1) (@cons form d l2)) *) (* Goal: Derivable fnil d *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) elim (ih_t d (b :: l1) l2); clear ih_t. (* Goal: forall (t : proof_term) (_ : derives (@app form (@cons form b l1) l2) t c), Derivable (@app form l1 l2) c *) (* Goal: @eq flist (@cons form b context) (@app form (@cons form b l1) (@cons form d l2)) *) (* Goal: Derivable fnil d *) (* Goal: @eq flist (@cons form a context) (@app form (@cons form a l1) (@cons form d l2)) *) (* Goal: Derivable fnil d *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) intros t0 der_t0. (* Goal: Derivable (@app form l1 l2) c *) (* Goal: @eq flist (@cons form b context) (@app form (@cons form b l1) (@cons form d l2)) *) (* Goal: Derivable fnil d *) (* Goal: @eq flist (@cons form a context) (@app form (@cons form a l1) (@cons form d l2)) *) (* Goal: Derivable fnil d *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) apply Derivable_Intro with (Cas a b r0 s0 t0). (* Goal: derives (@app form l1 l2) (Cas a b r0 s0 t0) c *) (* Goal: @eq flist (@cons form b context) (@app form (@cons form b l1) (@cons form d l2)) *) (* Goal: Derivable fnil d *) (* Goal: @eq flist (@cons form a context) (@app form (@cons form a l1) (@cons form d l2)) *) (* Goal: Derivable fnil d *) (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) apply OrFElim; assumption. (* Goal: @eq flist (@cons form a context) (@app form fnil (@cons form a context)) *) (* Goal: Derivable fnil a *) rewrite eq_context; trivial. (* Goal: derives context t (Imp (Imp Falsum b) c) *) (* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *) assumption. (* Goal: @eq flist (@cons form a context) (@app form fnil (@cons form a context)) *) (* Goal: Derivable fnil a *) rewrite eq_context; trivial. (* Goal: derives context t (Imp (Imp Falsum b) c) *) (* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *) assumption. (* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *) intros context r a b der_r ih_r c l1. (* Goal: forall (l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form c l2))) (_ : Derivable fnil c), Derivable (@app form l1 l2) b *) case l1; clear l1. (* Goal: forall (l2 : flist) (_ : @eq flist (@cons form a context) (@app form (@nil form) (@cons form c l2))) (_ : Derivable fnil c), Derivable (@app form (@nil form) l2) b *) (* Goal: forall (f : form) (l : list form) (l2 : flist) (_ : @eq flist (@cons form a context) (@app form (@cons form f l) (@cons form c l2))) (_ : Derivable fnil c), Derivable (@app form (@cons form f l) l2) b *) simpl in |- *; intros l2 eq_context der_c. (* Goal: Derivable l2 b *) (* Goal: forall (f : form) (l : list form) (l2 : flist) (_ : @eq flist (@cons form a context) (@app form (@cons form f l) (@cons form c l2))) (_ : Derivable fnil c), Derivable (@app form (@cons form f l) l2) b *) apply Derivable_Intro with r. (* Goal: derives l2 r b *) (* Goal: forall (f : form) (l : list form) (l2 : flist) (_ : @eq flist (@cons form a context) (@app form (@cons form f l) (@cons form c l2))) (_ : Derivable fnil c), Derivable (@app form (@cons form f l) l2) b *) injection eq_context; intros H1 H2. (* Goal: derives context t (Imp (Imp Falsum b) c) *) (* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *) rewrite <- H1; assumption. (* Goal: forall (f : form) (l : list form) (l2 : flist) (_ : @eq flist (@cons form a context) (@app form (@cons form f l) (@cons form c l2))) (_ : Derivable fnil c), Derivable (@app form (@cons form f l) l2) b *) simpl in |- *; intros d l1 l2 eq_context der_c. (* Goal: derives context t (Imp (Imp Falsum b) c) *) (* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *) elim (ih_r c l1 l2); clear ih_r; try assumption. (* Goal: forall (t : proof_term) (_ : derives (@app form l1 l2) t b), Derivable (@cons form d (@app form l1 l2)) b *) (* Goal: @eq flist context (@app form l1 (@cons form c l2)) *) intros r0 der_r0. (* Goal: Derivable (@cons form d (@app form l1 l2)) b *) (* Goal: @eq flist context (@app form l1 (@cons form c l2)) *) apply derivable_weak. (* Goal: derives context t (Imp (Imp Falsum b) c) *) (* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *) apply Derivable_Intro with r0; assumption. (* Goal: @eq flist context (@app form l1 (@cons form c l2)) *) injection eq_context. (* Goal: forall (_ : @eq (list form) context (@app form l1 (@cons form c l2))) (_ : @eq form a d), @eq flist context (@app form l1 (@cons form c l2)) *) intros; assumption. Qed. Lemma derivable_cut : forall (context : flist) (a b : form), Derivable fnil a -> Derivable (a :: context) b -> Derivable context b. (* Goal: forall (context : flist) (a b : form) (_ : Derivable fnil a) (_ : Derivable (@cons form a context) b), Derivable context b *) intros context a b der_a der_b. (* Goal: Derivable context b *) elim der_b; clear der_b. (* Goal: forall (t : proof_term) (_ : derives (@cons form a context) t b), Derivable context b *) intros t der_b. (* Goal: Derivable context b *) apply (derivable_cut_aux (a :: context) t b der_b a fnil context). (* Goal: @eq flist (@cons form a context) (@app form fnil (@cons form a context)) *) (* Goal: Derivable fnil a *) trivial. (* Goal: derives context t (Imp (Imp Falsum b) c) *) (* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *) assumption. Qed. Lemma derivable_cut_merge : forall (context : flist) (a b : form), Derivable context a -> Derivable (a :: context) b -> Derivable context b. (* Goal: forall (context : flist) (a b : form) (_ : Derivable context a) (_ : Derivable (@cons form a context) b), Derivable context b *) intros context; elim context; clear context. (* Goal: derives context t (Imp (Imp Falsum b) c) *) (* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *) intros; apply derivable_cut with a; assumption. (* Goal: forall (a : form) (l : list form) (_ : forall (a0 b : form) (_ : Derivable l a0) (_ : Derivable (@cons form a0 l) b), Derivable l b) (a0 b : form) (_ : Derivable (@cons form a l) a0) (_ : Derivable (@cons form a0 (@cons form a l)) b), Derivable (@cons form a l) b *) intros c context ih a b der_a der_b. (* Goal: Derivable (@cons form c context) b *) elim (ih (Imp c a) (Imp c b)); clear ih. (* Goal: forall (t : proof_term) (_ : derives (@cons form a context) t b), Derivable context (Imp a b) *) intros t der_t. (* Goal: Derivable (@cons form c context) b *) (* Goal: Derivable context (Imp c a) *) (* Goal: Derivable (@cons form (Imp c a) context) (Imp c b) *) apply Derivable_Intro with (App c (Shift t) (Var 0)). (* Goal: derives (@cons form (Atom i) context') (App (Atom i) (Shift s) (Var O)) b *) apply ImpElim. (* Goal: derives context t (Imp (Imp Falsum b) c) *) (* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *) apply ShiftIntro; assumption. (* Goal: derives (@cons form (Atom i) context') (Var O) (Atom i) *) apply ByAssumption. (* Goal: my_nth form O (@cons form (Atom i) context') (Atom i) *) apply My_NthO. (* Goal: forall (t : proof_term) (_ : derives (@cons form a context) t b), Derivable context (Imp a b) *) elim der_a; clear der_a; intros t der_t. (* Goal: Derivable context (Imp c a) *) (* Goal: Derivable (@cons form (Imp c a) context) (Imp c b) *) apply Derivable_Intro with (Abs c t). (* Goal: derives context' (Abs (Atom i) t) (Imp (Atom i) a) *) apply ImpIntro; assumption. (* Goal: forall (t : proof_term) (_ : derives (@cons form a context) t b), Derivable context (Imp a b) *) elim der_b; clear der_b; intros t der_t. apply Derivable_Intro with (Abs c (App a (App c (Shift (Shift (Abs c (Abs a t)))) (Var 0)) (App c (Var 1) (Var 0)))). (* Goal: derives context (Abs a (Shift t)) (Imp a b) *) apply ImpIntro. (* Goal: derives (@cons form (Atom i) context') (App (Atom i) (Shift s) (Var O)) b *) apply ImpElim. (* Goal: derives (@cons form (Atom i) context') (App (Atom i) (Shift s) (Var O)) b *) apply ImpElim. (* Goal: derives (@cons form a0 context) (Shift t) (Imp (AndF a0 a1) b) *) (* Goal: derives (@cons form a1 (@cons form a0 context)) (Pair (Var (S O)) (Var O)) (AndF a0 a1) *) apply ShiftIntro. (* Goal: derives (@cons form a0 context) (Shift t) (Imp (AndF a0 a1) b) *) (* Goal: derives (@cons form a1 (@cons form a0 context)) (Pair (Var (S O)) (Var O)) (AndF a0 a1) *) apply ShiftIntro. (* Goal: derives context (Abs a (Shift t)) (Imp a b) *) apply ImpIntro. (* Goal: derives context (Abs a (Shift t)) (Imp a b) *) apply ImpIntro. (* Goal: derives context t (Imp (Imp Falsum b) c) *) (* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *) assumption. (* Goal: derives (@cons form (Atom i) context') (Var O) (Atom i) *) apply ByAssumption. (* Goal: my_nth form O (@cons form (Atom i) context') (Atom i) *) apply My_NthO. (* Goal: derives (@cons form (Atom i) context') (App (Atom i) (Shift s) (Var O)) b *) apply ImpElim. (* Goal: derives (@cons form (Atom i) context') (Var O) (Atom i) *) apply ByAssumption. (* Goal: my_nth form (S O) (@cons form c (@cons form (Imp c a) context)) (Imp c a) *) (* Goal: derives (@cons form c (@cons form (Imp c a) context)) (Var O) c *) apply My_NthS. (* Goal: my_nth form O (@cons form (Atom i) context') (Atom i) *) apply My_NthO. (* Goal: derives (@cons form (Atom i) context') (Var O) (Atom i) *) apply ByAssumption. (* Goal: my_nth form O (@cons form (Atom i) context') (Atom i) *) apply My_NthO. Qed. (************************************************************************) Lemma derivable_a_imp_a : forall a : form, Derivable fnil (Imp a a). (* Goal: forall a : form, Derivable fnil (Imp a a) *) intros a. (* Goal: Derivable fnil (Imp a a) *) apply Derivable_Intro with (Abs a (Var 0)). (* Goal: derives context (Abs a (Shift t)) (Imp a b) *) apply ImpIntro. (* Goal: derives (@cons form (Atom i) context') (Var O) (Atom i) *) apply ByAssumption. (* Goal: my_nth form O (@cons form (Atom i) context') (Atom i) *) apply My_NthO. Qed. Lemma derivable_a_and_b__derivable_a : forall (a b : form) (context : flist), Derivable context (AndF a b) -> Derivable context a. (* Goal: forall (a b : form) (context : flist) (_ : Derivable (@cons form a context) b), Derivable context (Imp a b) *) intros a b context der. (* Goal: Derivable context (Imp a b) *) elim der; clear der. (* Goal: forall (t : proof_term) (_ : derives (@cons form a context) t b), Derivable context (Imp a b) *) intros t der_t. (* Goal: Derivable context a *) apply Derivable_Intro with (PrL b t). (* Goal: derives context (PrL b t) a *) apply AndFElimL; assumption. Qed. Lemma derivable_a_and_b__derivable_b : forall (a b : form) (context : flist), Derivable context (AndF a b) -> Derivable context b. (* Goal: forall (a b : form) (context : flist) (_ : Derivable (@cons form a context) b), Derivable context (Imp a b) *) intros a b context der. (* Goal: Derivable context (Imp a b) *) elim der; clear der. (* Goal: forall (t : proof_term) (_ : derives (@cons form a context) t b), Derivable context (Imp a b) *) intros t der_t. (* Goal: Derivable context b *) apply Derivable_Intro with (PrR a t). (* Goal: derives context (PrR a t) b *) apply AndFElimR; assumption. Qed. Lemma derivable_falsum_or_a__derivable_a : forall (a : form) (context : flist), Derivable context (OrF Falsum a) -> Derivable context a. (* Goal: forall (a : form) (context : flist) (_ : Derivable context (OrF a Falsum)), Derivable context a *) intros a context der. (* Goal: Derivable context (Imp a b) *) elim der; clear der. (* Goal: forall (t : proof_term) (_ : derives (@cons form a context) t b), Derivable context (Imp a b) *) intros t der_t. (* Goal: Derivable context a *) apply Derivable_Intro with (Cas Falsum a t (Efq (Var 0) a) (Var 0)). (* Goal: derives (@cons form a context) (Cas b Falsum (App a (Shift t) (Var O)) (Var O) (Efq (Var O) b)) b *) apply OrFElim. (* Goal: derives context t (Imp (Imp Falsum b) c) *) (* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *) assumption. (* Goal: derives (@cons form Falsum context) (Efq (Var O) b) b *) apply ByAbsurdity. (* Goal: derives (@cons form (Atom i) context') (Var O) (Atom i) *) apply ByAssumption. (* Goal: my_nth form O (@cons form (Atom i) context') (Atom i) *) apply My_NthO. (* Goal: derives (@cons form (Atom i) context') (Var O) (Atom i) *) apply ByAssumption. (* Goal: my_nth form O (@cons form (Atom i) context') (Atom i) *) apply My_NthO. Qed. Lemma derivable_a_or_falsum__derivable_a : forall (a : form) (context : flist), Derivable context (OrF a Falsum) -> Derivable context a. (* Goal: forall (a : form) (context : flist) (_ : Derivable context (OrF a Falsum)), Derivable context a *) intros a context der. (* Goal: Derivable context (Imp a b) *) elim der; clear der. (* Goal: forall (t : proof_term) (_ : derives (@cons form a context) t b), Derivable context (Imp a b) *) intros t der_t. (* Goal: Derivable context a *) apply Derivable_Intro with (Cas a Falsum t (Var 0) (Efq (Var 0) a)). (* Goal: derives (@cons form a context) (Cas b Falsum (App a (Shift t) (Var O)) (Var O) (Efq (Var O) b)) b *) apply OrFElim. (* Goal: derives context t (Imp (Imp Falsum b) c) *) (* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *) assumption. (* Goal: derives (@cons form (Atom i) context') (Var O) (Atom i) *) apply ByAssumption. (* Goal: my_nth form O (@cons form (Atom i) context') (Atom i) *) apply My_NthO. (* Goal: derives (@cons form Falsum context) (Efq (Var O) b) b *) apply ByAbsurdity. (* Goal: derives (@cons form (Atom i) context') (Var O) (Atom i) *) apply ByAssumption. (* Goal: my_nth form O (@cons form (Atom i) context') (Atom i) *) apply My_NthO. Qed. Lemma derivable_a_imp_falsum_or_b__derivable_a_imp_b : forall (context : flist) (a b : form), Derivable context (Imp a (OrF Falsum b)) -> Derivable context (Imp a b). (* Goal: forall (context : flist) (a b : form) (_ : Derivable context (Imp a (OrF b Falsum))), Derivable context (Imp a b) *) intros context a b der. (* Goal: Derivable context (Imp a b) *) elim der; clear der. (* Goal: forall (t : proof_term) (_ : derives (@cons form a context) t b), Derivable context (Imp a b) *) intros t der_t. apply Derivable_Intro with (Abs a (Cas Falsum b (App a (Shift t) (Var 0)) (Efq (Var 0) b) (Var 0))). (* Goal: derives context (Abs a (Shift t)) (Imp a b) *) apply ImpIntro. (* Goal: derives (@cons form a context) (Cas b Falsum (App a (Shift t) (Var O)) (Var O) (Efq (Var O) b)) b *) apply OrFElim. (* Goal: derives (@cons form (Atom i) context') (App (Atom i) (Shift s) (Var O)) b *) apply ImpElim. (* Goal: derives context t (Imp (Imp Falsum b) c) *) (* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *) apply ShiftIntro; assumption. (* Goal: my_nth form O (@cons form (Atom i) context') (Atom i) *) apply ByAssumption; apply My_NthO. (* Goal: derives (@cons form Falsum context) (Efq (Var O) b) b *) apply ByAbsurdity. (* Goal: my_nth form O (@cons form (Atom i) context') (Atom i) *) apply ByAssumption; apply My_NthO. (* Goal: my_nth form O (@cons form (Atom i) context') (Atom i) *) apply ByAssumption; apply My_NthO. Qed. Lemma derivable_a_imp_b_or_falsum__derivable_a_imp_b : forall (context : flist) (a b : form), Derivable context (Imp a (OrF b Falsum)) -> Derivable context (Imp a b). (* Goal: forall (context : flist) (a b : form) (_ : Derivable context (Imp a (OrF b Falsum))), Derivable context (Imp a b) *) intros context a b der. (* Goal: Derivable context (Imp a b) *) elim der; clear der. (* Goal: forall (t : proof_term) (_ : derives (@cons form a context) t b), Derivable context (Imp a b) *) intros t der_t. apply Derivable_Intro with (Abs a (Cas b Falsum (App a (Shift t) (Var 0)) (Var 0) (Efq (Var 0) b))). (* Goal: derives context (Abs a (Shift t)) (Imp a b) *) apply ImpIntro. (* Goal: derives (@cons form a context) (Cas b Falsum (App a (Shift t) (Var O)) (Var O) (Efq (Var O) b)) b *) apply OrFElim. (* Goal: derives (@cons form (Atom i) context') (App (Atom i) (Shift s) (Var O)) b *) apply ImpElim. (* Goal: derives context t (Imp (Imp Falsum b) c) *) (* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *) apply ShiftIntro; assumption. (* Goal: my_nth form O (@cons form (Atom i) context') (Atom i) *) apply ByAssumption; apply My_NthO. (* Goal: my_nth form O (@cons form (Atom i) context') (Atom i) *) apply ByAssumption; apply My_NthO. (* Goal: derives (@cons form Falsum context) (Efq (Var O) b) b *) apply ByAbsurdity. (* Goal: my_nth form O (@cons form (Atom i) context') (Atom i) *) apply ByAssumption; apply My_NthO. Qed. Lemma derivable_a0_and_a1_imp_b__derivable_a0_imp_a1_imp_b : forall (a0 a1 b : form) (context : flist), Derivable context (Imp (AndF a0 a1) b) -> Derivable context (Imp a0 (Imp a1 b)). (* Goal: forall (a0 a1 b : form) (context : flist) (_ : Derivable context (Imp (AndF a0 a1) b)), Derivable context (Imp a0 (Imp a1 b)) *) intros a0 a1 b context der. (* Goal: Derivable context (Imp a b) *) elim der; clear der. (* Goal: forall (t : proof_term) (_ : derives context t (Imp (AndF a0 a1) b)), Derivable context (Imp a0 (Imp a1 b)) *) intros t der. apply Derivable_Intro with (Abs a0 (Abs a1 (App (AndF a0 a1) (Shift (Shift t)) (Pair (Var 1) (Var 0))))). (* Goal: derives context (Abs a (Shift t)) (Imp a b) *) apply ImpIntro. (* Goal: derives context (Abs a (Shift t)) (Imp a b) *) apply ImpIntro. (* Goal: derives (@cons form (Atom i) context') (App (Atom i) (Shift s) (Var O)) b *) apply ImpElim. (* Goal: derives (@cons form a0 context) (Shift t) (Imp (AndF a0 a1) b) *) (* Goal: derives (@cons form a1 (@cons form a0 context)) (Pair (Var (S O)) (Var O)) (AndF a0 a1) *) apply ShiftIntro. (* Goal: derives (@cons form a0 context) (Shift t) (Imp (AndF a0 a1) b) *) (* Goal: derives (@cons form a1 (@cons form a0 context)) (Pair (Var (S O)) (Var O)) (AndF a0 a1) *) apply ShiftIntro. (* Goal: derives context t (Imp (Imp Falsum b) c) *) (* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *) assumption. (* Goal: derives (@cons form a1 (@cons form a0 context)) (Pair (Var (S O)) (Var O)) (AndF a0 a1) *) apply AndFIntro. (* Goal: derives (@cons form (Atom i) context') (Var O) (Atom i) *) apply ByAssumption. (* Goal: my_nth form O (@cons form (Atom i) context') (Atom i) *) apply My_NthS; apply My_NthO. (* Goal: derives (@cons form (Atom i) context') (Var O) (Atom i) *) apply ByAssumption. (* Goal: my_nth form O (@cons form (Atom i) context') (Atom i) *) apply My_NthO. Qed. Lemma derivable_a0_or_a1_imp_b__derivable_a0_imp_b : forall (context : flist) (a0 a1 b : form), Derivable context (Imp (OrF a0 a1) b) -> Derivable context (Imp a0 b). (* Goal: forall (context : flist) (a0 a1 b : form) (_ : Derivable context (Imp (OrF a0 a1) b)), Derivable context (Imp a1 b) *) intros context a0 a1 b der. (* Goal: Derivable context (Imp a b) *) elim der; clear der. (* Goal: forall (t : proof_term) (_ : derives (@cons form a context) t b), Derivable context (Imp a b) *) intros t der_t. apply Derivable_Intro with (Abs a0 (App (OrF a0 a1) (Shift t) (OrFL (Var 0) a1))). (* Goal: derives context (Abs a (Shift t)) (Imp a b) *) apply ImpIntro. (* Goal: derives (@cons form (Atom i) context') (App (Atom i) (Shift s) (Var O)) b *) apply ImpElim. (* Goal: derives context t (Imp (Imp Falsum b) c) *) (* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *) apply ShiftIntro; assumption. (* Goal: derives (@cons form a0 context) (OrFL (Var O) a1) (OrF a0 a1) *) apply OrFIntroL. (* Goal: my_nth form O (@cons form (Atom i) context') (Atom i) *) apply ByAssumption; apply My_NthO. Qed. Lemma derivable_a0_or_a1_imp_b__derivable_a1_imp_b : forall (context : flist) (a0 a1 b : form), Derivable context (Imp (OrF a0 a1) b) -> Derivable context (Imp a1 b). (* Goal: forall (context : flist) (a0 a1 b : form) (_ : Derivable context (Imp (OrF a0 a1) b)), Derivable context (Imp a1 b) *) intros context a0 a1 b der. (* Goal: Derivable context (Imp a b) *) elim der; clear der. (* Goal: forall (t : proof_term) (_ : derives (@cons form a context) t b), Derivable context (Imp a b) *) intros t der_t. apply Derivable_Intro with (Abs a1 (App (OrF a0 a1) (Shift t) (OrFR (Var 0) a0))). (* Goal: derives context (Abs a (Shift t)) (Imp a b) *) apply ImpIntro. (* Goal: derives (@cons form (Atom i) context') (App (Atom i) (Shift s) (Var O)) b *) apply ImpElim. (* Goal: derives context t (Imp (Imp Falsum b) c) *) (* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *) apply ShiftIntro; assumption. (* Goal: derives (@cons form a1 context) (OrFR (Var O) a0) (OrF a0 a1) *) apply OrFIntroR. (* Goal: my_nth form O (@cons form (Atom i) context') (Atom i) *) apply ByAssumption; apply My_NthO. Qed. Lemma derivable_falsum_imp_b_imp_c__derivable_c : forall (context : flist) (b c : form), Derivable context (Imp (Imp Falsum b) c) -> Derivable context c. (* Goal: forall (context : flist) (b c : form) (_ : Derivable context (Imp (Imp Falsum b) c)), Derivable context c *) intros context b c der. (* Goal: Derivable context (Imp a b) *) elim der; clear der. (* Goal: forall (t : proof_term) (_ : derives (@cons form a context) t b), Derivable context (Imp a b) *) intros t der_t. apply Derivable_Intro with (App (Imp Falsum b) t (Abs Falsum (Efq (Var 0) b))). (* Goal: derives (@cons form (Atom i) context') (App (Atom i) (Shift s) (Var O)) b *) apply ImpElim. (* Goal: derives context t (Imp (Imp Falsum b) c) *) (* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *) assumption. (* Goal: derives context (Abs a (Shift t)) (Imp a b) *) apply ImpIntro. (* Goal: derives (@cons form Falsum context) (Efq (Var O) b) b *) apply ByAbsurdity. (* Goal: my_nth form O (@cons form (Atom i) context') (Atom i) *) apply ByAssumption; apply My_NthO. Qed. Lemma derivable_b__derivable_a_imp_b : forall (a b : form) (context : flist), Derivable context b -> Derivable context (Imp a b). (* Goal: forall (a b : form) (context : flist) (_ : Derivable (@cons form a context) b), Derivable context (Imp a b) *) intros a b context der. (* Goal: Derivable context (Imp a b) *) elim der; clear der. (* Goal: forall (t : proof_term) (_ : derives (@cons form a context) t b), Derivable context (Imp a b) *) intros t der_t. (* Goal: Derivable context (Imp a b) *) apply Derivable_Intro with (Abs a (Shift t)). (* Goal: derives context (Abs a (Shift t)) (Imp a b) *) apply ImpIntro. (* Goal: derives context t (Imp (Imp Falsum b) c) *) (* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *) apply ShiftIntro; assumption. Qed. Lemma derivable_a_a_imp_b__derivable_b : forall (a b : form) (context : flist), Derivable context a -> Derivable context (Imp a b) -> Derivable context b. (* Goal: forall (a b : form) (context : flist) (_ : Derivable context a) (_ : Derivable context (Imp a b)), Derivable context b *) intros a b context der_a der_ab. (* Goal: Derivable context b *) elim der_a; clear der_a. (* Goal: forall (t : proof_term) (_ : derives (@cons form a context) t b), Derivable context (Imp a b) *) intros t der_t. (* Goal: Derivable context b *) elim der_ab; clear der_ab. (* Goal: forall (t : proof_term) (_ : derives context t (Imp a b)), Derivable context b *) intros s der_s. (* Goal: Derivable context b *) apply Derivable_Intro with (App a s t). (* Goal: derives context (App a s t) b *) apply ImpElim; assumption. Qed. Lemma derivable_a_context_b__derivable_a_imp_b : forall (a b : form) (context : flist), Derivable (a :: context) b -> Derivable context (Imp a b). (* Goal: forall (a b : form) (context : flist) (_ : Derivable (@cons form a context) b), Derivable context (Imp a b) *) intros a b context der. (* Goal: Derivable context (Imp a b) *) elim der; clear der. (* Goal: forall (t : proof_term) (_ : derives (@cons form a context) t b), Derivable context (Imp a b) *) intros t der_t. (* Goal: Derivable context (Imp a b) *) apply Derivable_Intro with (Abs a t). (* Goal: derives context' (Abs (Atom i) t) (Imp (Atom i) a) *) apply ImpIntro; assumption. Qed. Lemma derivable_vimp : forall (context : flist) (l : list Int) (a b : form), (forall context : flist, Derivable context a -> Derivable context b) -> Derivable context (vimp l a) -> Derivable context (vimp l b). (* Goal: forall (context : flist) (l : list Int) (a : form) (_ : forall context0 : flist, Derivable context0 a), Derivable context (vimp l a) *) intros context l. (* Goal: forall (a : form) (_ : forall context : flist, Derivable context a), Derivable context (vimp l a) *) elim l; clear l. (* Goal: forall (a b : form) (_ : forall (context : flist) (_ : Derivable context a), Derivable context b) (_ : Derivable context (vimp (@nil Int) a)), Derivable context (vimp (@nil Int) b) *) (* Goal: forall (a : Int) (l : list Int) (_ : forall (a0 b : form) (_ : forall (context : flist) (_ : Derivable context a0), Derivable context b) (_ : Derivable context (vimp l a0)), Derivable context (vimp l b)) (a0 b : form) (_ : forall (context : flist) (_ : Derivable context a0), Derivable context b) (_ : Derivable context (vimp (@cons Int a l) a0)), Derivable context (vimp (@cons Int a l) b) *) intros a b der_ab der_a. (* Goal: derives context t (Imp (Imp Falsum b) c) *) (* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *) apply der_ab; assumption. (* Goal: forall (a : Int) (l : list Int) (_ : forall (a0 b : form) (_ : forall (context : flist) (_ : Derivable context a0), Derivable context b) (_ : Derivable context (vimp l a0)), Derivable context (vimp l b)) (a0 b : form) (_ : forall (context : flist) (_ : Derivable context a0), Derivable context b) (_ : Derivable context (vimp (@cons Int a l) a0)), Derivable context (vimp (@cons Int a l) b) *) simpl in |- *; intros i l ih a b der_ab der_a. (* Goal: derives context t (Imp (Imp Falsum b) c) *) (* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *) apply ih with (a := Imp (Atom i) a); try assumption. (* Goal: forall (context : flist) (_ : Derivable context (Imp (Atom i) a)), Derivable context (Imp (Atom i) b) *) intros context' der_ia. (* Goal: Derivable context' (Imp (Atom i) c) *) elim der_ia; clear der_ia; intros t der_ia. (* Goal: Derivable context' (Imp (Atom i) b) *) elim (der_ab (Atom i :: context')). (* Goal: forall (t : proof_term) (_ : derives (@cons form (Atom i) context') t b), Derivable context' (Imp (Atom i) b) *) (* Goal: Derivable (@cons form (Atom i) context') a *) intros s der_b. (* Goal: Derivable context' (Imp (Atom i) b) *) (* Goal: Derivable (@cons form (Atom i) context') a *) apply Derivable_Intro with (Abs (Atom i) s). (* Goal: derives context' (Abs (Atom i) t) (Imp (Atom i) a) *) apply ImpIntro; assumption. (* Goal: Derivable (@cons form (Atom i) context') a *) (* Goal: Derivable (@cons form (Atom i) context') b *) apply Derivable_Intro with (App (Atom i) (Shift t) (Var 0)). (* Goal: derives (@cons form (Atom i) context') (App (Atom i) (Shift s) (Var O)) b *) apply ImpElim. (* Goal: derives context t (Imp (Imp Falsum b) c) *) (* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *) apply ShiftIntro; assumption. (* Goal: derives (@cons form (Atom i) context') (Var O) (Atom i) *) apply ByAssumption. (* Goal: my_nth form O (@cons form (Atom i) context') (Atom i) *) apply My_NthO. Qed. Lemma derivable_vimp2 : forall (context : flist) (l : list Int) (a b c : form), (forall context : flist, Derivable context a -> Derivable context b -> Derivable context c) -> Derivable context (vimp l a) -> Derivable context (vimp l b) -> Derivable context (vimp l c). (* Goal: forall (context : flist) (l : list Int) (a : form) (_ : forall context0 : flist, Derivable context0 a), Derivable context (vimp l a) *) intros context l. (* Goal: forall (a : form) (_ : forall context : flist, Derivable context a), Derivable context (vimp l a) *) elim l; clear l. (* Goal: forall (a b c : form) (_ : forall (context : flist) (_ : Derivable context a) (_ : Derivable context b), Derivable context c) (_ : Derivable context (vimp (@nil Int) a)) (_ : Derivable context (vimp (@nil Int) b)), Derivable context (vimp (@nil Int) c) *) (* Goal: forall (a : Int) (l : list Int) (_ : forall (a0 b c : form) (_ : forall (context : flist) (_ : Derivable context a0) (_ : Derivable context b), Derivable context c) (_ : Derivable context (vimp l a0)) (_ : Derivable context (vimp l b)), Derivable context (vimp l c)) (a0 b c : form) (_ : forall (context : flist) (_ : Derivable context a0) (_ : Derivable context b), Derivable context c) (_ : Derivable context (vimp (@cons Int a l) a0)) (_ : Derivable context (vimp (@cons Int a l) b)), Derivable context (vimp (@cons Int a l) c) *) intros a b c der_abc der_a der_b. (* Goal: derives context t (Imp (Imp Falsum b) c) *) (* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *) apply der_abc; assumption. (* Goal: forall (a : Int) (l : list Int) (_ : forall (a0 b c : form) (_ : forall (context : flist) (_ : Derivable context a0) (_ : Derivable context b), Derivable context c) (_ : Derivable context (vimp l a0)) (_ : Derivable context (vimp l b)), Derivable context (vimp l c)) (a0 b c : form) (_ : forall (context : flist) (_ : Derivable context a0) (_ : Derivable context b), Derivable context c) (_ : Derivable context (vimp (@cons Int a l) a0)) (_ : Derivable context (vimp (@cons Int a l) b)), Derivable context (vimp (@cons Int a l) c) *) simpl in |- *; intros i l ih a b c der_abc der_a der_b. (* Goal: derives context t (Imp (Imp Falsum b) c) *) (* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *) apply ih with (a := Imp (Atom i) a) (b := Imp (Atom i) b); try assumption. (* Goal: forall (context : flist) (_ : Derivable context (Imp (Atom i) a)) (_ : Derivable context (Imp (Atom i) b)), Derivable context (Imp (Atom i) c) *) clear ih. (* Goal: forall (context : flist) (_ : Derivable context (Imp (Atom i) a)) (_ : Derivable context (Imp (Atom i) b)), Derivable context (Imp (Atom i) c) *) intros context' der_ia der_ib. (* Goal: Derivable context' (Imp (Atom i) c) *) elim der_ia; clear der_ia; intros t der_ia. (* Goal: Derivable context' (Imp (Atom i) c) *) elim der_ib; clear der_ib; intros s der_ib. (* Goal: Derivable context' (Imp (Atom i) c) *) elim (der_abc (Atom i :: context')). (* Goal: forall (t : proof_term) (_ : derives (@cons form (Atom i) context') t c), Derivable context' (Imp (Atom i) c) *) (* Goal: Derivable (@cons form (Atom i) context') a *) (* Goal: Derivable (@cons form (Atom i) context') b *) intros r der_r. (* Goal: Derivable context' (Imp (Atom i) c) *) (* Goal: Derivable (@cons form (Atom i) context') a *) (* Goal: Derivable (@cons form (Atom i) context') b *) apply Derivable_Intro with (Abs (Atom i) r). (* Goal: derives context' (Abs (Atom i) t) (Imp (Atom i) a) *) apply ImpIntro; assumption. (* Goal: Derivable (@cons form (Atom i) context') a *) (* Goal: Derivable (@cons form (Atom i) context') b *) apply Derivable_Intro with (App (Atom i) (Shift t) (Var 0)). (* Goal: derives (@cons form (Atom i) context') (App (Atom i) (Shift s) (Var O)) b *) apply ImpElim. (* Goal: derives context t (Imp (Imp Falsum b) c) *) (* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *) apply ShiftIntro; assumption. (* Goal: derives (@cons form (Atom i) context') (Var O) (Atom i) *) apply ByAssumption. (* Goal: my_nth form O (@cons form (Atom i) context') (Atom i) *) apply My_NthO. (* Goal: Derivable (@cons form (Atom i) context') b *) apply Derivable_Intro with (App (Atom i) (Shift s) (Var 0)). (* Goal: derives (@cons form (Atom i) context') (App (Atom i) (Shift s) (Var O)) b *) apply ImpElim. (* Goal: derives context t (Imp (Imp Falsum b) c) *) (* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *) apply ShiftIntro; assumption. (* Goal: derives (@cons form (Atom i) context') (Var O) (Atom i) *) apply ByAssumption. (* Goal: my_nth form O (@cons form (Atom i) context') (Atom i) *) apply My_NthO. Qed. Lemma derivable_vimp0 : forall (context : flist) (l : list Int) (a : form), (forall context : flist, Derivable context a) -> Derivable context (vimp l a). (* Goal: forall (context : flist) (l : list Int) (a : form) (_ : forall context0 : flist, Derivable context0 a), Derivable context (vimp l a) *) intros context l. (* Goal: forall (a : form) (_ : forall context : flist, Derivable context a), Derivable context (vimp l a) *) elim l; clear l. (* Goal: forall (a : form) (_ : forall context : flist, Derivable context a), Derivable context (vimp (@nil Int) a) *) (* Goal: forall (a : Int) (l : list Int) (_ : forall (a0 : form) (_ : forall context : flist, Derivable context a0), Derivable context (vimp l a0)) (a0 : form) (_ : forall context : flist, Derivable context a0), Derivable context (vimp (@cons Int a l) a0) *) intros a der_a. (* Goal: derives context t (Imp (Imp Falsum b) c) *) (* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *) apply der_a; assumption. (* Goal: forall (a : Int) (l : list Int) (_ : forall (a0 : form) (_ : forall context : flist, Derivable context a0), Derivable context (vimp l a0)) (a0 : form) (_ : forall context : flist, Derivable context a0), Derivable context (vimp (@cons Int a l) a0) *) simpl in |- *; intros i l ih a der_a. (* Goal: Derivable context (vimp l (Imp (Atom i) a)) *) apply ih. (* Goal: forall context : flist, Derivable context (Imp (Atom i) a) *) intros context'. (* Goal: Derivable context' (Imp (Atom i) a) *) elim der_a with (Atom i :: context'); clear der_a; intros t der_a. (* Goal: Derivable context' (Imp (Atom i) a) *) apply Derivable_Intro with (Abs (Atom i) t). (* Goal: derives context' (Abs (Atom i) t) (Imp (Atom i) a) *) apply ImpIntro; assumption. Qed.
(* File: NDeco_Sound.v (last edited on 27/10/2000) (c) Klaus Weich *) Require Export NMinimal. (*****************************************************************) Inductive k_deco_sound (k : kripke_tree) (i0 i1 : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) : Prop := k_deco_sound_intro : Is_Monotone_kripke_tree k -> forces_ngamma work ds ni ai a k -> (forces_t k (Imp (Atom i0) (Atom i1)) -> False) -> k_deco_sound k i0 i1 work ds ni ai a. Definition deco_sound (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) := forall (k : kripke_tree) (i0 i1 : Int) (b : normal_form), In (Decorated (NImp i0 i1 b) k) ni -> k_deco_sound k i0 i1 work ds ni ai a. (*****************************************************************) Lemma deco_sound_cons_work_tail : forall (c : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms), deco_sound (c :: work) ds ni ai a -> deco_sound work ds ni ai a. (* Goal: forall (c : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (_ : deco_sound (@cons normal_form c work) ds ni ai a), deco_sound work ds ni ai a *) intros c work ds ni ai a complete. (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni ai a *) unfold deco_sound in |- *. (* Goal: forall (k : kripke_tree) (i0 i1 : Int) (b : normal_form) (_ : @In nested_imp (Decorated (NImp i0 i1 b) k) ni), k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) intros k i0 i1 j in_k. (* Goal: k_deco_sound k i0 i1 (@app normal_form bs work) ds ni ai' a' *) elim (complete k i0 i1 j in_k); clear complete in_k. (* Goal: forall (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma work ds ni ai a k) (_ : forall _ : forces_t k (Imp (Atom i0) (Atom i1)), False), k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) intros k_is_mon k_forces_ngamma k_notforces_i0i1. (* Goal: k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) apply k_deco_sound_intro; try assumption. (* Goal: forces_ngamma work ds ni ai a k *) apply forces_ngamma_cons_work_tail with c; assumption. Qed. Lemma deco_sound_cons_ds_tail : forall (work : nf_list) (i j : Int) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms), deco_sound work ((i, j) :: ds) ni ai a -> deco_sound work ds ni ai a. (* Goal: forall (work : nf_list) (i j : Int) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (_ : deco_sound work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a), deco_sound work ds ni ai a *) intros work i j ds ni ai a complete. (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni ai a *) unfold deco_sound in |- *. (* Goal: forall (k : kripke_tree) (i0 i1 : Int) (b : normal_form) (_ : @In nested_imp (Decorated (NImp i0 i1 b) k) (@app nested_imp ni1 ni2)), k_deco_sound k i0 i1 (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds (@app nested_imp ni1 ni2) ai a *) intros k a0 a1 b in_k. (* Goal: k_deco_sound k a0 a1 work ds ni ai a *) elim (complete k a0 a1 b in_k); clear complete in_k. (* Goal: forall (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma work ds ni ai a k) (_ : forall _ : forces_t k (Imp (Atom i0) (Atom i1)), False), k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) intros k_is_mon k_forces_ngamma k_notforces_i0i1. (* Goal: k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) apply k_deco_sound_intro; try assumption. (* Goal: forces_ngamma work ds ni ai a k *) apply forces_ngamma_cons_ds_tail with i j; assumption. Qed. Lemma deco_sound_cons_ni_tail : forall (work : nf_list) (ds : disjs) (x : nested_imp) (ni : nested_imps) (ai : atomic_imps) (a : atoms), deco_sound work ds (x :: ni) ai a -> deco_sound work ds ni ai a. (* Goal: forall (work : nf_list) (ds : disjs) (x : nested_imp) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (_ : deco_sound work ds (@cons nested_imp x ni) ai a), deco_sound work ds ni ai a *) intros work ds x ni ai a complete. (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni ai a *) unfold deco_sound in |- *. (* Goal: forall (k : kripke_tree) (i0 i1 : Int) (b : normal_form) (_ : @In nested_imp (Decorated (NImp i0 i1 b) k) (@app nested_imp ni1 ni2)), k_deco_sound k i0 i1 (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds (@app nested_imp ni1 ni2) ai a *) intros k a0 a1 b in_k. (* Goal: k_deco_sound k a0 a1 (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds (@app nested_imp ni1 ni2) ai a *) elim (complete k a0 a1 b); clear complete. (* Goal: forall (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma work ds ni ai a k) (_ : forall _ : forces_t k (Imp (Atom i0) (Atom i1)), False), k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) intros k_is_mon k_forces_ngamma k_notforces_i0i1. (* Goal: k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) apply k_deco_sound_intro; try assumption. (* Goal: forces_ngamma work ds ni ai a k *) (* Goal: @In nested_imp (Decorated (NImp a0 a1 b) k) (@cons nested_imp x ni) *) apply forces_ngamma_cons_ni_tail with x; try assumption. (* Goal: @In nested_imp (Decorated (NImp a0 a1 b) k) (@cons nested_imp x ni) *) right; assumption. Qed. (*****************************************************************) Lemma deco_sound_shift_ds_work : forall (i j : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms), deco_sound work ((i, j) :: ds) ni ai a -> deco_sound (NDisj i j :: work) ds ni ai a. (* Goal: forall (i j : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (_ : deco_sound (@cons normal_form (NDisj i j) work) ds ni ai a), deco_sound work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a *) intros i j work ds ni ai a complete. (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni ai a *) unfold deco_sound in |- *. (* Goal: forall (k : kripke_tree) (i0 i1 : Int) (b : normal_form) (_ : @In nested_imp (Decorated (NImp i0 i1 b) k) (@app nested_imp ni1 ni2)), k_deco_sound k i0 i1 (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds (@app nested_imp ni1 ni2) ai a *) intros k a0 a1 b in_k. (* Goal: k_deco_sound k a0 a1 work ds ni ai a' *) elim (complete k a0 a1 b in_k); clear complete. (* Goal: forall (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma work ds ni ai a k) (_ : forall _ : forces_t k (Imp (Atom i0) (Atom i1)), False), k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) intros k_is_mon k_forces_ngamma k_notforces_i0i1. (* Goal: k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) apply k_deco_sound_intro; try assumption. (* Goal: forces_ngamma (@cons normal_form (NDisj i j) work) ds ni ai a k *) apply forces_ngamma_shift_ds_work; assumption. Qed. Lemma deco_sound_shift_work_ds : forall (i j : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms), deco_sound (NDisj i j :: work) ds ni ai a -> deco_sound work ((i, j) :: ds) ni ai a. (* Goal: forall (i j : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (_ : deco_sound (@cons normal_form (NDisj i j) work) ds ni ai a), deco_sound work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a *) intros i j work ds ni ai a complete. (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni ai a *) unfold deco_sound in |- *. (* Goal: forall (k : kripke_tree) (i0 i1 : Int) (b : normal_form) (_ : @In nested_imp (Decorated (NImp i0 i1 b) k) (@app nested_imp ni1 ni2)), k_deco_sound k i0 i1 (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds (@app nested_imp ni1 ni2) ai a *) intros k a0 a1 b in_k. (* Goal: k_deco_sound k a0 a1 work ds ni ai a' *) elim (complete k a0 a1 b in_k); clear complete. (* Goal: forall (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma work ds ni ai a k) (_ : forall _ : forces_t k (Imp (Atom i0) (Atom i1)), False), k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) intros k_is_mon k_forces_ngamma k_notforces_i0i1. (* Goal: k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) apply k_deco_sound_intro; try assumption. (* Goal: forces_ngamma work (@cons (prod Int Int) (@pair Int Int i j) ds) ni ai a k *) apply forces_ngamma_shift_work_ds; assumption. Qed. Lemma deco_sound_shift_ni_work : forall (x : nested_imp) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms), deco_sound work ds (x :: ni) ai a -> deco_sound (NImp_NF (nested_imp2nimp x) :: work) ds ni ai a. (* Goal: forall (x : nimp) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (_ : deco_sound (@cons normal_form (NImp_NF x) work) ds ni ai a), deco_sound work ds (@cons nested_imp (Undecorated x) ni) ai a *) intros x work ds ni ai a complete. (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni ai a *) unfold deco_sound in |- *. (* Goal: forall (k : kripke_tree) (i0 i1 : Int) (b : normal_form) (_ : @In nested_imp (Decorated (NImp i0 i1 b) k) (@app nested_imp ni1 ni2)), k_deco_sound k i0 i1 (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds (@app nested_imp ni1 ni2) ai a *) intros k a0 a1 b in_k. (* Goal: k_deco_sound k a0 a1 (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds (@app nested_imp ni1 ni2) ai a *) elim (complete k a0 a1 b); clear complete. (* Goal: forall (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma work ds ni ai a k) (_ : forall _ : forces_t k (Imp (Atom i0) (Atom i1)), False), k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) intros k_is_mon k_forces_ngamma k_notforces_i0i1. (* Goal: k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) apply k_deco_sound_intro; try assumption. (* Goal: forces_ngamma (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds ni ai a k *) (* Goal: @In nested_imp (Decorated (NImp a0 a1 b) k) (@cons nested_imp x ni) *) apply forces_ngamma_shift_ni_work; assumption. (* Goal: @In nested_imp (Decorated (NImp a0 a1 b) k) (@cons nested_imp x ni) *) right; assumption. Qed. Lemma deco_sound_shift_work_ni0 : forall (x : nimp) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms), deco_sound (NImp_NF x :: work) ds ni ai a -> deco_sound work ds (Undecorated x :: ni) ai a. (* Goal: forall (x : nimp) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (_ : deco_sound (@cons normal_form (NImp_NF x) work) ds ni ai a), deco_sound work ds (@cons nested_imp (Undecorated x) ni) ai a *) intros x work ds ni ai a complete. (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni ai a *) unfold deco_sound in |- *. (* Goal: forall (k : kripke_tree) (i0 i1 : Int) (b : normal_form) (_ : @In nested_imp (Decorated (NImp i0 i1 b) k) ni), k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) intros k i0 i1 j in_k. (* Goal: k_deco_sound k i0 i1 work ds (@app nested_imp ni1 (@cons nested_imp (Undecorated x) ni2)) ai a *) elim (complete k i0 i1 j); clear complete. (* Goal: forall (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma work ds ni ai a k) (_ : forall _ : forces_t k (Imp (Atom i0) (Atom i1)), False), k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) intros k_is_mon k_forces_ngamma k_notforces_i0i1. (* Goal: k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) apply k_deco_sound_intro; try assumption. (* Goal: forces_ngamma work ds (@cons nested_imp (Undecorated x) ni) ai a k *) (* Goal: @In nested_imp (Decorated (NImp i0 i1 j) k) ni *) apply forces_ngamma_shift_work_ni; assumption. (* Goal: @In nested_imp (Decorated (NImp i0 i1 j) k) ni *) inversion_clear in_k. (* Goal: @In nested_imp (Decorated (NImp i0 i1 j) k) ni *) (* Goal: @In nested_imp (Decorated (NImp i0 i1 j) k) ni *) discriminate H. (* Goal: forces_ngamma work ds ni ai a k *) assumption. Qed. Lemma deco_sound_shift_ai_work_new : forall (i : Int) (b : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai ai' : atomic_imps) (a : atoms), (forall bs : nf_list, LOOKUP nf_list i ai bs -> False) -> EQUIV_INS nf_list i (cons b) nf_nil ai ai' -> deco_sound work ds ni ai' a -> deco_sound (AImp i b :: work) ds ni ai a. (* Goal: forall (i : Int) (b : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai ai' : atomic_imps) (a : atoms) (_ : forall (bs : nf_list) (_ : LOOKUP nf_list i ai bs), False) (_ : EQUIV_INS nf_list i (@cons normal_form b) nf_nil ai ai') (_ : deco_sound work ds ni ai' a), deco_sound (@cons normal_form (AImp i b) work) ds ni ai a *) intros i b work ds ni ai ai' a notlookup equiv_ins complete. (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni ai a *) unfold deco_sound in |- *. (* Goal: forall (k : kripke_tree) (i0 i1 : Int) (b : normal_form) (_ : @In nested_imp (Decorated (NImp i0 i1 b) k) ni), k_deco_sound k i0 i1 work ds ni ai' a *) intros k a0 a1 b0 in_k. (* Goal: k_deco_sound k a0 a1 work ds ni ai' a *) elim (complete k a0 a1 b0 in_k); clear complete. (* Goal: forall (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma work ds ni ai a k) (_ : forall _ : forces_t k (Imp (Atom i0) (Atom i1)), False), k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) intros k_is_mon k_forces_ngamma k_notforces_i0i1. (* Goal: k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) apply k_deco_sound_intro; try assumption. (* Goal: forces_ngamma work ds ni ai a k *) apply forces_ngamma_shift_ai_work_new with ai'; assumption. Qed. Lemma deco_sound_shift_ai_work_old : forall (i : Int) (b : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (bs : nf_list) (ai ai' : atomic_imps) (a : atoms), LOOKUP nf_list i ai bs -> EQUIV_INS nf_list i (cons b) nf_nil ai ai' -> deco_sound work ds ni ai' a -> deco_sound (AImp i b :: work) ds ni ai a. (* Goal: forall (i : Int) (b : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (bs : nf_list) (ai ai' : atomic_imps) (a : atoms) (_ : LOOKUP nf_list i ai bs) (_ : EQUIV_INS nf_list i (@cons normal_form b) nf_nil ai ai') (_ : deco_sound work ds ni ai' a), deco_sound (@cons normal_form (AImp i b) work) ds ni ai a *) intros i b work ds ni bs ai ai' a lookup equiv_ins complete. (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni ai a *) unfold deco_sound in |- *. (* Goal: forall (k : kripke_tree) (i0 i1 : Int) (b : normal_form) (_ : @In nested_imp (Decorated (NImp i0 i1 b) k) ni), k_deco_sound k i0 i1 work ds ni ai' a *) intros k a0 a1 b0 in_k. (* Goal: k_deco_sound k a0 a1 work ds ni ai' a *) elim (complete k a0 a1 b0 in_k); clear complete. (* Goal: forall (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma work ds ni ai a k) (_ : forall _ : forces_t k (Imp (Atom i0) (Atom i1)), False), k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) intros k_is_mon k_forces_ngamma k_notforces_i0i1. (* Goal: k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) apply k_deco_sound_intro; try assumption. (* Goal: forces_ngamma work ds ni ai a k *) apply forces_ngamma_shift_ai_work_old with bs ai'; assumption. Qed. Lemma deco_sound_shift_work_ai : forall (i : Int) (b : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai ai' : atomic_imps) (a : atoms), EQUIV_INS nf_list i (cons b) nf_nil ai ai' -> deco_sound (AImp i b :: work) ds ni ai a -> deco_sound work ds ni ai' a. (* Goal: forall (i : Int) (b : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai ai' : atomic_imps) (a : atoms) (_ : EQUIV_INS nf_list i (@cons normal_form b) nf_nil ai ai') (_ : deco_sound (@cons normal_form (AImp i b) work) ds ni ai a), deco_sound work ds ni ai' a *) intros i b work ds ni ai ai' a equiv_ins complete. (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni ai a *) unfold deco_sound in |- *. (* Goal: forall (k : kripke_tree) (i0 i1 : Int) (b : normal_form) (_ : @In nested_imp (Decorated (NImp i0 i1 b) k) ni), k_deco_sound k i0 i1 work ds ni ai' a *) intros k a0 a1 b0 in_k. (* Goal: k_deco_sound k a0 a1 work ds ni ai' a *) elim (complete k a0 a1 b0 in_k); clear complete. (* Goal: forall (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma work ds ni ai a k) (_ : forall _ : forces_t k (Imp (Atom i0) (Atom i1)), False), k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) intros k_is_mon k_forces_ngamma k_notforces_i0i1. (* Goal: k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) apply k_deco_sound_intro; try assumption. (* Goal: forces_ngamma work ds ni ai a k *) apply forces_ngamma_shift_work_ai with i b ai; assumption. Qed. Lemma deco_sound_shift_a_work : forall (i : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a a' : atoms), EQUIV_INS unit i (fun _ : unit => tt) tt a a' -> deco_sound work ds ni ai a' -> deco_sound (NAtom i :: work) ds ni ai a. (* Goal: forall (i : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a a' : atoms) (_ : EQUIV_INS unit i (fun _ : unit => tt) tt a a') (_ : deco_sound (@cons normal_form (NAtom i) work) ds ni ai a), deco_sound work ds ni ai a' *) intros i work ds ni ai a a' equiv_ins complete. (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni ai a *) unfold deco_sound in |- *. (* Goal: forall (k : kripke_tree) (i0 i1 : Int) (b : normal_form) (_ : @In nested_imp (Decorated (NImp i0 i1 b) k) (@app nested_imp ni1 ni2)), k_deco_sound k i0 i1 (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds (@app nested_imp ni1 ni2) ai a *) intros k a0 a1 b in_k. (* Goal: k_deco_sound k a0 a1 work ds ni ai a' *) elim (complete k a0 a1 b in_k); clear complete. (* Goal: forall (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma work ds ni ai a k) (_ : forall _ : forces_t k (Imp (Atom i0) (Atom i1)), False), k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) intros k_is_mon k_forces_ngamma k_notforces_i0i1. (* Goal: k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) apply k_deco_sound_intro; try assumption. (* Goal: forces_ngamma work ds ni ai a k *) apply forces_ngamma_shift_a_work with a'; assumption. Qed. Lemma deco_sound_shift_work_a : forall (i : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a a' : atoms), EQUIV_INS unit i (fun _ : unit => tt) tt a a' -> deco_sound (NAtom i :: work) ds ni ai a -> deco_sound work ds ni ai a'. (* Goal: forall (i : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a a' : atoms) (_ : EQUIV_INS unit i (fun _ : unit => tt) tt a a') (_ : deco_sound (@cons normal_form (NAtom i) work) ds ni ai a), deco_sound work ds ni ai a' *) intros i work ds ni ai a a' equiv_ins complete. (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni ai a *) unfold deco_sound in |- *. (* Goal: forall (k : kripke_tree) (i0 i1 : Int) (b : normal_form) (_ : @In nested_imp (Decorated (NImp i0 i1 b) k) (@app nested_imp ni1 ni2)), k_deco_sound k i0 i1 (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds (@app nested_imp ni1 ni2) ai a *) intros k a0 a1 b in_k. (* Goal: k_deco_sound k a0 a1 work ds ni ai a' *) elim (complete k a0 a1 b in_k); clear complete. (* Goal: forall (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma work ds ni ai a k) (_ : forall _ : forces_t k (Imp (Atom i0) (Atom i1)), False), k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) intros k_is_mon k_forces_ngamma k_notforces_i0i1. (* Goal: k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) apply k_deco_sound_intro; try assumption. (* Goal: forces_ngamma work ds ni ai a k *) apply forces_ngamma_shift_work_a with i a; assumption. Qed. Lemma deco_sound_shift_ni_x_ni_work : forall (x : nested_imp) (work : nf_list) (ds : disjs) (ni1 ni2 : nested_imps) (ai : atomic_imps) (a : atoms), deco_sound work ds (ni1 ++ x :: ni2) ai a -> deco_sound (NImp_NF (nested_imp2nimp x) :: work) ds (ni1 ++ ni2) ai a. (* Goal: forall (x : nimp) (work : nf_list) (ds : disjs) (ni1 ni2 : nested_imps) (ai : atomic_imps) (a : atoms) (_ : deco_sound (@cons normal_form (NImp_NF x) work) ds (@app nested_imp ni1 ni2) ai a), deco_sound work ds (@app nested_imp ni1 (@cons nested_imp (Undecorated x) ni2)) ai a *) intros x work ds ni1 ni2 ai a complete. (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni ai a *) unfold deco_sound in |- *. (* Goal: forall (k : kripke_tree) (i0 i1 : Int) (b : normal_form) (_ : @In nested_imp (Decorated (NImp i0 i1 b) k) (@app nested_imp ni1 ni2)), k_deco_sound k i0 i1 (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds (@app nested_imp ni1 ni2) ai a *) intros k a0 a1 b in_k. (* Goal: k_deco_sound k a0 a1 (@cons normal_form (NImp_NF (nested_imp2nimp x)) work) ds (@app nested_imp ni1 ni2) ai a *) elim (complete k a0 a1 b); clear complete. (* Goal: forall (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma work ds ni ai a k) (_ : forall _ : forces_t k (Imp (Atom i0) (Atom i1)), False), k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) intros k_is_mon k_forces_ngamma k_notforces_i0i1. (* Goal: k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) apply k_deco_sound_intro; try assumption. (* Goal: forces_ngamma work ds ni ai a k *) apply forces_ngamma_shift_ni_x_ni_work; assumption. (* Goal: forces_ngamma work ds ni ai a k *) apply in_ni_x_ni_tail; assumption. Qed. Lemma deco_sound_shift_work_ninni : forall (x : nimp) (work : nf_list) (ds : disjs) (ni1 ni2 : nested_imps) (ai : atomic_imps) (a : atoms), deco_sound (NImp_NF x :: work) ds (ni1 ++ ni2) ai a -> deco_sound work ds (ni1 ++ Undecorated x :: ni2) ai a. (* Goal: forall (x : nimp) (work : nf_list) (ds : disjs) (ni1 ni2 : nested_imps) (ai : atomic_imps) (a : atoms) (_ : deco_sound (@cons normal_form (NImp_NF x) work) ds (@app nested_imp ni1 ni2) ai a), deco_sound work ds (@app nested_imp ni1 (@cons nested_imp (Undecorated x) ni2)) ai a *) intros x work ds ni1 ni2 ai a complete. (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni ai a *) unfold deco_sound in |- *. (* Goal: forall (k : kripke_tree) (i0 i1 : Int) (b : normal_form) (_ : @In nested_imp (Decorated (NImp i0 i1 b) k) ni), k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) intros k i0 i1 j in_k. (* Goal: k_deco_sound k i0 i1 work ds (@app nested_imp ni1 (@cons nested_imp (Undecorated x) ni2)) ai a *) elim (complete k i0 i1 j); clear complete. (* Goal: forall (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma work ds ni ai a k) (_ : forall _ : forces_t k (Imp (Atom i0) (Atom i1)), False), k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) intros k_is_mon k_forces_ngamma k_notforces_i0i1. (* Goal: k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) apply k_deco_sound_intro; try assumption. (* Goal: forces_ngamma work ds ni ai a k *) apply forces_ngamma_shift_work_ni_x_ni; assumption. elim (in_ni_x_ni_rev (Decorated (NImp i0 i1 j) k) (Undecorated x) ni1 ni2 in_k). (* Goal: forces_ngamma work ds ni ai a k *) intros; assumption. intros eq; discriminate eq. Qed. Lemma deco_sound_shift_work_nirni : forall (a0 a1 : Int) (b : normal_form) (k1 : kripke_tree) (work : nf_list) (ds : disjs) (ni1 ni2 : nested_imps) (ai : atomic_imps) (a : atoms), k_deco_sound k1 a0 a1 work ds (ni1 ++ Decorated (NImp a0 a1 b) k1 :: ni2) ai a -> deco_sound (NImp_NF (NImp a0 a1 b) :: work) ds (ni1 ++ ni2) ai a -> deco_sound work ds (ni1 ++ Decorated (NImp a0 a1 b) k1 :: ni2) ai a. (* Goal: forall (a0 a1 : Int) (b : normal_form) (k1 : kripke_tree) (work : nf_list) (ds : disjs) (ni1 ni2 : nested_imps) (ai : atomic_imps) (a : atoms) (_ : k_deco_sound k1 a0 a1 work ds (@app nested_imp ni1 (@cons nested_imp (Decorated (NImp a0 a1 b) k1) ni2)) ai a) (_ : deco_sound (@cons normal_form (NImp_NF (NImp a0 a1 b)) work) ds (@app nested_imp ni1 ni2) ai a), deco_sound work ds (@app nested_imp ni1 (@cons nested_imp (Decorated (NImp a0 a1 b) k1) ni2)) ai a *) intros a0 a1 b k1 work ds ni1 ni2 ai a k_deco_sound0 complete. (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni ai a *) unfold deco_sound in |- *. (* Goal: forall (k : kripke_tree) (i0 i1 : Int) (b0 : normal_form) (_ : @In nested_imp (Decorated (NImp i0 i1 b0) k) (@app nested_imp ni1 (@cons nested_imp (Decorated (NImp a0 a1 b) k1) ni2))), k_deco_sound k i0 i1 work ds (@app nested_imp ni1 (@cons nested_imp (Decorated (NImp a0 a1 b) k1) ni2)) ai a *) intros k a2 a3 b0 in_k. elim (in_ni_x_ni_rev (Decorated (NImp a2 a3 b0) k) (Decorated (NImp a0 a1 b) k1) ni1 ni2 in_k); clear in_k. (* Goal: forall _ : @In nested_imp (Decorated (NImp a2 a3 b0) k) (@app nested_imp ni1 ni2), k_deco_sound k a2 a3 work ds (@app nested_imp ni1 (@cons nested_imp (Decorated (NImp a0 a1 b) k1) ni2)) ai a *) (* Goal: forall _ : @eq nested_imp (Decorated (NImp a2 a3 b0) k) (Decorated (NImp a0 a1 b) k1), k_deco_sound k a2 a3 work ds (@app nested_imp ni1 (@cons nested_imp (Decorated (NImp a0 a1 b) k1) ni2)) ai a *) intros in_k. (* Goal: k_deco_sound k a2 a3 work ds (@app nested_imp ni1 (@cons nested_imp (Decorated (NImp a0 a1 b) k1) ni2)) ai a *) (* Goal: forall _ : @eq nested_imp (Decorated (NImp a2 a3 b0) k) (Decorated (NImp a0 a1 b) k1), k_deco_sound k a2 a3 work ds (@app nested_imp ni1 (@cons nested_imp (Decorated (NImp a0 a1 b) k1) ni2)) ai a *) elim (complete k a2 a3 b0 in_k); clear complete in_k. (* Goal: forall (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma work ds ni ai a k) (_ : forall _ : forces_t k (Imp (Atom i0) (Atom i1)), False), k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) intros k_is_mon k_forces_ngamma k_notforces_i0i1. (* Goal: k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) apply k_deco_sound_intro; try assumption. (* Goal: forces_ngamma work ds ni ai a k *) apply forces_ngamma_shift_work_ni_x_ni; assumption. (* Goal: forall _ : @eq nested_imp (Decorated (NImp a2 a3 b0) k) (Decorated (NImp a0 a1 b) k1), k_deco_sound k a2 a3 work ds (@app nested_imp ni1 (@cons nested_imp (Decorated (NImp a0 a1 b) k1) ni2)) ai a *) intros eq. (* Goal: k_deco_sound k a2 a3 work ds (@app nested_imp ni1 (@cons nested_imp (Decorated (NImp a0 a1 b) k1) ni2)) ai a *) generalize k_deco_sound0. (* Goal: forall _ : k_deco_sound k1 a0 a1 work ds (@app nested_imp ni1 (@cons nested_imp (Decorated (NImp a0 a1 b) k1) ni2)) ai a, k_deco_sound k a2 a3 work ds (@app nested_imp ni1 (@cons nested_imp (Decorated (NImp a0 a1 b) k1) ni2)) ai a *) inversion_clear eq. (* Goal: forall _ : k_deco_sound k1 a0 a1 work ds (@app nested_imp ni1 (@cons nested_imp (Decorated (NImp a0 a1 b) k1) ni2)) ai a, k_deco_sound k1 a0 a1 work ds (@app nested_imp ni1 (@cons nested_imp (Decorated (NImp a0 a1 b) k1) ni2)) ai a *) trivial. Qed. (********************************************************************) Lemma deco_sound_le : forall (ni1 ni2 : nested_imps) (work : nf_list) (ds : disjs) (ai : atomic_imps) (a : atoms), le_ni ni1 ni2 -> deco_sound work ds ni1 ai a -> deco_sound work ds ni2 ai a. (* Goal: forall (ni1 ni2 : nested_imps) (work : nf_list) (ds : disjs) (ai : atomic_imps) (a : atoms) (_ : le_ni ni1 ni2) (_ : deco_sound work ds ni1 ai a), deco_sound work ds ni2 ai a *) intros ni1 ni2 work ds ai a le12 complete. (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni ai a *) unfold deco_sound in |- *. (* Goal: forall (k : kripke_tree) (i0 i1 : Int) (b : normal_form) (_ : @In nested_imp (Decorated (NImp i0 i1 b) k) ni), k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) intros k i0 i1 j in_k. (* Goal: k_deco_sound k i0 i1 work ds ni2 ai a *) elim complete with k i0 i1 j. (* Goal: forall (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma work ds ni ai a k) (_ : forall _ : forces_t k (Imp (Atom i0) (Atom i1)), False), k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) intros k_is_mon k_forces_ngamma k_notforces_i0i1. (* Goal: k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) apply k_deco_sound_intro; try assumption. (* Goal: forces_ngamma work ds ni ai a k *) (* Goal: @In nested_imp (Decorated (NImp i0 i1 j) k) ni1 *) (* Goal: forall _ : @In nested_imp (Decorated (NImp i0 i1 j) k) ni2, k_deco_sound k i0 i1 work ds ni ai a *) apply forces_ngamma_eqv with ni1. (* Goal: forces_ngamma work ds ni ai a k *) apply ge_eqv; assumption. (* Goal: forces_ngamma work ds ni ai a k *) assumption. (* Goal: forces_ngamma work ds ni ai a k *) apply in_k_le with ni2; assumption. Qed. (*********************************************************************) Lemma deco_sound_cons_work_weak : forall (b c : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms), (forall k : kripke_tree, Is_Monotone_kripke_tree k -> forces_t k (nf2form b) -> forces_t k (nf2form c)) -> deco_sound (b :: work) ds ni ai a -> deco_sound (c :: work) ds ni ai a. (* Goal: forall (b c : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form b work) ds ni ai a k), forces_t k (nf2form c)) (_ : deco_sound (@cons normal_form b work) ds ni ai a), deco_sound (@cons normal_form c work) ds ni ai a *) intros b c work ds ni ai a forces_bc complete. (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni ai a *) unfold deco_sound in |- *. (* Goal: forall (k : kripke_tree) (i0 i1 : Int) (b : normal_form) (_ : @In nested_imp (Decorated (NImp i0 i1 b) k) ni), k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) intros k i0 i1 j in_k. (* Goal: k_deco_sound k i0 i1 (@app normal_form bs work) ds ni ai' a' *) elim (complete k i0 i1 j in_k); clear complete in_k. (* Goal: forall (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma work ds ni ai a' k) (_ : forall _ : forces_t k (Imp (Atom i0) (Atom i1)), False), k_deco_sound k i0 i1 (@app normal_form bs work) ds ni ai' a' *) intros k_is_mon k_forces_ngamma k_nonforces. (* Goal: k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) apply k_deco_sound_intro; try assumption. (* Goal: forces_ngamma work ds ni ai a k *) apply forces_ngamma_cons_work_weak with b; try assumption. (* Goal: forall _ : forces_t k (nf2form b), forces_t k (nf2form c) *) intros forces_c. (* Goal: forces_ngamma work ds ni ai a k *) apply forces_bc; assumption. Qed. Lemma deco_sound_cons_work_weak2 : forall (b c d : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms), (forall k : kripke_tree, Is_Monotone_kripke_tree k -> forces_t k (nf2form b) -> forces_t k (nf2form c) -> forces_t k (nf2form d)) -> deco_sound (b :: c :: work) ds ni ai a -> deco_sound (d :: work) ds ni ai a. (* Goal: forall (b c d : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_t k (nf2form b)) (_ : forces_t k (nf2form c)), forces_t k (nf2form d)) (_ : deco_sound (@cons normal_form b (@cons normal_form c work)) ds ni ai a), deco_sound (@cons normal_form d work) ds ni ai a *) intros b c d work ds ni ai a forces_bcd complete. (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni ai a *) unfold deco_sound in |- *. (* Goal: forall (k : kripke_tree) (i0 i1 : Int) (b : normal_form) (_ : @In nested_imp (Decorated (NImp i0 i1 b) k) ni), k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) intros k i0 i1 j in_k. (* Goal: k_deco_sound k i0 i1 (@app normal_form bs work) ds ni ai' a' *) elim (complete k i0 i1 j in_k); clear complete in_k. (* Goal: forall (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma work ds ni ai a' k) (_ : forall _ : forces_t k (Imp (Atom i0) (Atom i1)), False), k_deco_sound k i0 i1 (@app normal_form bs work) ds ni ai' a' *) intros k_is_mon k_forces_ngamma k_nonforces. (* Goal: k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) apply k_deco_sound_intro; try assumption. (* Goal: forces_ngamma work ds ni ai a k *) apply forces_ngamma_cons_work_weak2 with b c; try assumption. (* Goal: forall (_ : forces_t k (nf2form b)) (_ : forces_t k (nf2form c)), forces_t k (nf2form d) *) intros forces_b forces_c. (* Goal: forces_ngamma work ds ni ai a k *) apply forces_bcd; assumption. Qed. Lemma deco_sound_cons_work_strength : forall (b c : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms), (forall k : kripke_tree, Is_Monotone_kripke_tree k -> forces_ngamma (b :: work) ds ni ai a k -> forces_t k (nf2form c)) -> deco_sound (b :: work) ds ni ai a -> deco_sound (c :: work) ds ni ai a. (* Goal: forall (b c : normal_form) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (_ : forall (k : kripke_tree) (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma (@cons normal_form b work) ds ni ai a k), forces_t k (nf2form c)) (_ : deco_sound (@cons normal_form b work) ds ni ai a), deco_sound (@cons normal_form c work) ds ni ai a *) intros b c work ds ni ai a forces_bc complete. (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni ai a *) unfold deco_sound in |- *. (* Goal: forall (k : kripke_tree) (i0 i1 : Int) (b : normal_form) (_ : @In nested_imp (Decorated (NImp i0 i1 b) k) ni), k_deco_sound k i0 i1 (@cons normal_form c work) ds ni ai a *) intros k i0 i1 b0 in_k. (* Goal: k_deco_sound k i0 i1 (@cons normal_form c work) ds ni ai a *) elim (complete k i0 i1 b0 in_k); clear complete in_k. (* Goal: forall (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma work ds ni ai a k) (_ : forall _ : forces_t k (Imp (Atom i0) (Atom i1)), False), k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) intros k_is_mon k_forces_ngamma k_notforces_i0i1. (* Goal: k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) apply k_deco_sound_intro; try assumption. (* Goal: forces_ngamma work ds ni ai a k *) apply forces_ngamma_cons_work_weak with b; try assumption. (* Goal: forall _ : forces_t k (nf2form b), forces_t k (nf2form c) *) intros forces_b. (* Goal: forces_ngamma work ds ni ai a k *) apply forces_bc; assumption. Qed. Lemma deco_sound_shift_work_ai_weak : forall (i : Int) (bs work : nf_list) (ds : disjs) (ni : nested_imps) (ai ai' : atomic_imps) (a : atoms), LOOKUP nf_list i ai bs -> EQUIV_DEL nf_list i ai ai' -> deco_sound (bs ++ work) ds ni ai' a -> deco_sound work ds ni ai a. (* Goal: forall (i : Int) (bs work : nf_list) (ds : disjs) (ni : nested_imps) (ai ai' : atomic_imps) (a : atoms) (_ : LOOKUP nf_list i ai bs) (_ : EQUIV_DEL nf_list i ai ai') (_ : deco_sound (@app normal_form bs work) ds ni ai' a), deco_sound work ds ni ai a *) intros i bs work ds ni ai ai' a lookup equiv_del complete. (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni ai a *) unfold deco_sound in |- *. (* Goal: forall (k : kripke_tree) (i0 i1 : Int) (b : normal_form) (_ : @In nested_imp (Decorated (NImp i0 i1 b) k) ni), k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) intros k i0 i1 j in_k. (* Goal: k_deco_sound k i0 i1 (@app normal_form bs work) ds ni ai' a' *) elim (complete k i0 i1 j in_k); clear complete in_k. (* Goal: forall (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma work ds ni ai a' k) (_ : forall _ : forces_t k (Imp (Atom i0) (Atom i1)), False), k_deco_sound k i0 i1 (@app normal_form bs work) ds ni ai' a' *) intros k_is_mon k_forces_ngamma k_nonforces. (* Goal: k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) apply k_deco_sound_intro; try assumption. (* Goal: forces_ngamma work ds ni ai a k *) apply forces_ngamma_shift_work_ai_weak with i bs ai'; assumption. Qed. Lemma deco_sound_shift_work_ai_strength : forall (i : Int) (bs work : nf_list) (ds : disjs) (ni : nested_imps) (ai ai' : atomic_imps) (a a' : atoms), EQUIV_INS unit i (fun _ : unit => tt) tt a a' -> LOOKUP nf_list i ai bs -> EQUIV_DEL nf_list i ai ai' -> deco_sound work ds ni ai a' -> deco_sound (bs ++ work) ds ni ai' a'. (* Goal: forall (i : Int) (bs work : nf_list) (ds : disjs) (ni : nested_imps) (ai ai' : atomic_imps) (a a' : atoms) (_ : EQUIV_INS unit i (fun _ : unit => tt) tt a a') (_ : LOOKUP nf_list i ai bs) (_ : EQUIV_DEL nf_list i ai ai') (_ : deco_sound work ds ni ai a'), deco_sound (@app normal_form bs work) ds ni ai' a' *) intros i bs work ds ni ai ai' a a' equiv_ins lookup equiv_del complete. (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni ai a *) unfold deco_sound in |- *. (* Goal: forall (k : kripke_tree) (i0 i1 : Int) (b : normal_form) (_ : @In nested_imp (Decorated (NImp i0 i1 b) k) ni), k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) intros k i0 i1 j in_k. (* Goal: k_deco_sound k i0 i1 (@app normal_form bs work) ds ni ai' a' *) elim (complete k i0 i1 j in_k); clear complete in_k. (* Goal: forall (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma work ds ni ai a' k) (_ : forall _ : forces_t k (Imp (Atom i0) (Atom i1)), False), k_deco_sound k i0 i1 (@app normal_form bs work) ds ni ai' a' *) intros k_is_mon k_forces_ngamma k_nonforces. (* Goal: k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) apply k_deco_sound_intro; try assumption. (* Goal: forces_ngamma work ds ni ai a k *) apply forces_ngamma_shift_work_ai_strength with i ai a; assumption. Qed. Lemma deco_sound_inf : forall (ni ni1 ni2 : nested_imps) (work : nf_list) (ds : disjs) (ai : atomic_imps) (a : atoms), le_ni ni ni1 -> eqv_ni ni ni2 -> (forall (x : nimp) (k : kripke_tree), In (Decorated x k) ni -> In (Decorated x k) ni1 \/ In (Decorated x k) ni2) -> deco_sound work ds ni1 ai a -> deco_sound work ds ni2 ai a -> deco_sound work ds ni ai a. (* Goal: forall (ni ni1 ni2 : nested_imps) (work : nf_list) (ds : disjs) (ai : atomic_imps) (a : atoms) (_ : le_ni ni ni1) (_ : eqv_ni ni ni2) (_ : forall (x : nimp) (k : kripke_tree) (_ : @In nested_imp (Decorated x k) ni), or (@In nested_imp (Decorated x k) ni1) (@In nested_imp (Decorated x k) ni2)) (_ : deco_sound work ds ni1 ai a) (_ : deco_sound work ds ni2 ai a), deco_sound work ds ni ai a *) intros ni ni1 ni2 work ds ai a le1 eqv2 inf complete1 complete2. (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni ai a *) unfold deco_sound in |- *. (* Goal: forall (k : kripke_tree) (i0 i1 : Int) (b : normal_form) (_ : @In nested_imp (Decorated (NImp i0 i1 b) k) ni), k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) intros k i0 i1 j in_k. (* Goal: k_deco_sound k i0 i1 work ds ni ai a *) elim (inf (NImp i0 i1 j) k in_k); clear inf in_k. (* Goal: forall _ : @In nested_imp (Decorated (NImp i0 i1 j) k) ni1, k_deco_sound k i0 i1 work ds ni ai a *) (* Goal: forall _ : @In nested_imp (Decorated (NImp i0 i1 j) k) ni2, k_deco_sound k i0 i1 work ds ni ai a *) intros in1. (* Goal: k_deco_sound k i0 i1 work ds ni ai a *) (* Goal: forall _ : @In nested_imp (Decorated (NImp i0 i1 j) k) ni2, k_deco_sound k i0 i1 work ds ni ai a *) elim complete1 with k i0 i1 j. (* Goal: forall (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma work ds ni ai a k) (_ : forall _ : forces_t k (Imp (Atom i0) (Atom i1)), False), k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) intros k_is_mon k_forces_ngamma k_notforces_i0i1. (* Goal: k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) apply k_deco_sound_intro; try assumption. (* Goal: forces_ngamma work ds ni ai a k *) (* Goal: @In nested_imp (Decorated (NImp i0 i1 j) k) ni1 *) (* Goal: forall _ : @In nested_imp (Decorated (NImp i0 i1 j) k) ni2, k_deco_sound k i0 i1 work ds ni ai a *) apply forces_ngamma_eqv with ni1. (* Goal: forces_ngamma work ds ni ai a k *) apply le_eqv; assumption. (* Goal: forces_ngamma work ds ni ai a k *) assumption. (* Goal: forces_ngamma work ds ni ai a k *) assumption. (* Goal: forall _ : @In nested_imp (Decorated (NImp i0 i1 j) k) ni2, k_deco_sound k i0 i1 work ds ni ai a *) intros in2. (* Goal: k_deco_sound k i0 i1 work ds ni ai a *) elim complete2 with k i0 i1 j. (* Goal: forall (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma work ds ni ai a k) (_ : forall _ : forces_t k (Imp (Atom i0) (Atom i1)), False), k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) intros k_is_mon k_forces_ngamma k_notforces_i0i1. (* Goal: k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) apply k_deco_sound_intro; try assumption. (* Goal: forces_ngamma work ds ni ai a k *) apply forces_ngamma_eqv with ni2; assumption. (* Goal: forces_ngamma work ds ni ai a k *) assumption. Qed. Lemma deco_sound_filter_deco : forall (i : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms), (forall (x : nimp) (k : kripke_tree), In (Decorated x k) ni -> forces_t k (Atom i)) -> deco_sound work ds ni ai a -> deco_sound (NAtom i :: work) ds ni ai a. (* Goal: forall (i : Int) (work : nf_list) (ds : disjs) (ni : nested_imps) (ai : atomic_imps) (a : atoms) (_ : forall (x : nimp) (k : kripke_tree) (_ : @In nested_imp (Decorated x k) ni), forces_t k (Atom i)) (_ : deco_sound work ds ni ai a), deco_sound (@cons normal_form (NAtom i) work) ds ni ai a *) intros i work ds ni ai a filter_deco complete. (* Goal: deco_sound (@cons normal_form (NAtom i) work) ds ni ai a *) unfold deco_sound in |- *. (* Goal: forall (k : kripke_tree) (i0 i1 : Int) (b : normal_form) (_ : @In nested_imp (Decorated (NImp i0 i1 b) k) ni), k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) intros k i0 i1 j in_k. (* Goal: k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) elim (complete k i0 i1 j in_k); clear complete. (* Goal: forall (_ : Is_Monotone_kripke_tree k) (_ : forces_ngamma work ds ni ai a k) (_ : forall _ : forces_t k (Imp (Atom i0) (Atom i1)), False), k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) intros k_is_mon k_forces_ngamma k_notforces_i0i1. (* Goal: k_deco_sound k i0 i1 (@cons normal_form (NAtom i) work) ds ni ai a *) apply k_deco_sound_intro; try assumption. (* Goal: forces_ngamma (@cons normal_form (NAtom i) work) ds ni ai a k *) apply forces_ngamma_cons_work. (* Goal: forces_ngamma work ds ni ai a k *) apply filter_deco with (NImp i0 i1 j); assumption. (* Goal: forces_ngamma work ds ni ai a k *) assumption. Qed.
(* File: My_Arith.v (last edited on 25/10/2000) (c) Klaus Weich *) Require Import Le. Require Import Lt. Require Import List. Require Import Plus. (******* List stuff ***********************************************) Lemma fold_right_perm : forall (A B : Set) (f : B -> A -> A) (o : A) (l0 l1 : list B) (x : B), (forall (a b : B) (c : A), f a (f b c) = f b (f a c)) -> fold_right f o (l0 ++ x :: l1) = fold_right f o (x :: l0 ++ l1). (* Goal: forall (A B : Set) (f : forall (_ : B) (_ : A), A) (o : A) (l0 l1 : list B) (x : B) (_ : forall (a b : B) (c : A), @eq A (f a (f b c)) (f b (f a c))), @eq A (@fold_right A B f o (@app B l0 (@cons B x l1))) (@fold_right A B f o (@cons B x (@app B l0 l1))) *) intros A B f o l0 l1 x f_perm. (* Goal: @eq A (@fold_right A B f o (@app B l0 (@cons B x l1))) (@fold_right A B f o (@cons B x (@app B l0 l1))) *) elim l0; clear l0. (* Goal: @eq nat (max (S n) O) (S n) *) trivial. (* Goal: forall (a : B) (l : list B) (_ : @eq A (@fold_right A B f o (@app B l (@cons B x l1))) (@fold_right A B f o (@cons B x (@app B l l1)))), @eq A (@fold_right A B f o (@app B (@cons B a l) (@cons B x l1))) (@fold_right A B f o (@cons B x (@app B (@cons B a l) l1))) *) intros a0 l0 ih. (* Goal: le (S n) (max O (S n)) *) (* Goal: forall n0 : nat, le (S n) (max (S n0) (S n)) *) simpl in |- *. (* Goal: @eq nat (S (max n (S n))) (S (S n)) *) rewrite ih. (* Goal: le (S n) (max O (S n)) *) (* Goal: forall n0 : nat, le (S n) (max (S n0) (S n)) *) simpl in |- *. (* Goal: @eq A (f a0 (f x (@fold_right A B f o (@app B l0 l1)))) (f x (f a0 (@fold_right A B f o (@app B l0 l1)))) *) apply f_perm. Qed. (********************************************************************) Lemma plus_O : forall n : nat, n + 0 = n. (* Goal: forall n : nat, @eq nat (Nat.add n O) n *) intros n. (* Goal: @eq nat (Nat.add n O) n *) rewrite (plus_comm n 0). (* Goal: le (S n) (max O (S n)) *) (* Goal: forall n0 : nat, le (S n) (max (S n0) (S n)) *) simpl in |- *. (* Goal: @eq nat (max (S n) O) (S n) *) trivial. Qed. Lemma n_Sn_false : forall n : nat, n = S n -> False. (* Goal: forall n : nat, @eq nat (max n O) n *) intros n; elim n; clear n. intro u0; discriminate u0. (* Goal: forall (n : nat) (_ : forall _ : @eq nat n (S n), False) (_ : @eq nat (S n) (S (S n))), False *) intros n ih u0. (* Goal: le n (max m0 n) *) apply ih. (* Goal: @eq nat (max (S n) O) (S n) *) injection u0; trivial. Qed. Lemma le_reg : forall m n : nat, n <= m -> S n <= S m. (* Goal: forall (m n : nat) (_ : le n m), le (S n) (S m) *) intros m; elim m; clear m. (* Goal: forall (n : nat) (_ : le n O), le (S n) (S O) *) (* Goal: forall (n : nat) (_ : forall (n0 : nat) (_ : le n0 n), le (S n0) (S n)) (n0 : nat) (_ : le n0 (S n)), le (S n0) (S (S n)) *) intros n; case n; clear n. (* Goal: forall (l m n : nat) (_ : @eq nat m n), @eq nat (Nat.add l m) (Nat.add l n) *) intros. (* Goal: le (S (S m)) (S (S m)) *) (* Goal: le (S n) (S (S m)) *) apply le_n. (* Goal: forall (l m n : nat) (_ : @eq nat m n), @eq nat (Nat.add l m) (Nat.add l n) *) intros. (* Goal: le (S n) (S (S m)) *) inversion_clear H. (* Goal: forall (n : nat) (_ : forall (n0 : nat) (_ : le n0 n), le (S n0) (S n)) (n0 : nat) (_ : le n0 (S n)), le (S n0) (S (S n)) *) intros m ih n H. (* Goal: le (S n) (S (S m)) *) inversion_clear H. (* Goal: le (S (S m)) (S (S m)) *) (* Goal: le (S n) (S (S m)) *) apply le_n. (* Goal: le (S n) (S (S m)) *) apply le_S. (* Goal: le (S n) (S m) *) apply ih; assumption. Qed. Lemma eq_lt_trans : forall n m p : nat, n = m -> m < p -> n < p. (* Goal: forall (n m p : nat) (_ : @eq nat n m) (_ : lt m p), lt n p *) intros n m p eq lt. (* Goal: Peano.lt n p *) rewrite eq; assumption. Qed. Lemma S_reg : forall n m : nat, n = m -> S n = S m. (* Goal: forall (l m n : nat) (_ : @eq nat m n), @eq nat (Nat.add l m) (Nat.add l n) *) intros. (* Goal: @eq nat (S n) (S m) *) rewrite H. (* Goal: @eq nat (max (S n) O) (S n) *) trivial. Qed. Lemma plus_reg : forall l m n : nat, m = n -> l + m = l + n. (* Goal: forall (l m n : nat) (_ : @eq nat m n), @eq nat (Nat.add l m) (Nat.add l n) *) intros. (* Goal: le (S n) (max O (S n)) *) (* Goal: forall n0 : nat, le (S n) (max (S n0) (S n)) *) elim l; clear l; simpl in |- *. (* Goal: @eq nat m n *) (* Goal: forall (n0 : nat) (_ : @eq nat (Nat.add n0 m) (Nat.add n0 n)), @eq nat (S (Nat.add n0 m)) (S (Nat.add n0 n)) *) assumption. (* Goal: forall (n0 : nat) (_ : @eq nat (Nat.add n0 m) (Nat.add n0 n)), @eq nat (S (Nat.add n0 m)) (S (Nat.add n0 n)) *) intros l' ih. (* Goal: @eq nat (S (max n (S n))) (S (S n)) *) rewrite ih. (* Goal: @eq nat (max (S n) O) (S n) *) trivial. Qed. Lemma lt_plus_assoc_l : forall n m k l : nat, n + m + k < l -> n + (m + k) < l. (* Goal: forall (n m k l : nat) (_ : lt (Nat.add (Nat.add n m) k) l), lt (Nat.add n (Nat.add m k)) l *) intros n m k l lt. (* Goal: @eq nat m n *) (* Goal: forall (n0 : nat) (_ : @eq nat (Nat.add n0 m) (Nat.add n0 n)), @eq nat (S (Nat.add n0 m)) (S (Nat.add n0 n)) *) rewrite (plus_assoc n m k); assumption. Qed. Lemma my_lt_weak : forall n m : nat, S n < m -> n < m. (* Goal: forall (n m : nat) (_ : lt (S n) m), lt n m *) intros n m H. (* Goal: lt n m *) apply lt_S_n. (* Goal: @eq nat m n *) (* Goal: forall (n0 : nat) (_ : @eq nat (Nat.add n0 m) (Nat.add n0 n)), @eq nat (S (Nat.add n0 m)) (S (Nat.add n0 n)) *) apply lt_trans with m; try assumption. (* Goal: lt m (S m) *) apply lt_n_Sn. Qed. (********************************************************************) (* max *) Fixpoint max (n m : nat) {struct n} : nat := match n with | O => m | S p => match m with | O => S p | S q => S (max p q) end end. Lemma le_n_max1 : forall n m : nat, n <= max n m. (* Goal: forall n : nat, @eq nat (max n O) n *) intros n; elim n; clear n. (* Goal: le (S n) (max O (S n)) *) (* Goal: forall n0 : nat, le (S n) (max (S n0) (S n)) *) simpl in |- *. (* Goal: forall m : nat, le O (max m O) *) (* Goal: forall (n : nat) (_ : forall m : nat, le n (max m n)) (m : nat), le (S n) (max m (S n)) *) intros m. (* Goal: le O (max m O) *) (* Goal: forall (n : nat) (_ : forall m : nat, le n (max m n)) (m : nat), le (S n) (max m (S n)) *) apply le_O_n. (* Goal: forall (n : nat) (_ : forall m : nat, le n (max m n)) (m : nat), le (S n) (max m (S n)) *) intros n ih m. (* Goal: le (S n) (max m (S n)) *) case m; clear m. (* Goal: le (S n) (max O (S n)) *) (* Goal: forall n0 : nat, le (S n) (max (S n0) (S n)) *) simpl in |- *. (* Goal: @eq nat (max (S n) O) (S n) *) trivial. (* Goal: le (S n) (max O (S n)) *) (* Goal: forall n0 : nat, le (S n) (max (S n0) (S n)) *) intros m0; simpl in |- *. (* Goal: le (S n) (S (max m0 n)) *) apply le_n_S. (* Goal: le n (max m0 n) *) apply ih. Qed. Lemma le_n_max2 : forall n m : nat, n <= max m n. (* Goal: forall n : nat, @eq nat (max n O) n *) intros n; elim n; clear n. (* Goal: forall m : nat, le O (max m O) *) (* Goal: forall (n : nat) (_ : forall m : nat, le n (max m n)) (m : nat), le (S n) (max m (S n)) *) intros m. (* Goal: le O (max m O) *) (* Goal: forall (n : nat) (_ : forall m : nat, le n (max m n)) (m : nat), le (S n) (max m (S n)) *) apply le_O_n. (* Goal: forall (n : nat) (_ : forall m : nat, le n (max m n)) (m : nat), le (S n) (max m (S n)) *) intros n ih m. (* Goal: le (S n) (max m (S n)) *) case m; clear m. (* Goal: le (S n) (max O (S n)) *) (* Goal: forall n0 : nat, le (S n) (max (S n0) (S n)) *) simpl in |- *. (* Goal: @eq nat (max (S n) O) (S n) *) trivial. (* Goal: le (S n) (max O (S n)) *) (* Goal: forall n0 : nat, le (S n) (max (S n0) (S n)) *) intros m0; simpl in |- *. (* Goal: le (S n) (S (max m0 n)) *) apply le_n_S. (* Goal: le n (max m0 n) *) apply ih. Qed. Lemma max_n_n : forall n : nat, max n n = n. (* Goal: le (S n) (max O (S n)) *) (* Goal: forall n0 : nat, le (S n) (max (S n0) (S n)) *) simple induction n; clear n; simpl in |- *. (* Goal: @eq nat (max (S n) O) (S n) *) trivial. (* Goal: forall (n : nat) (_ : @eq nat (max n O) n), @eq nat (max (S n) O) (S n) *) intros n ih. (* Goal: @eq nat (S (max n (S n))) (S (S n)) *) rewrite ih. (* Goal: @eq nat (max (S n) O) (S n) *) trivial. Qed. Lemma max_Sn_n : forall n : nat, max (S n) n = S n. (* Goal: le (S n) (max O (S n)) *) (* Goal: forall n0 : nat, le (S n) (max (S n0) (S n)) *) simple induction n; clear n; simpl in |- *. (* Goal: @eq nat (max (S n) O) (S n) *) trivial. (* Goal: forall (n : nat) (_ : @eq nat (max n O) n), @eq nat (max (S n) O) (S n) *) intros n ih. (* Goal: @eq nat (S (max n (S n))) (S (S n)) *) rewrite ih. (* Goal: @eq nat (max (S n) O) (S n) *) trivial. Qed. Lemma max_n_Sn : forall n : nat, max n (S n) = S n. (* Goal: le (S n) (max O (S n)) *) (* Goal: forall n0 : nat, le (S n) (max (S n0) (S n)) *) simple induction n; clear n; simpl in |- *. (* Goal: @eq nat (max (S n) O) (S n) *) trivial. (* Goal: forall (n : nat) (_ : @eq nat (max n O) n), @eq nat (max (S n) O) (S n) *) intros n ih. (* Goal: @eq nat (S (max n (S n))) (S (S n)) *) rewrite ih. (* Goal: @eq nat (max (S n) O) (S n) *) trivial. Qed. Lemma max_n_O : forall n : nat, max n 0 = n. (* Goal: forall n : nat, @eq nat (max n O) n *) intros n; elim n; clear n. (* Goal: @eq nat (max (S n) O) (S n) *) trivial. (* Goal: forall (n : nat) (_ : @eq nat (max n O) n), @eq nat (max (S n) O) (S n) *) intros n ih. (* Goal: @eq nat (max (S n) O) (S n) *) trivial. Qed.
Require Import InfSeqExt.infseq. Require Import InfSeqExt.exteq. (* map *) Section sec_map. Variable A B: Type. CoFixpoint map (f: A->B) (s: infseq A): infseq B := match s with | Cons x s => Cons (f x) (map f s) end. Lemma map_Cons: forall (f:A->B) x s, map f (Cons x s) = Cons (f x) (map f s). Proof using. (* Goal: forall (s : infseq A) (_ : @True_tl A s) (_ : Q (@map A B f s)), @eventually A P s *) intros. pattern (map f (Cons x s)). rewrite <- recons. simpl. reflexivity. Qed. End sec_map. Arguments map [A B] _ _. Arguments map_Cons [A B] _ _ _. (* --------------------------------------------------------------------------- *) (* Zipping two infseqs: useful for map theory *) Section sec_zip. Variable A B: Type. CoFixpoint zip (sA: infseq A) (sB: infseq B) : infseq (A*B) := match sA, sB with | Cons a sA0, Cons b sB0 => Cons (a, b) (zip sA0 sB0) end. Lemma zip_Cons: forall (a:A) (b:B) sA sB, zip (Cons a sA) (Cons b sB) = Cons (a, b) (zip sA sB). Proof using. (* Goal: forall (s : infseq A) (_ : @True_tl A s) (_ : Q (@map A B f s)), @eventually A P s *) intros. pattern (zip (Cons a sA) (Cons b sB)); rewrite <- recons. simpl. reflexivity. Qed. End sec_zip. Arguments zip [A B] _ _. Arguments zip_Cons [A B] _ _ _ _. (* --------------------------------------------------------------------------- *) (* map and_tl temporal logic *) Section sec_map_modalop. Variable A B: Type. Lemma and_tl_map : forall (f: A->B) (P P': infseq A->Prop) (Q Q': infseq B->Prop), (forall s, P s -> Q (map f s)) -> (forall s, P' s -> Q' (map f s)) -> forall (s: infseq A), (P /\_ P') s -> (Q /\_ Q') (map f s). Proof using. (* Goal: forall (f : forall _ : A, B) (P P' : forall _ : infseq A, Prop) (Q Q' : forall _ : infseq B, Prop) (_ : forall (s : infseq A) (_ : Q (@map A B f s)), P s) (_ : forall (s : infseq A) (_ : Q' (@map A B f s)), P' s) (s : infseq A) (_ : @and_tl B Q Q' (@map A B f s)), @and_tl A P P' s *) unfold and_tl; intuition. Qed. Lemma and_tl_map_conv : forall (f: A->B) (P P': infseq A->Prop) (Q Q': infseq B->Prop), (forall s, Q (map f s) -> P s) -> (forall s, Q' (map f s) -> P' s) -> forall (s: infseq A), (Q /\_ Q') (map f s) -> (P /\_ P') s. Proof using. (* Goal: forall (f : forall _ : A, B) (P P' : forall _ : infseq A, Prop) (Q Q' : forall _ : infseq B, Prop) (_ : forall (s : infseq A) (_ : Q (@map A B f s)), P s) (_ : forall (s : infseq A) (_ : Q' (@map A B f s)), P' s) (s : infseq A) (_ : @and_tl B Q Q' (@map A B f s)), @and_tl A P P' s *) unfold and_tl; intuition. Qed. Lemma or_tl_map : forall (f: A->B) (P P': infseq A->Prop) (Q Q': infseq B->Prop), (forall s, P s -> Q (map f s)) -> (forall s, P' s -> Q' (map f s)) -> forall (s: infseq A), (P \/_ P') s -> (Q \/_ Q') (map f s). Proof using. (* Goal: forall (f : forall _ : A, B) (P P' : forall _ : infseq A, Prop) (Q Q' : forall _ : infseq B, Prop) (_ : forall (s : infseq A) (_ : Q (@map A B f s)), P s) (_ : forall (s : infseq A) (_ : Q' (@map A B f s)), P' s) (s : infseq A) (_ : @or_tl B Q Q' (@map A B f s)), @or_tl A P P' s *) unfold or_tl; intuition. Qed. Lemma or_tl_map_conv : forall (f: A->B) (P P': infseq A->Prop) (Q Q': infseq B->Prop), (forall s, Q (map f s) -> P s) -> (forall s, Q' (map f s) -> P' s) -> forall (s: infseq A), (Q \/_ Q') (map f s) -> (P \/_ P') s. Proof using. (* Goal: forall (f : forall _ : A, B) (P P' : forall _ : infseq A, Prop) (Q Q' : forall _ : infseq B, Prop) (_ : forall (s : infseq A) (_ : Q (@map A B f s)), P s) (_ : forall (s : infseq A) (_ : Q' (@map A B f s)), P' s) (s : infseq A) (_ : @or_tl B Q Q' (@map A B f s)), @or_tl A P P' s *) unfold or_tl; intuition. Qed. Lemma impl_tl_map : forall (f: A->B) (P P': infseq A->Prop) (Q Q': infseq B->Prop), (forall s, Q (map f s) -> P s) -> (forall s, P' s -> Q' (map f s)) -> forall (s: infseq A), (P ->_ P') s -> (Q ->_ Q') (map f s). Proof using. (* Goal: forall (f : forall _ : A, B) (P P' : forall _ : infseq A, Prop) (Q Q' : forall _ : infseq B, Prop) (_ : forall (s : infseq A) (_ : P s), Q (@map A B f s)) (_ : forall (s : infseq A) (_ : Q' (@map A B f s)), P' s) (s : infseq A) (_ : @impl_tl B Q Q' (@map A B f s)), @impl_tl A P P' s *) unfold impl_tl; intuition. Qed. Lemma impl_tl_map_conv : forall (f: A->B) (P P': infseq A->Prop) (Q Q': infseq B->Prop), (forall s, P s -> Q (map f s)) -> (forall s, Q' (map f s) -> P' s) -> forall (s: infseq A), (Q ->_ Q') (map f s) -> (P ->_ P') s. Proof using. (* Goal: forall (f : forall _ : A, B) (P P' : forall _ : infseq A, Prop) (Q Q' : forall _ : infseq B, Prop) (_ : forall (s : infseq A) (_ : P s), Q (@map A B f s)) (_ : forall (s : infseq A) (_ : Q' (@map A B f s)), P' s) (s : infseq A) (_ : @impl_tl B Q Q' (@map A B f s)), @impl_tl A P P' s *) unfold impl_tl; intuition. Qed. Lemma not_tl_map : forall (f: A->B) (P : infseq A->Prop) (Q: infseq B->Prop), (forall s, Q (map f s) -> P s) -> forall (s: infseq A), (~_ P) s -> (~_ Q) (map f s). Proof using. (* Goal: forall (f : forall _ : A, B) (P : forall _ : infseq A, Prop) (Q : forall _ : infseq B, Prop) (_ : forall (s : infseq A) (_ : P s), Q (@map A B f s)) (s : infseq A) (_ : @not_tl B Q (@map A B f s)), @not_tl A P s *) unfold not_tl; intuition. Qed. Lemma not_tl_map_conv : forall (f: A->B) (P: infseq A->Prop) (Q: infseq B->Prop), (forall s, P s -> Q (map f s)) -> forall (s: infseq A), (~_ Q) (map f s) -> (~_ P) s. Proof using. (* Goal: forall (f : forall _ : A, B) (P : forall _ : infseq A, Prop) (Q : forall _ : infseq B, Prop) (_ : forall (s : infseq A) (_ : P s), Q (@map A B f s)) (s : infseq A) (_ : @not_tl B Q (@map A B f s)), @not_tl A P s *) unfold not_tl; intuition. Qed. Lemma now_map : forall (f: A->B) (P: B->Prop) (s: infseq A), now (fun x => P (f x)) s -> now P (map f s). Proof using. (* Goal: forall (f : forall _ : A, B) (P : forall _ : B, Prop) (s : infseq A) (_ : @now B P (@map A B f s)), @now A (fun x : A => P (f x)) s *) intros f P (x, s) nP; assumption. Qed. Lemma now_map_conv : forall (f: A->B) (P: B->Prop) (s: infseq A), now P (map f s) -> now (fun x => P (f x)) s. Proof using. (* Goal: forall (f : forall _ : A, B) (P : forall _ : B, Prop) (s : infseq A) (_ : @now B P (@map A B f s)), @now A (fun x : A => P (f x)) s *) intros f P (x, s) nP; assumption. Qed. Lemma next_map : forall (f: A->B) (P: infseq A->Prop) (Q: infseq B->Prop), (forall s, P s -> Q (map f s)) -> forall (s: infseq A), next P s -> next Q (map f s). Proof using. (* Goal: forall (f : forall _ : A, B) (P : forall _ : infseq A, Prop) (Q : forall _ : infseq B, Prop) (_ : forall (s : infseq A) (_ : P s), Q (@map A B f s)) (s : infseq A) (_ : @next A P s), @next B Q (@map A B f s) *) intros f P Q PQ [x s]; apply PQ. Qed. Lemma next_map_conv : forall (f: A->B) (P: infseq A->Prop) (Q: infseq B->Prop), (forall s, Q (map f s) -> P s) -> forall (s: infseq A), next Q (map f s) -> next P s. Proof using. (* Goal: forall (f : forall _ : A, B) (P : forall _ : infseq A, Prop) (Q : forall _ : infseq B, Prop) (_ : forall (s : infseq A) (_ : Q (@map A B f s)), P s) (s : infseq A) (_ : @next B Q (@map A B f s)), @next A P s *) intros f P Q QP [x s]; apply QP. Qed. Lemma consecutive_map : forall (f: A->B) (P: B->B->Prop) (s: infseq A), consecutive (fun x y => P (f x) (f y)) s -> consecutive P (map f s). Proof using. (* Goal: forall (f : forall _ : A, B) (P : forall (_ : B) (_ : B), Prop) (s : infseq A) (_ : @consecutive B P (@map A B f s)), @consecutive A (fun x y : A => P (f x) (f y)) s *) intros f P (x, (y, s)) nP; assumption. Qed. Lemma consecutive_map_conv : forall (f: A->B) (P: B->B->Prop) (s: infseq A), consecutive P (map f s) -> consecutive (fun x y => P (f x) (f y)) s. Proof using. (* Goal: forall (f : forall _ : A, B) (P : forall (_ : B) (_ : B), Prop) (s : infseq A) (_ : @consecutive B P (@map A B f s)), @consecutive A (fun x y : A => P (f x) (f y)) s *) intros f P (x, (y, s)) nP; assumption. Qed. Lemma always_map : forall (f: A->B) (P: infseq A->Prop) (Q: infseq B->Prop), (forall s, P s -> Q (map f s)) -> forall (s: infseq A), always P s -> always Q (map f s). Proof using. (* Goal: forall (f : forall _ : A, B) (P : forall _ : infseq A, Prop) (Q : forall _ : infseq B, Prop) (_ : forall (s : infseq A) (_ : P s), Q (@map A B f s)) (s : infseq A) (_ : @continuously A P s), @continuously B Q (@map A B f s) *) intros f P Q PQ. cofix cf. (* Goal: forall (s : infseq A) (_ : @always A P s), @always B Q (@map A B f s) *) intros (x, s) a. case (always_Cons a); intros a1 a2. constructor. - apply PQ. assumption. (* Goal: forall _ : @now B P (@Cons B (f x) (@map A B f s)), @now A (fun x : A => P (f x)) (@Cons A x s) *) - rewrite map_Cons; simpl. apply cf; assumption. Qed. Lemma always_map_conv_ext : forall (f: A->B) (P: infseq A->Prop) (Q: infseq B->Prop) (J : infseq A -> Prop), (forall x s, J (Cons x s) -> J s) -> (forall s, J s -> Q (map f s) -> P s) -> forall s, J s -> always Q (map f s) -> always P s. Proof using. (* Goal: forall (f : forall _ : A, B) (P : forall _ : infseq A, Prop) (Q : forall _ : infseq B, Prop) (J : forall _ : infseq A, Prop) (_ : forall (x : A) (s : infseq A) (_ : J (@Cons A x s)), J s) (_ : forall (s : infseq A) (_ : J s) (_ : Q (@map A B f s)), P s) (s : infseq A) (_ : J s) (_ : @always B Q (@map A B f s)), @always A P s *) intros f J P Q inv JQP. cofix c. (* Goal: forall (s : infseq A) (_ : Q s) (_ : @always B P (@map A B f s)), @always A J s *) intros [x s] Js a. (* Goal: @always A J (@Cons A x s) *) rewrite map_Cons in a. case (always_Cons a); intros a1 a2. constructor. - apply JQP. assumption. (* Goal: Q (@map A B f s0) *) rewrite map_Cons; assumption. (* Goal: forall _ : @now B P (@Cons B (f x) (@map A B f s)), @now A (fun x : A => P (f x)) (@Cons A x s) *) - simpl. apply c. (* Goal: Q (@map A B f s0) *) * apply (inv x). assumption. (* Goal: Q (@map A B f s0) *) * assumption. Qed. Lemma always_map_conv : forall (f: A->B) (P: infseq A->Prop) (Q: infseq B->Prop), (forall s, Q (map f s) -> P s) -> forall (s: infseq A), always Q (map f s) -> always P s. Proof using. (* Goal: forall (f : forall _ : A, B) (P : forall _ : infseq A, Prop) (Q : forall _ : infseq B, Prop) (_ : forall (s : infseq A) (_ : Q (@map A B f s)), P s) (s : infseq A) (_ : @always B Q (@map A B f s)), @always A P s *) intros f P Q QP s. (* Goal: forall _ : @always B Q (@map A B f s), @always A P s *) apply (always_map_conv_ext f P Q True_tl); auto. Qed. Lemma weak_until_map : forall (f: A->B) (J P: infseq A->Prop) (K Q: infseq B->Prop), (forall s, J s -> K (map f s)) -> (forall s, P s -> Q (map f s)) -> forall (s: infseq A), weak_until J P s -> weak_until K Q (map f s). Proof using. (* Goal: forall s : infseq A, @always (prod A B) (@now (prod A B) (fun c : prod A B => let (x, y) := c in @eq B y (f x))) (@zip A B s (@map A B f s)) *) intros f J P K Q JK PQ. cofix cf. (* Goal: forall (s : infseq A) (_ : @weak_until B K Q (@map A B f s)), @weak_until A J P s *) intros (x, s) un. case (weak_until_Cons un); clear un. - intro Pxs; constructor 1. apply PQ. assumption. - intros (Jxs, un). rewrite map_Cons. constructor 2. * rewrite <- map_Cons. auto. (* Goal: forall _ : @now B P (@Cons B (f x) (@map A B f s)), @now A (fun x : A => P (f x)) (@Cons A x s) *) * simpl. auto. Qed. Lemma weak_until_map_conv : forall (f: A->B) (J P: infseq A->Prop) (K Q: infseq B->Prop), (forall s, K (map f s) -> J s) -> (forall s, Q (map f s) -> P s) -> forall (s: infseq A), weak_until K Q (map f s) -> weak_until J P s. Proof using. (* Goal: forall s : infseq A, @always (prod A B) (@now (prod A B) (fun c : prod A B => let (x, y) := c in @eq B y (f x))) (@zip A B s (@map A B f s)) *) intros f J P K Q KJ QP. cofix cf. (* Goal: forall (s : infseq A) (_ : @weak_until B K Q (@map A B f s)), @weak_until A J P s *) intros (x, s) un. rewrite map_Cons in un; case (weak_until_Cons un); clear un; rewrite <- map_Cons. - intro Qxs; constructor 1. apply QP. assumption. - intros (Kxs, un). constructor 2; simpl; auto. Qed. Lemma until_map : forall (f: A->B) (J P: infseq A->Prop) (K Q: infseq B->Prop), (forall s, J s -> K (map f s)) -> (forall s, P s -> Q (map f s)) -> forall (s: infseq A), until J P s -> until K Q (map f s). Proof using. (* Goal: forall (f : forall _ : A, B) (J P : forall _ : infseq A, Prop) (K Q : forall _ : infseq B, Prop) (_ : forall (s : infseq A) (_ : J s), K (@map A B f s)) (_ : forall (s : infseq A) (_ : P s), Q (@map A B f s)) (s : infseq A) (_ : @until A J P s), @until B K Q (@map A B f s) *) intros f J P K Q JK PQ s un. (* Goal: @until B K Q (@map A B f s) *) induction un. - apply U0, PQ. assumption. - rewrite map_Cons. (* Goal: @until B K Q (@Cons B (f x) (@map A B f s)) *) apply U_next. * rewrite <- map_Cons. (* Goal: K (@map A B f (@Cons A x s)) *) apply JK. (* Goal: Q (@map A B f s0) *) assumption. (* Goal: Q (@map A B f s0) *) * assumption. Qed. Lemma release_map : forall (f: A->B) (J P: infseq A->Prop) (K Q: infseq B->Prop), (forall s, J s -> K (map f s)) -> (forall s, P s -> Q (map f s)) -> forall (s: infseq A), release J P s -> release K Q (map f s). Proof using. (* Goal: forall s : infseq A, @always (prod A B) (@now (prod A B) (fun c : prod A B => let (x, y) := c in @eq B y (f x))) (@zip A B s (@map A B f s)) *) intros f J P K Q JK PQ. cofix cf. (* Goal: forall (s : infseq A) (_ : @release B K Q (@map A B f s)), @release A J P s *) intros (x, s) rl. case (release_Cons rl); clear rl. (* Goal: forall (_ : P (@Cons A x s)) (_ : or (J (@Cons A x s)) (@release A J P s)), @release B K Q (@map A B f (@Cons A x s)) *) intros Pxs orR. (* Goal: @release B K Q (@map A B f (@Cons A x s)) *) case orR; intro cR. - apply R0. (* Goal: Q (@map A B f (@Cons A x s)) *) * apply PQ. assumption. (* Goal: Q (@map A B f s0) *) * apply JK. assumption. - apply R_tl. (* Goal: Q (@map A B f (@Cons A x s)) *) * apply PQ. assumption. (* Goal: Q (@map A B f s0) *) * apply cf. assumption. Qed. Lemma release_map_conv : forall (f: A->B) (J P: infseq A->Prop) (K Q: infseq B->Prop), (forall s, K (map f s) -> J s) -> (forall s, Q (map f s) -> P s) -> forall (s: infseq A), release K Q (map f s) -> release J P s. Proof using. (* Goal: forall s : infseq A, @always (prod A B) (@now (prod A B) (fun c : prod A B => let (x, y) := c in @eq B y (f x))) (@zip A B s (@map A B f s)) *) intros f J P K Q KJ QP. cofix cf. (* Goal: forall (s : infseq A) (_ : @release B K Q (@map A B f s)), @release A J P s *) intros (x, s) rl. rewrite map_Cons in rl; case (release_Cons rl); clear rl; rewrite <- map_Cons; intros QC orR; case orR; intro cR. - apply R0. (* Goal: Q (@map A B f s0) *) * apply QP. assumption. (* Goal: Q (@map A B f s0) *) * apply KJ. assumption. - apply R_tl. (* Goal: Q (@map A B f s0) *) * apply QP. assumption. (* Goal: Q (@map A B f s0) *) * apply cf. assumption. Qed. Lemma eventually_map : forall (f: A->B) (P: infseq A->Prop) (Q: infseq B->Prop), (forall s, P s -> Q (map f s)) -> forall s, eventually P s -> eventually Q (map f s). Proof using. (* Goal: forall (f : forall _ : A, B) (P : forall _ : infseq A, Prop) (Q : forall _ : infseq B, Prop) (_ : forall (s : infseq A) (_ : P s), Q (@map A B f s)) (s : infseq A) (_ : @eventually A P s), @eventually B Q (@map A B f s) *) intros f P Q PQ s e. induction e as [s ok | x s e induc_hyp]. - destruct s as (x, s); simpl in *. rewrite map_Cons. constructor 1. rewrite <- map_Cons. apply PQ. exact ok. - rewrite map_Cons. constructor 2. exact induc_hyp. Qed. (* The converse seems to require much more work *) Definition fstAB := fst (A:=A) (B:=B). Lemma exteq_fst_zip: forall sA sB, exteq (map fstAB (zip sA sB)) sA. Proof using. (* Goal: forall s : infseq A, @always (prod A B) (@now (prod A B) (fun c : prod A B => let (x, y) := c in @eq B y (f x))) (@zip A B s (@map A B f s)) *) cofix cf. intros (a, sA) (b, sB). (* Goal: @always (prod A B) (@now (prod A B) (fun c : prod A B => let (x, y) := c in @eq B y (f x))) (@zip A B (@Cons A x s0) (@map A B f (@Cons A x s0))) *) rewrite zip_Cons. rewrite map_Cons. constructor. apply cf. Qed. Lemma exteq_zip_map : forall (f: A->B) (sA: infseq A) (sB: infseq B), always (now (fun c: A*B => let (x, y) := c in y = f x)) (zip sA sB) -> exteq sB (map f (map fstAB (zip sA (map f sA)))). Proof using. (* Goal: forall s : infseq A, @always (prod A B) (@now (prod A B) (fun c : prod A B => let (x, y) := c in @eq B y (f x))) (@zip A B s (@map A B f s)) *) intros f. cofix cf. (* Goal: forall (sA : infseq A) (sB : infseq B) (_ : @always (prod A B) (@now (prod A B) (fun c : prod A B => let (x, y) := c in @eq B y (f x))) (@zip A B sA sB)), @exteq B sB (@map A B f (@map (prod A B) A fstAB (@zip A B sA (@map A B f sA)))) *) intros (a, sA) (b, sB). (* Goal: forall _ : @now B P (@Cons B (f x) (@map A B f s)), @now A (fun x : A => P (f x)) (@Cons A x s) *) repeat rewrite map_Cons; repeat rewrite zip_Cons; repeat rewrite map_Cons; simpl. (* Goal: forall _ : @now B P (@Cons B (f x) (@map A B f s)), @now A (fun x : A => P (f x)) (@Cons A x s) *) intro al; case (always_Cons al); clear al; simpl. intros e al. case e. constructor. (* Goal: @always (prod A B) (@now (prod A B) (fun c : prod A B => let (x, y) := c in @eq B y (f x))) ((cofix zip (sA : infseq A) (sB : infseq B) : infseq (prod A B) := match sA with | Cons a sA0 => match sB with | Cons b sB0 => @Cons (prod A B) (@pair A B a b) (zip sA0 sB0) end end) s0 ((cofix map (f : forall _ : A, B) (s : infseq A) : infseq B := match s with | Cons x s0 => @Cons B (f x) (map f s0) end) f s0)) *) apply cf. exact al. Qed. Lemma eventually_map_conv_aux : forall (f: A->B) (Q: infseq B->Prop), extensional Q -> forall (s: infseq A) (sB: infseq B), always (now (fun c: A*B => let (x, y) := c in y = f x)) (zip s sB) -> eventually Q sB -> eventually (fun sc => Q (map f (map fstAB sc))) (zip s (map f s)). Proof using. (* Goal: forall (f : forall _ : A, B) (Q : forall _ : infseq B, Prop) (_ : @extensional B Q) (s : infseq A) (sB : infseq B) (_ : @always (prod A B) (@now (prod A B) (fun c : prod A B => let (x, y) := c in @eq B y (f x))) (@zip A B s sB)) (_ : @eventually B Q sB), @eventually (prod A B) (fun sc : infseq (prod A B) => Q (@map A B f (@map (prod A B) A fstAB sc))) (@zip A B s (@map A B f s)) *) intros f Q extQ s sB al ev. genclear al; genclear s. (* Goal: forall (s : infseq A) (_ : @always (prod A B) (@now (prod A B) (fun c : prod A B => let (x, y) := c in @eq B y (f x))) (@zip A B s sB)), @eventually (prod A B) (fun sc : infseq (prod A B) => Q (@map A B f (@map (prod A B) A fstAB sc))) (@zip A B s (@map A B f s)) *) induction ev as [(b, sB) QbsB | b sB ev induc_hyp]. - intros (a, sA) al. (* Goal: Q (@map A B f s0) *) constructor 1. apply extQ with (Cons b sB); try assumption. (* Goal: @exteq B (@Cons B b sB) (@map A B f (@map (prod A B) A fstAB (@zip A B (@Cons A a sA) (@map A B f (@Cons A a sA))))) *) apply exteq_zip_map. apply al. - intros (a, sA). repeat rewrite map_Cons. repeat rewrite zip_Cons. (* Goal: forall _ : @now B P (@Cons B (f x) (@map A B f s)), @now A (fun x : A => P (f x)) (@Cons A x s) *) intro al. case (always_Cons al); simpl. clear al; intros e al. (* Goal: @eventually (prod A B) (fun sc : infseq (prod A B) => Q (@map A B f (@map (prod A B) A fstAB sc))) (@Cons (prod A B) (@pair A B a (f a)) (@zip A B sA (@map A B f sA))) *) constructor 2. apply induc_hyp. exact al. Qed. Lemma eventually_map_conv_ext : forall (f: A->B) (P: infseq A->Prop) (Q: infseq B->Prop) (J : infseq A -> Prop), extensional P -> extensional Q -> extensional J -> (forall x s, J (Cons x s) -> J s) -> (forall s, J s -> Q (map f s) -> eventually P s) -> forall s, J s -> eventually Q (map f s) -> eventually P s. Proof using. (* Goal: forall (f : forall _ : A, B) (P : forall _ : infseq A, Prop) (Q : forall _ : infseq B, Prop) (J : forall _ : infseq A, Prop) (_ : @extensional A P) (_ : @extensional B Q) (_ : @extensional A J) (_ : forall (x : A) (s : infseq A) (_ : J (@Cons A x s)), J s) (_ : forall (s : infseq A) (_ : J s) (_ : Q (@map A B f s)), @eventually A P s) (s : infseq A) (_ : J s) (_ : @eventually B Q (@map A B f s)), @eventually A P s *) intros f P Q J extP extQ extJ inv QP s Js ev. (* Goal: @eventually A P s *) revert Js. assert (efst: J (map fstAB (zip s (map f s))) -> eventually P (map fstAB (zip s (map f s)))). - assert (evzip : eventually (fun sc => Q (map f (map fstAB sc))) (zip s (map f s))). * clear extP QP P. assert (alzip : (always (now (fun c : A * B => let (x, y) := c in y = f x)) (zip s (map f s)))). (* Goal: forall s : infseq A, @always (prod A B) (@now (prod A B) (fun c : prod A B => let (x, y) := c in @eq B y (f x))) (@zip A B s (@map A B f s)) *) + clear ev extQ. generalize s. cofix cf. intros (x, s0). constructor. (* Goal: forall _ : @now B P (@Cons B (f x) (@map A B f s)), @now A (fun x : A => P (f x)) (@Cons A x s) *) -- simpl. reflexivity. (* Goal: forall _ : @now B P (@Cons B (f x) (@map A B f s)), @now A (fun x : A => P (f x)) (@Cons A x s) *) -- simpl. apply cf. + apply (eventually_map_conv_aux f Q extQ s (map f s) alzip ev). * clear ev. induction evzip as [((a, b), sAB) QabsAB | c sAB _ induc_hyp]. + intros Js. (* Goal: Q (@map A B f s0) *) apply QP; assumption. + intros Js. (* Goal: @eventually A P (@map (prod A B) A fstAB (@Cons (prod A B) c sAB)) *) rewrite map_Cons. (* Goal: @eventually A P (@Cons A x s) *) apply E_next. (* Goal: @eventually A P (@map (prod A B) A fstAB sAB) *) apply induc_hyp. (* Goal: J (@map (prod A B) A fstAB sAB) *) rewrite map_Cons in Js. (* Goal: J (@map (prod A B) A fstAB sAB) *) apply (inv (fstAB c)). (* Goal: Q (@map A B f s0) *) assumption. - intros Js. (* Goal: @eventually A P s *) assert (emJ: J (map fstAB (zip s (map f s)))). * unfold extensional in extJ. (* Goal: J (@map (prod A B) A fstAB (@zip A B s (@map A B f s))) *) apply (extJ s). + apply exteq_sym. apply exteq_fst_zip. (* Goal: Q (@map A B f s0) *) + assumption. * apply efst in emJ. (* Goal: @eventually A P s *) genclear emJ. (* Goal: forall _ : @eventually A P (@map (prod A B) A fstAB (@zip A B s (@map A B f s))), @eventually A P s *) apply extensional_eventually. + exact extP. + apply exteq_fst_zip. Qed. Lemma eventually_map_conv : forall (f: A->B) (P: infseq A->Prop) (Q: infseq B->Prop), extensional P -> extensional Q -> (forall s, Q (map f s) -> P s) -> forall s, eventually Q (map f s) -> eventually P s. Proof using. (* Goal: forall (f : forall _ : A, B) (P : forall _ : infseq A, Prop) (Q : forall _ : infseq B, Prop) (_ : @extensional A P) (_ : @extensional B Q) (_ : forall (s : infseq A) (_ : Q (@map A B f s)), P s) (s : infseq A) (_ : @eventually B Q (@map A B f s)), @eventually A P s *) intros f P Q extP extQ QP s. (* Goal: @weak_until B K Q (@map A B f s) *) apply eventually_map_conv_ext with (J := True_tl); auto. - apply extensional_True_tl. (* Goal: forall (s : infseq A) (_ : @True_tl A s) (_ : Q (@map A B f s)), @eventually A P s *) - intros. apply E0. apply QP. assumption. Qed. Lemma eventually_map_monotonic : forall (f: A->B) (P Q J: infseq A->Prop) (K : infseq B -> Prop), (forall x s, J (Cons x s) -> J s) -> (forall x s, K (map f (Cons x s)) -> K (map f s)) -> (forall s, J s -> K (map f s) -> Q s -> P s) -> forall s, J s -> K (map f s) -> eventually Q s -> eventually P s. Proof using. (* Goal: forall (f : forall _ : A, B) (P Q J : forall _ : infseq A, Prop) (K : forall _ : infseq B, Prop) (_ : forall (x : A) (s : infseq A) (_ : J (@Cons A x s)), J s) (_ : forall (x : A) (s : infseq A) (_ : K (@map A B f (@Cons A x s))), K (@map A B f s)) (_ : forall (s : infseq A) (_ : J s) (_ : K (@map A B f s)) (_ : Q s), P s) (s : infseq A) (_ : J s) (_ : K (@map A B f s)) (_ : @eventually A Q s), @eventually A P s *) intros f P Q J K Jinv Kinv JKQP s invJ invK ev. (* Goal: @eventually A P s *) induction ev as [s Qs | x s ev IHev]. - apply E0. (* Goal: Q (@map A B f s0) *) apply JKQP; assumption. - apply E_next. (* Goal: @eventually A P s *) apply IHev. (* Goal: Q (@map A B f s0) *) * apply (Jinv x); assumption. (* Goal: Q (@map A B f s0) *) * apply (Kinv x); assumption. Qed. Lemma inf_often_map : forall (f: A->B) (P: infseq A->Prop) (Q: infseq B->Prop), (forall s, P s -> Q (map f s)) -> forall (s: infseq A), inf_often P s -> inf_often Q (map f s). Proof using. (* Goal: forall (f : forall _ : A, B) (P : forall _ : infseq A, Prop) (Q : forall _ : infseq B, Prop) (_ : forall (s : infseq A) (_ : P s), Q (@map A B f s)) (s : infseq A) (_ : @continuously A P s), @continuously B Q (@map A B f s) *) intros f P Q PQ. (* Goal: Q (@map A B f s0) *) apply always_map; apply eventually_map; assumption. Qed. Lemma inf_often_map_conv : forall (f: A->B) (P: infseq A->Prop) (Q: infseq B->Prop), extensional P -> extensional Q -> (forall s, Q (map f s) -> P s) -> forall (s: infseq A), inf_often Q (map f s) -> inf_often P s. Proof using. (* Goal: forall (f : forall _ : A, B) (P : forall _ : infseq A, Prop) (Q : forall _ : infseq B, Prop) (_ : @extensional A P) (_ : @extensional B Q) (_ : forall (s : infseq A) (_ : Q (@map A B f s)), P s) (s : infseq A) (_ : @continuously B Q (@map A B f s)), @continuously A P s *) intros f P Q eP eQ QP. (* Goal: forall (s : infseq A) (_ : @inf_often B Q (@map A B f s)), @inf_often A P s *) apply always_map_conv; apply eventually_map_conv; trivial. Qed. Lemma continuously_map : forall (f: A->B) (P: infseq A->Prop) (Q: infseq B->Prop), (forall s, P s -> Q (map f s)) -> forall (s: infseq A), continuously P s -> continuously Q (map f s). Proof using. (* Goal: forall (f : forall _ : A, B) (P : forall _ : infseq A, Prop) (Q : forall _ : infseq B, Prop) (_ : forall (s : infseq A) (_ : P s), Q (@map A B f s)) (s : infseq A) (_ : @continuously A P s), @continuously B Q (@map A B f s) *) intros f P Q PQ. (* Goal: Q (@map A B f s0) *) apply eventually_map; apply always_map; assumption. Qed. Lemma continuously_map_conv : forall (f: A->B) (P: infseq A->Prop) (Q: infseq B->Prop), extensional P -> extensional Q -> (forall s, Q (map f s) -> P s) -> forall (s: infseq A), continuously Q (map f s) -> continuously P s. Proof using. (* Goal: forall (f : forall _ : A, B) (P : forall _ : infseq A, Prop) (Q : forall _ : infseq B, Prop) (_ : @extensional A P) (_ : @extensional B Q) (_ : forall (s : infseq A) (_ : Q (@map A B f s)), P s) (s : infseq A) (_ : @continuously B Q (@map A B f s)), @continuously A P s *) intros f P Q eP eQ QP. (* Goal: forall _ : @eventually B (@now B P) (@map A B f s), @eventually A (@now A (fun x : A => P (f x))) s *) apply eventually_map_conv. - apply extensional_always; assumption. - apply extensional_always; assumption. - apply always_map_conv; assumption. Qed. (* Some corollaries *) Lemma eventually_now_map : forall (f: A->B) (P: B->Prop) (s: infseq A), eventually (now (fun x => P (f x))) s -> eventually (now P) (map f s). Proof using. (* Goal: forall (f : forall _ : A, B) (P : forall _ : B, Prop) (s : infseq A) (_ : @eventually A (@now A (fun x : A => P (f x))) s), @eventually B (@now B P) (@map A B f s) *) intros f P. apply eventually_map. apply now_map. Qed. Lemma eventually_now_map_conv : forall (f: A->B) (P: B->Prop) (s: infseq A), eventually (now P) (map f s) -> eventually (now (fun x => P (f x))) s. Proof using. (* Goal: forall _ : @eventually B (@now B P) (@map A B f s), @eventually A (@now A (fun x : A => P (f x))) s *) intros f P s. apply eventually_map_conv. - apply extensional_now. - apply extensional_now. (* Goal: forall _ : @now B P (@Cons B (f x) (@map A B f s)), @now A (fun x : A => P (f x)) (@Cons A x s) *) - clear s. intros (x, s). repeat rewrite map_Cons. simpl. trivial. Qed. Lemma eventually_map_now_eq : forall (f: A -> B) a s, eventually (now (eq a)) s -> eventually (now (eq (f a))) (map f s). Proof using. (* Goal: forall (s : infseq A) (_ : @eventually A (@now A (@eq A a)) s), @eventually B (@now B (@eq B (f a))) (@map A B f s) *) intros f a. apply eventually_map. (* Goal: @now B (@eq B (f a)) (@map A B f s) *) intros s noa. apply now_map. (* Goal: @now A (fun x : A => @eq B (f a) (f x)) s *) genclear noa. monotony. apply f_equal. Qed. End sec_map_modalop. Arguments and_tl_map [A B f P P' Q Q'] _ _ [s] _. Arguments and_tl_map_conv [A B f P P' Q Q'] _ _ [s] _. Arguments or_tl_map [A B f P P' Q Q'] _ _ [s] _. Arguments or_tl_map_conv [A B f P P' Q Q'] _ _ [s] _. Arguments impl_tl_map [A B f P P' Q Q'] _ _ [s] _ _. Arguments impl_tl_map_conv [A B f P P' Q Q'] _ _ [s] _ _. Arguments not_tl_map [A B f P Q] _ [s] _ _. Arguments not_tl_map_conv [A B f P Q] _ [s] _ _. Arguments now_map [A B f P s] _. Arguments now_map_conv [A B f P s] _. Arguments next_map [A B f P Q] _ [s] _. Arguments next_map_conv [A B f P Q] _ [s] _. Arguments consecutive_map [A B f P s] _. Arguments consecutive_map_conv [A B f P s] _. Arguments always_map [A B f P Q] _ [s] _. Arguments always_map_conv_ext [A B f P Q J] _ _ [s] _ _. Arguments always_map_conv [A B f P Q] _ [s] _. Arguments weak_until_map [A B f J P K Q] _ _ [s] _. Arguments weak_until_map_conv [A B f J P K Q] _ _ [s] _. Arguments until_map [A B f J P K Q] _ _ [s] _. Arguments release_map [A B f J P K Q] _ _ [s] _. Arguments release_map_conv [A B f J P K Q] _ _ [s] _. Arguments eventually_map [A B f P Q] _ [s] _. Arguments eventually_map_conv_ext [A B f P Q J] _ _ _ _ _ [s] _ _. Arguments eventually_map_conv [A B f P Q] _ _ _ [s] _. Arguments eventually_map_monotonic [A B f P Q] _ _ _ _ _ [s] _ _ _. Arguments inf_often_map [A B f P Q] _ [s] _. Arguments inf_often_map_conv [A B f P Q] _ _ _ [s] _. Arguments continuously_map [A B f P Q] _ [s] _. Arguments continuously_map_conv [A B f P Q] _ _ _ [s] _. Arguments eventually_now_map [A B f P s] _. Arguments eventually_now_map_conv [A B f P s] _. Arguments eventually_map_now_eq [A B f a s] _.
Require Import InfSeqExt.infseq. Require Import Classical. Section sec_classical. Variable T : Type. Lemma weak_until_until_or_always : forall (J P : infseq T -> Prop) (s : infseq T), weak_until J P s -> until J P s \/ always J s. Proof using. (* Goal: forall (J P : forall _ : infseq T, Prop) (s : infseq T) (_ : @weak_until T J P s), or (@until T J P s) (@always T J s) *) intros J P s. (* Goal: forall _ : @weak_until T J P s, or (@until T J P s) (@always T J s) *) case (classic (eventually P s)). - intros evP wu. (* Goal: or (@until T J P s) (@always T J s) *) left. (* Goal: @until T J P s *) induction evP. * apply U0. assumption. * apply weak_until_Cons in wu. (* Goal: @until T J P (@Cons T x s) *) case wu. + intros PC. (* Goal: @until T J P s *) apply U0. assumption. + intros [Js wu']. (* Goal: @until T J P (@Cons T x s) *) apply U_next; trivial. (* Goal: @until T J P s *) apply IHevP. (* Goal: @eventually T (@always T P) s *) assumption. - intros evP wu. (* Goal: or (@until T J P s) (@always T J s) *) right. (* Goal: @always T J s *) apply not_eventually_always_not in evP. (* Goal: @always T J s *) apply weak_until_always_not_always in wu; trivial. Qed. Lemma not_until_weak_until : forall (J P : infseq T -> Prop) (s : infseq T), ~ until J P s -> weak_until (J /\_ ~_ P) (~_ J /\_ ~_ P) s. Proof using. (* Goal: forall (J P : forall _ : infseq T, Prop) (s : infseq T) (_ : not (@until T (@not_tl T J) (@not_tl T P) s)), @release T J P s *) intros J P. (* Goal: forall (s : infseq T) (_ : not (@continuously T P s)), @inf_often T (@not_tl T P) s *) cofix c. (* Goal: forall (s : infseq T) (_ : not (@until T (@not_tl T J) (@not_tl T P) s)), @release T J P s *) intros s. (* Goal: @release T (@not_tl T J) (@not_tl T P) s *) case (classic (P s)). - intros Ps un. (* Goal: False *) contradict un. (* Goal: @until T J P s *) apply U0. (* Goal: @eventually T (@always T P) s *) assumption. - intros Ps. (* Goal: forall _ : not (@until T (@and_tl T J (@not_tl T P)) (@and_tl T (@not_tl T J) (@not_tl T P)) s), @weak_until T J P s *) case (classic (J s)); destruct s as [x s]. * intros Js un. (* Goal: @weak_until T (@and_tl T J (@not_tl T P)) (@and_tl T (@not_tl T J) (@not_tl T P)) (@Cons T x s) *) apply W_tl. + unfold and_tl, not_tl. (* Goal: @and_tl T (@not_tl T J) (@not_tl T P) (@Cons T x s) *) split; trivial. + simpl. (* Goal: @always T (@eventually T (@not_tl T P)) (@tl T (@Cons T x s)) *) apply c. (* Goal: not (@until T J P s) *) intros unn. (* Goal: False *) contradict un. (* Goal: @until T J P (@Cons T x s) *) apply U_next; trivial. * intros Js un. (* Goal: @weak_until T J P s *) apply W0. (* Goal: @and_tl T (@not_tl T J) (@not_tl T P) (@Cons T x s) *) split; trivial. Qed. Lemma not_weak_until_until : forall (J P : infseq T -> Prop) (s : infseq T), ~ weak_until J P s -> until (J /\_ ~_ P) (~_ J /\_ ~_ P) s. Proof using. (* Goal: forall (J P : forall _ : infseq T, Prop) (s : infseq T) (_ : not (@weak_until T J P s)), @until T (@and_tl T J (@not_tl T P)) (@and_tl T (@not_tl T J) (@not_tl T P)) s *) intros J P s wun. (* Goal: @until T (@and_tl T J (@not_tl T P)) (@and_tl T (@not_tl T J) (@not_tl T P)) s *) case (classic (until (J /\_ ~_ P) (~_ J /\_ ~_ P) s)); trivial. (* Goal: forall _ : not (@until T J P s), @until T J P s *) intros un. (* Goal: @until T (@and_tl T J (@not_tl T P)) (@and_tl T (@not_tl T J) (@not_tl T P)) s *) contradict wun. (* Goal: @release T (@not_tl T J) (@not_tl T P) s *) revert s un. (* Goal: forall (s : infseq T) (_ : not (@continuously T P s)), @inf_often T (@not_tl T P) s *) cofix c. (* Goal: forall (s : infseq T) (_ : not (@until T (@not_tl T J) (@not_tl T P) s)), @release T J P s *) intros s. (* Goal: @release T (@not_tl T J) (@not_tl T P) s *) case (classic (P s)). - intros Ps un. (* Goal: @weak_until T J P s *) apply W0. (* Goal: @eventually T (@always T P) s *) assumption. - intros Ps. (* Goal: forall _ : not (@until T (@and_tl T J (@not_tl T P)) (@and_tl T (@not_tl T J) (@not_tl T P)) s), @weak_until T J P s *) case (classic (J s)); destruct s as [x s]. * intros Js un. (* Goal: @weak_until T J P (@Cons T x s) *) apply W_tl; trivial. (* Goal: @release T (@not_tl T J) (@not_tl T P) (@tl T (@Cons T x s)) *) simpl. (* Goal: @always T (@eventually T (@not_tl T P)) (@tl T (@Cons T x s)) *) apply c. (* Goal: not (@until T J P s) *) intros unn. (* Goal: False *) contradict un. (* Goal: @until T J P (@Cons T x s) *) apply U_next; trivial. (* Goal: @and_tl T (@not_tl T J) (@not_tl T P) (@Cons T x s) *) split; trivial. * intros Js un. (* Goal: False *) contradict un. (* Goal: @until T J P s *) apply U0. (* Goal: @and_tl T (@not_tl T J) (@not_tl T P) (@Cons T x s) *) split; trivial. Qed. Lemma not_eventually_not_always : forall (P : infseq T -> Prop) (s : infseq T), ~ eventually (~_ P) s -> always P s. Proof using. (* Goal: forall (P : forall _ : infseq T, Prop) (s : infseq T) (_ : not (@continuously T P s)), @inf_often T (@not_tl T P) s *) intros P. (* Goal: forall (s : infseq T) (_ : not (@continuously T P s)), @inf_often T (@not_tl T P) s *) cofix c. (* Goal: forall (s : infseq T) (_ : not (@eventually T (@not_tl T P) s)), @always T P s *) intro s. (* Goal: forall _ : not (@eventually T (@not_tl T P) s), @always T P s *) destruct s as [e s]. (* Goal: forall _ : not (@eventually T (@not_tl T P) (@Cons T e s)), @always T P (@Cons T e s) *) intros evnP. (* Goal: @inf_often T (@not_tl T P) (@Cons T x s) *) apply Always. - case (classic (P (Cons e s))); trivial. (* Goal: forall _ : not (P (@Cons T e s)), P (@Cons T e s) *) intros orP. (* Goal: P (@Cons T e s) *) apply (E0 _ (~_ P)) in orP. (* Goal: False *) contradict evnP. (* Goal: @eventually T (@always T P) s *) assumption. - apply c. (* Goal: @release T (@not_tl T J) (@not_tl T P) (@tl T (@Cons T x s)) *) simpl. (* Goal: forall _ : not (@eventually T (@not_tl T P) s), @eventually T (@not_tl T P) s *) intros evP. (* Goal: False *) contradict evnP. (* Goal: @continuously T P (@Cons T x s) *) apply E_next. (* Goal: @eventually T (@always T P) s *) assumption. Qed. Lemma not_always_eventually_not : forall (P : infseq T -> Prop) (s : infseq T), ~ always P s -> eventually (~_ P) s. Proof using. (* Goal: forall (P : forall _ : infseq T, Prop) (s : infseq T) (_ : not (@always T P s)), @eventually T (@not_tl T P) s *) intros P s alP. (* Goal: @eventually T (@not_tl T P) s *) case (classic ((eventually (~_ P)) s)); trivial. (* Goal: forall _ : not (@eventually T (@not_tl T P) s), @eventually T (@not_tl T P) s *) intros evP. (* Goal: @eventually T (@not_tl T P) s *) apply not_eventually_not_always in evP. (* Goal: @eventually T (@not_tl T P) s *) contradict alP. (* Goal: @eventually T (@always T P) s *) assumption. Qed. Lemma not_until_release : forall (J P : infseq T -> Prop) (s : infseq T), ~ until (~_ J) (~_ P) s -> release J P s. Proof using. (* Goal: forall (J P : forall _ : infseq T, Prop) (s : infseq T) (_ : not (@until T (@not_tl T J) (@not_tl T P) s)), @release T J P s *) intros J P. (* Goal: forall (s : infseq T) (_ : not (@continuously T P s)), @inf_often T (@not_tl T P) s *) cofix c. (* Goal: forall (s : infseq T) (_ : not (@until T (@not_tl T J) (@not_tl T P) s)), @release T J P s *) intros s. (* Goal: @release T (@not_tl T J) (@not_tl T P) s *) case (classic (J s)). - intros Js un. (* Goal: @release T (@not_tl T J) (@not_tl T P) s *) destruct s as [x s]. (* Goal: @release T J P (@Cons T x s) *) apply R0; trivial. (* Goal: P (@Cons T x s) *) case (classic (P (Cons x s))); trivial. (* Goal: forall _ : not (P s), @release T (@not_tl T J) (@not_tl T P) s *) intros Ps. (* Goal: False *) contradict un. (* Goal: @until T J P s *) apply U0. (* Goal: @not_tl T P (@Cons T x s) *) apply Ps. - intros Js un. (* Goal: @release T (@not_tl T J) (@not_tl T P) s *) destruct s as [x s]. (* Goal: @release T J P (@Cons T x s) *) apply R_tl. * case (classic (P (Cons x s))); trivial. (* Goal: forall _ : not (P s), @release T (@not_tl T J) (@not_tl T P) s *) intros Ps. (* Goal: False *) contradict un. (* Goal: @until T J P s *) apply U0. (* Goal: @not_tl T P (@Cons T x s) *) apply Ps. * simpl. (* Goal: @always T (@eventually T (@not_tl T P)) (@tl T (@Cons T x s)) *) apply c. (* Goal: not (@until T J P s) *) intros unn. (* Goal: False *) contradict un. (* Goal: @until T J P (@Cons T x s) *) apply U_next; trivial. Qed. Lemma not_release_until : forall (J P : infseq T -> Prop) (s : infseq T), ~ release (~_ J) (~_ P) s -> until J P s. Proof using. (* Goal: forall (J P : forall _ : infseq T, Prop) (s : infseq T) (_ : not (@release T (@not_tl T J) (@not_tl T P) s)), @until T J P s *) intros J P s rl. (* Goal: @until T J P s *) case (classic (until J P s)); trivial. (* Goal: forall _ : not (@until T J P s), @until T J P s *) intros un. (* Goal: @until T J P s *) contradict rl. (* Goal: @release T (@not_tl T J) (@not_tl T P) s *) revert s un. (* Goal: forall (s : infseq T) (_ : not (@continuously T P s)), @inf_often T (@not_tl T P) s *) cofix c. (* Goal: forall (s : infseq T) (_ : not (@until T J P s)), @release T (@not_tl T J) (@not_tl T P) s *) intros s un. (* Goal: @release T (@not_tl T J) (@not_tl T P) s *) case (classic (P s)). - intros Ps. (* Goal: False *) contradict un. (* Goal: @until T J P s *) apply U0. (* Goal: @eventually T (@always T P) s *) assumption. - intros Ps. (* Goal: @release T (@not_tl T J) (@not_tl T P) s *) case (classic (J s)). * intros Js. (* Goal: @release T (@not_tl T J) (@not_tl T P) s *) destruct s as [x s]. (* Goal: @release T (@not_tl T J) (@not_tl T P) (@Cons T x s) *) apply R_tl; trivial. (* Goal: @release T (@not_tl T J) (@not_tl T P) (@tl T (@Cons T x s)) *) simpl. (* Goal: @always T (@eventually T (@not_tl T P)) (@tl T (@Cons T x s)) *) apply c. (* Goal: not (@until T J P s) *) intros unn. (* Goal: False *) contradict un. (* Goal: @until T J P (@Cons T x s) *) apply U_next; trivial. * intros Js. (* Goal: @release T (@not_tl T J) (@not_tl T P) s *) destruct s as [x s]. (* Goal: @eventually T (@always T P) s *) apply R0; unfold not_tl; assumption. Qed. Lemma not_inf_often_continuously_not : forall (P : infseq T -> Prop) (s : infseq T), ~ inf_often P s -> continuously (~_ P) s. Proof using. (* Goal: forall (P : forall _ : infseq T, Prop) (s : infseq T) (_ : not (@inf_often T P s)), @continuously T (@not_tl T P) s *) intros P s ioP. (* Goal: @continuously T (@not_tl T P) s *) apply not_always_eventually_not in ioP. (* Goal: @continuously T (@not_tl T P) s *) induction ioP. - apply not_eventually_always_not in H. (* Goal: @continuously T (@not_tl T P) s *) apply E0. (* Goal: @eventually T (@always T P) s *) assumption. - apply E_next. (* Goal: @eventually T (@always T P) s *) assumption. Qed. Lemma not_continously_inf_often_not : forall (P : infseq T -> Prop) (s : infseq T), ~ continuously P s -> inf_often (~_ P) s. Proof using. (* Goal: forall (P : forall _ : infseq T, Prop) (s : infseq T) (_ : not (@continuously T P s)), @inf_often T (@not_tl T P) s *) intros P. (* Goal: forall (s : infseq T) (_ : not (@continuously T P s)), @inf_often T (@not_tl T P) s *) cofix c. (* Goal: forall (s : infseq T) (_ : not (@continuously T P s)), @inf_often T (@not_tl T P) s *) intros [x s] cnyP. (* Goal: @inf_often T (@not_tl T P) (@Cons T x s) *) apply Always. - unfold continuously in cnyP. (* Goal: @eventually T (@not_tl T P) (@Cons T x s) *) apply not_eventually_always_not in cnyP. (* Goal: @eventually T (@not_tl T P) (@Cons T x s) *) apply always_now in cnyP. (* Goal: @eventually T (@not_tl T P) (@Cons T x s) *) unfold not_tl in cnyP. (* Goal: @eventually T (@not_tl T P) (@Cons T x s) *) apply not_always_eventually_not in cnyP. (* Goal: @eventually T (@always T P) s *) assumption. - apply c. (* Goal: not (@continuously T P (@tl T (@Cons T x s))) *) intros cnynP. (* Goal: False *) contradict cnyP. (* Goal: @continuously T P (@Cons T x s) *) apply E_next. (* Goal: @eventually T (@always T P) s *) assumption. Qed. Lemma not_tl_and_tl_or_tl : forall (P Q : infseq T -> Prop) (s : infseq T), (~_ (P /\_ Q)) s -> ((~_ P) \/_ (~_ Q)) s. Proof using. (* Goal: forall (P Q : forall _ : infseq T, Prop) (s : infseq T) (_ : @not_tl T (@and_tl T P Q) s), @or_tl T (@not_tl T P) (@not_tl T Q) s *) intros P Q s; unfold not_tl, and_tl, or_tl. (* Goal: forall _ : not (and (P s) (Q s)), or (not (P s)) (not (Q s)) *) apply not_and_or. Qed. End sec_classical. Arguments weak_until_until_or_always [T J P s] _. Arguments not_until_weak_until [T J P s] _. Arguments not_weak_until_until [T J P s] _. Arguments not_eventually_not_always [T P s] _. Arguments not_always_eventually_not [T P s] _. Arguments not_until_release [T J P s] _. Arguments not_release_until [T J P s] _. Arguments not_inf_often_continuously_not [T P s] _. Arguments not_continously_inf_often_not [T P s] _. Arguments not_tl_and_tl_or_tl [T P Q s] _.
(* ------------------------------------------------------------------------- *) (* General tactics *) Ltac genclear H := generalize H; clear H. Ltac clearall := repeat match goal with [H : _ |- _ ] => clear H end || match goal with [H : _ |- _ ] => genclear H end. (* ------------------------------------------------------------------------- *) (* Infinite traces *) Section sec_infseq. Variable T: Type. CoInductive infseq : Type := Cons : T -> infseq -> infseq. Definition hd (s:infseq) : T := match s with Cons x _ => x end. Definition tl (s:infseq) : infseq := match s with Cons _ s => s end. Lemma recons : forall s, Cons (hd s) (tl s) = s. Proof using. (* Goal: forall s : infseq, @eq infseq (Cons (hd s) (tl s)) s *) intros s. (* Trick : simpl doesn't progress, you have to eat s first *) (* Goal: @eq infseq (Cons (hd s) (tl s)) s *) case s. simpl. reflexivity. Qed. End sec_infseq. Arguments Cons [T] _ _. Arguments hd [T] _. Arguments tl [T] _. Arguments recons [T] _. (* --------------------------------------------------------------------------- *) (* Temporal logic operations *) Section sec_modal_op_defn. Variable T : Type. Definition now (P: T->Prop) (s: infseq T) : Prop := match s with Cons x s => P x end. Definition next (P: infseq T -> Prop) (s: infseq T) : Prop := match s with Cons x s => P s end. Definition consecutive (R: T -> T -> Prop) (s: infseq T) : Prop := match s with Cons x1 (Cons x2 s) => R x1 x2 end. CoInductive always1 (P: T->Prop) : infseq T -> Prop := | Always1 : forall x s, P x -> always1 P s -> always1 P (Cons x s). CoInductive always (P: infseq T->Prop) : infseq T -> Prop := | Always : forall s, P s -> always P (tl s) -> always P s. CoInductive weak_until (J P: infseq T->Prop) : infseq T -> Prop := | W0 : forall s, P s -> weak_until J P s | W_tl : forall s, J s -> weak_until J P (tl s) -> weak_until J P s. Inductive until (J P: infseq T->Prop) : infseq T -> Prop := | U0 : forall s, P s -> until J P s | U_next : forall x s, J (Cons x s) -> until J P s -> until J P (Cons x s). CoInductive release (J P: infseq T->Prop) : infseq T -> Prop := | R0 : forall s, P s -> J s -> release J P s | R_tl : forall s, P s -> release J P (tl s) -> release J P s. Inductive eventually (P: infseq T->Prop) : infseq T -> Prop := | E0 : forall s, P s -> eventually P s | E_next : forall x s, eventually P s -> eventually P (Cons x s). Definition inf_often (P: infseq T->Prop) (s: infseq T) : Prop := always (eventually P) s. Definition continuously (P: infseq T->Prop) (s: infseq T) : Prop := eventually (always P) s. (* temporal logic connectors *) Definition impl_tl (P Q: infseq T -> Prop) : infseq T -> Prop := fun s => P s -> Q s. Definition and_tl (P Q: infseq T -> Prop) : infseq T -> Prop := fun s => P s /\ Q s. Definition or_tl (P Q: infseq T -> Prop) : infseq T -> Prop := fun s => P s \/ Q s. Definition not_tl (P : infseq T -> Prop) : infseq T -> Prop := fun s => ~ P s. (* constants *) Definition True_tl : infseq T -> Prop := fun _ => True. Definition False_tl : infseq T -> Prop := fun _ => False. End sec_modal_op_defn. Hint Unfold True_tl False_tl : core. Arguments now [T] _ _. Arguments next [T] _ _. Arguments consecutive [T] _ _. Arguments always [T] _ _. Arguments always1 [T] _ _. Arguments eventually [T] _ _. Arguments weak_until [T] _ _ _. Arguments until [T] _ _ _. Arguments release [T] _ _ _. Arguments inf_often [T] _ _. Arguments continuously [T] _ _. Arguments impl_tl [T] _ _ _. Arguments and_tl [T] _ _ _. Arguments or_tl [T] _ _ _. Arguments not_tl [T] _ _. Arguments True_tl {T} _. Arguments False_tl {T} _. Notation "A ->_ B" := (impl_tl A B) (right associativity, at level 90). Notation "A /\_ B" := (and_tl A B) (right associativity, at level 80). Notation "A \/_ B" := (or_tl A B) (right associativity, at level 85). Notation "~_ A" := (not_tl A) (right associativity, at level 75). Section sec_modal_op_lemmas. Variable T : Type. (* now facts *) Lemma now_hd : forall (P : T -> Prop) ex, now P ex -> P (hd ex). Proof using. (* Goal: forall (P : forall _ : T, Prop) (ex : infseq T) (_ : @now T P ex), P (@hd T ex) *) now destruct ex. Qed. (* always facts *) Lemma always_inv : forall (inv: infseq T -> Prop), (forall x s, inv (Cons x s) -> inv s) -> forall s, inv s -> always inv s. Proof using. (* Goal: forall (inv : forall _ : infseq T, Prop) (_ : forall (x : T) (s : infseq T) (_ : inv (@Cons T x s)), inv s) (s : infseq T) (_ : inv s), @always T inv s *) intros P invP. (* Goal: forall (s : infseq T) (_ : @weak_until T J P s) (_ : @always T (@not_tl T P) s), @always T J s *) cofix c. (* Goal: forall (s : infseq T) (_ : P s), @always T P s *) intros [x s] Pxs; apply Always; trivial. (* Goal: @always T P (@tl T (@Cons T x s)) *) apply c; apply invP in Pxs. (* Goal: @weak_until T J P s *) assumption. Qed. Lemma always_Cons : forall (x: T) (s: infseq T) P, always P (Cons x s) -> P (Cons x s) /\ always P s. Proof using. (* Goal: forall (x : T) (s : infseq T) (P : forall _ : infseq T, Prop) (_ : @eventually T P (@Cons T x s)), or (P (@Cons T x s)) (@eventually T P s) *) intros x s P al. change (P (Cons x s) /\ always P (tl (Cons x s))). (* Goal: @weak_until T J P s *) destruct al. split; assumption. Qed. Lemma always_now : forall (x: T) (s: infseq T) P, always P (Cons x s) -> P (Cons x s). Proof using. (* Goal: forall (x : T) (s : infseq T) (P : forall _ : infseq T, Prop) (_ : @eventually T P (@Cons T x s)), or (P (@Cons T x s)) (@eventually T P s) *) intros x s P al. case (always_Cons x s P al); trivial. Qed. Lemma always_now' : forall (P : infseq T -> Prop) ex, always P ex -> P ex. Proof using. (* Goal: forall (P : forall _ : infseq T, Prop) (ex : infseq T) (_ : @always T P ex), P ex *) destruct ex. (* Goal: forall _ : @always T P (@Cons T t ex), P (@Cons T t ex) *) apply always_now. Qed. Lemma always_invar : forall (x: T) (s: infseq T) P, always P (Cons x s) -> always P s. Proof using. (* Goal: forall (x : T) (s : infseq T) (P : forall _ : infseq T, Prop) (_ : @eventually T P (@Cons T x s)), or (P (@Cons T x s)) (@eventually T P s) *) intros x s P al. case (always_Cons x s P al); trivial. Qed. Lemma always_tl : forall (s: infseq T) P, always P s -> always P (tl s). Proof using. (* Goal: @release T K Q (@tl T (@Cons T x s)) *) intros (x, s). simpl. apply always_invar. Qed. Lemma always_not_false : forall s : infseq T, always (~_ False_tl) s. Proof using. (* Goal: forall (s : infseq T) (_ : @weak_until T J P s) (_ : @always T (@not_tl T P) s), @always T J s *) cofix c. (* Goal: forall s : infseq T, @always T (@True_tl T) s *) intros [x s]. (* Goal: @always T (@not_tl T P) (@Cons T e s) *) apply Always. - unfold not_tl, False_tl; auto. - apply c. Qed. Lemma always_true : forall s : infseq T, always True_tl s. Proof using. (* Goal: forall (s : infseq T) (_ : @weak_until T J P s) (_ : @always T (@not_tl T P) s), @always T J s *) cofix c. (* Goal: forall s : infseq T, @always T (@True_tl T) s *) intros [x s]. (* Goal: @always T (@not_tl T P) (@Cons T e s) *) apply Always. - unfold True_tl; trivial. - apply c. Qed. Lemma always_and_tl : forall (P Q : infseq T -> Prop), forall s, always P s -> always Q s -> always (P /\_ Q) s. Proof using. (* Goal: forall (P Q : forall _ : infseq T, Prop) (s : infseq T) (_ : @always T P s) (_ : @always T Q s), @always T (@and_tl T P Q) s *) intros P Q. (* Goal: forall (s : infseq T) (_ : @weak_until T J P s) (_ : @always T (@not_tl T P) s), @always T J s *) cofix c. (* Goal: forall (s : infseq T) (_ : @always T P s) (_ : @always T Q s), @always T (@and_tl T P Q) s *) intros s alP alQ. (* Goal: @always T (@and_tl T P Q) s *) destruct alP. (* Goal: @always T (@and_tl T P Q) s *) destruct alQ. (* Goal: @always T (@not_tl T P) (@Cons T e s) *) apply Always. (* Goal: @weak_until T J P s *) - split; assumption. (* Goal: @weak_until T J P s *) - apply c; assumption. Qed. Lemma always_always : forall (P : infseq T -> Prop) s, always P s -> always (always P) s. Proof using. (* Goal: forall (P : forall _ : infseq T, Prop) (s : infseq T) (_ : @always T P s), @always T (@always T P) s *) intro P. (* Goal: forall (s : infseq T) (_ : @weak_until T J P s) (_ : @always T (@not_tl T P) s), @always T J s *) cofix c. (* Goal: @inf_often T P s *) constructor. - auto. - do 2 destruct s. (* Goal: @always T (@always T P) (@tl T (@Cons T t (@Cons T t0 s))) *) constructor; eauto using always_invar. Qed. Lemma always_always1 : forall P (s: infseq T), always (now P) s -> always1 P s. Proof using. (* Goal: forall (P : forall _ : infseq T, Prop) (s : infseq T) (_ : @always T (@not_tl T P) s), not (@eventually T P s) *) intros P. (* Goal: forall (s : infseq T) (_ : @always1 T P s), @always T (@now T P) s *) cofix alwn. (* Goal: @release T K Q (@tl T (@Cons T x s)) *) intros s a; case a; clear a s. intros (x, s); simpl. constructor. (* Goal: @weak_until T J P s *) - assumption. (* Goal: @weak_until T J P s *) - apply alwn; assumption. Qed. Lemma always1_always : forall P (s: infseq T), always1 P s -> always (now P) s. Proof using. (* Goal: forall (P : forall _ : infseq T, Prop) (s : infseq T) (_ : @always T (@not_tl T P) s), not (@eventually T P s) *) intros P. (* Goal: @release T K Q (@tl T (@Cons T x s)) *) cofix alwn. destruct 1. constructor; simpl. (* Goal: @weak_until T J P s *) - assumption. (* Goal: @weak_until T J P s *) - apply alwn; assumption. Qed. Lemma always_weak_until : forall (J P : infseq T -> Prop) (s : infseq T), always J s -> weak_until J P s. Proof using. (* Goal: forall (J P : forall _ : infseq T, Prop) (s : infseq T) (_ : @weak_until T J P s) (_ : @always T (@not_tl T P) s), @always T J s *) intros J P. (* Goal: forall (s : infseq T) (_ : @weak_until T J P s) (_ : @always T (@not_tl T P) s), @always T J s *) cofix c. (* Goal: forall (s : infseq T) (_ : @always T J s), @weak_until T J P s *) intros [x s] alJ. (* Goal: @weak_until T J P (@Cons T x s) *) apply W_tl. - apply always_now in alJ. (* Goal: @weak_until T J P s *) assumption. - apply c. (* Goal: @always T J (@tl T (@Cons T x s)) *) apply always_invar in alJ. (* Goal: @weak_until T J P s *) assumption. Qed. Lemma always_release : forall (J P : infseq T -> Prop) (s : infseq T), always P s -> release J P s. Proof using. (* Goal: forall (J P : forall _ : infseq T, Prop) (s : infseq T) (_ : @weak_until T J P s) (_ : @always T (@not_tl T P) s), @always T J s *) intros J P. (* Goal: forall (s : infseq T) (_ : @weak_until T J P s) (_ : @always T (@not_tl T P) s), @always T J s *) cofix c. (* Goal: forall (s : infseq T) (_ : @always T P s), @release T J P s *) intros [x s] al. (* Goal: @release T K Q (@Cons T x s) *) apply R_tl. - apply always_now in al. (* Goal: @weak_until T J P s *) assumption. (* Goal: @release T K Q (@tl T (@Cons T x s)) *) - simpl. (* Goal: @always T (@not_tl T P) (@tl T (@Cons T e s)) *) apply c. (* Goal: @always T P s *) apply always_invar in al. (* Goal: @weak_until T J P s *) assumption. Qed. Lemma always_inf_often : forall (P: infseq T -> Prop) (s : infseq T), always P s -> inf_often P s. Proof using. (* Goal: @inf_often T P s *) intros P. cofix f. intros s a. destruct a. constructor. (* Goal: @weak_until T J P s *) - constructor 1. assumption. (* Goal: @weak_until T J P s *) - apply f. assumption. Qed. Lemma always_continuously : forall (P: infseq T -> Prop) (s : infseq T), always P s -> continuously P s. Proof using. (* Goal: forall (P : forall _ : infseq T, Prop) (s : infseq T) (_ : @always T P s), @continuously T P s *) intros P s alP. (* Goal: @eventually T P (@Cons T e s) *) apply E0. (* Goal: @weak_until T J P s *) assumption. Qed. (* weak_until and eventually facts *) Lemma weak_until_Cons : forall (x: T) (s: infseq T) J P, weak_until J P (Cons x s) -> P (Cons x s) \/ (J (Cons x s) /\ weak_until J P s). Proof using. (* Goal: forall (x : T) (s : infseq T) (J P : forall _ : infseq T, Prop) (_ : @weak_until T J P (@Cons T x s)), or (P (@Cons T x s)) (and (J (@Cons T x s)) (@weak_until T J P s)) *) intros x s J P un. (* Goal: or (P (@Cons T x s)) (and (J (@Cons T x s)) (@weak_until T J P s)) *) change (P (Cons x s) \/ (J (Cons x s) /\ weak_until J P (tl (Cons x s)))). (* Goal: or (P (@Cons T x s)) (and (J (@Cons T x s)) (@weak_until T J P (@tl T (@Cons T x s)))) *) destruct un; intuition. Qed. Lemma weak_until_always : forall (J J' P : infseq T -> Prop) s, weak_until J P s -> always J' s -> weak_until (J' /\_ J) P s. Proof using. (* Goal: forall (s : infseq T) (_ : @release T J P s), @release T K Q s *) cofix cf. (* Goal: forall (J J' P : forall _ : infseq T, Prop) (s : infseq T) (_ : @weak_until T J P s) (_ : @always T J' s), @weak_until T (@and_tl T J' J) P s *) intros J J' P s Hweak Halways. (* Goal: @and_tl T P Q s *) destruct s. (* Goal: @weak_until T (@and_tl T J' J) P (@Cons T t s) *) inversion Hweak. - now eauto using W0. - inversion Halways. (* Goal: @weak_until T J P (@Cons T x s) *) eapply W_tl. + now unfold and_tl. (* Goal: @release T K Q (@tl T (@Cons T x s)) *) + simpl. now eauto. Qed. Lemma until_weak_until : forall (J P : infseq T -> Prop) (s : infseq T), until J P s -> weak_until J P s. Proof using. (* Goal: forall (J P : forall _ : infseq T, Prop) (s : infseq T) (_ : @until T J P s), @weak_until T J P s *) intros J P s un. (* Goal: False *) induction un. (* Goal: @weak_until T J P s *) - apply W0. assumption. - apply W_tl; trivial. Qed. Lemma eventually_Cons : forall (x: T) (s: infseq T) P, eventually P (Cons x s) -> P (Cons x s) \/ eventually P s. Proof using. (* Goal: forall (x : T) (s : infseq T) (P : forall _ : infseq T, Prop) (_ : @eventually T P (@Cons T x s)), or (P (@Cons T x s)) (@eventually T P s) *) intros x s P al. change (P (Cons x s) \/ eventually P (tl (Cons x s))). case al; auto. Qed. Lemma eventually_trans : forall (P Q inv: infseq T -> Prop), (forall x s, inv (Cons x s) -> inv s) -> (forall s, inv s -> P s -> eventually Q s) -> forall s, inv s -> eventually P s -> eventually Q s. Proof using. (* Goal: forall (P Q inv : forall _ : infseq T, Prop) (_ : forall (x : T) (s : infseq T) (_ : inv (@Cons T x s)), inv s) (_ : forall (s : infseq T) (_ : inv s) (_ : P s), @eventually T Q s) (s : infseq T) (_ : inv s) (_ : @eventually T P s), @eventually T Q s *) intros P Q inv is_inv PeQ s invs ev. induction ev as [s Ps | x s ev IHev]. (* Goal: @weak_until T J P s *) - apply PeQ; assumption. (* Goal: @weak_until T J P s *) - constructor 2. apply IHev. apply is_inv with x; assumption. Qed. Lemma not_eventually : forall (P : infseq T -> Prop), forall x s, ~ eventually P (Cons x s) -> ~ eventually P s. Proof using. (* Goal: forall (P : forall _ : infseq T, Prop) (x : T) (s : infseq T) (_ : not (@eventually T P (@Cons T x s))), not (@eventually T P s) *) intros P x s evCP evP. (* Goal: False *) contradict evCP. (* Goal: @eventually T P (@Cons T e s) *) apply E_next. (* Goal: @weak_until T J P s *) assumption. Qed. Lemma eventually_next : forall (s: infseq T) P, eventually (next P) s -> eventually P s. Proof using. (* Goal: forall (s : infseq T) (P : forall _ : infseq T, Prop) (_ : @eventually T (@next T P) s), @eventually T P s *) intros e P ev. induction ev as [(x, s) Ps | x s ev induc_hyp]. - constructor 2; constructor 1; exact Ps. - constructor 2. apply induc_hyp. Qed. Lemma eventually_always_cumul : forall (s: infseq T) P Q, eventually P s -> always Q s -> eventually (P /\_ always Q) s. Proof using. (* Goal: forall (s : infseq T) (P Q : forall _ : infseq T, Prop) (_ : @eventually T P s) (_ : @always T Q s), @eventually T (@and_tl T P (@always T Q)) s *) induction 1 as [s Ps | x s evPs induc_hyp]; intro al. (* Goal: @weak_until T J P s *) - constructor 1. split; assumption. - constructor 2. apply induc_hyp. eapply always_invar; eauto. Qed. Lemma eventually_weak_until_cumul : forall (s: infseq T) P J, eventually P s -> weak_until J P s -> eventually (P /\_ weak_until J P) s. Proof using. (* Goal: forall (s : infseq T) (P J : forall _ : infseq T, Prop) (_ : @eventually T P s) (_ : @weak_until T J P s), @eventually T (@and_tl T P (@weak_until T J P)) s *) intros s P J ev. induction ev as [s Ps | x s evPs induc_hyp]. (* Goal: @weak_until T J P s *) - intro un. constructor 1. split; assumption. - intro unxs. case (weak_until_Cons _ _ _ _ unxs). (* Goal: @weak_until T J P s *) * intro Pxs. constructor 1; split; assumption. (* Goal: @eventually T Q (@Cons T x s1) *) * intros (_, uns). constructor 2. apply induc_hyp. exact uns. Qed. Lemma weak_until_eventually : forall (P Q J: infseq T -> Prop), (forall s, J s -> P s -> Q s) -> forall s, J s -> weak_until J Q s -> eventually P s -> eventually Q s. Proof using. (* Goal: forall (P Q J : forall _ : infseq T, Prop) (_ : forall (s : infseq T) (_ : J s) (_ : P s), Q s) (s : infseq T) (_ : J s) (_ : @weak_until T J Q s) (_ : @eventually T P s), @eventually T Q s *) intros P Q J impl s Js J_weak_until_Q ev. (* Goal: @eventually T Q s *) genclear J_weak_until_Q; genclear Js. (* Goal: forall (_ : J s) (_ : @weak_until T J Q s), @eventually T Q s *) induction ev as [s Ps | x s ev induc_hyp]. (* Goal: @weak_until T J P s *) - intros Js J_weak_until_Q. constructor 1. apply impl; assumption. - intros _ J_weak_until_Q. cut (s = tl (Cons x s)); [idtac | reflexivity]. (* Goal: forall _ : @eq (infseq T) s (@tl T (@Cons T x s)), @eventually T Q (@Cons T x s) *) case J_weak_until_Q; clear J_weak_until_Q x. (* Goal: @weak_until T J P s *) * constructor 1; assumption. * intros (x, s1) _ J_weak_until_Q e; simpl in *. (* Goal: @eventually T Q (@Cons T x s1) *) constructor 2. generalize e J_weak_until_Q; clear e x. (* trick: keep J_weak_until_Q!! *) (* Goal: forall (_ : @eq (infseq T) s s1) (_ : @weak_until T J Q s1), @eventually T Q s1 *) case J_weak_until_Q; clear J_weak_until_Q s1. (* Goal: @weak_until T J P s *) + clearall. constructor 1; assumption. + intros s2 Js2 _ e J_weak_until_Q2. rewrite e in induc_hyp; clear e. (* Goal: @weak_until T J P s *) apply induc_hyp; assumption. Qed. Lemma eventually_or_tl_intror : forall (P Q : infseq T -> Prop) s, eventually Q s -> eventually (P \/_ Q) s. Proof using. (* Goal: forall (P Q : forall _ : infseq T, Prop) (s : infseq T) (_ : @eventually T (@or_tl T P Q) s), or (@eventually T P s) (@eventually T Q s) *) induction 1; firstorder using E0, E_next. Qed. Lemma eventually_or_tl_introl : forall (P Q : infseq T -> Prop) s, eventually P s -> eventually (P \/_ Q) s. Proof using. (* Goal: forall (P Q : forall _ : infseq T, Prop) (s : infseq T) (_ : @eventually T (@or_tl T P Q) s), or (@eventually T P s) (@eventually T Q s) *) induction 1; firstorder using E0, E_next. Qed. Lemma eventually_or_tl_or : forall (P Q : infseq T -> Prop) s, eventually (P \/_ Q) s -> eventually P s \/ eventually Q s. Proof using. (* Goal: forall (P Q : forall _ : infseq T, Prop) (s : infseq T) (_ : @eventually T (@or_tl T P Q) s), or (@eventually T P s) (@eventually T Q s) *) induction 1; firstorder using E0, E_next. Qed. (* until facts *) Lemma until_Cons : forall (x: T) (s: infseq T) J P, until J P (Cons x s) -> P (Cons x s) \/ (J (Cons x s) /\ until J P s). Proof using. (* Goal: forall (x : T) (s : infseq T) (J P : forall _ : infseq T, Prop) (_ : @until T J P (@Cons T x s)), or (P (@Cons T x s)) (and (J (@Cons T x s)) (@until T J P s)) *) intros x s J P ul. (* Goal: @always T P s *) change (P (Cons x s) \/ (J (Cons x s) /\ until J P (tl (Cons x s)))). case ul; auto. Qed. Lemma until_eventually : forall (J P : infseq T -> Prop), forall s, until J P s -> eventually P s. Proof using. (* Goal: forall (J P : forall _ : infseq T, Prop) (s : infseq T) (_ : @until T J P s), @eventually T P s *) intros P J s unP. (* Goal: @eventually T J s *) induction unP. (* Goal: @weak_until T J P s *) - apply E0; assumption. (* Goal: @weak_until T J P s *) - apply E_next; assumption. Qed. (* release facts *) Lemma release_Cons : forall (x: T) (s: infseq T) J P, release J P (Cons x s) -> P (Cons x s) /\ (J (Cons x s) \/ release J P s). Proof using. (* Goal: forall (x : T) (s : infseq T) (J P : forall _ : infseq T, Prop) (_ : @release T J P (@Cons T x s)), and (P (@Cons T x s)) (or (J (@Cons T x s)) (@release T J P s)) *) intros x s J P rl. (* Goal: and (P (@Cons T x s)) (or (J (@Cons T x s)) (@release T J P s)) *) change (P (Cons x s) /\ (J (Cons x s) \/ release J P (tl (Cons x s)))). (* Goal: and (P (@Cons T x s)) (or (J (@Cons T x s)) (@release T J P (@tl T (@Cons T x s)))) *) destruct rl; intuition. Qed. (* inf_often and continuously facts *) Lemma inf_often_invar : forall (x: T) (s: infseq T) P, inf_often P (Cons x s) -> inf_often P s. Proof using. (* Goal: forall (P : forall _ : infseq T, Prop) (_ : @always T P (@Cons T x s)), @always T P s *) intros x s P; apply always_invar. Qed. Lemma continuously_invar : forall (x: T) (s: infseq T) P, continuously P (Cons x s) -> continuously P s. Proof using. (* Goal: forall (x : T) (s : infseq T) (P : forall _ : infseq T, Prop) (_ : @continuously T P (@Cons T x s)), @continuously T P s *) intros x s P cny. (* Goal: @continuously T P s *) apply eventually_Cons in cny. (* Goal: @continuously T P s *) case cny; trivial. (* Goal: forall _ : @always T P (@Cons T x s), @continuously T P s *) intro alP. (* Goal: @eventually T P (@Cons T e s) *) apply E0. (* Goal: @weak_until T J P s *) apply always_invar in alP; assumption. Qed. Lemma continuously_and_tl : forall (P Q : infseq T -> Prop) (s : infseq T), continuously P s -> continuously Q s -> continuously (P /\_ Q) s. Proof using. (* Goal: forall (P Q : forall _ : infseq T, Prop) (s : infseq T) (_ : @continuously T P s) (_ : @continuously T Q s), @continuously T (@and_tl T P Q) s *) intros P Q s cnyP. (* Goal: forall _ : @continuously T Q s, @continuously T (@and_tl T P Q) s *) induction cnyP as [s alP|]. - intro cnyQ. (* Goal: @continuously T (@and_tl T P Q) s *) induction cnyQ. (* Goal: @eventually T P (@Cons T e s) *) apply E0. (* Goal: @always T (@and_tl T P Q) s *) (* Goal: @continuously T (@and_tl T P Q) (@Cons T x s) *) apply always_and_tl; trivial. (* Goal: @eventually T P (@Cons T e s) *) apply E_next. (* Goal: @eventually T (@always T (@and_tl T P Q)) s *) apply IHcnyQ. (* Goal: @weak_until T J P s *) apply always_invar in alP; assumption. - intro cnyQ. (* Goal: @eventually T P (@Cons T e s) *) apply E_next. (* Goal: @always T (@eventually T P) (@tl T (@Cons T x s)) *) apply IHcnyP. (* Goal: @weak_until T J P s *) apply continuously_invar in cnyQ; assumption. Qed. Lemma continuously_inf_often : forall (P : infseq T -> Prop) (s : infseq T), continuously P s -> inf_often P s. Proof using. (* Goal: forall (P : forall _ : infseq T, Prop) (s : infseq T) (_ : @always T (@not_tl T P) s), not (@eventually T P s) *) intros P. (* Goal: forall (s : infseq T) (_ : @weak_until T J P s) (_ : @always T (@not_tl T P) s), @always T J s *) cofix c. (* Goal: forall (s : infseq T) (_ : @continuously T P s), @inf_often T P s *) intros s cnyP. (* Goal: False *) induction cnyP. (* Goal: @weak_until T J P s *) - apply always_inf_often. assumption. (* Goal: @always T (@not_tl T P) (@Cons T e s) *) - apply Always. (* Goal: @weak_until T J P s *) * apply E_next. destruct s as [s x']. apply always_now in IHcnyP. assumption. * apply IHcnyP. Qed. (* monotony *) Lemma now_monotonic : forall (P Q: T -> Prop), (forall x, P x -> Q x) -> forall s, now P s -> now Q s. Proof using. (* Goal: @release T K Q (@tl T (@Cons T x s)) *) intros P Q PQ (x, s) nP; simpl. apply PQ. assumption. Qed. Lemma next_monotonic : forall (P Q: infseq T -> Prop), (forall s, P s -> Q s) -> forall s, next P s -> next Q s. Proof using. (* Goal: Q (@Cons T x s) *) intros P Q PQ [x s]; apply PQ. Qed. Lemma consecutive_monotonic : forall (P Q: T -> T -> Prop), (forall x y, P x y -> Q x y) -> forall s, consecutive P s -> consecutive Q s. Proof using. (* Goal: @release T K Q (@tl T (@Cons T x s)) *) intros P Q PQ (x, (y, s)) nP; simpl. apply PQ. assumption. Qed. Lemma always_monotonic : forall (P Q: infseq T -> Prop), (forall s, P s -> Q s) -> forall s, always P s -> always Q s. Proof using. (* Goal: forall (s : infseq T) (_ : @release T J P s), @release T K Q s *) intros P Q PQ. cofix cf. intros(x, s) a. (* Goal: @release T K Q (@tl T (@Cons T x s)) *) generalize (always_Cons x s P a); simpl; intros (a1, a2). constructor; simpl. (* Goal: @weak_until T J P s *) - apply PQ. assumption. (* Goal: @weak_until T J P s *) - apply cf. assumption. Qed. Lemma weak_until_monotonic : forall (P Q J K: infseq T -> Prop), (forall s, P s -> Q s) -> (forall s, J s -> K s) -> forall s, weak_until J P s -> weak_until K Q s. Proof using. (* Goal: forall (s : infseq T) (_ : @release T J P s), @release T K Q s *) intros P Q J K PQ JK. cofix cf. intros(x, s) un. (* Goal: @release T K Q (@tl T (@Cons T x s)) *) generalize (weak_until_Cons x s J P un); simpl. intros [Pxs | (Jxs, uns)]. - constructor 1; simpl; auto. - constructor 2; simpl; auto. Qed. Lemma until_monotonic : forall (P Q J K: infseq T -> Prop), (forall s, P s -> Q s) -> (forall s, J s -> K s) -> forall s, until J P s -> until K Q s. Proof using. (* Goal: forall (P Q J K : forall _ : infseq T, Prop) (_ : forall (s : infseq T) (_ : P s), Q s) (_ : forall (s : infseq T) (_ : J s), K s) (s : infseq T) (_ : @until T J P s), @until T K Q s *) intros P Q J K PQ JK s unJP. (* Goal: @until T K Q s *) induction unJP. (* Goal: @weak_until T J P s *) - apply U0, PQ; assumption. - apply U_next. (* Goal: @weak_until T J P s *) * apply JK; assumption. (* Goal: @weak_until T J P s *) * assumption. Qed. Lemma release_monotonic : forall (P Q J K: infseq T -> Prop), (forall s, P s -> Q s) -> (forall s, J s -> K s) -> forall s, release J P s -> release K Q s. Proof using. (* Goal: forall (P Q J K : forall _ : infseq T, Prop) (_ : forall (s : infseq T) (_ : P s), Q s) (_ : forall (s : infseq T) (_ : J s), K s) (s : infseq T) (_ : @release T J P s), @release T K Q s *) intros P Q J K PQ JK. (* Goal: forall (s : infseq T) (_ : @release T J P s), @release T K Q s *) cofix cf. intros [x s] rl. (* Goal: @release T K Q (@tl T (@Cons T x s)) *) generalize (release_Cons x s J P rl); simpl. (* Goal: forall _ : and (P (@Cons T x s)) (or (J (@Cons T x s)) (@release T J P s)), @release T K Q (@Cons T x s) *) intros [Pxs rlCJP]. (* Goal: @release T K Q (@Cons T x s) *) case rlCJP; intros rlJP. - apply R0. (* Goal: @weak_until T J P s *) * apply PQ; assumption. (* Goal: @weak_until T J P s *) * apply JK; assumption. - apply R_tl. (* Goal: @weak_until T J P s *) * apply PQ; assumption. (* Goal: @release T K Q (@tl T (@Cons T x s)) *) * simpl. (* Goal: @weak_until T J P s *) apply cf. assumption. Qed. Lemma eventually_monotonic : forall (P Q J: infseq T -> Prop), (forall x s, J (Cons x s) -> J s) -> (forall s, J s -> P s -> Q s) -> forall s, J s -> eventually P s -> eventually Q s. Proof using. (* Goal: forall (P Q J : forall _ : infseq T, Prop) (_ : forall (x : T) (s : infseq T) (_ : J (@Cons T x s)), J s) (_ : forall (s : infseq T) (_ : J s) (_ : P s), Q s) (s : infseq T) (_ : J s) (_ : @eventually T P s), @eventually T Q s *) intros P Q J is_inv JPQ s Js ev. (* Goal: @weak_until T J P s *) apply (eventually_trans P Q J is_inv); try assumption. (* Goal: @weak_until T J P s *) intros; constructor 1. apply JPQ; assumption. Qed. (* corollary which turns out to be too weak in practice *) Lemma eventually_monotonic_simple : forall (P Q: infseq T -> Prop), (forall s, P s -> Q s) -> forall s, eventually P s -> eventually Q s. Proof using. (* Goal: forall (P Q : forall _ : infseq T, Prop) (_ : forall (s : infseq T) (_ : P s), Q s) (s : infseq T) (_ : @eventually T P s), @eventually T Q s *) intros P Q PQ s. (* Goal: @always T P s *) apply (eventually_monotonic P Q True_tl); auto. Qed. Lemma inf_often_monotonic : forall (P Q : infseq T -> Prop), (forall s, P s -> Q s) -> forall s, inf_often P s -> inf_often Q s. Proof using. (* Goal: forall (P Q : forall _ : infseq T, Prop) (_ : forall (s : infseq T) (_ : P s), Q s) (s : infseq T) (_ : @continuously T P s), @continuously T Q s *) intros P Q impl. (* Goal: forall (s : infseq T) (_ : @always T P s), @always T Q s *) apply always_monotonic. (* Goal: forall (s : infseq T) (_ : @continuously T P s), @continuously T Q s *) apply eventually_monotonic_simple. (* Goal: @weak_until T J P s *) assumption. Qed. Lemma cumul_eventually_always : forall (P Q : infseq T -> Prop) s, always P s -> eventually Q s -> eventually (P /\_ Q) s. Proof using. (* Goal: forall (P Q : forall _ : infseq T, Prop) (s : infseq T) (_ : @always T P s) (_ : @eventually T Q s), @eventually T (@and_tl T P Q) s *) intros until 1. (* Goal: forall _ : @eventually T Q s, @eventually T (@and_tl T P Q) s *) intro H_eventually. (* Goal: @eventually T (@and_tl T P Q) s *) induction H_eventually. - apply E0. (* Goal: @and_tl T P Q s *) destruct s. (* Goal: @and_tl T P Q (@Cons T t s) *) firstorder using always_Cons. - eauto using E_next, always_invar. Qed. Lemma cumul_inf_often_always : forall (P Q : infseq T -> Prop) s, always P s -> inf_often Q s -> inf_often (P /\_ Q) s. Proof using. (* Goal: forall (s : infseq T) (_ : @and_tl T invariant P s), Q s *) intros. eapply always_monotonic with (P := always P /\_ eventually Q) (Q := eventually (P /\_ Q)). - intros. unfold and_tl in * |-. (* Goal: @eventually T (@and_tl T P Q) s0 *) firstorder using cumul_eventually_always. - eapply always_and_tl; eauto using always_always. Qed. (** This theorem is an analog of eventually_monotonic. *) Lemma inf_often_monotonic_invar : forall (invariant P Q : infseq T -> Prop), (forall s, invariant s -> P s -> Q s) -> forall ex, always invariant ex -> inf_often P ex -> inf_often Q ex. Proof using. (* Goal: forall (s : infseq T) (_ : @and_tl T invariant P s), Q s *) intros. (* Goal: @inf_often T Q ex *) eapply inf_often_monotonic with (P:=invariant /\_ P). - intros. unfold and_tl in *; firstorder. - eapply cumul_inf_often_always; eauto. Qed. Lemma continuously_monotonic : forall (P Q : infseq T -> Prop), (forall s, P s -> Q s) -> forall s, continuously P s -> continuously Q s. Proof using. (* Goal: forall (P Q : forall _ : infseq T, Prop) (_ : forall (s : infseq T) (_ : P s), Q s) (s : infseq T) (_ : @continuously T P s), @continuously T Q s *) intros P Q impl. (* Goal: forall (s : infseq T) (_ : @continuously T P s), @continuously T Q s *) apply eventually_monotonic_simple. (* Goal: forall (s : infseq T) (_ : @always T P s), @always T Q s *) apply always_monotonic. (* Goal: @weak_until T J P s *) assumption. Qed. (* not_tl inside operators *) Lemma not_eventually_always_not : forall (P : infseq T -> Prop) (s : infseq T), ~ eventually P s -> always (~_ P) s. Proof using. (* Goal: forall (P : forall _ : infseq T, Prop) (s : infseq T) (_ : @always T (@not_tl T P) s), not (@eventually T P s) *) intros P. (* Goal: forall (s : infseq T) (_ : @weak_until T J P s) (_ : @always T (@not_tl T P) s), @always T J s *) cofix c. (* Goal: forall (s : infseq T) (_ : not (@eventually T P s)), @always T (@not_tl T P) s *) intros s evP. (* Goal: not (@inf_often T P s) *) destruct s as [e s]. (* Goal: @always T (@not_tl T P) (@Cons T e s) *) apply Always. * unfold not_tl. (* Goal: not (P (@Cons T e s)) *) intro Pn. (* Goal: False *) case evP. (* Goal: @eventually T P (@Cons T e s) *) apply E0. (* Goal: @weak_until T J P s *) assumption. (* Goal: @always T (@not_tl T P) (@tl T (@Cons T e s)) *) * apply c. (* Goal: not (@eventually T P (@tl T (@Cons T e s))) *) intro evPn. (* Goal: False *) contradict evP. (* Goal: @eventually T P (@Cons T e s) *) apply E_next. (* Goal: @weak_until T J P s *) assumption. Qed. Lemma always_not_eventually : forall (P : infseq T -> Prop) (s : infseq T), always (~_ P) s -> ~ eventually P s. Proof using. (* Goal: forall (P : forall _ : infseq T, Prop) (s : infseq T) (_ : @always T (@not_tl T P) s), not (@eventually T P s) *) intros P. (* Goal: forall (s : infseq T) (_ : @always T (@not_tl T P) s), not (@eventually T P s) *) intros s alP evP. (* Goal: False *) induction evP. * destruct s as [e s]. (* Goal: @always T J (@Cons T e s) *) apply always_Cons in alP. (* Goal: @always T J (@Cons T e s) *) destruct alP as [nP alP]. (* Goal: @always T J (@Cons T e s) *) unfold not_tl in nP. (* Goal: @weak_until T J P s *) contradict nP; assumption. * apply always_invar in alP. (* Goal: @weak_until T J P s *) contradict IHevP; assumption. Qed. Lemma eventually_not_always : forall (P : infseq T -> Prop) (s : infseq T), eventually (~_ P) s -> ~ always P s. Proof using. (* Goal: forall (P : forall _ : infseq T, Prop) (s : infseq T) (_ : @eventually T (@not_tl T P) s), not (@always T P s) *) intros P s eP alP. (* Goal: False *) induction eP. - destruct s as [x s]. (* Goal: False *) unfold not_tl in H. (* Goal: False *) contradict H. (* Goal: @always T J (@Cons T e s) *) apply always_Cons in alP. (* Goal: P (@Cons T x s) *) destruct alP as [PC alP]. (* Goal: @weak_until T J P s *) assumption. - apply always_invar in alP. (* Goal: False *) contradict IHeP. (* Goal: @weak_until T J P s *) assumption. Qed. Lemma weak_until_always_not_always : forall (J P : infseq T -> Prop) (s : infseq T), weak_until J P s -> always (~_ P) s -> always J s. Proof using. (* Goal: forall (J P : forall _ : infseq T, Prop) (s : infseq T) (_ : @weak_until T J P s) (_ : @always T (@not_tl T P) s), @always T J s *) intros J P. (* Goal: forall (s : infseq T) (_ : @weak_until T J P s) (_ : @always T (@not_tl T P) s), @always T J s *) cofix c. (* Goal: forall (s : infseq T) (_ : @weak_until T J P s) (_ : @always T (@not_tl T P) s), @always T J s *) intros s unJP alP. (* Goal: not (@inf_often T P s) *) destruct s as [e s]. (* Goal: @always T J (@Cons T e s) *) apply weak_until_Cons in unJP. (* Goal: @always T J (@Cons T e s) *) case unJP. - intro PC. (* Goal: @always T J (@Cons T e s) *) apply always_Cons in alP. (* Goal: @always T J (@Cons T e s) *) destruct alP as [nP alP]. (* Goal: @always T J (@Cons T e s) *) unfold not_tl in nP. (* Goal: @always T J (@Cons T e s) *) contradict nP. (* Goal: @weak_until T J P s *) assumption. - intros Jun. (* Goal: @always T J (@Cons T e s) *) destruct Jun as [JC unJPs]. (* Goal: @always T J (@Cons T e s) *) apply Always; trivial. (* Goal: @always T J (@tl T (@Cons T e s)) *) apply c; trivial. (* Goal: @always T P s *) apply always_invar in alP. (* Goal: @weak_until T J P s *) assumption. Qed. Lemma weak_until_latch_eventually : forall (P Q : infseq T -> Prop) ex, weak_until (P /\_ ~_ Q) (P /\_ Q) ex -> eventually Q ex -> eventually (P /\_ Q) ex. Proof using. (* Goal: forall (P Q : forall _ : infseq T, Prop) (ex : infseq T) (_ : @weak_until T (@and_tl T P (@not_tl T Q)) (@and_tl T P Q) ex) (_ : @eventually T Q ex), @eventually T (@and_tl T P Q) ex *) intros P Q ex H_w. induction 1; inversion H_w; firstorder using E0, E_next. Qed. Lemma always_not_eventually_not : forall (P : infseq T -> Prop) (s : infseq T), always P s -> ~ eventually (~_ P) s. Proof using. (* Goal: forall (P : forall _ : infseq T, Prop) (s : infseq T) (_ : @always T P s), not (@eventually T (@not_tl T P) s) *) intros P s alP evP. (* Goal: False *) induction evP. - unfold not_tl in H. (* Goal: False *) contradict H. (* Goal: False *) destruct s as [x s]. (* Goal: P (@Cons T x s) *) apply always_now in alP. (* Goal: @weak_until T J P s *) assumption. - contradict IHevP. (* Goal: @always T P s *) apply always_invar in alP. (* Goal: @weak_until T J P s *) assumption. Qed. Lemma continuously_not_inf_often : forall (P : infseq T -> Prop) (s : infseq T), continuously (~_ P) s -> ~ inf_often P s. Proof using. (* Goal: forall (P : forall _ : infseq T, Prop) (s : infseq T) (_ : @continuously T (@not_tl T P) s), not (@inf_often T P s) *) intros P s cnyP. (* Goal: False *) induction cnyP. - destruct s as [e s]. (* Goal: not (@inf_often T P (@Cons T e s)) *) intros ifP. (* Goal: False *) apply always_now in ifP. (* Goal: False *) induction ifP. * destruct s0 as [e0 s0]. (* Goal: False *) apply always_now in H. (* Goal: False *) unfold not_tl in H. (* Goal: False *) contradict H. (* Goal: @inf_often T P s *) trivial. * apply always_invar in H. (* Goal: False *) contradict IHifP. (* Goal: @inf_often T P s *) trivial. - intro ioP. (* Goal: False *) apply always_invar in ioP. (* Goal: False *) contradict IHcnyP. (* Goal: @inf_often T P s *) trivial. Qed. Lemma inf_often_not_continuously : forall (P : infseq T -> Prop) (s : infseq T), inf_often (~_ P) s -> ~ continuously P s. Proof using. (* Goal: forall (P : forall _ : infseq T, Prop) (s : infseq T) (_ : @inf_often T (@not_tl T P) s), not (@continuously T P s) *) intros P s ioP cnyP. (* Goal: False *) induction cnyP. - destruct s as [x s]. (* Goal: False *) apply always_now in ioP. (* Goal: False *) induction ioP. * destruct s0 as [x' s0]. (* Goal: False *) apply always_now in H. (* Goal: False *) unfold not_tl in H0. (* Goal: False *) contradict H0. (* Goal: @weak_until T J P s *) assumption. * apply always_invar in H. (* Goal: False *) contradict IHioP. (* Goal: @weak_until T J P s *) assumption. - apply inf_often_invar in ioP. (* Goal: False *) contradict IHcnyP. (* Goal: @weak_until T J P s *) assumption. Qed. Lemma release_not_until : forall (J P : infseq T -> Prop) (s : infseq T), release J P s -> ~ until (~_ J) (~_ P) s. Proof using. (* Goal: forall (J P : forall _ : infseq T, Prop) (s : infseq T) (_ : @release T J P s), not (@until T (@not_tl T J) (@not_tl T P) s) *) intros J P s rl un. (* Goal: False *) induction un as [s Ps |x s Js IHun IH]. - destruct s as [x s]. (* Goal: False *) unfold not_tl in Ps. (* Goal: False *) apply release_Cons in rl. (* Goal: False *) destruct rl as [Psr rl]. (* Goal: False *) contradict Ps. (* Goal: @weak_until T J P s *) assumption. - apply release_Cons in rl. (* Goal: False *) destruct rl as [Ps rl]. (* Goal: False *) unfold not_tl in Js. (* Goal: @inf_often T P s *) case rl; trivial. Qed. Lemma until_not_release : forall (J P : infseq T -> Prop) (s : infseq T), until J P s -> ~ release (~_ J) (~_ P) s. Proof using. (* Goal: forall (J P : forall _ : infseq T, Prop) (s : infseq T) (_ : @until T J P s), not (@release T (@not_tl T J) (@not_tl T P) s) *) intros J P s un rl. (* Goal: False *) induction un. - destruct s as [x s]. (* Goal: False *) apply release_Cons in rl. (* Goal: False *) destruct rl as [Ps rl]. (* Goal: False *) unfold not_tl in Ps. (* Goal: False *) contradict Ps. (* Goal: @weak_until T J P s *) assumption. - apply release_Cons in rl. (* Goal: False *) destruct rl as [Ps rl]. (* Goal: @inf_often T P s *) case rl; trivial. (* Goal: forall _ : @not_tl T J (@Cons T x s), False *) unfold not_tl. (* Goal: forall _ : not (J (@Cons T x s)), False *) intros Js. (* Goal: False *) contradict Js. (* Goal: @weak_until T J P s *) assumption. Qed. Lemma weak_until_not_until : forall (J P : infseq T -> Prop) (s : infseq T), weak_until (J /\_ ~_ P) (~_ J /\_ ~_ P) s -> ~ until J P s. Proof using. (* Goal: forall (J P : forall _ : infseq T, Prop) (s : infseq T) (_ : @weak_until T (@and_tl T J (@not_tl T P)) (@and_tl T (@not_tl T J) (@not_tl T P)) s), not (@until T J P s) *) intros J P s wu un. (* Goal: False *) induction un. - destruct s as [x s]. (* Goal: False *) apply weak_until_Cons in wu. (* Goal: False *) case wu; unfold not_tl, and_tl. * intros [Js Ps]. (* Goal: False *) contradict Ps. (* Goal: @weak_until T J P s *) assumption. * intros [[Js Ps] wun]. (* Goal: False *) contradict Ps. (* Goal: @weak_until T J P s *) assumption. - apply weak_until_Cons in wu. (* Goal: False *) case wu. * unfold not_tl, and_tl. (* Goal: forall _ : and (not (J (@Cons T x s))) (not (P (@Cons T x s))), False *) intros [Js Ps]. (* Goal: False *) contradict Js. (* Goal: @weak_until T J P s *) assumption. * intros [[Js Ps] wun]. (* Goal: False *) contradict IHun. (* Goal: @weak_until T J P s *) assumption. Qed. Lemma until_not_weak_until : forall (J P : infseq T -> Prop) (s : infseq T), until (J /\_ ~_ P) (~_ J /\_ ~_ P) s -> ~ weak_until J P s. Proof using. (* Goal: forall (J P : forall _ : infseq T, Prop) (s : infseq T) (_ : @until T (@and_tl T J (@not_tl T P)) (@and_tl T (@not_tl T J) (@not_tl T P)) s), not (@weak_until T J P s) *) intros J P s un wun. (* Goal: False *) induction un as [s JPs | x s JPs IHun IH]; unfold not_tl, and_tl in JPs; destruct JPs as [Js Ps]. - destruct s as [x s]. (* Goal: False *) apply weak_until_Cons in wun. (* Goal: @inf_often T P s *) case wun; trivial. (* Goal: forall _ : and (J (@Cons T x s)) (@weak_until T J P s), False *) intros [JCs wu]. (* Goal: False *) contradict Js. (* Goal: @weak_until T J P s *) assumption. - apply weak_until_Cons in wun. (* Goal: False *) case wun. * intros PCs. (* Goal: False *) contradict Ps. (* Goal: @weak_until T J P s *) assumption. * intros [JCs wu]. (* Goal: False *) contradict IH. (* Goal: @weak_until T J P s *) assumption. Qed. (* connector facts *) Lemma and_tl_comm : forall (P Q : infseq T -> Prop) (s : infseq T), (P /\_ Q) s <-> (Q /\_ P) s. Proof using. (* Goal: forall (P Q : forall _ : infseq T, Prop) (s : infseq T), iff (@and_tl T P Q s) (@and_tl T Q P s) *) intros; split; unfold and_tl; apply and_comm. Qed. Lemma and_tl_assoc : forall (P Q R : infseq T -> Prop) (s : infseq T), ((P /\_ Q) /\_ R) s <-> (P /\_ Q /\_ R) s. Proof using. (* Goal: forall (P Q R : forall _ : infseq T, Prop) (s : infseq T), iff (@and_tl T (@and_tl T P Q) R s) (@and_tl T P (@and_tl T Q R) s) *) intros; split; unfold and_tl; apply and_assoc. Qed. Lemma or_tl_comm : forall (P Q : infseq T -> Prop) (s : infseq T), (P \/_ Q) s <-> (Q \/_ P) s. Proof using. (* Goal: forall (P Q : forall _ : infseq T, Prop) (s : infseq T), iff (@or_tl T P Q s) (@or_tl T Q P s) *) intros; split; unfold or_tl; apply or_comm. Qed. Lemma or_tl_assoc : forall (P Q R : infseq T -> Prop) (s : infseq T), ((P \/_ Q) \/_ R) s <-> (P \/_ Q \/_ R) s. Proof using. (* Goal: forall (P Q R : forall _ : infseq T, Prop) (s : infseq T), iff (@or_tl T (@or_tl T P Q) R s) (@or_tl T P (@or_tl T Q R) s) *) intros; split; unfold or_tl; apply or_assoc. Qed. Lemma not_tl_or_tl : forall (P Q : infseq T -> Prop) (s : infseq T), (~_ (P \/_ Q)) s <-> ((~_ P) /\_ (~_ Q)) s. Proof using. (* Goal: forall (P Q : forall _ : infseq T, Prop) (s : infseq T), iff (@not_tl T (@or_tl T P Q) s) (@and_tl T (@not_tl T P) (@not_tl T Q) s) *) intros P Q s; unfold not_tl, and_tl, or_tl; split; [ intros PQs | intros [Ps Qs] PQs]. (* Goal: @weak_until T J P s *) - split; intro Ps; contradict PQs; [left|right]; assumption. (* Goal: @weak_until T J P s *) - case PQs; assumption. Qed. Lemma not_tl_or_tl_and_tl : forall (P Q : infseq T -> Prop) (s : infseq T), ((~_ P) \/_ (~_ Q)) s -> (~_ (P /\_ Q)) s. Proof using. (* Goal: @weak_until T J P s *) intros P Q s; unfold not_tl, and_tl, or_tl; intros PQs [Ps Qs]; case PQs; intros nPQs; contradict nPQs; assumption. Qed. End sec_modal_op_lemmas. Arguments always_inv [T inv] _ [s] _. Arguments always_Cons [T x s P] _. Arguments always_now [T x s P] _. Arguments always_invar [T x s P] _. Arguments always_tl [T s P] _. Arguments always_not_false [T s]. Arguments always_true [T s]. Arguments always_and_tl [T P Q s] _ _. Arguments always_always1 [T P s] _. Arguments always1_always [T P s] _. Arguments always_weak_until [T J P s] _. Arguments always_release [T J P s] _. Arguments always_inf_often [T P s] _. Arguments always_continuously [T P s] _. Arguments weak_until_Cons [T x s J P] _. Arguments weak_until_always [T J J' P s] _ _. Arguments until_weak_until [T J P s] _. Arguments eventually_Cons [T x s P] _. Arguments eventually_trans [T P Q inv] _ _ [s] _ _. Arguments not_eventually [T P x s] _ _. Arguments eventually_next [T s P] _. Arguments eventually_always_cumul [T s P Q] _ _. Arguments eventually_weak_until_cumul [T s P J] _ _. Arguments weak_until_eventually [T P Q J] _ [s] _ _ _. Arguments until_Cons [T x s J P] _. Arguments until_eventually [T J P s] _. Arguments release_Cons [T x s J P] _. Arguments inf_often_invar [T x s P] _. Arguments continuously_invar [T x s P] _. Arguments continuously_and_tl [T P Q s] _ _. Arguments continuously_inf_often [T P s] _. Arguments now_monotonic [T P Q] _ [s] _. Arguments next_monotonic [T P Q] _ [s] _. Arguments consecutive_monotonic [T P Q] _ [s] _. Arguments always_monotonic [T P Q] _ [s] _. Arguments weak_until_monotonic [T P Q J K] _ _ [s] _. Arguments until_monotonic [T P Q J K] _ _ [s] _. Arguments release_monotonic [T P Q J K] _ _ [s] _. Arguments eventually_monotonic [T P Q] _ _ _ [s] _ _. Arguments eventually_monotonic_simple [T P Q] _ [s] _. Arguments inf_often_monotonic [T P Q] _ [s] _. Arguments continuously_monotonic [T P Q] _ [s] _. Arguments not_eventually_always_not [T P s] _. Arguments always_not_eventually [T P s] _ _. Arguments eventually_not_always [T P s] _ _. Arguments weak_until_always_not_always [T J P s] _ _. Arguments always_not_eventually_not [T P s] _ _. Arguments continuously_not_inf_often [T P s] _ _. Arguments inf_often_not_continuously [T P s] _ _. Arguments release_not_until [T J P s] _ _. Arguments until_not_release [T J P s] _ _. Arguments weak_until_not_until [T J P s] _ _. Arguments until_not_weak_until [T J P s] _ _. Arguments and_tl_comm [T P Q s]. Arguments and_tl_assoc [T P Q R s]. Arguments or_tl_comm [T P Q s]. Arguments or_tl_assoc [T P Q R s]. Arguments not_tl_or_tl [T P Q s]. Arguments not_tl_or_tl_and_tl [T P Q s] _ _. Ltac monotony := match goal with | [ |- now ?P ?s -> now ?Q ?s ] => apply now_monotonic | [ |- next ?P ?s -> next ?Q ?s ] => apply next_monotonic | [ |- consecutive ?P ?s -> consecutive ?Q ?s ] => apply consecutive_monotonic | [ |- always ?P ?s -> always ?Q ?s ] => apply always_monotonic | [ |- weak_until ?J ?P ?s -> weak_until ?K ?Q ?s ] => apply weak_until_monotonic | [ |- until ?J ?P ?s -> until ?K ?Q ?s ] => apply until_monotonic | [ |- release ?J ?P ?s -> release ?K ?Q ?s ] => apply release_monotonic | [ |- ?J ?s -> eventually ?P ?s -> eventually ?Q ?s ] => apply eventually_monotonic | [ |- continuously ?P ?s -> continuously ?Q ?s ] => apply continuously_monotonic | [ |- inf_often ?P ?s -> inf_often ?Q ?s ] => apply inf_often_monotonic end.
Require Import InfSeqExt.infseq. Require Import InfSeqExt.exteq. (* --------------------------------------------------------------------------- *) (* Infinite subsequences *) Section sec_subseq. Variable T: Type. (* suff s s' means s is a suffix of s' *) Inductive suff (s : infseq T) : infseq T -> Prop := | sp_eq : suff s s | sp_next : forall x s0, suff s s0 -> suff s (Cons x s0). (* simple but not the most useful -- useless indeed *) CoInductive subseq : infseq T -> infseq T -> Prop := | Subseq : forall s s0 s1, suff s1 s0 -> subseq s (tl s1) -> subseq (Cons (hd s1) s) s0. CoInductive subseqs' : infseq (infseq T) -> infseq T -> Prop := | Subseqs' : forall si s0 s1, suff s1 s0 -> subseqs' si (tl s1) -> subseqs' (Cons s1 si) s0. CoInductive subseqs : infseq (infseq T) -> infseq T -> Prop := | Subseqs : forall si s, suff (hd si) s -> subseqs (tl si) (tl (hd si)) -> subseqs si s. Lemma subseqs_subseqs' : forall si s, subseqs si s -> subseqs' si s. Proof using. (* Goal: forall (si : infseq (infseq T)) (s : infseq T) (_ : subseqs' si s), subseqs si s *) cofix subsub. (* Goal: forall (si : infseq (infseq T)) (s : infseq T) (_ : subseqs' si s), subseqs si s *) intros si s su. case su; clear su si s. (* Goal: forall (si : infseq (infseq T)) (s : infseq T) (_ : suff (@hd (infseq T) si) s) (_ : subseqs (@tl (infseq T) si) (@tl T (@hd (infseq T) si))), subseqs' si s *) intros (s1, si) s0. simpl. intros su sb. constructor. - assumption. - apply subsub. assumption. Qed. Lemma subseqs'_subseqs : forall si s, subseqs' si s -> subseqs si s. (* Goal: forall (si : infseq (infseq T)) (s : infseq T) (_ : subseqs' si s), subseqs si s *) cofix subsub. (* Goal: forall (si : infseq (infseq T)) (s : infseq T) (_ : subseqs' si s), subseqs si s *) intros si s su. case su; clear su si s. (* Goal: forall (_ : suff (@hd (infseq T) (@Cons (infseq T) s1 si)) s0) (_ : subseqs (@tl (infseq T) (@Cons (infseq T) s1 si)) (@tl T (@hd (infseq T) (@Cons (infseq T) s1 si)))), subseqs' (@Cons (infseq T) s1 si) s0 *) intros si s0 s1 su sb. constructor; simpl. - assumption. - apply subsub. assumption. Qed. (* Relating inf subseq to infinitely often *) (* In the next lemma, always1 is bit overkill, but is just what is needed below *) Lemma subseqs_eventually : forall P si s, subseqs si s -> always1 P si -> eventually P s. Proof using. (* Goal: forall (P : forall _ : infseq T, Prop) (si : infseq (infseq T)) (s : infseq T) (_ : subseqs si s) (_ : @always1 (infseq T) P si), @eventually T P s *) intros P si s su. destruct su as [si s sf _]. (* Goal: forall _ : @always1 (infseq T) P si, @eventually T P s *) induction sf as [ | x s0 _ Hrec]; intro a. (* Goal: forall (_ : suff (@hd (infseq T) (@Cons (infseq T) s1 si)) s0) (_ : subseqs (@tl (infseq T) (@Cons (infseq T) s1 si)) (@tl T (@hd (infseq T) (@Cons (infseq T) s1 si)))), subseqs' (@Cons (infseq T) s1 si) s0 *) - constructor 1. case a; simpl. intros; assumption. - constructor 2. apply Hrec. apply a. Qed. Lemma subseqs_tl : forall si s, subseqs si (tl s) -> subseqs si s. Proof using. (* Goal: forall (si : infseq (infseq T)) (s : infseq T) (_ : subseqs si (@tl T s)), subseqs si s *) intros si (x, s) su. simpl in su. (* Goal: forall _ : @always1 (infseq T) P si, @always T (@eventually T P) (@tl T s) *) case su. clear su si s; intros si s sf su. (* Goal: mem x (@Cons T y s') *) constructor. - constructor 2. exact sf. - exact su. Qed. Theorem subseq_inf_often : forall P si s, subseqs si s -> always1 P si -> inf_often P s. Proof using. (* Goal: forall (P : forall _ : infseq T, Prop) (si : infseq (infseq T)) (s : infseq T) (_ : subseqs si s) (_ : @always1 (infseq T) P si), @inf_often T P s *) intros P. red. cofix sio. (* Goal: forall (si : infseq (infseq T)) (s : infseq T) (_ : subseqs si s) (_ : @always1 (infseq T) P si), @always T (@eventually T P) s *) intros si s su a. (* Goal: mem x (@Cons T y s') *) constructor. - apply subseqs_eventually with si; assumption. - genclear a. case su. clear su si s; intros (s0, si) s sf su a; simpl in * |- * . (* Goal: @always T (@eventually T P) (@tl T s) *) apply (sio si); clear sio. (* Goal: forall (_ : suff (@hd (infseq T) (@Cons (infseq T) s1 si)) s0) (_ : subseqs (@tl (infseq T) (@Cons (infseq T) s1 si)) (@tl T (@hd (infseq T) (@Cons (infseq T) s1 si)))), subseqs' (@Cons (infseq T) s1 si) s0 *) * induction sf; simpl. (* Goal: subseqs si (@tl T s0) *) (* Goal: subseqs si s1 *) trivial. apply subseqs_tl. assumption (* induction hyp *). * change (always1 P (tl (Cons s0 si))). case a; simpl; trivial. Qed. (* Conversely : TODO *) Inductive ex_suff (P: infseq T -> Prop) (s' : infseq T) : Prop := Esp : forall s, suff s s' -> P s -> ex_suff P s'. Theorem eventually_suff : forall P s', eventually P s' -> ex_suff P s'. Proof using. (* Goal: forall (P : forall _ : infseq T, Prop) (s' : infseq T) (_ : @eventually T P s'), ex_suff P s' *) intros P s ev. induction ev. - exists s; [ constructor | assumption]. - destruct IHev. exists s0. (* Goal: mem x s' *) * constructor; assumption. (* Goal: mem x s' *) * assumption. Qed. (* Extensional version *) Inductive suff_exteq (s : infseq T) : infseq T -> Prop := | sb_eq : forall s', exteq s s' -> suff_exteq s s' | sb_next : forall x s', suff_exteq s s' -> suff_exteq s (Cons x s'). Inductive suffb (x : T) (s : infseq T) : infseq T -> Prop := | sp_eqb : forall s', exteq (Cons x s) s' -> suffb x s s' | sp_nextb : forall y s', suffb x s s' -> suffb x s (Cons y s'). CoInductive subseqb : infseq T -> infseq T -> Prop := | Subseqb : forall x s s', suffb x s s' -> subseqb s s' -> subseqb (Cons x s) s'. Inductive mem (x : T) : infseq T -> Prop := | mem0 : forall s, mem x (Cons x s) | mem_next : forall y s, mem x s -> mem x (Cons y s). Lemma subseqb_included : forall x s, mem x s -> forall s', subseqb s s' -> mem x s'. Proof using. (* Goal: forall (x : T) (s : infseq T) (_ : mem x s) (s' : infseq T) (_ : subseqb s s'), mem x s' *) induction 1 as [| y s M IHmem]. - inversion_clear 1 as [a b c ssp _]. induction ssp as [s' ssp | ]. (* Goal: mem x (@Cons T y s') *) inversion_clear ssp. constructor. (* Goal: mem x (@Cons T y s') *) constructor. assumption. - inversion_clear 1. apply IHmem; assumption. Qed. End sec_subseq.
Require Import InfSeqExt.infseq. (* ------------------------------------------------------------------------- *) (* Extensional equality on infinite sequences *) Section sec_exteq. Variable T: Type. CoInductive exteq : infseq T -> infseq T -> Prop := exteq_intro : forall x s1 s2, exteq s1 s2 -> exteq (Cons x s1) (Cons x s2). Lemma exteq_inversion : forall (x1:T) s1 x2 s2, exteq (Cons x1 s1) (Cons x2 s2) -> x1 = x2 /\ exteq s1 s2. Proof using. (* Goal: forall (x1 : T) (s1 : infseq T) (x2 : T) (s2 : infseq T) (_ : exteq (@Cons T x1 s1) (@Cons T x2 s2)), and (@eq T x1 x2) (exteq s1 s2) *) intros x1 s1 x2 s2 e. change (hd (Cons x1 s1) = hd (Cons x2 s2) /\ exteq (tl (Cons x1 s1)) (tl (Cons x2 s2))). (* Goal: and (@eq T (@hd T (@Cons T x1 s1)) (@hd T (@Cons T x2 s2))) (exteq (@tl T (@Cons T x1 s1)) (@tl T (@Cons T x2 s2))) *) case e; clear e x1 s1 x2 s2. simpl. intros; split; trivial. Qed. Lemma exteq_refl : forall s, exteq s s. Proof using. (* Goal: extensional (@release T P Q) *) cofix cf. intros (x, s). constructor. apply cf. Qed. Lemma exteq_sym : forall s1 s2, exteq s1 s2 -> exteq s2 s1. Proof using. (* Goal: extensional (@release T P Q) *) cofix cf. destruct 1. constructor. apply cf. assumption. Qed. Lemma exteq_trans : forall s1 s2 s3, exteq s1 s2 -> exteq s2 s3 -> exteq s1 s3. Proof using. (* Goal: extensional (@release T P Q) *) cofix cf. (* Goal: forall (s1 s2 s3 : infseq T) (_ : exteq s1 s2) (_ : exteq s2 s3), exteq s1 s3 *) intros (x1, s1) (x2, s2) (x3, s3) e12 e23. (* Goal: exteq (@Cons T x1 s1) (@Cons T x3 s3) *) case (exteq_inversion _ _ _ _ e12); clear e12; intros e12 ex12. (* Goal: exteq (@Cons T x1 s1) (@Cons T x3 s3) *) case (exteq_inversion _ _ _ _ e23); clear e23; intros e23 ex23. (* Goal: @always T P (@Cons T x2 s2) *) rewrite e12; rewrite e23. constructor. apply cf with s2; assumption. Qed. End sec_exteq. Arguments exteq [T] _ _. Arguments exteq_inversion [T x1 s1 x2 s2] _. Arguments exteq_refl [T] _. Arguments exteq_sym [T] _ _ _. Arguments exteq_trans [T] _ _ _ _ _. (* --------------------------------------------------------------------------- *) (* Extensional equality and temporal logic *) Section sec_exteq_congruence. Variable T: Type. (* All useful predicates are extensional in the following sense *) Definition extensional (P: infseq T -> Prop) := forall s1 s2, exteq s1 s2 -> P s1 -> P s2. Lemma extensional_True_tl : extensional True_tl. Proof using. (* Goal: extensional (@False_tl T) *) intros s1 s2 eq; auto. Qed. Lemma extensional_False_tl : extensional False_tl. Proof using. (* Goal: extensional (@False_tl T) *) intros s1 s2 eq; auto. Qed. Lemma extensional_and_tl : forall (P Q: infseq T -> Prop), extensional P -> extensional Q -> extensional (P /\_ Q). Proof using. (* Goal: @release T P Q (@tl T (@Cons T x2 s2)) *) intros P Q eP eQ s1 s2 e. destruct e; simpl. unfold and_tl. intuition. - apply eP with (Cons x s1); [constructor; assumption | assumption]. - apply eQ with (Cons x s1); [constructor; assumption | assumption]. Qed. Lemma extensional_or_tl : forall (P Q: infseq T -> Prop), extensional P -> extensional Q -> extensional (P \/_ Q). Proof using. (* Goal: @release T P Q (@tl T (@Cons T x2 s2)) *) intros P Q eP eQ s1 s2 e. destruct e; simpl. unfold or_tl. intuition. - left; apply eP with (Cons x s1); [constructor; assumption | assumption]. - right; apply eQ with (Cons x s1); [constructor; assumption | assumption]. Qed. Lemma extensional_impl_tl : forall (P Q: infseq T -> Prop), extensional P -> extensional Q -> extensional (P ->_ Q). Proof using. (* Goal: @release T P Q (@tl T (@Cons T x2 s2)) *) intros P Q eP eQ s1 s2 e. destruct e; simpl. unfold impl_tl. (* Goal: forall (_ : forall _ : P (@Cons T x s1), Q (@Cons T x s1)) (_ : P (@Cons T x s2)), Q (@Cons T x s2) *) intros PQ1 P2. (* Goal: Q (@Cons T x s2) *) apply eQ with (Cons x s1); [constructor; assumption | idtac]. (* Goal: Q (@Cons T x s1) *) apply PQ1. apply eP with (Cons x s2). (* Goal: @always T P (@Cons T x2 s2) *) - constructor. apply exteq_sym. assumption. (* Goal: @exteq T s1 s2 *) - assumption. Qed. Lemma extensional_not_tl : forall (P: infseq T -> Prop), extensional P -> extensional (~_ P). Proof using. (* Goal: @release T P Q (@tl T (@Cons T x2 s2)) *) intros P eP s1 s2 e; destruct e; simpl. unfold not_tl. (* Goal: forall _ : not (P (@Cons T x s1)), not (P (@Cons T x s2)) *) intros P1 nP2. (* Goal: False *) contradict P1. (* Goal: P (@Cons T x s1) *) apply eP with (Cons x s2); trivial. (* Goal: @exteq T (@Cons T x s2) (@Cons T x s1) *) apply exteq_sym. (* Goal: @exteq T (@Cons T x s1) (@Cons T x s2) *) apply exteq_intro. (* Goal: @exteq T s1 s2 *) assumption. Qed. Lemma extensional_now : forall (P: T -> Prop), extensional (now P). Proof using. (* Goal: @release T P Q (@tl T (@Cons T x2 s2)) *) intros P s1 s2 e. destruct e; simpl. trivial. Qed. Lemma extensional_next : forall (P: infseq T -> Prop), extensional P -> extensional (next P). Proof using. (* Goal: @release T P Q (@tl T (@Cons T x2 s2)) *) intros P eP s1 s2 exP; destruct exP; simpl. (* Goal: @exteq T s1 s2 *) apply eP; assumption. Qed. Lemma extensional_consecutive : forall (P: T -> T -> Prop), extensional (consecutive P). Proof using. (* Goal: @release T P Q (@tl T (@Cons T x2 s2)) *) intros P s1 s2 e. do 2 destruct e; simpl. trivial. Qed. Lemma extensional_always : forall (P: infseq T -> Prop), extensional P -> extensional (always P). Proof using. (* Goal: extensional (@release T P Q) *) intros P eP. cofix cf. (* Goal: @always T P (@Cons T x2 s2) *) intros (x1, s1) (x2, s2) e al1. case (always_Cons al1); intros Px1s1 als1. constructor. (* Goal: @exteq T s1 s2 *) - eapply eP; eassumption. (* Goal: @release T P Q (@tl T (@Cons T x2 s2)) *) - simpl. apply cf with s1; try assumption. case (exteq_inversion e); trivial. Qed. Lemma extensional_weak_until : forall (P Q: infseq T -> Prop), extensional P -> extensional Q -> extensional (weak_until P Q). Proof using. (* Goal: extensional (@release T P Q) *) intros P Q eP eQ. cofix cf. (* Goal: extensional (@weak_until T P Q) *) intros (x1, s1) (x2, s2) e un1. case (weak_until_Cons un1). (* Goal: @exteq T s1 s2 *) - intro Q1. constructor 1. eapply eQ; eassumption. - intros (Px1s1, uns1). constructor 2. (* Goal: @exteq T s1 s2 *) * eapply eP; eassumption. (* Goal: @release T P Q (@tl T (@Cons T x2 s2)) *) * simpl. apply cf with s1; try assumption. case (exteq_inversion e); trivial. Qed. Lemma extensional_until : forall (P Q: infseq T -> Prop), extensional P -> extensional Q -> extensional (until P Q). Proof using. (* Goal: forall (P Q : forall _ : infseq T, Prop) (_ : extensional P) (_ : extensional Q), extensional (@until T P Q) *) intros P Q eP eQ s1 s2 e un1; genclear e; genclear s2. (* Goal: forall (s2 : infseq T) (_ : @exteq T s1 s2), @until T P Q s2 *) induction un1. (* Goal: @exteq T s1 s2 *) - intros s2 e; apply U0; apply eQ with s; assumption. - intros (x2, s2) e. (* Goal: @until T P Q (@Cons T x2 s2) *) apply U_next. (* Goal: @exteq T s1 s2 *) * apply eP with (Cons x s); assumption. * apply IHun1. (* Goal: forall (_ : @eq T x1 x2) (_ : @exteq T s1 s2), @exteq T s1 s2 *) case (exteq_inversion e). trivial. Qed. Lemma extensional_release : forall (P Q: infseq T -> Prop), extensional P -> extensional Q -> extensional (release P Q). Proof using. (* Goal: extensional (@release T P Q) *) intros P Q eP eQ. cofix cf. (* Goal: extensional (@release T P Q) *) intros (x1, s1) (x2, s2) e rl1. case (release_Cons rl1). intros Qx orR. case orR; intro orRx. - apply R0. (* Goal: @exteq T s1 s2 *) * eapply eQ; eassumption. (* Goal: @exteq T s1 s2 *) * eapply eP; eassumption. - apply R_tl. (* Goal: @exteq T s1 s2 *) * eapply eQ; eassumption. (* Goal: @release T P Q (@tl T (@Cons T x2 s2)) *) * simpl. apply cf with s1; trivial. case (exteq_inversion e); trivial. Qed. Lemma extensional_eventually : forall (P: infseq T -> Prop), extensional P -> extensional (eventually P). Proof using. (* Goal: forall (P : forall _ : infseq T, Prop) (_ : extensional P), extensional (@eventually T P) *) intros P eP s1 s2 e ev1. genclear e; genclear s2. (* Goal: forall (s2 : infseq T) (_ : @exteq T s1 s2), @eventually T P s2 *) induction ev1 as [s1 ev1 | x1 s1 ev1 induc_hyp]. (* Goal: @exteq T s1 s2 *) - intros s2 e. constructor 1. apply eP with s1; assumption. - intros (x2, s2) e. constructor 2. apply induc_hyp. (* Goal: forall (_ : @eq T x1 x2) (_ : @exteq T s1 s2), @exteq T s1 s2 *) case (exteq_inversion e). trivial. Qed. Lemma extensional_inf_often : forall (P: infseq T -> Prop), extensional P -> extensional (inf_often P). Proof using. (* Goal: @exteq T s1 s2 *) intros P eP; apply extensional_always; apply extensional_eventually; assumption. Qed. Lemma extensional_continuously : forall (P: infseq T -> Prop), extensional P -> extensional (continuously P). Proof using. (* Goal: @exteq T s1 s2 *) intros P eP; apply extensional_eventually; apply extensional_always; assumption. Qed. End sec_exteq_congruence. Arguments extensional [T] _. Arguments extensional_True_tl [T] _ _ _ _. Arguments extensional_False_tl [T] _ _ _ _. Arguments extensional_and_tl [T P Q] _ _ _ _ _ _. Arguments extensional_or_tl [T P Q] _ _ _ _ _ _. Arguments extensional_impl_tl [T P Q] _ _ _ _ _ _ _. Arguments extensional_not_tl [T P] _ _ _ _ _ _. Arguments extensional_now [T P] _ _ _ _. Arguments extensional_next [T P] _ _ _ _ _. Arguments extensional_consecutive [T P] _ _ _ _. Arguments extensional_always [T P] _ _ _ _ _. Arguments extensional_weak_until [T P Q] _ _ _ _ _ _. Arguments extensional_until [T P Q] _ _ _ _ _ _. Arguments extensional_release [T P Q] _ _ _ _ _ _. Arguments extensional_eventually [T P] _ _ _ _ _. Arguments extensional_inf_often [T P] _ _ _ _ _. Arguments extensional_continuously [T P] _ _ _ _ _.
Require Import StructTact.StructTactics. Set Implicit Arguments. Lemma or_false : forall P : Prop, P -> (P \/ False). Proof. (* Goal: forall (P : Prop) (_ : P), or P False *) firstorder. Qed. Lemma if_sum_bool_fun_comm : forall A B C D (b : {A}+{B}) (c1 c2 : C) (f : C -> D), f (if b then c1 else c2) = if b then f c1 else f c2. Proof. (* Goal: forall (y1 : A0) (P : forall (_ : A0) (x1 : A1) (x2 : A2 x1) (x3 : @A3 x1 x2) (x4 : @A4 x1 x2 x3) (_ : @A5 x1 x2 x3 x4), Prop) (x1 : A0) (x2 : A1) (x3 : A2 x2) (x4 : @A3 x2 x3) (x5 : @A4 x2 x3 x4) (x6 : @A5 x2 x3 x4 x5) (_ : P y1 x2 x3 x4 x5 x6) (_ : @eq A0 x1 y1), P x1 x2 x3 x4 x5 x6 *) intros. break_if; auto. Qed. Lemma if_decider_true : forall A B (P : A -> Prop) (dec : forall x, {P x} + {~ P x}) a (b1 b2 : B), P a -> (if dec a then b1 else b2) = b1. Proof. (* Goal: forall (y1 : A0) (P : forall (_ : A0) (x1 : A1) (x2 : A2 x1) (x3 : @A3 x1 x2) (x4 : @A4 x1 x2 x3) (_ : @A5 x1 x2 x3 x4), Prop) (x1 : A0) (x2 : A1) (x3 : A2 x2) (x4 : @A3 x2 x3) (x5 : @A4 x2 x3 x4) (x6 : @A5 x2 x3 x4 x5) (_ : P y1 x2 x3 x4 x5 x6) (_ : @eq A0 x1 y1), P x1 x2 x3 x4 x5 x6 *) intros. (* Goal: @eq B (if dec a then b1 else b2) b2 *) break_if; congruence. Qed. Lemma if_decider_false : forall A B (P : A -> Prop) (dec : forall x, {P x} + {~ P x}) a (b1 b2 : B), ~ P a -> (if dec a then b1 else b2) = b2. Proof. (* Goal: forall (y1 : A0) (P : forall (_ : A0) (x1 : A1) (x2 : A2 x1) (x3 : @A3 x1 x2) (x4 : @A4 x1 x2 x3) (_ : @A5 x1 x2 x3 x4), Prop) (x1 : A0) (x2 : A1) (x3 : A2 x2) (x4 : @A3 x2 x3) (x5 : @A4 x2 x3 x4) (x6 : @A5 x2 x3 x4 x5) (_ : P y1 x2 x3 x4 x5 x6) (_ : @eq A0 x1 y1), P x1 x2 x3 x4 x5 x6 *) intros. (* Goal: @eq B (if dec a then b1 else b2) b2 *) break_if; congruence. Qed. Definition prod_eq_dec : forall A B (A_eq_dec : forall x y : A, {x = y} + {x <> y}) (B_eq_dec : forall x y : B, {x = y} + {x <> y}) (x y : A * B), {x = y} + {x <> y}. Proof. (* Goal: forall (A B : Type) (_ : forall x y : A, sumbool (@eq A x y) (not (@eq A x y))) (_ : forall x y : B, sumbool (@eq B x y) (not (@eq B x y))) (x y : prod A B), sumbool (@eq (prod A B) x y) (not (@eq (prod A B) x y)) *) decide equality. Defined. (* from SF's tactics library *) Section equatesLemma. Variables (A0 A1 : Type) (A2 : forall(x1 : A1), Type) (A3 : forall(x1 : A1) (x2 : A2 x1), Type) (A4 : forall(x1 : A1) (x2 : A2 x1) (x3 : A3 x2), Type) (A5 : forall(x1 : A1) (x2 : A2 x1) (x3 : A3 x2) (x4 : A4 x3), Type) (A6 : forall(x1 : A1) (x2 : A2 x1) (x3 : A3 x2) (x4 : A4 x3) (x5 : A5 x4), Type). Lemma equates_0 : forall(P Q:Prop), P -> P = Q -> Q. Proof using. intros. subst. auto. Qed. Lemma equates_1 : forall(P:A0->Prop) x1 y1, P y1 -> x1 = y1 -> P x1. Proof using. intros. subst. auto. Qed. Lemma equates_2 : forall y1 (P:A0->forall(x1:A1),Prop) x1 x2, P y1 x2 -> x1 = y1 -> P x1 x2. Proof using. intros. subst. auto. Qed. Lemma equates_3 : forall y1 (P:A0->forall(x1:A1)(x2:A2 x1),Prop) x1 x2 x3, P y1 x2 x3 -> x1 = y1 -> P x1 x2 x3. Proof using. intros. subst. auto. Qed. Lemma equates_4 : forall y1 (P:A0->forall(x1:A1)(x2:A2 x1)(x3:A3 x2),Prop) x1 x2 x3 x4, P y1 x2 x3 x4 -> x1 = y1 -> P x1 x2 x3 x4. Proof using. intros. subst. auto. Qed. Lemma equates_5 : forall y1 (P:A0->forall(x1:A1)(x2:A2 x1)(x3:A3 x2)(x4:A4 x3),Prop) x1 x2 x3 x4 x5, P y1 x2 x3 x4 x5 -> x1 = y1 -> P x1 x2 x3 x4 x5. Proof using. intros. subst. auto. Qed. Lemma equates_6 : forall y1 (P:A0->forall(x1:A1)(x2:A2 x1)(x3:A3 x2)(x4:A4 x3)(x5:A5 x4),Prop) x1 x2 x3 x4 x5 x6, P y1 x2 x3 x4 x5 x6 -> x1 = y1 -> P x1 x2 x3 x4 x5 x6. Proof using. intros. subst. auto. Qed. End equatesLemma.
Require Import List. Import ListNotations. Require Import StructTact.StructTactics. Require Import StructTact.ListTactics. Require Import StructTact.ListUtil. Set Implicit Arguments. Section dedup. Variable A : Type. Hypothesis A_eq_dec : forall x y : A, {x = y} + {x <> y}. Fixpoint dedup (xs : list A) : list A := match xs with | [] => [] | x :: xs => let tail := dedup xs in if in_dec A_eq_dec x xs then tail else x :: tail end. Lemma dedup_eliminates_duplicates : forall a l l', dedup (a :: l ++ a :: l') = dedup (l ++ a :: l'). Proof using. (* Goal: forall (x y : A) (_ : @In A x xs) (_ : @In A y ys), not (@eq A x y) *) intros. simpl in *. (* Goal: @eq (list A) (if @in_dec A A_eq_dec a (@app A l (@cons A a l')) then dedup (@app A l (@cons A a l')) else @cons A a (dedup (@app A l (@cons A a l')))) (dedup (@app A l (@cons A a l'))) *) break_match. + auto. + exfalso. intuition. Qed. Lemma dedup_In : forall (x : A) xs, In x xs -> In x (dedup xs). Proof using. (* Goal: @eq (list A) (@cons A x (dedup (@cons A a xs))) (dedup (@cons A x (@cons A a xs))) *) induction xs; intros; simpl in *. (* Goal: @eq (list A) (@cons A x (if @in_dec A A_eq_dec a xs then dedup xs else @cons A a (dedup xs))) (if match A_eq_dec a x with | left e => @left (or (@eq A a x) (@In A x xs)) (not (or (@eq A a x) (@In A x xs))) (@or_introl (@eq A a x) (@In A x xs) e) | right n => match @in_dec A A_eq_dec x xs with | left i => @left (or (@eq A a x) (@In A x xs)) (not (or (@eq A a x) (@In A x xs))) (@or_intror (@eq A a x) (@In A x xs) i) | right n0 => @right (or (@eq A a x) (@In A x xs)) (not (or (@eq A a x) (@In A x xs))) (fun H0 : or (@eq A a x) (@In A x xs) => match H0 with | or_introl Hc1 => n Hc1 | or_intror Hc2 => n0 Hc2 end) end end then if @in_dec A A_eq_dec a xs then dedup xs else @cons A a (dedup xs) else @cons A x (if @in_dec A A_eq_dec a xs then dedup xs else @cons A a (dedup xs))) *) - intuition. (* Goal: @eq (list A) (@cons A x (dedup (@nil A))) (dedup (@cons A x (@nil A))) *) - break_if; intuition; subst; simpl; auto. Qed. Lemma filter_dedup (pred : A -> bool) : forall xs (p : A) ys, pred p = false -> filter pred (dedup (xs ++ ys)) = filter pred (dedup (xs ++ p :: ys)). Proof using. (* Goal: forall (x y : A) (_ : @In A x xs) (_ : @In A y ys), not (@eq A x y) *) intros. induction xs; simpl; repeat (break_match; simpl); auto using f_equal2; try discriminate. + exfalso. apply n. apply in_app_iff. apply in_app_or in i. intuition. + exfalso. apply n. apply in_app_or in i. intuition. (* Goal: @eq (list A) (@cons A x (dedup (@cons A a xs))) (dedup (@cons A x (@cons A a xs))) *) * simpl in *. intuition. congruence. Qed. Lemma dedup_app : forall (xs ys : list A), (forall x y, In x xs -> In y ys -> x <> y) -> dedup (xs ++ ys) = dedup xs ++ dedup ys. Proof using. (* Goal: forall (x y : A) (_ : @In A x xs) (_ : @In A y ys), not (@eq A x y) *) intros. induction xs; simpl; auto. (* Goal: @eq (list A) (if @in_dec A A_eq_dec a (@app A l (@cons A a l')) then dedup (@app A l (@cons A a l')) else @cons A a (dedup (@app A l (@cons A a l')))) (dedup (@app A l (@cons A a l'))) *) repeat break_match. - apply IHxs. (* Goal: forall (x y : A) (_ : @In A x xs) (_ : @In A y ys), not (@eq A x y) *) intros. apply H; intuition. (* Goal: @eq (list A) (@cons A a (@remove A A_eq_dec x (dedup xs))) (dedup (@remove A A_eq_dec x xs)) *) - exfalso. specialize (H a a). (* Goal: @eq (list A) (@cons A x (if @in_dec A A_eq_dec a xs then dedup xs else @cons A a (dedup xs))) (if match A_eq_dec a x with | left e => @left (or (@eq A a x) (@In A x xs)) (not (or (@eq A a x) (@In A x xs))) (@or_introl (@eq A a x) (@In A x xs) e) | right n => match @in_dec A A_eq_dec x xs with | left i => @left (or (@eq A a x) (@In A x xs)) (not (or (@eq A a x) (@In A x xs))) (@or_intror (@eq A a x) (@In A x xs) i) | right n0 => @right (or (@eq A a x) (@In A x xs)) (not (or (@eq A a x) (@In A x xs))) (fun H0 : or (@eq A a x) (@In A x xs) => match H0 with | or_introl Hc1 => n Hc1 | or_intror Hc2 => n0 Hc2 end) end end then if @in_dec A A_eq_dec a xs then dedup xs else @cons A a (dedup xs) else @cons A x (if @in_dec A A_eq_dec a xs then dedup xs else @cons A a (dedup xs))) *) apply H; intuition. (* Goal: @eq (list A) (@cons A x (if @in_dec A A_eq_dec a xs then dedup xs else @cons A a (dedup xs))) (if match A_eq_dec a x with | left e => @left (or (@eq A a x) (@In A x xs)) (not (or (@eq A a x) (@In A x xs))) (@or_introl (@eq A a x) (@In A x xs) e) | right n => match @in_dec A A_eq_dec x xs with | left i => @left (or (@eq A a x) (@In A x xs)) (not (or (@eq A a x) (@In A x xs))) (@or_intror (@eq A a x) (@In A x xs) i) | right n0 => @right (or (@eq A a x) (@In A x xs)) (not (or (@eq A a x) (@In A x xs))) (fun H0 : or (@eq A a x) (@In A x xs) => match H0 with | or_introl Hc1 => n Hc1 | or_intror Hc2 => n0 Hc2 end) end end then if @in_dec A A_eq_dec a xs then dedup xs else @cons A a (dedup xs) else @cons A x (if @in_dec A A_eq_dec a xs then dedup xs else @cons A a (dedup xs))) *) do_in_app. intuition. (* Goal: @eq (list A) (@cons A a (@remove A A_eq_dec x (dedup xs))) (dedup (@remove A A_eq_dec x xs)) *) - exfalso. apply n. intuition. - simpl. f_equal. (* Goal: @eq (list A) (dedup (@app A xs ys)) (@app A (dedup xs) (dedup ys)) *) apply IHxs. (* Goal: forall (x y : A) (_ : @In A x xs) (_ : @In A y ys), not (@eq A x y) *) intros. apply H; intuition. Qed. Lemma in_dedup_was_in : forall xs (x : A), In x (dedup xs) -> In x xs. Proof using. (* Goal: @eq (list A) (@cons A x (dedup (@cons A a xs))) (dedup (@cons A x (@cons A a xs))) *) induction xs; intros; simpl in *. (* Goal: @eq (list A) (@cons A x (if @in_dec A A_eq_dec a xs then dedup xs else @cons A a (dedup xs))) (if match A_eq_dec a x with | left e => @left (or (@eq A a x) (@In A x xs)) (not (or (@eq A a x) (@In A x xs))) (@or_introl (@eq A a x) (@In A x xs) e) | right n => match @in_dec A A_eq_dec x xs with | left i => @left (or (@eq A a x) (@In A x xs)) (not (or (@eq A a x) (@In A x xs))) (@or_intror (@eq A a x) (@In A x xs) i) | right n0 => @right (or (@eq A a x) (@In A x xs)) (not (or (@eq A a x) (@In A x xs))) (fun H0 : or (@eq A a x) (@In A x xs) => match H0 with | or_introl Hc1 => n Hc1 | or_intror Hc2 => n0 Hc2 end) end end then if @in_dec A A_eq_dec a xs then dedup xs else @cons A a (dedup xs) else @cons A x (if @in_dec A A_eq_dec a xs then dedup xs else @cons A a (dedup xs))) *) - intuition. (* Goal: @eq (list A) (@cons A x (if @in_dec A A_eq_dec a xs then dedup xs else @cons A a (dedup xs))) (if match A_eq_dec a x with | left e => @left (or (@eq A a x) (@In A x xs)) (not (or (@eq A a x) (@In A x xs))) (@or_introl (@eq A a x) (@In A x xs) e) | right n => match @in_dec A A_eq_dec x xs with | left i => @left (or (@eq A a x) (@In A x xs)) (not (or (@eq A a x) (@In A x xs))) (@or_intror (@eq A a x) (@In A x xs) i) | right n0 => @right (or (@eq A a x) (@In A x xs)) (not (or (@eq A a x) (@In A x xs))) (fun H0 : or (@eq A a x) (@In A x xs) => match H0 with | or_introl Hc1 => n Hc1 | or_intror Hc2 => n0 Hc2 end) end end then if @in_dec A A_eq_dec a xs then dedup xs else @cons A a (dedup xs) else @cons A x (if @in_dec A A_eq_dec a xs then dedup xs else @cons A a (dedup xs))) *) - break_if; simpl in *; intuition. Qed. Lemma NoDup_dedup : forall (xs : list A), NoDup (dedup xs). Proof using. (* Goal: @eq (list A) (dedup (@cons A a xs)) (@cons A a xs) *) induction xs; simpl. - constructor. (* Goal: @eq (list A) (@cons A x (dedup (@nil A))) (dedup (@cons A x (@nil A))) *) - break_if; auto. (* Goal: @eq (list A) (@cons A x (dedup (@nil A))) (dedup (@cons A x (@nil A))) *) constructor; auto. (* Goal: not (@In A a (dedup xs)) *) intro. (* Goal: False *) apply n. (* Goal: @eq (list A) (@cons A x (dedup (@nil A))) (dedup (@cons A x (@nil A))) *) eapply in_dedup_was_in; eauto. Qed. Lemma remove_dedup_comm : forall (x : A) xs, remove A_eq_dec x (dedup xs) = dedup (remove A_eq_dec x xs). Proof using. (* Goal: forall (x y : A) (_ : @In A x xs) (_ : @In A y ys), not (@eq A x y) *) induction xs; intros. (* Goal: @eq (list A) (@cons A x (dedup (@nil A))) (dedup (@cons A x (@nil A))) *) - auto. - simpl. repeat (break_match; simpl); auto using f_equal. + exfalso. apply n0. apply remove_preserve; auto. + exfalso. apply n. eapply in_remove; eauto. Qed. Lemma dedup_partition : forall xs (p : A) ys xs' ys', dedup (xs ++ p :: ys) = xs' ++ p :: ys' -> remove A_eq_dec p (dedup (xs ++ ys)) = xs' ++ ys'. Proof using. (* Goal: forall (xs : list A) (p : A) (ys xs' ys' : list A) (_ : @eq (list A) (dedup (@app A xs (@cons A p ys))) (@app A xs' (@cons A p ys'))), @eq (list A) (@remove A A_eq_dec p (dedup (@app A xs ys))) (@app A xs' ys') *) intros xs p ys xs' ys' H. (* Goal: @eq (list A) (@remove A A_eq_dec p (dedup (@app A xs ys))) (@app A xs' ys') *) f_apply H (remove A_eq_dec p). (* Goal: @In A a (@app A xs ys) *) rewrite remove_dedup_comm, remove_partition in *. (* Goal: @eq (list A) (dedup (@remove A A_eq_dec p (@app A xs ys))) (@app A xs' ys') *) find_rewrite. (* Goal: @eq (list A) (@remove A A_eq_dec p (@app A xs' (@cons A p ys'))) (@app A xs' ys') *) rewrite remove_partition. (* Goal: @eq (list A) (@remove A A_eq_dec p (@app A xs' ys')) (@app A xs' ys') *) apply remove_not_in. (* Goal: not (@In A p (@app A xs' ys')) *) apply NoDup_remove_2. rewrite <- H. (* Goal: @NoDup A (dedup (@app A xs (@cons A p ys))) *) apply NoDup_dedup. Qed. Lemma dedup_NoDup_id : forall (xs : list A), NoDup xs -> dedup xs = xs. Proof using. (* Goal: forall (x y : A) (_ : @In A x xs) (_ : @In A y ys), not (@eq A x y) *) induction xs; intros. (* Goal: @eq (list A) (@cons A x (dedup (@nil A))) (dedup (@cons A x (@nil A))) *) - auto. - simpl. invc_NoDup. concludes. (* Goal: @In A a (@app A xs ys) *) break_if; congruence. Qed. Lemma dedup_not_in_cons : forall x xs, (~ In x xs) -> x :: dedup xs = dedup (x :: xs). Proof using. (* Goal: forall (x y : A) (_ : @In A x xs) (_ : @In A y ys), not (@eq A x y) *) induction xs; intros. (* Goal: @eq (list A) (@cons A x (dedup (@nil A))) (dedup (@cons A x (@nil A))) *) - auto. (* Goal: @eq (list A) (@cons A x (dedup (@cons A a xs))) (dedup (@cons A x (@cons A a xs))) *) - simpl in *. intuition. repeat break_match; intuition. Qed. End dedup.
Require Import List. Import ListNotations. Require Import StructTact.StructTactics. Set Implicit Arguments. Fixpoint before {A: Type} (x : A) y l : Prop := match l with | [] => False | a :: l' => a = x \/ (a <> y /\ before x y l') end. Section before. Variable A : Type. Lemma before_In : forall x y l, before (A:=A) x y l -> In x l. Proof using. (* Goal: forall (x y : A) (l : list A) (y' : A) (dec : forall x0 y0 : A, sumbool (@eq A x0 y0) (not (@eq A x0 y0))) (_ : @before A x y (@remove A dec y' l)) (_ : not (@eq A y y')), @before A x y l *) induction l; intros; simpl in *; intuition. Qed. Lemma before_split : forall l (x y : A), before x y l -> x <> y -> In x l -> In y l -> exists xs ys zs, l = xs ++ x :: ys ++ y :: zs. Proof using. (* Goal: forall (l : list A) (x y : A) (_ : @before A x y l) (_ : not (@eq A x y)) (_ : @In A x l) (_ : @In A y l), @ex (list A) (fun xs : list A => @ex (list A) (fun ys : list A => @ex (list A) (fun zs : list A => @eq (list A) l (@app A xs (@cons A x (@app A ys (@cons A y zs))))))) *) induction l; intros; simpl in *; intuition; subst; try congruence. - exists nil. simpl. find_apply_lem_hyp in_split. break_exists. subst. eauto. - exists nil. simpl. find_apply_lem_hyp in_split. break_exists. subst. eauto. - exists nil. simpl. find_apply_lem_hyp in_split. break_exists. subst. eauto. - eapply_prop_hyp In In; eauto. break_exists. subst. (* Goal: @ex (list A) (fun xs : list A => @ex (list A) (fun ys : list A => @ex (list A) (fun zs : list A => @eq (list A) (@cons A a (@app A x0 (@cons A x (@app A x1 (@cons A y x2))))) (@app A xs (@cons A x (@app A ys (@cons A y zs))))))) *) exists (a :: x0), x1, x2. auto. Qed. Lemma In_app_before : forall xs ys x y, In(A:=A) x xs -> (~ In y xs) -> before x y (xs ++ y :: ys). Proof using. (* Goal: @before A a b (@app A xs (@cons A y zs)) *) induction xs; intros; simpl in *; intuition. Qed. Lemma before_2_3_insert : forall xs ys zs x y a b, before(A:=A) a b (xs ++ ys ++ zs) -> b <> x -> b <> y -> before a b (xs ++ x :: ys ++ y :: zs). Proof using. (* Goal: @before A a b (@app A xs (@cons A y zs)) *) induction xs; intros; simpl in *; intuition. (* Goal: or (@eq A x a) (and (forall _ : @eq A x b, False) (@before A a b (@app A ys (@cons A y zs)))) *) induction ys; intros; simpl in *; intuition. Qed. Lemma before_middle_insert : forall xs y zs a b, before(A:=A) a b (xs ++ zs) -> b <> y -> before a b (xs ++ y :: zs). Proof using. (* Goal: forall (x y : A) (l : list A) (_ : @before A x y l) (_ : @before A y x l), @eq A x y *) intros. (* Goal: @before A a b (@app A xs (@cons A y zs)) *) induction xs; intros; simpl in *; intuition. Qed. Lemma before_2_3_reduce : forall xs ys zs x y a b, before(A:=A) a b (xs ++ x :: ys ++ y :: zs) -> a <> x -> a <> y -> before a b (xs ++ ys ++ zs). Proof using. (* Goal: @ex (list A) (fun ys : list A => @ex (list A) (fun zs : list A => @eq (list A) (@cons A x (@app A x0 (@cons A y x1))) (@cons A x (@app A ys (@cons A y zs))))) *) induction xs; intros; simpl in *; intuition; try congruence; eauto. (* Goal: @before A a b (@app A ys zs) *) induction ys; intros; simpl in *; intuition; try congruence. Qed. Lemma before_middle_reduce : forall xs zs a b y, before(A:=A) a b (xs ++ y :: zs) -> a <> y -> before a b (xs ++ zs). Proof using. (* Goal: @ex (list A) (fun ys : list A => @ex (list A) (fun zs : list A => @eq (list A) (@cons A x (@app A x0 (@cons A y x1))) (@cons A x (@app A ys (@cons A y zs))))) *) induction xs; intros; simpl in *; intuition; try congruence; eauto. Qed. Lemma before_remove : forall x y l y' dec, before (A := A) x y (remove dec y' l) -> y <> y' -> before x y l. Proof using. (* Goal: forall (x y : A) (l : list A) (y' : A) (dec : forall x0 y0 : A, sumbool (@eq A x0 y0) (not (@eq A x0 y0))) (_ : @before A x y (@remove A dec y' l)) (_ : not (@eq A y y')), @before A x y l *) induction l; intros; simpl in *; intuition. (* Goal: @ex (list A) (fun ys : list A => @ex (list A) (fun zs : list A => @eq (list A) (@cons A x (@app A x0 (@cons A y x1))) (@cons A x (@app A ys (@cons A y zs))))) *) break_if; subst; simpl in *; intuition eauto. Qed. Lemma before_remove_if : forall (x : A) y l x' dec, before x y l -> x <> x' -> before x y (remove dec x' l). Proof using. induction l; intros; simpl in *; intuition; (* Goal: @ex (list A) (fun ys : list A => @ex (list A) (fun zs : list A => @eq (list A) (@cons A x (@app A x0 (@cons A y x1))) (@cons A x (@app A ys (@cons A y zs))))) *) break_if; subst; simpl in *; intuition eauto. Qed. Lemma before_app : forall x y l' l, before (A := A) x y (l' ++ l) -> ~ In x l' -> before (A := A) x y l. Proof using. (* Goal: forall (x y : A) (l' l : list A) (_ : @before A x y l) (_ : not (@In A y l')), @before A x y (@app A l' l) *) induction l'; intros; simpl in *; intuition. Qed. Lemma before_app_if : forall x y l' l, before (A := A) x y l -> ~ In y l' -> before (A := A) x y (l' ++ l). Proof using. (* Goal: forall (x y : A) (l' l : list A) (_ : @before A x y l) (_ : not (@In A y l')), @before A x y (@app A l' l) *) induction l'; intros; simpl in *; intuition. Qed. Lemma before_antisymmetric : forall x y l, before (A := A) x y l -> before y x l -> x = y. Proof using. (* Goal: forall (x y : A) (l : list A) (_ : @before A x y l) (_ : @before A y x l), @eq A x y *) intros. (* Goal: @eq A x y *) induction l; simpl in *; intuition; congruence. Qed. End before.
Require Import List. Import ListNotations. Require Import StructTact.StructTactics. Set Implicit Arguments. Fixpoint Prefix {A} (l1 : list A) l2 : Prop := match l1, l2 with | a :: l1', b :: l2' => a = b /\ Prefix l1' l2' | [], _ => True | _, _ => False end. Section prefix. Variable A : Type. Lemma Prefix_refl : forall (l : list A), Prefix l l. Proof using. (* Goal: forall (x : A) (_ : @In A x (@cons A a0 l')), @In A x (@cons A a l) *) intros. induction l; simpl in *; auto. Qed. Lemma Prefix_nil : forall (l : list A), Prefix l [] -> l = []. Proof using. (* Goal: forall (x : A) (_ : @In A x (@cons A a0 l')), @In A x (@cons A a l) *) intros. destruct l. - reflexivity. - contradiction. Qed. Lemma Prefix_cons : forall (l l' : list A) a, Prefix l' l -> Prefix (a :: l') (a :: l). Proof using. (* Goal: forall (l l' : list A) (a : A) (_ : @Prefix A l' l), @Prefix A (@cons A a l') (@cons A a l) *) simpl. intuition. Qed. Lemma Prefix_in : forall (l l' : list A), Prefix l' l -> forall x, In x l' -> In x l. Proof using. (* Goal: forall (l l' : list A) (_ : @Prefix A l' l) (x : A) (_ : @In A x l'), @In A x l *) induction l; intros l' H. - find_apply_lem_hyp Prefix_nil. subst. contradiction. - destruct l'. (* Goal: forall (x : A) (_ : @In A x (@nil A)), @In A x (@cons A a l) *) + contradiction. (* Goal: forall (x : A) (_ : @In A x (@cons A a0 l')), @In A x (@cons A a l) *) + intros. simpl Prefix in *. break_and. subst. simpl in *. intuition. (* Goal: or (@eq A a x) (@In A x l) *) right. eapply IHl; eauto. Qed. Lemma app_Prefix : forall (xs ys zs : list A), xs ++ ys = zs -> Prefix xs zs. Proof using. (* Goal: @In A x (@cons A a l) *) induction xs; intros; simpl in *. - auto. - break_match. + discriminate. (* Goal: @eq (list A) (@cons A a0 l) (@cons A a0 (@app A l1 x)) *) + subst. find_inversion. eauto. Qed. Lemma Prefix_In : forall (l : list A) l' x, Prefix l l' -> In x l -> In x l'. Proof using. induction l; intros; simpl in *; intuition; (* Goal: or (@eq A a x) (@In A x l) *) subst; break_match; intuition; subst; intuition. Qed. Lemma Prefix_exists_rest : forall (l1 l2 : list A), Prefix l1 l2 -> exists rest, l2 = l1 ++ rest. Proof using. (* Goal: @eq (list A) (@cons A a0 (@app A l1 x)) (@cons A a0 (@app A l1 x)) *) induction l1; intros; simpl in *; eauto. (* Goal: or (@eq A a x) (@In A x l) *) break_match; intuition. subst. (* Goal: @ex (list A) (fun rest : list A => @eq (list A) (@cons A a0 l) (@cons A a0 (@app A l1 rest))) *) find_apply_hyp_hyp. (* Goal: @eq (list A) (@cons A a0 l) (@cons A a0 (@app A l1 x)) *) break_exists_exists. subst. auto. Qed. End prefix.
Require Import List. Import ListNotations. Require Import StructTact.StructTactics. Require Import StructTact.ListUtil. Require Import StructTact.ListTactics. Require Import StructTact.Before. Set Implicit Arguments. Section remove_all. Variable A : Type. Hypothesis A_eq_dec : forall x y : A, {x = y} + {x <> y}. Fixpoint remove_all (to_delete l : list A) : list A := match to_delete with | [] => l | d :: ds => remove_all ds (remove A_eq_dec d l) end. Lemma in_remove_all_was_in : forall ds l x, In x (remove_all ds l) -> In x l. Proof using. (* Goal: forall (ds l : list A) (x : A) (_ : @In A x (remove_all ds l)) (_ : @In A x ds), False *) induction ds; intros; simpl in *; intuition. (* Goal: @In A x l *) eauto using in_remove. Qed. Lemma in_remove_all_preserve : forall ds l x, ~ In x ds -> In x l -> In x (remove_all ds l). Proof using. (* Goal: forall (ds l : list A) (x : A) (_ : not (@In A x ds)) (_ : @In A x l), @In A x (remove_all ds l) *) induction ds; intros; simpl in *; intuition auto using remove_preserve. Qed. Lemma in_remove_all_not_in : forall ds l x, In x (remove_all ds l) -> In x ds -> False. Proof using. (* Goal: forall (ds l : list A) (x : A) (_ : @In A x (remove_all ds l)) (_ : @In A x ds), False *) induction ds; intros; simpl in *; intuition. - subst. find_apply_lem_hyp in_remove_all_was_in. (* Goal: False *) eapply remove_In; eauto. - eauto. Qed. Lemma remove_all_nil : forall ys, remove_all ys [] = []. Proof using. (* Goal: forall xs ys zs : list A, @eq (list A) (remove_all xs (remove_all ys zs)) (remove_all ys (remove_all xs zs)) *) intros. induction ys; simpl in *; intuition. Qed. Lemma remove_all_cons : forall ys a l, (remove_all ys (a :: l) = remove_all ys l /\ In a ys) \/ (remove_all ys (a :: l) = a :: (remove_all ys l) /\ ~In a ys). Proof using. (* Goal: forall (ys : list A) (a : A) (l : list A), or (and (@eq (list A) (remove_all ys (@cons A a l)) (remove_all ys l)) (@In A a ys)) (and (@eq (list A) (remove_all ys (@cons A a l)) (@cons A a (remove_all ys l))) (not (@In A a ys))) *) induction ys; intros; simpl in *; intuition. (* Goal: or (and (@eq (list A) (remove_all ys (if A_eq_dec a a0 then @remove A A_eq_dec a l else @cons A a0 (@remove A A_eq_dec a l))) (remove_all ys (@remove A A_eq_dec a l))) (or (@eq A a a0) (@In A a0 ys))) (and (@eq (list A) (remove_all ys (if A_eq_dec a a0 then @remove A A_eq_dec a l else @cons A a0 (@remove A A_eq_dec a l))) (@cons A a0 (remove_all ys (@remove A A_eq_dec a l)))) (forall _ : or (@eq A a a0) (@In A a0 ys), False)) *) break_if; subst; simpl in *; intuition. (* Goal: or (and (@eq (list A) (remove_all ys (@cons A a0 (@remove A A_eq_dec a l))) (remove_all ys (@remove A A_eq_dec a l))) (or (@eq A a a0) (@In A a0 ys))) (and (@eq (list A) (remove_all ys (@cons A a0 (@remove A A_eq_dec a l))) (@cons A a0 (remove_all ys (@remove A A_eq_dec a l)))) (forall _ : or (@eq A a a0) (@In A a0 ys), False)) *) specialize (IHys a0 (remove A_eq_dec a l)). intuition. Qed. Lemma before_remove_all : forall x y l ys, before x y (remove_all ys l) -> ~ In y ys -> before x y l. Proof using. (* Goal: @eq (list A) (remove_all l l') (@cons A a (@app A l0 l1)) *) induction l; intros; simpl in *; intuition. - rewrite remove_all_nil in *. simpl in *. intuition. - pose proof remove_all_cons ys a l. intuition. (* Goal: False *) + repeat find_rewrite. right. intuition eauto. (* Goal: @eq (list A) (remove_all l l') (@cons A a (@app A l0 l1)) *) subst; intuition. (* Goal: False *) + repeat find_rewrite. simpl in *. intuition eauto. Qed. Lemma before_remove_all_if : forall x y l xs, before x y l -> ~ In x xs -> before x y (remove_all xs l). Proof using. induction l; intros; simpl in *; intuition; pose proof remove_all_cons xs a l; subst; intuition; (* Goal: @eq (list A) (remove_all l l') (@cons A a (@app A l0 l1)) *) repeat find_rewrite; simpl in *; intuition. Qed. Lemma NoDup_remove_all : forall l l', NoDup l' -> NoDup (remove_all l l'). Proof using. (* Goal: forall xs ys zs : list A, @eq (list A) (remove_all xs (remove_all ys zs)) (remove_all ys (remove_all xs zs)) *) intros. (* Goal: @NoDup A (remove_all l l') *) induction l'. - rewrite remove_all_nil; auto. - invc_NoDup. (* Goal: @NoDup A (remove_all l (@cons A a l')) *) concludes. (* Goal: @eq (list A) (remove_all l (@cons A a (@remove A A_eq_dec a0 l'))) (@app A l0 l1) *) pose proof remove_all_cons l a l'. (* Goal: @NoDup A (remove_all l (@cons A a l')) *) break_or_hyp; break_and; find_rewrite; auto. (* Goal: @NoDup A (@cons A a (remove_all l l')) *) constructor; auto. (* Goal: not (@In A a (remove_all l l')) *) intro. (* Goal: False *) find_apply_lem_hyp in_remove_all_was_in; auto. Qed. Lemma remove_all_NoDup_split : forall l l' l0 l1 a, NoDup l' -> remove_all l l' = l0 ++ a :: l1 -> remove_all l (remove A_eq_dec a l') = l0 ++ l1. Proof using. (* Goal: or (@eq A a x) (and (forall _ : @eq A a y, False) (@before A x y l)) *) induction l'; intros; simpl in *. - find_rewrite_lem remove_all_nil. destruct l0; simpl in *; match goal with H: [] = _ |- _ => contradict H end; auto using nil_cons. - invc_NoDup. (* Goal: False *) break_if; subst. * rewrite remove_not_in; auto. (* Goal: @eq (list A) (remove_all l (@cons A a (@remove A A_eq_dec a0 l'))) (@app A l0 l1) *) pose proof remove_all_cons l a l'. (* Goal: @eq (list A) (remove_all l l') (@app A l0 l1) *) break_or_hyp; break_and. + find_rewrite. match goal with H0: NoDup _, H1: _ = remove_all _ _ |- _ => specialize (IHl' _ _ _ H0 (eq_sym H1)) end. (* Goal: @eq (list A) (remove_all l l') (@app A l0 l1) *) rewrite remove_not_in in IHl'; auto. + destruct l0; simpl in *; find_rewrite; find_injection; auto. (* Goal: @eq (list A) (remove_all l l') (@cons A a (@app A l0 l1)) *) assert (In a (remove_all l l')). match goal with H: _ = remove_all _ _ |- _ => rewrite <- H end. (* Goal: @In A a (@app A l0 (@cons A a l1)) *) (* Goal: @eq (list A) (remove_all l l') (@cons A a (@app A l0 l1)) *) apply in_or_app. (* Goal: or (@In A a l0) (@In A a (@cons A a l1)) *) (* Goal: @eq (list A) (remove_all l l') (@cons A a (@app A l0 l1)) *) right; left; auto. (* Goal: @eq (list A) (remove_all l l') (@cons A a (@app A l0 l1)) *) find_apply_lem_hyp in_remove_all_was_in. (* Goal: @eq (list A) (remove_all l l') (@cons A a (@app A l0 l1)) *) intuition. (* Goal: @eq (list A) (remove_all l (@cons A a (@remove A A_eq_dec a0 l'))) (@app A l0 l1) *) * pose proof remove_all_cons l a l'. (* Goal: @eq (list A) (remove_all l l') (@app A l0 l1) *) break_or_hyp; break_and; find_rewrite. + pose proof remove_all_cons l a (remove A_eq_dec a0 l'). (* Goal: @eq (list A) (remove_all l l') (@cons A a (@app A l0 l1)) *) break_or_hyp; break_and; intuition. (* Goal: @eq (list A) (remove_all l (@cons A a (@remove A A_eq_dec a0 l'))) (@app A l0 l1) *) aggressive_rewrite_goal; auto. (* Goal: @eq (list A) (remove_all l l') (@cons A a (@app A l0 l1)) *) + destruct l0; simpl in *; find_injection; intuition. match goal with H0: NoDup _, H1: _ = remove_all _ _ |- _ => specialize (IHl' _ _ _ H0 (eq_sym H1)) end. rewrite <- IHl'. (* Goal: @eq (list A) (remove_all l (@cons A a (@remove A A_eq_dec a0 l'))) (@cons A a (remove_all l (@remove A A_eq_dec a0 l'))) *) pose proof remove_all_cons l a (remove A_eq_dec a0 l'). (* Goal: @eq (list A) (remove_all l l') (@cons A a (@app A l0 l1)) *) break_or_hyp; break_and; intuition. Qed. Lemma remove_all_app_l : forall xs ys zs, remove_all (xs ++ ys) zs = remove_all xs (remove_all ys zs). Proof using. (* Goal: forall xs ys zs : list A, @eq (list A) (remove_all xs (remove_all ys zs)) (remove_all ys (remove_all xs zs)) *) induction zs; intros. - now repeat rewrite remove_all_nil. - pose proof (remove_all_cons (xs ++ ys) a zs). (* Goal: @eq (list A) (remove_all xs (remove_all ys (@cons A a zs))) (remove_all ys (remove_all xs (@cons A a zs))) *) pose proof (remove_all_cons ys a zs). (* Goal: @eq (list A) (remove_all xs (remove_all ys (@cons A a zs))) (remove_all ys (remove_all xs (@cons A a zs))) *) pose proof (remove_all_cons xs a (remove_all ys zs)). repeat (break_or_hyp; break_and); repeat find_rewrite; try find_eapply_lem_hyp in_app_or; try assert (In a (xs ++ ys)) by (eapply in_or_app; eauto); (* Goal: @eq (list A) (remove_all xs (@app A (@remove A A_eq_dec a ys) (@remove A A_eq_dec a zs))) (@app A (remove_all xs (@remove A A_eq_dec a ys)) (remove_all xs (@remove A A_eq_dec a zs))) *) tauto. Qed. Lemma remove_all_app_r : forall xs ys zs, remove_all xs (ys ++ zs) = remove_all xs ys ++ remove_all xs zs. Proof using. (* Goal: forall xs ys zs : list A, @eq (list A) (remove_all xs (@app A ys zs)) (@app A (remove_all xs ys) (remove_all xs zs)) *) induction xs. - auto. - intros. (* Goal: @eq (list A) (remove_all (@cons A a xs) (@app A ys zs)) (@app A (remove_all (@cons A a xs) ys) (remove_all (@cons A a xs) zs)) *) simpl. (* Goal: @eq (list A) (remove_all xs (@remove A A_eq_dec a (@app A ys zs))) (@app A (remove_all xs (@remove A A_eq_dec a ys)) (remove_all xs (@remove A A_eq_dec a zs))) *) rewrite remove_app_comm. (* Goal: @eq (list A) (remove_all xs (@app A (@remove A A_eq_dec a ys) (@remove A A_eq_dec a zs))) (@app A (remove_all xs (@remove A A_eq_dec a ys)) (remove_all xs (@remove A A_eq_dec a zs))) *) auto. Qed. Lemma remove_all_del_comm : forall xs ys zs, remove_all xs (remove_all ys zs) = remove_all ys (remove_all xs zs). Proof using. (* Goal: forall xs ys zs : list A, @eq (list A) (remove_all xs (remove_all ys zs)) (remove_all ys (remove_all xs zs)) *) intros. (* Goal: forall xs ys zs : list A, @eq (list A) (remove_all xs (remove_all ys zs)) (remove_all ys (remove_all xs zs)) *) induction zs; intros. - now repeat rewrite remove_all_nil. - pose proof (remove_all_cons xs a zs). (* Goal: @eq (list A) (remove_all xs (remove_all ys (@cons A a zs))) (remove_all ys (remove_all xs (@cons A a zs))) *) pose proof (remove_all_cons ys a zs). (* Goal: @eq (list A) (remove_all xs (remove_all ys (@cons A a zs))) (remove_all ys (remove_all xs (@cons A a zs))) *) pose proof (remove_all_cons ys a (remove_all xs zs)). (* Goal: @eq (list A) (remove_all xs (remove_all ys (@cons A a zs))) (remove_all ys (remove_all xs (@cons A a zs))) *) pose proof (remove_all_cons xs a (remove_all ys zs)). repeat (break_or_hyp; break_and); repeat find_rewrite; congruence. Qed. End remove_all. Arguments in_remove_all_was_in : clear implicits.
Require Import Arith. Require Import List. Import ListNotations. Require Import StructTact.StructTactics. Set Implicit Arguments. Lemma leb_false_lt : forall m n, leb m n = false -> n < m. Proof. (* Goal: forall (m n : nat) (_ : @eq bool (Nat.leb m n) true), le m n *) induction m; intros. - discriminate. - simpl in *. break_match; subst; auto with arith. Qed. Lemma leb_true_le : forall m n, leb m n = true -> m <= n. Proof. (* Goal: forall (m n : nat) (_ : @eq bool (Nat.leb m n) true), le m n *) induction m; intros. - auto with arith. - simpl in *. break_match; subst; auto with arith. (* Goal: le (S m) O *) discriminate. Qed. Lemma ltb_false_le : forall m n, m <? n = false -> n <= m. Proof. (* Goal: le O n *) induction m; intros; destruct n; try discriminate; auto with arith. Qed. Lemma ltb_true_lt : forall m n, m <? n = true -> m < n. (* Goal: le O n *) induction m; intros; destruct n; try discriminate; auto with arith. Qed. Ltac do_bool := repeat match goal with | [ H : beq_nat _ _ = true |- _ ] => apply beq_nat_true in H | [ H : beq_nat _ _ = false |- _ ] => apply beq_nat_false in H | [ H : andb _ _ = true |- _ ] => apply Bool.andb_true_iff in H | [ H : andb _ _ = false |- _ ] => apply Bool.andb_false_iff in H | [ H : orb _ _ = true |- _ ] => apply Bool.orb_prop in H | [ H : negb _ = true |- _ ] => apply Bool.negb_true_iff in H | [ H : negb _ = false |- _ ] => apply Bool.negb_false_iff in H | [ H : PeanoNat.Nat.ltb _ _ = true |- _ ] => apply ltb_true_lt in H | [ H : PeanoNat.Nat.ltb _ _ = false |- _ ] => apply ltb_false_le in H | [ H : leb _ _ = true |- _ ] => apply leb_true_le in H | [ H : leb _ _ = false |- _ ] => apply leb_false_lt in H | [ |- andb _ _ = true ]=> apply Bool.andb_true_iff | [ |- andb _ _ = false ] => apply Bool.andb_false_iff | [ |- leb _ _ = true ] => apply leb_correct | [ |- _ <> false ] => apply Bool.not_false_iff_true | [ |- beq_nat _ _ = false ] => apply beq_nat_false_iff | [ |- beq_nat _ _ = true ] => apply beq_nat_true_iff end. Definition null {A : Type} (xs : list A) : bool := match xs with | [] => true | _ => false end. Lemma null_sound : forall A (l : list A), null l = true -> l = []. Proof. (* Goal: le (S m) O *) destruct l; simpl in *; auto; discriminate. Qed. Lemma null_false_neq_nil : forall A (l : list A), null l = false -> l <> []. Proof. (* Goal: le (S m) O *) destruct l; simpl in *; auto; discriminate. Qed.
Require Import StructTact.StructTactics. Require Import FunctionalExtensionality. Definition update {A B : Type} (A_eq_dec : forall x y : A, {x = y} + {x <> y}) st h (v : B) := fun nm => if A_eq_dec nm h then v else st nm. Section update. Variables A B : Type. Hypothesis A_eq_dec : forall x y : A, {x = y} + {x <> y}. Lemma update_diff : forall (sigma : A -> B) x v y, x <> y -> update A_eq_dec sigma x v y = sigma y. Proof using. (* Goal: @eq B (@update A B A_eq_dec sigma y v y) v *) unfold update. (* Goal: forall (A B C : Type) (A_eq_dec : forall x y : A, sumbool (@eq A x y) (not (@eq A x y))) (f : forall _ : B, C) (st : forall _ : A, B) (y : A) (v : B) (x : A), @eq C (f (@update A B A_eq_dec st y v x)) (@update A C A_eq_dec (fun x0 : A => f (st x0)) y (f v) x) *) intros. (* Goal: @eq B (if A_eq_dec y y then v else sigma y) v *) break_if; congruence. Qed. Lemma update_nop : forall (sigma : A -> B) x y, update A_eq_dec sigma x (sigma x) y = sigma y. Proof using. (* Goal: @eq B (@update A B A_eq_dec sigma y v y) v *) unfold update. (* Goal: forall (A B C : Type) (A_eq_dec : forall x y : A, sumbool (@eq A x y) (not (@eq A x y))) (f : forall _ : B, C) (st : forall _ : A, B) (y : A) (v : B) (x : A), @eq C (f (@update A B A_eq_dec st y v x)) (@update A C A_eq_dec (fun x0 : A => f (st x0)) y (f v) x) *) intros. break_if; congruence. Qed. Lemma update_eq : forall (sigma : A -> B) x y v, x = y -> update A_eq_dec sigma x v y = v. Proof using. (* Goal: forall (A B C : Type) (A_eq_dec : forall x y : A, sumbool (@eq A x y) (not (@eq A x y))) (f : forall _ : B, C) (st : forall _ : A, B) (y : A) (v : B) (x : A), @eq C (f (@update A B A_eq_dec st y v x)) (@update A C A_eq_dec (fun x0 : A => f (st x0)) y (f v) x) *) intros. subst. (* Goal: @eq B (@update A B A_eq_dec sigma y v y) v *) unfold update. (* Goal: @eq B (if A_eq_dec y y then v else sigma y) v *) break_if; congruence. Qed. Lemma update_same : forall (sigma : A -> B) x v, update A_eq_dec sigma x v x = v. Proof using. (* Goal: forall (A B C : Type) (A_eq_dec : forall x y : A, sumbool (@eq A x y) (not (@eq A x y))) (f : forall _ : B, C) (st : forall _ : A, B) (y : A) (v : B) (x : A), @eq C (f (@update A B A_eq_dec st y v x)) (@update A C A_eq_dec (fun x0 : A => f (st x0)) y (f v) x) *) intros. (* Goal: @eq B (@update A B A_eq_dec sigma x v x) v *) rewrite update_eq; auto. Qed. Lemma update_nop_ext : forall (sigma : A -> B) h, update A_eq_dec sigma h (sigma h) = sigma. Proof using. (* Goal: forall (A B C : Type) (A_eq_dec : forall x y : A, sumbool (@eq A x y) (not (@eq A x y))) (f : forall _ : B, C) (st : forall _ : A, B) (y : A) (v : B) (x : A), @eq C (f (@update A B A_eq_dec st y v x)) (@update A C A_eq_dec (fun x0 : A => f (st x0)) y (f v) x) *) intros. (* Goal: @eq (forall _ : A, B) (@update A B A_eq_dec (@update A B A_eq_dec sigma h st) h st') (@update A B A_eq_dec sigma h st') *) apply functional_extensionality. (* Goal: forall (A B C : Type) (A_eq_dec : forall x y : A, sumbool (@eq A x y) (not (@eq A x y))) (f : forall _ : B, C) (st : forall _ : A, B) (y : A) (v : B) (x : A), @eq C (f (@update A B A_eq_dec st y v x)) (@update A C A_eq_dec (fun x0 : A => f (st x0)) y (f v) x) *) intros. (* Goal: @eq B (@update A B A_eq_dec sigma h (sigma h) x) (sigma x) *) apply update_nop. Qed. Lemma update_nop_ext' : forall (sigma : A -> B) y v, sigma y = v -> update A_eq_dec sigma y v = sigma. Proof using. (* Goal: forall (A B C : Type) (A_eq_dec : forall x y : A, sumbool (@eq A x y) (not (@eq A x y))) (f : forall _ : B, C) (st : forall _ : A, B) (y : A) (v : B) (x : A), @eq C (f (@update A B A_eq_dec st y v x)) (@update A C A_eq_dec (fun x0 : A => f (st x0)) y (f v) x) *) intros. (* Goal: @eq (forall _ : A, B) (@update A B A_eq_dec sigma y v) sigma *) subst. (* Goal: @eq (forall _ : A, B) (@update A B A_eq_dec sigma y (sigma y)) sigma *) apply update_nop_ext. Qed. Lemma update_overwrite : forall (sigma : A -> B) h st st', update A_eq_dec (update A_eq_dec sigma h st) h st' = update A_eq_dec sigma h st'. Proof using. (* Goal: forall (A B C : Type) (A_eq_dec : forall x y : A, sumbool (@eq A x y) (not (@eq A x y))) (f : forall _ : B, C) (st : forall _ : A, B) (y : A) (v : B) (x : A), @eq C (f (@update A B A_eq_dec st y v x)) (@update A C A_eq_dec (fun x0 : A => f (st x0)) y (f v) x) *) intros. (* Goal: @eq (forall _ : A, B) (@update A B A_eq_dec (@update A B A_eq_dec sigma h st) h st') (@update A B A_eq_dec sigma h st') *) apply functional_extensionality. (* Goal: forall (A B C : Type) (A_eq_dec : forall x y : A, sumbool (@eq A x y) (not (@eq A x y))) (f : forall _ : B, C) (st : forall _ : A, B) (y : A) (v : B) (x : A), @eq C (f (@update A B A_eq_dec st y v x)) (@update A C A_eq_dec (fun x0 : A => f (st x0)) y (f v) x) *) intros. destruct (A_eq_dec h x). (* Goal: @eq B (@update A B A_eq_dec sigma x v x) v *) - repeat rewrite update_eq; auto. - repeat rewrite update_diff; auto. Qed. End update. Lemma update_fun_comm : forall A B C A_eq_dec (f : B -> C) (st : A -> B) y v x, f (update A_eq_dec st y v x) = update A_eq_dec (fun x => f (st x)) y (f v) x. Proof. (* Goal: forall (A B C : Type) (A_eq_dec : forall x y : A, sumbool (@eq A x y) (not (@eq A x y))) (f : forall _ : B, C) (st : forall _ : A, B) (y : A) (v : B) (x : A), @eq C (f (@update A B A_eq_dec st y v x)) (@update A C A_eq_dec (fun x0 : A => f (st x0)) y (f v) x) *) intros. destruct (A_eq_dec x y); subst; repeat first [rewrite update_diff by congruence | rewrite update_eq by auto ]; auto. Qed. Ltac update_destruct_goal := match goal with | [ |- context [ update ?eq_dec _ ?y _ ?x ] ] => destruct (eq_dec y x) end. Ltac update_destruct_hyp := match goal with | [ _ : context [ update ?eq_dec _ ?y _ ?x ] |- _ ] => destruct (eq_dec y x) end. Ltac update_destruct := update_destruct_goal || update_destruct_hyp. Ltac rewrite_update' H := first [rewrite update_diff in H by congruence | rewrite update_eq in H by auto ]. Ltac rewrite_update := repeat match goal with | [ H : context [ update _ _ _ _ _ ] |- _ ] => rewrite_update' H; repeat rewrite_update' H | [ |- _ ] => repeat (try rewrite update_diff by congruence; try rewrite update_eq by auto) end. Ltac destruct_update := repeat (update_destruct; subst; rewrite_update). Ltac destruct_update_hyp := repeat ((update_destruct_hyp || update_destruct_goal); subst; rewrite_update). Ltac update_destruct_simplify := update_destruct; subst; rewrite_update; simpl in *. Ltac update_destruct_simplify_hyp := update_destruct_hyp || update_destruct_goal; subst; rewrite_update; simpl in *. Ltac update_destruct_max_simplify := update_destruct; subst_max; rewrite_update; simpl in *.
Require Import List. Import ListNotations. Require Import StructTact.StructTactics. Require Import StructTact.ListTactics. Require Import StructTact.ListUtil. Require Import StructTact.RemoveAll. Require Import StructTact.PropUtil. Require Import FunctionalExtensionality. Require Import Sumbool. Require Import Sorting.Permutation. Require Import Relation_Definitions. Require Import RelationClasses. Definition update2 {A B : Type} (A_eq_dec : forall x y : A, {x = y} + {x <> y}) (f : A -> A -> B) (x y : A) (v : B) := fun x' y' => if sumbool_and _ _ _ _ (A_eq_dec x x') (A_eq_dec y y') then v else f x' y'. Fixpoint collate {A B : Type} (A_eq_dec : forall x y : A, {x = y} + {x <> y}) (from : A) (f : A -> A -> list B) (ms : list (A * B)) := match ms with | [] => f | (to, m) :: ms' => collate A_eq_dec from (update2 A_eq_dec f from to (f from to ++ [m])) ms' end. Fixpoint collate_ls {A B : Type} (A_eq_dec : forall x y : A, {x = y} + {x <> y}) (s : list A) (f : A -> A -> list B) (to : A) (m : B) := match s with | [] => f | from :: s' => collate_ls A_eq_dec s' (update2 A_eq_dec f from to (f from to ++ [m])) to m end. Fixpoint filter_rel {A : Type} {rel : relation A} (A_rel_dec : forall x y : A, {rel x y} + {~ rel x y}) (x : A) (l : list A) := match l with | [] => [] | y :: tl => if A_rel_dec x y then y :: filter_rel A_rel_dec x tl else filter_rel A_rel_dec x tl end. Definition map2fst {A B : Type} (a : A) := map (fun (b : B) => (a, b)). Definition map2snd {A B : Type} (b : B) := map (fun (a : A) => (a, b)). Section Update2. Variables A B : Type. Hypothesis A_eq_dec : forall x y : A, {x = y} + {x <> y}. Lemma update2_diff1 : forall (sigma : A -> A -> B) x y v x' y', x <> x' -> update2 A_eq_dec sigma x y v x' y' = sigma x' y'. Proof using. (* Goal: @eq (list B) (@update2 A (list B) A_eq_dec f h' h (@app B (f h' h) (@cons B m (@nil B))) from to) (f from to) *) unfold update2. (* Goal: forall (f : forall (_ : A) (_ : A), list B) (l' : list A) (_ : @NoDup A (@cons A a l)) (_ : @Permutation A (@cons A a l) l'), @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@cons A a l) f h m) (@collate_ls A B A_eq_dec l' f h m) *) intros. (* Goal: @eq B (if sumbool_and (@eq A x x') (not (@eq A x x')) (@eq A y y') (not (@eq A y y')) (A_eq_dec x x') (A_eq_dec y y') then v else sigma x' y') v *) break_if; intuition congruence. Qed. Lemma update2_diff2 : forall (sigma : A -> A -> B) x y v x' y', y <> y' -> update2 A_eq_dec sigma x y v x' y' = sigma x' y'. Proof using. (* Goal: @eq (list B) (@update2 A (list B) A_eq_dec f h' h (@app B (f h' h) (@cons B m (@nil B))) from to) (f from to) *) unfold update2. (* Goal: forall (f : forall (_ : A) (_ : A), list B) (l' : list A) (_ : @NoDup A (@cons A a l)) (_ : @Permutation A (@cons A a l) l'), @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@cons A a l) f h m) (@collate_ls A B A_eq_dec l' f h m) *) intros. (* Goal: @eq B (if sumbool_and (@eq A x x') (not (@eq A x x')) (@eq A y y') (not (@eq A y y')) (A_eq_dec x x') (A_eq_dec y y') then v else sigma x' y') v *) break_if; intuition congruence. Qed. Lemma update2_diff_prod : forall (sigma : A -> A -> B) x y v x' y', (x, y) <> (x', y') -> update2 A_eq_dec sigma x y v x' y' = sigma x' y'. Proof using. (* Goal: @eq (list B) (@update2 A (list B) A_eq_dec f h' h (@app B (f h' h) (@cons B m (@nil B))) from to) (f from to) *) unfold update2. (* Goal: forall (f : forall (_ : A) (_ : A), list B) (l' : list A) (_ : @NoDup A (@cons A a l)) (_ : @Permutation A (@cons A a l) l'), @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@cons A a l) f h m) (@collate_ls A B A_eq_dec l' f h m) *) intros. (* Goal: @eq B (if sumbool_and (@eq A x x') (not (@eq A x x')) (@eq A y y') (not (@eq A y y')) (A_eq_dec x x') (A_eq_dec y y') then v else sigma x' y') v *) break_if; intuition congruence. Qed. Lemma update2_nop : forall (sigma : A -> A -> B) x y x' y', update2 A_eq_dec sigma x y (sigma x y) x' y' = sigma x' y'. Proof using. (* Goal: @eq (list B) (@update2 A (list B) A_eq_dec f h' h (@app B (f h' h) (@cons B m (@nil B))) from to) (f from to) *) unfold update2. (* Goal: forall (f : forall (_ : A) (_ : A), list B) (l' : list A) (_ : @NoDup A (@cons A a l)) (_ : @Permutation A (@cons A a l) l'), @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@cons A a l) f h m) (@collate_ls A B A_eq_dec l' f h m) *) intros. break_if; intuition congruence. Qed. Lemma update2_eq : forall (sigma : A -> A -> B) x y x' y' v, x = x' -> y = y' -> update2 A_eq_dec sigma x y v x' y' = v. Proof using. (* Goal: forall (f : forall (_ : A) (_ : A), list B) (l' : list A) (_ : @NoDup A (@cons A a l)) (_ : @Permutation A (@cons A a l) l'), @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@cons A a l) f h m) (@collate_ls A B A_eq_dec l' f h m) *) intros. subst. (* Goal: @eq (list B) (@update2 A (list B) A_eq_dec f h' h (@app B (f h' h) (@cons B m (@nil B))) from to) (f from to) *) unfold update2. (* Goal: @eq B (if sumbool_and (@eq A x x') (not (@eq A x x')) (@eq A y y') (not (@eq A y y')) (A_eq_dec x x') (A_eq_dec y y') then v else sigma x' y') v *) break_if; intuition congruence. Qed. Lemma update2_eq_prod : forall (sigma : A -> A -> B) x y x' y' v, (x, y) = (x', y') -> update2 A_eq_dec sigma x y v x' y' = v. Proof using. (* Goal: forall (f : forall (_ : A) (_ : A), list B) (l' : list A) (_ : @NoDup A (@cons A a l)) (_ : @Permutation A (@cons A a l) l'), @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@cons A a l) f h m) (@collate_ls A B A_eq_dec l' f h m) *) intros. subst. (* Goal: @eq (list B) (@update2 A (list B) A_eq_dec f h' h (@app B (f h' h) (@cons B m (@nil B))) from to) (f from to) *) unfold update2. (* Goal: @eq B (if sumbool_and (@eq A x x') (not (@eq A x x')) (@eq A y y') (not (@eq A y y')) (A_eq_dec x x') (A_eq_dec y y') then v else sigma x' y') v *) break_if; intuition congruence. Qed. Lemma update2_same : forall (sigma : A -> A -> B) x y v, update2 A_eq_dec sigma x y v x y = v. Proof using. (* Goal: forall (f : forall (_ : A) (_ : A), list B) (l' : list A) (_ : @NoDup A (@cons A a l)) (_ : @Permutation A (@cons A a l) l'), @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@cons A a l) f h m) (@collate_ls A B A_eq_dec l' f h m) *) intros. (* Goal: @eq B (@update2 A B A_eq_dec sigma x y v x y) v *) rewrite update2_eq; auto. Qed. Lemma update2_nop_ext : forall (sigma : A -> A -> B) x y, update2 A_eq_dec sigma x y (sigma x y) = sigma. Proof using. (* Goal: forall (f : forall (_ : A) (_ : A), list B) (l' : list A) (_ : @NoDup A (@cons A a l)) (_ : @Permutation A (@cons A a l) l'), @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@cons A a l) f h m) (@collate_ls A B A_eq_dec l' f h m) *) intros. (* Goal: @eq (forall (_ : A) (_ : A), B) (@update2 A B A_eq_dec (@update2 A B A_eq_dec sigma x y st) x y st') (@update2 A B A_eq_dec sigma x y st') *) do 2 (apply functional_extensionality; intros). (* Goal: @eq B (@update2 A B A_eq_dec sigma x y (sigma x y) x0 x1) (sigma x0 x1) *) apply update2_nop. Qed. Lemma update2_nop_ext' : forall (sigma : A -> A -> B) x y v, sigma x y = v -> update2 A_eq_dec sigma x y v = sigma. Proof using. (* Goal: forall (f : forall (_ : A) (_ : A), list B) (l' : list A) (_ : @NoDup A (@cons A a l)) (_ : @Permutation A (@cons A a l) l'), @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@cons A a l) f h m) (@collate_ls A B A_eq_dec l' f h m) *) intros. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@nil A) f h m) (@collate_ls A B A_eq_dec l' f h m) *) subst. (* Goal: @eq (forall (_ : A) (_ : A), B) (@update2 A B A_eq_dec sigma x y (sigma x y)) sigma *) apply update2_nop_ext. Qed. Lemma update2_overwrite : forall (sigma : A -> A -> B) x y st st', update2 A_eq_dec (update2 A_eq_dec sigma x y st) x y st' = update2 A_eq_dec sigma x y st'. Proof using. (* Goal: forall (f : forall (_ : A) (_ : A), list B) (l' : list A) (_ : @NoDup A (@cons A a l)) (_ : @Permutation A (@cons A a l) l'), @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@cons A a l) f h m) (@collate_ls A B A_eq_dec l' f h m) *) intros. (* Goal: @eq (forall (_ : A) (_ : A), B) (@update2 A B A_eq_dec (@update2 A B A_eq_dec sigma x y st) x y st') (@update2 A B A_eq_dec sigma x y st') *) do 2 (apply functional_extensionality; intros). destruct (A_eq_dec x x0); destruct (A_eq_dec y x1). (* Goal: @eq B (@update2 A B A_eq_dec sigma x y v x y) v *) - repeat rewrite update2_eq; auto. - repeat rewrite update2_diff2; auto. - repeat rewrite update2_diff1; auto. - repeat rewrite update2_diff1; auto. Qed. End Update2. Lemma update2_fun_comm : forall A B C A_eq_dec (f : B -> C) (st : A -> A -> B) x y v x' y', f (update2 A_eq_dec st x y v x' y') = update2 A_eq_dec (fun x y => f (st x y)) x y (f v) x' y'. Proof using. (* Goal: forall (f : forall (_ : A) (_ : A), list B) (l' : list A) (_ : @NoDup A (@cons A a l)) (_ : @Permutation A (@cons A a l) l'), @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@cons A a l) f h m) (@collate_ls A B A_eq_dec l' f h m) *) intros. destruct (prod_eq_dec A_eq_dec A_eq_dec (x, y) (x', y')); subst; repeat first [rewrite update2_diff_prod by congruence | (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) rewrite update2_eq_prod by auto ]; auto. Qed. Ltac update2_destruct_goal := match goal with | [ |- context [ update2 ?eq_dec _ ?x ?y _ ?x' ?y' ] ] => destruct (prod_eq_dec eq_dec eq_dec (x, y) (x', y')) end. Ltac update2_destruct_hyp := match goal with | [ _ : context [ update2 ?eq_dec _ ?x ?y _ ?x' ?y' ] |- _ ] => destruct (prod_eq_dec eq_dec eq_dec (x, y) (x', y')) end. Ltac update2_destruct := update2_destruct_goal || update2_destruct_hyp. Ltac rewrite_update2' H := first [rewrite update2_diff_prod in H by congruence | rewrite update2_eq_prod in H by auto ]. Ltac rewrite_update2 := repeat match goal with | [ H : context [ update2 _ _ _ _ _ _ _ ] |- _ ] => rewrite_update2' H; repeat rewrite_update2' H | [ |- _ ] => repeat (try rewrite update2_diff_prod by congruence; try rewrite update2_eq_prod by auto) end. Ltac destruct_update2 := repeat (update2_destruct; subst; rewrite_update2). Ltac destruct_update2_hyp := repeat ((update2_destruct_hyp || update2_destruct_goal); subst; rewrite_update2). Ltac update2_destruct_simplify := update2_destruct; subst; rewrite_update2; simpl in *. Ltac update2_destruct_simplify_hyp := update2_destruct_hyp || update2_destruct_goal; subst; rewrite_update2; simpl in *. Ltac update2_destruct_max_simplify := update2_destruct; subst_max; rewrite_update2; simpl in *. Section Update2Rel. Variables A B : Type. Variable R : relation A. Hypothesis A_eq_dec : forall x y : A, {x = y} + {x <> y}. Hypothesis R_dec : forall x y : A, {R x y} + {~ R x y}. Lemma filter_rel_related : forall n n' ns, In n' (filter_rel R_dec n ns) -> In n' ns /\ R n n'. Proof using. (* Goal: forall (f : forall (_ : A) (_ : A), list B) (l' : list A) (_ : @NoDup A (@cons A a l)) (_ : @Permutation A (@cons A a l) l'), @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@cons A a l) f h m) (@collate_ls A B A_eq_dec l' f h m) *) intros. (* Goal: @In A n' (@filter_rel A R R_dec n ns) *) induction ns; simpl in *; [ intuition | idtac ]. (* Goal: and (R h n) (or (@eq A a n) (@In A n ns)) *) break_if; simpl in *. - break_or_hyp; auto. (* Goal: @NoDup (prod A B) (@map2snd A B m (@filter_rel A R R_dec h (@cons A a ns))) *) concludes. (* Goal: @eq (list B) (@app B (f h to) (@cons B m (@nil B))) (f from to) *) break_and. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) auto. - concludes. (* Goal: @eq (list B) (@app B (f h to) (@cons B m (@nil B))) (f from to) *) break_and. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) auto. Qed. Lemma related_filter_rel : forall n n' ns, In n' ns -> R n n' -> In n' (filter_rel R_dec n ns). Proof using. (* Goal: forall (f : forall (_ : A) (_ : A), list B) (l' : list A) (_ : @NoDup A (@cons A a l)) (_ : @Permutation A (@cons A a l) l'), @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@cons A a l) f h m) (@collate_ls A B A_eq_dec l' f h m) *) intros. (* Goal: @In A n' (@filter_rel A R R_dec n ns) *) induction ns; simpl in *; [ intuition | idtac ]. (* Goal: @eq (list B) (@update2 A (list B) A_eq_dec f h' h (@app B (f h' h) (@cons B m (@nil B))) h' h) (if sumbool_and (@eq A h' h') (not (@eq A h' h')) (@eq A h h) (not (@eq A h h)) (A_eq_dec h' h') (A_eq_dec h h) then @app B (f' h' h) (@cons B m (@nil B)) else f' h' h) *) break_if. - break_or_hyp. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) * left; auto. (* Goal: @NoDup (prod A B) (@map2snd A B m (@filter_rel A R R_dec h (@cons A a ns))) *) * concludes. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) right; auto. - break_or_hyp. * intuition. (* Goal: @NoDup (prod A B) (@map2snd A B m (@filter_rel A R R_dec h (@cons A a ns))) *) * concludes. (* Goal: @Permutation A l (@app A x x0) *) assumption. Qed. Lemma not_in_not_in_filter_rel : forall ns n h, ~ In n ns -> ~ In n (filter_rel R_dec h ns). Proof using. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) induction ns; intros; auto. (* Goal: @eq (list B) (@collate_ls A B A_eq_dec (@filter_rel A R R_dec h (@remove_all A A_eq_dec ns' ns)) (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B mg (@nil B)))) h mg n h) (f n h) *) assert (H_neq: a <> n). (* Goal: not (@In A a (@app A x x0)) *) intro. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@nil A) f h m) (@collate_ls A B A_eq_dec l' f h m) *) subst. (* Goal: False *) (* Goal: not (@In A n (@filter_rel A R R_dec h (@cons A a ns))) *) auto with datatypes. (* Goal: not (@In A n (@filter_rel A R R_dec h (@cons A a ns))) *) assert (H_not_in: ~ In n ns). (* Goal: not (@In A a (@app A x x0)) *) intro. (* Goal: @eq (list B) (@app B (f from to) (@cons B m (@nil B))) (f from to) *) intuition. (* Goal: @eq (list B) (@collate_ls A B A_eq_dec (@cons A a (@filter_rel A R R_dec h (@remove_all A A_eq_dec ns' ns))) f h mg n h) (f n h) *) simpl. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) break_if; auto. (* Goal: @eq (list B) (@collate_ls A B A_eq_dec (@cons A a (@filter_rel A R R_dec h (@remove_all A A_eq_dec ns' ns))) f h mg n h) (f n h) *) simpl. (* Goal: not (@In A a (@app A x x0)) *) intro. (* Goal: False *) break_or_hyp; auto. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) intuition eauto. Qed. Lemma NoDup_filter_rel: forall h ns, NoDup ns -> NoDup (filter_rel R_dec h ns). Proof using. (* Goal: forall (f : forall (_ : A) (_ : A), list B) (l' : list A) (_ : @NoDup A (@cons A a l)) (_ : @Permutation A (@cons A a l) l'), @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@cons A a l) f h m) (@collate_ls A B A_eq_dec l' f h m) *) intros. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) induction ns; auto. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@cons A a l) f h m) (@collate_ls A B A_eq_dec l' f h m) *) invc_NoDup. (* Goal: @NoDup (prod A B) (@map2snd A B m (@filter_rel A R R_dec h (@cons A a ns))) *) concludes. simpl in *. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) break_if; auto. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) apply NoDup_cons; auto. (* Goal: not (@In A n (@filter_rel A R R_dec h (@remove_all A A_eq_dec ns' ns))) *) apply not_in_not_in_filter_rel. (* Goal: @Permutation A l (@app A x x0) *) assumption. Qed. Lemma filter_rel_self_eq {irreflexive_R : Irreflexive R} : forall ns0 ns1 h, filter_rel R_dec h (ns0 ++ h :: ns1) = filter_rel R_dec h (ns0 ++ ns1). Proof using. induction ns0; intros; simpl in *. - break_if; auto. (* Goal: @eq (list A) (@cons A h (@filter_rel A R R_dec h ns1)) (@filter_rel A R R_dec h ns1) *) find_apply_lem_hyp irreflexive_R. (* Goal: @eq (list B) (@app B (f from to) (@cons B m (@nil B))) (f from to) *) intuition. - break_if; auto. (* Goal: @eq (list A) (@cons A a (@filter_rel A R R_dec h (@app A ns0 (@cons A h ns1)))) (@cons A a (@filter_rel A R R_dec h (@app A ns0 ns1))) *) find_higher_order_rewrite. (* Goal: @eq A a a *) (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec l' f h m) *) trivial. Qed. Lemma collate_f_eq : forall (f : A -> A -> list B) g h n n' l, f n n' = g n n' -> collate A_eq_dec h f l n n' = collate A_eq_dec h g l n n'. Proof using. (* Goal: forall (f g : forall (_ : A) (_ : A), list B) (h n n' : A) (l : list (prod A B)) (_ : @eq (list B) (f n n') (g n n')), @eq (list B) (@collate A B A_eq_dec h f l n n') (@collate A B A_eq_dec h g l n n') *) intros f g h n n' l. (* Goal: forall _ : @eq (list B) (f n n') (g n n'), @eq (list B) (@collate A B A_eq_dec h f l n n') (@collate A B A_eq_dec h g l n n') *) generalize f g; clear f g. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) induction l; auto. (* Goal: forall (f : forall (_ : A) (_ : A), list B) (l' : list A) (_ : @NoDup A (@cons A a l)) (_ : @Permutation A (@cons A a l) l'), @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@cons A a l) f h m) (@collate_ls A B A_eq_dec l' f h m) *) intros. simpl in *. (* Goal: @eq (list B) ((let (to, m) := a in @collate A B A_eq_dec h (@update2 A (list B) A_eq_dec (@collate A B A_eq_dec h f l1) h to (@app B (@collate A B A_eq_dec h f l1 h to) (@cons B m (@nil B)))) l2) h h') (@collate A B A_eq_dec h f l1 h h') *) break_let. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate A B A_eq_dec h f (@cons (prod A B) a l)) (@collate A B A_eq_dec h f l') *) destruct a. (* Goal: False *) find_injection. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec (@app A x (@cons A a x0)) f h m) *) set (f' := update2 _ _ _ _ _). (* Goal: @eq (list B) (@collate_ls A B A_eq_dec ns f' h mg n n') (@collate_ls A B A_eq_dec ns (@update2 A (list B) A_eq_dec g a h (@app B (g a h) (@cons B mg (@nil B)))) h mg n n') *) set (g' := update2 _ _ _ _ _). (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) rewrite (IHl f' g'); auto. (* Goal: @eq (list B) (f' n n') (g' n n') *) unfold f', g', update2. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) break_if; auto. (* Goal: @eq (list B) (@app B (f h to) (@cons B m (@nil B))) (f from to) *) break_and. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@nil A) f h m) (@collate_ls A B A_eq_dec l' f h m) *) subst. (* Goal: @In B x (f a b) *) find_rewrite. (* Goal: @eq A a a *) (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec l' f h m) *) trivial. Qed. Lemma collate_in_in : forall l h n n' (f : A -> A -> list B) a, In a (f n' n) -> In a ((collate A_eq_dec h f l) n' n). Proof using. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) induction l; intros; auto. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate A B A_eq_dec h f (@cons (prod A B) a l)) (@collate A B A_eq_dec h f l') *) destruct a. (* Goal: @eq (option B) (@hd_error B (@collate A B A_eq_dec h (@update2 A (list B) A_eq_dec f h a (@app B (f h a) (@cons B b (@nil B)))) l n' n)) (@Some B a0) *) apply IHl. (* Goal: @eq (list B) (@update2 A (list B) A_eq_dec f h' h (@app B (f h' h) (@cons B m (@nil B))) from to) (f from to) *) unfold update2. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) break_if; auto. (* Goal: @eq (list B) (@app B (f h to) (@cons B m (@nil B))) (f from to) *) break_and. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@nil A) f h m) (@collate_ls A B A_eq_dec l' f h m) *) subst. (* Goal: @In A h' (@app A l1 l2) *) apply in_or_app. (* Goal: @In A a (@cons A a l) *) (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec l' f h m) *) left. (* Goal: @Permutation A l (@app A x x0) *) assumption. Qed. Lemma collate_head_head : forall l h n n' (f : A -> A -> list B) a, head (f n' n) = Some a -> head ((collate A_eq_dec h f l) n' n) = Some a. Proof using. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) induction l; intros; auto. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate A B A_eq_dec h f (@cons (prod A B) a l)) (@collate A B A_eq_dec h f l') *) destruct a. (* Goal: @eq (list B) (@collate_ls A B A_eq_dec (@cons A a (@filter_rel A R R_dec h (@remove_all A A_eq_dec ns' ns))) f h mg n h) (f n h) *) simpl. (* Goal: @eq (option B) (@hd_error B (@collate A B A_eq_dec h (@update2 A (list B) A_eq_dec f h a (@app B (f h a) (@cons B b (@nil B)))) l n' n)) (@Some B a0) *) apply IHl. (* Goal: @eq (list B) (@update2 A (list B) A_eq_dec f h' h (@app B (f h' h) (@cons B m (@nil B))) from to) (f from to) *) unfold update2. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) break_if; auto. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@nil A) f h m) (@collate_ls A B A_eq_dec l' f h m) *) break_and; subst. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) destruct (f n' n); auto. (* Goal: @eq (option B) (@hd_error B (@app B (@nil B) (@cons B b (@nil B)))) (@Some B a0) *) find_apply_lem_hyp hd_error_some_nil. (* Goal: @eq (list B) (@app B (f from to) (@cons B m (@nil B))) (f from to) *) intuition. Qed. Lemma collate_neq : forall h n n' ns (f : A -> A -> list B), h <> n -> collate A_eq_dec h f ns n n' = f n n'. Proof using. (* Goal: forall (f : forall (_ : A) (_ : A), list B) (l' : list A) (_ : @NoDup A (@cons A a l)) (_ : @Permutation A (@cons A a l) l'), @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@cons A a l) f h m) (@collate_ls A B A_eq_dec l' f h m) *) intros. (* Goal: @eq (list B) (@collate_ls A B A_eq_dec (@filter_rel A R R_dec h (@remove_all A A_eq_dec ns' ns)) f h mg n h) (f n h) *) revert f. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) induction ns; intros; auto. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate A B A_eq_dec h f (@cons (prod A B) a l)) (@collate A B A_eq_dec h f l') *) destruct a. simpl in *. (* Goal: @eq (list B) (@collate_ls A B A_eq_dec (@filter_rel A R R_dec h (@remove_all A A_eq_dec ns' ns)) (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B mg (@nil B)))) h mg n h) (f n h) *) rewrite IHns. (* Goal: @eq (list B) (@update2 A (list B) A_eq_dec f h' h (@app B (f h' h) (@cons B m (@nil B))) from to) (f from to) *) unfold update2. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) break_if; auto. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@nil A) f h m) (@collate_ls A B A_eq_dec l' f h m) *) break_and; subst. (* Goal: @eq (list B) (@app B (f from to) (@cons B m (@nil B))) (f from to) *) intuition. Qed. Lemma collate_not_in_eq : forall h' h (f : A -> A -> list B) l, ~ In h (map fst l) -> collate A_eq_dec h' f l h' h = f h' h. Proof using. (* Goal: forall (f : forall (_ : A) (_ : A), list B) (l' : list A) (_ : @NoDup A (@cons A a l)) (_ : @Permutation A (@cons A a l) l'), @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@cons A a l) f h m) (@collate_ls A B A_eq_dec l' f h m) *) intros. (* Goal: @eq (list B) (@collate_ls A B A_eq_dec (@filter_rel A R R_dec h (@remove_all A A_eq_dec ns' ns)) f h mg n h) (f n h) *) revert f. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) induction l; intros; auto. simpl in *. (* Goal: @eq (list B) ((let (to, m) := a in @collate A B A_eq_dec h (@update2 A (list B) A_eq_dec (@collate A B A_eq_dec h f l1) h to (@app B (@collate A B A_eq_dec h f l1 h to) (@cons B m (@nil B)))) l2) h h') (@collate A B A_eq_dec h f l1 h h') *) break_let. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate A B A_eq_dec h f (@cons (prod A B) a l)) (@collate A B A_eq_dec h f l') *) destruct a. (* Goal: False *) find_injection. (* Goal: @eq (list B) (@update2 A (list B) A_eq_dec f h' h (@app B (f h' h) (@cons B m (@nil B))) from to) (f from to) *) rewrite IHl; unfold update2. - break_if. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@nil A) f h m) (@collate_ls A B A_eq_dec l' f h m) *) * break_and; subst. simpl in *. (* Goal: False *) contradict H. (* Goal: @In A a (@cons A a l) *) (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec l' f h m) *) left. (* Goal: @eq A a a *) (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec l' f h m) *) trivial. (* Goal: forall (f : forall (_ : A) (_ : A), list B) (l' : list A) (_ : @NoDup A (@cons A a l)) (_ : @Permutation A (@cons A a l) l'), @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@cons A a l) f h m) (@collate_ls A B A_eq_dec l' f h m) *) * intros. (* Goal: @eq A a a *) (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec l' f h m) *) trivial. - intro. (* Goal: False *) contradict H. (* Goal: or (@In A h' l1) (@In A h' l2) *) right. (* Goal: @Permutation A l (@app A x x0) *) assumption. Qed. Lemma collate_app : forall h' l1 l2 (f : A -> A -> list B), collate A_eq_dec h' f (l1 ++ l2) = collate A_eq_dec h' (collate A_eq_dec h' f l1) l2. Proof using. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) induction l1; intros; auto. (* Goal: @eq (list B) (@collate_ls A B A_eq_dec (@cons A a (@filter_rel A R R_dec h (@remove_all A A_eq_dec ns' ns))) f h mg n h) (f n h) *) simpl. (* Goal: @eq (list B) ((let (to, m) := a in @collate A B A_eq_dec h (@update2 A (list B) A_eq_dec (@collate A B A_eq_dec h f l1) h to (@app B (@collate A B A_eq_dec h f l1 h to) (@cons B m (@nil B)))) l2) h h') (@collate A B A_eq_dec h f l1 h h') *) break_let. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate A B A_eq_dec h f (@cons (prod A B) a l)) (@collate A B A_eq_dec h f l') *) destruct a. (* Goal: False *) find_injection. (* Goal: @eq (list B) (@collate A B A_eq_dec h (@collate A B A_eq_dec h (@update2 A (list B) A_eq_dec f h a0 (@app B (f h a0) (@cons B b (@nil B)))) l1) l2 h h') (@collate A B A_eq_dec h f l2 h h') *) rewrite IHl1. (* Goal: @eq A a a *) (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec l' f h m) *) trivial. Qed. Lemma collate_neq_update2 : forall h h' n (f : A -> A -> list B) l ms, n <> h' -> collate A_eq_dec h (update2 A_eq_dec f h n ms) l h h' = collate A_eq_dec h f l h h'. Proof using. (* Goal: forall (f : forall (_ : A) (_ : A), list B) (l' : list A) (_ : @NoDup A (@cons A a l)) (_ : @Permutation A (@cons A a l) l'), @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@cons A a l) f h m) (@collate_ls A B A_eq_dec l' f h m) *) intros. assert (H_eq: update2 A_eq_dec f h n ms h h' = f h h'). (* Goal: @eq (list B) (@update2 A (list B) A_eq_dec f h' h (@app B (f h' h) (@cons B m (@nil B))) from to) (f from to) *) unfold update2. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) break_if; auto. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@nil A) f h m) (@collate_ls A B A_eq_dec l' f h m) *) break_and; subst. (* Goal: @eq (list B) (@app B (f from to) (@cons B m (@nil B))) (f from to) *) intuition. (* Goal: @eq (list B) (@collate A B A_eq_dec h (@update2 A (list B) A_eq_dec f h n ms) l h h') (@collate A B A_eq_dec h f l h h') *) rewrite (collate_f_eq _ _ _ _ _ _ H_eq). (* Goal: @eq A a a *) (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec l' f h m) *) trivial. Qed. Lemma collate_not_in : forall h h' l1 l2 (f : A -> A -> list B), ~ In h' (map fst l1) -> collate A_eq_dec h f (l1 ++ l2) h h' = collate A_eq_dec h f l2 h h'. Proof using. (* Goal: forall (f : forall (_ : A) (_ : A), list B) (l' : list A) (_ : @NoDup A (@cons A a l)) (_ : @Permutation A (@cons A a l) l'), @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@cons A a l) f h m) (@collate_ls A B A_eq_dec l' f h m) *) intros. (* Goal: @eq (list B) (@collate A B A_eq_dec h' (@collate A B A_eq_dec h' f l1) l2 h' to) (@collate A B A_eq_dec h' f (@app (prod A B) l1 (@cons (prod A B) (@pair A B h m) l2)) h' to) *) rewrite collate_app. (* Goal: @eq (list B) (@collate_ls A B A_eq_dec (@filter_rel A R R_dec h (@remove_all A A_eq_dec ns' ns)) f h mg n h) (f n h) *) revert f. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) induction l1; intros; simpl in *; auto. (* Goal: @eq (list B) ((let (to, m) := a in @collate A B A_eq_dec h (@update2 A (list B) A_eq_dec (@collate A B A_eq_dec h f l1) h to (@app B (@collate A B A_eq_dec h f l1 h to) (@cons B m (@nil B)))) l2) h h') (@collate A B A_eq_dec h f l1 h h') *) break_let. (* Goal: @eq (list B) (@collate A B A_eq_dec h (@collate A B A_eq_dec h (@update2 A (list B) A_eq_dec f h a0 (@app B (f h a0) (@cons B b (@nil B)))) l1) l2 h h') (@collate A B A_eq_dec h f l2 h h') *) rewrite IHl1. - destruct a. (* Goal: False *) find_injection. simpl in *. (* Goal: @eq (list B) (@collate A B A_eq_dec h (@update2 A (list B) A_eq_dec f h a0 (@app B (f h a0) (@cons B b (@nil B)))) l2 h h') (@collate A B A_eq_dec h f l2 h h') *) assert (H_neq: a0 <> h'). (* Goal: not (@In A a (@app A x x0)) *) intro. (* Goal: False *) contradict H. (* Goal: @In A a (@cons A a l) *) (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec l' f h m) *) left. (* Goal: @eq A a a *) (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec l' f h m) *) trivial. (* Goal: @eq A a a *) (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec l' f h m) *) rewrite collate_neq_update2; trivial. - intro. (* Goal: False *) contradict H. (* Goal: or (@In A h' l1) (@In A h' l2) *) right. (* Goal: @eq A a a *) (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec l' f h m) *) trivial. Qed. Lemma collate_not_in_rest : forall h h' l1 l2 (f : A -> A -> list B), ~ In h' (map fst l2) -> collate A_eq_dec h f (l1 ++ l2) h h' = collate A_eq_dec h f l1 h h'. Proof using. (* Goal: forall (f : forall (_ : A) (_ : A), list B) (l' : list A) (_ : @NoDup A (@cons A a l)) (_ : @Permutation A (@cons A a l) l'), @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@cons A a l) f h m) (@collate_ls A B A_eq_dec l' f h m) *) intros. (* Goal: @eq (list B) (@collate A B A_eq_dec h' (@collate A B A_eq_dec h' f l1) l2 h' to) (@collate A B A_eq_dec h' f (@app (prod A B) l1 (@cons (prod A B) (@pair A B h m) l2)) h' to) *) rewrite collate_app. (* Goal: @eq (list B) (@collate_ls A B A_eq_dec (@filter_rel A R R_dec h (@remove_all A A_eq_dec ns' ns)) f h mg n h) (f n h) *) revert f. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) induction l2; intros; simpl in *; auto. (* Goal: @eq (list B) ((let (to, m) := a in @collate A B A_eq_dec h (@update2 A (list B) A_eq_dec (@collate A B A_eq_dec h f l1) h to (@app B (@collate A B A_eq_dec h f l1 h to) (@cons B m (@nil B)))) l2) h h') (@collate A B A_eq_dec h f l1 h h') *) break_let. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec l' f h m) *) subst_max. simpl in *. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) assert (H_neq: a0 <> h'); auto. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) rewrite collate_neq_update2; auto. Qed. Lemma collate_not_in_mid : forall h h' l1 l2 (f : A -> A -> list B) m, ~ In h (map fst (l1 ++ l2)) -> collate A_eq_dec h' (update2 A_eq_dec f h' h (f h' h ++ [m])) (l1 ++ l2) = collate A_eq_dec h' f (l1 ++ (h, m) :: l2). Proof using. (* Goal: forall (h h' : A) (l1 l2 : list A) (f : forall (_ : A) (_ : A), list B) (m : B) (_ : not (@In A h' (@app A l1 l2))), @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@app A l1 l2) (@update2 A (list B) A_eq_dec f h' h (@app B (f h' h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec (@app A l1 (@cons A h' l2)) f h m) *) intros h h' l1 l2 f m H_in. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@app A l1 l2) (@update2 A (list B) A_eq_dec f h' h (@app B (f h' h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec (@app A l1 (@cons A h' l2)) f h m) *) apply functional_extensionality; intro from. (* Goal: @eq (forall _ : A, list B) (@collate_ls A B A_eq_dec (@app A l1 l2) (@update2 A (list B) A_eq_dec f h' h (@app B (f h' h) (@cons B m (@nil B)))) h m from) (@collate_ls A B A_eq_dec (@app A l1 (@cons A h' l2)) f h m from) *) apply functional_extensionality; intro to. (* Goal: @eq (list B) (@collate A B A_eq_dec h' (@update2 A (list B) A_eq_dec f h' h (@app B (f h' h) (@cons B m (@nil B)))) (@app (prod A B) l1 l2) from to) (@collate A B A_eq_dec h' f (@app (prod A B) l1 (@cons (prod A B) (@pair A B h m) l2)) from to) *) case (A_eq_dec h' from); intro H_dec. - rewrite <- H_dec. (* Goal: @eq (list B) (@collate A B A_eq_dec h' (@update2 A (list B) A_eq_dec f h' h (@app B (f h' h) (@cons B m (@nil B)))) (@app (prod A B) l1 l2) h' to) (@collate A B A_eq_dec h' f (@app (prod A B) l1 (@cons (prod A B) (@pair A B h m) l2)) h' to) *) case (A_eq_dec h to); intro H_dec'. * rewrite <- H_dec'. (* Goal: @eq (list B) (@collate A B A_eq_dec h' (@update2 A (list B) A_eq_dec f h' h (@app B (f h' h) (@cons B m (@nil B)))) (@app (prod A B) l1 l2) h' h) (@collate A B A_eq_dec h' f (@app (prod A B) l1 (@cons (prod A B) (@pair A B h m) l2)) h' h) *) rewrite collate_not_in. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@nil A) f h m) (@collate_ls A B A_eq_dec l' f h m) *) + subst. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) rewrite collate_not_in; auto. (* Goal: not (@In A a (@app A x x0)) *) intro. (* Goal: False *) contradict H_in. (* Goal: @In A h (@map (prod A B) A (@fst A B) (@app (prod A B) l1 l2)) *) rewrite map_app. (* Goal: @In A h' (@app A l1 l2) *) apply in_or_app. (* Goal: @In A a (@cons A a l) *) (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec l' f h m) *) left. (* Goal: @Permutation A l (@app A x x0) *) assumption. (* Goal: not (@In A a (@app A x x0)) *) + intro. (* Goal: False *) contradict H_in. (* Goal: @In A h (@map (prod A B) A (@fst A B) (@app (prod A B) l1 l2)) *) rewrite map_app. (* Goal: @In A h' (@app A l1 l2) *) apply in_or_app. (* Goal: @In A a (@cons A a l) *) (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec l' f h m) *) left. (* Goal: @Permutation A l (@app A x x0) *) assumption. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) * rewrite collate_neq_update2; auto. (* Goal: @eq (list B) (@collate A B A_eq_dec h' (@collate A B A_eq_dec h' f l1) l2 h' to) (@collate A B A_eq_dec h' f (@app (prod A B) l1 (@cons (prod A B) (@pair A B h m) l2)) h' to) *) rewrite collate_app. (* Goal: @eq (list B) (@collate A B A_eq_dec h' (@collate A B A_eq_dec h' f l1) l2 h' to) (@collate A B A_eq_dec h' f (@app (prod A B) l1 (@cons (prod A B) (@pair A B h m) l2)) h' to) *) rewrite collate_app. (* Goal: @eq (list B) (@collate_ls A B A_eq_dec (@cons A a (@filter_rel A R R_dec h (@remove_all A A_eq_dec ns' ns))) f h mg n h) (f n h) *) simpl. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) rewrite collate_neq_update2; auto. - rewrite collate_neq; auto. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) rewrite collate_neq; auto. (* Goal: @eq (list B) (@update2 A (list B) A_eq_dec f h' h (@app B (f h' h) (@cons B m (@nil B))) from to) (f from to) *) unfold update2. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) break_if; auto. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@nil A) f h m) (@collate_ls A B A_eq_dec l' f h m) *) break_and; subst. (* Goal: @eq (list B) (@app B (f from to) (@cons B m (@nil B))) (f from to) *) intuition. Qed. Lemma NoDup_Permutation_collate_eq : forall h (f : A -> A -> list B) l l', NoDup (map fst l) -> Permutation l l' -> collate A_eq_dec h f l = collate A_eq_dec h f l'. Proof using. (* Goal: forall (h : A) (f : forall (_ : A) (_ : A), list B) (l l' : list (prod A B)) (_ : @NoDup A (@map (prod A B) A (@fst A B) l)) (_ : @Permutation (prod A B) l l'), @eq (forall (_ : A) (_ : A), list B) (@collate A B A_eq_dec h f l) (@collate A B A_eq_dec h f l') *) intros h f l. (* Goal: forall (l' : list (prod A B)) (_ : @NoDup A (@map (prod A B) A (@fst A B) l)) (_ : @Permutation (prod A B) l l'), @eq (forall (_ : A) (_ : A), list B) (@collate A B A_eq_dec h f l) (@collate A B A_eq_dec h f l') *) revert h f. (* Goal: forall (f : forall (_ : A) (_ : A), list B) (l' : list A) (_ : @NoDup A l) (_ : @Permutation A l l'), @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l f h m) (@collate_ls A B A_eq_dec l' f h m) *) induction l. (* Goal: forall (f : forall (_ : A) (_ : A), list B) (l' : list A) (_ : @NoDup A (@cons A a l)) (_ : @Permutation A (@cons A a l) l'), @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@cons A a l) f h m) (@collate_ls A B A_eq_dec l' f h m) *) - intros. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@nil A) f h m) (@collate_ls A B A_eq_dec l' f h m) *) find_apply_lem_hyp Permutation_nil. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@nil A) f h m) (@collate_ls A B A_eq_dec l' f h m) *) subst. (* Goal: @eq A a a *) (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec l' f h m) *) trivial. (* Goal: forall (f : forall (_ : A) (_ : A), list B) (l' : list A) (_ : @NoDup A (@cons A a l)) (_ : @Permutation A (@cons A a l) l'), @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@cons A a l) f h m) (@collate_ls A B A_eq_dec l' f h m) *) - intros. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate A B A_eq_dec h f (@cons (prod A B) a l)) (@collate A B A_eq_dec h f l') *) destruct a. simpl in *. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@cons A a l) f h m) (@collate_ls A B A_eq_dec l' f h m) *) invc_NoDup. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate A B A_eq_dec h (@update2 A (list B) A_eq_dec f h a (@app B (f h a) (@cons B b (@nil B)))) l) (@collate A B A_eq_dec h f l') *) assert (H_in': In (a, b) ((a, b) :: l)). (* Goal: @In A a (@cons A a l) *) (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec l' f h m) *) left. (* Goal: @eq A a a *) (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec l' f h m) *) trivial. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate A B A_eq_dec h (@update2 A (list B) A_eq_dec f h a (@app B (f h a) (@cons B b (@nil B)))) l) (@collate A B A_eq_dec h f l') *) pose proof (Permutation_in _ H0 H_in') as H_pm'. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate A B A_eq_dec h (@update2 A (list B) A_eq_dec f h a (@app B (f h a) (@cons B b (@nil B)))) l) (@collate A B A_eq_dec h f l') *) apply in_split in H_pm'. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@nil A) f h m) (@collate_ls A B A_eq_dec l' f h m) *) break_exists; subst. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec (@app A x (@cons A a x0)) f h m) *) find_apply_lem_hyp Permutation_cons_app_inv. pose proof (IHl h (update2 A_eq_dec f h a (f h a ++ [b])) _ H4 H0) as IHl'. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate A B A_eq_dec h (@update2 A (list B) A_eq_dec f h a (@app B (f h a) (@cons B b (@nil B)))) l) (@collate A B A_eq_dec h f (@app (prod A B) x (@cons (prod A B) (@pair A B a b) x0))) *) rewrite IHl'. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) rewrite collate_not_in_mid; auto. (* Goal: not (@In A a (@app A x x0)) *) intro. assert (H_pm': Permutation (map (fun nm : A * B => fst nm) l) (map (fun nm : A * B => fst nm) (x ++ x0))). (* Goal: @Permutation A (@map (prod A B) A (fun nm : prod A B => @fst A B nm) l) (@map (prod A B) A (fun nm : prod A B => @fst A B nm) (@app (prod A B) x x0)) *) (* Goal: False *) apply Permutation_map_fst. (* Goal: @eq A a a *) (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec l' f h m) *) trivial. (* Goal: False *) contradict H3. (* Goal: @In A a l *) revert H. (* Goal: forall _ : @In A a (@app A x x0), @In A a l *) apply Permutation_in. (* Goal: @Permutation A (@app A x x0) l *) apply Permutation_sym. (* Goal: @eq A a a *) (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec l' f h m) *) trivial. Qed. Lemma collate_map2snd_not_related : forall m n h ns (f : A -> A -> list B), ~ R h n -> collate A_eq_dec h f (map2snd m (filter_rel R_dec h ns)) h n = f h n. Proof using. (* Goal: forall (m : B) (n h : A) (ns : list A) (f : forall (_ : A) (_ : A), list B) (_ : not (R h n)), @eq (list B) (@collate A B A_eq_dec h f (@map2snd A B m (@filter_rel A R R_dec h ns)) h n) (f h n) *) intros m n h ns f H_adj. (* Goal: @eq (list B) (@collate_ls A B A_eq_dec (@filter_rel A R R_dec h (@remove_all A A_eq_dec ns' ns)) f h mg n h) (f n h) *) revert f. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) induction ns; intros; auto. (* Goal: @eq (list B) (@collate_ls A B A_eq_dec (@cons A a (@filter_rel A R R_dec h (@remove_all A A_eq_dec ns' ns))) f h mg n h) (f n h) *) simpl. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) break_if; simpl; auto. (* Goal: @eq (list B) (@collate_ls A B A_eq_dec (@filter_rel A R R_dec h (@remove_all A A_eq_dec ns' ns)) (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B mg (@nil B)))) h mg n h) (f n h) *) rewrite IHns. (* Goal: @eq (list B) (@update2 A (list B) A_eq_dec f h' h (@app B (f h' h) (@cons B m (@nil B))) from to) (f from to) *) unfold update2. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) break_if; auto. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@nil A) f h m) (@collate_ls A B A_eq_dec l' f h m) *) break_and; subst. (* Goal: @eq (list B) (@app B (f from to) (@cons B m (@nil B))) (f from to) *) intuition. Qed. Lemma collate_map2snd_in_neq_in_before : forall from (f : A -> A -> list B) m dsts a b x, In x (collate A_eq_dec from f (map2snd m dsts) a b) -> x <> m -> In x (f a b). Proof using. (* Goal: forall (f : forall (_ : A) (_ : A), list B) (l' : list A) (_ : @NoDup A (@cons A a l)) (_ : @Permutation A (@cons A a l) l'), @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@cons A a l) f h m) (@collate_ls A B A_eq_dec l' f h m) *) intros. (* Goal: or (@eq (list B) (@collate_ls A B A_eq_dec s f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec s f to m a b) (@app B (f a b) l)))) *) generalize dependent f. (* Goal: forall (f : forall (_ : A) (_ : A), list B) (_ : @In B x (@collate A B A_eq_dec from f (@map2snd A B m dsts) a b)), @In B x (f a b) *) induction dsts. - auto. - simpl; intros f H_coll. (* Goal: @In B x (f a b) *) eapply IHdsts in H_coll. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@nil A) f h m) (@collate_ls A B A_eq_dec l' f h m) *) destruct (A_eq_dec from a), (A_eq_dec a0 b); subst. + rewrite update2_same in *. (* Goal: @eq (list B) (@collate_ls A B A_eq_dec ns (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B mg (@nil B)))) h mg from h) (@app B (f from h) (@cons B mg (@nil B))) *) find_eapply_lem_hyp in_app_or; break_or_hyp. * assumption. * exfalso; (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) find_eapply_lem_hyp in_inv; break_or_hyp; exfalso; auto. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) + rewrite update2_diff2 in *; auto. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) + rewrite update2_diff1 in *; auto. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) + rewrite update2_diff1 in *; auto. Qed. Lemma collate_map2snd_not_in : forall m n h ns (f : A -> A -> list B), ~ In n ns -> collate A_eq_dec h f (map2snd m (filter_rel R_dec h ns)) h n = f h n. Proof using. (* Goal: forall (m : B) (n h : A) (ns : list A) (f : forall (_ : A) (_ : A), list B) (_ : not (@In A n ns)), @eq (list B) (@collate A B A_eq_dec h f (@map2snd A B m (@filter_rel A R R_dec h ns)) h n) (f h n) *) intros m n h ns f. (* Goal: @eq (list B) (@collate_ls A B A_eq_dec (@filter_rel A R R_dec h (@remove_all A A_eq_dec ns' ns)) f h mg n h) (f n h) *) revert f. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) induction ns; intros; auto. simpl in *. (* Goal: @eq (list B) (@collate_ls A B A_eq_dec (@cons A a (@filter_rel A R R_dec h (@remove_all A A_eq_dec ns' ns))) f h mg n h) (f n h) *) break_if; simpl. - rewrite IHns. (* Goal: @eq (list B) (@update2 A (list B) A_eq_dec f h' h (@app B (f h' h) (@cons B m (@nil B))) from to) (f from to) *) * unfold update2. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) break_if; auto. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@nil A) f h m) (@collate_ls A B A_eq_dec l' f h m) *) break_and; subst. (* Goal: False *) contradict H. (* Goal: @In A a (@cons A a l) *) (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec l' f h m) *) left. (* Goal: @eq A a a *) (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec l' f h m) *) trivial. * intro. (* Goal: False *) contradict H. (* Goal: or (@In A h' l1) (@In A h' l2) *) right. (* Goal: @Permutation A l (@app A x x0) *) assumption. - rewrite IHns; auto. Qed. Lemma collate_map2snd_not_in_remove_all : forall m n h ns (f : A -> A -> list B) ns', ~ In n ns -> collate A_eq_dec h f (map2snd m (filter_rel R_dec h (remove_all A_eq_dec ns' ns))) h n = f h n. Proof using. (* Goal: forall (m : B) (n h : A) (ns : list A) (f : forall (_ : A) (_ : A), list B) (ns' : list A) (_ : not (@In A n ns)), @eq (list B) (@collate A B A_eq_dec h f (@map2snd A B m (@filter_rel A R R_dec h (@remove_all A A_eq_dec ns' ns))) h n) (f h n) *) intros m n h ns f ns' H_in. (* Goal: @eq (list B) (@collate A B A_eq_dec h f (@map2snd A B m (@filter_rel A R R_dec h (@remove_all A A_eq_dec ns' ns))) h n) (f h n) *) apply collate_map2snd_not_in. (* Goal: not (@In A a (@app A x x0)) *) intro. (* Goal: False *) find_apply_lem_hyp in_remove_all_was_in. (* Goal: @eq (list B) (@app B (f from to) (@cons B m (@nil B))) (f from to) *) intuition. Qed. Lemma collate_map2snd_not_in_related : forall m n h ns (f : A -> A -> list B) ns', ~ In n ns' -> R h n -> In n ns -> NoDup ns -> collate A_eq_dec h f (map2snd m (filter_rel R_dec h (remove_all A_eq_dec ns' ns))) h n = f h n ++ [m]. Proof using. (* Goal: forall (m : B) (n h : A) (ns : list A) (f : forall (_ : A) (_ : A), list B) (ns' : list A) (_ : not (@In A n ns')) (_ : R h n) (_ : @In A n ns) (_ : @NoDup A ns), @eq (list B) (@collate A B A_eq_dec h f (@map2snd A B m (@filter_rel A R R_dec h (@remove_all A A_eq_dec ns' ns))) h n) (@app B (f h n) (@cons B m (@nil B))) *) intros m n h ns f ns' H_in H_adj. (* Goal: @eq (list B) (@collate_ls A B A_eq_dec (@filter_rel A R R_dec h (@remove_all A A_eq_dec ns' ns)) f h mg n h) (f n h) *) revert f. (* Goal: forall (f : forall (_ : A) (_ : A), list B) (_ : @In A n ns) (_ : @NoDup A ns), @eq (list B) (@collate A B A_eq_dec h f (@map2snd A B m (@filter_rel A R R_dec h (@remove_all A A_eq_dec ns' ns))) h n) (@app B (f h n) (@cons B m (@nil B))) *) induction ns; intros; [ contradict H | idtac ]. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@cons A a l) f h m) (@collate_ls A B A_eq_dec l' f h m) *) invc_NoDup. simpl in *. (* Goal: @eq (list B) (@collate_ls A B A_eq_dec ns (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B mg (@nil B)))) h mg from h) (@app B (f from h) (@cons B mg (@nil B))) *) break_or_hyp. - pose proof (remove_all_cons A_eq_dec ns' n ns) as H_ra. (* Goal: @eq (list B) (@app B (f from to) (@cons B m (@nil B))) (f from to) *) break_or_hyp; break_and; intuition. (* Goal: @In B x (f a b) *) find_rewrite. (* Goal: @eq (list B) (@collate_ls A B A_eq_dec (@cons A a (@filter_rel A R R_dec h (@remove_all A A_eq_dec ns' ns))) f h mg n h) (f n h) *) simpl. (* Goal: @eq (list B) (@app B (f from to) (@cons B m (@nil B))) (f from to) *) break_if; intuition. (* Goal: @eq (list B) (@collate_ls A B A_eq_dec (@cons A a (@filter_rel A R R_dec h (@remove_all A A_eq_dec ns' ns))) f h mg n h) (f n h) *) simpl. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) rewrite collate_map2snd_not_in_remove_all; auto. (* Goal: @eq (list B) (@update2 A (list B) A_eq_dec f h' h (@app B (f h' h) (@cons B m (@nil B))) from to) (f from to) *) unfold update2. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) break_if; auto. (* Goal: @eq (list B) (@app B (f from to) (@cons B m (@nil B))) (f from to) *) intuition. - assert (H_neq: a <> n). (* Goal: not (@In A a (@app A x x0)) *) intro. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@nil A) f h m) (@collate_ls A B A_eq_dec l' f h m) *) subst. (* Goal: @eq (list B) (@app B (f from to) (@cons B m (@nil B))) (f from to) *) intuition. (* Goal: @eq (list B) (@collate A B A_eq_dec h f (@map2snd A B m (@filter_rel A R R_dec h (@remove_all A A_eq_dec ns' (@cons A a ns)))) h n) (f h n) *) pose proof (remove_all_cons A_eq_dec ns' a ns) as H_ra. (* Goal: @eq (list B) (@app B (f h to) (@cons B m (@nil B))) (f from to) *) break_or_hyp; break_and. * find_rewrite. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) rewrite IHns; auto. * find_rewrite. (* Goal: @eq (list B) (@collate_ls A B A_eq_dec (@cons A a (@filter_rel A R R_dec h (@remove_all A A_eq_dec ns' ns))) f h mg n h) (f n h) *) simpl. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) break_if; auto. (* Goal: @eq (list B) (@collate_ls A B A_eq_dec (@cons A a (@filter_rel A R R_dec h (@remove_all A A_eq_dec ns' ns))) f h mg n h) (f n h) *) simpl. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) rewrite IHns; auto. (* Goal: @eq (list B) (@update2 A (list B) A_eq_dec f h' h (@app B (f h' h) (@cons B m (@nil B))) from to) (f from to) *) unfold update2. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) break_if; auto. (* Goal: @eq (list B) (@app B (f h to) (@cons B m (@nil B))) (f from to) *) break_and. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@nil A) f h m) (@collate_ls A B A_eq_dec l' f h m) *) subst. (* Goal: @eq (list B) (@app B (f from to) (@cons B m (@nil B))) (f from to) *) intuition. Qed. Lemma collate_map2snd_in : forall m n h ns (f : A -> A -> list B) ns', In n ns' -> collate A_eq_dec h f (map2snd m (filter_rel R_dec h (remove_all A_eq_dec ns' ns))) h n = f h n. Proof using. (* Goal: forall (m : B) (n h : A) (ns : list A) (f : forall (_ : A) (_ : A), list B) (ns' : list A) (_ : @In A n ns'), @eq (list B) (@collate A B A_eq_dec h f (@map2snd A B m (@filter_rel A R R_dec h (@remove_all A A_eq_dec ns' ns))) h n) (f h n) *) intros m n h ns f ns'. (* Goal: @eq (list B) (@collate_ls A B A_eq_dec (@filter_rel A R R_dec h (@remove_all A A_eq_dec ns' ns)) f h mg n h) (f n h) *) revert f. (* Goal: forall (f : forall (_ : A) (_ : A), list B) (l' : list A) (_ : @NoDup A (@cons A a l)) (_ : @Permutation A (@cons A a l) l'), @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@cons A a l) f h m) (@collate_ls A B A_eq_dec l' f h m) *) induction ns; intros. - rewrite remove_all_nil. (* Goal: @eq A a a *) (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec l' f h m) *) trivial. - pose proof (remove_all_cons A_eq_dec ns' a ns) as H_ra. (* Goal: @In B x (f a b) *) break_or_hyp; break_and; find_rewrite. * rewrite IHns; trivial. * simpl. (* Goal: @eq (list B) (@update2 A (list B) A_eq_dec f h' h (@app B (f h' h) (@cons B m (@nil B))) h' h) (if sumbool_and (@eq A h' h') (not (@eq A h' h')) (@eq A h h) (not (@eq A h h)) (A_eq_dec h' h') (A_eq_dec h h) then @app B (f' h' h) (@cons B m (@nil B)) else f' h' h) *) break_if. (* Goal: @eq (list B) (@collate_ls A B A_eq_dec (@cons A a (@filter_rel A R R_dec h (@remove_all A A_eq_dec ns' ns))) f h mg n h) (f n h) *) + simpl. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) rewrite IHns; simpl; auto. (* Goal: @eq (list B) (@update2 A (list B) A_eq_dec f h' h (@app B (f h' h) (@cons B m (@nil B))) from to) (f from to) *) unfold update2. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) break_if; auto. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@nil A) f h m) (@collate_ls A B A_eq_dec l' f h m) *) break_and; subst. (* Goal: @eq (list B) (@app B (f from to) (@cons B m (@nil B))) (f from to) *) intuition. (* Goal: @eq A a a *) (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec l' f h m) *) + rewrite IHns; trivial. Qed. Lemma collate_map2snd_related_not_in : forall a n h ns (f : A -> A -> list B), R h n -> ~ In n ns -> collate A_eq_dec h f (map2snd a (filter_rel R_dec h (n :: ns))) h n = f h n ++ [a]. Proof using. (* Goal: forall (a : B) (n h : A) (ns : list A) (f : forall (_ : A) (_ : A), list B) (_ : R h n) (_ : not (@In A n ns)), @eq (list B) (@collate A B A_eq_dec h f (@map2snd A B a (@filter_rel A R R_dec h (@cons A n ns))) h n) (@app B (f h n) (@cons B a (@nil B))) *) intros a n h ns f H_adj H_in. (* Goal: @eq (list B) (@collate_ls A B A_eq_dec (@cons A a (@filter_rel A R R_dec h (@remove_all A A_eq_dec ns' ns))) f h mg n h) (f n h) *) simpl. (* Goal: @eq (list B) (@app B (f from to) (@cons B m (@nil B))) (f from to) *) break_if; intuition. (* Goal: @eq (list B) (@collate A B A_eq_dec h f (@map2snd A B a (@cons A n (@filter_rel A R R_dec h ns))) h n) (@app B (f h n) (@cons B a (@nil B))) *) clear r. (* Goal: @eq (list B) (@collate A B A_eq_dec h f (@map2snd A B a (@cons A n (@filter_rel A R R_dec h ns))) h n) (@app B (f h n) (@cons B a (@nil B))) *) revert f n h H_in H_adj. (* Goal: @eq (list B) (@collate_ls A B A_eq_dec (@cons A a (@filter_rel A R R_dec h (@remove_all A A_eq_dec ns' ns))) f h mg n h) (f n h) *) induction ns; intros; simpl. (* Goal: @eq (list B) (@update2 A (list B) A_eq_dec f h' h (@app B (f h' h) (@cons B m (@nil B))) from to) (f from to) *) - unfold update2. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) break_if; auto. (* Goal: @eq (list B) (@app B (f from to) (@cons B m (@nil B))) (f from to) *) intuition. - assert (H_in': ~ In n ns). (* Goal: not (@In A a (@app A x x0)) *) intro. (* Goal: False *) contradict H_in. (* Goal: or (@In A h' l1) (@In A h' l2) *) right. (* Goal: @eq A a a *) (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec l' f h m) *) trivial. (* Goal: @eq (list B) (@collate A B A_eq_dec h (@update2 A (list B) A_eq_dec f h n (@app B (f h n) (@cons B a (@nil B)))) (@map2snd A B a (if R_dec h a0 then @cons A a0 (@filter_rel A R R_dec h ns) else @filter_rel A R R_dec h ns)) h n) (@app B (f h n) (@cons B a (@nil B))) *) assert (H_neq: n <> a0). (* Goal: not (@In A a (@app A x x0)) *) intro. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@nil A) f h m) (@collate_ls A B A_eq_dec l' f h m) *) subst. (* Goal: False *) contradict H_in. (* Goal: @In A a (@cons A a l) *) (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec l' f h m) *) left. (* Goal: @eq A a a *) (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec l' f h m) *) trivial. simpl in *. (* Goal: @eq (list B) (@update2 A (list B) A_eq_dec f h' h (@app B (f h' h) (@cons B m (@nil B))) h' h) (if sumbool_and (@eq A h' h') (not (@eq A h' h')) (@eq A h h) (not (@eq A h h)) (A_eq_dec h' h') (A_eq_dec h h) then @app B (f' h' h) (@cons B m (@nil B)) else f' h' h) *) break_if. * simpl. (* Goal: @eq (list B) (@collate A B A_eq_dec h (@update2 A (list B) A_eq_dec (@update2 A (list B) A_eq_dec f h n (@app B (f h n) (@cons B a (@nil B)))) h a0 (@app B (@update2 A (list B) A_eq_dec f h n (@app B (f h n) (@cons B a (@nil B))) h a0) (@cons B a (@nil B)))) (@map2snd A B a (@filter_rel A R R_dec h ns)) h n) (@app B (f h n) (@cons B a (@nil B))) *) unfold update2 at 3. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) break_if; intuition eauto. (* Goal: @eq (list B) (@collate A B A_eq_dec h (@update2 A (list B) A_eq_dec (@update2 A (list B) A_eq_dec f h n (@app B (f h n) (@cons B a (@nil B)))) h a0 (@app B (f h a0) (@cons B a (@nil B)))) (@map2snd A B a (@filter_rel A R R_dec h ns)) h n) (@app B (f h n) (@cons B a (@nil B))) *) pose proof (IHns f) as IH'. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) rewrite collate_map2snd_not_in; auto. (* Goal: @eq (list B) (@update2 A (list B) A_eq_dec f h' h (@app B (f h' h) (@cons B m (@nil B))) from to) (f from to) *) unfold update2. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) break_if; intuition eauto. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) break_if; auto. (* Goal: @eq (list B) (@app B (f from to) (@cons B m (@nil B))) (f from to) *) intuition. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) * rewrite IHns; auto. Qed. Lemma in_collate_in : forall ns n h (f : A -> A -> list B) a, ~ In n ns -> In a (collate A_eq_dec h f (map2snd a (filter_rel R_dec h ns)) h n) -> In a (f h n). Proof using. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) induction ns; intros; auto. (* Goal: @In B a0 (f h n) *) assert (H_in': ~ In n ns). (* Goal: not (@In A a (@app A x x0)) *) intro. (* Goal: False *) contradict H. (* Goal: or (@In A h' l1) (@In A h' l2) *) right. (* Goal: @eq A a a *) (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec l' f h m) *) trivial. (* Goal: @In B a0 (f h n) *) assert (H_neq: n <> a). (* Goal: not (@In A a (@app A x x0)) *) intro. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@nil A) f h m) (@collate_ls A B A_eq_dec l' f h m) *) subst. (* Goal: False *) contradict H. (* Goal: @In A a (@cons A a l) *) (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec l' f h m) *) left. (* Goal: @eq A a a *) (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec l' f h m) *) trivial. simpl in *. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) break_if; auto. simpl in *. assert (H_eq_f: update2 A_eq_dec f h a (f h a ++ [a0]) h n = f h n). (* Goal: @eq (list B) (@update2 A (list B) A_eq_dec f h' h (@app B (f h' h) (@cons B m (@nil B))) from to) (f from to) *) unfold update2. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) break_if; auto. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@nil A) f h m) (@collate_ls A B A_eq_dec l' f h m) *) break_and; subst. (* Goal: @eq (list B) (@app B (f from to) (@cons B m (@nil B))) (f from to) *) intuition. (* Goal: @In B a0 (f h n) *) rewrite (collate_f_eq _ _ _ _ _ _ H_eq_f) in H0. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) apply IHns; auto. Qed. Lemma not_in_map2snd : forall n h (m : B) ns, ~ In n ns -> ~ In (n, m) (map2snd m (filter_rel R_dec h ns)). Proof using. (* Goal: forall (f : forall (_ : A) (_ : A), list B) (l' : list A) (_ : @NoDup A (@cons A a l)) (_ : @Permutation A (@cons A a l) l'), @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@cons A a l) f h m) (@collate_ls A B A_eq_dec l' f h m) *) intros. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) induction ns; intros; auto. simpl in *. (* Goal: @eq (list B) (@update2 A (list B) A_eq_dec f h' h (@app B (f h' h) (@cons B m (@nil B))) h' h) (if sumbool_and (@eq A h' h') (not (@eq A h' h')) (@eq A h h) (not (@eq A h h)) (A_eq_dec h' h') (A_eq_dec h h) then @app B (f' h' h) (@cons B m (@nil B)) else f' h' h) *) break_if. - simpl. (* Goal: not (@In A a (@app A x x0)) *) intro. (* Goal: @eq (list B) (@collate_ls A B A_eq_dec ns (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B mg (@nil B)))) h mg from h) (@app B (f from h) (@cons B mg (@nil B))) *) break_or_hyp. * find_injection. (* Goal: False *) contradict H. (* Goal: @In A a (@cons A a l) *) (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec l' f h m) *) left. (* Goal: @eq A a a *) (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec l' f h m) *) trivial. * contradict H1. (* Goal: @eq B (@snd A B nm) m *) apply IHns. (* Goal: not (@In A a (@app A x x0)) *) intro. (* Goal: False *) contradict H. (* Goal: or (@In A h' l1) (@In A h' l2) *) right. (* Goal: @Permutation A l (@app A x x0) *) assumption. - apply IHns. (* Goal: not (@In A a (@app A x x0)) *) intro. (* Goal: False *) contradict H. (* Goal: or (@In A h' l1) (@In A h' l2) *) right. (* Goal: @Permutation A l (@app A x x0) *) assumption. Qed. Lemma NoDup_map2snd : forall h (m : B) ns, NoDup ns -> NoDup (map2snd m (filter_rel R_dec h ns)). Proof using. (* Goal: forall (f : forall (_ : A) (_ : A), list B) (l' : list A) (_ : @NoDup A (@cons A a l)) (_ : @Permutation A (@cons A a l) l'), @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@cons A a l) f h m) (@collate_ls A B A_eq_dec l' f h m) *) intros. (* Goal: forall (f : forall (_ : A) (_ : A), list B) (_ : @In B x (f a b)), @In B x (@collate_ls A B A_eq_dec ns f to m a b) *) induction ns. - apply NoDup_nil. - invc_NoDup. (* Goal: @NoDup (prod A B) (@map2snd A B m (@filter_rel A R R_dec h (@cons A a ns))) *) concludes. (* Goal: @eq (list B) (@collate_ls A B A_eq_dec (@cons A a (@filter_rel A R R_dec h (@remove_all A A_eq_dec ns' ns))) f h mg n h) (f n h) *) simpl. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) break_if; auto. (* Goal: @eq (list B) (@collate_ls A B A_eq_dec (@cons A a (@filter_rel A R R_dec h (@remove_all A A_eq_dec ns' ns))) f h mg n h) (f n h) *) simpl. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) apply NoDup_cons; auto. (* Goal: not (@In (prod A B) (@pair A B a m) (@map2snd A B m (@filter_rel A R R_dec h ns))) *) apply not_in_map2snd. (* Goal: @Permutation A l (@app A x x0) *) assumption. Qed. Lemma in_map2snd_snd : forall h (m : B) ns nm, In nm (map2snd m (filter_rel R_dec h ns)) -> snd nm = m. Proof using. (* Goal: forall (f : forall (_ : A) (_ : A), list B) (l' : list A) (_ : @NoDup A (@cons A a l)) (_ : @Permutation A (@cons A a l) l'), @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@cons A a l) f h m) (@collate_ls A B A_eq_dec l' f h m) *) intros. induction ns; intros; simpl in *; intuition. (* Goal: @eq (list B) (@update2 A (list B) A_eq_dec f h' h (@app B (f h' h) (@cons B m (@nil B))) h' h) (if sumbool_and (@eq A h' h') (not (@eq A h' h')) (@eq A h h) (not (@eq A h h)) (A_eq_dec h' h') (A_eq_dec h h) then @app B (f' h' h) (@cons B m (@nil B)) else f' h' h) *) break_if. - simpl in *. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) break_or_hyp; intuition eauto. - apply IHns. (* Goal: @Permutation A l (@app A x x0) *) assumption. Qed. Lemma in_map2snd_related_in : forall (m : B) ns n h, In (n, m) (map2snd m (filter_rel R_dec h ns)) -> R h n /\ In n ns. Proof using. (* Goal: forall (m : B) (ns : list A) (n h : A) (_ : @In (prod A B) (@pair A B n m) (@map2snd A B m (@filter_rel A R R_dec h ns))), and (R h n) (@In A n ns) *) intros m. induction ns; intros; simpl in *; [ intuition | idtac ]. (* Goal: and (R h n) (or (@eq A a n) (@In A n ns)) *) break_if; simpl in *. - break_or_hyp. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) * find_injection; auto. * find_apply_hyp_hyp. (* Goal: @eq (list B) (@app B (f h to) (@cons B m (@nil B))) (f from to) *) break_and. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) auto. - find_apply_hyp_hyp. (* Goal: @eq (list B) (@app B (f h to) (@cons B m (@nil B))) (f from to) *) break_and. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) auto. Qed. Lemma collate_ls_not_in : forall ns (f : A -> A -> list B) h mg from to, ~ In from ns -> collate_ls A_eq_dec ns f h mg from to = f from to. Proof using. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) induction ns; intros; auto. (* Goal: @eq (list B) (@collate_ls A B A_eq_dec ns (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B mg (@nil B)))) h mg from h) (@app B (f from h) (@cons B mg (@nil B))) *) assert (H_neq: a <> from). (* Goal: not (@In A a (@app A x x0)) *) intro. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@nil A) f h m) (@collate_ls A B A_eq_dec l' f h m) *) subst. (* Goal: False *) contradict H. (* Goal: @In A a (@cons A a l) *) (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec l' f h m) *) left. (* Goal: @eq A a a *) (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec l' f h m) *) trivial. (* Goal: @eq (list B) (@collate_ls A B A_eq_dec (@cons A a ns) f h mg from to) (f from to) *) assert (H_in': ~ In from ns). (* Goal: not (@In A a (@app A x x0)) *) intro. (* Goal: False *) contradict H. (* Goal: or (@In A h' l1) (@In A h' l2) *) right. (* Goal: @Permutation A l (@app A x x0) *) assumption. (* Goal: @eq (list B) (@collate_ls A B A_eq_dec (@cons A a (@filter_rel A R R_dec h (@remove_all A A_eq_dec ns' ns))) f h mg n h) (f n h) *) simpl. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) rewrite IHns; auto. (* Goal: @eq (list B) (@update2 A (list B) A_eq_dec f h' h (@app B (f h' h) (@cons B m (@nil B))) from to) (f from to) *) unfold update2. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) break_if; auto. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@nil A) f h m) (@collate_ls A B A_eq_dec l' f h m) *) break_and; subst. (* Goal: @eq (list B) (@app B (f from to) (@cons B m (@nil B))) (f from to) *) intuition. Qed. Lemma collate_ls_in_in : forall ns (f : A -> A -> list B) to m x a b, In x (f a b) -> In x (collate_ls A_eq_dec ns f to m a b). Proof using. (* Goal: forall (f : forall (_ : A) (_ : A), list B) (l' : list A) (_ : @NoDup A (@cons A a l)) (_ : @Permutation A (@cons A a l) l'), @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@cons A a l) f h m) (@collate_ls A B A_eq_dec l' f h m) *) intros. (* Goal: or (@eq (list B) (@collate_ls A B A_eq_dec s f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec s f to m a b) (@app B (f a b) l)))) *) generalize dependent f. (* Goal: forall (f : forall (_ : A) (_ : A), list B) (_ : @In B x (f a b)), @In B x (@collate_ls A B A_eq_dec ns f to m a b) *) induction ns. - auto. (* Goal: forall (f : forall (_ : A) (_ : A), list B) (l' : list A) (_ : @NoDup A (@cons A a l)) (_ : @Permutation A (@cons A a l) l'), @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@cons A a l) f h m) (@collate_ls A B A_eq_dec l' f h m) *) - intros. (* Goal: @eq (list B) (@collate_ls A B A_eq_dec (@cons A a (@filter_rel A R R_dec h (@remove_all A A_eq_dec ns' ns))) f h mg n h) (f n h) *) simpl. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) eapply IHns; eauto. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@nil A) f h m) (@collate_ls A B A_eq_dec l' f h m) *) destruct (A_eq_dec a a0), (A_eq_dec to b); subst. + rewrite update2_eq; auto using in_or_app. + rewrite update2_diff2; auto using in_or_app. + rewrite update2_diff1; auto using in_or_app. + rewrite update2_diff1; auto using in_or_app. Qed. Lemma collate_ls_neq_to : forall ns (f : A -> A -> list B) h mg from to, h <> to -> collate_ls A_eq_dec ns f h mg from to = f from to. Proof using. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) induction ns; intros; auto. simpl in *. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) rewrite IHns; auto. (* Goal: @eq (list B) (@update2 A (list B) A_eq_dec f h' h (@app B (f h' h) (@cons B m (@nil B))) from to) (f from to) *) unfold update2. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) break_if; auto. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@nil A) f h m) (@collate_ls A B A_eq_dec l' f h m) *) break_and; subst. (* Goal: @eq (list B) (@app B (f from to) (@cons B m (@nil B))) (f from to) *) intuition. Qed. Lemma collate_ls_NoDup_in : forall ns (f : A -> A -> list B) h mg from, NoDup ns -> In from ns -> collate_ls A_eq_dec ns f h mg from h = f from h ++ [mg]. Proof using. induction ns; intros; simpl in *; [ intuition | idtac ]. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@cons A a l) f h m) (@collate_ls A B A_eq_dec l' f h m) *) invc_NoDup. (* Goal: @eq (list B) (@collate_ls A B A_eq_dec ns (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B mg (@nil B)))) h mg from h) (@app B (f from h) (@cons B mg (@nil B))) *) break_or_hyp. - rewrite collate_ls_not_in; auto. (* Goal: @eq (list B) (@update2 A (list B) A_eq_dec f h' h (@app B (f h' h) (@cons B m (@nil B))) from to) (f from to) *) unfold update2. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) break_if; auto. (* Goal: @eq (list B) (@app B (f from to) (@cons B m (@nil B))) (f from to) *) break_or_hyp; intuition. - assert (H_neq: a <> from). (* Goal: not (@In A a (@app A x x0)) *) intro. (* Goal: @In B x (f a b) *) find_rewrite. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) auto. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) rewrite IHns; auto. (* Goal: @eq (list B) (@update2 A (list B) A_eq_dec f h' h (@app B (f h' h) (@cons B m (@nil B))) from to) (f from to) *) unfold update2. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) break_if; auto. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@nil A) f h m) (@collate_ls A B A_eq_dec l' f h m) *) break_and; subst. (* Goal: @eq (list B) (@app B (f from to) (@cons B m (@nil B))) (f from to) *) intuition. Qed. Lemma collate_ls_live_related : forall ns (f : A -> A -> list B) ns' h mg from, ~ In from ns' -> R h from -> In from ns -> NoDup ns -> collate_ls A_eq_dec (filter_rel R_dec h (remove_all A_eq_dec ns' ns)) f h mg from h = f from h ++ [mg]. Proof using. (* Goal: forall (f : forall (_ : A) (_ : A), list B) (l' : list A) (_ : @NoDup A (@cons A a l)) (_ : @Permutation A (@cons A a l) l'), @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@cons A a l) f h m) (@collate_ls A B A_eq_dec l' f h m) *) intros. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) rewrite collate_ls_NoDup_in; auto. - apply NoDup_filter_rel. (* Goal: @NoDup A (@remove_all A A_eq_dec ns' ns) *) apply NoDup_remove_all. (* Goal: @Permutation A l (@app A x x0) *) assumption. - apply related_filter_rel. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) apply in_remove_all_preserve; auto. (* Goal: @Permutation A l (@app A x x0) *) assumption. Qed. Lemma collate_ls_f_eq : forall ns (f : A -> A -> list B) g h mg n n', f n n' = g n n' -> collate_ls A_eq_dec ns f h mg n n' = collate_ls A_eq_dec ns g h mg n n'. Proof using. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) induction ns; intros; simpl in *; auto. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec (@app A x (@cons A a x0)) f h m) *) set (f' := update2 _ _ _ _ _). (* Goal: @eq (list B) (@collate_ls A B A_eq_dec ns f' h mg n n') (@collate_ls A B A_eq_dec ns (@update2 A (list B) A_eq_dec g a h (@app B (g a h) (@cons B mg (@nil B)))) h mg n n') *) set (g' := update2 _ _ _ _ _). (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) rewrite (IHns f' g'); auto. (* Goal: @eq (list B) (f' n n') (g' n n') *) unfold f', g', update2. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) break_if; auto. (* Goal: @eq (list B) (@app B (f h to) (@cons B m (@nil B))) (f from to) *) break_and. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@nil A) f h m) (@collate_ls A B A_eq_dec l' f h m) *) subst. (* Goal: @In B x (f a b) *) find_rewrite. (* Goal: @eq A a a *) (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec l' f h m) *) trivial. Qed. Lemma collate_ls_neq_update2 : forall ns (f : A -> A -> list B) n h h' ms mg, n <> h' -> collate_ls A_eq_dec ns (update2 A_eq_dec f n h ms) h mg h' h = collate_ls A_eq_dec ns f h mg h' h. Proof using. (* Goal: forall (f : forall (_ : A) (_ : A), list B) (l' : list A) (_ : @NoDup A (@cons A a l)) (_ : @Permutation A (@cons A a l) l'), @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@cons A a l) f h m) (@collate_ls A B A_eq_dec l' f h m) *) intros. (* Goal: @eq (list B) (@collate_ls A B A_eq_dec ns (@update2 A (list B) A_eq_dec f n h ms) h mg h' h) (@collate_ls A B A_eq_dec ns f h mg h' h) *) assert (H_eq: update2 A_eq_dec f n h ms h' h = f h' h). (* Goal: @eq (list B) (@update2 A (list B) A_eq_dec f h' h (@app B (f h' h) (@cons B m (@nil B))) from to) (f from to) *) unfold update2. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) break_if; auto. (* Goal: @eq (list B) (@app B (f h to) (@cons B m (@nil B))) (f from to) *) break_and. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@nil A) f h m) (@collate_ls A B A_eq_dec l' f h m) *) subst. (* Goal: @eq (list B) (@app B (f from to) (@cons B m (@nil B))) (f from to) *) intuition. (* Goal: @eq (list B) (@collate_ls A B A_eq_dec ns (@update2 A (list B) A_eq_dec f n h ms) h mg h' h) (@collate_ls A B A_eq_dec ns f h mg h' h) *) rewrite (collate_ls_f_eq _ _ _ _ _ _ _ H_eq). (* Goal: @eq A a a *) (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec l' f h m) *) trivial. Qed. Lemma collate_ls_cases : forall s (f : A -> A -> list B) to m a b, collate_ls A_eq_dec s f to m a b = f a b \/ exists l, (forall x, In x l -> x = m) /\ collate_ls A_eq_dec s f to m a b = f a b ++ l. Proof using. (* Goal: forall (f : forall (_ : A) (_ : A), list B) (l' : list A) (_ : @NoDup A (@cons A a l)) (_ : @Permutation A (@cons A a l) l'), @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@cons A a l) f h m) (@collate_ls A B A_eq_dec l' f h m) *) intros. (* Goal: or (@eq (list B) (@collate_ls A B A_eq_dec s f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec s f to m a b) (@app B (f a b) l)))) *) generalize dependent f. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec s f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec s f to m a b) (@app B (f a b) l)))) *) induction s as [|n s]. - auto. (* Goal: forall (f : forall (_ : A) (_ : A), list B) (l' : list A) (_ : @NoDup A (@cons A a l)) (_ : @Permutation A (@cons A a l) l'), @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@cons A a l) f h m) (@collate_ls A B A_eq_dec l' f h m) *) - intros. simpl in *. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@nil A) f h m) (@collate_ls A B A_eq_dec l' f h m) *) destruct (A_eq_dec b to), (A_eq_dec n a); subst. + specialize (IHs (update2 A_eq_dec f a to (f a to ++ [m]))); (* Goal: @eq (list B) (@collate_ls A B A_eq_dec ns (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B mg (@nil B)))) h mg from h) (@app B (f from h) (@cons B mg (@nil B))) *) break_or_hyp. * find_rewrite. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) rewrite update2_eq; eauto. (* Goal: @eq (list B) (@app B (f from to) (@cons B m (@nil B))) (f from to) *) right; eexists; intuition. find_apply_lem_hyp in_inv; break_or_hyp; [|exfalso]; eauto using in_nil. (* Goal: @eq (list B) (@app B (f h to) (@cons B m (@nil B))) (f from to) *) * break_exists_name l; break_and. (* Goal: @In B x (f a b) *) repeat find_rewrite. (* Goal: or (@eq (list B) (@app B (@update2 A (list B) A_eq_dec f a to (@app B (f a to) (@cons B m (@nil B))) a to) l) (f a to)) (@ex (list B) (fun l0 : list B => and (forall (x : B) (_ : @In B x l0), @eq B x m) (@eq (list B) (@app B (@update2 A (list B) A_eq_dec f a to (@app B (f a to) (@cons B m (@nil B))) a to) l) (@app B (f a to) l0)))) *) rewrite update2_same. (* Goal: or (@eq (list B) (@app B (@app B (f a to) (@cons B m (@nil B))) l) (f a to)) (@ex (list B) (fun l0 : list B => and (forall (x : B) (_ : @In B x l0), @eq B x m) (@eq (list B) (@app B (@app B (f a to) (@cons B m (@nil B))) l) (@app B (f a to) l0)))) *) right; exists (m :: l). (* Goal: and (forall (x : B) (_ : @In B x (@cons B m l)), @eq B x m) (@eq (list B) (@app B (@app B (f a to) (@cons B m (@nil B))) l) (@app B (f a to) (@cons B m l))) *) split. -- intros; find_apply_lem_hyp in_inv; (* Goal: @eq (list B) (@app B (f from to) (@cons B m (@nil B))) (f from to) *) intuition. -- rewrite <- app_assoc; auto. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) + rewrite collate_ls_neq_update2; auto. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) + rewrite collate_ls_neq_to, update2_diff2; auto. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) + rewrite collate_ls_neq_to, update2_diff2; auto. Qed. Lemma collate_ls_in_neq_in_before : forall s (f : A -> A -> list B) to m a b x, In x (collate_ls A_eq_dec s f to m a b) -> x <> m -> In x (f a b). Proof using. (* Goal: forall (f : forall (_ : A) (_ : A), list B) (l' : list A) (_ : @NoDup A (@cons A a l)) (_ : @Permutation A (@cons A a l) l'), @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@cons A a l) f h m) (@collate_ls A B A_eq_dec l' f h m) *) intros. (* Goal: @eq (list B) (@collate_ls A B A_eq_dec ns (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B mg (@nil B)))) h mg from h) (@app B (f from h) (@cons B mg (@nil B))) *) pose proof (collate_ls_cases s f to m a b); break_or_hyp. - now find_rewrite. - break_exists; break_and. (* Goal: @In B x (f a b) *) find_rewrite. (* Goal: False *) find_apply_lem_hyp in_app_or; break_or_hyp; auto. (* Goal: @In B x (f a b) *) find_apply_hyp_hyp; congruence. Qed. Lemma collate_ls_not_related : forall ns (f : A -> A -> list B) n h mg, ~ R h n -> collate_ls A_eq_dec (filter_rel R_dec h ns) f h mg n h = f n h. Proof using. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) induction ns; intros; simpl in *; auto. (* Goal: not (@In A a (@app A x x0)) *) case (A_eq_dec n a); intro. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@nil A) f h m) (@collate_ls A B A_eq_dec l' f h m) *) - subst. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) break_if; auto. (* Goal: @eq (list B) (@app B (f from to) (@cons B m (@nil B))) (f from to) *) intuition. - break_if; auto. (* Goal: @eq (list B) (@collate_ls A B A_eq_dec (@cons A a (@filter_rel A R R_dec h (@remove_all A A_eq_dec ns' ns))) f h mg n h) (f n h) *) simpl. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) rewrite IHns; auto. (* Goal: @eq (list B) (@update2 A (list B) A_eq_dec f h' h (@app B (f h' h) (@cons B m (@nil B))) from to) (f from to) *) unfold update2. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) break_if; auto. (* Goal: @eq (list B) (@app B (f h to) (@cons B m (@nil B))) (f from to) *) break_and. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@nil A) f h m) (@collate_ls A B A_eq_dec l' f h m) *) subst. (* Goal: @eq (list B) (@app B (f from to) (@cons B m (@nil B))) (f from to) *) intuition. Qed. Lemma collate_ls_not_in_related : forall ns (f : A -> A -> list B) n h mg, ~ In n ns -> collate_ls A_eq_dec (filter_rel R_dec h ns) f h mg n h = f n h. Proof using. (* Goal: forall (f : forall (_ : A) (_ : A), list B) (l' : list A) (_ : @NoDup A (@cons A a l)) (_ : @Permutation A (@cons A a l) l'), @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@cons A a l) f h m) (@collate_ls A B A_eq_dec l' f h m) *) intros. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) rewrite collate_ls_not_in; auto. (* Goal: not (@In A n (@filter_rel A R R_dec h (@remove_all A A_eq_dec ns' ns))) *) apply not_in_not_in_filter_rel. (* Goal: @Permutation A l (@app A x x0) *) assumption. Qed. Lemma collate_ls_not_in_related_remove_all : forall ns (f : A -> A -> list B) n h mg ns', ~ In n ns -> collate_ls A_eq_dec (filter_rel R_dec h (remove_all A_eq_dec ns' ns)) f h mg n h = f n h. Proof using. (* Goal: forall (f : forall (_ : A) (_ : A), list B) (l' : list A) (_ : @NoDup A (@cons A a l)) (_ : @Permutation A (@cons A a l) l'), @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@cons A a l) f h m) (@collate_ls A B A_eq_dec l' f h m) *) intros. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) rewrite collate_ls_not_in; auto. (* Goal: not (@In A n (@filter_rel A R R_dec h (@remove_all A A_eq_dec ns' ns))) *) apply not_in_not_in_filter_rel. (* Goal: not (@In A a (@app A x x0)) *) intro. (* Goal: False *) contradict H. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) eapply in_remove_all_was_in; eauto. Qed. Lemma collate_ls_in_remove_all : forall mg n h ns (f : A -> A -> list B) ns', In n ns' -> collate_ls A_eq_dec (filter_rel R_dec h (remove_all A_eq_dec ns' ns)) f h mg n h = f n h. Proof using. (* Goal: forall (f : forall (_ : A) (_ : A), list B) (l' : list A) (_ : @NoDup A (@cons A a l)) (_ : @Permutation A (@cons A a l) l'), @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@cons A a l) f h m) (@collate_ls A B A_eq_dec l' f h m) *) intros. (* Goal: @eq (list B) (@collate_ls A B A_eq_dec (@filter_rel A R R_dec h (@remove_all A A_eq_dec ns' ns)) f h mg n h) (f n h) *) revert f. (* Goal: forall (f : forall (_ : A) (_ : A), list B) (l' : list A) (_ : @NoDup A (@cons A a l)) (_ : @Permutation A (@cons A a l) l'), @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@cons A a l) f h m) (@collate_ls A B A_eq_dec l' f h m) *) induction ns; intros. - rewrite remove_all_nil. (* Goal: @eq A a a *) (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec l' f h m) *) trivial. - pose proof (remove_all_cons A_eq_dec ns' a ns) as H_cn. (* Goal: @In B x (f a b) *) break_or_hyp; break_and; find_rewrite. * rewrite IHns. (* Goal: @eq A a a *) (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec l' f h m) *) trivial. * simpl in *. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) break_if; auto. (* Goal: @eq (list B) (@collate_ls A B A_eq_dec (@cons A a (@filter_rel A R R_dec h (@remove_all A A_eq_dec ns' ns))) f h mg n h) (f n h) *) simpl. (* Goal: @eq (list B) (@collate_ls A B A_eq_dec (@filter_rel A R R_dec h (@remove_all A A_eq_dec ns' ns)) (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B mg (@nil B)))) h mg n h) (f n h) *) assert (H_neq: a <> n). (* Goal: not (@In A a (@app A x x0)) *) intro. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@nil A) f h m) (@collate_ls A B A_eq_dec l' f h m) *) subst. (* Goal: @eq (list B) (@app B (f from to) (@cons B m (@nil B))) (f from to) *) intuition. (* Goal: @eq (list B) (@collate_ls A B A_eq_dec (@filter_rel A R R_dec h (@remove_all A A_eq_dec ns' ns)) (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B mg (@nil B)))) h mg n h) (f n h) *) rewrite IHns. (* Goal: @eq (list B) (@update2 A (list B) A_eq_dec f h' h (@app B (f h' h) (@cons B m (@nil B))) from to) (f from to) *) unfold update2. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) break_if; auto. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@nil A) f h m) (@collate_ls A B A_eq_dec l' f h m) *) break_and; subst. (* Goal: @eq (list B) (@app B (f from to) (@cons B m (@nil B))) (f from to) *) intuition. Qed. Lemma collate_ls_app : forall l1 l2 (f : A -> A -> list B) h m, collate_ls A_eq_dec (l1 ++ l2) f h m = collate_ls A_eq_dec l2 (collate_ls A_eq_dec l1 f h m) h m. Proof using. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) induction l1; simpl in *; intuition eauto. Qed. Lemma collate_ls_split_eq : forall l1 l2 (f : A -> A -> list B) h m from to, h <> from -> collate_ls A_eq_dec (l1 ++ h :: l2) f to m from to = collate_ls A_eq_dec (l1 ++ l2) f to m from to. Proof using. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) induction l1; simpl in *; auto. (* Goal: forall (f : forall (_ : A) (_ : A), list B) (l' : list A) (_ : @NoDup A (@cons A a l)) (_ : @Permutation A (@cons A a l) l'), @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@cons A a l) f h m) (@collate_ls A B A_eq_dec l' f h m) *) intros. (* Goal: @eq (list B) (@collate_ls A B A_eq_dec l2 (@update2 A (list B) A_eq_dec f h to (@app B (f h to) (@cons B m (@nil B)))) to m from to) (@collate_ls A B A_eq_dec l2 f to m from to) *) apply collate_ls_f_eq. (* Goal: @eq (list B) (@update2 A (list B) A_eq_dec f h' h (@app B (f h' h) (@cons B m (@nil B))) from to) (f from to) *) unfold update2. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) break_if; auto. (* Goal: @eq (list B) (@app B (f h to) (@cons B m (@nil B))) (f from to) *) break_and. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@nil A) f h m) (@collate_ls A B A_eq_dec l' f h m) *) subst. (* Goal: @eq (list B) (@app B (f from to) (@cons B m (@nil B))) (f from to) *) intuition. Qed. Lemma collate_ls_not_in_mid : forall h h' l1 l2 (f : A -> A -> list B) m, ~ In h' (l1 ++ l2) -> collate_ls A_eq_dec (l1 ++ l2) (update2 A_eq_dec f h' h (f h' h ++ [m])) h m = collate_ls A_eq_dec (l1 ++ h' :: l2) f h m. Proof using. (* Goal: forall (h h' : A) (l1 l2 : list A) (f : forall (_ : A) (_ : A), list B) (m : B) (_ : not (@In A h' (@app A l1 l2))), @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@app A l1 l2) (@update2 A (list B) A_eq_dec f h' h (@app B (f h' h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec (@app A l1 (@cons A h' l2)) f h m) *) intros h h' l1 l2 f m H_in. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@app A l1 l2) (@update2 A (list B) A_eq_dec f h' h (@app B (f h' h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec (@app A l1 (@cons A h' l2)) f h m) *) apply functional_extensionality; intro from. (* Goal: @eq (forall _ : A, list B) (@collate_ls A B A_eq_dec (@app A l1 l2) (@update2 A (list B) A_eq_dec f h' h (@app B (f h' h) (@cons B m (@nil B)))) h m from) (@collate_ls A B A_eq_dec (@app A l1 (@cons A h' l2)) f h m from) *) apply functional_extensionality; intro to. (* Goal: @eq (list B) (@collate A B A_eq_dec h' (@update2 A (list B) A_eq_dec f h' h (@app B (f h' h) (@cons B m (@nil B)))) (@app (prod A B) l1 l2) h' to) (@collate A B A_eq_dec h' f (@app (prod A B) l1 (@cons (prod A B) (@pair A B h m) l2)) h' to) *) case (A_eq_dec h' from); intro H_dec; case (A_eq_dec h to); intro H_dec'. - rewrite <- H_dec. rewrite <- H_dec'. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) rewrite collate_ls_not_in; auto. (* Goal: @eq (list B) (@collate_ls A B A_eq_dec (@cons A a (@filter_rel A R R_dec h (@remove_all A A_eq_dec ns' ns))) f h mg n h) (f n h) *) rewrite collate_ls_app; simpl. (* Goal: @eq (list B) (@update2 A (list B) A_eq_dec f h' h (@app B (f h' h) (@cons B m (@nil B))) h' h) (@collate_ls A B A_eq_dec l2 (@update2 A (list B) A_eq_dec (@collate_ls A B A_eq_dec l1 f h m) h' h (@app B (@collate_ls A B A_eq_dec l1 f h m h' h) (@cons B m (@nil B)))) h m h' h) *) set (f' := collate_ls _ l1 _ _ _). (* Goal: @eq (list B) (@update2 A (list B) A_eq_dec f h' h (@app B (f h' h) (@cons B m (@nil B))) h' h) (@app B (@collate_ls A B A_eq_dec l1 f h m h' h) (@cons B m (@nil B))) *) rewrite collate_ls_not_in. * unfold update2 at 2. (* Goal: @eq (list B) (@update2 A (list B) A_eq_dec f h' h (@app B (f h' h) (@cons B m (@nil B))) h' h) (if sumbool_and (@eq A h' h') (not (@eq A h' h')) (@eq A h h) (not (@eq A h h)) (A_eq_dec h' h') (A_eq_dec h h) then @app B (f' h' h) (@cons B m (@nil B)) else f' h' h) *) break_if. + unfold f'. (* Goal: @eq (list B) (@update2 A (list B) A_eq_dec f h' h (@app B (f h' h) (@cons B m (@nil B))) h' h) (@app B (@collate_ls A B A_eq_dec l1 f h m h' h) (@cons B m (@nil B))) *) rewrite collate_ls_not_in. (* Goal: @eq (list B) (@update2 A (list B) A_eq_dec f h' h (@app B (f h' h) (@cons B m (@nil B))) from to) (f from to) *) -- unfold update2. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) break_if; auto. (* Goal: @eq (list B) (@app B (f from to) (@cons B m (@nil B))) (f from to) *) break_or_hyp; intuition. -- intro. (* Goal: False *) contradict H_in. (* Goal: @In A h' (@app A l1 l2) *) apply in_or_app. (* Goal: @In A a (@cons A a l) *) (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec l' f h m) *) left. (* Goal: @Permutation A l (@app A x x0) *) assumption. (* Goal: @eq (list B) (@app B (f from to) (@cons B m (@nil B))) (f from to) *) + break_or_hyp; intuition. * intro. (* Goal: False *) contradict H_in. (* Goal: @In A h' (@app A l1 l2) *) apply in_or_app. (* Goal: or (@In A h' l1) (@In A h' l2) *) right. (* Goal: @Permutation A l (@app A x x0) *) assumption. - rewrite collate_ls_neq_to; auto. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) rewrite collate_ls_neq_to; auto. (* Goal: @eq (list B) (@update2 A (list B) A_eq_dec f h' h (@app B (f h' h) (@cons B m (@nil B))) from to) (f from to) *) unfold update2. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) break_if; auto. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@nil A) f h m) (@collate_ls A B A_eq_dec l' f h m) *) break_and; subst. (* Goal: @eq (list B) (@app B (f from to) (@cons B m (@nil B))) (f from to) *) intuition. - rewrite H_dec'. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) rewrite collate_ls_neq_update2; auto. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) rewrite collate_ls_split_eq; auto. - rewrite collate_ls_neq_to; auto. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) rewrite collate_ls_neq_to; auto. (* Goal: @eq (list B) (@update2 A (list B) A_eq_dec f h' h (@app B (f h' h) (@cons B m (@nil B))) from to) (f from to) *) unfold update2. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) break_if; auto. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@nil A) f h m) (@collate_ls A B A_eq_dec l' f h m) *) break_and; subst. (* Goal: @eq (list B) (@app B (f from to) (@cons B m (@nil B))) (f from to) *) intuition. Qed. Lemma NoDup_Permutation_collate_ls_eq : forall l (f : A -> A -> list B) h m l', NoDup l -> Permutation l l' -> collate_ls A_eq_dec l f h m = collate_ls A_eq_dec l' f h m. Proof using. (* Goal: forall (l : list A) (f : forall (_ : A) (_ : A), list B) (h : A) (m : B) (l' : list A) (_ : @NoDup A l) (_ : @Permutation A l l'), @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l f h m) (@collate_ls A B A_eq_dec l' f h m) *) intros l f h m l'. (* Goal: forall (_ : @NoDup A l) (_ : @Permutation A l l'), @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l f h m) (@collate_ls A B A_eq_dec l' f h m) *) revert f l'. (* Goal: forall (f : forall (_ : A) (_ : A), list B) (l' : list A) (_ : @NoDup A l) (_ : @Permutation A l l'), @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l f h m) (@collate_ls A B A_eq_dec l' f h m) *) induction l. (* Goal: forall (f : forall (_ : A) (_ : A), list B) (l' : list A) (_ : @NoDup A (@cons A a l)) (_ : @Permutation A (@cons A a l) l'), @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@cons A a l) f h m) (@collate_ls A B A_eq_dec l' f h m) *) - intros. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@nil A) f h m) (@collate_ls A B A_eq_dec l' f h m) *) find_apply_lem_hyp Permutation_nil. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@nil A) f h m) (@collate_ls A B A_eq_dec l' f h m) *) subst. (* Goal: @eq A a a *) (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec l' f h m) *) trivial. (* Goal: forall (f : forall (_ : A) (_ : A), list B) (l' : list A) (_ : @NoDup A (@cons A a l)) (_ : @Permutation A (@cons A a l) l'), @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@cons A a l) f h m) (@collate_ls A B A_eq_dec l' f h m) *) - intros. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@cons A a l) f h m) (@collate_ls A B A_eq_dec l' f h m) *) invc_NoDup. simpl in *. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec l' f h m) *) assert (H_in: In a (a :: l)). (* Goal: @In A a (@cons A a l) *) (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec l' f h m) *) left. (* Goal: @eq A a a *) (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec l' f h m) *) trivial. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec l' f h m) *) pose proof (Permutation_in _ H0 H_in) as H_pm'. (* Goal: and (forall (x : B) (_ : @In B x (@cons B m l)), @eq B x m) (@eq (list B) (@app B (@app B (f a to) (@cons B m (@nil B))) l) (@app B (f a to) (@cons B m l))) *) find_apply_lem_hyp in_split. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec l' f h m) *) break_exists. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec l' f h m) *) subst_max. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec (@app A x (@cons A a x0)) f h m) *) find_apply_lem_hyp Permutation_cons_app_inv. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec l (@update2 A (list B) A_eq_dec f a h (@app B (f a h) (@cons B m (@nil B)))) h m) (@collate_ls A B A_eq_dec (@app A x (@cons A a x0)) f h m) *) set (f' := update2 _ _ _ _ _). (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) rewrite (IHl f' _ H4 H0); auto. (* Goal: @eq (forall (_ : A) (_ : A), list B) (@collate_ls A B A_eq_dec (@app A x x0) f' h m) (@collate_ls A B A_eq_dec (@app A x (@cons A a x0)) f h m) *) unfold f'. (* Goal: forall f : forall (_ : A) (_ : A), list B, or (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (f a b)) (@ex (list B) (fun l : list B => and (forall (x : B) (_ : @In B x l), @eq B x m) (@eq (list B) (@collate_ls A B A_eq_dec (@nil A) f to m a b) (@app B (f a b) l)))) *) rewrite collate_ls_not_in_mid; auto. (* Goal: not (@In A a (@app A x x0)) *) intro. (* Goal: False *) contradict H3. (* Goal: @In A a l *) revert H. (* Goal: forall _ : @In A a (@app A x x0), @In A a l *) apply Permutation_in. (* Goal: @Permutation A (@app A x x0) l *) apply Permutation_sym. (* Goal: @Permutation A l (@app A x x0) *) assumption. Qed. End Update2Rel.
Require Import Omega. Require Import List. Import ListNotations. Require Import StructTact.StructTactics. Require Import StructTact.ListTactics. Require Import StructTact.FilterMap. Require Import StructTact.RemoveAll. Set Implicit Arguments. Fixpoint subseq {A} (xs ys : list A) : Prop := match xs, ys with | [], _ => True | x :: xs', y :: ys' => (x = y /\ subseq xs' ys') \/ subseq xs ys' | _, _ => False end. Section subseq. Variable A B : Type. Hypothesis A_eq_dec : forall x y : A, {x = y} + {x <> y}. Lemma subseq_refl : forall (l : list A), subseq l l. Proof using. (* Goal: forall l : list A, @subseq A l l *) induction l; simpl; tauto. Qed. Lemma subseq_trans : forall (zs xs ys : list A), subseq xs ys -> subseq ys zs -> subseq xs zs. Proof using. induction zs; intros; simpl in *; repeat break_match; subst; simpl in *; intuition; subst; eauto; (* Goal: or (and (@eq A a0 a) (@subseq A (@app A l0 zs) (@app A ys zs))) (@subseq A (@app A (@cons A a0 l0) zs) (@app A ys zs)) *) right; (eapply IHzs; [|eauto]); simpl; eauto. Qed. Lemma subseq_In : forall (ys xs : list A) x, subseq xs ys -> In x xs -> In x ys. Proof using. (* Goal: forall (ys xs : list A) (_ : @subseq A xs ys) (_ : @NoDup A ys), @NoDup A xs *) induction ys; intros. - destruct xs; simpl in *; intuition. - simpl in *. break_match; simpl in *; intuition; subst; intuition eauto; right; (eapply IHys; [eauto| intuition]). Qed. Theorem subseq_NoDup : forall (ys xs : list A), subseq xs ys -> NoDup ys -> NoDup xs. Proof using. (* Goal: forall (ys xs : list A) (_ : @subseq A xs ys) (_ : @NoDup A ys), @NoDup A xs *) induction ys; intros. - destruct xs; simpl in *; intuition. - simpl in *. invc_NoDup. (* Goal: match ys with | nil => True | cons x xs' => or (and (@eq A x a) (@subseq A xs' (@app A xs ys))) (@subseq A ys (@app A xs ys)) end *) break_match. + constructor. + intuition. (* Goal: or (and (@eq A a0 a) (@subseq A l (@app A ys zs))) (@subseq A (@cons A a0 l) (@app A ys zs)) *) subst. constructor; eauto using subseq_In. Qed. Lemma subseq_remove : forall (x : A) xs, subseq (remove A_eq_dec x xs) xs. Proof using. (* Goal: forall xs ys : list A, @subseq A ys (@app A xs ys) *) induction xs; intros; simpl. - auto. - repeat break_match; auto. + intuition congruence. + find_inversion. auto. Qed. Lemma subseq_map : forall (f : A -> B) ys xs, subseq xs ys -> subseq (map f xs) (map f ys). Proof using. (* Goal: or (and (@eq A a0 a) (@subseq A l (@app A ys zs))) (@subseq A (@cons A a0 l) (@app A ys zs)) *) induction ys; intros; simpl in *. - repeat break_match; try discriminate; auto. - repeat break_match; try discriminate; auto. (* Goal: or (and (@eq A a0 a) (@subseq A (@app A l0 zs) (@app A ys zs))) (@subseq A (@cons A a0 (@app A l0 zs)) (@app A ys zs)) *) intuition. (* Goal: or (and (@eq A a0 a) (@subseq A l (@app A ys zs))) (@subseq A (@cons A a0 l) (@app A ys zs)) *) + subst. simpl in *. find_inversion. auto. + right. repeat find_reverse_rewrite. auto. Qed. Lemma subseq_cons_drop : forall xs ys (a : A), subseq (a :: xs) ys -> subseq xs ys. Proof using. (* Goal: or (and (@eq A a0 a) (@subseq A (@app A l0 zs) (@app A ys zs))) (@subseq A (@app A (@cons A a0 l0) zs) (@app A ys zs)) *) induction ys; intros; simpl in *; intuition; break_match; eauto. Qed. Lemma subseq_length : forall (ys xs : list A), subseq xs ys -> length xs <= length ys. Proof using. (* Goal: or (and (@eq A a0 a) (@subseq A (@app A l0 zs) (@app A ys zs))) (@subseq A (@cons A a0 (@app A l0 zs)) (@app A ys zs)) *) induction ys; intros; simpl in *; break_match; intuition. (* Goal: or (and (@eq A a0 a) (@subseq A l (@app A ys zs))) (@subseq A (@cons A a0 l) (@app A ys zs)) *) subst. simpl in *. specialize (IHys l). concludes. auto with *. Qed. Lemma subseq_subseq_eq : forall (xs ys : list A), subseq xs ys -> subseq ys xs -> xs = ys. Proof using. induction xs; intros; destruct ys; simpl in *; intuition eauto using f_equal2, subseq_cons_drop. (* Goal: @eq (list A) (@cons A a xs) (@cons A a0 ys) *) exfalso. (* Goal: False *) repeat find_apply_lem_hyp subseq_length. (* Goal: or (and (@eq A a0 a) (@subseq A l (@app A ys zs))) (@subseq A (@cons A a0 l) (@app A ys zs)) *) simpl in *. omega. Qed. Lemma subseq_filter : forall (f : A -> bool) xs, subseq (filter f xs) xs. Proof using. (* Goal: forall xs ys : list A, @subseq A ys (@app A xs ys) *) induction xs; intros; simpl. - auto. - repeat break_match; intuition congruence. Qed. Lemma subseq_nil : forall xs, subseq (A:=A) [] xs. Proof using. (* Goal: or (and (@eq A a0 a) (@subseq A (@app A l0 zs) (@app A ys zs))) (@subseq A (@app A (@cons A a0 l0) zs) (@app A ys zs)) *) destruct xs; simpl; auto. Qed. Lemma subseq_skip : forall a xs ys, subseq(A:=A) xs ys -> subseq xs (a :: ys). Proof using. (* Goal: or (and (@eq A a0 a) (@subseq A (@app A l0 zs) (@app A ys zs))) (@subseq A (@cons A a0 (@app A l0 zs)) (@app A ys zs)) *) induction ys; intros; simpl in *; repeat break_match; intuition. Qed. Lemma subseq_filterMap : forall (f : B -> option A) ys xs, subseq xs ys -> subseq (filterMap f xs) (filterMap f ys). Proof using. (* Goal: or (and (@eq A a0 a) (@subseq A l (@app A ys zs))) (@subseq A (@cons A a0 l) (@app A ys zs)) *) induction ys; intros; simpl in *; repeat break_match; auto; try discriminate; intuition; subst. - simpl. find_rewrite. auto. - auto using subseq_skip. - auto using subseq_nil. - simpl. find_rewrite. auto. Qed. Lemma subseq_app_r : forall xs ys, subseq (A:=A) ys (xs ++ ys). Proof using. (* Goal: forall xs ys : list A, @subseq A ys (@app A xs ys) *) induction xs; intros; simpl. + auto using subseq_refl. (* Goal: match ys with | nil => True | cons x xs' => or (and (@eq A x a) (@subseq A xs' (@app A xs ys))) (@subseq A ys (@app A xs ys)) end *) + break_match. (* Goal: or (and (@eq A a0 a) (@subseq A (@app A l0 zs) (@app A ys zs))) (@subseq A (@app A (@cons A a0 l0) zs) (@app A ys zs)) *) * auto. (* Goal: or (and (@eq A a0 a) (@subseq A l (@app A ys (@cons A a0 l)))) (@subseq A (@cons A a0 l) (@app A ys (@cons A a0 l))) *) * right. auto using subseq_nil. Qed. Lemma subseq_app_tail : forall ys xs zs, subseq (A:=A) xs ys -> subseq (xs ++ zs) (ys ++ zs). Proof using. (* Goal: or (and (@eq A a0 a) (@subseq A l (@app A ys zs))) (@subseq A (@cons A a0 l) (@app A ys zs)) *) induction ys; intros; simpl in *. - break_match; intuition auto using subseq_refl. - repeat break_match. + auto. + discriminate. (* Goal: or (and (@eq A a0 a) (@subseq A l (@app A ys zs))) (@subseq A (@cons A a0 l) (@app A ys zs)) *) + simpl in *. subst. right. auto using subseq_app_r. (* Goal: or (and (@eq A a0 a) (@subseq A l (@app A ys zs))) (@subseq A (@cons A a0 l) (@app A ys zs)) *) + simpl in *. find_inversion. intuition. (* Goal: or (and (@eq A a0 a) (@subseq A (@app A l0 zs) (@app A ys zs))) (@subseq A (@app A (@cons A a0 l0) zs) (@app A ys zs)) *) rewrite app_comm_cons. auto. Qed. Lemma subseq_app_head : forall xs ys zs, subseq (A:=A) ys zs -> subseq (A:=A) (xs ++ ys) (xs ++ zs). Proof using. (* Goal: or (and (@eq A a0 a) (@subseq A (@app A l0 zs) (@app A ys zs))) (@subseq A (@cons A a0 (@app A l0 zs)) (@app A ys zs)) *) induction xs; intros; simpl; intuition. Qed. Lemma subseq_2_3 : forall xs ys zs x y, subseq(A:=A) (xs ++ ys ++ zs) (xs ++ x :: ys ++ y :: zs). Proof using. (* Goal: forall (xs ys zs : list A) (x y : A), @subseq A (@app A xs (@app A ys zs)) (@app A xs (@cons A x (@app A ys (@cons A y zs)))) *) auto using subseq_refl, subseq_skip, subseq_app_head. Qed. Lemma subseq_middle : forall xs y zs, subseq (A:=A) (xs ++ zs) (xs ++ y :: zs). Proof using. (* Goal: forall (xs : list A) (y : A) (zs : list A), @subseq A (@app A xs zs) (@app A xs (@cons A y zs)) *) intros. (* Goal: @subseq A (@app A xs zs) (@app A xs (@cons A y zs)) *) apply subseq_app_head. (* Goal: @subseq A zs (@cons A y zs) *) apply subseq_skip. (* Goal: @subseq A zs zs *) apply subseq_refl. Qed. Lemma subseq_remove_all : forall (ds l l' : list A), subseq l l' -> subseq (remove_all A_eq_dec ds l) l'. Proof using. (* Goal: @subseq A (@filterMap B A f (@cons B a l)) (@filterMap B A f ys) *) induction ds; intros; simpl. - auto. - apply IHds. eapply subseq_trans. apply subseq_remove. (* Goal: or (and (@eq A a0 a) (@subseq A (@app A l0 zs) (@app A ys zs))) (@subseq A (@app A (@cons A a0 l0) zs) (@app A ys zs)) *) auto. Qed. End subseq.
Require Import List. Import ListNotations. Require Import StructTact.StructTactics. Require Import StructTact.ListTactics. Set Implicit Arguments. Fixpoint filterMap {A B} (f : A -> option B) (l : list A) : list B := match l with | [] => [] | x :: xs => match f x with | None => filterMap f xs | Some y => y :: filterMap f xs end end. Section filter_map. Variables A B C : Type. Lemma map_of_filterMap : forall (f : A -> option B) (g : B -> C) l, map g (filterMap f l) = filterMap (fun x => match f x with | Some y => Some (g y) | None => None end) l. Proof using. (* Goal: forall (f g : forall _ : A, option B) (l : list A) (_ : forall x : A, @eq (option B) (f x) (g x)), @eq (list B) (@filterMap A B f l) (@filterMap A B g l) *) induction l; intros; simpl in *. - auto. - repeat break_match; simpl; auto using f_equal. Qed. Lemma filterMap_ext : forall (f g : A -> option B) l, (forall x, f x = g x) -> filterMap f l = filterMap g l. Proof using. (* Goal: forall (f g : forall _ : A, option B) (l : list A) (_ : forall x : A, @eq (option B) (f x) (g x)), @eq (list B) (@filterMap A B f l) (@filterMap A B g l) *) induction l; intros; simpl in *. - auto. - repeat find_higher_order_rewrite; auto. Qed. Lemma filterMap_defn : forall (f : A -> option B) x xs, filterMap f (x :: xs) = match f x with | Some y => y :: filterMap f xs | None => filterMap f xs end. Proof using. (* Goal: forall (f : forall _ : A, option B) (x : A) (xs : list A), @eq (list B) match f x with | Some y => @cons B y (@filterMap A B f xs) | None => @filterMap A B f xs end match f x with | Some y => @cons B y (@filterMap A B f xs) | None => @filterMap A B f xs end *) simpl. auto. Qed. Lemma In_filterMap : forall (f : A -> option B) b xs, In b (filterMap f xs) -> exists a, In a xs /\ f a = Some b. Proof using. (* Goal: forall (f : forall _ : A, option B) (b : B) (xs : list A) (_ : @In B b (@filterMap A B f xs)), @ex A (fun a : A => and (@In A a xs) (@eq (option B) (f a) (@Some B b))) *) intros. (* Goal: @ex A (fun a : A => and (@In A a xs) (@eq (option B) (f a) (@Some B b))) *) induction xs; simpl in *; intuition. (* Goal: @ex A (fun a0 : A => and (or (@eq A a a0) (@In A a0 xs)) (@eq (option B) (f a0) (@Some B b))) *) break_match. - simpl in *. intuition; subst; eauto. (* Goal: @ex A (fun a0 : A => and (or (@eq A a a0) (@In A a0 xs)) (@eq (option B) (f a0) (@Some B b))) *) break_exists_exists; intuition. - concludes. break_exists_exists; intuition. Qed. Lemma filterMap_app : forall (f : A -> option B) xs ys, filterMap f (xs ++ ys) = filterMap f xs ++ filterMap f ys. Proof using. (* Goal: forall (f : forall _ : A, option B) (xs ys : list A), @eq (list B) (@filterMap A B f (@app A xs ys)) (@app B (@filterMap A B f xs) (@filterMap A B f ys)) *) induction xs; intros; simpl in *; repeat break_match; simpl in *; intuition auto using f_equal. Qed. Lemma filterMap_In : forall A B (f : A -> option B) a b xs, f a = Some b -> In a xs -> In b (filterMap f xs). Proof using. (* Goal: forall (A B : Type) (f : forall _ : A, option B) (a : A) (b : B) (xs : list A) (_ : @eq (option B) (f a) (@Some B b)) (_ : @In A a xs), @In B b (@filterMap A B f xs) *) induction xs; simpl; repeat break_match; simpl; intuition (auto; try congruence). Qed. Lemma filterMap_of_filterMap : forall (f : B -> option C) (g : A -> option B) xs, filterMap f (filterMap g xs) = filterMap (fun a => match g a with | Some b => f b | None => None end) xs. Proof using. (* Goal: forall (f : forall _ : B, option C) (g : forall _ : A, option B) (xs : list A), @eq (list C) (@filterMap B C f (@filterMap A B g xs)) (@filterMap A C (fun a : A => match g a with | Some b => f b | None => @None C end) xs) *) induction xs; simpl; intuition. (* Goal: forall (f : forall _ : A, option B) (x : A) (xs : list A), @eq (list B) match f x with | Some y => @cons B y (@filterMap A B f xs) | None => @filterMap A B f xs end match f x with | Some y => @cons B y (@filterMap A B f xs) | None => @filterMap A B f xs end *) repeat break_match; simpl; repeat find_rewrite; auto. Qed. Lemma filterMap_all_None : forall (f : A -> option B) xs, (forall x, In x xs -> f x = None) -> filterMap f xs = []. Proof using. (* Goal: forall (f : forall _ : A, option B) (xs : list A) (_ : forall (x : A) (_ : @In A x xs), @eq (option B) (f x) (@None B)), @eq (list B) (@filterMap A B f xs) (@nil B) *) induction xs; intros; simpl in *; intuition. (* Goal: forall (f : forall _ : A, option B) (x : A) (xs : list A), @eq (list B) match f x with | Some y => @cons B y (@filterMap A B f xs) | None => @filterMap A B f xs end match f x with | Some y => @cons B y (@filterMap A B f xs) | None => @filterMap A B f xs end *) rewrite H; auto. Qed. Lemma filterMap_NoDup_inj : forall (f : A -> option B) l, (forall x1 x2 y, f x1 = Some y -> f x2 = Some y -> x1 = x2) -> NoDup l -> NoDup (filterMap f l). Proof using. (* Goal: forall (f : forall _ : A, option B) (b : B) (xs : list A) (_ : @In B b (@filterMap A B f xs)), @ex A (fun a : A => and (@In A a xs) (@eq (option B) (f a) (@Some B b))) *) induction l; intros. - constructor. - simpl. invc_NoDup. (* Goal: forall (f : forall _ : A, option B) (x : A) (xs : list A), @eq (list B) match f x with | Some y => @cons B y (@filterMap A B f xs) | None => @filterMap A B f xs end match f x with | Some y => @cons B y (@filterMap A B f xs) | None => @filterMap A B f xs end *) break_match; auto. (* Goal: forall (f : forall _ : A, option B) (x : A) (xs : list A), @eq (list B) match f x with | Some y => @cons B y (@filterMap A B f xs) | None => @filterMap A B f xs end match f x with | Some y => @cons B y (@filterMap A B f xs) | None => @filterMap A B f xs end *) constructor; auto. (* Goal: not (@In B b (@filterMap A B f l)) *) intro. (* Goal: False *) find_apply_lem_hyp In_filterMap. break_exists. break_and. (* Goal: forall (f : forall _ : A, option B) (x : A) (xs : list A), @eq (list B) match f x with | Some y => @cons B y (@filterMap A B f xs) | None => @filterMap A B f xs end match f x with | Some y => @cons B y (@filterMap A B f xs) | None => @filterMap A B f xs end *) assert (a = x) by eauto. (* Goal: False *) subst. contradiction. Qed. End filter_map.
Require Import List. Import ListNotations. Require Import StructTact.StructTactics. Set Implicit Arguments. Inductive Nth {A : Type} : list A -> nat -> A -> Prop := | Nth_0 : forall x l, Nth (x :: l) 0 x | Nth_S : forall l x n y, Nth l n x -> Nth (y :: l) (S n) x. Section nth. Variable A : Type. Lemma nth_error_Nth : forall n l (x : A), nth_error l n = Some x -> Nth l n x. Proof using. (* Goal: forall (n : nat) (l : list A) (x : A) (_ : @eq (option A) (@nth_error A l n) (@Some A x)), @Nth A l n x *) induction n; intros; simpl in *; auto. - break_match; try discriminate. (* Goal: @Nth A (@cons A a l0) O x *) unfold value in *. (* Goal: @Nth A (@cons A a l0) O x *) find_inversion. (* Goal: @Nth A (@cons A a l0) (S n) x *) constructor. - break_match; try discriminate. (* Goal: @Nth A (@cons A a l0) (S n) x *) subst. constructor. (* Goal: @Nth A l0 n x *) eauto. Qed. Lemma Nth_nth_error : forall n l (x : A), Nth l n x -> nth_error l n = Some x. Proof using. (* Goal: forall (n : nat) (l : list A) (x : A) (_ : @Nth A l n x), @eq (option A) (@nth_error A l n) (@Some A x) *) intros. (* Goal: @eq (option A) (@nth_error A l n) (@Some A x) *) induction H; simpl in *; auto. Qed. End nth.
Require Import List. Import ListNotations. Require Import StructTact.StructTactics. Require Import StructTact.Before. Require Import StructTact.Prefix. Set Implicit Arguments. Fixpoint before_func {A: Type} (f : A -> bool) (g : A -> bool) (l : list A) : Prop := match l with | [] => False | a :: l' => f a = true \/ (g a = false /\ before_func f g l') end. Section before_func. Variable A : Type. Variables f g : A -> bool. Definition before_func_dec : forall l, {before_func f g l} + {~ before_func f g l}. (* Goal: forall l : list A, sumbool (@before_func A f g l) (not (@before_func A f g l)) *) intros; induction l; simpl in *. - intuition. - destruct (f a); destruct (g a); intuition. Defined. Lemma before_func_app : forall l x, before_func f g l -> before_func f g (l ++ x). Proof using. (* Goal: and (forall _ : @eq A a y, False) (@before A x y l) *) intros. induction l; simpl in *; intuition. Qed. Lemma before_func_antisymmetric : forall l, (forall x, f x = true -> g x = true -> False) -> before_func f g l -> before_func g f l -> False. Proof using. (* Goal: and (forall _ : @eq A a y, False) (@before A x y l) *) induction l; simpl; intuition. - eauto. - congruence. - congruence. Qed. Lemma before_func_prepend : forall l l', before_func f g l -> (forall x, In x l' -> g x = false) -> before_func f g (l' ++ l). Proof using. (* Goal: and (forall _ : @eq A a y, False) (@before A x y l) *) induction l'; intros; simpl in *; intuition. Qed. Lemma before_func_before : forall l, before_func f g l -> forall y, g y = true -> exists x : A, f x = true /\ before x y l. Proof using. (* Goal: and (forall _ : @eq A a y, False) (@before A x y l) *) induction l; intros; simpl in *; intuition. - eauto. - find_copy_apply_hyp_hyp. break_exists_exists. intuition. (* Goal: and (forall _ : @eq A a y, False) (@before A x y l) *) right. intuition. congruence. Qed. Lemma before_func_prefix : forall l l', Prefix l l' -> before_func f g l -> before_func f g l'. Proof using. (* Goal: forall (l l' : list A) (_ : not (@before_func A f g l)) (_ : @before_func A f g (@app A l l')), and (forall (x : A) (_ : @In A x l), @eq bool (g x) false) (@before_func A f g l') *) intros. (* Goal: @before_func A f g l' *) find_apply_lem_hyp Prefix_exists_rest. (* Goal: @before_func A f g l' *) break_exists; subst. (* Goal: @before_func A f g (@app A l x) *) eauto using before_func_app. Qed. Lemma before_func_app_necessary : forall l l', ~ before_func f g l -> before_func f g (l ++ l') -> (forall x, In x l -> g x = false) /\ before_func f g l'. Proof using. (* Goal: forall (l l' : list A) (_ : not (@before_func A f g l)) (_ : @before_func A f g (@app A l l')), and (forall (x : A) (_ : @In A x l), @eq bool (g x) false) (@before_func A f g l') *) intros. induction l; simpl in *; intuition; subst; auto. Qed. End before_func.
Require Import String. Require Import Ascii. Require Import Arith. Require Import OrderedType. Require Import OrderedTypeEx. Require Import StructTact.StructTactics. Inductive lex_lt: string -> string -> Prop := | lex_lt_lt : forall (c1 c2 : ascii) (s1 s2 : string), nat_of_ascii c1 < nat_of_ascii c2 -> lex_lt (String c1 s1) (String c2 s2) | lex_lt_eq : forall (c : ascii) (s1 s2 : string), lex_lt s1 s2 -> lex_lt (String c s1) (String c s2) | lex_lt_empty : forall (c : ascii) (s : string), lex_lt EmptyString (String c s). Inductive lex_order : string -> string -> Prop := | lex_order_empty : lex_order EmptyString EmptyString | lex_order_char_lt : forall (c1 c2: ascii) (s1 s2: string), nat_of_ascii c1 < nat_of_ascii c2 -> lex_order (String c1 s1) (String c2 s2) | lex_order_char_eq : forall (c: ascii) (s1 s2: string), lex_order s1 s2 -> lex_order (String c s1) (String c s2) | lex_order_empty_string : forall s, lex_order EmptyString s. Definition lex_le (s1 s2 : string) : Prop := lex_lt s1 s2 \/ s1 = s2. Lemma lex_le_in_lex_order : forall (s1 s2 : string), lex_order s1 s2 -> lex_le s1 s2. Proof. (* Goal: forall (s1 s2 : string) (_ : lex_order s1 s2), lex_le s1 s2 *) intros s1 s2 H. (* Goal: lex_le s1 s2 *) induction H. - right. (* Goal: @eq string (String c' s'1) (String c' s'1) *) reflexivity. - left. (* Goal: lex_lt (String c' s'1) (String c s'0) *) apply lex_lt_lt. (* Goal: lt (nat_of_ascii c) (nat_of_ascii c') *) assumption. - case IHlex_order; intro H_le. (* Goal: lex_le s1 s2 *) * left. (* Goal: lex_lt (String c' s'1) (String c' s'0) *) apply lex_lt_eq. (* Goal: lt (nat_of_ascii c) (nat_of_ascii c') *) assumption. * rewrite H_le. (* Goal: lex_le EmptyString EmptyString *) right. (* Goal: @eq string (String c' s'1) (String c' s'1) *) reflexivity. - case s. (* Goal: lex_le EmptyString EmptyString *) * right. (* Goal: @eq string (String c' s'1) (String c' s'1) *) reflexivity. * intros c s0. (* Goal: lex_le s1 s2 *) left. (* Goal: lex_lt EmptyString (String c s'0) *) apply lex_lt_empty. Qed. Lemma lex_order_refl : forall (s : string), lex_order s s. Proof. (* Goal: forall s : string, lex_order s s *) induction s. * apply lex_order_empty_string. * intros. (* Goal: lex_order (String c s1) (String c s2) *) apply lex_order_char_eq. (* Goal: lt (nat_of_ascii c) (nat_of_ascii c') *) assumption. Qed. Lemma lex_order_lex_le : forall (s1 s2 : string), lex_le s1 s2 -> lex_order s1 s2. (* Goal: forall (s1 s2 : string) (_ : lex_le s1 s2), lex_order s1 s2 *) intros s1 s2 H_le. (* Goal: lex_order s1 s2 *) case H_le; intro H_le'. - induction H_le'. * apply lex_order_char_lt. (* Goal: lt (nat_of_ascii c) (nat_of_ascii c') *) assumption. * apply lex_order_char_eq. (* Goal: lex_order s1 s2 *) apply IHH_le'. (* Goal: lex_le s1 s2 *) left. (* Goal: lt (nat_of_ascii c) (nat_of_ascii c') *) assumption. * apply lex_order_empty_string. - rewrite <- H_le'. (* Goal: lex_order s1 s1 *) apply lex_order_refl. Qed. Theorem lex_lt_trans : forall s0 s1 s2, lex_lt s0 s1 -> lex_lt s1 s2 -> lex_lt s0 s2. Proof. (* Goal: forall (s0 s1 : string) (_ : lex_lt s0 s1), not (@eq string s0 s1) *) induction s0. - intros. (* Goal: not (@eq string (String a s0) s1) *) inversion H; subst. (* Goal: lex_lt EmptyString s2 *) inversion H0; subst. * apply lex_lt_empty. * apply lex_lt_empty. - intros. (* Goal: lex_lt EmptyString s2 *) inversion H; subst; inversion H0; subst. (* Goal: lex_lt (String c' s'1) (String c s'0) *) * apply lex_lt_lt. (* Goal: lt (nat_of_ascii a) (nat_of_ascii c0) *) eauto with arith. (* Goal: lex_lt (String c' s'1) (String c s'0) *) * apply lex_lt_lt. (* Goal: lt (nat_of_ascii c) (nat_of_ascii c') *) assumption. (* Goal: lex_lt (String c' s'1) (String c s'0) *) * apply lex_lt_lt. (* Goal: lt (nat_of_ascii c) (nat_of_ascii c') *) assumption. * apply lex_lt_eq. (* Goal: lex_lt s0 s3 *) eapply IHs0; eauto. Qed. Theorem lex_lt_not_eq : forall s0 s1, lex_lt s0 s1 -> s0 <> s1. Proof. (* Goal: forall (s0 s1 : string) (_ : lex_lt s0 s1), not (@eq string s0 s1) *) induction s0. - intros. (* Goal: not (@eq string (String a s0) s1) *) inversion H; subst. (* Goal: not (@eq string EmptyString (String c s)) *) congruence. - intros. (* Goal: not (@eq string (String a s0) s1) *) inversion H; subst. * intro H_eq. (* Goal: False *) find_injection. (* Goal: False *) contradict H3. (* Goal: lt (nat_of_ascii c') (nat_of_ascii c) *) auto with arith. * intro H_eq. (* Goal: False *) find_injection. (* Goal: False *) specialize (IHs0 s3). (* Goal: False *) concludes. (* Goal: False *) auto. Qed. Lemma nat_of_ascii_injective: forall c1 c2, nat_of_ascii c1 = nat_of_ascii c2 -> c1 = c2. Proof. (* Goal: forall (c1 c2 : ascii) (_ : @eq nat (nat_of_ascii c1) (nat_of_ascii c2)), @eq ascii c1 c2 *) intros; simpl. assert (ascii_of_nat (nat_of_ascii c1) = ascii_of_nat (nat_of_ascii c2)) (* Goal: False *) as Hinvol. auto. (* Goal: @eq ascii c1 c2 *) repeat rewrite ascii_nat_embedding in Hinvol. (* Goal: @eq ascii c1 c2 *) trivial. Qed. Fixpoint string_compare_lex_compat (s0 s1 : string) : Compare lex_lt eq s0 s1. refine (match s0 as ss0, s1 as ss1 return (_ = ss0 -> _ = ss1 -> _) with | EmptyString, EmptyString => fun H_eq H_eq' => EQ _ | EmptyString, String c' s'1 => fun H_eq H_eq' => LT _ | String c s'0, EmptyString => fun H_eq H_eq' => GT _ | String c s'0, String c' s'1 => fun H_eq H_eq' => match Nat.compare (nat_of_ascii c) (nat_of_ascii c') as cmp return (_ = cmp -> _) with | Lt => fun H_eq_cmp => LT _ | Eq => fun H_eq_cmp => match string_compare_lex_compat s'0 s'1 with | LT H_lt => LT _ | EQ H_eq_lex => EQ _ | GT H_gt => GT _ end | Gt => fun H_eq_cmp => GT _ end (refl_equal _) (* Goal: False *) end (refl_equal _) (refl_equal _)); try (rewrite H_eq; rewrite H_eq'); auto. - apply lex_lt_empty. - apply lex_lt_empty. - apply nat_compare_eq in H_eq_cmp. (* Goal: lex_lt (String c' s'1) (String c s'0) *) apply nat_of_ascii_injective in H_eq_cmp. (* Goal: lex_lt (String c' s'1) (String c s'0) *) rewrite H_eq_cmp. (* Goal: lex_lt (String c' s'1) (String c' s'0) *) apply lex_lt_eq. (* Goal: lt (nat_of_ascii c) (nat_of_ascii c') *) assumption. - apply nat_compare_eq in H_eq_cmp. (* Goal: lex_lt (String c' s'1) (String c s'0) *) apply nat_of_ascii_injective in H_eq_cmp. (* Goal: @CompSpec string (@eq string) lex_lt (String c s'0) (String c' s'1) Gt *) subst. (* Goal: @eq string (String c' s'1) (String c' s'1) *) reflexivity. - apply nat_compare_eq in H_eq_cmp. (* Goal: lex_lt (String c' s'1) (String c s'0) *) apply nat_of_ascii_injective in H_eq_cmp. (* Goal: lex_lt (String c' s'1) (String c s'0) *) rewrite H_eq_cmp. (* Goal: lex_lt (String c' s'1) (String c' s'0) *) apply lex_lt_eq. (* Goal: lt (nat_of_ascii c) (nat_of_ascii c') *) assumption. - apply nat_compare_lt in H_eq_cmp. (* Goal: lex_lt (String c' s'1) (String c s'0) *) apply lex_lt_lt. (* Goal: lt (nat_of_ascii c) (nat_of_ascii c') *) assumption. - apply nat_compare_gt in H_eq_cmp. (* Goal: lex_lt (String c' s'1) (String c s'0) *) apply lex_lt_lt. (* Goal: lt (nat_of_ascii c') (nat_of_ascii c) *) auto with arith. Defined. Module string_lex_as_OT_compat <: UsualOrderedType. Definition t := string. Definition eq := @eq string. Definition lt := lex_lt. Definition eq_refl := @eq_refl string. Definition eq_sym := @eq_sym string. Definition eq_trans := @eq_trans string. Definition lt_trans := lex_lt_trans. Definition lt_not_eq := lex_lt_not_eq. Definition compare := string_compare_lex_compat. Definition eq_dec := string_dec. End string_lex_as_OT_compat. Require Import Orders. Lemma lex_lt_irrefl : Irreflexive lex_lt. Proof. (* Goal: @Irreflexive string lex_lt *) intros s0 H_lt. (* Goal: False *) apply lex_lt_not_eq in H_lt. (* Goal: False *) auto. Qed. Theorem lex_lt_strorder : StrictOrder lex_lt. Proof. (* Goal: @StrictOrder string lex_lt *) exact (Build_StrictOrder _ lex_lt_irrefl lex_lt_trans). Qed. Theorem lex_lt_lt_compat : Proper (eq ==> eq ==> iff) lex_lt. Proof. (* Goal: @Proper (forall (_ : string) (_ : string), Prop) (@respectful string (forall _ : string, Prop) (@eq string) (@respectful string Prop (@eq string) iff)) lex_lt *) intros s0 s1 H_eq s2 s3 H_eq'. (* Goal: False *) split; intro H_imp; subst; auto. Qed. Fixpoint string_compare_lex (s0 s1 : string) : { cmp : comparison | CompSpec eq lex_lt s0 s1 cmp }. refine (match s0 as ss0, s1 as ss1 return (_ = ss0 -> _ = ss1 -> _) with | EmptyString, EmptyString => fun H_eq H_eq' => exist _ Eq _ | EmptyString, String c' s'1 => fun H_eq H_eq' => exist _ Lt _ | String c s'0, EmptyString => fun H_eq H_eq' => exist _ Gt _ | String c s'0, String c' s'1 => fun H_eq H_eq' => match Nat.compare (nat_of_ascii c) (nat_of_ascii c') as cmp0 return (_ = cmp0 -> _) with | Lt => fun H_eq_cmp0 => exist _ Lt _ | Eq => fun H_eq_cmp0 => match string_compare_lex s'0 s'1 with | exist _ cmp H_cmp' => match cmp as cmp1 return (cmp = cmp1 -> _) with | Lt => fun H_eq_cmp1 => exist _ Lt _ | Eq => fun H_eq_cmp1 => exist _ Eq _ | Gt => fun H_eq_cmp1 => exist _ Gt _ end (refl_equal _) end | Gt => fun H_eq_cmp0 => exist _ Gt _ end (refl_equal _) end (refl_equal _) (refl_equal _)); try (rewrite H_eq; rewrite H_eq'). - apply CompEq; auto. - apply CompLt. (* Goal: lex_lt EmptyString (String c s'0) *) apply lex_lt_empty. - apply CompGt. (* Goal: lex_lt EmptyString (String c s'0) *) apply lex_lt_empty. - apply nat_compare_eq in H_eq_cmp0. (* Goal: @CompSpec string (@eq string) lex_lt (String c s'0) (String c' s'1) Gt *) apply nat_of_ascii_injective in H_eq_cmp0. (* Goal: @CompSpec string (@eq string) lex_lt (String c s'0) (String c' s'1) Gt *) rewrite H_eq_cmp1 in H_cmp'. (* Goal: @CompSpec string (@eq string) lex_lt (String c s'0) (String c' s'1) Gt *) inversion H_cmp'; subst. (* Goal: @CompSpec string (@eq string) lex_lt (String c' s'1) (String c' s'1) Eq *) apply CompEq. (* Goal: @eq string (String c' s'1) (String c' s'1) *) reflexivity. - apply nat_compare_eq in H_eq_cmp0. (* Goal: @CompSpec string (@eq string) lex_lt (String c s'0) (String c' s'1) Gt *) apply nat_of_ascii_injective in H_eq_cmp0. (* Goal: @CompSpec string (@eq string) lex_lt (String c s'0) (String c' s'1) Gt *) rewrite H_eq_cmp1 in H_cmp'. (* Goal: @CompSpec string (@eq string) lex_lt (String c' s'0) (String c' s'1) Gt *) inversion H_cmp'. (* Goal: @CompSpec string (@eq string) lex_lt (String c s'0) (String c' s'1) Gt *) subst. (* Goal: @CompSpec string (@eq string) lex_lt (String c s'0) (String c' s'1) Lt *) apply CompLt. (* Goal: lex_lt (String c' s'1) (String c' s'0) *) apply lex_lt_eq. (* Goal: lt (nat_of_ascii c) (nat_of_ascii c') *) assumption. - apply nat_compare_eq in H_eq_cmp0. (* Goal: @CompSpec string (@eq string) lex_lt (String c s'0) (String c' s'1) Gt *) apply nat_of_ascii_injective in H_eq_cmp0. (* Goal: @CompSpec string (@eq string) lex_lt (String c s'0) (String c' s'1) Gt *) rewrite H_eq_cmp1 in H_cmp'. (* Goal: @CompSpec string (@eq string) lex_lt (String c s'0) (String c' s'1) Gt *) subst. (* Goal: @CompSpec string (@eq string) lex_lt (String c' s'0) (String c' s'1) Gt *) inversion H_cmp'. (* Goal: @CompSpec string (@eq string) lex_lt (String c s'0) (String c' s'1) Gt *) apply CompGt. (* Goal: lex_lt (String c' s'1) (String c' s'0) *) apply lex_lt_eq. (* Goal: lt (nat_of_ascii c) (nat_of_ascii c') *) assumption. - apply nat_compare_lt in H_eq_cmp0. (* Goal: @CompSpec string (@eq string) lex_lt (String c s'0) (String c' s'1) Lt *) apply CompLt. (* Goal: lex_lt (String c' s'1) (String c s'0) *) apply lex_lt_lt. (* Goal: lt (nat_of_ascii c) (nat_of_ascii c') *) assumption. - apply nat_compare_gt in H_eq_cmp0. (* Goal: @CompSpec string (@eq string) lex_lt (String c s'0) (String c' s'1) Gt *) apply CompGt. (* Goal: lex_lt (String c' s'1) (String c s'0) *) apply lex_lt_lt. (* Goal: lt (nat_of_ascii c') (nat_of_ascii c) *) auto with arith. Defined. Module string_lex_as_OT <: UsualOrderedType. Definition t := string. Definition eq := @eq string. Definition eq_equiv := @eq_equivalence string. Definition lt := lex_lt. Definition lt_strorder := lex_lt_strorder. Definition lt_compat := lex_lt_lt_compat. Definition compare := fun x y => proj1_sig (string_compare_lex x y). Definition compare_spec := fun x y => proj2_sig (string_compare_lex x y). Definition eq_dec := string_dec. End string_lex_as_OT.
Require Import List. Import ListNotations. Require Import StructTact.StructTactics. Require Import StructTact.ListUtil. Require Import OrderedType. Require Import OrderedTypeEx. Set Implicit Arguments. Fixpoint fin (n : nat) : Type := match n with | 0 => False | S n' => option (fin n') end. Fixpoint fin_eq_dec (n : nat) : forall (a b : fin n), {a = b} + {a <> b}. refine (match n with | 0 => fun a b : fin 0 => right (match b with end) | S n' => fun a b : fin (S n') => match a, b with | Some a', Some b' => match fin_eq_dec n' a' b' with | left _ _ => left _ | right _ _ => right _ end | Some a', None => right _ | None, Some b' => right _ | None, None => left eq_refl end (* Goal: not (@eq (fin (S n)) (@Some (fin n) f) (@Some (fin n) f0)) *) end); congruence. Defined. Fixpoint all_fin (n : nat) : list (fin n) := match n with | 0 => [] | S n' => None :: map (fun x => Some x) (all_fin n') end. Lemma all_fin_all : forall n (x : fin n), In x (all_fin n). Proof. (* Goal: forall (n : nat) (x y : fin n) (_ : @fin_lt n x y), not (@eq (fin n) x y) *) induction n; intros. - solve_by_inversion. - simpl in *. destruct x; auto using in_map. Qed. Lemma all_fin_NoDup : forall n, NoDup (all_fin n). Proof. (* Goal: forall n : nat, @NoDup (fin n) (all_fin n) *) induction n; intros; simpl; constructor. - intro. apply in_map_iff in H. firstorder. discriminate. - apply NoDup_map_injective; auto. congruence. Qed. Fixpoint fin_to_nat {n : nat} : fin n -> nat := match n with | 0 => fun x : fin 0 => match x with end | S n' => fun x : fin (S n') => match x with | None => 0 | Some y => S (fin_to_nat y) end end. Definition fin_lt {n : nat} (a b : fin n) : Prop := lt (fin_to_nat a) (fin_to_nat b). Lemma fin_lt_Some_elim : forall n (a b : fin n), @fin_lt (S n) (Some a) (Some b) -> fin_lt a b. Proof. (* Goal: forall (n' : nat) (x' y' : fin n') (_ : @CompSpec (fin n') (@eq (fin n')) (@fin_lt n') x' y' Gt), @fin_lt n' y' x' *) intros. (* Goal: forall (n : nat) (x : fin n), @fin_lt (S n) (@None ((fix fin (n0 : nat) : Type := match n0 with | O => False | S n' => option (fin n') end) n)) (@Some (fin n) x) *) unfold fin_lt. simpl. (* Goal: forall (x : fin n) (_ : lt (@fin_to_nat n x) (@fin_to_nat n x)), False *) intuition. Qed. Lemma fin_lt_Some_intro : forall n (a b : fin n), fin_lt a b -> @fin_lt (S n) (Some a) (Some b). Proof. (* Goal: forall (n' : nat) (x' y' : fin n') (_ : @CompSpec (fin n') (@eq (fin n')) (@fin_lt n') x' y' Gt), @fin_lt n' y' x' *) intros. (* Goal: forall (n : nat) (x : fin n), @fin_lt (S n) (@None ((fix fin (n0 : nat) : Type := match n0 with | O => False | S n' => option (fin n') end) n)) (@Some (fin n) x) *) unfold fin_lt. simpl. (* Goal: forall (x : fin n) (_ : lt (@fin_to_nat n x) (@fin_to_nat n x)), False *) intuition. Qed. Lemma None_lt_Some : forall n (x : fin n), @fin_lt (S n) None (Some x). Proof. (* Goal: forall (n : nat) (x : fin n), @fin_lt (S n) (@None ((fix fin (n0 : nat) : Type := match n0 with | O => False | S n' => option (fin n') end) n)) (@Some (fin n) x) *) unfold fin_lt. simpl. auto with *. Qed. Lemma fin_lt_trans : forall n (x y z : fin n), fin_lt x y -> fin_lt y z -> fin_lt x z. Proof. (* Goal: forall (n : nat) (x y : fin n) (_ : @fin_lt n x y), not (@eq (fin n) x y) *) induction n; intros. - destruct x. - destruct x, y, z; simpl in *; repeat match goal with | [ H : fin_lt (Some _) (Some _) |- _ ] => apply fin_lt_Some_elim in H | [ |- fin_lt (Some _) (Some _) ] => apply fin_lt_Some_intro (* Goal: @fin_lt n' y' x' *) end; eauto using None_lt_Some; solve_by_inversion. Qed. Lemma fin_lt_not_eq : forall n (x y : fin n), fin_lt x y -> x <> y. Proof. (* Goal: forall (n : nat) (x y : fin n) (_ : @fin_lt n x y), not (@eq (fin n) x y) *) induction n; intros. - destruct x. - destruct x, y; repeat match goal with | [ H : fin_lt (Some _) (Some _) |- _ ] => apply fin_lt_Some_elim in H | [ |- fin_lt (Some _) (Some _) ] => apply fin_lt_Some_intro (* Goal: not (@eq (fin (S n)) (@Some (fin n) f) (@Some (fin n) f0)) *) end; try congruence. (* Goal: not (@eq (fin (S n)) (@Some (fin n) f) (@Some (fin n) f0)) *) + specialize (IHn f f0). concludes. congruence. (* Goal: @fin_lt n' y' x' *) + solve_by_inversion. Qed. Fixpoint fin_compare_compat (n : nat) : forall (x y : fin n), Compare fin_lt eq x y := match n with | 0 => fun x y : fin 0 => match x with end | S n' => fun x y : fin (S n') => match x, y with | Some x', Some y' => match fin_compare_compat n' x' y' with | LT pf => LT (fin_lt_Some_intro pf) | EQ pf => EQ (f_equal _ pf) | GT pf => GT (fin_lt_Some_intro pf) end | Some x', None => GT (None_lt_Some n' x') | None, Some y' => LT (None_lt_Some n' y') | None, None => EQ eq_refl end end. Module Type NatValue. Parameter n : nat. End NatValue. Module fin_OT_compat (Import N : NatValue) <: UsualOrderedType. Definition t := fin n. Definition eq := @eq (fin n). Definition lt := @fin_lt n. Definition eq_refl := @eq_refl (fin n). Definition eq_sym := @eq_sym (fin n). Definition eq_trans := @eq_trans (fin n). Definition lt_trans := @fin_lt_trans n. Definition lt_not_eq := @fin_lt_not_eq n. Definition compare := fin_compare_compat n. Definition eq_dec := fin_eq_dec n. End fin_OT_compat. Require Import Orders. Lemma fin_lt_irrefl : forall n, Irreflexive (@fin_lt n). Proof. (* Goal: forall (n' : nat) (x' y' : fin n') (_ : @CompSpec (fin n') (@eq (fin n')) (@fin_lt n') x' y' Gt), @fin_lt n' y' x' *) intros. (* Goal: @Irreflexive (fin n) (@fin_lt n) *) unfold Irreflexive, complement, Reflexive, fin_lt. (* Goal: forall (x : fin n) (_ : lt (@fin_to_nat n x) (@fin_to_nat n x)), False *) intuition. Qed. Lemma fin_lt_strorder : forall n, StrictOrder (@fin_lt n). Proof. (* Goal: forall (n' : nat) (x' y' : fin n') (_ : @CompSpec (fin n') (@eq (fin n')) (@fin_lt n') x' y' Gt), @fin_lt n' y' x' *) intros. (* Goal: @StrictOrder (fin n) (@fin_lt n) *) apply (Build_StrictOrder _ (@fin_lt_irrefl n) (@fin_lt_trans n)). Qed. Lemma fin_lt_lt_compat : forall n, Proper (eq ==> eq ==> iff) (@fin_lt n). Proof. (* Goal: forall n : nat, @Proper (forall (_ : fin n) (_ : fin n), Prop) (@respectful (fin n) (forall _ : fin n, Prop) (@eq (fin n)) (@respectful (fin n) Prop (@eq (fin n)) iff)) (@fin_lt n) *) intros; split; intros; repeat find_rewrite; assumption. Qed. Lemma CompSpec_Eq_Some : forall n' (x' y' : fin n'), CompSpec eq fin_lt x' y' Eq -> Some x' = Some y'. Proof. (* Goal: forall (n' : nat) (x' y' : fin n') (_ : @CompSpec (fin n') (@eq (fin n')) (@fin_lt n') x' y' Gt), @fin_lt n' y' x' *) intros. (* Goal: @eq (option (fin n')) (@Some (fin n') x') (@Some (fin n') y') *) apply f_equal. (* Goal: @fin_lt n' y' x' *) solve_by_inversion. Qed. Lemma CompSpec_Lt : forall n' (x' y' : fin n'), CompSpec eq fin_lt x' y' Lt -> fin_lt x' y'. Proof. (* Goal: forall (n' : nat) (x' y' : fin n') (_ : @CompSpec (fin n') (@eq (fin n')) (@fin_lt n') x' y' Gt), @fin_lt n' y' x' *) intros. (* Goal: @fin_lt n' y' x' *) solve_by_inversion. Qed. Lemma CompSpec_Gt : forall n' (x' y' : fin n'), CompSpec eq fin_lt x' y' Gt -> fin_lt y' x'. Proof. (* Goal: forall (n' : nat) (x' y' : fin n') (_ : @CompSpec (fin n') (@eq (fin n')) (@fin_lt n') x' y' Gt), @fin_lt n' y' x' *) intros. (* Goal: @fin_lt n' y' x' *) solve_by_inversion. Qed. Fixpoint fin_compare (n : nat) : forall (x y : fin n), { cmp : comparison | CompSpec eq fin_lt x y cmp } := match n with | 0 => fun x y : fin 0 => match x with end | S n' => fun x y : fin (S n') => match x, y with | Some x', Some y' => match fin_compare n' x' y' with | exist _ Lt Hc => exist _ Lt (CompLt _ _ (fin_lt_Some_intro (CompSpec_Lt Hc))) | exist _ Eq Hc => exist _ Eq (CompEq _ _ (CompSpec_Eq_Some Hc)) | exist _ Gt Hc => exist _ Gt (CompGt _ _ (fin_lt_Some_intro (CompSpec_Gt Hc))) end | Some x', None => exist _ Gt (CompGt _ _ (None_lt_Some n' x')) | None, Some y' => exist _ Lt (CompLt _ _ (None_lt_Some n' y')) | None, None => exist _ Eq (CompEq _ _ eq_refl) end end. Module fin_OT (Import N : NatValue) <: UsualOrderedType. Definition t := fin n. Definition eq := @eq (fin n). Definition eq_equiv := @eq_equivalence (fin n). Definition lt := @fin_lt n. Definition lt_strorder := fin_lt_strorder n. Definition lt_compat := fin_lt_lt_compat n. Definition compare := fun x y => proj1_sig (fin_compare n x y). Definition compare_spec := fun x y => proj2_sig (fin_compare n x y). Definition eq_dec := fin_eq_dec n. End fin_OT. Fixpoint fin_of_nat (m n : nat) : fin n + {exists p, m = n + p} := match n with | 0 => inright (ex_intro _ _ eq_refl) | S n' => match m with | 0 => inleft None | S m' => match fin_of_nat m' n' with | inleft f => inleft (Some f) | inright pf => inright (match pf with | ex_intro _ x H => ex_intro _ x (f_equal _ H) end) end end end. Lemma fin_of_nat_fin_to_nat : forall (n : nat) (a : fin n), fin_of_nat (fin_to_nat a) n = inleft a. Proof. (* Goal: forall (x : fin n) (_ : lt (@fin_to_nat n x) (@fin_to_nat n x)), False *) induction n; simpl; intuition. (* Goal: @eq (sumor (option (fin n)) (@ex nat (fun p : nat => @eq nat match a with | Some y => S (@fin_to_nat n y) | None => O end (S (Nat.add n p))))) (fin_of_nat match a with | Some y => S (@fin_to_nat n y) | None => O end (S n)) (@inleft (option (fin n)) (@ex nat (fun p : nat => @eq nat match a with | Some y => S (@fin_to_nat n y) | None => O end (S (Nat.add n p)))) a) *) destruct a; simpl in *; auto. (* Goal: @eq (sumor (option (fin n)) (@ex nat (fun p : nat => @eq nat (S (@fin_to_nat n f)) (S (Nat.add n p))))) match fin_of_nat (@fin_to_nat n f) n with | inleft f0 => @inleft (option (fin n)) (@ex nat (fun p : nat => @eq nat (S (@fin_to_nat n f)) (S (Nat.add n p)))) (@Some (fin n) f0) | inright pf => @inright (option (fin n)) (@ex nat (fun p : nat => @eq nat (S (@fin_to_nat n f)) (S (Nat.add n p)))) match pf with | ex_intro _ x H => @ex_intro nat (fun p : nat => @eq nat (S (@fin_to_nat n f)) (S (Nat.add n p))) x (@f_equal nat nat S (@fin_to_nat n f) (Nat.add n x) H) end end (@inleft (option (fin n)) (@ex nat (fun p : nat => @eq nat (S (@fin_to_nat n f)) (S (Nat.add n p)))) (@Some (fin n) f)) *) now rewrite IHn. Qed.
Require Import Arith. Require Import Omega. Require Import List. Import ListNotations. Require Import Sorting.Permutation. Require Import StructTact.StructTactics. Require Import StructTact.ListTactics. Set Implicit Arguments. Notation member := (in_dec eq_nat_dec). Lemma seq_range : forall n a x, In x (seq a n) -> a <= x < a + n. Proof. (* Goal: forall (n a x : nat) (_ : @In nat x (seq a n)), and (le a x) (lt x (Init.Nat.add a n)) *) induction n; intros; simpl in *. - intuition. - break_or_hyp; try find_apply_hyp_hyp; intuition. Qed. Lemma plus_gt_0 : forall a b, a + b > 0 -> a > 0 \/ b > 0. Proof. (* Goal: forall (l : list A) (x : A) (_ : @eq (option A) (@hd_error A l) (@Some A x)), @ex (list A) (fun tl : list A => @eq (list A) l (@cons A x tl)) *) intros. (* Goal: @eq C (g (@fold_left A B f l' (f a b')) b) (g a b) *) destruct (eq_nat_dec a 0); intuition. Qed. Section list_util. Variables A B C : Type. Hypothesis A_eq_dec : forall x y : A, {x = y} + {x <> y}. Lemma list_neq_cons : forall (l : list A) x, x :: l <> l. Proof using. (* Goal: @eq C (g (@fold_left A B f l' (f a b')) b) (g a b) *) intuition. (* Goal: @ex (list A) (fun l1 : list A => @ex (list A) (fun l2 : list A => and (@eq (list A) (@nil A) (@app A l1 l2)) (and (@eq (list B) (@map A B f l1) xs) (@eq (list B) (@map A B f l2) ys)))) *) symmetry in H. induction l; now inversion H. Qed. Lemma remove_preserve : forall (x y : A) xs, x <> y -> In y xs -> In y (remove A_eq_dec x xs). Proof using. (* Goal: forall (l : list A) (x : A) (_ : @eq (option A) (@hd_error A l) (@Some A x)), @ex (list A) (fun tl : list A => @eq (list A) l (@cons A x tl)) *) induction xs; intros. - intuition. - simpl in *. (* Goal: not (or (@eq A a0 a) (@In A a l)) *) concludes. (* Goal: @eq C (g (@fold_left A B f l' (f a b')) b) (g a b) *) intuition; break_if; subst; try congruence; intuition. Qed. Lemma in_remove : forall (x y : A) xs, In y (remove A_eq_dec x xs) -> In y xs. Proof using. (* Goal: forall (l : list A) (x : A) (_ : @eq (option A) (@hd_error A l) (@Some A x)), @ex (list A) (fun tl : list A => @eq (list A) l (@cons A x tl)) *) induction xs; intros. - auto. - simpl in *. break_if; simpl in *; intuition. Qed. Lemma remove_partition : forall xs (p : A) ys, remove A_eq_dec p (xs ++ p :: ys) = remove A_eq_dec p (xs ++ ys). Proof using. (* Goal: forall (xs : list A) (p : A) (ys : list A), @eq (list A) (@remove A A_eq_dec p (@app A xs (@cons A p ys))) (@remove A A_eq_dec p (@app A xs ys)) *) induction xs; intros; simpl; break_if; congruence. Qed. Lemma remove_not_in : forall (x : A) xs, ~ In x xs -> remove A_eq_dec x xs = xs. Proof using. (* Goal: forall (l : list A) (x : A) (_ : @eq (option A) (@hd_error A l) (@Some A x)), @ex (list A) (fun tl : list A => @eq (list A) l (@cons A x tl)) *) intros. induction xs; simpl in *; try break_if; intuition congruence. Qed. Lemma remove_app_comm : forall a xs ys, remove A_eq_dec a (xs ++ ys) = remove A_eq_dec a xs ++ remove A_eq_dec a ys. Proof. (* Goal: forall (l : list A) (x : A) (_ : @eq (option A) (@hd_error A l) (@Some A x)), @ex (list A) (fun tl : list A => @eq (list A) l (@cons A x tl)) *) intros. (* Goal: @eq (list A) (@remove A A_eq_dec a (@app A xs ys)) (@app A (@remove A A_eq_dec a xs) (@remove A A_eq_dec a ys)) *) generalize dependent ys. (* Goal: forall (l : list A) (x : A) (_ : @eq (option A) (@hd_error A l) (@Some A x)), @ex (list A) (fun tl : list A => @eq (list A) l (@cons A x tl)) *) induction xs; intros. - tauto. - destruct (A_eq_dec a0 a); simpl; break_if; try rewrite <- app_comm_cons; rewrite IHxs; (* Goal: @ex (list A) (fun tl : list A => @eq (list A) (@nil A) (@cons A x tl)) *) congruence. Qed. Lemma filter_app : forall (f : A -> bool) xs ys, filter f (xs ++ ys) = filter f xs ++ filter f ys. Proof using. (* Goal: forall (l : list A) (x : A) (_ : @eq (option A) (@hd_error A l) (@Some A x)), @ex (list A) (fun tl : list A => @eq (list A) l (@cons A x tl)) *) induction xs; intros. - auto. - simpl. rewrite IHxs. break_if; auto. Qed. Lemma filter_fun_ext_eq : forall f g xs, (forall a : A, In a xs -> f a = g a) -> filter f xs = filter g xs. Proof using. (* Goal: forall (l : list A) (x : A) (_ : @eq (option A) (@hd_error A l) (@Some A x)), @ex (list A) (fun tl : list A => @eq (list A) l (@cons A x tl)) *) induction xs; intros. - auto. - simpl. rewrite H by intuition. rewrite IHxs by intuition. auto. Qed. Lemma not_in_filter_false : forall (f : A -> bool) l x, In x l -> ~ In x (filter f l) -> f x = false. Proof. (* Goal: forall (l : list A) (x : A) (_ : @eq (option A) (@hd_error A l) (@Some A x)), @ex (list A) (fun tl : list A => @eq (list A) l (@cons A x tl)) *) intros. (* Goal: @eq bool (f x) false *) destruct (f x) eqn:?H; [|tauto]. (* Goal: @eq bool true false *) unfold not in *; find_false. (* Goal: @In A x (@filter A f l) *) now eapply filter_In. Qed. Lemma filter_length_bound : forall f (l : list A), length (filter f l) <= length l. Proof. (* Goal: forall (g : forall _ : B, A) (x : A) (acc : list A) (_ : @In A x (@fold_left (list A) B (fun (a : list A) (b : B) => @cons A (g b) a) l acc)), or (@In A x acc) (@ex B (fun y : B => and (@In B y l) (@eq A x (g y)))) *) induction l. - easy. - simpl. (* Goal: le (@length A (if f a then @cons A a (@filter A f l) else @filter A f l)) (S (@length A l)) *) break_if; simpl; omega. Qed. Lemma NoDup_map_injective : forall (f : A -> B) xs, (forall x y, In x xs -> In y xs -> f x = f y -> x = y) -> NoDup xs -> NoDup (map f xs). Proof using. (* Goal: forall (l : list A) (x : A) (_ : @eq (option A) (@hd_error A l) (@Some A x)), @ex (list A) (fun tl : list A => @eq (list A) l (@cons A x tl)) *) induction xs; intros. - constructor. - simpl. invc_NoDup. constructor. + intro. do_in_map. (* Goal: @eq C (g (@fold_left A B f l' (f a b')) b) (g a b) *) assert (x = a) by intuition. (* Goal: @ex (list A) (fun tl : list A => @eq (list A) (@nil A) (@cons A x tl)) *) congruence. (* Goal: @eq C (g (@fold_left A B f l' (f a b')) b) (g a b) *) + intuition. Qed. Lemma NoDup_disjoint_append : forall (l : list A) l', NoDup l -> NoDup l' -> (forall a, In a l -> ~ In a l') -> NoDup (l ++ l'). Proof using. (* Goal: forall (l : list A) (x : A) (_ : @eq (option A) (@hd_error A l) (@Some A x)), @ex (list A) (fun tl : list A => @eq (list A) l (@cons A x tl)) *) induction l; intros. - auto. - simpl. invc_NoDup. constructor. + intro. do_in_app. intuition eauto with *. + intuition eauto with *. Qed. Lemma NoDup_map_partition : forall (f : A -> B) xs l y zs xs' y' zs', NoDup (map f l) -> l = xs ++ y :: zs -> l = xs' ++ y' :: zs' -> f y = f y' -> xs = xs'. Proof using. (* Goal: forall (f : forall _ : A, B) (xs l : list A) (y : A) (zs xs' : list A) (y' : A) (zs' : list A) (_ : @NoDup B (@map A B f l)) (_ : @eq (list A) l (@app A xs (@cons A y zs))) (_ : @eq (list A) l (@app A xs' (@cons A y' zs'))) (_ : @eq B (f y) (f y')), @eq (list A) xs xs' *) induction xs; simpl; intros; destruct xs'. - auto. - subst. simpl in *. find_inversion. (* Goal: @eq (prod A B) (@pair A B a b) (@pair A B (@fst A B (@pair A B a b)) m) *) invc H. exfalso. rewrite map_app in *. simpl in *. (* Goal: @eq C (g (@fold_left A B f l' (f a b')) b) (g a b) *) repeat find_rewrite. intuition. - subst. simpl in *. find_inversion. (* Goal: @eq (prod A B) (@pair A B a b) (@pair A B (@fst A B (@pair A B a b)) m) *) invc H. exfalso. rewrite map_app in *. simpl in *. (* Goal: @eq C (g (@fold_left A B f l' (f a b')) b) (g a b) *) repeat find_rewrite. intuition. - subst. simpl in *. find_injection. intros. subst. (* Goal: forall (g : forall _ : B, A) (x : A) (acc : list A) (_ : @In A x (@fold_left (list A) B (fun (a : list A) (b : B) => @cons A (g b) a) (@nil B) acc)), or (@In A x acc) (@ex B (fun y : B => and (@In B y (@nil B)) (@eq A x (g y)))) *) f_equal. eapply IHxs; eauto. solve_by_inversion. Qed. Lemma filter_NoDup : forall p (l : list A), NoDup l -> NoDup (filter p l). Proof using. (* Goal: forall (l : list A) (x : A) (_ : @eq (option A) (@hd_error A l) (@Some A x)), @ex (list A) (fun tl : list A => @eq (list A) l (@cons A x tl)) *) induction l; intros. - auto. - invc_NoDup. simpl. break_if; auto. (* Goal: forall (g : forall _ : B, A) (x : A) (acc : list A) (_ : @In A x (@fold_left (list A) B (fun (a : list A) (b : B) => @cons A (g b) a) (@nil B) acc)), or (@In A x acc) (@ex B (fun y : B => and (@In B y (@nil B)) (@eq A x (g y)))) *) constructor; auto. (* Goal: @eq C (g (@fold_left A B f l' (f a b')) b) (g a b) *) intro. apply filter_In in H. intuition. Qed. Lemma NoDup_map_filter : forall (f : A -> B) g l, NoDup (map f l) -> NoDup (map f (filter g l)). Proof using. (* Goal: forall (l : list A) (x : A) (_ : @eq (option A) (@hd_error A l) (@Some A x)), @ex (list A) (fun tl : list A => @eq (list A) l (@cons A x tl)) *) intros. induction l; simpl in *. - constructor. - invc_NoDup. concludes. (* Goal: forall (g : forall _ : B, A) (x : A) (acc : list A) (_ : @In A x (@fold_left (list A) B (fun (a : list A) (b : B) => @cons A (g b) a) (@nil B) acc)), or (@In A x acc) (@ex B (fun y : B => and (@In B y (@nil B)) (@eq A x (g y)))) *) break_if; simpl in *; auto. (* Goal: forall (g : forall _ : B, A) (x : A) (acc : list A) (_ : @In A x (@fold_left (list A) B (fun (a : list A) (b : B) => @cons A (g b) a) (@nil B) acc)), or (@In A x acc) (@ex B (fun y : B => and (@In B y (@nil B)) (@eq A x (g y)))) *) constructor; auto. (* Goal: not (or (@eq A (@fst A B a) n) (@In A n (@map (prod A B) A (@fst A B) l))) *) intro. do_in_map. (* Goal: @eq C (g (@fold_left A B f l' (f a b')) b) (g a b) *) find_apply_lem_hyp filter_In. intuition. match goal with | H : _ -> False |- False => apply H end. (* Goal: forall (g : forall _ : B, A) (x : A) (acc : list A) (_ : @In A x (@fold_left (list A) B (fun (a : list A) (b : B) => @cons A (g b) a) (@nil B) acc)), or (@In A x acc) (@ex B (fun y : B => and (@In B y (@nil B)) (@eq A x (g y)))) *) apply in_map_iff. eauto. Qed. Lemma filter_true_id : forall (f : A -> bool) xs, (forall x, In x xs -> f x = true) -> filter f xs = xs. Proof using. (* Goal: forall (l : list A) (x : A) (_ : @eq (option A) (@hd_error A l) (@Some A x)), @ex (list A) (fun tl : list A => @eq (list A) l (@cons A x tl)) *) induction xs; intros. - auto. - simpl. now rewrite H, IHxs by intuition. Qed. Lemma map_of_map : forall (f : A -> B) (g : B -> C) xs, map g (map f xs) = map (fun x => g (f x)) xs. Proof using. (* Goal: forall (f : forall _ : A, B) (g : forall _ : B, C) (xs : list A), @eq (list C) (@map B C g (@map A B f xs)) (@map A C (fun x : A => g (f x)) xs) *) induction xs; simpl; auto using f_equal2. Qed. Lemma filter_except_one : forall (f g : A -> bool) x xs, (forall y, In y xs -> x <> y -> f y = g y) -> g x = false -> filter f (remove A_eq_dec x xs) = filter g xs. Proof using. (* Goal: forall (l : list A) (x : A) (_ : @eq (option A) (@hd_error A l) (@Some A x)), @ex (list A) (fun tl : list A => @eq (list A) l (@cons A x tl)) *) induction xs; intros. - auto. - simpl. (* Goal: ge (@length A (if A_eq_dec x a then @remove A A_eq_dec x xs else @cons A a (@remove A A_eq_dec x xs))) (Init.Nat.sub (@length A xs) O) *) break_if. + subst. repeat find_rewrite. eauto with *. (* Goal: @Permutation A (@cons A (@fst A B a) (@map (prod A B) A (@fst A B) l)) (@app A (@map (prod A B) A (@fst A B) x) (@map (prod A B) A (@fst A B) (@cons (prod A B) a x0))) *) + simpl. rewrite H by auto with *. (* Goal: @eq (list A) (if g a then @cons A a (@filter A f (@remove A A_eq_dec x xs)) else @filter A f (@remove A A_eq_dec x xs)) (if g a then @cons A a (@filter A g xs) else @filter A g xs) *) break_if; eauto using f_equal2 with *. Qed. Lemma flat_map_nil : forall (f : A -> list B) l, flat_map f l = [] -> l = [] \/ (forall x, In x l -> f x = []). Proof using. (* Goal: forall (l : list A) (x : A) (_ : @eq (option A) (@hd_error A l) (@Some A x)), @ex (list A) (fun tl : list A => @eq (list A) l (@cons A x tl)) *) induction l; intros. - intuition. - right. simpl in *. (* Goal: @ex (list A) (fun l1 : list A => @ex (list A) (fun l2 : list A => and (@eq (list A) (@nil A) (@app A l1 l2)) (and (@eq (list B) (@map A B f l1) xs) (@eq (list B) (@map A B f l2) ys)))) *) apply app_eq_nil in H. (* Goal: @eq C (g (@fold_left A B f l' (f a b')) b) (g a b) *) intuition; subst; simpl in *; intuition. Qed. Theorem NoDup_Permutation_NoDup : forall (l l' : list A), NoDup l -> Permutation l l' -> NoDup l'. Proof using. (* Goal: forall (l l' : list A) (_ : @NoDup A l) (_ : @Permutation A l l'), @NoDup A l' *) intros l l' Hnd Hp. induction Hp; auto; invc_NoDup; constructor; eauto using Permutation_in, Permutation_sym; (* Goal: @eq C (g (@fold_left A B f l' (f a b')) b) (g a b) *) simpl in *; intuition. Qed. Theorem NoDup_append : forall l (a : A), NoDup (l ++ [a]) <-> NoDup (a :: l). Proof using. (* Goal: forall (l : list A) (a : A), iff (@NoDup A (@app A l (@cons A a (@nil A)))) (@NoDup A (@cons A a l)) *) intuition eauto using NoDup_Permutation_NoDup, Permutation_sym, Permutation_cons_append. Qed. Lemma NoDup_map_elim : forall (f : A -> B) xs x y, f x = f y -> NoDup (map f xs) -> In x xs -> In y xs -> x = y. Proof using. (* Goal: @eq (prod A B) (@pair A B a b) (@pair A B (@fst A B (@pair A B a b)) m) *) induction xs; intros; simpl in *. - intuition. - invc_NoDup. intuition; subst; auto; exfalso. + repeat find_rewrite. auto using in_map. + repeat find_reverse_rewrite. auto using in_map. Qed. Lemma remove_length_not_in : forall (x : A) xs, ~ In x xs -> length (remove A_eq_dec x xs) = length xs. Proof using. (* Goal: forall (l : list A) (x : A) (_ : @eq (option A) (@hd_error A l) (@Some A x)), @ex (list A) (fun tl : list A => @eq (list A) l (@cons A x tl)) *) induction xs; intros. - auto. - simpl in *. intuition. (* Goal: @eq C (g (@fold_left A B f l' (f a b')) b) (g a b) *) break_if; subst; simpl; intuition. Qed. Lemma remove_length_in : forall (x : A) xs, In x xs -> NoDup xs -> S (length (remove A_eq_dec x xs)) = length xs. Proof using. induction xs; intros; simpl in *; intuition; invc_NoDup; break_if; subst; intuition (simpl; try congruence). (* Goal: @eq nat (S (@length A (@remove A A_eq_dec x xs))) (S (@length A xs)) *) now rewrite remove_length_not_in. Qed. Lemma subset_size_eq : forall xs, NoDup xs -> forall ys, NoDup ys -> (forall x : A, In x xs -> In x ys) -> length xs = length ys -> (forall x, In x ys -> In x xs). Proof using. (* Goal: forall (l : list A) (x : A) (_ : @eq (option A) (@hd_error A l) (@Some A x)), @ex (list A) (fun tl : list A => @eq (list A) l (@cons A x tl)) *) induction xs; intros. - destruct ys; simpl in *; congruence. - invc_NoDup. concludes. (* Goal: False *) assert (In a ys) by eauto with *. (* Goal: @Permutation A (@cons A (@fst A B a) (@map (prod A B) A (@fst A B) l)) (@map (prod A B) A (@fst A B) l') *) find_apply_lem_hyp in_split. (* Goal: @ex (list A) (fun ap : list A => @ex A (fun a : A => @ex (list A) (fun ap' : list A => and (@eq (list A) l (@app A ap (@cons A a ap'))) (and (@eq (list B) (@map A B f ap) p) (and (@eq B (f a) x) (@eq (list B) (@map A B f ap') p')))))) *) break_exists_name l1. (* Goal: @ex (list A) (fun ap : list A => @ex A (fun a : A => @ex (list A) (fun ap' : list A => and (@eq (list A) l (@app A ap (@cons A a ap'))) (and (@eq (list B) (@map A B f ap) p) (and (@eq B (f a) x) (@eq (list B) (@map A B f ap') p')))))) *) break_exists_name l2. (* Goal: and (@eq (list A) (@cons A a l) (@app A (@cons A a l1) l2)) (and (@eq (list B) (@map A B f (@cons A a l1)) (@cons B (f a) xs)) (@eq (list B) (@map A B f l2) ys)) *) subst. specialize (IHxs (l1 ++ l2)). (* Goal: @In A x (@cons A a xs) *) conclude_using ltac:(eauto using NoDup_remove_1). (* Goal: ge (@length A ys) (@length A (@cons A a xs)) *) forward IHxs. (* Goal: forall (x : A) (_ : @In A x xs), @In A x (@app A l1 l2) *) (* Goal: @In A x (@cons A a xs) *) intros x' Hx'. assert (In x' (l1 ++ a :: l2)) by eauto with *. (* Goal: @eq C (g (@fold_left A B f l' (f a b')) b) (g a b) *) do_in_app. simpl in *. intuition. subst. congruence. (* Goal: not (or (@eq A a0 a) (@In A a l)) *) concludes. (* Goal: ge (@length A ys) (@length A (@cons A a xs)) *) forward IHxs. (* Goal: @eq (prod A B) (@pair A B a b) (@pair A B (@fst A B (@pair A B a b)) m) *) rewrite app_length in *. simpl in *. omega. (* Goal: not (or (@eq A a0 a) (@In A a l)) *) concludes. (* Goal: @eq C (g (@fold_left A B f l' (f a b')) b) (g a b) *) do_in_app. simpl in *. intuition. Qed. Lemma remove_NoDup : forall (x : A) xs, NoDup xs -> NoDup (remove A_eq_dec x xs). Proof using. (* Goal: forall (l : list A) (x : A) (_ : @eq (option A) (@hd_error A l) (@Some A x)), @ex (list A) (fun tl : list A => @eq (list A) l (@cons A x tl)) *) induction xs; intros. - auto with struct_util. - invc_NoDup. simpl. break_if; eauto 6 using in_remove with struct_util. Qed. Lemma remove_length_ge : forall (x : A) xs, NoDup xs -> length (remove A_eq_dec x xs) >= length xs - 1. Proof using. (* Goal: forall (l : list A) (x : A) (_ : @eq (option A) (@hd_error A l) (@Some A x)), @ex (list A) (fun tl : list A => @eq (list A) l (@cons A x tl)) *) induction xs; intros. - auto. - invc_NoDup. simpl. break_if. + rewrite <- minus_n_O. (* Goal: and (@eq (list A) (@cons A a l) (@app A (@cons A a l1) l2)) (and (@eq (list B) (@map A B f (@cons A a l1)) (@cons B (f a) xs)) (@eq (list B) (@map A B f l2) ys)) *) subst. (* Goal: forall (g : forall _ : B, A) (x : A) (acc : list A) (_ : @In A x (@fold_left (list A) B (fun (a : list A) (b : B) => @cons A (g b) a) (@nil B) acc)), or (@In A x acc) (@ex B (fun y : B => and (@In B y (@nil B)) (@eq A x (g y)))) *) rewrite remove_length_not_in; auto. (* Goal: not (or (@eq A a0 a) (@In A a l)) *) + simpl. concludes. omega. Qed. Lemma remove_length_le : forall (x : A) xs eq_dec, length xs >= length (remove eq_dec x xs). Proof using. (* Goal: forall (l : list A) (x : A) (_ : @eq (option A) (@hd_error A l) (@Some A x)), @ex (list A) (fun tl : list A => @eq (list A) l (@cons A x tl)) *) induction xs; intros. - auto. - simpl in *. (* Goal: ge (S (@length A xs)) (@length A (if eq_dec x a then @remove A eq_dec x xs else @cons A a (@remove A eq_dec x xs))) *) specialize (IHxs eq_dec). (* Goal: ge (@length A ys) (S (@length A xs)) *) break_if; subst; simpl; omega. Qed. Lemma remove_length_lt : forall (x : A) xs eq_dec, In x xs -> length xs > length (remove eq_dec x xs). Proof using. (* Goal: @eq C (g (@fold_left A B f l' (f a b')) b) (g a b) *) induction xs; intros; simpl in *; intuition. - subst. (* Goal: @ex (list A) (fun tl : list A => @eq (list A) (@nil A) (@cons A x tl)) *) break_if; try congruence. (* Goal: gt (S (@length A xs)) (@length A (@remove A eq_dec x xs)) *) pose proof remove_length_le x xs eq_dec. (* Goal: ge (@length A ys) (S (@length A xs)) *) omega. - specialize (IHxs ltac:(eauto) ltac:(eauto)). (* Goal: ge (@length A ys) (S (@length A xs)) *) break_if; subst; simpl; omega. Qed. Lemma subset_length : forall xs ys, NoDup xs -> (forall x : A, In x xs -> In x ys) -> length ys >= length xs. Proof using A_eq_dec. (* Goal: forall (l : list A) (x : A) (_ : @eq (option A) (@hd_error A l) (@Some A x)), @ex (list A) (fun tl : list A => @eq (list A) l (@cons A x tl)) *) induction xs; intros. - simpl. omega. - specialize (IHxs (remove A_eq_dec a ys)). (* Goal: @NoDup A (@cons A (@fst A B a) (@map (prod A B) A (@fst A B) nms)) *) invc_NoDup. (* Goal: not (or (@eq A a0 a) (@In A a l)) *) concludes. (* Goal: ge (@length A ys) (@length A (@cons A a xs)) *) forward IHxs. (* Goal: forall (l : list A) (x : A) (_ : @eq (option A) (@hd_error A l) (@Some A x)), @ex (list A) (fun tl : list A => @eq (list A) l (@cons A x tl)) *) intros. (* Goal: @In A x (@remove A A_eq_dec a ys) *) (* Goal: ge (@length A ys) (@length A (@cons A a xs)) *) apply remove_preserve; [congruence|intuition]. (* Goal: not (or (@eq A a0 a) (@In A a l)) *) concludes. (* Goal: ge (@length A ys) (@length A (@cons A a xs)) *) pose proof remove_length_lt a ys A_eq_dec. (* Goal: @eq C (g (@fold_left A B f l' (f a b')) b) (g a b) *) conclude_using intuition. (* Goal: @Permutation A (@cons A (@fst A B a) (@map (prod A B) A (@fst A B) l)) (@app A (@map (prod A B) A (@fst A B) x) (@map (prod A B) A (@fst A B) (@cons (prod A B) a x0))) *) simpl. omega. Qed. Lemma app_cons_singleton_inv : forall xs (y : A) zs w, xs ++ y :: zs = [w] -> xs = [] /\ y = w /\ zs = []. Proof using. (* Goal: forall (l : list A) (x : A) (_ : @eq (option A) (@hd_error A l) (@Some A x)), @ex (list A) (fun tl : list A => @eq (list A) l (@cons A x tl)) *) intros. (* Goal: and (@eq (list A) xs (@nil A)) (and (@eq A y w) (@eq (list A) zs (@nil A))) *) destruct xs. - solve_by_inversion. - destruct xs; solve_by_inversion. Qed. Lemma app_cons_in : forall (l : list A) xs a ys, l = xs ++ a :: ys -> In a l. Proof using. (* Goal: forall (l : list A) (x : A) (_ : @eq (option A) (@hd_error A l) (@Some A x)), @ex (list A) (fun tl : list A => @eq (list A) l (@cons A x tl)) *) intros. subst. auto with *. Qed. Hint Resolve app_cons_in : struct_util. Lemma app_cons_in_rest: forall (l : list A) xs a b ys, l = xs ++ a :: ys -> In b (xs ++ ys) -> In b l. Proof using. (* Goal: forall (l : list A) (x : A) (_ : @eq (option A) (@hd_error A l) (@Some A x)), @ex (list A) (fun tl : list A => @eq (list A) l (@cons A x tl)) *) intros. subst. in_crush. Qed. Hint Resolve app_cons_in_rest : struct_util. Lemma in_rest_app_cons: forall (l xs ys : list A) a b, l = xs ++ a :: ys -> In b l -> a <> b -> In b (xs ++ ys). Proof using. (* Goal: forall (l : list A) (x : A) (_ : @eq (option A) (@hd_error A l) (@Some A x)), @ex (list A) (fun tl : list A => @eq (list A) l (@cons A x tl)) *) intros. (* Goal: @In A b (@app A xs ys) *) subst_max. (* Goal: @In A b (@app A xs ys) *) do_in_app. (* Goal: False *) break_or_hyp. - auto with datatypes. - find_apply_lem_hyp in_inv. (* Goal: @ex (list A) (fun tl : list A => @eq (list A) (@nil A) (@cons A x tl)) *) break_or_hyp; auto using in_or_app || congruence. Qed. Hint Resolve in_rest_app_cons : struct_util. Lemma remove_filter_commute : forall (l : list A) A_eq_dec f x, remove A_eq_dec x (filter f l) = filter f (remove A_eq_dec x l). Proof using. (* Goal: forall (g : forall _ : B, A) (x : A) (acc : list A) (_ : @In A x (@fold_left (list A) B (fun (a : list A) (b : B) => @cons A (g b) a) (@nil B) acc)), or (@In A x acc) (@ex B (fun y : B => and (@In B y (@nil B)) (@eq A x (g y)))) *) induction l; intros; simpl in *; auto. (* Goal: @eq (list A) (@remove A A_eq_dec0 x (if f a then @cons A a (@filter A f l) else @filter A f l)) (@filter A f (if A_eq_dec0 x a then @remove A A_eq_dec0 x l else @cons A a (@remove A A_eq_dec0 x l))) *) repeat (break_if; subst; simpl in *; try congruence). Qed. Lemma In_filter_In : forall (f : A -> bool) x l l', filter f l = l' -> In x l' -> In x l. Proof using. (* Goal: forall (l : list A) (x : A) (_ : @eq (option A) (@hd_error A l) (@Some A x)), @ex (list A) (fun tl : list A => @eq (list A) l (@cons A x tl)) *) intros. subst. (* Goal: forall (g : forall _ : B, A) (x : A) (acc : list A) (_ : @In A x (@fold_left (list A) B (fun (a : list A) (b : B) => @cons A (g b) a) (@nil B) acc)), or (@In A x acc) (@ex B (fun y : B => and (@In B y (@nil B)) (@eq A x (g y)))) *) eapply filter_In; eauto. Qed. Lemma filter_partition : forall (l1 : list A) f l2 x l1' l2', NoDup (l1 ++ x :: l2) -> filter f (l1 ++ x :: l2) = (l1' ++ x :: l2') -> filter f l1 = l1' /\ filter f l2 = l2'. Proof using. (* Goal: @NoDup A (@cons A (@fst A B a) (@map (prod A B) A (@fst A B) nms)) *) induction l1; intros; simpl in *; break_if; simpl in *; invc_NoDup. - destruct l1'; simpl in *. + solve_by_inversion. + find_inversion. exfalso. eauto using In_filter_In with *. - exfalso. eauto using In_filter_In with *. - destruct l1'; simpl in *; break_and; find_inversion. + exfalso. eauto with *. + find_apply_hyp_hyp. intuition auto using f_equal2. - eauto. Qed. Lemma map_inverses : forall (la : list A) (lb : list B) (f : A -> B) g, (forall a, g (f a) = a) -> (forall b, f (g b) = b) -> lb = map f la -> la = map g lb. Proof using. (* Goal: @eq (prod A B) (@pair A B a b) (@pair A B (@fst A B (@pair A B a b)) m) *) destruct la; intros; simpl in *. - subst. reflexivity. - destruct lb; try congruence. (* Goal: @eq (prod A B) (@pair A B a b) (@pair A B (@fst A B (@pair A B a b)) m) *) simpl in *. find_inversion. (* Goal: @eq (list A) (@cons A a la) (@cons A (g (f a)) (@map B A g (@map A B f la))) *) find_higher_order_rewrite. (* Goal: @eq (list A) (@cons A a la) (@cons A a (@map B A g (@map A B f la))) *) f_equal. (* Goal: @eq (list A) la (@map B A g (@map A B f la)) *) rewrite map_map. (* Goal: @eq (list A) la (@map A A (fun x : A => g (f x)) la) *) erewrite map_ext; [symmetry; apply map_id|]. (* Goal: @eq (prod A B) (@pair A B a b) (@pair A B (@fst A B (@pair A B a b)) m) *) simpl in *. auto. Qed. Lemma In_notIn_implies_neq : forall x y l, In(A:=A) x l -> ~ In(A:=A) y l -> x <> y. Proof using. (* Goal: @ex (list A) (fun tl : list A => @eq (list A) (@nil A) (@cons A x tl)) *) intuition congruence. Qed. Lemma In_cons_neq : forall a x xs, In(A:=A) a (x :: xs) -> a <> x -> In a xs. Proof using. (* Goal: @Permutation A (@cons A (@fst A B a) (@map (prod A B) A (@fst A B) l)) (@app A (@map (prod A B) A (@fst A B) x) (@map (prod A B) A (@fst A B) (@cons (prod A B) a x0))) *) simpl. (* Goal: @ex (list A) (fun tl : list A => @eq (list A) (@nil A) (@cons A x tl)) *) intuition congruence. Qed. Lemma NoDup_app3_not_in_1 : forall (xs ys zs : list A) b, NoDup (xs ++ ys ++ b :: zs) -> In b xs -> False. Proof using. (* Goal: forall (l : list A) (x : A) (_ : @eq (option A) (@hd_error A l) (@Some A x)), @ex (list A) (fun tl : list A => @eq (list A) l (@cons A x tl)) *) intros. rewrite <- app_ass in *. (* Goal: False *) find_apply_lem_hyp NoDup_remove. (* Goal: False *) rewrite app_ass in *. (* Goal: @eq C (g (@fold_left A B f l' (f a b')) b) (g a b) *) intuition. Qed. Lemma NoDup_app3_not_in_2 : forall (xs ys zs : list A) b, NoDup (xs ++ ys ++ b :: zs) -> In b ys -> False. Proof using. (* Goal: forall (l : list A) (x : A) (_ : @eq (option A) (@hd_error A l) (@Some A x)), @ex (list A) (fun tl : list A => @eq (list A) l (@cons A x tl)) *) intros. rewrite <- app_ass in *. (* Goal: False *) find_apply_lem_hyp NoDup_remove_2. (* Goal: False *) rewrite app_ass in *. (* Goal: False *) auto 10 with *. Qed. Lemma NoDup_app3_not_in_3 : forall (xs ys zs : list A) b, NoDup (xs ++ ys ++ b :: zs) -> In b zs -> False. Proof using. (* Goal: forall (l : list A) (x : A) (_ : @eq (option A) (@hd_error A l) (@Some A x)), @ex (list A) (fun tl : list A => @eq (list A) l (@cons A x tl)) *) intros. rewrite <- app_ass in *. (* Goal: False *) find_apply_lem_hyp NoDup_remove_2. (* Goal: False *) rewrite app_ass in *. (* Goal: False *) auto 10 with *. Qed. Lemma In_cons_2_3 : forall xs ys zs x y a, In (A:=A) a (xs ++ ys ++ zs) -> In a (xs ++ x :: ys ++ y :: zs). Proof using. (* Goal: forall (l : list A) (x : A) (_ : @eq (option A) (@hd_error A l) (@Some A x)), @ex (list A) (fun tl : list A => @eq (list A) l (@cons A x tl)) *) intros. (* Goal: @In A a (@app A xs (@cons A x (@app A ys (@cons A y zs)))) *) repeat (do_in_app; intuition auto 10 with *). Qed. Lemma In_cons_2_3_neq : forall a x y xs ys zs, In (A:=A) a (xs ++ x :: ys ++ y :: zs) -> a <> x -> a <> y -> In a (xs ++ ys ++ zs). Proof using. (* Goal: forall (l : list A) (x : A) (_ : @eq (option A) (@hd_error A l) (@Some A x)), @ex (list A) (fun tl : list A => @eq (list A) l (@cons A x tl)) *) intros. (* Goal: @In A a (@app A xs (@app A ys zs)) *) repeat (do_in_app; simpl in *; intuition (auto with *; try congruence)). Qed. Lemma in_middle_reduce : forall a xs y zs, In (A:=A) a (xs ++ y :: zs) -> a <> y -> In a (xs ++ zs). Proof using. (* Goal: forall (l : list A) (x : A) (_ : @eq (option A) (@hd_error A l) (@Some A x)), @ex (list A) (fun tl : list A => @eq (list A) l (@cons A x tl)) *) intros. (* Goal: @eq C (g (@fold_left A B f l' (f a b')) b) (g a b) *) do_in_app; simpl in *; intuition. congruence. Qed. Lemma in_middle_insert : forall a xs y zs, In (A:=A) a (xs ++ zs) -> In a (xs ++ y :: zs). Proof using. (* Goal: forall (l : list A) (x : A) (_ : @eq (option A) (@hd_error A l) (@Some A x)), @ex (list A) (fun tl : list A => @eq (list A) l (@cons A x tl)) *) intros. (* Goal: @eq C (g (@fold_left A B f l' (f a b')) b) (g a b) *) do_in_app; simpl in *; intuition. Qed. Lemma NoDup_rev : forall l, NoDup (A:=A) l -> NoDup (rev l). Proof using. (* Goal: @Permutation A (@cons A (@fst A B a) (@map (prod A B) A (@fst A B) l)) (@app A (@map (prod A B) A (@fst A B) x) (@map (prod A B) A (@fst A B) (@cons (prod A B) a x0))) *) induction l; intros; simpl. - auto. - apply NoDup_append. (* Goal: @NoDup A (@cons A (@fst A B a) (@map (prod A B) A (@fst A B) nms)) *) invc_NoDup. (* Goal: forall (g : forall _ : B, A) (x : A) (acc : list A) (_ : @In A x (@fold_left (list A) B (fun (a : list A) (b : B) => @cons A (g b) a) (@nil B) acc)), or (@In A x acc) (@ex B (fun y : B => and (@In B y (@nil B)) (@eq A x (g y)))) *) constructor; auto. (* Goal: @eq C (g (@fold_left A B f l' (f a b')) b) (g a b) *) intuition. (* Goal: False *) find_apply_lem_hyp in_rev. (* Goal: forall (g : forall _ : B, A) (x : A) (acc : list A) (_ : @In A x (@fold_left (list A) B (fun (a : list A) (b : B) => @cons A (g b) a) (@nil B) acc)), or (@In A x acc) (@ex B (fun y : B => and (@In B y (@nil B)) (@eq A x (g y)))) *) auto. Qed. Lemma NoDup_map_map : forall (f : A -> B) (g : A -> C) xs, (forall x y, In x xs -> In y xs -> f x = f y -> g x = g y) -> NoDup (map g xs) -> NoDup (map f xs). Proof using. (* Goal: @eq (prod A B) (@pair A B a b) (@pair A B (@fst A B (@pair A B a b)) m) *) induction xs; intros; simpl in *. - constructor. - invc_NoDup. (* Goal: forall (g : forall _ : B, A) (x : A) (acc : list A) (_ : @In A x (@fold_left (list A) B (fun (a : list A) (b : B) => @cons A (g b) a) (@nil B) acc)), or (@In A x acc) (@ex B (fun y : B => and (@In B y (@nil B)) (@eq A x (g y)))) *) constructor; auto. (* Goal: not (or (@eq A (@fst A B a) n) (@In A n (@map (prod A B) A (@fst A B) l))) *) intro. (* Goal: False *) do_in_map. (* Goal: @Permutation A (@cons A (@fst A B a) (@map (prod A B) A (@fst A B) l)) (@map (prod A B) A (@fst A B) l') *) find_apply_hyp_hyp. (* Goal: False *) find_reverse_rewrite. (* Goal: False *) auto using in_map. Qed. Lemma pigeon : forall (l : list A) sub1 sub2, (forall a, In a sub1 -> In a l) -> (forall a, In a sub2 -> In a l) -> NoDup l -> NoDup sub1 -> NoDup sub2 -> length sub1 + length sub2 > length l -> exists a, In a sub1 /\ In a sub2. Proof using A_eq_dec. (* Goal: forall (g : forall _ : B, A) (x : A) (acc : list A) (_ : @In A x (@fold_left (list A) B (fun (a : list A) (b : B) => @cons A (g b) a) l acc)), or (@In A x acc) (@ex B (fun y : B => and (@In B y l) (@eq A x (g y)))) *) induction l. (* Goal: forall (l : list A) (x : A) (_ : @eq (option A) (@hd_error A l) (@Some A x)), @ex (list A) (fun tl : list A => @eq (list A) l (@cons A x tl)) *) intros. (* Goal: @eq C (g (@fold_left A B f l' (f a b')) b) (g a b) *) + simpl in *. find_apply_lem_hyp plus_gt_0. intuition. * destruct sub1; simpl in *; [omega|]. (* Goal: @eq C (g (@fold_left A B f l' (f a b')) b) (g a b) *) specialize (H a). intuition. * destruct sub2; simpl in *; [omega|]. (* Goal: @eq C (g (@fold_left A B f l' (f a b')) b) (g a b) *) specialize (H0 a). intuition. (* Goal: forall (l : list A) (x : A) (_ : @eq (option A) (@hd_error A l) (@Some A x)), @ex (list A) (fun tl : list A => @eq (list A) l (@cons A x tl)) *) + intros. simpl in *. destruct (in_dec A_eq_dec a sub1); destruct (in_dec A_eq_dec a sub2); eauto; specialize (IHl (remove A_eq_dec a sub1) (remove A_eq_dec a sub2)); cut (exists a0, In a0 (remove A_eq_dec a sub1) /\ In a0 (remove A_eq_dec a sub2)); try solve [intros; break_exists; intuition eauto using in_remove]; apply IHl; try solve [ intros; find_copy_apply_lem_hyp in_remove; find_apply_hyp_hyp; intuition; subst; exfalso; eapply remove_In; eauto]; eauto using remove_NoDup; try solve_by_inversion; repeat match goal with | H : ~ In a ?sub |- _ => assert (length (remove A_eq_dec a sub) = length sub) by eauto using remove_length_not_in; clear H | H : In a ?sub |- _ => assert (length (remove A_eq_dec a sub) >= length sub - 1) by eauto using remove_length_ge; clear H (* Goal: ge (@length A ys) (S (@length A xs)) *) end; omega. Qed. Lemma snoc_assoc : forall (l : list A) x y, l ++ [x; y] = (l ++ [x]) ++ [y]. Proof using. (* Goal: @eq C (g (@fold_left A B f l' (f a b')) b) (g a b) *) induction l; intros; simpl; intuition. (* Goal: @eq (list A) (@cons A a la) (@cons A a (@map B A g (@map A B f la))) *) auto using f_equal. Qed. Lemma cons_cons_app : forall (x y : A), [x; y] = [x] ++ [y]. Proof using. (* Goal: forall (g : forall _ : B, A) (x : A) (acc : list A) (_ : @In A x (@fold_left (list A) B (fun (a : list A) (b : B) => @cons A (g b) a) (@nil B) acc)), or (@In A x acc) (@ex B (fun y : B => and (@In B y (@nil B)) (@eq A x (g y)))) *) auto. Qed. Lemma map_eq_inv : forall (f : A -> B) l xs ys, map f l = xs ++ ys -> exists l1 l2, l = l1 ++ l2 /\ map f l1 = xs /\ map f l2 = ys. Proof using. (* Goal: forall (f : forall _ : A, B) (l : list A) (xs ys : list B) (_ : @eq (list B) (@map A B f l) (@app B xs ys)), @ex (list A) (fun l1 : list A => @ex (list A) (fun l2 : list A => and (@eq (list A) l (@app A l1 l2)) (and (@eq (list B) (@map A B f l1) xs) (@eq (list B) (@map A B f l2) ys)))) *) induction l; simpl; intros xs ys H. - symmetry in H. apply app_eq_nil in H. break_and. subst. (* Goal: forall (g : forall _ : B, A) (x : A) (acc : list A) (_ : @In A x (@fold_left (list A) B (fun (a : list A) (b : B) => @cons A (g b) a) (@nil B) acc)), or (@In A x acc) (@ex B (fun y : B => and (@In B y (@nil B)) (@eq A x (g y)))) *) exists [], []. auto. - destruct xs; simpl in *. (* Goal: @eq C (g (@fold_left A B f l' (f a b')) b) (g a b) *) + exists [], (a :: l). intuition. + invc H. find_apply_hyp_hyp. (* Goal: @ex (list A) (fun ap : list A => @ex A (fun a : A => @ex (list A) (fun ap' : list A => and (@eq (list A) l (@app A ap (@cons A a ap'))) (and (@eq (list B) (@map A B f ap) p) (and (@eq B (f a) x) (@eq (list B) (@map A B f ap') p')))))) *) break_exists_name l1. (* Goal: @ex (list A) (fun ap : list A => @ex A (fun a : A => @ex (list A) (fun ap' : list A => and (@eq (list A) l (@app A ap (@cons A a ap'))) (and (@eq (list B) (@map A B f ap) p) (and (@eq B (f a) x) (@eq (list B) (@map A B f ap') p')))))) *) break_exists_name l2. (* Goal: @ex (list A) (fun ap : list A => @ex A (fun a : A => @ex (list A) (fun ap' : list A => and (@eq (list A) l (@app A ap (@cons A a ap'))) (and (@eq (list B) (@map A B f ap) p) (and (@eq B (f a) x) (@eq (list B) (@map A B f ap') p')))))) *) break_and. (* Goal: and (@eq (list A) (@cons A a l) (@app A (@cons A a l1) l2)) (and (@eq (list B) (@map A B f (@cons A a l1)) (@cons B (f a) xs)) (@eq (list B) (@map A B f l2) ys)) *) exists (a :: l1), l2. subst. (* Goal: @eq C (g (@fold_left A B f l' (f a b')) b) (g a b) *) intuition. Qed. Lemma map_partition : forall p l (x : B) p' (f : A -> B), map f l = (p ++ x :: p') -> exists ap a ap', l = ap ++ a :: ap' /\ map f ap = p /\ f a = x /\ map f ap' = p'. Proof using. (* Goal: forall (p : list B) (l : list A) (x : B) (p' : list B) (f : forall _ : A, B) (_ : @eq (list B) (@map A B f l) (@app B p (@cons B x p'))), @ex (list A) (fun ap : list A => @ex A (fun a : A => @ex (list A) (fun ap' : list A => and (@eq (list A) l (@app A ap (@cons A a ap'))) (and (@eq (list B) (@map A B f ap) p) (and (@eq B (f a) x) (@eq (list B) (@map A B f ap') p')))))) *) intros p l x p' f H_m. (* Goal: @ex (list A) (fun ap : list A => @ex A (fun a : A => @ex (list A) (fun ap' : list A => and (@eq (list A) l (@app A ap (@cons A a ap'))) (and (@eq (list B) (@map A B f ap) p) (and (@eq B (f a) x) (@eq (list B) (@map A B f ap') p')))))) *) pose proof map_eq_inv f _ _ _ H_m. (* Goal: @ex (list A) (fun ap : list A => @ex A (fun a : A => @ex (list A) (fun ap' : list A => and (@eq (list A) l (@app A ap (@cons A a ap'))) (and (@eq (list B) (@map A B f ap) p) (and (@eq B (f a) x) (@eq (list B) (@map A B f ap') p')))))) *) break_exists_name l1. (* Goal: @ex (list A) (fun ap : list A => @ex A (fun a : A => @ex (list A) (fun ap' : list A => and (@eq (list A) l (@app A ap (@cons A a ap'))) (and (@eq (list B) (@map A B f ap) p) (and (@eq B (f a) x) (@eq (list B) (@map A B f ap') p')))))) *) break_exists_name l2. (* Goal: @ex (list A) (fun ap : list A => @ex A (fun a : A => @ex (list A) (fun ap' : list A => and (@eq (list A) l (@app A ap (@cons A a ap'))) (and (@eq (list B) (@map A B f ap) p) (and (@eq B (f a) x) (@eq (list B) (@map A B f ap') p')))))) *) break_and. (* Goal: @Permutation A (@cons A (@fst A B a) (@map (prod A B) A (@fst A B) l)) (@map (prod A B) A (@fst A B) l') *) find_rewrite. (* Goal: @eq (prod A B) (@pair A B a b) (@pair A B (@fst A B (@pair A B a b)) m) *) destruct l2; simpl in *. - match goal with H : [] = _ :: _ |- _ => contradict H end. (* Goal: not (@eq (list B) (@nil B) (@cons B x p')) *) auto with datatypes. - repeat find_rewrite. (* Goal: @eq (list A) (@cons A a l) (@cons A a0 l') *) find_inversion. (* Goal: forall (g : forall _ : B, A) (x : A) (acc : list A) (_ : @In A x (@fold_left (list A) B (fun (a : list A) (b : B) => @cons A (g b) a) (@nil B) acc)), or (@In A x acc) (@ex B (fun y : B => and (@In B y (@nil B)) (@eq A x (g y)))) *) exists l1, a, l2. auto. Qed. Lemma map_eq_inv_eq : forall (f : A -> B), (forall a a', f a = f a' -> a = a') -> forall l l', map f l = map f l' -> l = l'. Proof using. (* Goal: @ex (list A) (fun tl : list A => @eq (list A) (@nil A) (@cons A x tl)) *) induction l; simpl; intros l' Heq; destruct l'; simpl in *; try congruence. (* Goal: @eq (list A) (@cons A a l) (@cons A a0 l') *) find_inversion. auto using f_equal2. Qed. Lemma map_fst_snd_id : forall l, map (fun t : A * B => (fst t, snd t)) l = l. Proof using. (* Goal: forall (l : list A) (x : A) (_ : @eq (option A) (@hd_error A l) (@Some A x)), @ex (list A) (fun tl : list A => @eq (list A) l (@cons A x tl)) *) intros. rewrite <- map_id. (* Goal: @eq (list (prod A B)) (@map (prod A B) (prod A B) (fun t : prod A B => @pair A B (@fst A B t) (@snd A B t)) l) (@map (prod A B) (prod A B) (fun x : prod A B => x) l) *) apply map_ext. (* Goal: forall (g : forall _ : B, A) (x : A) (acc : list A) (_ : @In A x (@fold_left (list A) B (fun (a : list A) (b : B) => @cons A (g b) a) (@nil B) acc)), or (@In A x acc) (@ex B (fun y : B => and (@In B y (@nil B)) (@eq A x (g y)))) *) destruct a; auto. Qed. Lemma in_firstn : forall n (x : A) xs, In x (firstn n xs) -> In x xs. Proof using. (* Goal: @eq C (g (@fold_left A B f l' (f a b')) b) (g a b) *) induction n; simpl; intuition; break_match; simpl in *; intuition. Qed. Lemma firstn_NoDup : forall n (xs : list A), NoDup xs -> NoDup (firstn n xs). Proof using. (* Goal: @NoDup A (@remove A A_eq_dec x (@nil A)) *) induction n; intros; simpl; destruct xs; auto with struct_util. (* Goal: @NoDup A (@cons A (@fst A B a) (@map (prod A B) A (@fst A B) nms)) *) invc_NoDup. (* Goal: @NoDup A (@cons A a (@firstn A n xs)) *) eauto 6 using in_firstn with struct_util. Qed. Lemma NoDup_mid_not_in : forall (a : A) (l l' : list A), NoDup (l ++ a :: l') -> ~ In a (l ++ l'). Proof using. (* Goal: @eq (prod A B) (@pair A B a b) (@pair A B (@fst A B (@pair A B a b)) m) *) induction l; intros; simpl in *. - invc_NoDup; auto. - invc_NoDup. (* Goal: not (or (@eq A (@fst A B a) n) (@In A n (@map (prod A B) A (@fst A B) l))) *) intro. (* Goal: False *) break_or_hyp. * match goal with H: ~ In _ _ |- _ => contradict H end. (* Goal: @In A a (@app A l l') *) apply in_or_app. (* Goal: forall (g : forall _ : B, A) (x : A) (acc : list A) (_ : @In A x (@fold_left (list A) B (fun (a : list A) (b : B) => @cons A (g b) a) (@nil B) acc)), or (@In A x acc) (@ex B (fun y : B => and (@In B y (@nil B)) (@eq A x (g y)))) *) right; left. auto. * match goal with H: In _ _ |- _ => contradict H end. (* Goal: forall (g : forall _ : B, A) (x : A) (acc : list A) (_ : @In A x (@fold_left (list A) B (fun (a : list A) (b : B) => @cons A (g b) a) (@nil B) acc)), or (@In A x acc) (@ex B (fun y : B => and (@In B y (@nil B)) (@eq A x (g y)))) *) eauto. Qed. Lemma Permutation_split : forall (ns ns' : list A) (n : A), Permutation (n :: ns) ns' -> exists ns0, exists ns1, ns' = ns0 ++ n :: ns1. Proof using. (* Goal: forall (ns ns' : list A) (n : A) (_ : @Permutation A (@cons A n ns) ns'), @ex (list A) (fun ns0 : list A => @ex (list A) (fun ns1 : list A => @eq (list A) ns' (@app A ns0 (@cons A n ns1)))) *) intros l l' a H_pm. (* Goal: not (@eq (list B) (@nil B) (@cons B x p')) *) assert (In a (a :: l)); auto with datatypes. (* Goal: @ex (list A) (fun ns0 : list A => @ex (list A) (fun ns1 : list A => @eq (list A) l' (@app A ns0 (@cons A a ns1)))) *) assert (In a l'); eauto using Permutation_in. (* Goal: forall (g : forall _ : B, A) (x : A) (acc : list A) (_ : @In A x (@fold_left (list A) B (fun (a : list A) (b : B) => @cons A (g b) a) (@nil B) acc)), or (@In A x acc) (@ex B (fun y : B => and (@In B y (@nil B)) (@eq A x (g y)))) *) find_apply_lem_hyp In_split; auto. Qed. Lemma NoDup_app_left : forall (l l' : list A), NoDup (l ++ l') -> NoDup l. Proof using. (* Goal: @eq (prod A B) (@pair A B a b) (@pair A B (@fst A B (@pair A B a b)) m) *) induction l; intros; simpl in *. - apply NoDup_nil. - invc_NoDup. (* Goal: @Permutation A (@cons A (@fst A B a) (@map (prod A B) A (@fst A B) l)) (@map (prod A B) A (@fst A B) l') *) find_apply_hyp_hyp. (* Goal: forall (g : forall _ : B, A) (x : A) (acc : list A) (_ : @In A x (@fold_left (list A) B (fun (a : list A) (b : B) => @cons A (g b) a) (@nil B) acc)), or (@In A x acc) (@ex B (fun y : B => and (@In B y (@nil B)) (@eq A x (g y)))) *) apply NoDup_cons; auto. (* Goal: not (or (@eq A (@fst A B a) n) (@In A n (@map (prod A B) A (@fst A B) l))) *) intro. match goal with H: ~ In _ _ |- _ => contradict H end. (* Goal: @In A a (@app A l l') *) apply in_or_app. (* Goal: forall (g : forall _ : B, A) (x : A) (acc : list A) (_ : @In A x (@fold_left (list A) B (fun (a : list A) (b : B) => @cons A (g b) a) (@nil B) acc)), or (@In A x acc) (@ex B (fun y : B => and (@In B y (@nil B)) (@eq A x (g y)))) *) left; auto. Qed. Lemma NoDup_app_right : forall (l l' : list A), NoDup (l ++ l') -> NoDup l'. Proof using. (* Goal: forall (g : forall _ : B, A) (x : A) (acc : list A) (_ : @In A x (@fold_left (list A) B (fun (a : list A) (b : B) => @cons A (g b) a) (@nil B) acc)), or (@In A x acc) (@ex B (fun y : B => and (@In B y (@nil B)) (@eq A x (g y)))) *) induction l; intros; simpl in *; auto. (* Goal: @NoDup A (@cons A (@fst A B a) (@map (prod A B) A (@fst A B) nms)) *) invc_NoDup. (* Goal: forall (g : forall _ : B, A) (x : A) (acc : list A) (_ : @In A x (@fold_left (list A) B (fun (a : list A) (b : B) => @cons A (g b) a) (@nil B) acc)), or (@In A x acc) (@ex B (fun y : B => and (@In B y (@nil B)) (@eq A x (g y)))) *) find_apply_hyp_hyp; auto. Qed. Lemma NoDup_in_not_in_right : forall (l l' : list A) (a : A), NoDup (l ++ l') -> In a l -> ~ In a l'. Proof using. (* Goal: forall (g : forall _ : B, A) (x : A) (acc : list A) (_ : @In A x (@fold_left (list A) B (fun (a : list A) (b : B) => @cons A (g b) a) (@nil B) acc)), or (@In A x acc) (@ex B (fun y : B => and (@In B y (@nil B)) (@eq A x (g y)))) *) induction l; intros; simpl in *; auto. (* Goal: @NoDup A (@cons A (@fst A B a) (@map (prod A B) A (@fst A B) nms)) *) invc_NoDup. (* Goal: not (@eq (list B) (@nil B) (@cons B x p')) *) break_or_hyp; eauto with datatypes. Qed. Lemma NoDup_in_not_in_left : forall (l l' : list A) (a : A), NoDup (l ++ l') -> In a l' -> ~ In a l. Proof using. (* Goal: forall (l : list A) (x : A) (_ : @eq (option A) (@hd_error A l) (@Some A x)), @ex (list A) (fun tl : list A => @eq (list A) l (@cons A x tl)) *) intros. (* Goal: forall (g : forall _ : B, A) (x : A) (acc : list A) (_ : @In A x (@fold_left (list A) B (fun (a : list A) (b : B) => @cons A (g b) a) (@nil B) acc)), or (@In A x acc) (@ex B (fun y : B => and (@In B y (@nil B)) (@eq A x (g y)))) *) induction l; simpl in *; auto. (* Goal: @NoDup A (@cons A (@fst A B a) (@map (prod A B) A (@fst A B) nms)) *) invc_NoDup. (* Goal: not (or (@eq A a0 a) (@In A a l)) *) concludes. (* Goal: not (or (@eq A (@fst A B a) n) (@In A n (@map (prod A B) A (@fst A B) l))) *) intro. (* Goal: not (@eq (list B) (@nil B) (@cons B x p')) *) break_or_hyp; auto with datatypes. Qed. Lemma count_occ_app : forall l l' (a : A), count_occ A_eq_dec (l ++ l') a = count_occ A_eq_dec l a + count_occ A_eq_dec l' a. Proof using. (* Goal: forall (l : list A) (x : A) (_ : @eq (option A) (@hd_error A l) (@Some A x)), @ex (list A) (fun tl : list A => @eq (list A) l (@cons A x tl)) *) intros. (* Goal: forall (g : forall _ : B, A) (x : A) (acc : list A) (_ : @In A x (@fold_left (list A) B (fun (a : list A) (b : B) => @cons A (g b) a) (@nil B) acc)), or (@In A x acc) (@ex B (fun y : B => and (@In B y (@nil B)) (@eq A x (g y)))) *) induction l; simpl in *; auto. (* Goal: forall (g : forall _ : B, A) (x : A) (acc : list A) (_ : @In A x (@fold_left (list A) B (fun (a : list A) (b : B) => @cons A (g b) a) (@nil B) acc)), or (@In A x acc) (@ex B (fun y : B => and (@In B y (@nil B)) (@eq A x (g y)))) *) break_if; auto. (* Goal: @Permutation A (@cons A (@fst A B a) (@map (prod A B) A (@fst A B) l)) (@map (prod A B) A (@fst A B) l') *) find_rewrite. (* Goal: forall (g : forall _ : B, A) (x : A) (acc : list A) (_ : @In A x (@fold_left (list A) B (fun (a : list A) (b : B) => @cons A (g b) a) (@nil B) acc)), or (@In A x acc) (@ex B (fun y : B => and (@In B y (@nil B)) (@eq A x (g y)))) *) auto. Qed. Lemma Permutation_map_fst : forall l l' : list (A * B), Permutation l l' -> Permutation (map fst l) (map fst l'). Proof using. (* Goal: @eq (prod A B) (@pair A B a b) (@pair A B (@fst A B (@pair A B a b)) m) *) induction l; intros; simpl in *. - find_apply_lem_hyp Permutation_nil. (* Goal: @Permutation A (@cons A (@fst A B a) (@map (prod A B) A (@fst A B) l)) (@map (prod A B) A (@fst A B) l') *) find_rewrite. (* Goal: forall (g : forall _ : B, A) (x : A) (acc : list A) (_ : @In A x (@fold_left (list A) B (fun (a : list A) (b : B) => @cons A (g b) a) (@nil B) acc)), or (@In A x acc) (@ex B (fun y : B => and (@In B y (@nil B)) (@eq A x (g y)))) *) auto. - assert (In a l'). (* Goal: not (@eq (list B) (@nil B) (@cons B x p')) *) apply Permutation_in with (l := a :: l); auto with datatypes. (* Goal: @Permutation A (@cons A (@fst A B a) (@map (prod A B) A (@fst A B) l)) (@map (prod A B) A (@fst A B) l') *) find_apply_lem_hyp in_split. (* Goal: @Permutation A (@cons A (@fst A B a) (@map (prod A B) A (@fst A B) l)) (@map (prod A B) A (@fst A B) l') *) break_exists. (* Goal: @Permutation A (@cons A (@fst A B a) (@map (prod A B) A (@fst A B) l)) (@map (prod A B) A (@fst A B) l') *) find_rewrite. (* Goal: @Permutation A (@cons A (@fst A B a) (@map (prod A B) A (@fst A B) l)) (@map (prod A B) A (@fst A B) l') *) find_apply_lem_hyp Permutation_cons_app_inv. (* Goal: @Permutation A (@cons A (@fst A B a) (@map (prod A B) A (@fst A B) l)) (@map (prod A B) A (@fst A B) l') *) find_apply_hyp_hyp. (* Goal: @Permutation A (@cons A (@fst A B a) (@map (prod A B) A (@fst A B) l)) (@map (prod A B) A (@fst A B) l') *) find_rewrite. (* Goal: @Permutation A (@cons A (@fst A B a) (@map (prod A B) A (@fst A B) l)) (@map (prod A B) A (@fst A B) (@app (prod A B) x (@cons (prod A B) a x0))) *) rewrite map_app. (* Goal: @Permutation A (@cons A (@fst A B a) (@map (prod A B) A (@fst A B) l)) (@app A (@map (prod A B) A (@fst A B) x) (@map (prod A B) A (@fst A B) (@cons (prod A B) a x0))) *) simpl. (* Goal: @Permutation A (@cons A (@fst A B a) (@map (prod A B) A (@fst A B) l)) (@app A (@map (prod A B) A (@fst A B) x) (@cons A (@fst A B a) (@map (prod A B) A (@fst A B) x0))) *) apply Permutation_cons_app. rewrite <- map_app. (* Goal: forall (g : forall _ : B, A) (x : A) (acc : list A) (_ : @In A x (@fold_left (list A) B (fun (a : list A) (b : B) => @cons A (g b) a) (@nil B) acc)), or (@In A x acc) (@ex B (fun y : B => and (@In B y (@nil B)) (@eq A x (g y)))) *) auto. Qed. Lemma snd_eq_not_in_map : forall (l : list (A * B)) n m, (forall nm, In nm l -> snd nm = m) -> ~ In (n, m) l -> ~ In n (map fst l). Proof using. (* Goal: forall (l : list A) (x : A) (_ : @eq (option A) (@hd_error A l) (@Some A x)), @ex (list A) (fun tl : list A => @eq (list A) l (@cons A x tl)) *) intros. (* Goal: forall (g : forall _ : B, A) (x : A) (acc : list A) (_ : @In A x (@fold_left (list A) B (fun (a : list A) (b : B) => @cons A (g b) a) (@nil B) acc)), or (@In A x acc) (@ex B (fun y : B => and (@In B y (@nil B)) (@eq A x (g y)))) *) induction l; simpl in *; auto. (* Goal: not (or (@eq A (@fst A B a) n) (@In A n (@map (prod A B) A (@fst A B) l))) *) intro. (* Goal: False *) break_or_hyp. - match goal with H: ~ _ |- _ => contradict H end. (* Goal: or (@eq (prod A B) a (@pair A B (@fst A B a) m)) (@In (prod A B) (@pair A B (@fst A B a) m) l) *) left. (* Goal: not (@In A (@fst A B a) (@map (prod A B) A (@fst A B) nms)) *) destruct a. match goal with H: forall _ : A * B, _ |- _ => specialize (H (a, b)) end. (* Goal: @eq (prod A B) (@pair A B a b) (@pair A B (@fst A B (@pair A B a b)) m) *) simpl in *. (* Goal: forall (g : forall _ : B, A) (x : A) (acc : list A) (_ : @In A x (@fold_left (list A) B (fun (a : list A) (b : B) => @cons A (g b) a) (@nil B) acc)), or (@In A x acc) (@ex B (fun y : B => and (@In B y (@nil B)) (@eq A x (g y)))) *) intuition eauto; repeat find_rewrite; auto. - match goal with H: In _ _ |- _ => contradict H end. (* Goal: forall (g : forall _ : B, A) (x : A) (acc : list A) (_ : @In A x (@fold_left (list A) B (fun (a : list A) (b : B) => @cons A (g b) a) (@nil B) acc)), or (@In A x acc) (@ex B (fun y : B => and (@In B y (@nil B)) (@eq A x (g y)))) *) apply IHl; eauto. Qed. Lemma NoDup_map_snd_fst : forall nms : list (A * B), NoDup nms -> (forall nm nm', In nm nms -> In nm' nms -> snd nm = snd nm') -> NoDup (map fst nms). Proof using. (* Goal: forall (l : list A) (x : A) (_ : @eq (option A) (@hd_error A l) (@Some A x)), @ex (list A) (fun tl : list A => @eq (list A) l (@cons A x tl)) *) intros. (* Goal: @eq (prod A B) (@pair A B a b) (@pair A B (@fst A B (@pair A B a b)) m) *) induction nms; simpl in *. - apply NoDup_nil. - invc_NoDup. (* Goal: @NoDup A (@cons A (@fst A B a) (@map (prod A B) A (@fst A B) nms)) *) apply NoDup_cons. * assert (forall nm, In nm nms -> snd nm = snd a). (* Goal: forall (g : forall _ : B, A) (x : A) (acc : list A) (_ : @In A x (@fold_left (list A) B (fun (a : list A) (b : B) => @cons A (g b) a) (@nil B) acc)), or (@In A x acc) (@ex B (fun y : B => and (@In B y (@nil B)) (@eq A x (g y)))) *) intuition eauto. (* Goal: not (@In A (@fst A B a) (@map (prod A B) A (@fst A B) nms)) *) destruct a. (* Goal: forall (g : forall _ : B, A) (x : A) (acc : list A) (_ : @In A x (@fold_left (list A) B (fun (a : list A) (b : B) => @cons A (g b) a) (@nil B) acc)), or (@In A x acc) (@ex B (fun y : B => and (@In B y (@nil B)) (@eq A x (g y)))) *) apply snd_eq_not_in_map with (m := b); auto. (* Goal: forall (g : forall _ : B, A) (x : A) (acc : list A) (_ : @In A x (@fold_left (list A) B (fun (a : list A) (b : B) => @cons A (g b) a) (@nil B) acc)), or (@In A x acc) (@ex B (fun y : B => and (@In B y (@nil B)) (@eq A x (g y)))) *) * apply IHnms; auto. Qed. Lemma in_fold_left_by_cons_in : forall (l : list B) (g : B -> A) x acc, In x (fold_left (fun a b => g b :: a) l acc) -> In x acc \/ exists y, In y l /\ x = g y. Proof using A_eq_dec. (* Goal: forall (l : list B) (g : forall _ : B, A) (x : A) (acc : list A) (_ : @In A x (@fold_left (list A) B (fun (a : list A) (b : B) => @cons A (g b) a) l acc)), or (@In A x acc) (@ex B (fun y : B => and (@In B y l) (@eq A x (g y)))) *) intros until l. (* Goal: forall (g : forall _ : B, A) (x : A) (acc : list A) (_ : @In A x (@fold_left (list A) B (fun (a : list A) (b : B) => @cons A (g b) a) l acc)), or (@In A x acc) (@ex B (fun y : B => and (@In B y l) (@eq A x (g y)))) *) induction l. - auto. - simpl; intros. (* Goal: and (@eq (list A) (@cons A a l) (@app A (@cons A a l1) l2)) (and (@eq (list B) (@map A B f (@cons A a l1)) (@cons B (f a) xs)) (@eq (list B) (@map A B f l2) ys)) *) destruct (A_eq_dec x (g a)); subst. (* Goal: forall (g : forall _ : B, A) (x : A) (acc : list A) (_ : @In A x (@fold_left (list A) B (fun (a : list A) (b : B) => @cons A (g b) a) (@nil B) acc)), or (@In A x acc) (@ex B (fun y : B => and (@In B y (@nil B)) (@eq A x (g y)))) *) + right; exists a; tauto. + find_apply_lem_hyp IHl. (* Goal: or (@In A x acc) (@ex B (fun y : B => and (or (@eq B a y) (@In B y l)) (@eq A x (g y)))) *) break_or_hyp; [left|right]. (* Goal: forall (g : forall _ : B, A) (x : A) (acc : list A) (_ : @In A x (@fold_left (list A) B (fun (a : list A) (b : B) => @cons A (g b) a) (@nil B) acc)), or (@In A x acc) (@ex B (fun y : B => and (@In B y (@nil B)) (@eq A x (g y)))) *) * find_apply_lem_hyp In_cons_neq; tauto. (* Goal: forall (g : forall _ : B, A) (x : A) (acc : list A) (_ : @In A x (@fold_left (list A) B (fun (a : list A) (b : B) => @cons A (g b) a) (@nil B) acc)), or (@In A x acc) (@ex B (fun y : B => and (@In B y (@nil B)) (@eq A x (g y)))) *) * break_exists_exists; tauto. Qed. Lemma fold_left_for_each_not_in : forall (f : A -> B -> A) (g : A -> B -> C), (forall a b b', b <> b' -> g (f a b') b = g a b) -> forall l a b, ~ In b l -> g (fold_left f l a) b = g a b. Proof using A B C. (* Goal: forall (g : forall _ : B, A) (x : A) (acc : list A) (_ : @In A x (@fold_left (list A) B (fun (a : list A) (b : B) => @cons A (g b) a) (@nil B) acc)), or (@In A x acc) (@ex B (fun y : B => and (@In B y (@nil B)) (@eq A x (g y)))) *) induction l as [| b' l']; simpl in *; auto. - intros. intuition. (* Goal: forall (g : forall _ : B, A) (x : A) (acc : list A) (_ : @In A x (@fold_left (list A) B (fun (a : list A) (b : B) => @cons A (g b) a) (@nil B) acc)), or (@In A x acc) (@ex B (fun y : B => and (@In B y (@nil B)) (@eq A x (g y)))) *) rewrite IHl'; auto. Qed. Lemma fold_left_for_each_in : forall (f : A -> B -> A) (g : A -> B -> C) (B_eq_dec : forall x y : B, {x = y} + {x <> y}), (forall a b b', b <> b' -> g (f a b') b = g a b) -> forall l a b, In b l -> exists a', g (fold_left f l a) b = g (f a' b) b. Proof using A B C. (* Goal: and (@eq (list A) (@cons A a l) (@app A (@cons A a l1) l2)) (and (@eq (list B) (@map A B f (@cons A a l1)) (@cons B (f a) xs)) (@eq (list B) (@map A B f l2) ys)) *) induction l as [|b' l']; simpl in *; intuition; subst. (* Goal: @eq C (g (@fold_left A B f l' (f a b')) b) (g a b) *) destruct (in_dec B_eq_dec b l'); intuition. (* Goal: forall (g : forall _ : B, A) (x : A) (acc : list A) (_ : @In A x (@fold_left (list A) B (fun (a : list A) (b : B) => @cons A (g b) a) (@nil B) acc)), or (@In A x acc) (@ex B (fun y : B => and (@In B y (@nil B)) (@eq A x (g y)))) *) find_eapply_lem_hyp fold_left_for_each_not_in; eauto. Qed. Lemma hd_error_tl_exists : forall (l : list A) x, hd_error l = Some x -> exists tl, l = x :: tl. Proof. (* Goal: forall (l : list A) (x : A) (_ : @eq (option A) (@hd_error A l) (@Some A x)), @ex (list A) (fun tl : list A => @eq (list A) l (@cons A x tl)) *) intros. (* Goal: @eq (prod A B) (@pair A B a b) (@pair A B (@fst A B (@pair A B a b)) m) *) destruct l; simpl in *. - congruence. - eexists; solve_by_inversion. Qed. Lemma hd_error_None : forall (l : list A), hd_error l = None -> l = []. Proof. (* Goal: forall (l : list A) (_ : @eq (option A) (@hd_error A l) (@None A)), @eq (list A) l (@nil A) *) now destruct l. Qed. End list_util. (* We have to repeat these Hint Resolve commands because hints don't survive past the ends of sections *) Hint Resolve app_cons_in : struct_util. Hint Resolve app_cons_in_rest : struct_util. Hint Resolve in_rest_app_cons : struct_util.
Require Import List. Import ListNotations. Require Import StructTact.StructTactics. Set Implicit Arguments. Section assoc. Variable K V : Type. Variable K_eq_dec : forall k k' : K, {k = k'} + {k <> k'}. Fixpoint assoc (l : list (K * V)) (k : K) : option V := match l with | [] => None | (k', v) :: l' => if K_eq_dec k k' then Some v else assoc l' k end. Definition assoc_default (l : list (K * V)) (k : K) (default : V) : V := match (assoc l k) with | Some x => x | None => default end. Fixpoint assoc_set (l : list (K * V)) (k : K) (v : V) : list (K * V) := match l with | [] => [(k, v)] | (k', v') :: l' => if K_eq_dec k k' then (k, v) :: l' else (k', v') :: (assoc_set l' k v) end. Fixpoint assoc_del (l : list (K * V)) (k : K) : list (K * V) := match l with | [] => [] | (k', v') :: l' => if K_eq_dec k k' then assoc_del l' k else (k', v') :: (assoc_del l' k) end. Lemma get_set_same : forall k v l, assoc (assoc_set l k v) k = Some v. Proof using. (* Goal: forall (k : K) (v : V) (l : list (prod K V)), @eq (option V) (assoc (assoc_set l k v) k) (@Some V v) *) induction l; intros; simpl; repeat (break_match; simpl); subst; congruence. Qed. Lemma get_set_same' : forall k k' v l, k = k' -> assoc (assoc_set l k v) k' = Some v. Proof using. (* Goal: forall (l : list (prod K V)) (k : K) (v : V) (k' : K) (d : V) (_ : not (@eq K k k')), @eq V (assoc_default (assoc_set l k' v) k d) (assoc_default l k d) *) intros. subst. auto using get_set_same. Qed. Lemma get_set_diff : forall k k' v l, k <> k' -> assoc (assoc_set l k v) k' = assoc l k'. Proof using. (* Goal: forall (k k' : K) (v : V) (l : list (prod K V)) (_ : not (@eq K k k')), @eq (option V) (assoc (assoc_set l k v) k') (assoc l k') *) induction l; intros; simpl; repeat (break_match; simpl); subst; try congruence; auto. Qed. Lemma not_in_assoc : forall k l, ~ In k (map (@fst _ _) l) -> assoc l k = None. Proof using. (* Goal: forall (l : list (prod K V)) (k : K) (v : V) (k' : K) (d : V) (_ : not (@eq K k k')), @eq V (assoc_default (assoc_set l k' v) k d) (assoc_default l k d) *) intros. (* Goal: @eq (option V) (assoc l k) (@None V) *) induction l. - auto. - simpl in *. repeat break_match; intuition. (* Goal: @eq (list (prod K V)) (@cons (prod K V) (@pair K V k v) l) (@cons (prod K V) (@pair K V k0 v0) l) *) subst. simpl in *. congruence. Qed. Lemma get_del_same : forall k l, assoc (assoc_del l k) k = None. Proof using. (* Goal: @eq (list (prod K V)) (@cons (prod K V) p l) (@nil (prod K V)) *) induction l; intros; simpl in *. - auto. - repeat break_match; subst; simpl in *; auto. (* Goal: @eq (option V) (@Some V v) (@None V) *) break_if; try congruence. Qed. Lemma get_del_diff : forall k k' l, k <> k' -> assoc (assoc_del l k') k = assoc l k. Proof using. (* Goal: @eq (list (prod K V)) (@cons (prod K V) p l) (@nil (prod K V)) *) induction l; intros; simpl in *. - auto. - repeat (break_match; simpl); subst; try congruence; auto. Qed. Lemma get_set_diff_default : forall (k k' : K) (v : V) l d, k <> k' -> assoc_default (assoc_set l k v) k' d = assoc_default l k' d. Proof using. (* Goal: @eq V (assoc_default (assoc_set l k' v) k d) (assoc_default l k d) *) unfold assoc_default. (* Goal: forall (l : list (prod K V)) (k : K) (v : V) (k' : K) (d : V) (_ : not (@eq K k k')), @eq V (assoc_default (assoc_set l k' v) k d) (assoc_default l k d) *) intros. repeat break_match; auto; (* Goal: @eq (option V) (@Some V v) (@None V) *) rewrite get_set_diff in * by auto; congruence. Qed. Lemma get_set_same_default : forall (k : K) (v : V) l d, assoc_default (assoc_set l k v) k d = v. Proof using. (* Goal: @eq V (assoc_default (assoc_set l k' v) k d) (assoc_default l k d) *) unfold assoc_default. (* Goal: forall (l : list (prod K V)) (k : K) (v : V) (k' : K) (d : V) (_ : not (@eq K k k')), @eq V (assoc_default (assoc_set l k' v) k d) (assoc_default l k d) *) intros. repeat break_match; auto; (* Goal: @eq (option V) (@Some V v) (@None V) *) rewrite get_set_same in *; congruence. Qed. Lemma assoc_assoc_default: forall l k (v : V) d, assoc l k = Some v -> assoc_default l k d = v. Proof using. (* Goal: forall (l : list (prod K V)) (k : K) (v : V) (k' : K) (d : V) (_ : not (@eq K k k')), @eq V (assoc_default (assoc_set l k' v) k d) (assoc_default l k d) *) intros. unfold assoc_default. (* Goal: @eq (option V) (@Some V v) (@None V) *) break_match; congruence. Qed. Lemma assoc_assoc_default_missing: forall (l : list (K * V)) k d, assoc l k = None -> assoc_default l k d = d. Proof using. (* Goal: forall (l : list (prod K V)) (k : K) (v : V) (k' : K) (d : V) (_ : not (@eq K k k')), @eq V (assoc_default (assoc_set l k' v) k d) (assoc_default l k d) *) intros. unfold assoc_default. (* Goal: @eq (option V) (@Some V v) (@None V) *) break_match; congruence. Qed. Lemma assoc_set_same : forall (l : list (K * V)) k v, assoc l k = Some v -> assoc_set l k v = l. Proof using. (* Goal: forall (l : list (prod K V)) (k : K) (v : V) (k' : K) (d : V) (_ : not (@eq K k k')), @eq V (assoc_default (assoc_set l k' v) k d) (assoc_default l k d) *) intros. induction l; simpl in *; auto; try congruence. (* Goal: @eq (list (prod K V)) (let (k', v') := a in if K_eq_dec k k' then @cons (prod K V) (@pair K V k v) l else @cons (prod K V) (@pair K V k' v') (assoc_set l k v)) (@cons (prod K V) a l) *) repeat break_match; simpl in *; intuition. (* Goal: @eq (list (prod K V)) (@cons (prod K V) (@pair K V k v) l) (@cons (prod K V) (@pair K V k0 v0) l) *) - subst. find_inversion. auto. - repeat find_rewrite. auto. Qed. Lemma assoc_default_assoc_set : forall l (k : K) (v : V) d, assoc_default (assoc_set l k v) k d = v. Proof using. (* Goal: forall (l : list (prod K V)) (k : K) (v : V) (k' : K) (d : V) (_ : not (@eq K k k')), @eq V (assoc_default (assoc_set l k' v) k d) (assoc_default l k d) *) intros. unfold assoc_default. (* Goal: forall (l l' : list (prod K V)) (k : K) (_ : forall k0 : K, @eq (option V) (assoc l k0) (assoc l' k0)), @eq (option V) (assoc l k) (assoc l' k) *) rewrite get_set_same. auto. Qed. Lemma assoc_set_assoc_set_same : forall l (k : K) (v : V) v', assoc_set (assoc_set l k v) k v' = assoc_set l k v'. Proof using. induction l; intros; simpl in *; repeat break_match; simpl in *; subst; try congruence; eauto; (* Goal: @eq (option V) (@Some V v) (@None V) *) break_if; congruence. Qed. Definition a_equiv (l1 : list (K * V)) l2 := forall k, assoc l1 k = assoc l2 k. Lemma a_equiv_refl : forall l, a_equiv l l. Proof using. (* Goal: forall (l : list (prod K V)) (k : K) (v : V) (k' : K) (d : V) (_ : not (@eq K k k')), @eq V (assoc_default (assoc_set l k' v) k d) (assoc_default l k d) *) intros. unfold a_equiv. auto. Qed. Lemma a_equiv_sym : forall l l', a_equiv l l' -> a_equiv l' l. Proof using. (* Goal: forall (l : list (prod K V)) (k : K) (v : V) (k' : K) (d : V) (_ : not (@eq K k k')), @eq V (assoc_default (assoc_set l k' v) k d) (assoc_default l k d) *) unfold a_equiv. intros. auto. Qed. Lemma a_equiv_trans : forall l l' l'', a_equiv l l' -> a_equiv l' l'' -> a_equiv l l''. Proof using. (* Goal: @eq (list (prod K V)) (@cons (prod K V) p l) (@nil (prod K V)) *) unfold a_equiv in *. (* Goal: forall (l : list (prod K V)) (k : K) (v : V) (k' : K) (d : V) (_ : not (@eq K k k')), @eq V (assoc_default (assoc_set l k' v) k d) (assoc_default l k d) *) intros. repeat find_higher_order_rewrite. (* Goal: forall (l l' : list (prod K V)) (k : K) (_ : forall k0 : K, @eq (option V) (assoc l k0) (assoc l' k0)), @eq (option V) (assoc l k) (assoc l' k) *) auto. Qed. Ltac assoc_destruct := match goal with | [ |- context [assoc (assoc_set _ ?k0' _) ?k0 ] ] => destruct (K_eq_dec k0 k0'); [subst k0'; rewrite get_set_same with (k := k0)| rewrite get_set_diff with (k' := k0) by auto] end. Ltac assoc_rewrite := match goal with | [ |- context [assoc (assoc_set _ ?k0' _) ?k0 ] ] => first [rewrite get_set_same with (k := k0) by auto | rewrite get_set_diff with (k' := k0) by auto ] end. Lemma assoc_set_assoc_set_diff : forall l (k : K) (v : V) k' v', k <> k' -> a_equiv (assoc_set (assoc_set l k v) k' v') (assoc_set (assoc_set l k' v') k v). Proof using. (* Goal: forall (l l' : list (prod K V)) (k : K) (_ : a_equiv l l'), @eq (option V) (assoc l k) (assoc l' k) *) unfold a_equiv. (* Goal: forall (l : list (prod K V)) (k : K) (v : V) (k' : K) (d : V) (_ : not (@eq K k k')), @eq V (assoc_default (assoc_set l k' v) k d) (assoc_default l k d) *) intros. (* Goal: @eq (option V) (assoc (assoc_set l k v) k0) (assoc (assoc_set (assoc_set l k' v') k v) k0) *) assoc_destruct. - now repeat assoc_rewrite. - assoc_destruct. (* Goal: @eq (option V) (assoc l k0) (assoc (assoc_set (assoc_set l k' v') k v) k0) *) + now repeat assoc_rewrite. (* Goal: @eq (option V) (assoc l k0) (assoc (assoc_set (assoc_set l k' v') k v) k0) *) + now repeat assoc_rewrite. Qed. Lemma a_equiv_nil : forall l, a_equiv l [] -> l = []. Proof using. (* Goal: forall (l : list (prod K V)) (k : K) (v : V) (k' : K) (d : V) (_ : not (@eq K k k')), @eq V (assoc_default (assoc_set l k' v) k d) (assoc_default l k d) *) intros. (* Goal: forall (l l' : list (prod K V)) (k : K) (_ : forall k0 : K, @eq (option V) (assoc l k0) (assoc l' k0)), @eq (option V) (assoc l k) (assoc l' k) *) destruct l; auto. (* Goal: @eq (list (prod K V)) (@cons (prod K V) p l) (@nil (prod K V)) *) unfold a_equiv in *. simpl in *. (* Goal: @eq (list (prod K V)) (@cons (prod K V) p l) (@nil (prod K V)) *) destruct p. (* Goal: @eq (list (prod K V)) (@cons (prod K V) (@pair K V k v) l) (@nil (prod K V)) *) specialize (H k). (* Goal: @eq (option V) (@Some V v) (@None V) *) break_if; try congruence. Qed. Lemma assoc_set_a_equiv : forall l l' (k : K) (v : V), a_equiv l l' -> a_equiv (assoc_set l k v) (assoc_set l' k v). Proof using. (* Goal: forall (l l' : list (prod K V)) (k : K) (_ : a_equiv l l'), @eq (option V) (assoc l k) (assoc l' k) *) unfold a_equiv. (* Goal: forall (l : list (prod K V)) (k : K) (v : V) (k' : K) (d : V) (_ : not (@eq K k k')), @eq V (assoc_default (assoc_set l k' v) k d) (assoc_default l k d) *) intros. (* Goal: forall (l l' : list (prod K V)) (k : K) (_ : forall k0 : K, @eq (option V) (assoc l k0) (assoc l' k0)), @eq (option V) (assoc l k) (assoc l' k) *) assoc_destruct; assoc_rewrite; auto. Qed. Lemma assoc_default_a_equiv : forall l l' (k : K) (v : V), a_equiv l l' -> assoc_default l k v = assoc_default l' k v. Proof using. (* Goal: forall (l : list (prod K V)) (k : K) (v : V) (k' : K) (d : V) (_ : not (@eq K k k')), @eq V (assoc_default (assoc_set l k' v) k d) (assoc_default l k d) *) intros. unfold a_equiv, assoc_default in *. (* Goal: @eq V match assoc l k with | Some x => x | None => v end match assoc l' k with | Some x => x | None => v end *) find_higher_order_rewrite. (* Goal: forall (l l' : list (prod K V)) (k : K) (_ : forall k0 : K, @eq (option V) (assoc l k0) (assoc l' k0)), @eq (option V) (assoc l k) (assoc l' k) *) auto. Qed. Lemma assoc_a_equiv : forall l l' (k : K), a_equiv l l' -> assoc l k = assoc l' k. Proof using. (* Goal: forall (l l' : list (prod K V)) (k : K) (_ : a_equiv l l'), @eq (option V) (assoc l k) (assoc l' k) *) unfold a_equiv. (* Goal: forall (l l' : list (prod K V)) (k : K) (_ : forall k0 : K, @eq (option V) (assoc l k0) (assoc l' k0)), @eq (option V) (assoc l k) (assoc l' k) *) auto. Qed. Lemma assoc_default_assoc_set_diff : forall (l : list (K * V)) k v k' d, k <> k' -> assoc_default (assoc_set l k' v) k d = assoc_default l k d. Proof using. (* Goal: forall (l : list (prod K V)) (k : K) (v : V) (k' : K) (d : V) (_ : not (@eq K k k')), @eq V (assoc_default (assoc_set l k' v) k d) (assoc_default l k d) *) intros. unfold assoc_default. rewrite get_set_diff; auto. Qed. End assoc. Arguments a_equiv {_} {_} _ _ _.
Require Import List. Import ListNotations. Require Import StructTact.StructTactics. Require Import StructTact.ListTactics. Fixpoint before_all {A : Type} (x : A) y l : Prop := match l with | [] => True | a :: l' => ~ In x l' \/ (y <> a /\ before_all x y l') end. Section before_all. Variable A : Type. Lemma before_all_head_not_in : forall l (x y : A), x <> y -> before_all x y (y :: l) -> ~ In x l. Proof using. (* Goal: forall (x y : A) (_ : not (@In A y (@cons A a l))), @before_all A x y (@cons A a l) *) intros. (* Goal: @before_all A x y (@cons A a l) *) simpl in *. (* Goal: False *) break_or_hyp; auto. (* Goal: or (not (@In A x (@app A l (@cons A a0 (@nil A))))) (and (not (@eq A y a)) (@before_all A x y (@app A l (@cons A a0 (@nil A))))) *) break_and. auto. Qed. Lemma before_all_neq_append : forall l (x y a : A), a <> x -> before_all x y l -> before_all x y (l ++ [a]). Proof using. (* Goal: forall (l : list A) (x y : A) (_ : not (@In A y l)), @before_all A x y l *) induction l. (* Goal: True *) - intros; left; auto. - intros; (* Goal: @before_all A x y (@cons A a l) *) simpl in *. (* Goal: or (not (@In A x (@app A l (@cons A a0 (@nil A))))) (and (not (@eq A y a)) (@before_all A x y (@app A l (@cons A a0 (@nil A))))) *) break_or_hyp. * left. (* Goal: not (@In A x (@app A l (@cons A a0 (@nil A)))) *) intro H_in. (* Goal: False *) do_in_app. (* Goal: False *) break_or_hyp; auto. (* Goal: @before_all A x y (@cons A a l) *) simpl in *. (* Goal: False *) break_or_hyp; auto. (* Goal: or (not (@In A x (@app A l (@cons A a0 (@nil A))))) (and (not (@eq A y a)) (@before_all A x y (@app A l (@cons A a0 (@nil A))))) *) * break_and. (* Goal: or (not (@In A x (@app A l (@cons A a0 (@nil A))))) (and (not (@eq A y a)) (@before_all A x y (@app A l (@cons A a0 (@nil A))))) *) right. (* Goal: True *) split; auto. Qed. Lemma before_all_not_in_1 : forall l (x y : A), ~ In x l -> before_all x y l. Proof using. (* Goal: forall (x y : A) (_ : not (@In A y (@cons A a l))), @before_all A x y (@cons A a l) *) intros. (* Goal: True *) destruct l; simpl in *; auto. Qed. Lemma before_all_not_in_2 : forall l (x y : A), ~ In y l -> before_all x y l. Proof using. (* Goal: forall (l : list A) (x y : A) (_ : not (@In A y l)), @before_all A x y l *) induction l. (* Goal: forall (x y : A) (_ : not (@In A y (@cons A a l))), @before_all A x y (@cons A a l) *) - intros. simpl in *. auto. (* Goal: forall (x y : A) (_ : not (@In A y (@cons A a l))), @before_all A x y (@cons A a l) *) - intros. simpl in *. (* Goal: True *) assert (H_neq: y <> a); auto. (* Goal: True *) assert (H_in: ~ In y l); auto. Qed. End before_all.
(* This program is free software; you can redistribute it and/or *) (* modify it under the terms of the GNU Lesser General Public License *) (* as published by the Free Software Foundation; either version 2.1 *) (* of the License, or (at your option) any later version. *) (* *) (* This program is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* GNU General Public License for more details. *) (* *) (* You should have received a copy of the GNU Lesser General Public *) (* License along with this program; if not, write to the Free *) (* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *) (* 02110-1301 USA *) (* (C) Pierre Castéran , LaBRI, Universite Bordeaux 1, Inria Futurs Dictionaries (after Paulson : ML for the working programmer) *) Require Import Relations. Require Import List. Set Asymmetric Patterns. Unset Standard Proposition Elimination Names. (* Dictionaries : a dictionary is roughly a partial maping from keys to values *) Module Type DICT. Parameter key : Set. Parameter data : Set. (* data associated with keys *) Parameter dict : Set. (* the type associated with dictionaries *) Parameter empty : dict. (* dictionary without any entry *) Parameter add : key -> data -> dict -> dict. (* add an entry to a dictionary *) Parameter find : key -> dict -> option data. (* get the value from the key *) (* relationships between find, add and empty *) Axiom empty_def : forall k : key, find k empty = None. Axiom success : forall (d : dict) (k : key) (v : data), find k (add k v d) = Some v. Axiom diff_key : forall (d : dict) (k k' : key) (v : data), k <> k' -> find k (add k' v d) = find k d. End DICT. (* building a dictionary from a list of entries *) Module Type DICT_PLUS. Declare Module Dict : DICT. Parameter build : list (Dict.key * Dict.data) -> Dict.dict. End DICT_PLUS. Module Dict_Plus (D: DICT) : DICT_PLUS with Module Dict := D. Module Dict := D. Definition key := D.key. Definition data := D.data. Definition dict := D.dict. Definition add := D.add. Definition empty := D.empty. Fixpoint addlist (l : list (key * data)) : dict -> dict := fun d : dict => match l with | nil => d | p :: l' => match p with | (k, v) => addlist l' (add k v d) end end. Definition build (l : list (key * data)) := addlist l empty. End Dict_Plus. (* keys for dictionaries We just need a data type on which Leibniz equality is decidable *) Module Type KEY. Parameter A : Set. Parameter eqdec : forall a b : A, {a = b} + {a <> b}. End KEY. Module LKey (K: KEY) : KEY with Definition A := list K.A. Definition A := list K.A. Definition eqdec : forall a b : A, {a = b} + {a <> b}. (* Goal: forall a b : A, sumbool (@eq A a b) (not (@eq A a b)) *) intro a; elim a. (* Goal: None *) (* Goal: None *) simple induction b; [ left; auto | right; red in |- *; discriminate 1 ]. (* Goal: None *) intros a0 k Ha; simple induction b. (* Goal: None *) (* Goal: None *) right; red in |- *; discriminate 1. (* Goal: None *) intros a1 l0 s; case (K.eqdec a0 a1); intro H0. (* Goal: None *) (* Goal: None *) case (Ha l0); intro H1. (* Goal: None *) (* Goal: None *) (* Goal: None *) left; rewrite H1; rewrite H0; auto. (* Goal: None *) right; red in |- *; injection 1. (* Goal: None *) (* Goal: None *) intro H3; case (H1 H3). (* Goal: None *) right; red in |- *; injection 1. (* Goal: None *) intros H3 H4; case (H0 H4). Defined. End LKey. Require Import ZArith. Module ZKey : KEY with Definition A := Z. Definition A := Z. Definition eqdec := Z_eq_dec. End ZKey. Module LZKey := LKey ZKey. (* Check (LZKey.eqdec (cons `7` (nil ?)) (cons `3+4` (nil ?))). *) (* pairs of keys *) Module PairKey (K1: KEY) (K2: KEY) : KEY with Definition A := (K1.A * K2.A)%type. Definition A := (K1.A * K2.A)%type. Definition eqdec : forall a b : A, {a = b} + {a <> b}. simple destruct a. intros a0 a1; simple destruct b; intros b0 b1. case (K1.eqdec a0 b0); intro H; case (K2.eqdec a1 b1); intro H0; [ left | right | right | right ]; try (rewrite H; rewrite H0; trivial); (* Goal: forall _ : occ v k x0, occ v k x0 *) red in |- *; intro H1; injection H1; tauto. Defined. End PairKey. (* Total decidable orders *) Module Type DEC_ORDER. Parameter A : Set. Parameter le : A -> A -> Prop. Parameter lt : A -> A -> Prop. Axiom ordered : order A le. Axiom lt_le_weak : forall a b : A, lt a b -> le a b. Axiom lt_diff : forall a b : A, lt a b -> a <> b. Axiom le_lt_or_eq : forall a b : A, le a b -> lt a b \/ a = b. Parameter lt_eq_lt_dec : forall a b : A, {lt a b} + {a = b} + {lt b a}. End DEC_ORDER. (* some derived theorems on dec_orders *) Module Type MORE_DEC_ORDERS. Parameter A : Set. Parameter le : A -> A -> Prop. Parameter lt : A -> A -> Prop. Axiom le_trans : transitive A le. Axiom le_refl : reflexive A le. Axiom le_antisym : antisymmetric A le. Axiom lt_irreflexive : forall a : A, ~ lt a a. Axiom lt_trans : transitive A lt. Axiom lt_not_le : forall a b : A, lt a b -> ~ le b a. Axiom le_not_lt : forall a b : A, le a b -> ~ lt b a. Axiom lt_intro : forall a b : A, le a b -> a <> b -> lt a b. Parameter le_lt_dec : forall a b : A, {le a b} + {lt b a}. Parameter le_lt_eq_dec : forall a b : A, le a b -> {lt a b} + {a = b}. End MORE_DEC_ORDERS. (* A functor for getting some useful derived properties on decidable orders *) Module More_Dec_Orders (D: DEC_ORDER) : MORE_DEC_ORDERS with Definition A := D.A with Definition le := D.le with Definition lt := D.lt. Definition A := D.A. Definition le := D.le. Definition lt := D.lt. Theorem le_trans : transitive A le. Proof. (* Goal: antisymmetric A le *) case D.ordered; auto. Qed. Theorem le_refl : reflexive A le. Proof. (* Goal: antisymmetric A le *) case D.ordered; auto. Qed. Theorem le_antisym : antisymmetric A le. Proof. (* Goal: antisymmetric A le *) case D.ordered; auto. Qed. Theorem lt_intro : forall a b : A, le a b -> a <> b -> lt a b. Proof. (* Goal: forall (a b : A) (_ : le a b) (_ : not (@eq A a b)), lt a b *) intros a b H diff; case (D.le_lt_or_eq a b H); tauto. Qed. Theorem lt_irreflexive : forall a : A, ~ lt a a. Proof. (* Goal: forall a : A, not (lt a a) *) intros a H. (* Goal: False *) case (D.lt_diff _ _ H); trivial. Qed. Theorem lt_not_le : forall a b : A, lt a b -> ~ le b a. Proof. (* Goal: forall (a b : A) (_ : lt a b), not (le b a) *) intros a b H H0. (* Goal: False *) absurd (a = b). (* Goal: not (@eq A a b) *) (* Goal: @eq A a b *) apply D.lt_diff; trivial. (* Goal: @eq A a b *) apply le_antisym; auto; apply D.lt_le_weak; assumption. Qed. Theorem le_not_lt : forall a b : A, le a b -> ~ lt b a. Proof. (* Goal: forall (a b : A) (_ : le a b), not (lt b a) *) intros a b H H0; apply (lt_not_le b a); auto. Qed. Theorem lt_trans : transitive A lt. Proof. (* Goal: transitive A lt *) unfold A, transitive in |- *. (* Goal: None *) intros x y z H H0. (* Goal: lt x z *) apply (lt_intro x z). (* Goal: le x z *) (* Goal: not (@eq A x z) *) apply le_trans with y; apply D.lt_le_weak; assumption. (* Goal: not (@eq A x z) *) intro e; rewrite e in H. (* Goal: False *) absurd (y = z). (* Goal: None *) (* Goal: None *) intro e'; rewrite e' in H. (* Goal: False *) (* Goal: None *) apply (lt_irreflexive _ H). (* Goal: None *) apply le_antisym; apply D.lt_le_weak; trivial. Qed. Definition le_lt_dec : forall a b : A, {le a b} + {lt b a}. (* Goal: forall a b : A, sumbool (le a b) (lt b a) *) intros a b; case (D.lt_eq_lt_dec a b). (* Goal: None *) (* Goal: None *) intro d; case d; auto. (* Goal: None *) (* Goal: None *) (* Goal: None *) left; apply D.lt_le_weak; trivial. (* Goal: None *) (* Goal: None *) simple induction 1; left; apply le_refl. (* Goal: None *) right; trivial. Defined. Definition le_lt_eq_dec : forall a b : A, le a b -> {lt a b} + {a = b}. (* Goal: forall (a b : A) (_ : le a b), sumbool (lt a b) (@eq A a b) *) intros a b H. (* Goal: sumbool (lt a b) (@eq A a b) *) case (D.lt_eq_lt_dec a b). (* Goal: None *) (* Goal: None *) trivial. (* Goal: None *) intro H0; case (le_not_lt a b H H0). Defined. End More_Dec_Orders. (* the forgetful functor ! *) Module Forget_Order (D: DEC_ORDER) : KEY with Definition A := D.A. Module M := More_Dec_Orders D. Definition A := D.A. Definition eqdec : forall a b : A, {a = b} + {a <> b}. (* Goal: forall a b : A, sumbool (le a b) (lt b a) *) intros a b; case (D.lt_eq_lt_dec a b). intro H; case H. right; apply D.lt_diff; auto. (* Goal: None *) (* Goal: None *) left; trivial. intro d; right. intro e; rewrite e in d. apply (M.lt_irreflexive b); auto. Defined. End Forget_Order. (* Lexicographic ordering *) Module Lexico (D1: DEC_ORDER) (D2: DEC_ORDER) <: DEC_ORDER with Definition A := (D1.A * D2.A)%type. Module M1 := More_Dec_Orders D1. Module M2 := More_Dec_Orders D2. Definition A := (D1.A * D2.A)%type. Definition le (a b : A) : Prop := let (a1, a2) := a in let (b1, b2) := b in D1.lt a1 b1 \/ a1 = b1 /\ D2.le a2 b2. Definition lt (a b : A) : Prop := let (a1, a2) := a in let (b1, b2) := b in D1.lt a1 b1 \/ a1 = b1 /\ D2.lt a2 b2. Theorem ordered : order A le. Proof. (* Goal: forall (n : key) (v v' : data) (t1 t2 : btree) (_ : search_tree (bnode n v t1 t2)), INSERT n v' (bnode n v t1 t2) (bnode n v' t1 t2) *) split. unfold reflexive in |- *; intros. unfold le in |- *; case x. (* Goal: forall _ : forall v : data, not (occ v p t2), sumor (@sig data (fun v0 : data => occ v0 p (bnode n v t1 t2))) (forall v0 : data, not (occ v0 p (bnode n v t1 t2))) *) right. split; [ trivial | apply M2.le_refl; auto ]. unfold le, transitive in |- *. simple destruct x; simple destruct y; simple destruct z. simple destruct 1; intro H1. (* Goal: forall (x0 : btree) (_ : INSERT k v x x0), occ v k x0 *) simple destruct 1. (* Goal: search_tree leaf *) left. eapply M1.lt_trans. eexact H1. (* Goal: None *) assumption. (* Goal: forall (x0 : btree) (_ : INSERT k v x x0), occ v k x0 *) simple destruct 1. (* Goal: forall (x0 : btree) (_ : INSERT k v x x0), occ v k x0 *) simple destruct 1. (* Goal: forall _ : occ v k x0, occ v k x0 *) auto. (* Goal: forall (x0 : btree) (_ : INSERT k v x x0), occ v k x0 *) simple destruct 1. (* Goal: None *) (* Goal: None *) intro. (* Goal: forall _ : occ v k x0, occ v k x0 *) case H1; intros e H3; rewrite e; auto. (* Goal: forall _ : occ v k x0, occ v k x0 *) case H1; intros e H3; rewrite e; auto. (* Goal: forall (x0 : btree) (_ : INSERT k v x x0), occ v k x0 *) simple destruct 1. (* Goal: forall (x0 : btree) (_ : INSERT k v x x0), occ v k x0 *) simple destruct 1. (* Goal: forall _ : forall v : data, not (occ v p t2), sumor (@sig data (fun v0 : data => occ v0 p (bnode n v t1 t2))) (forall v0 : data, not (occ v0 p (bnode n v t1 t2))) *) right. (* Goal: forall _ : occ v k x0, occ v k x0 *) split; try auto. (* Goal: forall _ : occ v k x0, occ v k x0 *) eapply M2.le_trans; eauto. unfold antisymmetric, A, le in |- *. simple destruct x; simple destruct y. simple destruct 1; simple destruct 2. (* Goal: None *) (* Goal: None *) intro. absurd (D1.lt a1 a1). apply M1.lt_irreflexive. (* Goal: forall _ : occ v k x0, occ v k x0 *) eapply M1.lt_trans; eauto. simple destruct 1; intros e H3. rewrite e in H0. case (M1.lt_irreflexive a H0). case H0; intros e H3. rewrite e; intro H2. case (M1.lt_irreflexive a1 H2). simple destruct 1; intros e H3; rewrite e. case (M2.le_antisym a2 a0). (* Goal: forall _ : occ v k x0, occ v k x0 *) auto. (* Goal: forall _ : occ v k x0, occ v k x0 *) case H0; auto. (* Goal: forall _ : occ v k x0, occ v k x0 *) auto. Qed. Theorem lt_le_weak : forall a b : A, lt a b -> le a b. Proof. (* Goal: forall (a b : A) (_ : le a b), or (lt a b) (@eq A a b) *) unfold A, lt, le in |- *; intros a b; case a; case b. (* Goal: forall _ : occ v k x0, occ v k x0 *) simple destruct 1; intros; auto. (* Goal: forall _ : occ v k x0, occ v k x0 *) right; case H0; split; auto. (* Goal: None *) (* Goal: None *) apply D2.lt_le_weak; trivial. Qed. Theorem lt_diff : forall a b : A, lt a b -> a <> b. Proof. (* Goal: forall (a b : A) (_ : le a b), or (lt a b) (@eq A a b) *) unfold A, lt, le in |- *; intros a b; case a; case b. (* Goal: forall (x0 : btree) (_ : INSERT k v x x0), occ v k x0 *) simple destruct 1. (* Goal: None *) (* Goal: None *) intro H0; red in |- *; injection 1. (* Goal: None *) (* Goal: None *) intros e1 e2; rewrite e2 in H0. (* Goal: False *) (* Goal: None *) case (M1.lt_irreflexive a0 H0). (* Goal: forall (x0 : btree) (_ : INSERT k v x x0), occ v k x0 *) simple destruct 1. (* Goal: forall (x0 : btree) (_ : INSERT k v x x0), occ v k x0 *) simple destruct 1. (* Goal: None *) intro H2; red in |- *; injection 1. (* Goal: None *) intro e; rewrite e in H2; case (M2.lt_irreflexive _ H2). Qed. Theorem le_lt_or_eq : forall a b : A, le a b -> lt a b \/ a = b. Proof. (* Goal: forall (a b : A) (_ : le a b), or (lt a b) (@eq A a b) *) unfold A, lt, le in |- *; intros a b; case a; case b. (* Goal: forall _ : occ v k x0, occ v k x0 *) simple destruct 1; auto. (* Goal: forall (x0 : btree) (_ : INSERT k v x x0), occ v k x0 *) simple destruct 1. (* Goal: forall (x0 : btree) (_ : INSERT k v x x0), occ v k x0 *) simple destruct 1. (* Goal: None *) intro H2; case (D2.le_lt_or_eq _ _ H2). (* Goal: forall _ : occ v k x0, occ v k x0 *) auto. (* Goal: forall (x0 : btree) (_ : INSERT k v x x0), occ v k x0 *) simple destruct 1. (* Goal: forall _ : occ v k x0, occ v k x0 *) auto. Qed. Definition lt_eq_lt_dec : forall a b : A, {lt a b} + {a = b} + {lt b a}. Proof. (* Goal: forall a b : A, sumor (sumbool (lt a b) (@eq A a b)) (lt b a) *) unfold A, lt in |- *; intros. (* Goal: None *) case a; case b. (* Goal: None *) intros a0 a1 a2 a3. (* Goal: None *) case (D1.lt_eq_lt_dec a0 a2). (* Goal: forall (x0 : btree) (_ : INSERT k v x x0), occ v k x0 *) simple destruct 1. (* Goal: forall _ : forall v : data, not (occ v p t2), sumor (@sig data (fun v0 : data => occ v0 p (bnode n v t1 t2))) (forall v0 : data, not (occ v0 p (bnode n v t1 t2))) *) right. (* Goal: forall _ : occ v k x0, occ v k x0 *) auto. (* Goal: forall (x0 : btree) (_ : INSERT k v x x0), occ v k x0 *) simple destruct 1. (* Goal: None *) (* Goal: None *) case (D2.lt_eq_lt_dec a1 a3). (* Goal: forall (x0 : btree) (_ : INSERT k v x x0), occ v k x0 *) simple destruct 1. (* Goal: forall _ : forall v : data, not (occ v p t2), sumor (@sig data (fun v0 : data => occ v0 p (bnode n v t1 t2))) (forall v0 : data, not (occ v0 p (bnode n v t1 t2))) *) right. (* Goal: forall _ : occ v k x0, occ v k x0 *) auto. (* Goal: forall (x0 : btree) (_ : INSERT k v x x0), occ v k x0 *) simple destruct 1. (* Goal: None *) left; right; trivial. (* Goal: forall _ : occ v k x0, occ v k x0 *) left; left; auto. (* Goal: search_tree leaf *) left. (* Goal: forall _ : occ v k x0, occ v k x0 *) left; auto. Defined. End Lexico. (* order on disjoint sums *) Module Sum_Order (O1: DEC_ORDER) (O2: DEC_ORDER) <: DEC_ORDER with Definition A := (O1.A + O2.A)%type. Definition A := (O1.A + O2.A)%type. Definition le (a b : A) : Prop := match a with | inl a' => match b with | inl b' => O1.le a' b' | _ => True end | inr a' => match b with | inr b' => O2.le a' b' | _ => False end end. Definition lt (a b : A) : Prop := match a with | inl a' => match b with | inl b' => O1.lt a' b' | _ => True end | inr a' => match b with | inr b' => O2.lt a' b' | _ => False end end. Module M1 := More_Dec_Orders O1. Module M2 := More_Dec_Orders O2. Theorem ordered : order A le. Proof. (* Goal: forall (n : key) (v v' : data) (t1 t2 : btree) (_ : search_tree (bnode n v t1 t2)), INSERT n v' (bnode n v t1 t2) (bnode n v' t1 t2) *) split. unfold reflexive in |- *; intros. unfold le in |- *. case x. exact M1.le_refl. exact M2.le_refl. unfold le in |- *. unfold transitive in |- *. simple destruct x; simple destruct y; simple destruct z. (* Goal: forall _ : occ v k x0, occ v k x0 *) intros; eapply M1.le_trans; eauto. (* Goal: forall _ : occ v k x0, occ v k x0 *) auto. contradiction. (* Goal: forall _ : occ v k x0, occ v k x0 *) auto. (* Goal: forall _ : occ v k x0, occ v k x0 *) auto. contradiction. (* Goal: forall _ : occ v k x0, occ v k x0 *) auto. (* Goal: forall _ : occ v k x0, occ v k x0 *) intros; eapply M2.le_trans; eauto. unfold antisymmetric, A, le in |- *. simple destruct x; simple destruct y. intros a0 H0 H1; rewrite (M1.le_antisym _ _ H0 H1). (* Goal: None *) (* Goal: None *) trivial. contradiction. contradiction. intros a0 H0 H1; rewrite (M2.le_antisym _ _ H0 H1). (* Goal: None *) (* Goal: None *) trivial. Qed. Theorem lt_le_weak : forall a b : A, lt a b -> le a b. Proof. unfold A, lt, le in |- *; intros a b. (* Goal: forall _ : occ v k x0, occ v k x0 *) case a; case b; auto. (* Goal: None *) (* Goal: None *) intros; apply O1.lt_le_weak; trivial. (* Goal: None *) (* Goal: None *) intros; apply O2.lt_le_weak; trivial. Qed. Theorem lt_diff : forall a b : A, lt a b -> a <> b. Proof. unfold lt in |- *; simple destruct a; simple destruct b. intros a1 H e; injection e; intro e'. case (O1.lt_diff _ _ H e'). intros a1 H e; discriminate e. contradiction. intros a1 H e; injection e; intro e'. case (O2.lt_diff _ _ H e'). Qed. Theorem le_lt_or_eq : forall a b : A, le a b -> lt a b \/ a = b. Proof. (* Goal: forall (a b : A) (_ : le a b), or (lt a b) (@eq A a b) *) unfold A, lt, le in |- *; intros a b; case a; case b. intros a0 a1 H; case (O1.le_lt_or_eq a1 a0 H). (* Goal: forall _ : occ v k x0, occ v k x0 *) auto. (* Goal: forall _ : occ v k x0, occ v k x0 *) simple destruct 1; auto. (* Goal: forall _ : occ v k x0, occ v k x0 *) auto. contradiction. (* Goal: forall _ : occ v k x0, occ v k x0 *) intros a0 a1 H; case (O2.le_lt_or_eq a1 a0 H); auto. (* Goal: forall _ : occ v k x0, occ v k x0 *) simple destruct 1; auto. Qed. Definition lt_eq_lt_dec : forall a b : A, {lt a b} + {a = b} + {lt b a}. (* Goal: forall a b : A, sumor (sumbool (lt a b) (@eq A a b)) (lt b a) *) unfold A, lt in |- *; intros. (* Goal: None *) case a; case b. intros a0 a1. case (O1.lt_eq_lt_dec a0 a1). (* Goal: forall (x0 : btree) (_ : INSERT k v x x0), occ v k x0 *) simple destruct 1. (* Goal: forall _ : forall v : data, not (occ v p t2), sumor (@sig data (fun v0 : data => occ v0 p (bnode n v t1 t2))) (forall v0 : data, not (occ v0 p (bnode n v t1 t2))) *) right. (* Goal: forall _ : occ v k x0, occ v k x0 *) auto. (* Goal: forall (x0 : btree) (_ : INSERT k v x x0), occ v k x0 *) simple destruct 1. (* Goal: search_tree leaf *) left. (* Goal: forall _ : forall v : data, not (occ v p t2), sumor (@sig data (fun v0 : data => occ v0 p (bnode n v t1 t2))) (forall v0 : data, not (occ v0 p (bnode n v t1 t2))) *) right. (* Goal: None *) (* Goal: None *) trivial. (* Goal: search_tree leaf *) left. (* Goal: search_tree leaf *) left. (* Goal: None *) (* Goal: None *) trivial. (* Goal: None *) (* Goal: None *) left; trivial. (* Goal: None *) (* Goal: None *) left; trivial. (* Goal: forall _ : forall v : data, not (occ v p t2), sumor (@sig data (fun v0 : data => occ v0 p (bnode n v t1 t2))) (forall v0 : data, not (occ v0 p (bnode n v t1 t2))) *) right. (* Goal: forall _ : occ v k x0, occ v k x0 *) auto. intros a0 a1. case (O2.lt_eq_lt_dec a0 a1). (* Goal: forall (x0 : btree) (_ : INSERT k v x x0), occ v k x0 *) simple destruct 1. (* Goal: forall _ : forall v : data, not (occ v p t2), sumor (@sig data (fun v0 : data => occ v0 p (bnode n v t1 t2))) (forall v0 : data, not (occ v0 p (bnode n v t1 t2))) *) right. (* Goal: forall _ : occ v k x0, occ v k x0 *) auto. (* Goal: forall (x0 : btree) (_ : INSERT k v x x0), occ v k x0 *) simple destruct 1. (* Goal: search_tree leaf *) left. (* Goal: forall _ : forall v : data, not (occ v p t2), sumor (@sig data (fun v0 : data => occ v0 p (bnode n v t1 t2))) (forall v0 : data, not (occ v0 p (bnode n v t1 t2))) *) right. (* Goal: None *) (* Goal: None *) trivial. (* Goal: search_tree leaf *) left. (* Goal: search_tree leaf *) left. (* Goal: None *) (* Goal: None *) trivial. Defined. End Sum_Order. Require Import Arith. Module Nat_Order : DEC_ORDER with Definition A := nat with Definition le := le with Definition lt := lt. Definition A := nat. Definition le := le. Definition lt := lt. Theorem ordered : order A le. Proof. (* Goal: forall (n : key) (v v' : data) (t1 t2 : btree) (_ : search_tree (bnode n v t1 t2)), INSERT n v' (bnode n v t1 t2) (bnode n v' t1 t2) *) split. unfold A, le, reflexive in |- *; auto with arith. unfold A, le, transitive in |- *; eauto with arith. unfold A, le, antisymmetric in |- *; eauto with arith. Qed. Theorem lt_le_weak : forall a b : A, lt a b -> le a b. Proof. unfold A in |- *; exact lt_le_weak. Qed. Theorem lt_diff : forall a b : A, lt a b -> a <> b. Proof. unfold A, lt, le in |- *; intros a b H e. rewrite e in H. case (lt_irrefl b H). Qed. Theorem le_lt_or_eq : forall a b : A, le a b -> lt a b \/ a = b. Proof. unfold A, le, lt in |- *. exact le_lt_or_eq. Qed. Definition lt_eq_lt_dec : forall a b : A, {lt a b} + {a = b} + {lt b a} := lt_eq_lt_dec. End Nat_Order. (* the natural order on booleans ( false < true ) *) Definition bool_le (b b' : bool) := if b then if b' then True else False else True. Definition bool_lt (b b' : bool) := if b then False else if b' then True else False. Module Bool_Order : DEC_ORDER with Definition A := bool with Definition le := bool_le with Definition lt := bool_lt. Definition A := bool. Definition le := bool_le. Definition lt := bool_lt. Theorem ordered : order A le. Proof. (* Goal: forall (n : key) (v v' : data) (t1 t2 : btree) (_ : search_tree (bnode n v t1 t2)), INSERT n v' (bnode n v t1 t2) (bnode n v' t1 t2) *) split. unfold A, le, reflexive in |- *. (* Goal: forall _ : occ v k x0, occ v k x0 *) intro x; case x; simpl in |- *; auto. unfold A, le, transitive in |- *; simple destruct x; simple destruct y; (* Goal: forall _ : occ v k x0, occ v k x0 *) auto; simple destruct z; auto. unfold A, le, antisymmetric in |- *; simple destruct x; simple destruct y; simpl in |- *; auto; contradiction. Qed. Theorem lt_le_weak : forall a b : A, lt a b -> le a b. Proof. unfold A, lt, le in |- *; simple destruct a; simple destruct b; (* Goal: forall _ : occ v k x0, occ v k x0 *) simpl in |- *; tauto. Qed. Theorem lt_diff : forall a b : A, lt a b -> a <> b. Proof. (* Goal: forall _ : occ v k x0, occ v k x0 *) unfold A, lt, bool_lt in |- *; simple destruct a; simple destruct b; auto. Qed. Theorem le_lt_or_eq : forall a b : A, le a b -> lt a b \/ a = b. Proof. unfold A, le, lt, bool_lt in |- *; simple destruct a; simple destruct b; (* Goal: forall _ : occ v k x0, occ v k x0 *) auto. Qed. Definition lt_eq_lt_dec : forall a b : A, {lt a b} + {a = b} + {lt b a}. unfold A, le, lt, bool_lt in |- *; simple destruct a; simple destruct b; (* Goal: forall _ : occ v k x0, occ v k x0 *) auto. Defined. End Bool_Order. (* This module type specifies the domain of values returned by consulting a dictionary ; it is supposed to be an argument of any functor building an implementation for dictionaries *) Module Type DATA. Parameter data : Set. End DATA. (* A simple implementation of dictionaries : the dictionary IS the (partial) function from keys to values This implementation is clearly inefficient, but since it is trivially correct ; during the building of a modular program, such trivial correct implementations of module types may be very useful during the development steps of an application *) Module TrivialDict (Key: KEY) (Val: DATA) : DICT with Definition key := Key.A with Definition data := Val.data. Definition key := Key.A. Definition data := Val.data. Definition dict := key -> option data. Definition empty (k : key) := None (A:=data). Definition find (k : key) (d : dict) := d k. Definition add (k : key) (v : data) (d : dict) : dict := fun k' : key => match Key.eqdec k' k with | left _ => Some v | right _ => d k' end. Theorem empty_def : forall k : key, find k empty = None. Proof. (* Goal: forall _ : occ v k x0, occ v k x0 *) unfold find, empty in |- *; auto. Qed. Theorem success : forall (d : dict) (k : key) (v : data), find k (add k v d) = Some v. Proof. (* Goal: forall (d : dict) (k : key) (v : data), @eq (option data) (find k (add k v d)) (@Some data v) *) unfold find, add in |- *; intros d k v. (* Goal: forall _ : occ v k x0, occ v k x0 *) case (Key.eqdec k k); simpl in |- *; tauto. Qed. Theorem diff_key : forall (d : dict) (k k' : key) (v : data), k <> k' -> find k (add k' v d) = find k d. Proof. (* Goal: forall (d : dict) (k k' : key) (v : data) (_ : not (@eq key k k')), @eq (option data) (find k (add k' v d)) (find k d) *) unfold find, add in |- *; intros d k k' v. (* Goal: forall _ : occ v k x0, occ v k x0 *) case (Key.eqdec k k'); simpl in |- *; tauto. Qed. End TrivialDict. (* dictionaries based on searchtrees we require a total decidable order on keys *) Module TDict (Key: DEC_ORDER) (Val: DATA) : DICT with Definition key := Key.A with Definition data := Val.data. Definition key := Key.A. Definition data := Val.data. Module M := More_Dec_Orders Key. (* search trees definitions and properties *) (* the underlying data structure : binary trees labeled with keys and associated values *) Inductive btree : Set := | leaf : btree | bnode : key -> data -> btree -> btree -> btree. (* The entry with key k and value v occurs in the binary tree t *) Inductive occ (v : data) (k : key) : btree -> Prop := | occ_root : forall t1 t2 : btree, occ v k (bnode k v t1 t2) | occ_l : forall (k' : key) (v' : data) (t1 t2 : btree), occ v k t1 -> occ v k (bnode k' v' t1 t2) | occ_r : forall (k' : key) (v' : data) (t1 t2 : btree), occ v k t2 -> occ v k (bnode k' v' t1 t2). (* key k is less than every key in t *) Inductive min (k : key) (t : btree) : Prop := min_intro : (forall (k' : key) (v : data), occ v k' t -> Key.lt k k') -> min k t. Hint Resolve min_intro: searchtrees. (* key k is gretaer than every key in t *) Inductive maj (k : key) (t : btree) : Prop := maj_intro : (forall (k' : key) (v : data), occ v k' t -> Key.lt k' k) -> maj k t. Hint Resolve maj_intro: searchtrees. (* searchness predicate on binary trees *) Inductive search_tree : btree -> Prop := | leaf_search_tree : search_tree leaf | bnode_search_tree : forall (k : key) (v : data) (t1 t2 : btree), search_tree t1 -> search_tree t2 -> maj k t1 -> min k t2 -> search_tree (bnode k v t1 t2). Inductive is_bnode : btree -> Prop := is_bnode_intro : forall (k : key) (v : data) (t1 t2 : btree), is_bnode (bnode k v t1 t2). Hint Resolve is_bnode_intro: searchtrees. Hint Resolve occ_root occ_l occ_r: searchtrees. Derive Inversion_clear OCC_INV with (forall (k k' : key) (v v' : data) (t1 t2 : btree), occ v' k' (bnode k v t1 t2)). Lemma occ_inv : forall (k k' : key) (v v' : data) (t1 t2 : btree), occ v' k' (bnode k v t1 t2) -> k = k' /\ v = v' \/ occ v' k' t1 \/ occ v' k' t2. Proof. (* Goal: forall (k k' : key) (v v' : data) (t1 t2 : btree) (_ : occ v' k' (bnode k v t1 t2)), or (and (@eq key k k') (@eq data v v')) (or (occ v' k' t1) (occ v' k' t2)) *) intros k k' v v' t1 t2 H. (* Goal: or (and (@eq key k k') (@eq data v v')) (or (occ v' k' t1) (occ v' k' t2)) *) inversion H using OCC_INV; auto with searchtrees. Qed. Hint Resolve occ_inv: searchtrees. Lemma not_occ_Leaf : forall (k : key) (v : data), ~ occ v k leaf. Proof. (* Goal: forall (k : key) (v : data), not (occ v k leaf) *) unfold not in |- *; intros k v H. (* Goal: False *) inversion_clear H. Qed. Hint Resolve not_occ_Leaf: searchtrees. Hint Resolve leaf_search_tree bnode_search_tree: searchtrees. Lemma min_leaf : forall k : key, min k leaf. Proof. (* Goal: None *) (* Goal: None *) intro k; apply min_intro. (* Goal: None *) inversion_clear 1. Qed. Hint Resolve min_leaf: searchtrees. Lemma maj_leaf : forall k : key, maj k leaf. Proof. (* Goal: None *) intro k; apply maj_intro; inversion_clear 1. Qed. Hint Resolve maj_leaf: searchtrees. Lemma maj_not_occ : forall (k : key) (v : data) (t : btree), maj k t -> ~ occ v k t. Proof. (* Goal: forall (k : key) (v : data) (t : btree) (_ : min k t), not (occ v k t) *) unfold not in |- *; intros k v t H H'. (* Goal: forall _ : occ v k x0, occ v k x0 *) elim H; intros; absurd (Key.lt k k); auto. (* Goal: None *) apply M.lt_irreflexive. (* Goal: forall _ : occ v k x0, occ v k x0 *) eauto. Qed. Hint Resolve maj_not_occ: searchtrees. Lemma min_not_occ : forall (k : key) (v : data) (t : btree), min k t -> ~ occ v k t. Proof. (* Goal: forall (k : key) (v : data) (t : btree) (_ : min k t), not (occ v k t) *) unfold not in |- *; intros k v t H H'. (* Goal: forall _ : occ v k x0, occ v k x0 *) elim H; intros; absurd (Key.lt k k); eauto. (* Goal: None *) apply M.lt_irreflexive. Qed. Hint Resolve min_not_occ: searchtrees. (* technical lemmas about some non-leaf search tree *) Section search_tree_basic_properties. Variables (n : key) (v : data) (t1 t2 : btree). Hypothesis se : search_tree (bnode n v t1 t2). Lemma search_tree_l : search_tree t1. Proof. (* Goal: min n t2 *) inversion_clear se; auto with searchtrees. Qed. Hint Resolve search_tree_l: searchtrees. Lemma search_tree_r : search_tree t2. Proof. (* Goal: min n t2 *) inversion_clear se; auto with searchtrees. Qed. Hint Resolve search_tree_r: searchtrees. Lemma maj_l : maj n t1. Proof. (* Goal: min n t2 *) inversion_clear se; auto with searchtrees. Qed. Hint Resolve maj_l: searchtrees. Lemma min_r : min n t2. Proof. (* Goal: min n t2 *) inversion_clear se; auto with searchtrees. Qed. Hint Resolve min_r: searchtrees. Lemma not_right : forall (p : key) (v' : data), Key.le p n -> ~ occ v' p t2. Proof. (* Goal: None *) intros p v' H; elim min_r. (* Goal: None *) unfold not in |- *; intros; absurd (Key.lt n p); eauto with searchtrees. (* Goal: None *) apply M.le_not_lt; assumption. Qed. Hint Resolve not_right: searchtrees. Lemma not_left : forall (p : key) (v' : data), Key.le n p -> ~ occ v' p t1. Proof. (* Goal: None *) intros p v' H; elim maj_l. (* Goal: None *) unfold not in |- *; intros; absurd (Key.lt p n); eauto with searchtrees. (* Goal: None *) apply M.le_not_lt; assumption. Qed. Hint Resolve not_left: searchtrees. Lemma go_left : forall (p : key) (v' : data), occ v' p (bnode n v t1 t2) -> Key.lt p n -> occ v' p t1. Proof. (* Goal: None *) intros p v' H H0. (* Goal: occ v' p t2 *) case (occ_inv _ _ _ _ _ _ H). (* Goal: forall _ : and (@eq key n p) (@eq data v v'), occ v' p t1 *) (* Goal: forall _ : or (occ v' p t1) (occ v' p t2), occ v' p t1 *) repeat simple destruct 1; absurd (Key.lt p n). (* Goal: None *) rewrite H2; apply M.lt_irreflexive. (* Goal: None *) assumption. (* Goal: None *) (* Goal: None *) simple destruct 1; trivial. (* Goal: forall _ : occ v' p t2, occ v' p t1 *) intro H2; absurd (occ v' p t2). (* Goal: forall _ : forall v : data, not (occ v p t2), sumor (@sig data (fun v0 : data => occ v0 p (bnode n v t1 t2))) (forall v0 : data, not (occ v0 p (bnode n v t1 t2))) *) apply not_right. (* Goal: None *) apply Key.lt_le_weak; assumption. (* Goal: forall _ : occ v k x0, occ v k x0 *) auto. Qed. Lemma go_right : forall (p : key) (v' : data), occ v' p (bnode n v t1 t2) -> Key.lt n p -> occ v' p t2. Proof. (* Goal: None *) intros p v' H H0. (* Goal: occ v' p t2 *) case (occ_inv _ _ _ _ _ _ H). (* Goal: forall _ : and (@eq key n p) (@eq data v v'), occ v' p t2 *) (* Goal: forall _ : or (occ v' p t1) (occ v' p t2), occ v' p t2 *) repeat simple destruct 1; absurd (Key.lt n p). (* Goal: None *) rewrite H2; apply M.lt_irreflexive. (* Goal: None *) assumption. (* Goal: None *) (* Goal: None *) simple destruct 1; trivial. (* Goal: forall _ : occ v' p t1, occ v' p t2 *) intro H2; absurd (occ v' p t1). (* Goal: search_tree leaf *) apply not_left. (* Goal: None *) apply Key.lt_le_weak; assumption. (* Goal: forall _ : occ v k x0, occ v k x0 *) auto. Qed. End search_tree_basic_properties. Hint Resolve go_left go_right not_left not_right search_tree_l search_tree_r maj_l min_r: searchtrees. (* each key occurs at most once *) Lemma occ_unicity : forall t : btree, search_tree t -> forall (k : key) (v v' : data), occ v k t -> occ v' k t -> v = v'. Proof. (* too long, but proofs are irrelevant, are'nt they ? *) (* Goal: forall (n : key) (v : data) (t : btree), insert_spec n v t *) simple induction t. inversion 2. (* Goal: forall (x0 : data) (_ : occ x0 k x), @eq (option data) (@Some data x0) (@None data) *) (* Goal: forall _ : forall v : data, not (occ v k x), @eq (option data) (@None data) (@None data) *) intros. case (occ_inv _ _ _ _ _ _ H2). (* Goal: forall (x0 : btree) (_ : INSERT k v x x0), occ v k x0 *) repeat simple destruct 1. case (occ_inv _ _ _ _ _ _ H3). (* Goal: forall _ : occ v k x0, occ v k x0 *) tauto. (* Goal: forall (x0 : btree) (_ : INSERT k v x x0), occ v k x0 *) simple destruct 1. (* Goal: None *) (* Goal: None *) intro. (* Goal: forall _ : occ v k x0, occ v k x0 *) absurd (occ v' k0 b); auto. (* Goal: search_tree leaf *) eapply not_left. (* Goal: forall _ : occ v k x0, occ v k x0 *) eauto. rewrite H5; apply M.le_refl. (* Goal: None *) (* Goal: None *) intro. (* Goal: forall _ : occ v k x0, occ v k x0 *) absurd (occ v' k0 b0); auto. (* Goal: forall _ : occ v k x0, occ v k x0 *) eapply not_right; eauto. rewrite H5; apply M.le_refl. (* Goal: None *) (* Goal: None *) simple destruct 1; intro. case (occ_inv _ _ _ _ _ _ H3). (* Goal: forall (x0 : btree) (_ : INSERT k v x x0), occ v k x0 *) repeat simple destruct 1. (* Goal: forall _ : occ v k x0, occ v k x0 *) absurd (occ v k b); auto. (* Goal: forall _ : occ v k x0, occ v k x0 *) eapply not_left; eauto. apply M.le_refl. (* Goal: forall _ : occ v k x0, occ v k x0 *) rewrite H7; auto. (* Goal: None *) (* Goal: None *) simple destruct 1; intro. eapply H. (* Goal: forall (_ : forall (p : key) (v' : data) (_ : occ v' p x), or (@eq key p k) (occ v' p x0)) (_ : occ v k x0) (_ : forall (p : key) (v' : data) (_ : occ v' p x0), or (occ v' p x) (and (@eq key k p) (@eq data v v'))) (_ : search_tree x0), occ v k x0 *) eauto with searchtrees. (* Goal: forall _ : occ v k x0, occ v k x0 *) eauto. (* Goal: None *) assumption. (* Goal: forall _ : occ v k x0, occ v k x0 *) absurd (occ v' k0 b0); auto. (* Goal: forall (_ : forall (p : key) (v' : data) (_ : occ v' p x), or (@eq key p k) (occ v' p x0)) (_ : occ v k x0) (_ : forall (p : key) (v' : data) (_ : occ v' p x0), or (occ v' p x) (and (@eq key k p) (@eq data v v'))) (_ : search_tree x0), occ v k x0 *) eapply not_right; eauto with searchtrees. case (maj_l _ _ _ _ H1). intro; apply Key.lt_le_weak. (* Goal: forall _ : occ v k x0, occ v k x0 *) eauto. case (occ_inv _ _ _ _ _ _ H3). (* Goal: forall (x0 : btree) (_ : INSERT k v x x0), occ v k x0 *) repeat simple destruct 1. (* Goal: forall _ : occ v k x0, occ v k x0 *) absurd (occ v k0 b0); auto. case H7. (* Goal: forall (_ : forall (p : key) (v' : data) (_ : occ v' p x), or (@eq key p k) (occ v' p x0)) (_ : occ v k x0) (_ : forall (p : key) (v' : data) (_ : occ v' p x0), or (occ v' p x) (and (@eq key k p) (@eq data v v'))) (_ : search_tree x0), occ v k x0 *) eapply not_right; eauto with searchtrees. apply M.le_refl. (* Goal: forall (x0 : btree) (_ : INSERT k v x x0), occ v k x0 *) simple destruct 1. (* Goal: None *) (* Goal: None *) intro. (* Goal: forall _ : occ v k x0, occ v k x0 *) absurd (occ v' k0 b); auto. (* Goal: forall (_ : forall (p : key) (v' : data) (_ : occ v' p x), or (@eq key p k) (occ v' p x0)) (_ : occ v k x0) (_ : forall (p : key) (v' : data) (_ : occ v' p x0), or (occ v' p x) (and (@eq key k p) (@eq data v v'))) (_ : search_tree x0), occ v k x0 *) eapply not_left; eauto with searchtrees. case (min_r _ _ _ _ H1). (* Goal: forall (x0 : data) (_ : occ x0 k x), @eq (option data) (@Some data x0) (@None data) *) (* Goal: forall _ : forall v : data, not (occ v k x), @eq (option data) (@None data) (@None data) *) intros. apply Key.lt_le_weak. (* Goal: forall _ : occ v k x0, occ v k x0 *) eauto. (* Goal: None *) (* Goal: None *) intro. eapply H0. (* Goal: forall (_ : forall (p : key) (v' : data) (_ : occ v' p x), or (@eq key p k) (occ v' p x0)) (_ : occ v k x0) (_ : forall (p : key) (v' : data) (_ : occ v' p x0), or (occ v' p x) (and (@eq key k p) (@eq data v v'))) (_ : search_tree x0), occ v k x0 *) eauto with searchtrees. (* Goal: forall _ : occ v k x0, occ v k x0 *) eauto. (* Goal: forall _ : occ v k x0, occ v k x0 *) eauto. Qed. (* given a key and a search tree, we return either an associated value or the proof of its non-existence *) Definition occ_dec_spec (k : key) (t : btree) := search_tree t -> {v : data | occ v k t} + {(forall v : data, ~ occ v k t)}. Definition occ_dec : forall (k : key) (t : btree), occ_dec_spec k t. (* Goal: forall (n : key) (v : data) (t : btree), insert_spec n v t *) intro p; simple induction t. (* Goal: forall _ : forall v : data, not (occ v p t2), sumor (@sig data (fun v0 : data => occ v0 p (bnode n v t1 t2))) (forall v0 : data, not (occ v0 p (bnode n v t1 t2))) *) right. (* Goal: INSERT n v (bnode p b t1 t2) (bnode p b t1 t3) *) auto with searchtrees. (* Goal: forall (k : key) (d : data) (b : btree) (_ : occ_dec_spec p b) (b0 : btree) (_ : occ_dec_spec p b0), occ_dec_spec p (bnode k d b b0) *) intros n v t1 R1 t2 R2 H. (* Goal: sumor (@sig data (fun v0 : data => occ v0 p (bnode n v t1 t2))) (forall v0 : data, not (occ v0 p (bnode n v t1 t2))) *) case (M.le_lt_dec p n). (* Goal: forall _ : M.le p n, sumor (@sig data (fun v0 : data => occ v0 p (bnode n v t1 t2))) (forall v0 : data, not (occ v0 p (bnode n v t1 t2))) *) (* Goal: forall _ : M.lt n p, sumor (@sig data (fun v0 : data => occ v0 p (bnode n v t1 t2))) (forall v0 : data, not (occ v0 p (bnode n v t1 t2))) *) intro H0; case (M.le_lt_eq_dec p n H0). (* Goal: forall _ : M.lt p n, sumor (@sig data (fun v0 : data => occ v0 p (bnode n v t1 t2))) (forall v0 : data, not (occ v0 p (bnode n v t1 t2))) *) (* Goal: forall _ : @eq M.A p n, sumor (@sig data (fun v0 : data => occ v0 p (bnode n v t1 t2))) (forall v0 : data, not (occ v0 p (bnode n v t1 t2))) *) (* Goal: forall _ : M.lt n p, sumor (@sig data (fun v0 : data => occ v0 p (bnode n v t1 t2))) (forall v0 : data, not (occ v0 p (bnode n v t1 t2))) *) intro H1; case R1. (* Goal: forall (_ : forall (p : key) (v' : data) (_ : occ v' p x), or (@eq key p k) (occ v' p x0)) (_ : occ v k x0) (_ : forall (p : key) (v' : data) (_ : occ v' p x0), or (occ v' p x) (and (@eq key k p) (@eq data v v'))) (_ : search_tree x0), occ v k x0 *) eauto with searchtrees. (* Goal: forall _ : @sig data (fun v : data => occ v p t2), sumor (@sig data (fun v0 : data => occ v0 p (bnode n v t1 t2))) (forall v0 : data, not (occ v0 p (bnode n v t1 t2))) *) (* Goal: forall _ : forall v : data, not (occ v p t2), sumor (@sig data (fun v0 : data => occ v0 p (bnode n v t1 t2))) (forall v0 : data, not (occ v0 p (bnode n v t1 t2))) *) simple destruct 1; intros v' H'. (* Goal: search_tree leaf *) left. (* Goal: forall (_ : forall (p : key) (v' : data) (_ : occ v' p x), or (@eq key p k) (occ v' p x0)) (_ : occ v k x0) (_ : forall (p : key) (v' : data) (_ : occ v' p x0), or (occ v' p x) (and (@eq key k p) (@eq data v v'))) (_ : search_tree x0), occ v k x0 *) exists v'; eauto with searchtrees. (* Goal: forall _ : forall v : data, not (occ v p t2), sumor (@sig data (fun v0 : data => occ v0 p (bnode n v t1 t2))) (forall v0 : data, not (occ v0 p (bnode n v t1 t2))) *) right. (* Goal: forall v0 : data, not (occ v0 p (bnode n v t1 t2)) *) intros v0 H3. (* Goal: forall (_ : forall (p : key) (v' : data) (_ : occ v' p x), or (@eq key p k) (occ v' p x0)) (_ : occ v k x0) (_ : forall (p : key) (v' : data) (_ : occ v' p x0), or (occ v' p x) (and (@eq key k p) (@eq data v v'))) (_ : search_tree x0), occ v k x0 *) apply (n0 v0); eauto with searchtrees. (* Goal: search_tree leaf *) simple destruct 1; left. (* Goal: forall (_ : forall (p : key) (v' : data) (_ : occ v' p x), or (@eq key p k) (occ v' p x0)) (_ : occ v k x0) (_ : forall (p : key) (v' : data) (_ : occ v' p x0), or (occ v' p x) (and (@eq key k p) (@eq data v v'))) (_ : search_tree x0), occ v k x0 *) exists v; eauto with searchtrees. (* Goal: forall _ : M.lt n p, sumor (@sig data (fun v0 : data => occ v0 p (bnode n v t1 t2))) (forall v0 : data, not (occ v0 p (bnode n v t1 t2))) *) intro H2; case R2. (* Goal: forall (_ : forall (p : key) (v' : data) (_ : occ v' p x), or (@eq key p k) (occ v' p x0)) (_ : occ v k x0) (_ : forall (p : key) (v' : data) (_ : occ v' p x0), or (occ v' p x) (and (@eq key k p) (@eq data v v'))) (_ : search_tree x0), occ v k x0 *) eauto with searchtrees. (* Goal: forall _ : @sig data (fun v : data => occ v p t2), sumor (@sig data (fun v0 : data => occ v0 p (bnode n v t1 t2))) (forall v0 : data, not (occ v0 p (bnode n v t1 t2))) *) (* Goal: forall _ : forall v : data, not (occ v p t2), sumor (@sig data (fun v0 : data => occ v0 p (bnode n v t1 t2))) (forall v0 : data, not (occ v0 p (bnode n v t1 t2))) *) simple destruct 1; intros v' H'. (* Goal: search_tree leaf *) left. (* Goal: forall (_ : forall (p : key) (v' : data) (_ : occ v' p x), or (@eq key p k) (occ v' p x0)) (_ : occ v k x0) (_ : forall (p : key) (v' : data) (_ : occ v' p x0), or (occ v' p x) (and (@eq key k p) (@eq data v v'))) (_ : search_tree x0), occ v k x0 *) exists v'; eauto with searchtrees. (* Goal: forall _ : forall v : data, not (occ v p t2), sumor (@sig data (fun v0 : data => occ v0 p (bnode n v t1 t2))) (forall v0 : data, not (occ v0 p (bnode n v t1 t2))) *) right. (* Goal: forall v0 : data, not (occ v0 p (bnode n v t1 t2)) *) intros v0 H3. (* Goal: forall (_ : forall (p : key) (v' : data) (_ : occ v' p x), or (@eq key p k) (occ v' p x0)) (_ : occ v k x0) (_ : forall (p : key) (v' : data) (_ : occ v' p x0), or (occ v' p x) (and (@eq key k p) (@eq data v v'))) (_ : search_tree x0), occ v k x0 *) apply (n0 v0); eauto with searchtrees. Defined. (* t' is obtained by inserting (n,v) into t *) Inductive INSERT (n : key) (v : data) (t t' : btree) : Prop := insert_intro : (forall (p : key) (v' : data), occ v' p t -> p = n \/ occ v' p t') -> occ v n t' -> (forall (p : key) (v' : data), occ v' p t' -> occ v' p t \/ n = p /\ v = v') -> search_tree t' -> INSERT n v t t'. Hint Resolve insert_intro: searchtrees. Definition insert_spec (n : key) (v : data) (t : btree) : Set := search_tree t -> {t' : btree | INSERT n v t t'}. Lemma insert_leaf : forall (n : key) (v : data), INSERT n v leaf (bnode n v leaf leaf). Proof. (* Goal: INSERT n v (bnode p b t1 t2) (bnode p b t1 t3) *) intro n; split; auto with searchtrees. (* Goal: INSERT n v (bnode p b t1 t2) (bnode p b t1 t3) *) intros p k H; inversion_clear H; auto with searchtrees. Qed. Hint Resolve insert_leaf: searchtrees. (* Inserting in the left son *) Lemma insert_l : forall (n p : key) (v v' : data) (t1 t'1 t2 : btree), Key.lt n p -> search_tree (bnode p v' t1 t2) -> INSERT n v t1 t'1 -> INSERT n v (bnode p v' t1 t2) (bnode p v' t'1 t2). Proof. (* Goal: forall (n : key) (v v' : data) (t1 t2 : btree) (_ : search_tree (bnode n v t1 t2)), INSERT n v' (bnode n v t1 t2) (bnode n v' t1 t2) *) intros n p v v' t1 t'1 t2 H H0 H1; split. (* Goal: forall (p0 : key) (v'0 : data) (_ : occ v'0 p0 (bnode p v' t1 t2)), or (@eq key p0 n) (occ v'0 p0 (bnode p v' t1 t'2)) *) (* Goal: occ v n (bnode p v' t1 t'2) *) (* Goal: forall (p0 : key) (v'0 : data) (_ : occ v'0 p0 (bnode p v' t1 t'2)), or (occ v'0 p0 (bnode p v' t1 t2)) (and (@eq key n p0) (@eq data v v'0)) *) (* Goal: search_tree (bnode p v' t1 t'2) *) intros p0 v'0 H2; inversion_clear H2. (* Goal: INSERT n v (bnode p b t1 t2) (bnode p b t1 t3) *) auto with searchtrees. (* Goal: forall (x0 : data) (_ : occ x0 k x), @eq (option data) (@Some data x0) (@None data) *) (* Goal: forall _ : forall v : data, not (occ v k x), @eq (option data) (@None data) (@None data) *) case H1; intros. (* Goal: or (@eq key p0 n) (occ v'0 p0 (bnode p v' t1 t'2)) *) (* Goal: occ v n (bnode p v' t1 t'2) *) (* Goal: forall (p0 : key) (v'0 : data) (_ : occ v'0 p0 (bnode p v' t1 t'2)), or (occ v'0 p0 (bnode p v' t1 t2)) (and (@eq key n p0) (@eq data v v'0)) *) (* Goal: search_tree (bnode p v' t1 t'2) *) case (H2 _ _ H3). (* Goal: forall _ : occ v k x0, occ v k x0 *) auto. (* Goal: INSERT n v (bnode p b t1 t2) (bnode p b t1 t3) *) auto with searchtrees. (* Goal: INSERT n v (bnode p b t1 t2) (bnode p b t1 t3) *) auto with searchtrees. (* Goal: forall (x0 : data) (_ : occ x0 k x), @eq (option data) (@Some data x0) (@None data) *) (* Goal: forall _ : forall v : data, not (occ v k x), @eq (option data) (@None data) (@None data) *) case H1; intros. (* Goal: forall (_ : forall (p : key) (v' : data) (_ : occ v' p x), or (@eq key p k) (occ v' p x0)) (_ : occ v k x0) (_ : forall (p : key) (v' : data) (_ : occ v' p x0), or (occ v' p x) (and (@eq key k p) (@eq data v v'))) (_ : search_tree x0), occ v k x0 *) eauto with searchtrees. (* Goal: forall (p0 : key) (v'0 : data) (_ : occ v'0 p0 (bnode p v' t1 t'2)), or (occ v'0 p0 (bnode p v' t1 t2)) (and (@eq key n p0) (@eq data v v'0)) *) (* Goal: search_tree (bnode p v' t1 t'2) *) intros p0 v'0 H2. (* Goal: or (occ v'0 p0 (bnode p v' t1 t2)) (and (@eq key n p0) (@eq data v v'0)) *) (* Goal: search_tree (bnode p v' t1 t'2) *) inversion_clear H2. (* Goal: INSERT n v (bnode p b t1 t2) (bnode p b t1 t3) *) auto with searchtrees. (* Goal: forall (x0 : data) (_ : occ x0 k x), @eq (option data) (@Some data x0) (@None data) *) (* Goal: forall _ : forall v : data, not (occ v k x), @eq (option data) (@None data) (@None data) *) case H1; intros. (* Goal: INSERT n v (bnode p b t1 t2) (bnode p b t1 t3) *) elim (H5 p0 v'0); auto with searchtrees. (* Goal: INSERT n v (bnode p b t1 t2) (bnode p b t1 t3) *) auto with searchtrees. (* Goal: INSERT n v (bnode p b t1 t2) (bnode p b t1 t3) *) case H1; constructor 2; auto with searchtrees. (* Goal: forall (_ : forall (p : key) (v' : data) (_ : occ v' p x), or (@eq key p k) (occ v' p x0)) (_ : occ v k x0) (_ : forall (p : key) (v' : data) (_ : occ v' p x0), or (occ v' p x) (and (@eq key k p) (@eq data v v'))) (_ : search_tree x0), occ v k x0 *) eapply search_tree_r; eauto with searchtrees. (* Goal: forall (x0 : data) (_ : occ x0 k x), @eq (option data) (@Some data x0) (@None data) *) (* Goal: forall _ : forall v : data, not (occ v k x), @eq (option data) (@None data) (@None data) *) split; intros. (* Goal: None *) (* Goal: min p t2 *) elim (H4 _ _ H6). (* Goal: None *) (* Goal: None *) intro. (* Goal: None *) (* Goal: None *) (* Goal: min p t2 *) cut (maj p t1). (* Goal: forall (_ : forall (p : key) (v' : data) (_ : occ v' p x), or (@eq key p k) (occ v' p x0)) (_ : occ v k x0) (_ : forall (p : key) (v' : data) (_ : occ v' p x0), or (occ v' p x) (and (@eq key k p) (@eq data v v'))) (_ : search_tree x0), occ v k x0 *) inversion_clear 1; eauto with searchtrees. (* Goal: forall (_ : forall (p : key) (v' : data) (_ : occ v' p x), or (@eq key p k) (occ v' p x0)) (_ : occ v k x0) (_ : forall (p : key) (v' : data) (_ : occ v' p x0), or (occ v' p x) (and (@eq key k p) (@eq data v v'))) (_ : search_tree x0), occ v k x0 *) eauto with searchtrees. (* Goal: forall (x0 : btree) (_ : INSERT k v x x0), occ v k x0 *) repeat simple destruct 1. (* Goal: None *) assumption. (* Goal: forall (_ : forall (p : key) (v' : data) (_ : occ v' p x), or (@eq key p k) (occ v' p x0)) (_ : occ v k x0) (_ : forall (p : key) (v' : data) (_ : occ v' p x0), or (occ v' p x) (and (@eq key k p) (@eq data v v'))) (_ : search_tree x0), occ v k x0 *) eauto with searchtrees. Qed. (* inserting in the right son *) Lemma insert_r : forall (n p : key) (v v' : data) (t1 t2 t'2 : btree), Key.lt p n -> search_tree (bnode p v' t1 t2) -> INSERT n v t2 t'2 -> INSERT n v (bnode p v' t1 t2) (bnode p v' t1 t'2). Proof. (* Goal: forall (n : key) (v v' : data) (t1 t2 : btree) (_ : search_tree (bnode n v t1 t2)), INSERT n v' (bnode n v t1 t2) (bnode n v' t1 t2) *) intros n p v v' t1 t2 t'2 H H0 H1; split. (* Goal: forall (p0 : key) (v'0 : data) (_ : occ v'0 p0 (bnode p v' t1 t2)), or (@eq key p0 n) (occ v'0 p0 (bnode p v' t1 t'2)) *) (* Goal: occ v n (bnode p v' t1 t'2) *) (* Goal: forall (p0 : key) (v'0 : data) (_ : occ v'0 p0 (bnode p v' t1 t'2)), or (occ v'0 p0 (bnode p v' t1 t2)) (and (@eq key n p0) (@eq data v v'0)) *) (* Goal: search_tree (bnode p v' t1 t'2) *) intros p0 v'0 H2; inversion_clear H2. (* Goal: INSERT n v (bnode p b t1 t2) (bnode p b t1 t3) *) auto with searchtrees. (* Goal: INSERT n v (bnode p b t1 t2) (bnode p b t1 t3) *) auto with searchtrees. (* Goal: forall (x0 : data) (_ : occ x0 k x), @eq (option data) (@Some data x0) (@None data) *) (* Goal: forall _ : forall v : data, not (occ v k x), @eq (option data) (@None data) (@None data) *) case H1; intros. (* Goal: or (@eq key p0 n) (occ v'0 p0 (bnode p v' t1 t'2)) *) (* Goal: occ v n (bnode p v' t1 t'2) *) (* Goal: forall (p0 : key) (v'0 : data) (_ : occ v'0 p0 (bnode p v' t1 t'2)), or (occ v'0 p0 (bnode p v' t1 t2)) (and (@eq key n p0) (@eq data v v'0)) *) (* Goal: search_tree (bnode p v' t1 t'2) *) case (H2 _ _ H3). (* Goal: forall _ : occ v k x0, occ v k x0 *) auto. (* Goal: INSERT n v (bnode p b t1 t2) (bnode p b t1 t3) *) auto with searchtrees. (* Goal: forall (x0 : data) (_ : occ x0 k x), @eq (option data) (@Some data x0) (@None data) *) (* Goal: forall _ : forall v : data, not (occ v k x), @eq (option data) (@None data) (@None data) *) case H1; intros. (* Goal: INSERT n v (bnode p b t1 t2) (bnode p b t1 t3) *) auto with searchtrees. (* Goal: forall (p0 : key) (v'0 : data) (_ : occ v'0 p0 (bnode p v' t1 t'2)), or (occ v'0 p0 (bnode p v' t1 t2)) (and (@eq key n p0) (@eq data v v'0)) *) (* Goal: search_tree (bnode p v' t1 t'2) *) intros p0 v'0 H2. (* Goal: or (occ v'0 p0 (bnode p v' t1 t2)) (and (@eq key n p0) (@eq data v v'0)) *) (* Goal: search_tree (bnode p v' t1 t'2) *) inversion_clear H2. (* Goal: INSERT n v (bnode p b t1 t2) (bnode p b t1 t3) *) auto with searchtrees. (* Goal: INSERT n v (bnode p b t1 t2) (bnode p b t1 t3) *) auto with searchtrees. (* Goal: forall (x0 : data) (_ : occ x0 k x), @eq (option data) (@Some data x0) (@None data) *) (* Goal: forall _ : forall v : data, not (occ v k x), @eq (option data) (@None data) (@None data) *) case H1; intros. (* Goal: INSERT n v (bnode p b t1 t2) (bnode p b t1 t3) *) elim (H5 p0 v'0 H3); auto with searchtrees. (* Goal: INSERT n v (bnode p b t1 t2) (bnode p b t1 t3) *) case H1; constructor 2; auto with searchtrees. (* Goal: forall (_ : forall (p : key) (v' : data) (_ : occ v' p x), or (@eq key p k) (occ v' p x0)) (_ : occ v k x0) (_ : forall (p : key) (v' : data) (_ : occ v' p x0), or (occ v' p x) (and (@eq key k p) (@eq data v v'))) (_ : search_tree x0), occ v k x0 *) eapply search_tree_l; eauto with searchtrees. (* Goal: forall (_ : forall (p : key) (v' : data) (_ : occ v' p x), or (@eq key p k) (occ v' p x0)) (_ : occ v k x0) (_ : forall (p : key) (v' : data) (_ : occ v' p x0), or (occ v' p x) (and (@eq key k p) (@eq data v v'))) (_ : search_tree x0), occ v k x0 *) eauto with searchtrees. (* Goal: forall (x0 : data) (_ : occ x0 k x), @eq (option data) (@Some data x0) (@None data) *) (* Goal: forall _ : forall v : data, not (occ v k x), @eq (option data) (@None data) (@None data) *) split; intros. (* Goal: None *) case (H4 _ _ H6). (* Goal: None *) (* Goal: None *) intro. (* Goal: None *) (* Goal: None *) cut (min p t2). (* Goal: forall (_ : forall (p : key) (v' : data) (_ : occ v' p x), or (@eq key p k) (occ v' p x0)) (_ : occ v k x0) (_ : forall (p : key) (v' : data) (_ : occ v' p x0), or (occ v' p x) (and (@eq key k p) (@eq data v v'))) (_ : search_tree x0), occ v k x0 *) inversion_clear 1; eauto with searchtrees. (* Goal: forall (_ : forall (p : key) (v' : data) (_ : occ v' p x), or (@eq key p k) (occ v' p x0)) (_ : occ v k x0) (_ : forall (p : key) (v' : data) (_ : occ v' p x0), or (occ v' p x) (and (@eq key k p) (@eq data v v'))) (_ : search_tree x0), occ v k x0 *) eauto with searchtrees. (* Goal: forall (x0 : btree) (_ : INSERT k v x x0), occ v k x0 *) repeat simple destruct 1. (* Goal: None *) assumption. Qed. (* inserting at the root ; please notice that the most recent value is stored *) Lemma insert_eq : forall (n : key) (v v' : data) (t1 t2 : btree), search_tree (bnode n v t1 t2) -> INSERT n v' (bnode n v t1 t2) (bnode n v' t1 t2). Proof. (* Goal: forall (n : key) (v v' : data) (t1 t2 : btree) (_ : search_tree (bnode n v t1 t2)), INSERT n v' (bnode n v t1 t2) (bnode n v' t1 t2) *) split. (* Goal: forall (_ : forall (p : key) (v' : data) (_ : occ v' p x), or (@eq key p k) (occ v' p x0)) (_ : occ v k x0) (_ : forall (p : key) (v' : data) (_ : occ v' p x0), or (occ v' p x) (and (@eq key k p) (@eq data v v'))) (_ : search_tree x0), occ v k x0 *) inversion 1; eauto with searchtrees. (* Goal: forall (_ : forall (p : key) (v' : data) (_ : occ v' p x), or (@eq key p k) (occ v' p x0)) (_ : occ v k x0) (_ : forall (p : key) (v' : data) (_ : occ v' p x0), or (occ v' p x) (and (@eq key k p) (@eq data v v'))) (_ : search_tree x0), occ v k x0 *) eauto with searchtrees. (* Goal: forall (_ : forall (p : key) (v' : data) (_ : occ v' p x), or (@eq key p k) (occ v' p x0)) (_ : occ v k x0) (_ : forall (p : key) (v' : data) (_ : occ v' p x0), or (occ v' p x) (and (@eq key k p) (@eq data v v'))) (_ : search_tree x0), occ v k x0 *) inversion 1; eauto with searchtrees. (* Goal: forall (_ : forall (p : key) (v' : data) (_ : occ v' p x), or (@eq key p k) (occ v' p x0)) (_ : occ v k x0) (_ : forall (p : key) (v' : data) (_ : occ v' p x0), or (occ v' p x) (and (@eq key k p) (@eq data v v'))) (_ : search_tree x0), occ v k x0 *) inversion H; eauto with searchtrees. Qed. Hint Resolve insert_l insert_r insert_eq: searchtrees. Definition insert : forall (n : key) (v : data) (t : btree), insert_spec n v t. (* Goal: forall (n : key) (v : data) (t : btree), insert_spec n v t *) simple induction t. (* Goal: insert_spec n v leaf *) (* Goal: forall (k : key) (d : data) (b : btree) (_ : insert_spec n v b) (b0 : btree) (_ : insert_spec n v b0), insert_spec n v (bnode k d b b0) *) exists (bnode n v leaf leaf). (* Goal: INSERT n v (bnode p b t1 t2) (bnode p b t1 t3) *) auto with searchtrees. (* Goal: forall (k : key) (d : data) (b : btree) (_ : insert_spec n v b) (b0 : btree) (_ : insert_spec n v b0), insert_spec n v (bnode k d b b0) *) unfold insert_spec at 3 in |- *; intros p b t1 H1 t2 H2 H0. (* Goal: @sig btree (fun t' : btree => INSERT n v (bnode p b t1 t2) t') *) case (M.le_lt_dec n p). (* Goal: forall _ : M.le n p, @sig btree (fun t' : btree => INSERT n v (bnode p b t1 t2) t') *) (* Goal: forall _ : M.lt p n, @sig btree (fun t' : btree => INSERT n v (bnode p b t1 t2) t') *) intro H; case (M.le_lt_eq_dec n p H). (* Goal: forall _ : M.lt n p, @sig btree (fun t' : btree => INSERT n v (bnode p b t1 t2) t') *) (* Goal: forall _ : @eq M.A n p, @sig btree (fun t' : btree => INSERT n v (bnode p b t1 t2) t') *) (* Goal: forall _ : M.lt p n, @sig btree (fun t' : btree => INSERT n v (bnode p b t1 t2) t') *) intro H'. (* Goal: @sig btree (fun t' : btree => INSERT n v (bnode p b t1 t2) t') *) (* Goal: forall _ : @eq M.A n p, @sig btree (fun t' : btree => INSERT n v (bnode p b t1 t2) t') *) (* Goal: forall _ : M.lt p n, @sig btree (fun t' : btree => INSERT n v (bnode p b t1 t2) t') *) case (H1 (search_tree_l _ _ _ _ H0)). (* Goal: forall (x : btree) (_ : INSERT n v t1 x), @sig btree (fun t' : btree => INSERT n v (bnode p b t1 t2) t') *) (* Goal: forall _ : @eq M.A n p, @sig btree (fun t' : btree => INSERT n v (bnode p b t1 t2) t') *) (* Goal: forall _ : M.lt p n, @sig btree (fun t' : btree => INSERT n v (bnode p b t1 t2) t') *) intros t3; exists (bnode p b t3 t2). (* Goal: INSERT n v (bnode p b t1 t2) (bnode p b t1 t3) *) auto with searchtrees. (* Goal: INSERT n v (bnode p b t1 t2) (bnode p b t1 t3) *) intro e; rewrite e; exists (bnode p v t1 t2); auto with searchtrees. (* Goal: forall _ : M.lt p n, @sig btree (fun t' : btree => INSERT n v (bnode p b t1 t2) t') *) case (H2 (search_tree_r _ _ _ _ H0)). (* Goal: forall (x : btree) (_ : INSERT n v t2 x) (_ : M.lt p n), @sig btree (fun t' : btree => INSERT n v (bnode p b t1 t2) t') *) intros t3; exists (bnode p b t1 t3). (* Goal: INSERT n v (bnode p b t1 t2) (bnode p b t1 t3) *) auto with searchtrees. Defined. (* realisation of the DICT signature *) (* dictionaries are represented as certified binary search trees *) Definition dict : Set := sig search_tree. Definition empty : dict. (* Goal: dict *) unfold dict in |- *; exists leaf. (* Goal: search_tree leaf *) left. Defined. Definition find (k : key) (d : dict) : option data := let (t, Ht) := d in match occ_dec k t Ht with | inleft s => let (v, _) := s in Some v | inright _ => None (A:=data) end. Definition add : key -> data -> dict -> dict. refine (fun (k : key) (v : data) (d : dict) => let (t, Ht) := d in let (x, Hx) := insert k v t Ht in exist search_tree x _). (* Goal: forall _ : occ v k x0, occ v k x0 *) case Hx; auto. Defined. (* Now, we've got to prove the axioms *) Definition D_tree (d : dict) : btree := match d with | exist t Ht => t end. Lemma D_search : forall d : dict, search_tree (D_tree d). Proof. (* Goal: forall _ : occ v k x0, occ v k x0 *) simple destruct d; simpl in |- *; auto. Qed. Lemma find_occ_dec : forall (k : key) (v : data) (d : dict), occ v k (D_tree d) -> find k d = Some v. Proof. (* Goal: forall (x0 : data) (_ : occ x0 k x), @eq (option data) (@Some data x0) (@None data) *) (* Goal: forall _ : forall v : data, not (occ v k x), @eq (option data) (@None data) (@None data) *) unfold find in |- *; simple destruct d; simpl in |- *; intros. (* Goal: @eq (option data) match occ_dec k x s with | inleft (@exist _ _ v x0 as s) => @Some data v | inright n => @None data end (@None data) *) case (occ_dec k x s); simpl in |- *. (* Goal: forall s : @sig data (fun v : data => occ v k x), @eq (option data) (let (v, _) := s in @Some data v) (@None data) *) (* Goal: forall _ : forall v : data, not (occ v k x), @eq (option data) (@None data) (@None data) *) simple destruct s0; simpl in |- *. (* Goal: forall (x0 : data) (_ : occ x0 k x), @eq (option data) (@Some data x0) (@Some data v) *) (* Goal: forall _ : forall v : data, not (occ v k x), @eq (option data) (@None data) (@Some data v) *) intros x0 H0; case (occ_unicity x s _ _ _ H H0). (* Goal: forall _ : occ v k x0, occ v k x0 *) auto. (* Goal: forall (x0 : data) (_ : occ x0 k x), @eq (option data) (@Some data x0) (@None data) *) (* Goal: forall _ : forall v : data, not (occ v k x), @eq (option data) (@None data) (@None data) *) intros. (* Goal: @eq (option data) (@None data) (@Some data v) *) case (n v H). Qed. Lemma not_find_occ_dec : forall (k : key) (d : dict), (forall v : data, ~ occ v k (D_tree d)) -> find k d = None. Proof. (* Goal: forall (x0 : data) (_ : occ x0 k x), @eq (option data) (@Some data x0) (@None data) *) (* Goal: forall _ : forall v : data, not (occ v k x), @eq (option data) (@None data) (@None data) *) unfold find in |- *; simple destruct d; simpl in |- *; intros. (* Goal: @eq (option data) match occ_dec k x s with | inleft (@exist _ _ v x0 as s) => @Some data v | inright n => @None data end (@None data) *) case (occ_dec k x s); simpl in |- *. (* Goal: forall s : @sig data (fun v : data => occ v k x), @eq (option data) (let (v, _) := s in @Some data v) (@None data) *) (* Goal: forall _ : forall v : data, not (occ v k x), @eq (option data) (@None data) (@None data) *) simple destruct s0; simpl in |- *. (* Goal: forall (x0 : data) (_ : occ x0 k x), @eq (option data) (@Some data x0) (@None data) *) (* Goal: forall _ : forall v : data, not (occ v k x), @eq (option data) (@None data) (@None data) *) intros. (* Goal: @eq (option data) (@Some data x0) (@None data) *) (* Goal: forall _ : forall v : data, not (occ v k x), @eq (option data) (@None data) (@None data) *) case (H _ o). (* Goal: forall _ : occ v k x0, occ v k x0 *) auto. Qed. Theorem empty_def : forall k : key, find k empty = None. Proof. unfold find, empty in |- *. intro k; case (occ_dec k leaf leaf_search_tree); simpl in |- *. simple destruct s. inversion 1. (* Goal: forall _ : occ v k x0, occ v k x0 *) auto. Qed. Remark success2 : forall (d : dict) (k : key) (v : data), occ v k (D_tree (add k v d)). Proof. (* Goal: forall (d : dict) (k k' : key) (v v' : data) (_ : not (@eq key k k')) (_ : occ v k (D_tree (add k' v' d))), occ v k (D_tree d) *) simple destruct d. (* Goal: forall (x : btree) (s : search_tree x) (k k' : key) (v v' : data) (_ : not (@eq key k k')) (_ : occ v k (D_tree (add k' v' (@exist btree search_tree x s)))), occ v k (D_tree (@exist btree search_tree x s)) *) simpl in |- *. (* Goal: forall (x : btree) (s : search_tree x) (k k' : key) (v v' : data) (_ : not (@eq key k k')) (_ : occ v k (D_tree (add k' v' (@exist btree search_tree x s)))), occ v k (D_tree (@exist btree search_tree x s)) *) intros x s k v; case (insert k v x s); simpl in |- *. (* Goal: forall (x0 : btree) (_ : INSERT k v x x0), occ v k x0 *) simple destruct 1. (* Goal: forall (_ : forall (p : key) (v' : data) (_ : occ v' p x), or (@eq key p k) (occ v' p x0)) (_ : occ v k x0) (_ : forall (p : key) (v' : data) (_ : occ v' p x0), or (occ v' p x) (and (@eq key k p) (@eq data v v'))) (_ : search_tree x0), occ v k x0 *) eauto with searchtrees. Qed. Theorem success : forall (d : dict) (k : key) (v : data), find k (add k v d) = Some v. Proof. intros; apply find_occ_dec. apply success2. Qed. Remark diff_key1 : forall (d : dict) (k k' : key) (v v' : data), k <> k' -> occ v k (D_tree (add k' v' d)) -> occ v k (D_tree d). Proof. (* Goal: forall (d : dict) (k k' : key) (v v' : data) (_ : not (@eq key k k')) (_ : occ v k (D_tree (add k' v' d))), occ v k (D_tree d) *) simple destruct d. (* Goal: forall (x : btree) (s : search_tree x) (k k' : key) (v v' : data) (_ : not (@eq key k k')) (_ : occ v k (D_tree (add k' v' (@exist btree search_tree x s)))), occ v k (D_tree (@exist btree search_tree x s)) *) simpl in |- *. (* Goal: forall (x : btree) (s : search_tree x) (k k' : key) (v v' : data) (_ : not (@eq key k k')) (_ : occ v k (D_tree (add k' v' (@exist btree search_tree x s)))), occ v k (D_tree (@exist btree search_tree x s)) *) intros x s k k' v v'; case (insert k' v' x s); simpl in |- *. (* Goal: forall (x0 : data) (_ : occ x0 k x), @eq (option data) (@Some data x0) (@None data) *) (* Goal: forall _ : forall v : data, not (occ v k x), @eq (option data) (@None data) (@None data) *) simple destruct 1; intros. (* Goal: occ v k x *) case (H1 _ _ H4). (* Goal: forall _ : occ v k x0, occ v k x0 *) auto. (* Goal: forall _ : occ v k x0, occ v k x0 *) simple destruct 1; absurd (k' = k); auto. (* Goal: forall _ : occ v k x0, occ v k x0 *) case H5; auto. Qed. Remark diff_key2 : forall (d : dict) (k k' : key) (v v' : data), k <> k' -> occ v k (D_tree d) -> occ v k (D_tree (add k' v' d)). Proof. (* Goal: forall (x : btree) (s : search_tree x) (k k' : key) (v v' : data) (_ : not (@eq key k k')) (_ : occ v k (D_tree (add k' v' (@exist btree search_tree x s)))), occ v k (D_tree (@exist btree search_tree x s)) *) simple destruct d; simpl in |- *. (* Goal: forall (x : btree) (s : search_tree x) (k k' : key) (v v' : data) (_ : not (@eq key k k')) (_ : occ v k (D_tree (add k' v' (@exist btree search_tree x s)))), occ v k (D_tree (@exist btree search_tree x s)) *) intros x s k k' v v'; case (insert k' v' x s); simpl in |- *. (* Goal: forall (x0 : data) (_ : occ x0 k x), @eq (option data) (@Some data x0) (@None data) *) (* Goal: forall _ : forall v : data, not (occ v k x), @eq (option data) (@None data) (@None data) *) simple destruct 1; intros. (* Goal: occ v k x0 *) case (H _ _ H4). (* Goal: forall _ : @eq key k k', occ v k x0 *) (* Goal: forall _ : occ v k x0, occ v k x0 *) intro H5; case (H3 H5). (* Goal: forall _ : occ v k x0, occ v k x0 *) auto. Qed. Theorem diff_key : forall (d : dict) (k k' : key) (v : data), k <> k' -> find k (add k' v d) = find k d. Proof. (* Goal: forall (x0 : data) (_ : occ x0 k x), @eq (option data) (@Some data x0) (@None data) *) (* Goal: forall _ : forall v : data, not (occ v k x), @eq (option data) (@None data) (@None data) *) intros. case (occ_dec k (D_tree d)). apply D_search. (* Goal: forall (x0 : btree) (_ : INSERT k v x x0), occ v k x0 *) simple destruct 1. intros x Hx. transitivity (Some x). apply find_occ_dec. (* Goal: forall _ : occ v k x0, occ v k x0 *) apply diff_key2; auto. (* Goal: forall _ : occ v k x0, occ v k x0 *) symmetry in |- *; apply find_occ_dec; auto. intro; transitivity (None (A:=data)). apply not_find_occ_dec. intros v0 H0. apply (n v0). (* Goal: forall _ : occ v k x0, occ v k x0 *) eapply diff_key1; eauto. symmetry in |- *; apply not_find_occ_dec. (* Goal: forall _ : occ v k x0, occ v k x0 *) auto. Qed. End TDict. (* Examples *) Module BoolNat := Lexico Bool_Order Nat_Order. Module MoreBoolNat := More_Dec_Orders BoolNat. Module Nats <: DATA. Definition data := list nat. End Nats. Module NaiveDict := TrivialDict LZKey Nats. Module MyDict : DICT := TDict BoolNat Nats. Module Dict2 := Dict_Plus MyDict. Module Dict1 := Dict_Plus NaiveDict. (* To get Ocaml code : unix: coqc dict. unix : coqtop Coq < Require dict. Coq < Recursive Extraction Library dict. *)
(* This program is free software; you can redistribute it and/or *) (* modify it under the terms of the GNU Lesser General Public License *) (* as published by the Free Software Foundation; either version 2.1 *) (* of the License, or (at your option) any later version. *) (* *) (* This program is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* GNU General Public License for more details. *) (* *) (* You should have received a copy of the GNU Lesser General Public *) (* License along with this program; if not, write to the Free *) (* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *) (* 02110-1301 USA *) (* Contribution to the Coq Library V6.3 (July 1999) *) (****************************************************************************) (* The Calculus of Inductive Constructions *) (* *) (* Projet Coq *) (* *) (* INRIA ENS-CNRS *) (* Rocquencourt Lyon *) (* *) (* Coq V5.10 *) (* Nov 25th 1994 *) (* *) (****************************************************************************) (* Rat.v *) (****************************************************************************) (* Formal Language Theory *) (* *) (* Judicael Courant - Jean-Christophe Filliatre *) (* *) (* Developped in V5.8 June-July 1993 *) (* Ported to V5.10 October 1994 *) (****************************************************************************) Require Import Ensf. Require Import Words. (* *) (* On definit la concatenation, l'union, l'intersection de 2 *) (* langages, le langage L* si L est un langage, ainsi que le *) (* langage reduit a un mot. *) (* *) Definition lword (w : Word) : wordset := fun w1 : Word => w = w1 :>Word. Definition lconc (l1 l2 : wordset) : wordset := fun w : Word => exists w1 : Word, (exists w2 : Word, l1 w1 /\ l2 w2 /\ w = Append w1 w2 :>Word). Definition lunion (l1 l2 : wordset) : wordset := fun w : Word => l1 w \/ l2 w. Definition linter (l1 l2 : wordset) : wordset := fun w : Word => l1 w /\ l2 w. Fixpoint lpuiss (n : nat) : wordset -> wordset := fun l : wordset => match n return wordset with | O => (* O *) lword nil (* S *) | S p => lconc l (lpuiss p l) end. Definition lstar (l : wordset) : wordset := fun w : Word => exists n : nat, lpuiss n l w. Lemma induction_star : forall (P : Word -> Prop) (l : wordset), (forall (n : nat) (w : Word), lpuiss n l w -> P w) -> forall w : Word, lstar l w -> P w. (* Goal: lstar l w *) unfold lstar in |- *. (* Goal: forall (l : wordset) (w : Word) (_ : l w), lstar l w *) intros. (* Goal: P w *) elim H0; clear H0. (* Goal: forall (x : nat) (_ : lpuiss x l w), P w *) intros x H0. (* Goal: P w *) apply (H x w); auto. Qed. (* *) (* Si w est dans l alors w est dans l*. *) (* *) Lemma lw_imp_lstarlw : forall (l : wordset) (w : Word), l w -> lstar l w. (* Goal: forall (l : wordset) (w : Word) (_ : l w), lstar l w *) intros. (* Goal: lstar l w *) unfold lstar in |- *. (* Goal: @ex nat (fun n : nat => lpuiss n l w) *) exists 1. (* Goal: lpuiss (S O) l w *) change (lconc l (lpuiss 0 l) w) in |- *. (* Goal: lconc l (lpuiss O l) w *) unfold lconc in |- *. (* Goal: @ex Word (fun w1 : Word => @ex Word (fun w2 : Word => and (l w1) (and (lpuiss O l w2) (@eq Word w (Append w1 w2))))) *) exists w. (* Goal: @ex Word (fun w2 : Word => and (l w) (and (lpuiss O l w2) (@eq Word w (Append w w2)))) *) exists nil. (* Goal: and (l w) (and (lpuiss O l nil) (@eq Word w (Append w nil))) *) split; [ assumption | split ]. (* Goal: lpuiss O l nil *) (* Goal: @eq Word w (Append w nil) *) unfold lpuiss in |- *. (* Goal: lword nil nil *) (* Goal: @eq Word w (Append w nil) *) unfold lword in |- *; auto. symmetry in |- *. (* Goal: @eq Word (Append w nil) w *) apply Append_w_nil. Qed. (* *) (* On definit le predicat isrationnal sur les langages en signifiant *) (* que le langage est d'une des 4 formes suivantes : *) (* -- {w} *) (* -- L1 U L2 *) (* -- L1.L2 *) (* -- L* *) (* ou L, L1 et L2 sont rationnels. *) (* *) Inductive isrationnal : wordset -> Prop := | israt_lword : forall w : Word, inmonoid alph w -> isrationnal (lword w) | israt_lunion : forall l1 l2 : wordset, isrationnal l1 -> isrationnal l2 -> isrationnal (lunion l1 l2) | israt_conc : forall l1 l2 : wordset, isrationnal l1 -> isrationnal l2 -> isrationnal (lconc l1 l2) | israt_lstar : forall l : wordset, isrationnal l -> isrationnal (lstar l).
(* This program is free software; you can redistribute it and/or *) (* modify it under the terms of the GNU Lesser General Public License *) (* as published by the Free Software Foundation; either version 2.1 *) (* of the License, or (at your option) any later version. *) (* *) (* This program is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* GNU General Public License for more details. *) (* *) (* You should have received a copy of the GNU Lesser General Public *) (* License along with this program; if not, write to the Free *) (* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *) (* 02110-1301 USA *) (* Contribution to the Coq Library V6.3 (July 1999) *) (****************************************************************************) (* The Calculus of Inductive Constructions *) (* *) (* Projet Coq *) (* *) (* INRIA ENS-CNRS *) (* Rocquencourt Lyon *) (* *) (* Coq V5.10 *) (* Nov 25th 1994 *) (* *) (****************************************************************************) (* Ensf_union.v *) (****************************************************************************) (* Formal Language Theory *) (* *) (* Judicael Courant - Jean-Christophe Filliatre *) (* *) (* Developped in V5.8 June-July 1993 *) (* Ported to V5.10 October 1994 *) (****************************************************************************) Require Import Ensf_types. Require Import Ensf_dans. (* *) (* UNION : *) (* On definit ici l'union de 2 ensembles. On remarquera qu'un *) (* peut apparaitre plusieurs fois dans un ensemble, et que c'est *) (* pour cela que l'on utilise *) (* union E (add x F) -> add x (union E F) *) (* directement. *) (* *) Fixpoint union (A : Ensf) : Ensf -> Ensf := fun B : Ensf => match A return Ensf with | empty => (* empty *) B (* add *) | add x e => add x (union e B) end. Lemma union_a_empty : forall a : Ensf, a = union a empty :>Ensf. (* Goal: forall a : Ensf, @eq Ensf a (union a empty) *) simple induction a. (* Goal: @eq Ensf empty (union empty empty) *) (* Goal: forall (e : Elt) (e0 : Ensf) (_ : @eq Ensf e0 (union e0 empty)), @eq Ensf (add e e0) (union (add e e0) empty) *) apply refl_equal. (* Goal: forall (e : Elt) (e0 : Ensf) (_ : @eq Ensf e0 (union e0 empty)), @eq Ensf (add e e0) (union (add e e0) empty) *) intros a0 b H. (* Goal: @eq Ensf (add a0 b) (union (add a0 b) empty) *) simpl in |- *; auto. Qed. Hint Resolve union_a_empty. Lemma dans_union : forall (x : Elt) (a b : Ensf), dans x (union a b) -> dans x a \/ dans x b. intros x. (* Goal: forall a : Ensf, @eq Ensf a (union a empty) *) simple induction a. auto. intros a0 b H b0. simpl in |- *. intro H0. cut (a0 = x :>Elt \/ dans x (union b b0)). 2: apply dans_add; auto. intro H1; elim H1. intro; left. rewrite H2; auto. intro. cut (dans x b \/ dans x b0); auto. intro H3; elim H3; auto. Qed. Hint Resolve dans_union. Lemma union_g : forall (x : Elt) (a b : Ensf), dans x a -> dans x (union a b). (* Goal: forall (x : Elt) (a b : Ensf) (_ : dans x b), dans x (union a b) *) intro x. (* Goal: forall a : Ensf, @eq Ensf a (union a empty) *) simple induction a. intros. apply (dans_empty_imp_P x); auto. intros a0 b H b0. simpl in |- *. intro. cut (a0 = x :>Elt \/ dans x b). 2: apply dans_add; auto. intro H1; elim H1; clear H1. intro H1. rewrite H1; auto. auto. Qed. Hint Resolve union_g. Lemma union_d : forall (x : Elt) (a b : Ensf), dans x b -> dans x (union a b). (* Goal: forall (x : Elt) (a b : Ensf) (_ : dans x b), dans x (union a b) *) intro x. (* Goal: @eq Ensf (add a0 b) (union (add a0 b) empty) *) simple induction a; simpl in |- *; auto. Qed. Hint Resolve union_d. Lemma dans_union_inv : forall (x : Elt) (a b : Ensf), dans x a \/ dans x b -> dans x (union a b). intros x a b H; elim H; auto. Qed.
(* This program is free software; you can redistribute it and/or *) (* modify it under the terms of the GNU Lesser General Public License *) (* as published by the Free Software Foundation; either version 2.1 *) (* of the License, or (at your option) any later version. *) (* *) (* This program is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* GNU General Public License for more details. *) (* *) (* You should have received a copy of the GNU Lesser General Public *) (* License along with this program; if not, write to the Free *) (* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *) (* 02110-1301 USA *) (* Contribution to the Coq Library V6.3 (July 1999) *) (****************************************************************************) (* The Calculus of Inductive Constructions *) (* *) (* Projet Coq *) (* *) (* INRIA ENS-CNRS *) (* Rocquencourt Lyon *) (* *) (* Coq V5.10 *) (* Nov 25th 1994 *) (* *) (****************************************************************************) (* Ensf_types.v *) (****************************************************************************) (* Formal Language Theory *) (* *) (* Judicael Courant - Jean-Christophe Filliatre *) (* *) (* Developped in V5.8 June-July 1993 *) (* Ported to V5.10 October 1994 *) (****************************************************************************) (* On definit 3 "types" mutuellement inductifs : Elt, Ensf et Word *) (* On distingue elt et mot, car on a besoin du type mot plus tard. *) (* Les constructeurs up et word permettent repectivement de considerer *) (* un ensemble ou un mot en tant qu'element. *) Inductive Ensf : Set := | empty : Ensf | add : Elt -> Ensf -> Ensf with Elt : Set := | natural : nat -> Elt | couple : Elt -> Elt -> Elt | up : Ensf -> Elt | word : Word -> Elt with Word : Set := | nil : Word | cons : Elt -> Word -> Word. (* Inversion de quelques constructeurs... *) (* Definition natural_inv : Elt -> nat := [e:Elt] (<nat>Case e of (* natural *) [n:nat]n (* couple *) [a:Elt][b:Elt]O (* up *) [e:Ensf]O (* word *) [w:Word]O end ). *) Definition natural_inv (e : Elt) : nat := match e with | natural n => n | _ => 0 end. Lemma nat_invol : forall n : nat, natural_inv (natural n) = n. (* Goal: forall n : nat, @eq nat (natural_inv (natural n)) n *) auto. Qed. (* Definition word_inv : Elt -> Word := [e:Elt] (<Word>Case e of (* natural *) [n:nat]nil (* couple *) [a:Elt][b:Elt]nil (* up *) [e:Ensf]nil (* word *) [w:Word]w end ). *) Definition word_inv (e : Elt) : Word := match e with | word w => w | _ => nil end. (* Quelques resultats triviaux sur les constructeurs... *) Lemma add_add : forall (a b : Elt) (c d : Ensf), a = b -> c = d -> add a c = add b d. (* Goal: forall (a b : Ensf) (e : Elt) (_ : @eq Ensf a b), @eq Ensf (add e a) (add e b) *) intros. (* Goal: @eq Elt (couple a c) (couple b d) *) rewrite H. (* Goal: @eq Elt (couple b c) (couple b d) *) rewrite H0. (* Goal: forall _ : @eq Word a b, @eq Word a b *) trivial. Qed. Hint Resolve add_add. Lemma couple_couple : forall a b c d : Elt, a = b -> c = d -> couple a c = couple b d. (* Goal: forall (a b : Ensf) (e : Elt) (_ : @eq Ensf a b), @eq Ensf (add e a) (add e b) *) intros. (* Goal: @eq Elt (couple a c) (couple b d) *) rewrite H. (* Goal: @eq Elt (couple b c) (couple b d) *) rewrite H0. (* Goal: forall _ : @eq Word a b, @eq Word a b *) trivial. Qed. Lemma word_word : forall a b : Word, a = b -> word a = word b. (* Goal: forall (a b : Ensf) (e : Elt) (_ : @eq Ensf a b), @eq Ensf (add e a) (add e b) *) intros. (* Goal: forall n : nat, @eq nat (natural_inv (natural n)) n *) apply (f_equal (A:=Word) (B:=Elt)); auto. Qed. Hint Resolve word_word. Lemma word_word_inv : forall a b : Word, word a = word b -> a = b. (* Goal: forall (a b : Word) (_ : @eq Elt (word a) (word b)), @eq Word a b *) intros a b H. (* Goal: @eq Word a b *) injection H. (* Goal: forall _ : @eq Word a b, @eq Word a b *) trivial. Qed. (* Quelques simplifications *) Definition zero : Elt := natural 0. Definition un : Elt := natural 1. Definition singleton (e : Elt) : Ensf := add e empty. (* Quelques petits lemmes divers... *) Lemma False_imp_P : forall P : Prop, False -> P. (* Goal: forall (a b : Ensf) (e : Elt) (_ : @eq Ensf a b), @eq Ensf (add e a) (add e b) *) intros. (* Goal: P *) elimtype False. (* Goal: False *) assumption. Qed. Lemma equal_add : forall (a b : Ensf) (e : Elt), a = b -> add e a = add e b. (* Goal: forall (a b : Ensf) (e : Elt) (_ : @eq Ensf a b), @eq Ensf (add e a) (add e b) *) intros. (* Goal: forall n : nat, @eq nat (natural_inv (natural n)) n *) apply (f_equal (A:=Ensf) (B:=Ensf)); auto. Qed.
(* This program is free software; you can redistribute it and/or *) (* modify it under the terms of the GNU Lesser General Public License *) (* as published by the Free Software Foundation; either version 2.1 *) (* of the License, or (at your option) any later version. *) (* *) (* This program is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* GNU General Public License for more details. *) (* *) (* You should have received a copy of the GNU Lesser General Public *) (* License along with this program; if not, write to the Free *) (* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *) (* 02110-1301 USA *) (* Contribution to the Coq Library V6.3 (July 1999) *) (****************************************************************************) (* The Calculus of Inductive Constructions *) (* *) (* Projet Coq *) (* *) (* INRIA ENS-CNRS *) (* Rocquencourt Lyon *) (* *) (* Coq V5.10 *) (* Nov 25th 1994 *) (* *) (****************************************************************************) (* more_words.v *) (****************************************************************************) (* Formal Language Theory *) (* *) (* Judicael Courant - Jean-Christophe Filliatre *) (* *) (* Developped in V5.8 June-July 1993 *) (* Ported to V5.10 October 1994 *) (****************************************************************************) Require Import Ensf. Require Import Words. Hint Unfold eqwordset . Definition l_inclus (l1 l2 : wordset) : Prop := forall w : Word, l1 w -> l2 w. Hint Unfold l_inclus. Lemma refl_l_inclus : forall l1 : wordset, l_inclus l1 l1. (* Goal: forall _ : @eq Word (wef nil) nil, @eq Word nil nil *) (* Goal: forall (e : Elt) (w : Word) (_ : @eq Word (wef (cons e w)) nil), @eq Word (cons e w) nil *) auto. Qed. Hint Resolve refl_l_inclus. Lemma trans_l_inclus : forall l1 l2 l3 : wordset, l_inclus l1 l2 -> l_inclus l2 l3 -> l_inclus l1 l3. (* Goal: forall _ : @eq Word (wef nil) nil, @eq Word nil nil *) (* Goal: forall (e : Elt) (w : Word) (_ : @eq Word (wef (cons e w)) nil), @eq Word (cons e w) nil *) auto. Qed. Definition l_egal (l1 l2 : wordset) : Prop := l_inclus l1 l2 /\ l_inclus l2 l1. Hint Unfold l_egal. (*predicat equivalent a eqwordset*) (*demonstration : *) Lemma equiv_l_egal_eqwordset : forall a b : wordset, l_egal a b <-> eqwordset a b. (* Goal: forall a b : wordset, iff (l_egal a b) (eqwordset a b) *) intros a b. (* Goal: iff (l_egal a b) (eqwordset a b) *) unfold iff in |- *. (* Goal: and (forall _ : l_egal a b, eqwordset a b) (forall _ : eqwordset a b, l_egal a b) *) split. (* Goal: forall _ : @eq Word (wef nil) nil, @eq Word nil nil *) (* Goal: forall (e : Elt) (w : Word) (_ : @eq Word (wef (cons e w)) nil), @eq Word (cons e w) nil *) intro Hyp; elim Hyp; auto. (* Goal: forall _ : eqwordset a b, l_egal a b *) intros Hyp. (* Goal: forall _ : @eq Word (wef nil) nil, @eq Word nil nil *) (* Goal: forall (e : Elt) (w : Word) (_ : @eq Word (wef (cons e w)) nil), @eq Word (cons e w) nil *) split; unfold l_inclus in |- *; intro w; elim (Hyp w); auto. Qed. Lemma refl_l_egal : forall l1 : wordset, l_egal l1 l1. (* Goal: forall _ : @eq Word (wef nil) nil, @eq Word nil nil *) (* Goal: forall (e : Elt) (w : Word) (_ : @eq Word (wef (cons e w)) nil), @eq Word (cons e w) nil *) auto. Qed. Hint Resolve refl_l_egal. Section more_about_words. Variable f : Elt -> Elt. Let wef := Word_ext f. (* Lemma wef_cons : (a:Elt)(u:Word)(wef (cons a u))=(cons (f a) (wef u)). Proof [a:Elt][u:Word](refl_equal Word (wef (cons a u))). *) Lemma wef_append : forall u v : Word, wef (Append u v) = Append (wef u) (wef v). (* Goal: forall u v : Word, @eq Word (wef (Append u v)) (Append (wef u) (wef v)) *) intros u v. (* Goal: @eq Word (wef (Append u v)) (Append (wef u) (wef v)) *) elim u. (* Goal: @eq Word (cons x w) (cons x w) *) (* Goal: and (@eq Elt (f x) e) (@eq Word (Word_ext f w) a) *) trivial. (* Goal: forall _ : @eq Word (cons e a) (wef b), @ex Elt (fun x : Elt => @ex2 Word (fun w : Word => @eq Word (cons x w) b) (fun w : Word => and (@eq Elt (f x) e) (@eq Word (wef w) a))) *) unfold wef in |- *. (* Goal: forall (e : Elt) (w : Word) (_ : @eq Word (Word_ext f (Append w v)) (Append (Word_ext f w) (Word_ext f v))), @eq Word (Word_ext f (Append (cons e w) v)) (Append (Word_ext f (cons e w)) (Word_ext f v)) *) intros x w H. (* Goal: @eq Word (Word_ext f (Append (cons x w) v)) (Append (Word_ext f (cons x w)) (Word_ext f v)) *) simpl in |- *. (* Goal: @eq Word (cons (f x) (Word_ext f (Append w v))) (cons (f x) (Append (Word_ext f w) (Word_ext f v))) *) rewrite <- H. (* Goal: @eq Word (cons (f x) (Word_ext f (Append w v))) (cons (f x) (Word_ext f (Append w v))) *) reflexivity. Qed. Lemma wef_nil : forall a : Word, wef a = nil -> a = nil. (* Goal: forall (a : Word) (_ : @eq Word (wef a) nil), @eq Word a nil *) intro a. (* Goal: forall _ : @eq Word (wef a) nil, @eq Word a nil *) case a. (* Goal: forall _ : @eq Word (wef nil) nil, @eq Word nil nil *) (* Goal: forall (e : Elt) (w : Word) (_ : @eq Word (wef (cons e w)) nil), @eq Word (cons e w) nil *) auto. (* Goal: forall (e : Elt) (w : Word) (_ : @eq Word (wef (cons e w)) nil), @eq Word (cons e w) nil *) unfold wef in |- *; simpl in |- *; intros x w H; discriminate H. Qed. Lemma wef_cons : forall (a b : Word) (e : Elt), cons e a = wef b -> exists x : Elt, ex2 (fun w : Word => cons x w = b) (fun w : Word => f x = e /\ wef w = a). (* Goal: forall (a b : Word) (e : Elt) (_ : @eq Word (cons e a) (wef b)), @ex Elt (fun x : Elt => @ex2 Word (fun w : Word => @eq Word (cons x w) b) (fun w : Word => and (@eq Elt (f x) e) (@eq Word (wef w) a))) *) intros a b e. (* Goal: forall _ : @eq Word (cons e a) (wef b), @ex Elt (fun x : Elt => @ex2 Word (fun w : Word => @eq Word (cons x w) b) (fun w : Word => and (@eq Elt (f x) e) (@eq Word (wef w) a))) *) unfold wef in |- *. (* Goal: forall _ : @eq Word (cons e a) (Word_ext f b), @ex Elt (fun x : Elt => @ex2 Word (fun w : Word => @eq Word (cons x w) b) (fun w : Word => and (@eq Elt (f x) e) (@eq Word (Word_ext f w) a))) *) case b. (* Goal: forall _ : @eq Word (cons e a) (Word_ext f nil), @ex Elt (fun x : Elt => @ex2 Word (fun w : Word => @eq Word (cons x w) nil) (fun w : Word => and (@eq Elt (f x) e) (@eq Word (Word_ext f w) a))) *) (* Goal: forall (e0 : Elt) (w : Word) (_ : @eq Word (cons e a) (Word_ext f (cons e0 w))), @ex Elt (fun x : Elt => @ex2 Word (fun w0 : Word => @eq Word (cons x w0) (cons e0 w)) (fun w0 : Word => and (@eq Elt (f x) e) (@eq Word (Word_ext f w0) a))) *) simpl in |- *; intro H; discriminate H. (* Goal: forall (e : Elt) (w : Word) (_ : @eq Word (Word_ext f (Append w v)) (Append (Word_ext f w) (Word_ext f v))), @eq Word (Word_ext f (Append (cons e w) v)) (Append (Word_ext f (cons e w)) (Word_ext f v)) *) simpl in |- *; intros x w H. (* Goal: @ex Elt (fun x0 : Elt => @ex2 Word (fun w0 : Word => @eq Word (cons x0 w0) (cons x w)) (fun w : Word => and (@eq Elt (f x0) e) (@eq Word (Word_ext f w) a))) *) exists x. (* Goal: @ex2 Word (fun w0 : Word => @eq Word (cons x w0) (cons x w)) (fun w : Word => and (@eq Elt (f x) e) (@eq Word (Word_ext f w) a)) *) exists w. (* Goal: @eq Word (cons x w) (cons x w) *) (* Goal: and (@eq Elt (f x) e) (@eq Word (Word_ext f w) a) *) trivial. (* Goal: forall _ : @eq Word (wef nil) nil, @eq Word nil nil *) (* Goal: forall (e : Elt) (w : Word) (_ : @eq Word (wef (cons e w)) nil), @eq Word (cons e w) nil *) injection H; auto. Qed. End more_about_words. Hint Resolve wef_cons. Lemma Append_assoc : forall a b c : Word, Append a (Append b c) = Append (Append a b) c. (* Goal: forall a b c : Word, @eq Word (Append a (Append b c)) (Append (Append a b) c) *) intros a b c. (* Goal: @eq Word (Append a (Append b c)) (Append (Append a b) c) *) unfold Append in |- *. (* Goal: forall _ : @eq Word (wef nil) nil, @eq Word nil nil *) (* Goal: forall (e : Elt) (w : Word) (_ : @eq Word (wef (cons e w)) nil), @eq Word (cons e w) nil *) elim a; auto. Qed. Hint Resolve Append_assoc.
(* This program is free software; you can redistribute it and/or *) (* modify it under the terms of the GNU Lesser General Public License *) (* as published by the Free Software Foundation; either version 2.1 *) (* of the License, or (at your option) any later version. *) (* *) (* This program is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* GNU General Public License for more details. *) (* *) (* You should have received a copy of the GNU Lesser General Public *) (* License along with this program; if not, write to the Free *) (* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *) (* 02110-1301 USA *) (* Contribution to the Coq Library V6.3 (July 1999) *) (****************************************************************************) (* The Calculus of Inductive Constructions *) (* *) (* Projet Coq *) (* *) (* INRIA ENS-CNRS *) (* Rocquencourt Lyon *) (* *) (* Coq V5.10 *) (* Nov 25th 1994 *) (* *) (****************************************************************************) (* Ensf_inclus.v *) (****************************************************************************) (* Formal Language Theory *) (* *) (* Judicael Courant - Jean-Christophe Filliatre *) (* *) (* Developped in V5.8 June-July 1993 *) (* Ported to V5.10 October 1994 *) (****************************************************************************) Require Import Ensf_types. Require Import Ensf_dans. Require Import Ensf_union. Require Import Ensf_produit. (* *) (* INCLUSION *) (* On definit le predicat (inclus E F) par (dans x E)->(dans x F). *) (* On montre ensuite facilement les resultats suivants : *) (* -- inclus empty A *) (* -- inclus A A *) (* -- (inclus a b)->(inclus c d) *) (* ->(inclus (prodcart a c) (prodcart b d) *) (* *) Definition inclus (A B : Ensf) : Prop := forall x : Elt, dans x A -> dans x B. Hint Unfold inclus. Lemma empty_inclus : forall x : Ensf, inclus empty x. (* Goal: forall x : Ensf, inclus empty x *) unfold inclus in |- *; intros. (* Goal: dans x0 x *) absurd (dans x0 empty); auto. Qed. Hint Resolve empty_inclus. Lemma refl_inclus : forall x : Ensf, inclus x x. (* Goal: forall (A B C : Ensf) (_ : inclus A C), inclus A (union B C) *) auto. Qed. Hint Resolve refl_inclus. Lemma inclus_trans : forall a b c : Ensf, inclus a b -> inclus b c -> inclus a c. (* Goal: forall (A B C : Ensf) (_ : inclus A C), inclus A (union B C) *) auto. Qed. Lemma cart_inclus : forall a b c d : Ensf, inclus a b -> inclus c d -> inclus (prodcart a c) (prodcart b d). (* Goal: forall (a b c : Ensf) (_ : inclus a c) (_ : inclus b c), inclus (union a b) c *) unfold inclus in |- *. (* Goal: forall (a b c : Ensf) (_ : forall (x : Elt) (_ : dans x a), dans x c) (_ : forall (x : Elt) (_ : dans x b), dans x c) (x : Elt) (_ : dans x (union a b)), dans x c *) intros. cut (exists x1 : Elt, (exists x2 : Elt, dans x1 a /\ dans x2 c /\ x = couple x1 x2)). (* Goal: forall (A B C : Ensf) (_ : inclus A C), inclus A (union B C) *) 2: apply coupl3; auto. intro H2; elim H2; clear H2. intros x1 H2; elim H2; clear H2. intros x2 H2; elim H2; clear H2. intros H2 H3; elim H3; clear H3. intros H3 H4. rewrite H4. (* Goal: forall (A B C : Ensf) (_ : inclus A C), inclus A (union B C) *) auto. Qed. Hint Resolve cart_inclus. Lemma inclus_add : forall (a b : Ensf) (y : Elt), inclus a b -> inclus a (add y b). (* Goal: forall (A B C : Ensf) (_ : inclus A C), inclus A (union B C) *) auto. Qed. Hint Resolve inclus_add. Lemma singl_inclus_add : forall (e : Elt) (a : Ensf), inclus (singleton e) (add e a). (* Goal: forall (a b c : Ensf) (_ : inclus a c) (_ : inclus b c), inclus (union a b) c *) unfold inclus in |- *. (* Goal: forall (e : Elt) (a : Ensf) (x : Elt) (_ : dans x (singleton e)), dans x (add e a) *) intros e a x H. (* Goal: forall (A B C : Ensf) (_ : inclus A C), inclus A (union B C) *) cut (x = e); auto. (* Goal: forall _ : @eq Elt x e, dans x (add e a) *) intro H0. (* Goal: forall (A B C : Ensf) (_ : inclus A C), inclus A (union B C) *) rewrite H0; auto. Qed. Hint Resolve singl_inclus_add. Lemma inclus_singl : forall (e : Elt) (a : Ensf), inclus (singleton e) a -> dans e a. (* Goal: forall (A B C : Ensf) (_ : inclus A C), inclus A (union B C) *) auto. Qed. Lemma add_inclus : forall (x : Elt) (a b : Ensf), dans x b -> inclus a b -> inclus (add x a) b. (* Goal: forall (a b c : Ensf) (_ : inclus a c) (_ : inclus b c), inclus (union a b) c *) unfold inclus in |- *. (* Goal: forall (a b c : Ensf) (_ : forall (x : Elt) (_ : dans x a), dans x c) (_ : forall (x : Elt) (_ : dans x b), dans x c) (x : Elt) (_ : dans x (union a b)), dans x c *) intros. cut (x = x0 \/ dans x0 a). (* Goal: forall (A B C : Ensf) (_ : inclus A C), inclus A (union B C) *) 2: apply dans_add; auto. intro H2; elim H2; clear H2. (* Goal: forall (A B C : Ensf) (_ : inclus A C), inclus A (union B C) *) intro H2; rewrite <- H2; auto. (* Goal: forall (A B C : Ensf) (_ : inclus A C), inclus A (union B C) *) auto. Qed. Hint Resolve add_inclus. Lemma dans_trans : forall (x : Elt) (a b : Ensf), dans x a -> inclus a b -> dans x b. (* Goal: forall (A B C : Ensf) (_ : inclus A C), inclus A (union B C) *) auto. Qed. Lemma union_inclus : forall a b c : Ensf, inclus a c -> inclus b c -> inclus (union a b) c. (* Goal: forall (a b c : Ensf) (_ : inclus a c) (_ : inclus b c), inclus (union a b) c *) unfold inclus in |- *. (* Goal: forall (a b c : Ensf) (_ : forall (x : Elt) (_ : dans x a), dans x c) (_ : forall (x : Elt) (_ : dans x b), dans x c) (x : Elt) (_ : dans x (union a b)), dans x c *) intros. (* Goal: forall (A B C : Ensf) (_ : inclus A C), inclus A (union B C) *) cut (dans x a \/ dans x b); auto. (* Goal: forall (A B C : Ensf) (_ : inclus A C), inclus A (union B C) *) intro H2; elim H2; auto. Qed. Hint Resolve union_inclus. Lemma inclus_g : forall a b : Ensf, inclus a (union a b). (* Goal: forall (A B C : Ensf) (_ : inclus A C), inclus A (union B C) *) auto. Qed. Lemma inclus_d : forall a b : Ensf, inclus b (union a b). (* Goal: forall (A B C : Ensf) (_ : inclus A C), inclus A (union B C) *) auto. Qed. Lemma inclus_g2 : forall A B C : Ensf, inclus A B -> inclus A (union B C). (* Goal: forall (A B C : Ensf) (_ : inclus A C), inclus A (union B C) *) auto. Qed. Hint Resolve inclus_g2. Lemma inclus_d2 : forall A B C : Ensf, inclus A C -> inclus A (union B C). (* Goal: forall (A B C : Ensf) (_ : inclus A C), inclus A (union B C) *) auto. Qed. Hint Resolve inclus_d2.
(* This program is free software; you can redistribute it and/or *) (* modify it under the terms of the GNU Lesser General Public License *) (* as published by the Free Software Foundation; either version 2.1 *) (* of the License, or (at your option) any later version. *) (* *) (* This program is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* GNU General Public License for more details. *) (* *) (* You should have received a copy of the GNU Lesser General Public *) (* License along with this program; if not, write to the Free *) (* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *) (* 02110-1301 USA *) (* Contribution to the Coq Library V6.3 (July 1999) *) (****************************************************************************) (* The Calculus of Inductive Constructions *) (* *) (* Projet Coq *) (* *) (* INRIA ENS-CNRS *) (* Rocquencourt Lyon *) (* *) (* Coq V5.10 *) (* Nov 25th 1994 *) (* *) (****************************************************************************) (* Ensf_couple.v *) (****************************************************************************) (* Formal Language Theory *) (* *) (* Judicael Courant - Jean-Christophe Filliatre *) (* *) (* Developped in V5.8 June-July 1993 *) (* Ported to V5.10 October 1994 *) (****************************************************************************) Require Import Ensf_types. (* *) (* first et second renvoient repsectivement le premier et le deuxieme *) (* element d'un couple. *) (* *) Definition first (x : Elt) : Elt := match x return Elt with | natural n => (* natural *) zero (* couple *) | couple a b => a (* up *) | up e => zero (* word *) | word w => zero end. Definition second (x : Elt) : Elt := match x return Elt with | natural n => (* natural *) zero (* couple *) | couple a b => b (* up *) | up e => zero (* word *) | word w => zero end. (* Grace a first et second on recupere facilement le lemme suivant : *) Lemma equal_couple : forall x y z t : Elt, couple x y = couple z t :>Elt -> x = z :>Elt /\ y = t :>Elt. (* Goal: forall (x y z t : Elt) (_ : @eq Elt (couple x y) (couple z t)), and (@eq Elt x z) (@eq Elt y t) *) intros x y z t H. (* Goal: @eq Elt c d *) injection H; auto. Qed. Lemma couple_couple_inv1 : forall a b c d : Elt, couple a c = couple b d :>Elt -> a = b :>Elt. (* Goal: forall (a b c d : Elt) (_ : @eq Elt (couple a c) (couple b d)), @eq Elt c d *) intros a b c d H. (* Goal: @eq Elt c d *) injection H; auto. Qed. Lemma couple_couple_inv2 : forall a b c d : Elt, couple a c = couple b d :>Elt -> c = d :>Elt. (* Goal: forall (a b c d : Elt) (_ : @eq Elt (couple a c) (couple b d)), @eq Elt c d *) intros a b c d H. (* Goal: @eq Elt c d *) injection H; auto. Qed.
(* This program is free software; you can redistribute it and/or *) (* modify it under the terms of the GNU Lesser General Public License *) (* as published by the Free Software Foundation; either version 2.1 *) (* of the License, or (at your option) any later version. *) (* *) (* This program is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* GNU General Public License for more details. *) (* *) (* You should have received a copy of the GNU Lesser General Public *) (* License along with this program; if not, write to the Free *) (* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *) (* 02110-1301 USA *) (* Contribution to the Coq Library V6.3 (July 1999) *) (****************************************************************************) (* The Calculus of Inductive Constructions *) (* *) (* Projet Coq *) (* *) (* INRIA ENS-CNRS *) (* Rocquencourt Lyon *) (* *) (* Coq V5.10 *) (* Nov 25th 1994 *) (* *) (****************************************************************************) (* Relations.v *) (****************************************************************************) (* Formal Language Theory *) (* *) (* Judicael Courant - Jean-Christophe Filliatre *) (* *) (* Developped in V5.8 June-July 1993 *) (* Ported to V5.10 October 1994 *) (****************************************************************************) (*Resultats sur les relations sur un Set,*) (*copie de THEORIES/RELATIONS/Relations.v*) (*ou l'on a remplace Type par Set et ou l'on definit le predicat Rstar_inv *) Section Relations. (* Properties of a binary relation R on type A *) Variable A : Set. Variable R : A -> A -> Prop. (* Definition of the reflexive-transitive closure R* of R *) (* Smallest reflexive P containing R o P *) Definition Rstar (x y : A) := forall P : A -> A -> Prop, (forall u : A, P u u) -> (forall u v w : A, R u v -> P v w -> P u w) -> P x y. Theorem Rstar_reflexive : forall x : A, Rstar x x. Proof fun (x : A) (P : A -> A -> Prop) (h1 : forall u : A, P u u) (h2 : forall u v w : A, R u v -> P v w -> P u w) => h1 x. Theorem Rstar_R : forall x y z : A, R x y -> Rstar y z -> Rstar x z. Proof fun (x y z : A) (t1 : R x y) (t2 : Rstar y z) (P : A -> A -> Prop) (h1 : forall u : A, P u u) (h2 : forall u v w : A, R u v -> P v w -> P u w) => h2 x y z t1 (t2 P h1 h2). (* We conclude with transitivity of Rstar : *) Theorem Rstar_transitive : forall x y z : A, Rstar x y -> Rstar y z -> Rstar x z. Proof fun (x y z : A) (h : Rstar x y) => h (fun u v : A => Rstar v z -> Rstar u z) (fun (u : A) (t : Rstar u z) => t) (fun (u v w : A) (t1 : R u v) (t2 : Rstar w z -> Rstar v z) (t3 : Rstar w z) => Rstar_R u v z t1 (t2 t3)). (* Another characterization of R* *) (* Smallest reflexive P containing R o R* *) Definition Rstar' (x y : A) := forall P : A -> A -> Prop, P x x -> (forall u : A, R x u -> Rstar u y -> P x y) -> P x y. Theorem Rstar'_reflexive : forall x : A, Rstar' x x. Proof fun (x : A) (P : A -> A -> Prop) (h : P x x) (h' : forall u : A, R x u -> Rstar u x -> P x x) => h. Theorem Rstar'_R : forall x y z : A, R x z -> Rstar z y -> Rstar' x y. Proof fun (x y z : A) (t1 : R x z) (t2 : Rstar z y) (P : A -> A -> Prop) (h1 : P x x) (h2 : forall u : A, R x u -> Rstar u y -> P x y) => h2 z t1 t2. (* Equivalence of the two definitions: *) Theorem Rstar'_Rstar : forall x y : A, Rstar' x y -> Rstar x y. Proof fun (x y : A) (h : Rstar' x y) => h Rstar (Rstar_reflexive x) (fun u : A => Rstar_R x u y). Theorem Rstar_Rstar' : forall x y : A, Rstar x y -> Rstar' x y. Proof fun (x y : A) (h : Rstar x y) => h Rstar' (fun u : A => Rstar'_reflexive u) (fun (u v w : A) (h1 : R u v) (h2 : Rstar' v w) => Rstar'_R u w v h1 (Rstar'_Rstar v w h2)). (* inversion de Rstar*) Lemma Rstar_inv : forall x y : A, Rstar x y -> x = y \/ ex2 (fun z : A => R x z) (fun z : A => Rstar z y). (* Goal: forall (x y : A) (_ : Rstar x y), or (@eq A x y) (@ex2 A (fun z : A => R x z) (fun z : A => Rstar z y)) *) intros x y Rstar_x_y. (* Goal: or (@eq A x y) (@ex2 A (fun z : A => R x z) (fun z : A => Rstar z y)) *) pattern x, y in |- *. (* Goal: (fun a a0 : A => or (@eq A a a0) (@ex2 A (fun z : A => R a z) (fun z : A => Rstar z a0))) x y *) apply Rstar_x_y. (* Goal: forall u : A, or (@eq A u u) (@ex2 A (fun z : A => R u z) (fun z : A => Rstar z u)) *) (* Goal: forall (u v w : A) (_ : R u v) (_ : or (@eq A v w) (@ex2 A (fun z : A => R v z) (fun z : A => Rstar z w))), or (@eq A u w) (@ex2 A (fun z : A => R u z) (fun z : A => Rstar z w)) *) auto. (* Goal: forall (u v w : A) (_ : R u v) (_ : or (@eq A v w) (@ex2 A (fun z : A => R v z) (fun z : A => Rstar z w))), or (@eq A u w) (@ex2 A (fun z : A => R u z) (fun z : A => Rstar z w)) *) intros u v w R_u_v Hyp. (* Goal: or (@eq A u w) (@ex2 A (fun z : A => R u z) (fun z : A => Rstar z w)) *) apply or_intror. (* Goal: @ex2 A (fun z : A => R u z) (fun z : A => Rstar z w) *) exists v. (* Goal: R u v *) (* Goal: Rstar v w *) assumption. (* Goal: Rstar v w *) elim Hyp. (* Goal: forall _ : @eq A v w, Rstar v w *) (* Goal: forall _ : @ex2 A (fun z : A => R v z) (fun z : A => Rstar z w), Rstar v w *) intro Rew. (* Goal: Rstar v w *) (* Goal: forall _ : @ex2 A (fun z : A => R v z) (fun z : A => Rstar z w), Rstar v w *) rewrite Rew. (* Goal: Rstar w w *) (* Goal: forall _ : @ex2 A (fun z : A => R v z) (fun z : A => Rstar z w), Rstar v w *) apply Rstar_reflexive. (* Goal: forall _ : @ex2 A (fun z : A => R v z) (fun z : A => Rstar z w), Rstar v w *) intro temp; elim temp; clear temp. (* Goal: forall (x : A) (_ : R v x) (_ : Rstar x w), Rstar v w *) intros z R_v_z Rstar_z_w. (* Goal: R u v *) (* Goal: Rstar v w *) apply Rstar_R with z; assumption. Qed. End Relations. Hint Resolve Rstar_reflexive.
(* This program is free software; you can redistribute it and/or *) (* modify it under the terms of the GNU Lesser General Public License *) (* as published by the Free Software Foundation; either version 2.1 *) (* of the License, or (at your option) any later version. *) (* *) (* This program is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* GNU General Public License for more details. *) (* *) (* You should have received a copy of the GNU Lesser General Public *) (* License along with this program; if not, write to the Free *) (* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *) (* 02110-1301 USA *) (* Contribution to the Coq Library V6.3 (July 1999) *) (****************************************************************************) (* The Calculus of Inductive Constructions *) (* *) (* Projet Coq *) (* *) (* INRIA ENS-CNRS *) (* Rocquencourt Lyon *) (* *) (* Coq V5.10 *) (* Nov 25th 1994 *) (* *) (****************************************************************************) (* extract.v *) (****************************************************************************) (* Formal Language Theory *) (* *) (* Judicael Courant - Jean-Christophe Filliatre *) (* *) (* Developped in V5.8 June-July 1993 *) (* Ported to V5.10 October 1994 *) (****************************************************************************) Require Import Ensf. Require Import more_words. Require Import PushdownAutomata. Require Import gram. Require Import gram_aut. Section def_axiom_APD. Variable X P : Ensf. Variable wd : Word. Variable wa : Word. Variable d : Ensf. Let L := LA X wd wa d. Axiom axiom_APD : P_automata X P wd wa d -> forall u : Word, {L u} + {~ L u}. End def_axiom_APD. Section parser. Variable X V R : Ensf. Variable S' : Elt. Hypothesis H : isGram X V R S'. Let LL := LG X V R S'. Let P := union X V. Let f_R_d (a : Elt) := couple (word (cons (first a) nil)) (couple (eps X) (second a)). Let f_X_d (x : Elt) := couple (word (cons x nil)) (couple x (word nil)). Let d := union (map f_R_d R) (map f_X_d X). Let wd := cons S' nil. Let wa := nil. Let L := LA X wd wa d. Theorem Parser1 : forall u : Word, {LL u} + {~ LL u}. (* Goal: forall (_ : forall (w : Word) (_ : L w), LL w) (_ : forall (w : Word) (_ : LL w), L w), L u *) (* Goal: l_egal L LL *) (* Goal: sumbool (L u) (not (L u)) *) intros. (* Goal: sumbool (LL u) (not (LL u)) *) elimtype ({L u} + {~ L u}). (* Goal: forall _ : forall _ : L u, False, sumbool (LL u) (forall _ : LL u, False) *) (* Goal: sumbool (L u) (not (L u)) *) intro Hyp. (* Goal: sumbool (LL u) (not (LL u)) *) (* Goal: forall _ : not (L u), sumbool (LL u) (not (LL u)) *) (* Goal: sumbool (L u) (not (L u)) *) left. (* Goal: L u *) (* Goal: sumbool (L u) (not (L u)) *) cut (l_egal L LL). (* Goal: forall _ : l_egal L LL, L u *) (* Goal: l_egal L LL *) (* Goal: sumbool (L u) (not (L u)) *) intro temp; elim temp. (* Goal: forall (_ : l_inclus L LL) (_ : l_inclus LL L), L u *) (* Goal: l_egal L LL *) (* Goal: sumbool (L u) (not (L u)) *) unfold l_inclus in |- *. (* Goal: forall (_ : forall (w : Word) (_ : L w), LL w) (_ : forall (w : Word) (_ : LL w), L w), L u *) (* Goal: l_egal L LL *) (* Goal: sumbool (L u) (not (L u)) *) intros. (* Goal: L u *) (* Goal: l_egal L LL *) (* Goal: sumbool (L u) (not (L u)) *) auto. (* Goal: l_egal L LL *) (* Goal: sumbool (L u) (not (L u)) *) unfold L, LL, wa, wd, d, f_R_d, f_X_d in |- *. (* Goal: l_egal (LA X (cons S' nil) nil (union (map (fun a : Elt => couple (word (cons (first a) nil)) (couple (eps X) (second a))) R) (map (fun x : Elt => couple (word (cons x nil)) (couple x (word nil))) X))) (LG X V R S') *) (* Goal: sumbool (L u) (not (L u)) *) apply equiv_APD_Gram. (* Goal: isGram X V R S' *) exact H. (* Goal: forall _ : not (L u), sumbool (LL u) (not (LL u)) *) (* Goal: sumbool (L u) (not (L u)) *) unfold not in |- *. (* Goal: forall _ : forall _ : L u, False, sumbool (LL u) (forall _ : LL u, False) *) (* Goal: sumbool (L u) (not (L u)) *) intro Hyp. (* Goal: sumbool (LL u) (forall _ : LL u, False) *) (* Goal: sumbool (L u) (not (L u)) *) right. (* Goal: forall _ : LL u, False *) (* Goal: sumbool (L u) (not (L u)) *) intro LL_u. (* Goal: False *) (* Goal: sumbool (L u) (not (L u)) *) apply Hyp. (* Goal: L u *) (* Goal: sumbool (L u) (not (L u)) *) cut (l_egal L LL). (* Goal: forall _ : l_egal L LL, L u *) (* Goal: l_egal L LL *) (* Goal: sumbool (L u) (not (L u)) *) intro temp; elim temp. (* Goal: forall (_ : l_inclus L LL) (_ : l_inclus LL L), L u *) (* Goal: l_egal L LL *) (* Goal: sumbool (L u) (not (L u)) *) unfold l_inclus in |- *. (* Goal: forall (_ : forall (w : Word) (_ : L w), LL w) (_ : forall (w : Word) (_ : LL w), L w), L u *) (* Goal: l_egal L LL *) (* Goal: sumbool (L u) (not (L u)) *) intros. (* Goal: L u *) (* Goal: l_egal L LL *) (* Goal: sumbool (L u) (not (L u)) *) auto. (* Goal: l_egal L LL *) (* Goal: sumbool (L u) (not (L u)) *) unfold L, LL, wa, wd, d, f_R_d, f_X_d in |- *. (* Goal: l_egal (LA X (cons S' nil) nil (union (map (fun a : Elt => couple (word (cons (first a) nil)) (couple (eps X) (second a))) R) (map (fun x : Elt => couple (word (cons x nil)) (couple x (word nil))) X))) (LG X V R S') *) (* Goal: sumbool (L u) (not (L u)) *) apply equiv_APD_Gram. (* Goal: isGram X V R S' *) exact H. (* Goal: sumbool (L u) (not (L u)) *) unfold L in |- *. (* Goal: sumbool (LA X wd wa d u) (not (LA X wd wa d u)) *) apply axiom_APD with P. (* Goal: P_automata X P wd wa d *) unfold P, wd, wa, d, f_R_d, f_X_d in |- *. (* Goal: P_automata X (union X V) (cons S' nil) nil (union (map (fun a : Elt => couple (word (cons (first a) nil)) (couple (eps X) (second a))) R) (map (fun x : Elt => couple (word (cons x nil)) (couple x (word nil))) X)) *) apply X_P_wd_wa_d. (* Goal: isGram X V R S' *) exact H. Qed. End parser.
(* This program is free software; you can redistribute it and/or *) (* modify it under the terms of the GNU Lesser General Public License *) (* as published by the Free Software Foundation; either version 2.1 *) (* of the License, or (at your option) any later version. *) (* *) (* This program is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* GNU General Public License for more details. *) (* *) (* You should have received a copy of the GNU Lesser General Public *) (* License along with this program; if not, write to the Free *) (* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *) (* 02110-1301 USA *) (* Contribution to the Coq Library V6.3 (July 1999) *) (****************************************************************************) (* The Calculus of Inductive Constructions *) (* *) (* Projet Coq *) (* *) (* INRIA ENS-CNRS *) (* Rocquencourt Lyon *) (* *) (* Coq V5.10 *) (* Nov 25th 1994 *) (* *) (****************************************************************************) (* PushdownAutomata.v *) (****************************************************************************) (* Formal Language Theory *) (* *) (* Judicael Courant - Jean-Christophe Filliatre *) (* *) (* Developped in V5.8 June-July 1993 *) (* Ported to V5.10 October 1994 *) (****************************************************************************) Require Import Ensf. Require Import Max. Require Import Words. Require Import fonctions. Require Import need. Require Import Relations. Section pushdown_automata. Variable X P : Ensf. Variable wd : Word. Variable wa : Word. Variable d : Ensf. Definition eps := natural (sup X). Lemma not_dans_X_eps : ~ dans eps X. (* Goal: not (dans eps X) *) unfold eps in |- *. (* Goal: not (dans (natural (sup X)) X) *) apply sup_out. Qed. Definition Transition : Prop := forall x : Elt, dans x d -> exists2 w1 : Word, inmonoid P w1 & (exists2 y : Elt, dans y (add eps X) & (exists2 w2 : Word, inmonoid P w2 & x = couple (word w1) (couple y (word w2)) :>Elt)). Definition P_automata := inmonoid P wd /\ inmonoid P wa /\ Transition. Lemma P_automata_1 : P_automata -> inmonoid P wd. (* Goal: forall _ : P_automata, Transition *) unfold P_automata in |- *. (* Goal: forall _ : and (inmonoid P wd) (and (inmonoid P wa) Transition), inmonoid P wd *) intro temp; elim temp. (* Goal: forall (_ : inmonoid P wa) (_ : Transition), Transition *) auto. Qed. Lemma P_automata_2 : P_automata -> Transition. (* Goal: forall _ : P_automata, Transition *) unfold P_automata in |- *. (* Goal: forall _ : and (inmonoid P wd) (and (inmonoid P wa) Transition), Transition *) intro temp; elim temp; clear temp. (* Goal: forall (_ : inmonoid P wd) (_ : and (inmonoid P wa) Transition), Transition *) intros H temp; elim temp; clear temp. (* Goal: forall (_ : inmonoid P wa) (_ : Transition), Transition *) auto. Qed. Definition Conf := (Word * Word)%type. Inductive Derive_P_A : Conf -> Conf -> Prop := | Derive_cons : forall (w w1 w2 u : Word) (x : Elt), dans x X -> dans (couple (word w1) (couple x (word w2))) d -> Derive_P_A (pair (Append w1 w) (cons x u)) (pair (Append w2 w) u) | Derive_eps : forall w w1 w2 u : Word, dans (couple (word w1) (couple eps (word w2))) d -> Derive_P_A (pair (Append w1 w) u) (pair (Append w2 w) u). Definition Derivestar_P_A := Rstar Conf Derive_P_A. Definition LA (u : Word) := Derivestar_P_A (pair wd u) (pair wa nil) /\ inmonoid X u. Lemma LA_langage : islanguage X LA. (* Goal: islanguage X LA *) unfold LA, islanguage in |- *. (* Goal: forall (_ : inmonoid P wa) (_ : Transition), Transition *) intros w temp; elim temp; clear temp; auto. Qed. End pushdown_automata.
(* This program is free software; you can redistribute it and/or *) (* modify it under the terms of the GNU Lesser General Public License *) (* as published by the Free Software Foundation; either version 2.1 *) (* of the License, or (at your option) any later version. *) (* *) (* This program is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* GNU General Public License for more details. *) (* *) (* You should have received a copy of the GNU Lesser General Public *) (* License along with this program; if not, write to the Free *) (* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *) (* 02110-1301 USA *) (* Contribution to the Coq Library V6.3 (July 1999) *) (****************************************************************************) (* The Calculus of Inductive Constructions *) (* *) (* Projet Coq *) (* *) (* INRIA ENS-CNRS *) (* Rocquencourt Lyon *) (* *) (* Coq V5.10 *) (* Nov 25th 1994 *) (* *) (****************************************************************************) (* Ensf_disj.v *) (****************************************************************************) (* Formal Language Theory *) (* *) (* Judicael Courant - Jean-Christophe Filliatre *) (* *) (* Developped in V5.8 June-July 1993 *) (* Ported to V5.10 October 1994 *) (****************************************************************************) Require Import Ensf_types. Require Import Ensf_dans. Require Import Ensf_union. Require Import Ensf_couple. Require Import Ensf_inclus. Require Import Ensf_map. (* *) (* UNION DISJOINTE *) (* L'union disjointe de A et B est definie comme l'ensemble des *) (* des couples (x,zero) pour x dans A et (x,un) pour x dans B *) (* Pour cela on definit 2 fonctions injgauche : x->(x,zero) et *) (* injdroite : x->(x,un) et on fait l'union de (map injgauche A) *) (* et de (map injdroite B). *) (* *) Definition injgauche (e : Elt) : Elt := couple e zero. Definition injdroite (e : Elt) : Elt := couple e un. Definition union_disj (e f : Ensf) : Ensf := union (map injgauche e) (map injdroite f). Lemma dans_map_injg : forall (e : Ensf) (x : Elt), dans x (map injgauche e) -> dans (first x) e. (* Goal: forall (x : Elt) (a b : Ensf) (_ : dans x a), dans (injgauche x) (union_disj a b) *) intros. cut (exists y : Elt, dans y e /\ x = injgauche y). 2: apply dans_map; auto. intro Ht; elim Ht; clear Ht. intros y Ht; elim Ht; clear Ht. (* Goal: forall (x : Elt) (a b : Ensf) (_ : dans x a), dans (injgauche x) (union_disj a b) *) intros. unfold injgauche in H1. replace (first x) with y; auto. symmetry in |- *. replace y with (first (couple y zero)); auto. apply (f_equal (A:=Elt) (B:=Elt)); auto. Qed. Lemma dans_map_injd : forall (e : Ensf) (x : Elt), dans x (map injdroite e) -> dans (first x) e. (* Goal: forall (x : Elt) (a b : Ensf) (_ : dans x a), dans (injgauche x) (union_disj a b) *) intros. cut (exists y : Elt, dans y e /\ x = injdroite y). 2: apply dans_map; auto. intro Ht; elim Ht; clear Ht. intros y Ht; elim Ht; clear Ht. (* Goal: forall (x : Elt) (a b : Ensf) (_ : dans x a), dans (injgauche x) (union_disj a b) *) intros. unfold injdroite in H1. replace (first x) with y; auto. symmetry in |- *. replace y with (first (couple y un)); auto. apply (f_equal (A:=Elt) (B:=Elt)); auto. Qed. Lemma absurd_injg_injd : forall (x : Elt) (e f : Ensf), dans x (map injgauche e) -> ~ dans x (map injdroite f). (* Goal: forall (x : Elt) (a b : Ensf) (_ : dans x a), dans (injgauche x) (union_disj a b) *) intros. cut (exists y : Elt, dans y e /\ x = injgauche y). 2: apply dans_map; auto. intro Ht; elim Ht; clear Ht. intros y Ht; elim Ht; clear Ht. (* Goal: forall (x : Elt) (a b : Ensf) (_ : dans x a), dans (injgauche x) (union_disj a b) *) intros. red in |- *. intro. cut (exists y' : Elt, dans y' f /\ x = injdroite y' :>Elt). 2: apply dans_map; auto. intro Ht; elim Ht; clear Ht. intros y' Ht; elim Ht; clear Ht. (* Goal: forall (x : Elt) (a b : Ensf) (_ : dans x a), dans (injgauche x) (union_disj a b) *) intros. absurd (zero = un :>Elt). unfold zero in |- *. unfold un in |- *. discriminate. unfold injdroite in H4. unfold injgauche in H1. replace zero with (second (couple y zero)); auto. replace un with (second (couple y' un)); auto. rewrite <- H4. rewrite <- H1. (* Goal: dans x a *) auto. Qed. (* *) (* On montre ici que si x est dans l'union disjointe de A et B alors *) (* x est soit de la forme (injgauche y) avec y dans A, soit de la *) (* forme (injdroite y) avec y dans B *) (* *) Lemma union_disj1 : forall (x : Elt) (a b : Ensf), dans x (union_disj a b) -> (exists y : Elt, dans y a /\ x = injgauche y :>Elt) \/ (exists y : Elt, dans y b /\ x = injdroite y :>Elt). (* Goal: dans (injgauche x) (union_disj a b) *) unfold union_disj in |- *. (* Goal: forall (x : Elt) (a b : Ensf) (_ : dans x a), dans (injgauche x) (union_disj a b) *) intros. cut (dans x (map injgauche a) \/ dans x (map injdroite b)). (* Goal: dans x a *) 2: auto. intro H0; elim H0; clear H0. intro; left. (* Goal: dans x a *) apply dans_map; auto. intro; right. (* Goal: dans x a *) apply dans_map; auto. Qed. Lemma union_disj_d : forall (x : Elt) (a b : Ensf), dans x b -> dans (injdroite x) (union_disj a b). (* Goal: forall (x : Elt) (a b : Ensf) (_ : dans x a), dans (injgauche x) (union_disj a b) *) intros. (* Goal: dans (injgauche x) (union_disj a b) *) unfold union_disj in |- *. (* Goal: dans (injdroite x) (union (map injgauche a) (map injdroite b)) *) apply union_d. (* Goal: dans (injgauche x) (map injgauche a) *) apply dans_map_inv. (* Goal: dans x a *) auto. Qed. Lemma union_disj_g : forall (x : Elt) (a b : Ensf), dans x a -> dans (injgauche x) (union_disj a b). (* Goal: forall (x : Elt) (a b : Ensf) (_ : dans x a), dans (injgauche x) (union_disj a b) *) intros. (* Goal: dans (injgauche x) (union_disj a b) *) unfold union_disj in |- *. (* Goal: dans (injgauche x) (union (map injgauche a) (map injdroite b)) *) apply union_g. (* Goal: dans (injgauche x) (map injgauche a) *) apply dans_map_inv. (* Goal: dans x a *) auto. Qed. Lemma inclus_union_disj : forall a b c d : Ensf, inclus a c -> inclus b d -> inclus (union_disj a b) (union_disj c d). unfold inclus in |- *. (* Goal: forall (x : Elt) (a b : Ensf) (_ : dans x a), dans (injgauche x) (union_disj a b) *) intros. unfold union_disj in H1. (* Goal: dans x a *) cut (dans x (map injgauche a) \/ dans x (map injdroite b)); auto. intro Ht; elim Ht; clear Ht. intro. cut (exists y : Elt, dans y a /\ x = injgauche y). 2: apply dans_map; auto. intro Ht; elim Ht; clear Ht. intros y Ht; elim Ht; clear Ht; intros H3 H4. (* Goal: dans x a *) cut (dans y c); auto. intro. (* Goal: dans (injgauche x) (union_disj a b) *) unfold union_disj in |- *. (* Goal: dans (injgauche x) (union (map injgauche a) (map injdroite b)) *) apply union_g. rewrite H4. (* Goal: dans x a *) apply dans_map_inv; auto. intro. cut (exists y : Elt, dans y b /\ x = injdroite y :>Elt). 2: apply dans_map; auto. intro Ht; elim Ht; clear Ht. intros y Ht; elim Ht; clear Ht; intros H3 H4. (* Goal: dans x a *) cut (dans y d); auto. intro. (* Goal: dans (injgauche x) (union_disj a b) *) unfold union_disj in |- *. (* Goal: dans (injdroite x) (union (map injgauche a) (map injdroite b)) *) apply union_d. rewrite H4. (* Goal: dans x a *) apply dans_map_inv; auto. Qed. (* *) (* Resultats n'ayant rien a voir avec les ensembles finis mais n'ayant *) (* pas de place dans un fichier particulier. *) (* *) Lemma pair_equal : forall (A B : Set) (x x' : A) (y y' : B), x = x' :>A -> y = y' :>B -> pair x y = pair x' y' :>A * B. (* Goal: forall (A B : Set) (x x' : A) (y y' : B) (_ : @eq A x x') (_ : @eq B y y'), @eq (prod A B) (@pair A B x y) (@pair A B x' y') *) intros A B x x' y y' X Y. (* Goal: @eq (prod A B) (@pair A B x y) (@pair A B x' y') *) rewrite X. (* Goal: @eq (prod A B) (@pair A B x' y) (@pair A B x' y') *) rewrite Y. (* Goal: @eq (prod A B) (@pair A B x' y') (@pair A B x' y') *) apply refl_equal. Qed. Hint Resolve pair_equal.
(* This program is free software; you can redistribute it and/or *) (* modify it under the terms of the GNU Lesser General Public License *) (* as published by the Free Software Foundation; either version 2.1 *) (* of the License, or (at your option) any later version. *) (* *) (* This program is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* GNU General Public License for more details. *) (* *) (* You should have received a copy of the GNU Lesser General Public *) (* License along with this program; if not, write to the Free *) (* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *) (* 02110-1301 USA *) (* Contribution to the Coq Library V6.3 (July 1999) *) (****************************************************************************) (* The Calculus of Inductive Constructions *) (* *) (* Projet Coq *) (* *) (* INRIA ENS-CNRS *) (* Rocquencourt Lyon *) (* *) (* Coq V5.10 *) (* Nov 25th 1994 *) (* *) (****************************************************************************) (* gram.v *) (****************************************************************************) (* Formal Language Theory *) (* *) (* Judicael Courant - Jean-Christophe Filliatre *) (* *) (* Developped in V5.8 June-July 1993 *) (* Ported to V5.10 October 1994 *) (****************************************************************************) Require Import Ensf. Require Import Words. Require Import more_words. Require Import need. Require Import fonctions. Require Import Relations. Definition Mots (X : Ensf) := forall a : Elt, dans a X -> exists w : Word, word w = a. Definition Regles (X V R : Ensf) := forall x : Elt, dans x R -> ex2 (fun A : Elt => dans A V) (fun A : Elt => ex2 (fun B : Word => x = couple A (word B)) (fun B : Word => inmonoid (union X V) B)). Lemma Regles_inv1 : forall (X V R : Ensf) (x y : Elt), Regles X V R -> dans (couple x y) R -> dans x V. (* Goal: forall (X V R : Ensf) (x y : Elt) (_ : Regles X V R) (_ : dans (couple x y) R), dans x V *) intros X V R x y Regles_R dans_couple_R. cut (ex2 (fun A : Elt => dans A V) (fun A : Elt => ex2 (fun B : Word => couple x y = couple A (word B)) (fun B : Word => inmonoid (union X V) B))). (* Goal: forall _ : @ex2 Elt (fun A : Elt => dans A V) (fun A : Elt => @ex2 Word (fun B : Word => @eq Elt (couple x (word u)) (couple A (word B))) (fun B : Word => inmonoid (union X V) B)), inmonoid (union X V) u *) (* Goal: @ex2 Elt (fun A : Elt => dans A V) (fun A : Elt => @ex2 Word (fun B : Word => @eq Elt (couple x (word u)) (couple A (word B))) (fun B : Word => inmonoid (union X V) B)) *) intro temp; elim temp; clear temp. (* Goal: forall (x0 : Elt) (_ : dans x0 V) (_ : @ex2 Word (fun B : Word => @eq Elt (couple x (word u)) (couple x0 (word B))) (fun B : Word => inmonoid (union X V) B)), inmonoid (union X V) u *) (* Goal: @ex2 Elt (fun A : Elt => dans A V) (fun A : Elt => @ex2 Word (fun B : Word => @eq Elt (couple x (word u)) (couple A (word B))) (fun B : Word => inmonoid (union X V) B)) *) intros x0 dans_x0_V temp; elim temp; clear temp. (* Goal: forall (x1 : Word) (_ : @eq Elt (couple x y) (couple x0 (word x1))) (_ : inmonoid (union X V) x1), dans x V *) (* Goal: @ex2 Elt (fun A : Elt => dans A V) (fun A : Elt => @ex2 Word (fun B : Word => @eq Elt (couple x y) (couple A (word B))) (fun B : Word => inmonoid (union X V) B)) *) intros u eg_couple inmonoid_u. (* Goal: dans x V *) (* Goal: @ex2 Elt (fun A : Elt => dans A V) (fun A : Elt => @ex2 Word (fun B : Word => @eq Elt (couple x y) (couple A (word B))) (fun B : Word => inmonoid (union X V) B)) *) replace x with x0; prolog [ sym_equal couple_couple_inv1 ] 3. (*Assumption. Apply sym_equal. Apply couple_couple_inv1 with y (word u); Assumption.*) (* Goal: forall u : Word, Derivestar R2 u u *) (* Goal: forall (u v w : Word) (_ : Derive R1 u v) (_ : Derivestar R2 v w), Derivestar R2 u w *) auto. Qed. Lemma Regles_inv2 : forall (X V R : Ensf) (x : Elt) (u : Word), Regles X V R -> dans (couple x (word u)) R -> inmonoid (union X V) u. (* Goal: forall (X V R : Ensf) (x : Elt) (u : Word) (_ : Regles X V R) (_ : dans (couple x (word u)) R), inmonoid (union X V) u *) intros X V R x u Regles_R dans_couple_R. (**) cut (ex2 (fun A : Elt => dans A V) (fun A : Elt => ex2 (fun B : Word => couple x (word u) = couple A (word B)) (fun B : Word => inmonoid (union X V) B))). (* Goal: forall _ : @ex2 Elt (fun A : Elt => dans A V) (fun A : Elt => @ex2 Word (fun B : Word => @eq Elt (couple x (word u)) (couple A (word B))) (fun B : Word => inmonoid (union X V) B)), inmonoid (union X V) u *) (* Goal: @ex2 Elt (fun A : Elt => dans A V) (fun A : Elt => @ex2 Word (fun B : Word => @eq Elt (couple x (word u)) (couple A (word B))) (fun B : Word => inmonoid (union X V) B)) *) intro temp; elim temp; clear temp. (* Goal: forall (x0 : Elt) (_ : dans x0 V) (_ : @ex2 Word (fun B : Word => @eq Elt (couple x (word u)) (couple x0 (word B))) (fun B : Word => inmonoid (union X V) B)), inmonoid (union X V) u *) (* Goal: @ex2 Elt (fun A : Elt => dans A V) (fun A : Elt => @ex2 Word (fun B : Word => @eq Elt (couple x (word u)) (couple A (word B))) (fun B : Word => inmonoid (union X V) B)) *) intros x0 dans_x0_V temp; elim temp; clear temp. (* Goal: forall (x1 : Word) (_ : @eq Elt (couple x (word u)) (couple x0 (word x1))) (_ : inmonoid (union X V) x1), inmonoid (union X V) u *) (* Goal: @ex2 Elt (fun A : Elt => dans A V) (fun A : Elt => @ex2 Word (fun B : Word => @eq Elt (couple x (word u)) (couple A (word B))) (fun B : Word => inmonoid (union X V) B)) *) intros u0 eg_couple inmonoid_u0. (* Goal: inmonoid (union X V) u *) (* Goal: @ex2 Elt (fun A : Elt => dans A V) (fun A : Elt => @ex2 Word (fun B : Word => @eq Elt (couple x (word u)) (couple A (word B))) (fun B : Word => inmonoid (union X V) B)) *) replace u with u0; prolog [ sym_equal couple_couple_inv2 word_word_inv ] 4. (*Assumption. Apply word_word_inv. Apply couple_couple_inv2 with x0 x;Auto.*) (* Goal: forall u : Word, Derivestar R2 u u *) (* Goal: forall (u v w : Word) (_ : Derive R1 u v) (_ : Derivestar R2 v w), Derivestar R2 u w *) (**) auto. Qed. (* Definition d'une grammaire, *) (*X : ensemble des terminaux, *) (*V ensemble des non-terminaux, *) (*R ensemble des productions A -> w, *) (*S axiome *) Definition isGram (X V R : Ensf) (S : Elt) : Prop := Mots X /\ inter X V empty /\ dans S V /\ Regles X V R. Section Easy_lemma_isGram. Variable X V R : Ensf. Variable S : Elt. Let H := isGram X V R S. Lemma isGram1 : H -> Mots X. (* Goal: forall _ : H, Regles X V R *) intro H1. (* Goal: Regles X V R *) elim H1. (* Goal: forall (_ : Mots X) (_ : and (inter X V empty) (and (dans S V) (Regles X V R))), Mots X *) trivial. Qed. Lemma isGram2 : H -> inter X V empty. (* Goal: forall _ : H, Regles X V R *) intro H1. (* Goal: Regles X V R *) elim H1. (* Goal: forall _ : False, @ex Elt (fun A : Elt => @ex2 Word (fun w : Word => @eq Word (cons A w) nil) (fun w : Word => or (@ex2 Word (fun u : Word => dans (couple A (word u)) R) (fun u : Word => @ex2 Word (fun v : Word => @eq Word (cons A v) nil) (fun v : Word => @eq Word (Append u v) y))) (@ex2 Word (fun v : Word => Derive R w v) (fun v : Word => @eq Word (cons A v) y)))) *) (* Goal: forall (e : Elt) (w : Word) (_ : forall _ : Derive_inv R w y, @ex Elt (fun A : Elt => @ex2 Word (fun w0 : Word => @eq Word (cons A w0) w) (fun w0 : Word => or (@ex2 Word (fun u : Word => dans (couple A (word u)) R) (fun u : Word => @ex2 Word (fun v : Word => @eq Word (cons A v) w) (fun v : Word => @eq Word (Append u v) y))) (@ex2 Word (fun v : Word => Derive R w0 v) (fun v : Word => @eq Word (cons A v) y))))) (_ : Derive_inv R (cons e w) y), @ex Elt (fun A : Elt => @ex2 Word (fun w0 : Word => @eq Word (cons A w0) (cons e w)) (fun w0 : Word => or (@ex2 Word (fun u : Word => dans (couple A (word u)) R) (fun u : Word => @ex2 Word (fun v : Word => @eq Word (cons A v) (cons e w)) (fun v : Word => @eq Word (Append u v) y))) (@ex2 Word (fun v : Word => Derive R w0 v) (fun v : Word => @eq Word (cons A v) y)))) *) intuition. Qed. Lemma isGram3 : H -> dans S V. (* Goal: forall _ : H, Regles X V R *) intro H1. (* Goal: Regles X V R *) elim H1. (* Goal: forall _ : False, @ex Elt (fun A : Elt => @ex2 Word (fun w : Word => @eq Word (cons A w) nil) (fun w : Word => or (@ex2 Word (fun u : Word => dans (couple A (word u)) R) (fun u : Word => @ex2 Word (fun v : Word => @eq Word (cons A v) nil) (fun v : Word => @eq Word (Append u v) y))) (@ex2 Word (fun v : Word => Derive R w v) (fun v : Word => @eq Word (cons A v) y)))) *) (* Goal: forall (e : Elt) (w : Word) (_ : forall _ : Derive_inv R w y, @ex Elt (fun A : Elt => @ex2 Word (fun w0 : Word => @eq Word (cons A w0) w) (fun w0 : Word => or (@ex2 Word (fun u : Word => dans (couple A (word u)) R) (fun u : Word => @ex2 Word (fun v : Word => @eq Word (cons A v) w) (fun v : Word => @eq Word (Append u v) y))) (@ex2 Word (fun v : Word => Derive R w0 v) (fun v : Word => @eq Word (cons A v) y))))) (_ : Derive_inv R (cons e w) y), @ex Elt (fun A : Elt => @ex2 Word (fun w0 : Word => @eq Word (cons A w0) (cons e w)) (fun w0 : Word => or (@ex2 Word (fun u : Word => dans (couple A (word u)) R) (fun u : Word => @ex2 Word (fun v : Word => @eq Word (cons A v) (cons e w)) (fun v : Word => @eq Word (Append u v) y))) (@ex2 Word (fun v : Word => Derive R w0 v) (fun v : Word => @eq Word (cons A v) y)))) *) intuition. Qed. Lemma isGram4 : H -> Regles X V R. (* Goal: forall _ : H, Regles X V R *) intro H1. (* Goal: Regles X V R *) elim H1. (* Goal: forall _ : False, @ex Elt (fun A : Elt => @ex2 Word (fun w : Word => @eq Word (cons A w) nil) (fun w : Word => or (@ex2 Word (fun u : Word => dans (couple A (word u)) R) (fun u : Word => @ex2 Word (fun v : Word => @eq Word (cons A v) nil) (fun v : Word => @eq Word (Append u v) y))) (@ex2 Word (fun v : Word => Derive R w v) (fun v : Word => @eq Word (cons A v) y)))) *) (* Goal: forall (e : Elt) (w : Word) (_ : forall _ : Derive_inv R w y, @ex Elt (fun A : Elt => @ex2 Word (fun w0 : Word => @eq Word (cons A w0) w) (fun w0 : Word => or (@ex2 Word (fun u : Word => dans (couple A (word u)) R) (fun u : Word => @ex2 Word (fun v : Word => @eq Word (cons A v) w) (fun v : Word => @eq Word (Append u v) y))) (@ex2 Word (fun v : Word => Derive R w0 v) (fun v : Word => @eq Word (cons A v) y))))) (_ : Derive_inv R (cons e w) y), @ex Elt (fun A : Elt => @ex2 Word (fun w0 : Word => @eq Word (cons A w0) (cons e w)) (fun w0 : Word => or (@ex2 Word (fun u : Word => dans (couple A (word u)) R) (fun u : Word => @ex2 Word (fun v : Word => @eq Word (cons A v) (cons e w)) (fun v : Word => @eq Word (Append u v) y))) (@ex2 Word (fun v : Word => Derive R w0 v) (fun v : Word => @eq Word (cons A v) y)))) *) intuition. Qed. Lemma isGram5 : Mots X -> inter X V empty -> dans S V -> Regles X V R -> H. (* Goal: forall (X _ : Ensf) (R : Ensf) (S : Elt) (w : Word) (_ : and (Derivestar R (cons S nil) w) (inmonoid X w)), inmonoid X w *) intros. (* Goal: H *) red in |- *; red in |- *. (* Goal: forall u : Word, Derivestar R2 u u *) (* Goal: forall (u v w : Word) (_ : Derive R1 u v) (_ : Derivestar R2 v w), Derivestar R2 u w *) auto. Qed. End Easy_lemma_isGram. (*--------*) Lemma Regles_R : forall X V R R' : Ensf, inclus R' R -> Regles X V R -> Regles X V R'. (* Goal: forall (X V R R' : Ensf) (_ : Regles X V R) (_ : Regles X V R'), Regles X V (union R R') *) unfold Regles in |- *. (* Goal: forall u : Word, Derivestar R2 u u *) (* Goal: forall (u v w : Word) (_ : Derive R1 u v) (_ : Derivestar R2 v w), Derivestar R2 u w *) auto. Qed. Lemma Regles_V : forall X V R V' : Ensf, inclus V V' -> Regles X V R -> Regles X V' R. (* Goal: forall (X V R R' : Ensf) (_ : Regles X V R) (_ : Regles X V R'), Regles X V (union R R') *) unfold Regles in |- *. (* Goal: forall (X V R V' : Ensf) (_ : inclus V V') (_ : forall (x : Elt) (_ : dans x R), @ex2 Elt (fun A : Elt => dans A V) (fun A : Elt => @ex2 Word (fun B : Word => @eq Elt x (couple A (word B))) (fun B : Word => inmonoid (union X V) B))) (x : Elt) (_ : dans x R), @ex2 Elt (fun A : Elt => dans A V') (fun A : Elt => @ex2 Word (fun B : Word => @eq Elt x (couple A (word B))) (fun B : Word => inmonoid (union X V') B)) *) intros X V R V' inclus_V_V' Regles_X_V_R x dans_x_R. (* Goal: @ex2 Elt (fun A : Elt => dans A V') (fun A : Elt => @ex2 Word (fun B : Word => @eq Elt x (couple A (word B))) (fun B : Word => inmonoid (union X V') B)) *) elim (Regles_X_V_R x dans_x_R). (* Goal: forall (x0 : Elt) (_ : dans x0 V) (_ : @ex2 Word (fun B : Word => @eq Elt x (couple x0 (word B))) (fun B : Word => inmonoid (union X V) B)), @ex2 Elt (fun A : Elt => dans A V') (fun A : Elt => @ex2 Word (fun B : Word => @eq Elt x (couple A (word B))) (fun B : Word => inmonoid (union X V') B)) *) intros A dans_A_V temp; elim temp; clear temp. (* Goal: forall (x0 : Word) (_ : @eq Elt x (couple A (word x0))) (_ : inmonoid (union X V) x0), @ex2 Elt (fun A : Elt => dans A V') (fun A : Elt => @ex2 Word (fun B : Word => @eq Elt x (couple A (word B))) (fun B : Word => inmonoid (union X V') B)) *) intros B egal_B inmonoid_B. (* Goal: @ex2 Elt (fun A : Elt => dans A V') (fun A : Elt => @ex2 Word (fun B : Word => @eq Elt x (couple A (word B))) (fun B : Word => inmonoid (union X V') B)) *) exists A. (* Goal: forall u : Word, Derivestar R2 u u *) (* Goal: forall (u v w : Word) (_ : Derive R1 u v) (_ : Derivestar R2 v w), Derivestar R2 u w *) auto. (* Goal: @ex2 Word (fun B : Word => @eq Elt x (couple A (word B))) (fun B : Word => inmonoid (union X V') B) *) exists B. (* Goal: dans a V *) (* Goal: @ex2 Word (fun B : Word => @eq Elt x (couple a (word B))) (fun B : Word => inmonoid (union X V) B) *) (* Goal: or (@eq Elt (couple a (word u)) x) (dans x R) *) assumption. (* Goal: forall u : Word, Derivestar R2 u u *) (* Goal: forall (u v w : Word) (_ : Derive R1 u v) (_ : Derivestar R2 v w), Derivestar R2 u w *) apply inmonoid_inclus with (union X V); auto. Qed. Lemma Regles_add : forall (X V R : Ensf) (a : Elt) (u : Word), Regles X V R -> dans a V -> inmonoid (union X V) u -> Regles X V (add (couple a (word u)) R). (* Goal: forall (X V R : Ensf) (a : Elt) (u : Word) (_ : Regles X V R) (_ : dans a V) (_ : inmonoid (union X V) u), Regles X V (add (couple a (word u)) R) *) intros X V R a u R_R dans_a_V inmonoid_u_X_V_u. (* Goal: Regles X V (add (couple a (word u)) R) *) red in |- *. (* Goal: forall (x : Elt) (_ : dans x (add (couple a (word u)) R)), @ex2 Elt (fun A : Elt => dans A V) (fun A : Elt => @ex2 Word (fun B : Word => @eq Elt x (couple A (word B))) (fun B : Word => inmonoid (union X V) B)) *) intros x dans_x_R'. (* Goal: @ex2 Elt (fun A : Elt => dans A V) (fun A : Elt => @ex2 Word (fun B : Word => @eq Elt x (couple A (word B))) (fun B : Word => inmonoid (union X V) B)) *) cut (couple a (word u) = x :>Elt \/ dans x R). (**) (* Goal: forall _ : False, @ex Elt (fun A : Elt => @ex2 Word (fun w : Word => @eq Word (cons A w) nil) (fun w : Word => or (@ex2 Word (fun u : Word => dans (couple A (word u)) R) (fun u : Word => @ex2 Word (fun v : Word => @eq Word (cons A v) nil) (fun v : Word => @eq Word (Append u v) y))) (@ex2 Word (fun v : Word => Derive R w v) (fun v : Word => @eq Word (cons A v) y)))) *) (* Goal: forall (e : Elt) (w : Word) (_ : forall _ : Derive_inv R w y, @ex Elt (fun A : Elt => @ex2 Word (fun w0 : Word => @eq Word (cons A w0) w) (fun w0 : Word => or (@ex2 Word (fun u : Word => dans (couple A (word u)) R) (fun u : Word => @ex2 Word (fun v : Word => @eq Word (cons A v) w) (fun v : Word => @eq Word (Append u v) y))) (@ex2 Word (fun v : Word => Derive R w0 v) (fun v : Word => @eq Word (cons A v) y))))) (_ : Derive_inv R (cons e w) y), @ex Elt (fun A : Elt => @ex2 Word (fun w0 : Word => @eq Word (cons A w0) (cons e w)) (fun w0 : Word => or (@ex2 Word (fun u : Word => dans (couple A (word u)) R) (fun u : Word => @ex2 Word (fun v : Word => @eq Word (cons A v) (cons e w)) (fun v : Word => @eq Word (Append u v) y))) (@ex2 Word (fun v : Word => Derive R w0 v) (fun v : Word => @eq Word (cons A v) y)))) *) intuition. (* Intro egal_x_couple.*) (* Goal: @ex2 Elt (fun A : Elt => dans A V) (fun A : Elt => @ex2 Word (fun B : Word => @eq Elt x (couple A (word B))) (fun B : Word => inmonoid (union X V) B)) *) (* Goal: or (@eq Elt (couple a (word u)) x) (dans x R) *) exists a. (* Goal: dans a V *) (* Goal: @ex2 Word (fun B : Word => @eq Elt x (couple a (word B))) (fun B : Word => inmonoid (union X V) B) *) (* Goal: or (@eq Elt (couple a (word u)) x) (dans x R) *) assumption. (* Goal: forall u : Word, Derivestar R2 u u *) (* Goal: forall (u v w : Word) (_ : Derive R1 u v) (_ : Derivestar R2 v w), Derivestar R2 u w *) exists u; auto. (* Goal: dans a V *) (* Goal: @ex2 Word (fun B : Word => @eq Elt x (couple a (word B))) (fun B : Word => inmonoid (union X V) B) *) (* Goal: or (@eq Elt (couple a (word u)) x) (dans x R) *) (**)apply dans_add; assumption. Qed. Lemma Regles_add2 : forall (X V R : Ensf) (a : Elt), Regles X V R -> Regles X (add a V) R. (* Goal: forall (X _ : Ensf) (R : Ensf) (S : Elt) (w : Word) (_ : and (Derivestar R (cons S nil) w) (inmonoid X w)), inmonoid X w *) intros. (* Goal: forall u : Word, Derivestar R2 u u *) (* Goal: forall (u v w : Word) (_ : Derive R1 u v) (_ : Derivestar R2 v w), Derivestar R2 u w *) apply Regles_V with V; auto. Qed. Lemma Regles_union : forall X V R R' : Ensf, Regles X V R -> Regles X V R' -> Regles X V (union R R'). (* Goal: forall (X V R R' : Ensf) (_ : Regles X V R) (_ : Regles X V R'), Regles X V (union R R') *) unfold Regles in |- *. (* Goal: forall (X V R R' : Ensf) (_ : forall (x : Elt) (_ : dans x R), @ex2 Elt (fun A : Elt => dans A V) (fun A : Elt => @ex2 Word (fun B : Word => @eq Elt x (couple A (word B))) (fun B : Word => inmonoid (union X V) B))) (_ : forall (x : Elt) (_ : dans x R'), @ex2 Elt (fun A : Elt => dans A V) (fun A : Elt => @ex2 Word (fun B : Word => @eq Elt x (couple A (word B))) (fun B : Word => inmonoid (union X V) B))) (x : Elt) (_ : dans x (union R R')), @ex2 Elt (fun A : Elt => dans A V) (fun A : Elt => @ex2 Word (fun B : Word => @eq Elt x (couple A (word B))) (fun B : Word => inmonoid (union X V) B)) *) intros X V R R' R_R R_R' x dans_x_union. (* Goal: forall u : Word, Derivestar R2 u u *) (* Goal: forall (u v w : Word) (_ : Derive R1 u v) (_ : Derivestar R2 v w), Derivestar R2 u w *) cut (dans x R \/ dans x R'); auto. (* Goal: forall u : Word, Derivestar R2 u u *) (* Goal: forall (u v w : Word) (_ : Derive R1 u v) (_ : Derivestar R2 v w), Derivestar R2 u w *) intros [HR| HR']; auto. Qed. Lemma isGram_inclus2 : forall (X V R R' : Ensf) (S : Elt), inclus R' R -> isGram X V R S -> isGram X V R' S. (* Goal: forall (X V R R' : Ensf) (S : Elt) (_ : inclus R' R) (_ : isGram X V R S), isGram X V R' S *) prolog [ isGram4 Regles_R isGram3 isGram2 isGram1 isGram5 ] 11. (*Intros X V R R' S incl isGram_X_V_R_S. Apply isGram5 . Apply isGram1 with V R S; Assumption. Apply isGram2 with R S; Assumption. Apply isGram3 with X R; Assumption. Apply Regles_R with R. Assumption. Apply isGram4 with S; Assumption.*) Qed. Lemma isGram_inclus3 : forall (X V R : Ensf) (S a : Elt), isGram X V (add a R) S -> isGram X V R S. (* Goal: forall (X V R : Ensf) (S a : Elt) (_ : isGram X V (add a R) S), isGram X V R S *) intros X V R S a isGram_X_V_a_R_S. (* Goal: forall u : Word, Derivestar R2 u u *) (* Goal: forall (u v w : Word) (_ : Derive R1 u v) (_ : Derivestar R2 v w), Derivestar R2 u w *) apply isGram_inclus2 with (add a R); auto. Qed. (*--------------------------*) (* (Derive R u v) signifie "u se recrit en v par une production de R" *) Inductive Derive (R : Ensf) : Word -> Word -> Prop := (*si A -R-> u alors Av -G-> uv *) | Derive1 : forall (u v : Word) (A : Elt), dans (couple A (word u)) R -> Derive R (cons A v) (Append u v) (*si u -G-> v alors x::u -G-> x::v*) | Derive2 : forall (u v : Word) (x : Elt), Derive R u v -> Derive R (cons x u) (cons x v). Hint Resolve Derive1. Hint Resolve Derive2. Lemma Derive_inclus : forall (R1 R2 : Ensf) (u v : Word), inclus R1 R2 -> Derive R1 u v -> Derive R2 u v. (* Goal: forall (R1 R2 : Ensf) (u v : Word) (_ : inclus R1 R2) (_ : Derivestar R1 u v), Derivestar R2 u v *) intros R1 R2 u v inclus_R1_R2 Der_R1. (* Goal: forall u : Word, Derivestar R2 u u *) (* Goal: forall (u v w : Word) (_ : Derive R1 u v) (_ : Derivestar R2 v w), Derivestar R2 u w *) elim Der_R1; auto. Qed. Definition Derive_inv (R : Ensf) (x y : Word) := match x return Prop with | nil => (* nil *) False (* cons *) | cons A w => ex2 (fun u : Word => dans (couple A (word u)) R) (fun u : Word => ex2 (fun v : Word => cons A v = x :>Word) (fun v : Word => Append u v = y :>Word)) \/ ex2 (fun v : Word => Derive R w v) (fun v : Word => cons A v = y :>Word) end. Lemma Derive_inv1 : forall (R : Ensf) (u v : Word), Derive R u v -> Derive_inv R u v. (* Goal: forall (R : Ensf) (u v : Word) (_ : Derive R u v), Derive_inv R u v *) intros R x y Der_x_y. (* Goal: forall _ : Derive_inv R (cons x0 w) y, @ex Elt (fun A : Elt => @ex2 Word (fun w0 : Word => @eq Word (cons A w0) (cons x0 w)) (fun w0 : Word => or (@ex2 Word (fun u : Word => dans (couple A (word u)) R) (fun u : Word => @ex2 Word (fun v : Word => @eq Word (cons A v) (cons x0 w)) (fun v : Word => @eq Word (Append u v) y))) (@ex2 Word (fun v : Word => Derive R w0 v) (fun v : Word => @eq Word (cons A v) y)))) *) unfold Derive_inv in |- *. (* Goal: match x with | nil => False | cons A w => or (@ex2 Word (fun u : Word => dans (couple A (word u)) R) (fun u : Word => @ex2 Word (fun v : Word => @eq Word (cons A v) x) (fun v : Word => @eq Word (Append u v) y))) (@ex2 Word (fun v : Word => Derive R w v) (fun v : Word => @eq Word (cons A v) y)) end *) elim Der_x_y; prolog [ ex_intro2 refl_equal or_intror or_introl ] 8. (* Intros u v A dans_couple. Left. Exists u; [Assumption | Exists v; Apply refl_equal]. Intros u v x0 Der_u_v Der_inv_u_v. Simpl; Right. Exists v; Trivial .*) Qed. Hint Resolve Derive_inv1. Lemma Derive_inv2 : forall (R : Ensf) (x y : Word), Derive_inv R x y -> exists A : Elt, (exists2 w : Word, cons A w = x & (exists2 u : Word, dans (couple A (word u)) R & (exists2 v : Word, cons A v = x & Append u v = y)) \/ (exists2 v : Word, Derive R w v & cons A v = y)). (* Goal: forall (R : Ensf) (x y : Word) (_ : Derive_inv R x y), @ex Elt (fun A : Elt => @ex2 Word (fun w : Word => @eq Word (cons A w) x) (fun w : Word => or (@ex2 Word (fun u : Word => dans (couple A (word u)) R) (fun u : Word => @ex2 Word (fun v : Word => @eq Word (cons A v) x) (fun v : Word => @eq Word (Append u v) y))) (@ex2 Word (fun v : Word => Derive R w v) (fun v : Word => @eq Word (cons A v) y)))) *) intros R x y. (* Goal: forall _ : Derive_inv R x y, @ex Elt (fun A : Elt => @ex2 Word (fun w : Word => @eq Word (cons A w) x) (fun w : Word => or (@ex2 Word (fun u : Word => dans (couple A (word u)) R) (fun u : Word => @ex2 Word (fun v : Word => @eq Word (cons A v) x) (fun v : Word => @eq Word (Append u v) y))) (@ex2 Word (fun v : Word => Derive R w v) (fun v : Word => @eq Word (cons A v) y)))) *) elim x. (* Goal: forall _ : Derive_inv R (cons x0 w) y, @ex Elt (fun A : Elt => @ex2 Word (fun w0 : Word => @eq Word (cons A w0) (cons x0 w)) (fun w0 : Word => or (@ex2 Word (fun u : Word => dans (couple A (word u)) R) (fun u : Word => @ex2 Word (fun v : Word => @eq Word (cons A v) (cons x0 w)) (fun v : Word => @eq Word (Append u v) y))) (@ex2 Word (fun v : Word => Derive R w0 v) (fun v : Word => @eq Word (cons A v) y)))) *) unfold Derive_inv in |- *. (* Goal: forall _ : False, @ex Elt (fun A : Elt => @ex2 Word (fun w : Word => @eq Word (cons A w) nil) (fun w : Word => or (@ex2 Word (fun u : Word => dans (couple A (word u)) R) (fun u : Word => @ex2 Word (fun v : Word => @eq Word (cons A v) nil) (fun v : Word => @eq Word (Append u v) y))) (@ex2 Word (fun v : Word => Derive R w v) (fun v : Word => @eq Word (cons A v) y)))) *) (* Goal: forall (e : Elt) (w : Word) (_ : forall _ : Derive_inv R w y, @ex Elt (fun A : Elt => @ex2 Word (fun w0 : Word => @eq Word (cons A w0) w) (fun w0 : Word => or (@ex2 Word (fun u : Word => dans (couple A (word u)) R) (fun u : Word => @ex2 Word (fun v : Word => @eq Word (cons A v) w) (fun v : Word => @eq Word (Append u v) y))) (@ex2 Word (fun v : Word => Derive R w0 v) (fun v : Word => @eq Word (cons A v) y))))) (_ : Derive_inv R (cons e w) y), @ex Elt (fun A : Elt => @ex2 Word (fun w0 : Word => @eq Word (cons A w0) (cons e w)) (fun w0 : Word => or (@ex2 Word (fun u : Word => dans (couple A (word u)) R) (fun u : Word => @ex2 Word (fun v : Word => @eq Word (cons A v) (cons e w)) (fun v : Word => @eq Word (Append u v) y))) (@ex2 Word (fun v : Word => Derive R w0 v) (fun v : Word => @eq Word (cons A v) y)))) *) intuition. (*Intro temp; Elim temp; Clear temp.*) (* Goal: forall (e : Elt) (w : Word) (_ : forall _ : Derive_inv R w y, @ex Elt (fun A : Elt => @ex2 Word (fun w0 : Word => @eq Word (cons A w0) w) (fun w0 : Word => or (@ex2 Word (fun u : Word => dans (couple A (word u)) R) (fun u : Word => @ex2 Word (fun v : Word => @eq Word (cons A v) w) (fun v : Word => @eq Word (Append u v) y))) (@ex2 Word (fun v : Word => Derive R w0 v) (fun v : Word => @eq Word (cons A v) y))))) (_ : Derive_inv R (cons e w) y), @ex Elt (fun A : Elt => @ex2 Word (fun w0 : Word => @eq Word (cons A w0) (cons e w)) (fun w0 : Word => or (@ex2 Word (fun u : Word => dans (couple A (word u)) R) (fun u : Word => @ex2 Word (fun v : Word => @eq Word (cons A v) (cons e w)) (fun v : Word => @eq Word (Append u v) y))) (@ex2 Word (fun v : Word => Derive R w0 v) (fun v : Word => @eq Word (cons A v) y)))) *) intros x0 w Hyp_rec. (* Goal: forall _ : Derive_inv R (cons x0 w) y, @ex Elt (fun A : Elt => @ex2 Word (fun w0 : Word => @eq Word (cons A w0) (cons x0 w)) (fun w0 : Word => or (@ex2 Word (fun u : Word => dans (couple A (word u)) R) (fun u : Word => @ex2 Word (fun v : Word => @eq Word (cons A v) (cons x0 w)) (fun v : Word => @eq Word (Append u v) y))) (@ex2 Word (fun v : Word => Derive R w0 v) (fun v : Word => @eq Word (cons A v) y)))) *) unfold Derive_inv in |- *. (*Simpl.*) (* Goal: forall _ : or (@ex2 Word (fun u : Word => dans (couple x0 (word u)) R) (fun u : Word => @ex2 Word (fun v : Word => @eq Word (cons x0 v) (cons x0 w)) (fun v : Word => @eq Word (Append u v) y))) (@ex2 Word (fun v : Word => Derive R w v) (fun v : Word => @eq Word (cons x0 v) y)), @ex Elt (fun A : Elt => @ex2 Word (fun w0 : Word => @eq Word (cons A w0) (cons x0 w)) (fun w0 : Word => or (@ex2 Word (fun u : Word => dans (couple A (word u)) R) (fun u : Word => @ex2 Word (fun v : Word => @eq Word (cons A v) (cons x0 w)) (fun v : Word => @eq Word (Append u v) y))) (@ex2 Word (fun v : Word => Derive R w0 v) (fun v : Word => @eq Word (cons A v) y)))) *) exists x0. (* Goal: forall (_ : Mots X) (_ : and (inter X V empty) (and (dans S V) (Regles X V R))), Mots X *) exists w; trivial. Qed. Lemma Derive_inv3 : forall (R : Ensf) (x y : Word), Derive R x y -> exists A : _, (exists2 w : _, cons A w = x & (exists2 u : _, dans (couple A (word u)) R & (exists2 v : _, cons A v = x & Append u v = y)) \/ (exists2 v : _, Derive R w v & cons A v = y)). (* Proof [R:Ensf][x,y:Word][D : (Derive R x y)] (Derive_inv2 R x y (Derive_inv1 R x y D)). *) (* Goal: forall (R : Ensf) (x y : Word) (_ : Derive R x y), @ex Elt (fun A : Elt => @ex2 Word (fun w : Word => @eq Word (cons A w) x) (fun w : Word => or (@ex2 Word (fun u : Word => dans (couple A (word u)) R) (fun u : Word => @ex2 Word (fun v : Word => @eq Word (cons A v) x) (fun v : Word => @eq Word (Append u v) y))) (@ex2 Word (fun v : Word => Derive R w v) (fun v : Word => @eq Word (cons A v) y)))) *) prolog [ Derive_inv1 Derive Derive_inv2 ] 7. Qed. Lemma in_mon_X_Der_imp_inmon_X : forall (X V R : Ensf) (u v : Word), Regles X V R -> Derive R u v -> inmonoid (union X V) u -> inmonoid (union X V) v. (* Goal: forall (X V R : Ensf) (u v : Word) (_ : Regles X V R) (_ : Derive R u v) (_ : inmonoid (union X V) u), inmonoid (union X V) v *) intros X V1 R1 u v Regles_R1 Der_R1. elim Der_R1; prolog [ Regles_inv2 inmonoid_cons_inv inmonoid_cons_inv2 inmonoid_cons inmonoid_Append ] 10. (*Intros u0 v0 A dans_R1 inmonoid_cons_A_v0. Apply inmonoid_Append. Apply Regles_inv2 with R1 A;Assumption. Apply inmonoid_cons_inv with A; Assumption. Intros u0 v0 x Der_R1_u0 imp inmon_cons_x_u0. Apply inmonoid_cons. Apply imp. Apply inmonoid_cons_inv with x;Assumption. Apply inmonoid_cons_inv2 with u0;Assumption.*) Qed. (* (Derivestar R u v) signifie "u se recrit en v par zero ou plusieurs productions de R" *) Definition Derivestar (R : Ensf) := Rstar Word (Derive R). Hint Unfold Derivestar. Lemma Derivestar_refl : forall (R : Ensf) (u : Word), Derivestar R u u. (* Goal: forall u : Word, Derivestar R2 u u *) (* Goal: forall (u v w : Word) (_ : Derive R1 u v) (_ : Derivestar R2 v w), Derivestar R2 u w *) auto. Qed. Hint Resolve Derivestar_refl. Lemma Derivestar_R : forall (R : Ensf) (u v w : Word), Derive R u v -> Derivestar R v w -> Derivestar R u w. (* Goal: forall (R : Ensf) (u v : Word) (_ : Derivestar R u v), or (@eq Word u v) (@ex2 Word (fun w : Word => Derive R u w) (fun w : Word => Derivestar R w v)) *) unfold Derivestar in |- *. (* Goal: forall (R : Ensf) (u v w : Word) (_ : Derive R u v) (_ : Rstar Word (Derive R) v w), Rstar Word (Derive R) u w *) prolog [ Rstar_R ] 8. (*Intros. Apply Rstar_R with v;Assumption.*) Qed. Lemma Derivestar_inv : forall (R : Ensf) (u v : Word), Derivestar R u v -> u = v \/ (exists2 w : Word, Derive R u w & Derivestar R w v). (* Goal: forall (R : Ensf) (u v : Word) (_ : Derivestar R u v), or (@eq Word u v) (@ex2 Word (fun w : Word => Derive R u w) (fun w : Word => Derivestar R w v)) *) unfold Derivestar in |- *. (* Goal: forall (R : Ensf) (u v : Word) (_ : Rstar Word (Derive R) u v), or (@eq Word u v) (@ex2 Word (fun w : Word => Derive R u w) (fun w : Word => Rstar Word (Derive R) w v)) *) prolog [ Rstar_inv ] 6. (*Intros R u v Der_R. Apply Rstar_inv;Assumption.*) Qed. Hint Resolve Derivestar_inv. Lemma Derivestar_inclus : forall (R1 R2 : Ensf) (u v : Word), inclus R1 R2 -> Derivestar R1 u v -> Derivestar R2 u v. (* Goal: forall (R1 R2 : Ensf) (u v : Word) (_ : inclus R1 R2) (_ : Derivestar R1 u v), Derivestar R2 u v *) intros R1 R2 u v inclus_R1_R2 Der_R1. (* Goal: Derivestar R2 u v *) unfold Derivestar, Rstar in Der_R1. (* Goal: Derivestar R2 u v *) pattern u, v in |- *. (* Goal: (fun w w0 : Word => Derivestar R2 w w0) u v *) apply Der_R1. (* Goal: forall u : Word, Derivestar R2 u u *) (* Goal: forall (u v w : Word) (_ : Derive R1 u v) (_ : Derivestar R2 v w), Derivestar R2 u w *) auto. (* Goal: forall (u v w : Word) (_ : Derive R1 u v) (_ : Derivestar R2 v w), Derivestar R2 u w *) intros; prolog [ Derive_inclus Derivestar_R ] 3. (*Intros a b c Der_a_b Der_b_c. Apply Derivestar_R with b. Apply Derive_inclus with R1;Assumption. Assumption.*) Qed. (* LG X V R S est l'ensemble de mots engendre par la grammaire (X V R S) *) Definition LG (X V R : Ensf) (S : Elt) : wordset := fun w : Word => Derivestar R (cons S nil) w /\ inmonoid X w. Lemma LG_inv : forall (X V R : Ensf) (S : Elt) (w : Word), LG X V R S w -> inmonoid X w. (* Goal: forall (X V R : Ensf) (S : Elt) (w : Word) (_ : LG X V R S w), inmonoid X w *) unfold LG in |- *. (* Goal: forall (X _ : Ensf) (R : Ensf) (S : Elt) (w : Word) (_ : and (Derivestar R (cons S nil) w) (inmonoid X w)), inmonoid X w *) intros. (* Goal: forall u : Word, Derivestar R2 u u *) (* Goal: forall (u v w : Word) (_ : Derive R1 u v) (_ : Derivestar R2 v w), Derivestar R2 u w *) elim H; auto. Qed. (*Pour toute grammaire (X,V,R,S), (LG X V R S) est un langage *) Lemma LG_langage : forall (X V R : Ensf) (S : Elt), isGram X V R S -> islanguage X (LG X V R S). (* Goal: forall u : Word, Derivestar R2 u u *) (* Goal: forall (u v w : Word) (_ : Derive R1 u v) (_ : Derivestar R2 v w), Derivestar R2 u w *) intros; red in |- *; intros; elim H0; auto. Qed. (*Reunion de 2 grammaires *) Definition Gunion (V1 R1 V2 R2 : Ensf) := (union V1 V2, union R1 R2). (*------------------*) Section injprod. Let injproduc (f : Elt -> Elt) (V : Ensf) := extension V f. Definition injproducg : Ensf -> Elt -> Elt := injproduc injgauche. Definition injproducd : Ensf -> Elt -> Elt := injproduc injdroite. (*prennent en arguments l'ensemble de non-terminaux V,*) (*de productions R et rendent*) (*les injections gauche et droite*) (*utilisees ensuite pour la definition de G_union_disj_p.*) End injprod. Definition Gunion_disj_p (V1 R1 : Ensf) (S1 : Elt) (V2 R2 : Ensf) (S2 S : Elt) := (add S (fst (Gunion V1 R1 V2 R2)), (add (couple S (word (cons S1 nil))) (add (couple S (word (cons S2 nil))) (snd (Gunion V1 R1 V2 R2))), S)). (* image par une fonction d'une grammaire *) Definition imageGram (f : Elt -> Elt) (X V R : Ensf) (S : Elt) := (map f X, (map f V, (map (fun P : Elt => couple (f (first P)) ((fun w : Elt => word (Word_ext f (word_inv w))) (second P))) R, f S))).
(* This program is free software; you can redistribute it and/or *) (* modify it under the terms of the GNU Lesser General Public License *) (* as published by the Free Software Foundation; either version 2.1 *) (* of the License, or (at your option) any later version. *) (* *) (* This program is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* GNU General Public License for more details. *) (* *) (* You should have received a copy of the GNU Lesser General Public *) (* License along with this program; if not, write to the Free *) (* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *) (* 02110-1301 USA *) (* Contribution to the Coq Library V6.3 (July 1999) *) (****************************************************************************) (* The Calculus of Inductive Constructions *) (* *) (* Projet Coq *) (* *) (* INRIA ENS-CNRS *) (* Rocquencourt Lyon *) (* *) (* Coq V5.10 *) (* Nov 25th 1994 *) (* *) (****************************************************************************) (* gram4.v *) (****************************************************************************) (* Formal Language Theory *) (* *) (* Judicael Courant - Jean-Christophe Filliatre *) (* *) (* Developped in V5.8 June-July 1993 *) (* Ported to V5.10 October 1994 *) (****************************************************************************) Require Import Ensf. Require Import Words. Require Import more_words. Require Import Rat. Require Import need. Require Import fonctions. Require Import Relations. Require Import gram. Require Import gram2. Require Import gram3. Section gram4. Variable X V1 R1 : Ensf. Variable S1 : Elt. Variable V2 R2 : Ensf. Variable S2 : Elt. Variable S : Elt. Let C := Gunion_disj_p V1 R1 S1 V2 R2 S2 S. Let Vu := fst C. Let C' := snd C. Let Ru := fst C'. Let Su := snd C'. Lemma inter_X_V1_u_V2 : isGram X V1 R1 S1 -> isGram X V2 R2 S2 -> inter X (union V1 V2) empty. (* Goal: forall (_ : isGram X V1 R1 S1) (_ : isGram X V2 R2 S2), inter X (union V1 V2) empty *) prolog [ isGram2 union_inter ] 5. (*Intro G1. Intro G2. Apply union_inter. Apply isGram2 with R1 S1; Assumption. Apply isGram2 with R2 S2; Assumption.*) Qed. Lemma inter_X_Vu_d : isGram X V1 R1 S1 -> isGram X V2 R2 S2 -> ~ dans S X -> inter X Vu empty. (* Goal: forall (_ : isGram X V1 R1 S1) (_ : isGram X V2 R2 S2) (_ : not (dans S X)), inter X Vu empty *) intros G_1 G_2 N_dans_S_X. (* Goal: forall _ : inter (union X V2) V1 empty, False *) (* Goal: inter (union X V2) V1 empty *) (* Goal: forall _ : dans (couple A (word u0)) R2, dans (couple A (word u0)) R2 *) (* Goal: or (dans (couple A (word u0)) R1) (dans (couple A (word u0)) R2) *) (* Goal: or (@eq Elt (couple S (word (cons S2 nil))) (couple A (word u0))) (dans (couple A (word u0)) (union R1 R2)) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple A (word u0))) (dans (couple A (word u0)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V2) u, Derive R2 u v) (_ : inmonoid (union X V2) (cons x u)), Derive R2 (cons x u) (cons x v) *) unfold inter in |- *. (* Goal: and (Derivestar (add (couple S (word (cons S1 nil))) (add (couple S (word (cons S2 nil))) (union R1 R2))) (cons S nil) w) (inmonoid X w) *) split. (* Goal: @eq Word (Append (cons S2 nil) nil) (cons S2 nil) *) (* Goal: Derivestar (add (couple S (word (cons S1 nil))) (add (couple S (word (cons S2 nil))) (union R1 R2))) (cons S2 nil) w *) (* Goal: inmonoid X w *) auto. (* Goal: and (Derivestar (add (couple S (word (cons S1 nil))) (add (couple S (word (cons S2 nil))) (union R1 R2))) (cons S nil) w) (inmonoid X w) *) split. (* Goal: @eq Word (Append (cons S2 nil) nil) (cons S2 nil) *) (* Goal: Derivestar (add (couple S (word (cons S1 nil))) (add (couple S (word (cons S2 nil))) (union R1 R2))) (cons S2 nil) w *) (* Goal: inmonoid X w *) auto. (* Goal: forall (x : Elt) (_ : dans x X) (_ : dans x Vu), dans x empty *) intros x dans_x_X dans_x_Vu. (* Goal: dans x empty *) absurd (dans x X). (* Goal: not (dans x X) *) (* Goal: dans x X *) cut (S = x :>Elt \/ dans x (union V1 V2)). (**) (* Goal: forall _ : @ex2 Word (fun w : Word => Derive Ru (cons S nil) w) (fun w : Word => Derivestar Ru w u), or (@eq Word (cons S nil) u) (or (Derivestar R1 (cons S1 nil) u) (Derivestar R2 (cons S2 nil) u)) *) (* Goal: or (@eq Word (cons S nil) u) (@ex2 Word (fun w : Word => Derive Ru (cons S nil) w) (fun w : Word => Derivestar Ru w u)) *) intro temp; elim temp; clear temp. (* Goal: forall _ : @eq Elt S x, not (dans x X) *) (* Goal: forall _ : dans x (union V1 V2), not (dans x X) *) (* Goal: or (@eq Elt S x) (dans x (union V1 V2)) *) (* Goal: dans x X *) intros egal_S_x. (* Goal: not (dans x X) *) (* Goal: forall _ : dans x (union V1 V2), not (dans x X) *) (* Goal: or (@eq Elt S x) (dans x (union V1 V2)) *) (* Goal: dans x X *) rewrite <- egal_S_x; assumption. (* Goal: forall _ : dans x (union V1 V2), not (dans x X) *) (* Goal: or (@eq Elt S x) (dans x (union V1 V2)) *) (* Goal: dans x X *) intro dans_x_V1_u_V2. (* Goal: not (dans x X) *) (* Goal: or (@eq Elt S x) (dans x (union V1 V2)) *) (* Goal: dans x X *) prolog [ inter_X_V1_u_V2 sym_inter inter_dans ] 4. (*Apply inter_dans with (union V1 V2). Apply sym_inter. Apply inter_X_V1_u_V2;Assumption. Assumption.*) (* Goal: @eq Word (Append (cons S2 nil) nil) (cons S2 nil) *) (* Goal: Derivestar (add (couple S (word (cons S1 nil))) (add (couple S (word (cons S2 nil))) (union R1 R2))) (cons S2 nil) w *) (* Goal: inmonoid X w *) (**)auto. (* Goal: inmonoid X w *) assumption. Qed. Lemma Gunion_disj_Regles : isGram X V1 R1 S1 -> isGram X V2 R2 S2 -> Regles X Vu Ru. (* Goal: forall (_ : not (dans S X)) (_ : not (dans S V1)) (_ : not (dans S V2)) (_ : isGram X V1 R1 S1) (_ : isGram X V2 R2 S2) (_ : inter V1 V2 empty), l_egal (LG X Vu Ru S) (lunion (LG X V1 R1 S1) (LG X V2 R2 S2)) *) intros. (* Goal: Regles X Vu Ru *) unfold Vu, Ru in |- *; simpl in |- *. (* Goal: Regles X (add S (union V1 V2)) (add (couple S (word (cons S2 nil))) (union R1 R2)) *) (* Goal: dans S (add S (union V1 V2)) *) (* Goal: inmonoid (union X (add S (union V1 V2))) (cons S1 nil) *) apply Regles_add. (* Goal: Regles X (add S (union V1 V2)) (add (couple S (word (cons S2 nil))) (union R1 R2)) *) (* Goal: dans S (add S (union V1 V2)) *) (* Goal: inmonoid (union X (add S (union V1 V2))) (cons S1 nil) *) apply Regles_add. (* Goal: Regles X (add S (union V1 V2)) (union R1 R2) *) (* Goal: dans S (add S (union V1 V2)) *) (* Goal: inmonoid (union X (add S (union V1 V2))) (cons S2 nil) *) (* Goal: dans S (add S (union V1 V2)) *) (* Goal: inmonoid (union X (add S (union V1 V2))) (cons S1 nil) *) apply Regles_add2. change (Regles X (fst (Gunion V1 R1 V2 R2)) (snd (Gunion V1 R1 V2 R2))) in |- *. (* Goal: Regles X (@fst Ensf Ensf (Gunion V1 R1 V2 R2)) (@snd Ensf Ensf (Gunion V1 R1 V2 R2)) *) (* Goal: dans S (add S (union V1 V2)) *) (* Goal: inmonoid (union X (add S (union V1 V2))) (cons S2 nil) *) (* Goal: dans S (add S (union V1 V2)) *) (* Goal: inmonoid (union X (add S (union V1 V2))) (cons S1 nil) *) prolog [ Gunion_Regles ] 2. (*Apply Gunion_Regles with S1 S2;Auto.*) (* Goal: @eq Word (Append (cons S2 nil) nil) (cons S2 nil) *) (* Goal: Derivestar (add (couple S (word (cons S1 nil))) (add (couple S (word (cons S2 nil))) (union R1 R2))) (cons S2 nil) w *) (* Goal: inmonoid X w *) auto. (* Goal: inmonoid (union X (add S (union V1 V2))) (cons S1 nil) *) apply inmonoid_cons. (* Goal: forall _ : dans (couple A (word u0)) R2, dans (couple A (word u0)) R2 *) (* Goal: or (dans (couple A (word u0)) R1) (dans (couple A (word u0)) R2) *) (* Goal: or (@eq Elt (couple S (word (cons S2 nil))) (couple A (word u0))) (dans (couple A (word u0)) (union R1 R2)) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple A (word u0))) (dans (couple A (word u0)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V2) u, Derive R2 u v) (_ : inmonoid (union X V2) (cons x u)), Derive R2 (cons x u) (cons x v) *) trivial. cut (dans S2 V2); [ auto | prolog [ isGram3 ] 2(*Apply isGram3 with X R2;Assumption*) ]. (* Goal: @eq Word (Append (cons S2 nil) nil) (cons S2 nil) *) (* Goal: Derivestar (add (couple S (word (cons S1 nil))) (add (couple S (word (cons S2 nil))) (union R1 R2))) (cons S2 nil) w *) (* Goal: inmonoid X w *) auto. (* Goal: inmonoid (union X (add S (union V1 V2))) (cons S1 nil) *) apply inmonoid_cons. (* Goal: forall _ : dans (couple A (word u0)) R2, dans (couple A (word u0)) R2 *) (* Goal: or (dans (couple A (word u0)) R1) (dans (couple A (word u0)) R2) *) (* Goal: or (@eq Elt (couple S (word (cons S2 nil))) (couple A (word u0))) (dans (couple A (word u0)) (union R1 R2)) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple A (word u0))) (dans (couple A (word u0)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V2) u, Derive R2 u v) (_ : inmonoid (union X V2) (cons x u)), Derive R2 (cons x u) (cons x v) *) trivial. cut (dans S1 V1); [ auto | prolog [ isGram3 ] 2 (*Apply isGram3 with X R1;Assumption*) ]. Qed. Lemma inmon_Der_imp_Der_d : ~ dans S X -> ~ dans S V1 -> ~ dans S V2 -> Regles X V1 R1 -> Regles X V2 R2 -> inter (union X V1) V2 empty -> forall u v : Word, Derive Ru u v -> inmonoid (union X V1) u -> Derive R1 u v. intros N_dans_X N_dans_V1 N_dans_V2 Re_1 Re_2 inter_X_V1_V2_empty u v Der_Ru_u. (* Goal: forall _ : inmonoid (union X V2) u, Derive R2 u v *) elim Der_Ru_u. (* Goal: forall (u v : Word) (A : Elt) (_ : dans (couple A (word u)) Ru) (_ : inmonoid (union X V2) (cons A v)), Derive R2 (cons A v) (Append u v) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V2) u, Derive R2 u v) (_ : inmonoid (union X V2) (cons x u)), Derive R2 (cons x u) (cons x v) *) intros u0 v0 A dans_couple_Ru inmon_cons_A_v0. (* Goal: Derive R2 (cons A v0) (Append u0 v0) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V2) u, Derive R2 u v) (_ : inmonoid (union X V2) (cons x u)), Derive R2 (cons x u) (cons x v) *) apply Derive1. cut (couple S (word (cons S1 nil)) = couple A (word u0) :>Elt \/ dans (couple A (word u0)) (add (couple S (word (cons S2 nil))) (union R1 R2))). (**) (* Goal: forall _ : @ex2 Word (fun w : Word => Derive Ru (cons S nil) w) (fun w : Word => Derivestar Ru w u), or (@eq Word (cons S nil) u) (or (Derivestar R1 (cons S1 nil) u) (Derivestar R2 (cons S2 nil) u)) *) (* Goal: or (@eq Word (cons S nil) u) (@ex2 Word (fun w : Word => Derive Ru (cons S nil) w) (fun w : Word => Derivestar Ru w u)) *) intro temp; elim temp; clear temp. (* Goal: forall _ : @eq Elt (couple S (word (cons S2 nil))) (couple S (word x)), or (@eq Word (cons S1 nil) x) (@eq Word (cons S2 nil) x) *) (* Goal: forall _ : dans (couple S (word x)) (union R1 R2), or (@eq Word (cons S1 nil) x) (@eq Word (cons S2 nil) x) *) (* Goal: or (@eq Elt (couple S (word (cons S2 nil))) (couple S (word x))) (dans (couple S (word x)) (union R1 R2)) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple S (word x))) (dans (couple S (word x)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: @eq Word x u *) (* Goal: forall (x : Word) (_ : Derive Ru nil x) (_ : @eq Word (cons S x) u), or (@eq Word (cons S1 nil) u) (@eq Word (cons S2 nil) u) *) (* Goal: Derive_inv Ru (cons S nil) u *) intro egal_S. (* Goal: dans (couple A (word u0)) R1 *) (* Goal: forall _ : dans (couple A (word u0)) (union R1 R2), dans (couple A (word u0)) R1 *) (* Goal: or (@eq Elt (couple S (word (cons S2 nil))) (couple A (word u0))) (dans (couple A (word u0)) (union R1 R2)) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple A (word u0))) (dans (couple A (word u0)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V1) u, Derive R1 u v) (_ : inmonoid (union X V1) (cons x u)), Derive R1 (cons x u) (cons x v) *) absurd (dans S X \/ dans S V1). (* Goal: l_inclus (LG X V2 R2 S2) (LG X Vu Ru S) *) red in |- *. (* Goal: forall _ : @ex2 Word (fun w : Word => Derive Ru (cons S nil) w) (fun w : Word => Derivestar Ru w u), or (@eq Word (cons S nil) u) (or (Derivestar R1 (cons S1 nil) u) (Derivestar R2 (cons S2 nil) u)) *) (* Goal: or (@eq Word (cons S nil) u) (@ex2 Word (fun w : Word => Derive Ru (cons S nil) w) (fun w : Word => Derivestar Ru w u)) *) intro temp; elim temp; clear temp. (* Goal: forall _ : dans S X, False *) (* Goal: forall _ : dans S V1, False *) (* Goal: or (dans S X) (dans S V1) *) (* Goal: forall _ : dans (couple A (word u0)) (add (couple S (word (cons S2 nil))) (union R1 R2)), dans (couple A (word u0)) R1 *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple A (word u0))) (dans (couple A (word u0)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V1) u, Derive R1 u v) (_ : inmonoid (union X V1) (cons x u)), Derive R1 (cons x u) (cons x v) *) exact N_dans_X. (* Goal: forall _ : dans S V1, False *) (* Goal: or (dans S X) (dans S V1) *) (* Goal: forall _ : dans (couple A (word u0)) (add (couple S (word (cons S2 nil))) (union R1 R2)), dans (couple A (word u0)) R1 *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple A (word u0))) (dans (couple A (word u0)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V1) u, Derive R1 u v) (_ : inmonoid (union X V1) (cons x u)), Derive R1 (cons x u) (cons x v) *) exact N_dans_V1. (* Goal: or (dans S X) (dans S V2) *) (* Goal: forall _ : dans (couple A (word u0)) (union R1 R2), dans (couple A (word u0)) R2 *) (* Goal: or (@eq Elt (couple S (word (cons S2 nil))) (couple A (word u0))) (dans (couple A (word u0)) (union R1 R2)) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple A (word u0))) (dans (couple A (word u0)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V2) u, Derive R2 u v) (_ : inmonoid (union X V2) (cons x u)), Derive R2 (cons x u) (cons x v) *) apply dans_union. (* Goal: dans S (union X V2) *) (* Goal: forall _ : dans (couple A (word u0)) (union R1 R2), dans (couple A (word u0)) R2 *) (* Goal: or (@eq Elt (couple S (word (cons S2 nil))) (couple A (word u0))) (dans (couple A (word u0)) (union R1 R2)) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple A (word u0))) (dans (couple A (word u0)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V2) u, Derive R2 u v) (_ : inmonoid (union X V2) (cons x u)), Derive R2 (cons x u) (cons x v) *) replace S with A. (* Goal: dans A (union X V2) *) (* Goal: @eq Elt A S *) (* Goal: forall _ : dans (couple A (word u0)) (union R1 R2), dans (couple A (word u0)) R2 *) (* Goal: or (@eq Elt (couple S (word (cons S2 nil))) (couple A (word u0))) (dans (couple A (word u0)) (union R1 R2)) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple A (word u0))) (dans (couple A (word u0)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V2) u, Derive R2 u v) (_ : inmonoid (union X V2) (cons x u)), Derive R2 (cons x u) (cons x v) *) prolog [ inmonoid_cons_inv2 ] 2. (*Apply inmonoid_cons_inv2 with v0;Assumption.*) (* Goal: @eq Word (Append (cons S2 nil) nil) (cons S2 nil) *) (* Goal: Derivestar (add (couple S (word (cons S1 nil))) (add (couple S (word (cons S2 nil))) (union R1 R2))) (cons S2 nil) w *) (* Goal: inmonoid X w *) injection egal_S; auto. (* Goal: forall _ : dans (couple S (word x)) (add (couple S (word (cons S2 nil))) (union R1 R2)), or (@eq Word (cons S1 nil) x) (@eq Word (cons S2 nil) x) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple S (word x))) (dans (couple S (word x)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: @eq Word x u *) (* Goal: forall (x : Word) (_ : Derive Ru nil x) (_ : @eq Word (cons S x) u), or (@eq Word (cons S1 nil) u) (@eq Word (cons S2 nil) u) *) (* Goal: Derive_inv Ru (cons S nil) u *) intro dans_couple_add. cut (couple S (word (cons S2 nil)) = couple A (word u0) :>Elt \/ dans (couple A (word u0)) (union R1 R2)). (***) (* Goal: forall _ : @ex2 Word (fun w : Word => Derive Ru (cons S nil) w) (fun w : Word => Derivestar Ru w u), or (@eq Word (cons S nil) u) (or (Derivestar R1 (cons S1 nil) u) (Derivestar R2 (cons S2 nil) u)) *) (* Goal: or (@eq Word (cons S nil) u) (@ex2 Word (fun w : Word => Derive Ru (cons S nil) w) (fun w : Word => Derivestar Ru w u)) *) intro temp; elim temp; clear temp. (* Goal: forall _ : @eq Elt (couple S (word (cons S2 nil))) (couple S (word x)), or (@eq Word (cons S1 nil) x) (@eq Word (cons S2 nil) x) *) (* Goal: forall _ : dans (couple S (word x)) (union R1 R2), or (@eq Word (cons S1 nil) x) (@eq Word (cons S2 nil) x) *) (* Goal: or (@eq Elt (couple S (word (cons S2 nil))) (couple S (word x))) (dans (couple S (word x)) (union R1 R2)) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple S (word x))) (dans (couple S (word x)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: @eq Word x u *) (* Goal: forall (x : Word) (_ : Derive Ru nil x) (_ : @eq Word (cons S x) u), or (@eq Word (cons S1 nil) u) (@eq Word (cons S2 nil) u) *) (* Goal: Derive_inv Ru (cons S nil) u *) intro egal_S. (* Goal: dans (couple A (word u0)) R1 *) (* Goal: forall _ : dans (couple A (word u0)) (union R1 R2), dans (couple A (word u0)) R1 *) (* Goal: or (@eq Elt (couple S (word (cons S2 nil))) (couple A (word u0))) (dans (couple A (word u0)) (union R1 R2)) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple A (word u0))) (dans (couple A (word u0)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V1) u, Derive R1 u v) (_ : inmonoid (union X V1) (cons x u)), Derive R1 (cons x u) (cons x v) *) absurd (dans S X \/ dans S V1). (* Goal: l_inclus (LG X V2 R2 S2) (LG X Vu Ru S) *) red in |- *. (* Goal: @eq Word (Append (cons S2 nil) nil) (cons S2 nil) *) (* Goal: Derivestar (add (couple S (word (cons S1 nil))) (add (couple S (word (cons S2 nil))) (union R1 R2))) (cons S2 nil) w *) (* Goal: inmonoid X w *) intro temp; elim temp; auto. (* Goal: or (dans S X) (dans S V2) *) (* Goal: forall _ : dans (couple A (word u0)) (union R1 R2), dans (couple A (word u0)) R2 *) (* Goal: or (@eq Elt (couple S (word (cons S2 nil))) (couple A (word u0))) (dans (couple A (word u0)) (union R1 R2)) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple A (word u0))) (dans (couple A (word u0)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V2) u, Derive R2 u v) (_ : inmonoid (union X V2) (cons x u)), Derive R2 (cons x u) (cons x v) *) apply dans_union. (* Goal: dans S (union X V2) *) (* Goal: forall _ : dans (couple A (word u0)) (union R1 R2), dans (couple A (word u0)) R2 *) (* Goal: or (@eq Elt (couple S (word (cons S2 nil))) (couple A (word u0))) (dans (couple A (word u0)) (union R1 R2)) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple A (word u0))) (dans (couple A (word u0)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V2) u, Derive R2 u v) (_ : inmonoid (union X V2) (cons x u)), Derive R2 (cons x u) (cons x v) *) replace S with A. (* Goal: dans A (union X V2) *) (* Goal: @eq Elt A S *) (* Goal: forall _ : dans (couple A (word u0)) (union R1 R2), dans (couple A (word u0)) R2 *) (* Goal: or (@eq Elt (couple S (word (cons S2 nil))) (couple A (word u0))) (dans (couple A (word u0)) (union R1 R2)) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple A (word u0))) (dans (couple A (word u0)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V2) u, Derive R2 u v) (_ : inmonoid (union X V2) (cons x u)), Derive R2 (cons x u) (cons x v) *) prolog [ inmonoid_cons_inv2 ] 2. (*Apply inmonoid_cons_inv2 with v0;Assumption.*) (* Goal: @eq Word (Append (cons S2 nil) nil) (cons S2 nil) *) (* Goal: Derivestar (add (couple S (word (cons S1 nil))) (add (couple S (word (cons S2 nil))) (union R1 R2))) (cons S2 nil) w *) (* Goal: inmonoid X w *) injection egal_S; auto. (* Goal: forall _ : dans (couple S (word x)) (union R1 R2), or (@eq Word (cons S1 nil) x) (@eq Word (cons S2 nil) x) *) (* Goal: or (@eq Elt (couple S (word (cons S2 nil))) (couple S (word x))) (dans (couple S (word x)) (union R1 R2)) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple S (word x))) (dans (couple S (word x)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: @eq Word x u *) (* Goal: forall (x : Word) (_ : Derive Ru nil x) (_ : @eq Word (cons S x) u), or (@eq Word (cons S1 nil) u) (@eq Word (cons S2 nil) u) *) (* Goal: Derive_inv Ru (cons S nil) u *) intro dans_couple_union. (* Goal: dans (couple A (word u0)) R2 *) (* Goal: or (@eq Elt (couple S (word (cons S2 nil))) (couple A (word u0))) (dans (couple A (word u0)) (union R1 R2)) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple A (word u0))) (dans (couple A (word u0)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V2) u, Derive R2 u v) (_ : inmonoid (union X V2) (cons x u)), Derive R2 (cons x u) (cons x v) *) cut (dans (couple A (word u0)) R1 \/ dans (couple A (word u0)) R2). (****) (* Goal: forall _ : @ex2 Word (fun w : Word => Derive Ru (cons S nil) w) (fun w : Word => Derivestar Ru w u), or (@eq Word (cons S nil) u) (or (Derivestar R1 (cons S1 nil) u) (Derivestar R2 (cons S2 nil) u)) *) (* Goal: or (@eq Word (cons S nil) u) (@ex2 Word (fun w : Word => Derive Ru (cons S nil) w) (fun w : Word => Derivestar Ru w u)) *) (*Intuition.*)intro temp; elim temp; clear temp. (* Goal: @eq Word (Append (cons S2 nil) nil) (cons S2 nil) *) (* Goal: Derivestar (add (couple S (word (cons S1 nil))) (add (couple S (word (cons S2 nil))) (union R1 R2))) (cons S2 nil) w *) (* Goal: inmonoid X w *) auto. (* Goal: forall _ : dans (couple A (word u0)) R2, dans (couple A (word u0)) R1 *) (* Goal: or (dans (couple A (word u0)) R1) (dans (couple A (word u0)) R2) *) (* Goal: or (@eq Elt (couple S (word (cons S2 nil))) (couple A (word u0))) (dans (couple A (word u0)) (union R1 R2)) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple A (word u0))) (dans (couple A (word u0)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V1) u, Derive R1 u v) (_ : inmonoid (union X V1) (cons x u)), Derive R1 (cons x u) (cons x v) *) intro dans_R2. (* Goal: dans (couple A (word u0)) R1 *) (* Goal: or (dans (couple A (word u0)) R1) (dans (couple A (word u0)) R2) *) (* Goal: or (@eq Elt (couple S (word (cons S2 nil))) (couple A (word u0))) (dans (couple A (word u0)) (union R1 R2)) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple A (word u0))) (dans (couple A (word u0)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V1) u, Derive R1 u v) (_ : inmonoid (union X V1) (cons x u)), Derive R1 (cons x u) (cons x v) *) absurd (inter (union X V1) V2 empty). (* Goal: l_inclus (LG X V2 R2 S2) (LG X Vu Ru S) *) red in |- *. (* Goal: forall _ : inter (union X V2) V1 empty, False *) (* Goal: inter (union X V2) V1 empty *) (* Goal: forall _ : dans (couple A (word u0)) R2, dans (couple A (word u0)) R2 *) (* Goal: or (dans (couple A (word u0)) R1) (dans (couple A (word u0)) R2) *) (* Goal: or (@eq Elt (couple S (word (cons S2 nil))) (couple A (word u0))) (dans (couple A (word u0)) (union R1 R2)) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple A (word u0))) (dans (couple A (word u0)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V2) u, Derive R2 u v) (_ : inmonoid (union X V2) (cons x u)), Derive R2 (cons x u) (cons x v) *) unfold inter in |- *. (* Goal: forall _ : @ex2 Word (fun w : Word => Derive Ru (cons S nil) w) (fun w : Word => Derivestar Ru w u), or (@eq Word (cons S nil) u) (or (Derivestar R1 (cons S1 nil) u) (Derivestar R2 (cons S2 nil) u)) *) (* Goal: or (@eq Word (cons S nil) u) (@ex2 Word (fun w : Word => Derive Ru (cons S nil) w) (fun w : Word => Derivestar Ru w u)) *) (*Intuition.*)intro temp; elim temp; clear temp. (* Goal: forall (_ : inclus empty (union X V1)) (_ : and (inclus empty V2) (forall (x : Elt) (_ : dans x (union X V1)) (_ : dans x V2), dans x empty)), False *) (* Goal: inter (union X V1) V2 empty *) (* Goal: or (dans (couple A (word u0)) R1) (dans (couple A (word u0)) R2) *) (* Goal: or (@eq Elt (couple S (word (cons S2 nil))) (couple A (word u0))) (dans (couple A (word u0)) (union R1 R2)) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple A (word u0))) (dans (couple A (word u0)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V1) u, Derive R1 u v) (_ : inmonoid (union X V1) (cons x u)), Derive R1 (cons x u) (cons x v) *) intros HH temp; elim temp; clear temp; intros HHH HHHH. (*Intros.*) (* Goal: False *) (* Goal: inter (union X V1) V2 empty *) (* Goal: or (dans (couple A (word u0)) R1) (dans (couple A (word u0)) R2) *) (* Goal: or (@eq Elt (couple S (word (cons S2 nil))) (couple A (word u0))) (dans (couple A (word u0)) (union R1 R2)) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple A (word u0))) (dans (couple A (word u0)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V1) u, Derive R1 u v) (_ : inmonoid (union X V1) (cons x u)), Derive R1 (cons x u) (cons x v) *) prolog [ Regles_inv1 inmonoid_cons_inv2 dans_empty_imp_P ] 4. (*Intro temp;Elim temp;Clear temp. Intros incl_empty_X_V1 temp;Elim temp;Clear temp. Intros incl_empty_V2 imp. Apply dans_empty_imp_P with A. Apply imp. Apply inmonoid_cons_inv2 with v0;Assumption. Apply Regles_inv1 with X R2 (word u0); Assumption.*) (* Goal: inmonoid X w *) assumption. (* Goal: @eq Word (Append (cons S2 nil) nil) (cons S2 nil) *) (* Goal: Derivestar (add (couple S (word (cons S1 nil))) (add (couple S (word (cons S2 nil))) (union R1 R2))) (cons S2 nil) w *) (* Goal: inmonoid X w *) (****)auto. (* Goal: @eq Word (Append (cons S2 nil) nil) (cons S2 nil) *) (* Goal: Derivestar (add (couple S (word (cons S1 nil))) (add (couple S (word (cons S2 nil))) (union R1 R2))) (cons S2 nil) w *) (* Goal: inmonoid X w *) (***)auto. (* Goal: @eq Word (Append (cons S2 nil) nil) (cons S2 nil) *) (* Goal: Derivestar (add (couple S (word (cons S1 nil))) (add (couple S (word (cons S2 nil))) (union R1 R2))) (cons S2 nil) w *) (* Goal: inmonoid X w *) (**)auto. (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V2) u, Derive R2 u v) (_ : inmonoid (union X V2) (cons x u)), Derive R2 (cons x u) (cons x v) *) prolog [ inmonoid_cons_inv Derive2 ] 10. (*Intros u0 v0 x Der_Ru imp inmon_cons_x_u0. Apply Derive2. Apply imp. Apply inmonoid_cons_inv with x. Assumption.*) Qed. Lemma inmon_Der_imp_inmon_R1_d : forall u v : Word, Regles X V1 R1 -> Derive R1 u v -> inmonoid (union X V1) u -> inmonoid (union X V1) v. (* Goal: forall (u v : Word) (_ : Regles X V1 R1) (_ : Derive R1 u v) (_ : inmonoid (union X V1) u), inmonoid (union X V1) v *) prolog [ in_mon_X_Der_imp_inmon_X ] 7. (*Intros. Apply in_mon_X_Der_imp_inmon_X with R1 u;Assumption.*) Qed. Lemma inmon_Der_imp_inmon_d : ~ dans S X -> ~ dans S V1 -> ~ dans S V2 -> forall u v : Word, isGram X V1 R1 S1 -> isGram X V2 R2 S2 -> inter V1 V2 empty -> inmonoid (union X V1) u -> Derive Ru u v -> inmonoid (union X V1) v. prolog [ isGram2 isGram4 inter_union inmon_Der_imp_Der_d inmon_Der_imp_inmon_R1_d ] 15. (*Intros N_dans_X N_dans_V1 N_dans_V2 u v G_R1 G_R2 inter_V1_V2_empty inmon_X_V1_u Der_Ru_u_v. Apply inmon_Der_imp_inmon_R1_d with u. Apply isGram4 with S1;Assumption. Apply inmon_Der_imp_Der_d. Assumption. Assumption. Assumption. Apply isGram4 with S1;Assumption. Apply isGram4 with S2;Assumption. Apply inter_union. Apply isGram2 with R2 S2; Assumption. Assumption. Assumption. Assumption. Assumption.*) Qed. Lemma Gunion_disj_Derivestar : ~ dans S X -> ~ dans S V1 -> ~ dans S V2 -> isGram X V1 R1 S1 -> isGram X V2 R2 S2 -> inter V1 V2 empty -> forall u v : Word, Derivestar Ru u v -> inmonoid (union X V1) u -> Derivestar R1 u v. (* Goal: forall (_ : not (dans S X)) (_ : not (dans S V1)) (_ : not (dans S V2)) (_ : isGram X V1 R1 S1) (_ : isGram X V2 R2 S2) (_ : inter V1 V2 empty) (u v : Word) (_ : Derivestar Ru u v) (_ : inmonoid (union X V2) u), Derivestar R2 u v *) unfold Derivestar in |- *. intros N_dans_X N_dans_V1 N_dans_V2 G_1 G_2 inter_V1_V2_empty u v Derivestar_Ru. (* Goal: forall _ : inmonoid (union X V2) u, Rstar Word (Derive R2) u v *) pattern u, v in |- *. (* Goal: (fun w w0 : Word => forall _ : inmonoid (union X V2) w, Rstar Word (Derive R2) w w0) u v *) apply Derivestar_Ru. (* Goal: @eq Word (Append (cons S2 nil) nil) (cons S2 nil) *) (* Goal: Derivestar (add (couple S (word (cons S1 nil))) (add (couple S (word (cons S2 nil))) (union R1 R2))) (cons S2 nil) w *) (* Goal: inmonoid X w *) auto. (* Goal: forall (u v w : Word) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V1) v, Rstar Word (Derive R1) v w) (_ : inmonoid (union X V1) u), Rstar Word (Derive R1) u w *) intros u0 v0 w Der_Ru inmon_v0_imp_Rstar_R1_v0 inmon_u0. apply Rstar_R with v0; prolog [ isGram2 inter_union isGram4 inmon_Der_imp_Der_d inmon_Der_imp_inmon_d ] 4. (*Apply Rstar_R with v0 inmon_v0_imp_Rstar_R1_v0 inmon_Der_imp_inmon_d. Apply inmon_Der_imp_Der_d. Assumption. Assumption. Assumption. Apply isGram4 with S1;Assumption. Apply isGram4 with S2;Assumption. Apply inter_union. Apply isGram2 with R2 S2; Assumption. Assumption. Assumption. Assumption. Apply inmon_v0_imp_Rstar_R1_v0. Apply inmon_Der_imp_inmon_d with u0;Assumption.*) Qed. Lemma inmon_Der_imp_Der_d2 : ~ dans S X -> ~ dans S V1 -> ~ dans S V2 -> Regles X V1 R1 -> Regles X V2 R2 -> inter (union X V2) V1 empty -> forall u v : Word, Derive Ru u v -> inmonoid (union X V2) u -> Derive R2 u v. intros N_dans_X N_dans_V1 N_dans_V2 Re_1 Re_2 inter_X_V2_V1_empty u v Der_Ru_u. (* Goal: forall _ : inmonoid (union X V2) u, Derive R2 u v *) elim Der_Ru_u. (* Goal: forall (u v : Word) (A : Elt) (_ : dans (couple A (word u)) Ru) (_ : inmonoid (union X V2) (cons A v)), Derive R2 (cons A v) (Append u v) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V2) u, Derive R2 u v) (_ : inmonoid (union X V2) (cons x u)), Derive R2 (cons x u) (cons x v) *) intros u0 v0 A dans_couple_Ru inmon_cons_A_v0. (* Goal: Derive R2 (cons A v0) (Append u0 v0) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V2) u, Derive R2 u v) (_ : inmonoid (union X V2) (cons x u)), Derive R2 (cons x u) (cons x v) *) apply Derive1. cut (couple S (word (cons S1 nil)) = couple A (word u0) :>Elt \/ dans (couple A (word u0)) (add (couple S (word (cons S2 nil))) (union R1 R2))). (**) (* Goal: forall _ : @ex2 Word (fun w : Word => Derive Ru (cons S nil) w) (fun w : Word => Derivestar Ru w u), or (@eq Word (cons S nil) u) (or (Derivestar R1 (cons S1 nil) u) (Derivestar R2 (cons S2 nil) u)) *) (* Goal: or (@eq Word (cons S nil) u) (@ex2 Word (fun w : Word => Derive Ru (cons S nil) w) (fun w : Word => Derivestar Ru w u)) *) intro temp; elim temp; clear temp. (* Goal: forall _ : @eq Elt (couple S (word (cons S2 nil))) (couple S (word x)), or (@eq Word (cons S1 nil) x) (@eq Word (cons S2 nil) x) *) (* Goal: forall _ : dans (couple S (word x)) (union R1 R2), or (@eq Word (cons S1 nil) x) (@eq Word (cons S2 nil) x) *) (* Goal: or (@eq Elt (couple S (word (cons S2 nil))) (couple S (word x))) (dans (couple S (word x)) (union R1 R2)) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple S (word x))) (dans (couple S (word x)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: @eq Word x u *) (* Goal: forall (x : Word) (_ : Derive Ru nil x) (_ : @eq Word (cons S x) u), or (@eq Word (cons S1 nil) u) (@eq Word (cons S2 nil) u) *) (* Goal: Derive_inv Ru (cons S nil) u *) intro egal_S. (* Goal: dans (couple A (word u0)) R2 *) (* Goal: forall _ : dans (couple A (word u0)) (union R1 R2), dans (couple A (word u0)) R2 *) (* Goal: or (@eq Elt (couple S (word (cons S2 nil))) (couple A (word u0))) (dans (couple A (word u0)) (union R1 R2)) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple A (word u0))) (dans (couple A (word u0)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V2) u, Derive R2 u v) (_ : inmonoid (union X V2) (cons x u)), Derive R2 (cons x u) (cons x v) *) absurd (dans S X \/ dans S V2). (* Goal: l_inclus (LG X V2 R2 S2) (LG X Vu Ru S) *) red in |- *. (* Goal: forall _ : or (dans S X) (dans S V2), False *) (* Goal: or (dans S X) (dans S V2) *) (* Goal: forall _ : dans (couple A (word u0)) (union R1 R2), dans (couple A (word u0)) R2 *) (* Goal: or (@eq Elt (couple S (word (cons S2 nil))) (couple A (word u0))) (dans (couple A (word u0)) (union R1 R2)) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple A (word u0))) (dans (couple A (word u0)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V2) u, Derive R2 u v) (_ : inmonoid (union X V2) (cons x u)), Derive R2 (cons x u) (cons x v) *) intuition. (* Goal: or (dans S X) (dans S V2) *) (* Goal: forall _ : dans (couple A (word u0)) (union R1 R2), dans (couple A (word u0)) R2 *) (* Goal: or (@eq Elt (couple S (word (cons S2 nil))) (couple A (word u0))) (dans (couple A (word u0)) (union R1 R2)) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple A (word u0))) (dans (couple A (word u0)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V2) u, Derive R2 u v) (_ : inmonoid (union X V2) (cons x u)), Derive R2 (cons x u) (cons x v) *) apply dans_union. (* Goal: dans S (union X V2) *) (* Goal: forall _ : dans (couple A (word u0)) (union R1 R2), dans (couple A (word u0)) R2 *) (* Goal: or (@eq Elt (couple S (word (cons S2 nil))) (couple A (word u0))) (dans (couple A (word u0)) (union R1 R2)) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple A (word u0))) (dans (couple A (word u0)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V2) u, Derive R2 u v) (_ : inmonoid (union X V2) (cons x u)), Derive R2 (cons x u) (cons x v) *) replace S with A. (* Goal: dans A (union X V2) *) (* Goal: @eq Elt A S *) (* Goal: forall _ : dans (couple A (word u0)) (union R1 R2), dans (couple A (word u0)) R2 *) (* Goal: or (@eq Elt (couple S (word (cons S2 nil))) (couple A (word u0))) (dans (couple A (word u0)) (union R1 R2)) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple A (word u0))) (dans (couple A (word u0)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V2) u, Derive R2 u v) (_ : inmonoid (union X V2) (cons x u)), Derive R2 (cons x u) (cons x v) *) prolog [ inmonoid_cons_inv2 ] 2. (*Apply inmonoid_cons_inv2 with v0;Assumption.*) (* Goal: @eq Word (Append (cons S2 nil) nil) (cons S2 nil) *) (* Goal: Derivestar (add (couple S (word (cons S1 nil))) (add (couple S (word (cons S2 nil))) (union R1 R2))) (cons S2 nil) w *) (* Goal: inmonoid X w *) injection egal_S; auto. (* Goal: forall _ : dans (couple S (word x)) (add (couple S (word (cons S2 nil))) (union R1 R2)), or (@eq Word (cons S1 nil) x) (@eq Word (cons S2 nil) x) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple S (word x))) (dans (couple S (word x)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: @eq Word x u *) (* Goal: forall (x : Word) (_ : Derive Ru nil x) (_ : @eq Word (cons S x) u), or (@eq Word (cons S1 nil) u) (@eq Word (cons S2 nil) u) *) (* Goal: Derive_inv Ru (cons S nil) u *) intro dans_couple_add. cut (couple S (word (cons S2 nil)) = couple A (word u0) :>Elt \/ dans (couple A (word u0)) (union R1 R2)). (***) (* Goal: forall _ : @ex2 Word (fun w : Word => Derive Ru (cons S nil) w) (fun w : Word => Derivestar Ru w u), or (@eq Word (cons S nil) u) (or (Derivestar R1 (cons S1 nil) u) (Derivestar R2 (cons S2 nil) u)) *) (* Goal: or (@eq Word (cons S nil) u) (@ex2 Word (fun w : Word => Derive Ru (cons S nil) w) (fun w : Word => Derivestar Ru w u)) *) intro temp; elim temp; clear temp. (* Goal: forall _ : @eq Elt (couple S (word (cons S2 nil))) (couple S (word x)), or (@eq Word (cons S1 nil) x) (@eq Word (cons S2 nil) x) *) (* Goal: forall _ : dans (couple S (word x)) (union R1 R2), or (@eq Word (cons S1 nil) x) (@eq Word (cons S2 nil) x) *) (* Goal: or (@eq Elt (couple S (word (cons S2 nil))) (couple S (word x))) (dans (couple S (word x)) (union R1 R2)) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple S (word x))) (dans (couple S (word x)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: @eq Word x u *) (* Goal: forall (x : Word) (_ : Derive Ru nil x) (_ : @eq Word (cons S x) u), or (@eq Word (cons S1 nil) u) (@eq Word (cons S2 nil) u) *) (* Goal: Derive_inv Ru (cons S nil) u *) intro egal_S. (* Goal: dans (couple A (word u0)) R2 *) (* Goal: forall _ : dans (couple A (word u0)) (union R1 R2), dans (couple A (word u0)) R2 *) (* Goal: or (@eq Elt (couple S (word (cons S2 nil))) (couple A (word u0))) (dans (couple A (word u0)) (union R1 R2)) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple A (word u0))) (dans (couple A (word u0)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V2) u, Derive R2 u v) (_ : inmonoid (union X V2) (cons x u)), Derive R2 (cons x u) (cons x v) *) absurd (dans S X \/ dans S V2). (* Goal: l_inclus (LG X V2 R2 S2) (LG X Vu Ru S) *) red in |- *. (* Goal: forall _ : or (dans S X) (dans S V2), False *) (* Goal: or (dans S X) (dans S V2) *) (* Goal: forall _ : dans (couple A (word u0)) (union R1 R2), dans (couple A (word u0)) R2 *) (* Goal: or (@eq Elt (couple S (word (cons S2 nil))) (couple A (word u0))) (dans (couple A (word u0)) (union R1 R2)) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple A (word u0))) (dans (couple A (word u0)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V2) u, Derive R2 u v) (_ : inmonoid (union X V2) (cons x u)), Derive R2 (cons x u) (cons x v) *) intuition. (* Goal: or (dans S X) (dans S V2) *) (* Goal: forall _ : dans (couple A (word u0)) (union R1 R2), dans (couple A (word u0)) R2 *) (* Goal: or (@eq Elt (couple S (word (cons S2 nil))) (couple A (word u0))) (dans (couple A (word u0)) (union R1 R2)) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple A (word u0))) (dans (couple A (word u0)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V2) u, Derive R2 u v) (_ : inmonoid (union X V2) (cons x u)), Derive R2 (cons x u) (cons x v) *) apply dans_union. (* Goal: dans S (union X V2) *) (* Goal: forall _ : dans (couple A (word u0)) (union R1 R2), dans (couple A (word u0)) R2 *) (* Goal: or (@eq Elt (couple S (word (cons S2 nil))) (couple A (word u0))) (dans (couple A (word u0)) (union R1 R2)) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple A (word u0))) (dans (couple A (word u0)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V2) u, Derive R2 u v) (_ : inmonoid (union X V2) (cons x u)), Derive R2 (cons x u) (cons x v) *) replace S with A. (* Goal: dans A (union X V2) *) (* Goal: @eq Elt A S *) (* Goal: forall _ : dans (couple A (word u0)) (union R1 R2), dans (couple A (word u0)) R2 *) (* Goal: or (@eq Elt (couple S (word (cons S2 nil))) (couple A (word u0))) (dans (couple A (word u0)) (union R1 R2)) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple A (word u0))) (dans (couple A (word u0)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V2) u, Derive R2 u v) (_ : inmonoid (union X V2) (cons x u)), Derive R2 (cons x u) (cons x v) *) prolog [ inmonoid_cons_inv2 ] 2. (*Apply inmonoid_cons_inv2 with v0;Assumption.*) (* Goal: @eq Word (Append (cons S2 nil) nil) (cons S2 nil) *) (* Goal: Derivestar (add (couple S (word (cons S1 nil))) (add (couple S (word (cons S2 nil))) (union R1 R2))) (cons S2 nil) w *) (* Goal: inmonoid X w *) injection egal_S; auto. (* Goal: forall _ : dans (couple S (word x)) (union R1 R2), or (@eq Word (cons S1 nil) x) (@eq Word (cons S2 nil) x) *) (* Goal: or (@eq Elt (couple S (word (cons S2 nil))) (couple S (word x))) (dans (couple S (word x)) (union R1 R2)) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple S (word x))) (dans (couple S (word x)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: @eq Word x u *) (* Goal: forall (x : Word) (_ : Derive Ru nil x) (_ : @eq Word (cons S x) u), or (@eq Word (cons S1 nil) u) (@eq Word (cons S2 nil) u) *) (* Goal: Derive_inv Ru (cons S nil) u *) intro dans_couple_union. (* Goal: dans (couple A (word u0)) R2 *) (* Goal: or (@eq Elt (couple S (word (cons S2 nil))) (couple A (word u0))) (dans (couple A (word u0)) (union R1 R2)) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple A (word u0))) (dans (couple A (word u0)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V2) u, Derive R2 u v) (_ : inmonoid (union X V2) (cons x u)), Derive R2 (cons x u) (cons x v) *) cut (dans (couple A (word u0)) R1 \/ dans (couple A (word u0)) R2). (****) (* Goal: forall _ : @ex2 Word (fun w : Word => Derive Ru (cons S nil) w) (fun w : Word => Derivestar Ru w u), or (@eq Word (cons S nil) u) (or (Derivestar R1 (cons S1 nil) u) (Derivestar R2 (cons S2 nil) u)) *) (* Goal: or (@eq Word (cons S nil) u) (@ex2 Word (fun w : Word => Derive Ru (cons S nil) w) (fun w : Word => Derivestar Ru w u)) *) (*Intuition.*) intro temp; elim temp; clear temp. (* Goal: forall _ : dans (couple S (word x)) R1, or (@eq Word (cons S1 nil) x) (@eq Word (cons S2 nil) x) *) (* Goal: forall _ : dans (couple S (word x)) R2, or (@eq Word (cons S1 nil) x) (@eq Word (cons S2 nil) x) *) (* Goal: or (dans (couple S (word x)) R1) (dans (couple S (word x)) R2) *) (* Goal: or (@eq Elt (couple S (word (cons S2 nil))) (couple S (word x))) (dans (couple S (word x)) (union R1 R2)) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple S (word x))) (dans (couple S (word x)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: @eq Word x u *) (* Goal: forall (x : Word) (_ : Derive Ru nil x) (_ : @eq Word (cons S x) u), or (@eq Word (cons S1 nil) u) (@eq Word (cons S2 nil) u) *) (* Goal: Derive_inv Ru (cons S nil) u *) intro dans_R1. (* Goal: dans (couple A (word u0)) R2 *) (* Goal: forall _ : dans (couple A (word u0)) R2, dans (couple A (word u0)) R2 *) (* Goal: or (dans (couple A (word u0)) R1) (dans (couple A (word u0)) R2) *) (* Goal: or (@eq Elt (couple S (word (cons S2 nil))) (couple A (word u0))) (dans (couple A (word u0)) (union R1 R2)) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple A (word u0))) (dans (couple A (word u0)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V2) u, Derive R2 u v) (_ : inmonoid (union X V2) (cons x u)), Derive R2 (cons x u) (cons x v) *) absurd (inter (union X V2) V1 empty). (* Goal: l_inclus (LG X V2 R2 S2) (LG X Vu Ru S) *) red in |- *. (* Goal: forall _ : inter (union X V2) V1 empty, False *) (* Goal: inter (union X V2) V1 empty *) (* Goal: forall _ : dans (couple A (word u0)) R2, dans (couple A (word u0)) R2 *) (* Goal: or (dans (couple A (word u0)) R1) (dans (couple A (word u0)) R2) *) (* Goal: or (@eq Elt (couple S (word (cons S2 nil))) (couple A (word u0))) (dans (couple A (word u0)) (union R1 R2)) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple A (word u0))) (dans (couple A (word u0)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V2) u, Derive R2 u v) (_ : inmonoid (union X V2) (cons x u)), Derive R2 (cons x u) (cons x v) *) unfold inter in |- *. (* Goal: forall _ : @ex2 Word (fun w : Word => Derive Ru (cons S nil) w) (fun w : Word => Derivestar Ru w u), or (@eq Word (cons S nil) u) (or (Derivestar R1 (cons S1 nil) u) (Derivestar R2 (cons S2 nil) u)) *) (* Goal: or (@eq Word (cons S nil) u) (@ex2 Word (fun w : Word => Derive Ru (cons S nil) w) (fun w : Word => Derivestar Ru w u)) *) (*Intuition.*) intro temp; elim temp; clear temp. (* Goal: forall (_ : inclus empty (union X V2)) (_ : and (inclus empty V1) (forall (x : Elt) (_ : dans x (union X V2)) (_ : dans x V1), dans x empty)), False *) (* Goal: inter (union X V2) V1 empty *) (* Goal: forall _ : dans (couple A (word u0)) R2, dans (couple A (word u0)) R2 *) (* Goal: or (dans (couple A (word u0)) R1) (dans (couple A (word u0)) R2) *) (* Goal: or (@eq Elt (couple S (word (cons S2 nil))) (couple A (word u0))) (dans (couple A (word u0)) (union R1 R2)) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple A (word u0))) (dans (couple A (word u0)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V2) u, Derive R2 u v) (_ : inmonoid (union X V2) (cons x u)), Derive R2 (cons x u) (cons x v) *) intros inc_empt temp; elim temp; clear temp. (* Goal: forall (_ : inclus empty V1) (_ : forall (x : Elt) (_ : dans x (union X V2)) (_ : dans x V1), dans x empty), False *) (* Goal: inter (union X V2) V1 empty *) (* Goal: forall _ : dans (couple A (word u0)) R2, dans (couple A (word u0)) R2 *) (* Goal: or (dans (couple A (word u0)) R1) (dans (couple A (word u0)) R2) *) (* Goal: or (@eq Elt (couple S (word (cons S2 nil))) (couple A (word u0))) (dans (couple A (word u0)) (union R1 R2)) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple A (word u0))) (dans (couple A (word u0)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V2) u, Derive R2 u v) (_ : inmonoid (union X V2) (cons x u)), Derive R2 (cons x u) (cons x v) *) intros incl_empty_V1 imp_dans_empty. (* Goal: False *) (* Goal: inter (union X V2) V1 empty *) (* Goal: forall _ : dans (couple A (word u0)) R2, dans (couple A (word u0)) R2 *) (* Goal: or (dans (couple A (word u0)) R1) (dans (couple A (word u0)) R2) *) (* Goal: or (@eq Elt (couple S (word (cons S2 nil))) (couple A (word u0))) (dans (couple A (word u0)) (union R1 R2)) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple A (word u0))) (dans (couple A (word u0)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V2) u, Derive R2 u v) (_ : inmonoid (union X V2) (cons x u)), Derive R2 (cons x u) (cons x v) *) apply dans_empty_imp_P with A. (* Goal: dans A empty *) (* Goal: inter (union X V2) V1 empty *) (* Goal: forall _ : dans (couple A (word u0)) R2, dans (couple A (word u0)) R2 *) (* Goal: or (dans (couple A (word u0)) R1) (dans (couple A (word u0)) R2) *) (* Goal: or (@eq Elt (couple S (word (cons S2 nil))) (couple A (word u0))) (dans (couple A (word u0)) (union R1 R2)) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple A (word u0))) (dans (couple A (word u0)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V2) u, Derive R2 u v) (_ : inmonoid (union X V2) (cons x u)), Derive R2 (cons x u) (cons x v) *) apply imp_dans_empty; prolog [ Regles_inv1 inmonoid_cons_inv2 ] 4. (*Intro temp;Elim temp;Clear temp. Intros incl_empty_X_V2 temp;Elim temp;Clear temp. Intros incl_empty_V1 imp. Apply dans_empty_imp_P with A. Apply imp. Apply inmonoid_cons_inv2 with v0;Assumption. Apply Regles_inv1 with X R1 (word u0); Assumption.*) (* Goal: inmonoid X w *) assumption. (* Goal: forall _ : dans (couple A (word u0)) R2, dans (couple A (word u0)) R2 *) (* Goal: or (dans (couple A (word u0)) R1) (dans (couple A (word u0)) R2) *) (* Goal: or (@eq Elt (couple S (word (cons S2 nil))) (couple A (word u0))) (dans (couple A (word u0)) (union R1 R2)) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple A (word u0))) (dans (couple A (word u0)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V2) u, Derive R2 u v) (_ : inmonoid (union X V2) (cons x u)), Derive R2 (cons x u) (cons x v) *) trivial. (* Goal: @eq Word (Append (cons S2 nil) nil) (cons S2 nil) *) (* Goal: Derivestar (add (couple S (word (cons S1 nil))) (add (couple S (word (cons S2 nil))) (union R1 R2))) (cons S2 nil) w *) (* Goal: inmonoid X w *) (****)auto. (* Goal: @eq Word (Append (cons S2 nil) nil) (cons S2 nil) *) (* Goal: Derivestar (add (couple S (word (cons S1 nil))) (add (couple S (word (cons S2 nil))) (union R1 R2))) (cons S2 nil) w *) (* Goal: inmonoid X w *) (***)auto. (* Goal: @eq Word (Append (cons S2 nil) nil) (cons S2 nil) *) (* Goal: Derivestar (add (couple S (word (cons S1 nil))) (add (couple S (word (cons S2 nil))) (union R1 R2))) (cons S2 nil) w *) (* Goal: inmonoid X w *) (**)auto. (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V2) u, Derive R2 u v) (_ : inmonoid (union X V2) (cons x u)), Derive R2 (cons x u) (cons x v) *) prolog [ inmonoid_cons_inv Derive2 ] 10. (*Intros u0 v0 x Der_Ru imp inmon_cons_x_u0. Apply Derive2. Apply imp. Apply inmonoid_cons_inv with x. Assumption.*) Qed. Lemma inmon_Der_imp_inmon_R2_d : forall u v : Word, Regles X V2 R2 -> Derive R2 u v -> inmonoid (union X V2) u -> inmonoid (union X V2) v. (* Goal: forall (u v : Word) (_ : Regles X V2 R2) (_ : Derive R2 u v) (_ : inmonoid (union X V2) u), inmonoid (union X V2) v *) prolog [ in_mon_X_Der_imp_inmon_X ] 10. (*Intros. Apply in_mon_X_Der_imp_inmon_X with R2 u;Assumption.*) Qed. Lemma inmon_Der_imp_inmon_d2 : ~ dans S X -> ~ dans S V1 -> ~ dans S V2 -> forall u v : Word, isGram X V1 R1 S1 -> isGram X V2 R2 S2 -> inter V1 V2 empty -> inmonoid (union X V2) u -> Derive Ru u v -> inmonoid (union X V2) v. prolog [ sym_inter isGram2 inter_union isGram4 inmon_Der_imp_Der_d2 inmon_Der_imp_inmon_R2_d ] 15. (*Intros N_dans_X N_dans_V1 N_dans_V2 u v G_R1 G_R2 inter_V1_V2_empty inmon_X_V2_u Der_Ru_u_v. Apply inmon_Der_imp_inmon_R2_d with u. Apply isGram4 with S2;Assumption. Apply inmon_Der_imp_Der_d2. Assumption. Assumption. Assumption. Apply isGram4 with S1;Assumption. Apply isGram4 with S2;Assumption. Apply inter_union. Apply isGram2 with R1 S1; Assumption. Apply sym_inter;Assumption. Assumption. Assumption. Assumption.*) Qed. Lemma Gunion_disj_Derivestar2 : ~ dans S X -> ~ dans S V1 -> ~ dans S V2 -> isGram X V1 R1 S1 -> isGram X V2 R2 S2 -> inter V1 V2 empty -> forall u v : Word, Derivestar Ru u v -> inmonoid (union X V2) u -> Derivestar R2 u v. (* Goal: forall (_ : not (dans S X)) (_ : not (dans S V1)) (_ : not (dans S V2)) (_ : isGram X V1 R1 S1) (_ : isGram X V2 R2 S2) (_ : inter V1 V2 empty) (u v : Word) (_ : Derivestar Ru u v) (_ : inmonoid (union X V2) u), Derivestar R2 u v *) unfold Derivestar in |- *. intros N_dans_X N_dans_V1 N_dans_V2 G_1 G_2 inter_V1_V2_empty u v Derivestar_Ru. (* Goal: forall _ : inmonoid (union X V2) u, Rstar Word (Derive R2) u v *) pattern u, v in |- *. (* Goal: (fun w w0 : Word => forall _ : inmonoid (union X V2) w, Rstar Word (Derive R2) w w0) u v *) apply Derivestar_Ru. (* Goal: @eq Word (Append (cons S2 nil) nil) (cons S2 nil) *) (* Goal: Derivestar (add (couple S (word (cons S1 nil))) (add (couple S (word (cons S2 nil))) (union R1 R2))) (cons S2 nil) w *) (* Goal: inmonoid X w *) auto. (* Goal: forall (u v w : Word) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V2) v, Rstar Word (Derive R2) v w) (_ : inmonoid (union X V2) u), Rstar Word (Derive R2) u w *) intros u0 v0 w Der_Ru inmon_v0_imp_Rstar_R2_v0 inmon_u0. (* Goal: Rstar Word (Derive R2) u0 w *) apply Rstar_R with v0. (* Goal: Derive R2 u0 v0 *) (* Goal: Rstar Word (Derive R2) v0 w *) prolog [ sym_inter isGram2 inter_union isGram4 inmon_Der_imp_Der_d2 ] 4. (*Apply inmon_Der_imp_Der_d2. Assumption. Assumption. Assumption. Apply isGram4 with S1;Assumption. Apply isGram4 with S2;Assumption. Apply inter_union. Apply isGram2 with R1 S1; Assumption. Apply sym_inter;Assumption. Assumption. Assumption.*) (* Goal: Rstar Word (Derive R2) v0 w *) prolog [ inmon_Der_imp_inmon_d2 ] 3. (*Apply inmon_v0_imp_Rstar_R2_v0. Apply inmon_Der_imp_inmon_d2 with u0;Assumption.*) Qed. Lemma Gunion_disj_Derive1 : ~ dans S X -> ~ dans S V1 -> ~ dans S V2 -> isGram X V1 R1 S1 -> isGram X V2 R2 S2 -> forall u : Word, Derive Ru (cons S nil) u -> cons S1 nil = u :>Word \/ cons S2 nil = u :>Word. (* Goal: forall (_ : not (dans S X)) (_ : not (dans S V1)) (_ : not (dans S V2)) (_ : isGram X V1 R1 S1) (_ : isGram X V2 R2 S2) (u : Word) (_ : Derive Ru (cons S nil) u), or (@eq Word (cons S1 nil) u) (@eq Word (cons S2 nil) u) *) intros N_dans_X N_dans_V1 N_dans_V2 G_1 G_2 u Derive_Ru. (* Goal: or (@eq Word (cons S1 nil) u) (@eq Word (cons S2 nil) u) *) cut (Derive_inv Ru (cons S nil) u). (* Goal: forall _ : Derive_inv Ru nil x, or (@eq Word (cons S1 nil) u) (@eq Word (cons S2 nil) u) *) (* Goal: Derive_inv Ru nil x *) (* Goal: Derive_inv Ru (cons S nil) u *) unfold Derive_inv in |- *. (* Goal: forall _ : False, or (@eq Word (cons S1 nil) u) (@eq Word (cons S2 nil) u) *) (* Goal: Derive_inv Ru nil x *) (* Goal: Derive_inv Ru (cons S nil) u *) simpl in |- *. (* Goal: forall _ : @ex2 Word (fun w : Word => Derive Ru (cons S nil) w) (fun w : Word => Derivestar Ru w u), or (@eq Word (cons S nil) u) (or (Derivestar R1 (cons S1 nil) u) (Derivestar R2 (cons S2 nil) u)) *) (* Goal: or (@eq Word (cons S nil) u) (@ex2 Word (fun w : Word => Derive Ru (cons S nil) w) (fun w : Word => Derivestar Ru w u)) *) intro temp; elim temp; clear temp; intro temp; elim temp; clear temp. (* Goal: forall (x : Word) (_ : dans (couple S (word x)) Ru) (_ : @ex2 Word (fun v : Word => @eq Word (cons S v) (cons S nil)) (fun v : Word => @eq Word (Append x v) u)), or (@eq Word (cons S1 nil) u) (@eq Word (cons S2 nil) u) *) (* Goal: forall (x : Word) (_ : Derive Ru nil x) (_ : @eq Word (cons S x) u), or (@eq Word (cons S1 nil) u) (@eq Word (cons S2 nil) u) *) (* Goal: Derive_inv Ru (cons S nil) u *) intros x dans_S_x_Ru temp. (* Goal: or (@eq Word (cons S1 nil) u) (@eq Word (cons S2 nil) u) *) (* Goal: forall (x : Word) (_ : Derive Ru nil x) (_ : @eq Word (cons S x) u), or (@eq Word (cons S1 nil) u) (@eq Word (cons S2 nil) u) *) (* Goal: Derive_inv Ru (cons S nil) u *) elim temp; clear temp. (* Goal: forall (x0 : Word) (_ : @eq Word (cons S x0) (cons S nil)) (_ : @eq Word (Append x x0) u), or (@eq Word (cons S1 nil) u) (@eq Word (cons S2 nil) u) *) (* Goal: forall (x : Word) (_ : Derive Ru nil x) (_ : @eq Word (cons S x) u), or (@eq Word (cons S1 nil) u) (@eq Word (cons S2 nil) u) *) (* Goal: Derive_inv Ru (cons S nil) u *) intros x0 egal_S_x0_S_nil egal_Append_x_x0_u. (* Goal: or (@eq Word (cons S1 nil) u) (@eq Word (cons S2 nil) u) *) (* Goal: forall (x : Word) (_ : Derive Ru nil x) (_ : @eq Word (cons S x) u), or (@eq Word (cons S1 nil) u) (@eq Word (cons S2 nil) u) *) (* Goal: Derive_inv Ru (cons S nil) u *) replace u with x. cut (couple S (word (cons S1 nil)) = couple S (word x) :>Elt \/ dans (couple S (word x)) (add (couple S (word (cons S2 nil))) (union R1 R2))). (**) (* Goal: forall _ : @ex2 Word (fun w : Word => Derive Ru (cons S nil) w) (fun w : Word => Derivestar Ru w u), or (@eq Word (cons S nil) u) (or (Derivestar R1 (cons S1 nil) u) (Derivestar R2 (cons S2 nil) u)) *) (* Goal: or (@eq Word (cons S nil) u) (@ex2 Word (fun w : Word => Derive Ru (cons S nil) w) (fun w : Word => Derivestar Ru w u)) *) intro temp; elim temp; clear temp. (* Goal: forall _ : @eq Elt (couple S (word (cons S2 nil))) (couple S (word x)), or (@eq Word (cons S1 nil) x) (@eq Word (cons S2 nil) x) *) (* Goal: forall _ : dans (couple S (word x)) (union R1 R2), or (@eq Word (cons S1 nil) x) (@eq Word (cons S2 nil) x) *) (* Goal: or (@eq Elt (couple S (word (cons S2 nil))) (couple S (word x))) (dans (couple S (word x)) (union R1 R2)) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple S (word x))) (dans (couple S (word x)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: @eq Word x u *) (* Goal: forall (x : Word) (_ : Derive Ru nil x) (_ : @eq Word (cons S x) u), or (@eq Word (cons S1 nil) u) (@eq Word (cons S2 nil) u) *) (* Goal: Derive_inv Ru (cons S nil) u *) intro egal_S. (* Goal: @eq Word (Append (cons S2 nil) nil) (cons S2 nil) *) (* Goal: Derivestar (add (couple S (word (cons S1 nil))) (add (couple S (word (cons S2 nil))) (union R1 R2))) (cons S2 nil) w *) (* Goal: inmonoid X w *) injection egal_S; auto. (* Goal: forall _ : dans (couple S (word x)) (add (couple S (word (cons S2 nil))) (union R1 R2)), or (@eq Word (cons S1 nil) x) (@eq Word (cons S2 nil) x) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple S (word x))) (dans (couple S (word x)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: @eq Word x u *) (* Goal: forall (x : Word) (_ : Derive Ru nil x) (_ : @eq Word (cons S x) u), or (@eq Word (cons S1 nil) u) (@eq Word (cons S2 nil) u) *) (* Goal: Derive_inv Ru (cons S nil) u *) intro dans_couple_add. cut (couple S (word (cons S2 nil)) = couple S (word x) :>Elt \/ dans (couple S (word x)) (union R1 R2)). (***) (* Goal: forall _ : @ex2 Word (fun w : Word => Derive Ru (cons S nil) w) (fun w : Word => Derivestar Ru w u), or (@eq Word (cons S nil) u) (or (Derivestar R1 (cons S1 nil) u) (Derivestar R2 (cons S2 nil) u)) *) (* Goal: or (@eq Word (cons S nil) u) (@ex2 Word (fun w : Word => Derive Ru (cons S nil) w) (fun w : Word => Derivestar Ru w u)) *) intro temp; elim temp; clear temp. (* Goal: forall _ : @eq Elt (couple S (word (cons S2 nil))) (couple S (word x)), or (@eq Word (cons S1 nil) x) (@eq Word (cons S2 nil) x) *) (* Goal: forall _ : dans (couple S (word x)) (union R1 R2), or (@eq Word (cons S1 nil) x) (@eq Word (cons S2 nil) x) *) (* Goal: or (@eq Elt (couple S (word (cons S2 nil))) (couple S (word x))) (dans (couple S (word x)) (union R1 R2)) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple S (word x))) (dans (couple S (word x)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: @eq Word x u *) (* Goal: forall (x : Word) (_ : Derive Ru nil x) (_ : @eq Word (cons S x) u), or (@eq Word (cons S1 nil) u) (@eq Word (cons S2 nil) u) *) (* Goal: Derive_inv Ru (cons S nil) u *) intro egal_S. (* Goal: @eq Word (Append (cons S2 nil) nil) (cons S2 nil) *) (* Goal: Derivestar (add (couple S (word (cons S1 nil))) (add (couple S (word (cons S2 nil))) (union R1 R2))) (cons S2 nil) w *) (* Goal: inmonoid X w *) injection egal_S; auto. (* Goal: forall _ : dans (couple S (word x)) (union R1 R2), or (@eq Word (cons S1 nil) x) (@eq Word (cons S2 nil) x) *) (* Goal: or (@eq Elt (couple S (word (cons S2 nil))) (couple S (word x))) (dans (couple S (word x)) (union R1 R2)) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple S (word x))) (dans (couple S (word x)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: @eq Word x u *) (* Goal: forall (x : Word) (_ : Derive Ru nil x) (_ : @eq Word (cons S x) u), or (@eq Word (cons S1 nil) u) (@eq Word (cons S2 nil) u) *) (* Goal: Derive_inv Ru (cons S nil) u *) intro dans_couple_union. (* Goal: or (@eq Word (cons S1 nil) x) (@eq Word (cons S2 nil) x) *) (* Goal: or (@eq Elt (couple S (word (cons S2 nil))) (couple S (word x))) (dans (couple S (word x)) (union R1 R2)) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple S (word x))) (dans (couple S (word x)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: @eq Word x u *) (* Goal: forall (x : Word) (_ : Derive Ru nil x) (_ : @eq Word (cons S x) u), or (@eq Word (cons S1 nil) u) (@eq Word (cons S2 nil) u) *) (* Goal: Derive_inv Ru (cons S nil) u *) cut (dans (couple S (word x)) R1 \/ dans (couple S (word x)) R2). (****) (* Goal: forall _ : @ex2 Word (fun w : Word => Derive Ru (cons S nil) w) (fun w : Word => Derivestar Ru w u), or (@eq Word (cons S nil) u) (or (Derivestar R1 (cons S1 nil) u) (Derivestar R2 (cons S2 nil) u)) *) (* Goal: or (@eq Word (cons S nil) u) (@ex2 Word (fun w : Word => Derive Ru (cons S nil) w) (fun w : Word => Derivestar Ru w u)) *) intro temp; elim temp; clear temp. (* Goal: forall _ : dans (couple S (word x)) R1, or (@eq Word (cons S1 nil) x) (@eq Word (cons S2 nil) x) *) (* Goal: forall _ : dans (couple S (word x)) R2, or (@eq Word (cons S1 nil) x) (@eq Word (cons S2 nil) x) *) (* Goal: or (dans (couple S (word x)) R1) (dans (couple S (word x)) R2) *) (* Goal: or (@eq Elt (couple S (word (cons S2 nil))) (couple S (word x))) (dans (couple S (word x)) (union R1 R2)) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple S (word x))) (dans (couple S (word x)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: @eq Word x u *) (* Goal: forall (x : Word) (_ : Derive Ru nil x) (_ : @eq Word (cons S x) u), or (@eq Word (cons S1 nil) u) (@eq Word (cons S2 nil) u) *) (* Goal: Derive_inv Ru (cons S nil) u *) intro dans_R1. (* Goal: or (@eq Word (cons S1 nil) x) (@eq Word (cons S2 nil) x) *) (* Goal: forall _ : dans (couple S (word x)) R2, or (@eq Word (cons S1 nil) x) (@eq Word (cons S2 nil) x) *) (* Goal: or (dans (couple S (word x)) R1) (dans (couple S (word x)) R2) *) (* Goal: or (@eq Elt (couple S (word (cons S2 nil))) (couple S (word x))) (dans (couple S (word x)) (union R1 R2)) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple S (word x))) (dans (couple S (word x)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: @eq Word x u *) (* Goal: forall (x : Word) (_ : Derive Ru nil x) (_ : @eq Word (cons S x) u), or (@eq Word (cons S1 nil) u) (@eq Word (cons S2 nil) u) *) (* Goal: Derive_inv Ru (cons S nil) u *) absurd (dans S V1). (* Goal: inmonoid X w *) assumption. (* Goal: dans S V2 *) (* Goal: or (dans (couple S (word x)) R1) (dans (couple S (word x)) R2) *) (* Goal: or (@eq Elt (couple S (word (cons S2 nil))) (couple S (word x))) (dans (couple S (word x)) (union R1 R2)) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple S (word x))) (dans (couple S (word x)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: @eq Word x u *) (* Goal: forall (x : Word) (_ : Derive Ru nil x) (_ : @eq Word (cons S x) u), or (@eq Word (cons S1 nil) u) (@eq Word (cons S2 nil) u) *) (* Goal: Derive_inv Ru (cons S nil) u *) prolog [ isGram4 Regles_inv1 ] 3. (*Apply Regles_inv1 with X R1 (word x) . Apply isGram4 with S1;Assumption. Assumption.*) (* Goal: forall _ : dans (couple S (word x)) R2, or (@eq Word (cons S1 nil) x) (@eq Word (cons S2 nil) x) *) (* Goal: or (dans (couple S (word x)) R1) (dans (couple S (word x)) R2) *) (* Goal: or (@eq Elt (couple S (word (cons S2 nil))) (couple S (word x))) (dans (couple S (word x)) (union R1 R2)) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple S (word x))) (dans (couple S (word x)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: @eq Word x u *) (* Goal: forall (x : Word) (_ : Derive Ru nil x) (_ : @eq Word (cons S x) u), or (@eq Word (cons S1 nil) u) (@eq Word (cons S2 nil) u) *) (* Goal: Derive_inv Ru (cons S nil) u *) intros dans_R2. (* Goal: or (@eq Word (cons S1 nil) x) (@eq Word (cons S2 nil) x) *) (* Goal: or (dans (couple S (word x)) R1) (dans (couple S (word x)) R2) *) (* Goal: or (@eq Elt (couple S (word (cons S2 nil))) (couple S (word x))) (dans (couple S (word x)) (union R1 R2)) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple S (word x))) (dans (couple S (word x)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: @eq Word x u *) (* Goal: forall (x : Word) (_ : Derive Ru nil x) (_ : @eq Word (cons S x) u), or (@eq Word (cons S1 nil) u) (@eq Word (cons S2 nil) u) *) (* Goal: Derive_inv Ru (cons S nil) u *) absurd (dans S V2). (* Goal: inmonoid X w *) assumption. (* Goal: dans S V2 *) (* Goal: or (dans (couple S (word x)) R1) (dans (couple S (word x)) R2) *) (* Goal: or (@eq Elt (couple S (word (cons S2 nil))) (couple S (word x))) (dans (couple S (word x)) (union R1 R2)) *) (* Goal: or (@eq Elt (couple S (word (cons S1 nil))) (couple S (word x))) (dans (couple S (word x)) (add (couple S (word (cons S2 nil))) (union R1 R2))) *) (* Goal: @eq Word x u *) (* Goal: forall (x : Word) (_ : Derive Ru nil x) (_ : @eq Word (cons S x) u), or (@eq Word (cons S1 nil) u) (@eq Word (cons S2 nil) u) *) (* Goal: Derive_inv Ru (cons S nil) u *) prolog [ isGram4 Regles_inv1 ] 3. (*Apply Regles_inv1 with X R2 (word x) . Apply isGram4 with S2;Assumption. Assumption.*) (* Goal: @eq Word (Append (cons S2 nil) nil) (cons S2 nil) *) (* Goal: Derivestar (add (couple S (word (cons S1 nil))) (add (couple S (word (cons S2 nil))) (union R1 R2))) (cons S2 nil) w *) (* Goal: inmonoid X w *) (****)auto. (* Goal: @eq Word (Append (cons S2 nil) nil) (cons S2 nil) *) (* Goal: Derivestar (add (couple S (word (cons S1 nil))) (add (couple S (word (cons S2 nil))) (union R1 R2))) (cons S2 nil) w *) (* Goal: inmonoid X w *) (***)auto. (* Goal: @eq Word (Append (cons S2 nil) nil) (cons S2 nil) *) (* Goal: Derivestar (add (couple S (word (cons S1 nil))) (add (couple S (word (cons S2 nil))) (union R1 R2))) (cons S2 nil) w *) (* Goal: inmonoid X w *) (**)auto. (* Goal: @eq Word x u *) (* Goal: forall (x : Word) (_ : Derive Ru nil x) (_ : @eq Word (cons S x) u), or (@eq Word (cons S1 nil) u) (@eq Word (cons S2 nil) u) *) (* Goal: Derive_inv Ru (cons S nil) u *) replace x with (Append x nil). (* Goal: @eq Word (Append x nil) u *) (* Goal: @eq Word (Append x nil) x *) (* Goal: forall (x : Word) (_ : Derive Ru nil x) (_ : @eq Word (cons S x) u), or (@eq Word (cons S1 nil) u) (@eq Word (cons S2 nil) u) *) (* Goal: Derive_inv Ru (cons S nil) u *) replace nil with x0. (* Goal: inmonoid X w *) assumption. (* Goal: inmonoid X w *) apply cons_cons_inv2 with S S; assumption. (* Goal: @eq Word (Append x nil) x *) (* Goal: forall (x : Word) (_ : Derive Ru nil x) (_ : @eq Word (cons S x) u), or (@eq Word (cons S1 nil) u) (@eq Word (cons S2 nil) u) *) (* Goal: Derive_inv Ru (cons S nil) u *) apply Append_w_nil. (* Goal: forall (_ : not (dans S X)) (_ : not (dans S V1)) (_ : not (dans S V2)) (_ : isGram X V1 R1 S1) (_ : isGram X V2 R2 S2) (_ : inter V1 V2 empty), l_egal (LG X Vu Ru S) (lunion (LG X V1 R1 S1) (LG X V2 R2 S2)) *) intros. (* Goal: or (@eq Word (cons S1 nil) u) (@eq Word (cons S2 nil) u) *) (* Goal: Derive_inv Ru (cons S nil) u *) cut (Derive_inv Ru nil x). (* Goal: forall _ : Derive_inv Ru nil x, or (@eq Word (cons S1 nil) u) (@eq Word (cons S2 nil) u) *) (* Goal: Derive_inv Ru nil x *) (* Goal: Derive_inv Ru (cons S nil) u *) unfold Derive_inv in |- *. (* Goal: forall _ : False, or (@eq Word (cons S1 nil) u) (@eq Word (cons S2 nil) u) *) (* Goal: Derive_inv Ru nil x *) (* Goal: Derive_inv Ru (cons S nil) u *) simpl in |- *. (* Goal: @eq Word (Append (cons S2 nil) nil) (cons S2 nil) *) (* Goal: Derivestar (add (couple S (word (cons S1 nil))) (add (couple S (word (cons S2 nil))) (union R1 R2))) (cons S2 nil) w *) (* Goal: inmonoid X w *) tauto. (* Goal: @eq Word (Append (cons S2 nil) nil) (cons S2 nil) *) (* Goal: Derivestar (add (couple S (word (cons S1 nil))) (add (couple S (word (cons S2 nil))) (union R1 R2))) (cons S2 nil) w *) (* Goal: inmonoid X w *) auto. (* Goal: @eq Word (Append (cons S2 nil) nil) (cons S2 nil) *) (* Goal: Derivestar (add (couple S (word (cons S1 nil))) (add (couple S (word (cons S2 nil))) (union R1 R2))) (cons S2 nil) w *) (* Goal: inmonoid X w *) auto. Qed. Hint Resolve Gunion_disj_Derive1. Lemma Gunion_disj_Derivestar_S : ~ dans S X -> ~ dans S V1 -> ~ dans S V2 -> isGram X V1 R1 S1 -> isGram X V2 R2 S2 -> inter V1 V2 empty -> forall u : Word, Derivestar Ru (cons S nil) u -> cons S nil = u :>Word \/ Derivestar R1 (cons S1 nil) u \/ Derivestar R2 (cons S2 nil) u. (* Goal: forall (_ : not (dans S X)) (_ : not (dans S V1)) (_ : not (dans S V2)) (_ : isGram X V1 R1 S1) (_ : isGram X V2 R2 S2) (_ : inter V1 V2 empty) (u : Word) (_ : Derivestar Ru (cons S nil) u), or (@eq Word (cons S nil) u) (or (Derivestar R1 (cons S1 nil) u) (Derivestar R2 (cons S2 nil) u)) *) intros N_dans_X N_dans_V1 N_dans_V2 G_1 G_2 inter_V1_V2_empty u Derivestar_Ru. cut (cons S nil = u :>Word \/ (exists2 w : Word, Derive Ru (cons S nil) w & Derivestar Ru w u)). (**) (* Goal: forall _ : @ex2 Word (fun w : Word => Derive Ru (cons S nil) w) (fun w : Word => Derivestar Ru w u), or (@eq Word (cons S nil) u) (or (Derivestar R1 (cons S1 nil) u) (Derivestar R2 (cons S2 nil) u)) *) (* Goal: or (@eq Word (cons S nil) u) (@ex2 Word (fun w : Word => Derive Ru (cons S nil) w) (fun w : Word => Derivestar Ru w u)) *) intro temp; elim temp; clear temp. (* Goal: @eq Word (Append (cons S2 nil) nil) (cons S2 nil) *) (* Goal: Derivestar (add (couple S (word (cons S1 nil))) (add (couple S (word (cons S2 nil))) (union R1 R2))) (cons S2 nil) w *) (* Goal: inmonoid X w *) auto. (* Goal: forall _ : @ex2 Word (fun w : Word => Derive Ru (cons S nil) w) (fun w : Word => Derivestar Ru w u), or (@eq Word (cons S nil) u) (or (Derivestar R1 (cons S1 nil) u) (Derivestar R2 (cons S2 nil) u)) *) (* Goal: or (@eq Word (cons S nil) u) (@ex2 Word (fun w : Word => Derive Ru (cons S nil) w) (fun w : Word => Derivestar Ru w u)) *) intro temp; elim temp; clear temp. (* Goal: forall (x : Word) (_ : Derive Ru (cons S nil) x) (_ : Derivestar Ru x u), or (@eq Word (cons S nil) u) (or (Derivestar R1 (cons S1 nil) u) (Derivestar R2 (cons S2 nil) u)) *) (* Goal: or (@eq Word (cons S nil) u) (@ex2 Word (fun w : Word => Derive Ru (cons S nil) w) (fun w : Word => Derivestar Ru w u)) *) intros x Der_Ru_cons_S_nil_x Derivestar_Ru_x_u. (* Goal: or (@eq Word (cons S nil) u) (or (Derivestar R1 (cons S1 nil) u) (Derivestar R2 (cons S2 nil) u)) *) (* Goal: or (@eq Word (cons S nil) u) (@ex2 Word (fun w : Word => Derive Ru (cons S nil) w) (fun w : Word => Derivestar Ru w u)) *) right. (* Goal: or (Derivestar R1 (cons S1 nil) u) (Derivestar R2 (cons S2 nil) u) *) (* Goal: or (@eq Word (cons S nil) u) (@ex2 Word (fun w : Word => Derive Ru (cons S nil) w) (fun w : Word => Derivestar Ru w u)) *) cut (cons S1 nil = x :>Word \/ cons S2 nil = x :>Word). (***) (* Goal: forall _ : or (@eq Word (cons S1 nil) x) (@eq Word (cons S2 nil) x), or (Derivestar R1 (cons S1 nil) u) (Derivestar R2 (cons S2 nil) u) *) (* Goal: or (@eq Word (cons S1 nil) x) (@eq Word (cons S2 nil) x) *) (* Goal: or (@eq Word (cons S nil) u) (@ex2 Word (fun w : Word => Derive Ru (cons S nil) w) (fun w : Word => Derivestar Ru w u)) *) intro temp; elim temp; clear temp; intro x_egal; rewrite x_egal. (* Goal: or (Derivestar R1 x u) (Derivestar R2 (cons S2 nil) u) *) (* Goal: or (Derivestar R1 (cons S1 nil) u) (Derivestar R2 x u) *) (* Goal: or (@eq Word (cons S1 nil) x) (@eq Word (cons S2 nil) x) *) (* Goal: or (@eq Word (cons S nil) u) (@ex2 Word (fun w : Word => Derive Ru (cons S nil) w) (fun w : Word => Derivestar Ru w u)) *) apply or_introl. apply Gunion_disj_Derivestar; [ auto | auto | auto | auto | auto | auto | auto | idtac ]. (* Goal: inmonoid (union X V1) x *) (* Goal: or (Derivestar R1 (cons S1 nil) u) (Derivestar R2 x u) *) (* Goal: or (@eq Word (cons S1 nil) x) (@eq Word (cons S2 nil) x) *) (* Goal: or (@eq Word (cons S nil) u) (@ex2 Word (fun w : Word => Derive Ru (cons S nil) w) (fun w : Word => Derivestar Ru w u)) *) rewrite <- x_egal; cut (dans S1 V1). (* Goal: @eq Word (Append (cons S2 nil) nil) (cons S2 nil) *) (* Goal: Derivestar (add (couple S (word (cons S1 nil))) (add (couple S (word (cons S2 nil))) (union R1 R2))) (cons S2 nil) w *) (* Goal: inmonoid X w *) auto. (* Goal: dans S2 V2 *) (* Goal: or (@eq Word (cons S1 nil) x) (@eq Word (cons S2 nil) x) *) (* Goal: or (@eq Word (cons S nil) u) (@ex2 Word (fun w : Word => Derive Ru (cons S nil) w) (fun w : Word => Derivestar Ru w u)) *) prolog [ isGram3 ] 2. (*Apply isGram3 with X R1. Assumption.*) (* Goal: or (Derivestar R1 (cons S1 nil) u) (Derivestar R2 x u) *) (* Goal: or (@eq Word (cons S1 nil) x) (@eq Word (cons S2 nil) x) *) (* Goal: or (@eq Word (cons S nil) u) (@ex2 Word (fun w : Word => Derive Ru (cons S nil) w) (fun w : Word => Derivestar Ru w u)) *) apply or_intror. apply Gunion_disj_Derivestar2; [ auto | auto | auto | auto | auto | auto | auto | idtac ]. (* Goal: inmonoid (union X V2) x *) (* Goal: or (@eq Word (cons S1 nil) x) (@eq Word (cons S2 nil) x) *) (* Goal: or (@eq Word (cons S nil) u) (@ex2 Word (fun w : Word => Derive Ru (cons S nil) w) (fun w : Word => Derivestar Ru w u)) *) rewrite <- x_egal; cut (dans S2 V2). (* Goal: @eq Word (Append (cons S2 nil) nil) (cons S2 nil) *) (* Goal: Derivestar (add (couple S (word (cons S1 nil))) (add (couple S (word (cons S2 nil))) (union R1 R2))) (cons S2 nil) w *) (* Goal: inmonoid X w *) auto. (* Goal: dans S2 V2 *) (* Goal: or (@eq Word (cons S1 nil) x) (@eq Word (cons S2 nil) x) *) (* Goal: or (@eq Word (cons S nil) u) (@ex2 Word (fun w : Word => Derive Ru (cons S nil) w) (fun w : Word => Derivestar Ru w u)) *) prolog [ isGram3 ] 2. (*Apply isGram3 with X R2. Assumption.*) (* Goal: @eq Word (Append (cons S2 nil) nil) (cons S2 nil) *) (* Goal: Derivestar (add (couple S (word (cons S1 nil))) (add (couple S (word (cons S2 nil))) (union R1 R2))) (cons S2 nil) w *) (* Goal: inmonoid X w *) (***)auto. (* Goal: @eq Word (Append (cons S2 nil) nil) (cons S2 nil) *) (* Goal: Derivestar (add (couple S (word (cons S1 nil))) (add (couple S (word (cons S2 nil))) (union R1 R2))) (cons S2 nil) w *) (* Goal: inmonoid X w *) (**)auto. Qed. Hint Resolve Gunion_disj_Derivestar_S. Lemma Gunion_disj_LG_inclus1 : ~ dans S X -> ~ dans S V1 -> ~ dans S V2 -> isGram X V1 R1 S1 -> isGram X V2 R2 S2 -> inter V1 V2 empty -> l_inclus (LG X Vu Ru S) (lunion (LG X V1 R1 S1) (LG X V2 R2 S2)). (* Goal: forall (_ : not (dans S X)) (_ : not (dans S V1)) (_ : not (dans S V2)) (_ : isGram X V1 R1 S1) (_ : isGram X V2 R2 S2) (_ : inter V1 V2 empty), l_inclus (LG X Vu Ru S) (lunion (LG X V1 R1 S1) (LG X V2 R2 S2)) *) intros N_dans_X N_dans_V1 N_dans_V2 G_1 G_2 inter_V1_V2_empty. (* Goal: l_inclus (LG X V2 R2 S2) (LG X Vu Ru S) *) red in |- *. (* Goal: forall (w : Word) (_ : LG X V2 R2 S2 w), LG X Vu Ru S w *) unfold LG in |- *. (* Goal: forall (w : Word) (_ : and (Derivestar Ru (cons S nil) w) (inmonoid X w)), lunion (fun w0 : Word => and (Derivestar R1 (cons S1 nil) w0) (inmonoid X w0)) (fun w0 : Word => and (Derivestar R2 (cons S2 nil) w0) (inmonoid X w0)) w *) intros w temp; elim temp; clear temp; intros Der_Ru inmonoid_X_w. (* Goal: lunion (fun w : Word => and (Derivestar R1 (cons S1 nil) w) (inmonoid X w)) (fun w : Word => and (Derivestar R2 (cons S2 nil) w) (inmonoid X w)) w *) unfold lunion in |- *. elimtype (cons S nil = w :>Word \/ Derivestar R1 (cons S1 nil) w \/ Derivestar R2 (cons S2 nil) w). (**) (* Goal: forall _ : @eq Word (cons S nil) w, or (and (Derivestar R1 (cons S1 nil) w) (inmonoid X w)) (and (Derivestar R2 (cons S2 nil) w) (inmonoid X w)) *) (* Goal: forall _ : or (Derivestar R1 (cons S1 nil) w) (Derivestar R2 (cons S2 nil) w), or (and (Derivestar R1 (cons S1 nil) w) (inmonoid X w)) (and (Derivestar R2 (cons S2 nil) w) (inmonoid X w)) *) (* Goal: or (@eq Word (cons S nil) w) (or (Derivestar R1 (cons S1 nil) w) (Derivestar R2 (cons S2 nil) w)) *) intro eg_cons_S_nil_w. (* Goal: or (and (Derivestar R1 (cons S1 nil) w) (inmonoid X w)) (and (Derivestar R2 (cons S2 nil) w) (inmonoid X w)) *) (* Goal: forall _ : or (Derivestar R1 (cons S1 nil) w) (Derivestar R2 (cons S2 nil) w), or (and (Derivestar R1 (cons S1 nil) w) (inmonoid X w)) (and (Derivestar R2 (cons S2 nil) w) (inmonoid X w)) *) (* Goal: or (@eq Word (cons S nil) w) (or (Derivestar R1 (cons S1 nil) w) (Derivestar R2 (cons S2 nil) w)) *) absurd (dans S X). (* Goal: inmonoid X w *) assumption. (* Goal: dans S X *) (* Goal: forall _ : or (Derivestar R1 (cons S1 nil) w) (Derivestar R2 (cons S2 nil) w), or (and (Derivestar R1 (cons S1 nil) w) (inmonoid X w)) (and (Derivestar R2 (cons S2 nil) w) (inmonoid X w)) *) (* Goal: or (@eq Word (cons S nil) w) (or (Derivestar R1 (cons S1 nil) w) (Derivestar R2 (cons S2 nil) w)) *) apply inmonoid_cons_inv2 with nil. (* Goal: inmonoid X w *) rewrite eg_cons_S_nil_w; assumption. (* Goal: @eq Word (Append (cons S2 nil) nil) (cons S2 nil) *) (* Goal: Derivestar (add (couple S (word (cons S1 nil))) (add (couple S (word (cons S2 nil))) (union R1 R2))) (cons S2 nil) w *) (* Goal: inmonoid X w *) intro temp; elim temp; clear temp; auto. (* Goal: @eq Word (Append (cons S2 nil) nil) (cons S2 nil) *) (* Goal: Derivestar (add (couple S (word (cons S1 nil))) (add (couple S (word (cons S2 nil))) (union R1 R2))) (cons S2 nil) w *) (* Goal: inmonoid X w *) (**)auto. Qed. Lemma Gunion_disj_LG_inclus2 : l_inclus (LG X V1 R1 S1) (LG X Vu Ru S). (* Goal: l_inclus (LG X V2 R2 S2) (LG X Vu Ru S) *) red in |- *. (* Goal: forall (w : Word) (_ : LG X V2 R2 S2 w), LG X Vu Ru S w *) unfold LG in |- *. (* Goal: or (@eq Word (cons S1 nil) u) (@eq Word (cons S2 nil) u) *) (* Goal: forall (x : Word) (_ : Derive Ru nil x) (_ : @eq Word (cons S x) u), or (@eq Word (cons S1 nil) u) (@eq Word (cons S2 nil) u) *) (* Goal: Derive_inv Ru (cons S nil) u *) intros w temp; elim temp; clear temp. (* Goal: forall (_ : Derivestar R2 (cons S2 nil) w) (_ : inmonoid X w), and (Derivestar Ru (cons S nil) w) (inmonoid X w) *) intros Der_Ru inmonoid_X_w. (* Goal: forall _ : False, or (@eq Word (cons S1 nil) u) (@eq Word (cons S2 nil) u) *) (* Goal: Derive_inv Ru nil x *) (* Goal: Derive_inv Ru (cons S nil) u *) unfold Ru in |- *; simpl in |- *. (* Goal: and (Derivestar (add (couple S (word (cons S1 nil))) (add (couple S (word (cons S2 nil))) (union R1 R2))) (cons S nil) w) (inmonoid X w) *) split. (* Goal: Derivestar (add (couple S (word (cons S1 nil))) (add (couple S (word (cons S2 nil))) (union R1 R2))) (cons S nil) w *) (* Goal: inmonoid X w *) apply Derivestar_R with (cons S1 nil). (* Goal: Derive (add (couple S (word (cons S1 nil))) (add (couple S (word (cons S2 nil))) (union R1 R2))) (cons S nil) (cons S1 nil) *) (* Goal: Derivestar (add (couple S (word (cons S1 nil))) (add (couple S (word (cons S2 nil))) (union R1 R2))) (cons S1 nil) w *) (* Goal: inmonoid X w *) replace (cons S1 nil) with (Append (cons S1 nil) nil). (* Goal: @eq Word (Append (cons S2 nil) nil) (cons S2 nil) *) (* Goal: Derivestar (add (couple S (word (cons S1 nil))) (add (couple S (word (cons S2 nil))) (union R1 R2))) (cons S2 nil) w *) (* Goal: inmonoid X w *) auto. (* Goal: @eq Word (Append (cons S2 nil) nil) (cons S2 nil) *) (* Goal: Derivestar (add (couple S (word (cons S1 nil))) (add (couple S (word (cons S2 nil))) (union R1 R2))) (cons S2 nil) w *) (* Goal: inmonoid X w *) auto. (* Goal: @eq Word (Append (cons S2 nil) nil) (cons S2 nil) *) (* Goal: Derivestar (add (couple S (word (cons S1 nil))) (add (couple S (word (cons S2 nil))) (union R1 R2))) (cons S2 nil) w *) (* Goal: inmonoid X w *) apply Derivestar_inclus with R1; auto. (* Goal: inmonoid X w *) assumption. Qed. Lemma Gunion_disj_LG_inclus3 : l_inclus (LG X V2 R2 S2) (LG X Vu Ru S). (* Goal: l_inclus (LG X V2 R2 S2) (LG X Vu Ru S) *) red in |- *. (* Goal: forall (w : Word) (_ : LG X V2 R2 S2 w), LG X Vu Ru S w *) unfold LG in |- *. (* Goal: or (@eq Word (cons S1 nil) u) (@eq Word (cons S2 nil) u) *) (* Goal: forall (x : Word) (_ : Derive Ru nil x) (_ : @eq Word (cons S x) u), or (@eq Word (cons S1 nil) u) (@eq Word (cons S2 nil) u) *) (* Goal: Derive_inv Ru (cons S nil) u *) intros w temp; elim temp; clear temp. (* Goal: forall (_ : Derivestar R2 (cons S2 nil) w) (_ : inmonoid X w), and (Derivestar Ru (cons S nil) w) (inmonoid X w) *) intros Der_Ru inmonoid_X_w. (* Goal: forall _ : False, or (@eq Word (cons S1 nil) u) (@eq Word (cons S2 nil) u) *) (* Goal: Derive_inv Ru nil x *) (* Goal: Derive_inv Ru (cons S nil) u *) unfold Ru in |- *; simpl in |- *. (* Goal: and (Derivestar (add (couple S (word (cons S1 nil))) (add (couple S (word (cons S2 nil))) (union R1 R2))) (cons S nil) w) (inmonoid X w) *) split. (* Goal: Derivestar (add (couple S (word (cons S1 nil))) (add (couple S (word (cons S2 nil))) (union R1 R2))) (cons S nil) w *) (* Goal: inmonoid X w *) apply Derivestar_R with (cons S2 nil). (* Goal: Derive (add (couple S (word (cons S1 nil))) (add (couple S (word (cons S2 nil))) (union R1 R2))) (cons S nil) (cons S2 nil) *) (* Goal: Derivestar (add (couple S (word (cons S1 nil))) (add (couple S (word (cons S2 nil))) (union R1 R2))) (cons S2 nil) w *) (* Goal: inmonoid X w *) replace (cons S2 nil) with (Append (cons S2 nil) nil). (* Goal: @eq Word (Append (cons S2 nil) nil) (cons S2 nil) *) (* Goal: Derivestar (add (couple S (word (cons S1 nil))) (add (couple S (word (cons S2 nil))) (union R1 R2))) (cons S2 nil) w *) (* Goal: inmonoid X w *) auto. (* Goal: @eq Word (Append (cons S2 nil) nil) (cons S2 nil) *) (* Goal: Derivestar (add (couple S (word (cons S1 nil))) (add (couple S (word (cons S2 nil))) (union R1 R2))) (cons S2 nil) w *) (* Goal: inmonoid X w *) auto. (* Goal: @eq Word (Append (cons S2 nil) nil) (cons S2 nil) *) (* Goal: Derivestar (add (couple S (word (cons S1 nil))) (add (couple S (word (cons S2 nil))) (union R1 R2))) (cons S2 nil) w *) (* Goal: inmonoid X w *) apply Derivestar_inclus with R2; auto. (* Goal: inmonoid X w *) assumption. Qed. Lemma Gunion_disj_LG_inclus4 : l_inclus (lunion (LG X V1 R1 S1) (LG X V2 R2 S2)) (LG X Vu Ru S). (* Goal: l_inclus (lunion (LG X V1 R1 S1) (LG X V2 R2 S2)) (LG X Vu Ru S) *) unfold l_inclus, lunion in |- *. (* Goal: forall (w : Word) (_ : or (LG X V1 R1 S1 w) (LG X V2 R2 S2 w)), LG X Vu Ru S w *) intros w temp; elim temp; clear temp; intro LG_w. (* Goal: inmonoid X w *) apply Gunion_disj_LG_inclus2; assumption. (* Goal: inmonoid X w *) apply Gunion_disj_LG_inclus3; assumption. Qed. Lemma Gunion_disj_LG : ~ dans S X -> ~ dans S V1 -> ~ dans S V2 -> isGram X V1 R1 S1 -> isGram X V2 R2 S2 -> inter V1 V2 empty -> l_egal (LG X Vu Ru S) (lunion (LG X V1 R1 S1) (LG X V2 R2 S2)). (* Goal: forall (_ : not (dans S X)) (_ : not (dans S V1)) (_ : not (dans S V2)) (_ : isGram X V1 R1 S1) (_ : isGram X V2 R2 S2) (_ : inter V1 V2 empty), l_egal (LG X Vu Ru S) (lunion (LG X V1 R1 S1) (LG X V2 R2 S2)) *) intros. (* Goal: and (Derivestar (add (couple S (word (cons S1 nil))) (add (couple S (word (cons S2 nil))) (union R1 R2))) (cons S nil) w) (inmonoid X w) *) unfold l_egal in |- *; split. (* Goal: inmonoid X w *) apply Gunion_disj_LG_inclus1; assumption. (* Goal: l_inclus (lunion (LG X V1 R1 S1) (LG X V2 R2 S2)) (LG X Vu Ru S) *) exact Gunion_disj_LG_inclus4. Qed. End gram4.
(* This program is free software; you can redistribute it and/or *) (* modify it under the terms of the GNU Lesser General Public License *) (* as published by the Free Software Foundation; either version 2.1 *) (* of the License, or (at your option) any later version. *) (* *) (* This program is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* GNU General Public License for more details. *) (* *) (* You should have received a copy of the GNU Lesser General Public *) (* License along with this program; if not, write to the Free *) (* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *) (* 02110-1301 USA *) (* Contribution to the Coq Library V6.3 (July 1999) *) (****************************************************************************) (* The Calculus of Inductive Constructions *) (* *) (* Projet Coq *) (* *) (* INRIA ENS-CNRS *) (* Rocquencourt Lyon *) (* *) (* Coq V5.10 *) (* Nov 25th 1994 *) (* *) (****************************************************************************) (* gram5.v *) (****************************************************************************) (* Formal Language Theory *) (* *) (* Judicael Courant - Jean-Christophe Filliatre *) (* *) (* Developped in V5.8 June-July 1993 *) (* Ported to V5.10 October 1994 *) (****************************************************************************) Require Import Ensf. Require Import Words. Require Import more_words. Require Import Rat. Require Import need. Require Import fonctions. Require Import Relations. Require Import gram. Require Import gram2. Require Import gram3. Require Import gram4. Section gram5. Variable X : Ensf. Variable V1 R1 : Ensf. Variable S1 : Elt. Variable V2 R2 : Ensf. Variable S2 : Elt. Let S' := zero. Let G1 := imageGram (injproducg V1) X V1 R1 S1. Let G2 := imageGram (injproducd V2) X V2 R2 S2. Let X1' := fst G1. Let GG1 := snd G1. Let V1' := fst GG1. Let GGG1 := snd GG1. Let R1' := fst GGG1. Let S1' := snd GGG1. Let X2' := fst G2. Let GG2 := snd G2. Let V2' := fst GG2. Let GGG2 := snd GG2. Let R2' := fst GGG2. Let S2' := snd GGG2. Let Gim := Gunion_disj_p V1' R1' S1' V2' R2' S2' S'. Let Vu := fst Gim. Let C' := snd Gim. Let Ru := fst C'. Let Su := snd C'. Hypothesis Grammaire1 : isGram X V1 R1 S1. Hypothesis Grammaire2 : isGram X V2 R2 S2. Hint Resolve Grammaire1. Hint Resolve Grammaire2. Lemma Mots_X : Mots X. (* Goal: Mots X *) apply isGram1 with V1 R1 S1. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) auto. Qed. Hint Resolve Mots_X. Lemma int_X_V1_empty : inter X V1 empty. (* Goal: inter X V1 empty *) apply isGram2 with R1 S1. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) auto. Qed. Hint Resolve int_X_V1_empty. Lemma int_X_V2_empty : inter X V2 empty. (* Goal: inter X V2 empty *) apply isGram2 with R2 S2. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) auto. Qed. Hint Resolve int_X_V2_empty. Definition Gunion_disj := Gim. Let Vim := fst Gunion_disj. Let GGim := snd Gunion_disj. Let Rim := fst GGim. Let Sim := snd GGim. Lemma Id_injproducg1 : forall x : Elt, dans x X -> injproducg V1 x = x :>Elt. (* Goal: forall (x : Elt) (_ : dans x X), @eq Elt (injproducg V1 x) x *) unfold Id, injproducg in |- *. (* Goal: @eq Ensf (@fst Ensf (prod Ensf (prod Ensf Elt)) G2) X *) simpl in |- *. (* Goal: forall (x : Elt) (_ : dans x X), @eq Elt (extension V2 injdroite x) x *) intros x dans_x_X. (* Goal: @eq Elt (extension V2 injdroite x) x *) apply extension_out. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) apply inter_dans with X; auto. Qed. Hint Resolve Id_injproducg1. Lemma Id_injproducd2 : forall x : Elt, dans x X -> injproducd V2 x = x :>Elt. (* Goal: forall (x : Elt) (_ : dans x X), @eq Elt (injproducd V2 x) x *) unfold Id, injproducd in |- *. (* Goal: @eq Ensf (@fst Ensf (prod Ensf (prod Ensf Elt)) G2) X *) simpl in |- *. (* Goal: forall (x : Elt) (_ : dans x X), @eq Elt (extension V2 injdroite x) x *) intros x dans_x_X. (* Goal: @eq Elt (extension V2 injdroite x) x *) apply extension_out. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) apply inter_dans with X; auto. Qed. Hint Resolve Id_injproducd2. Lemma N_dans_S_X : ~ dans S' X. (* Goal: not (@eq Elt (natural O) (natural (S O))) *) (* Goal: @eq Elt zero un *) (* Goal: @ex Elt (fun y : Elt => and (dans y V2) (@eq Elt x (injdroite y))) *) (* Goal: @ex Elt (fun y : Elt => and (dans y V1) (@eq Elt x (injgauche y))) *) (* Goal: @eq Ensf (map injdroite V2) (map (injproducd V2) V2) *) (* Goal: @eq Ensf (map injgauche V1) (map (injproducg V1) V1) *) red in |- *. (* Goal: forall _ : dans S' X, False *) intro dans_S_X. (* Goal: False *) elimtype (exists w : Word, word w = S'). (* Goal: forall (x : Word) (_ : @eq Elt (word x) S'), False *) (* Goal: @ex Word (fun w : Word => @eq Elt (word w) S') *) intro x. (* Goal: forall _ : @eq Elt (word x) S', False *) (* Goal: @ex Word (fun w : Word => @eq Elt (word w) S') *) change (word x <> natural 0) in |- *. (* Goal: not (@eq Elt (word x0) (couple x un)) *) (* Goal: @eq Elt (word x0) (couple x un) *) (* Goal: @eq Elt y (injproducd V2 y) *) (* Goal: forall (_ : dans y V2) (_ : @eq Elt (injdroite x) (injproducd V2 y)), @eq Elt x y *) (* Goal: or (dans y X) (dans y V2) *) (* Goal: @eq Elt (injdroite x) (injproducd V2 x) *) (* Goal: or (dans x X) (dans x V2) *) discriminate. (* Goal: @ex Word (fun w : Word => @eq Elt (word w) S') *) apply Mots_X; assumption. Qed. Hint Resolve N_dans_S_X. Lemma injproducg_V1 : forall x : Elt, dans x V1 -> injproducg V1 x = injgauche x. (* Goal: forall (x : Elt) (_ : dans x V1), @eq Elt (injproducg V1 x) (injgauche x) *) intros x dans_x_V1. (* Goal: @eq Elt (injproducg V1 x) (injgauche x) *) unfold injproducg, extension in |- *. (* Goal: @eq Elt (let (y, _) := extension_spec V1 injgauche x in y) (injgauche x) *) elim (extension_spec V1 injgauche x). (* Goal: forall (x0 : Elt) (_ : or (and (dans x V2) (@eq Elt x0 (injdroite x))) (and (not (dans x V2)) (@eq Elt x0 x))), @eq Elt x0 (injdroite x) *) intros x0 temp; elim temp; clear temp; intro temp; elim temp; clear temp. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) auto. (* Goal: forall _ : @eq Elt (couple x un) (couple y un), @eq Elt x y *) (* Goal: @eq Elt (injdroite y) (injproducd V2 y) *) (* Goal: or (dans y X) (dans y V2) *) (* Goal: @eq Elt (injdroite x) (injproducd V2 x) *) (* Goal: or (dans x X) (dans x V2) *) intros. (* Goal: @eq Elt x0 (injgauche x) *) absurd (dans x V1); assumption. Qed. Hint Resolve injproducg_V1. Lemma map_injproducg_V1 : map (injproducg V1) V1 = map injgauche V1 :>Ensf. (* Goal: @eq Ensf (map (injproducd V2) V2) (map injdroite V2) *) apply map_egal. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) auto. Qed. Hint Resolve map_injproducg_V1. Lemma injproducd_V2 : forall x : Elt, dans x V2 -> injproducd V2 x = injdroite x. (* Goal: forall (x : Elt) (_ : dans x V2), @eq Elt (injproducd V2 x) (injdroite x) *) intros x dans_x_V2. (* Goal: @eq Elt (injproducd V2 x) (injdroite x) *) unfold injproducd, extension in |- *. (* Goal: @eq Elt (let (y, _) := extension_spec V2 injdroite x in y) (injdroite x) *) elim (extension_spec V2 injdroite x). (* Goal: forall (x0 : Elt) (_ : or (and (dans x V2) (@eq Elt x0 (injdroite x))) (and (not (dans x V2)) (@eq Elt x0 x))), @eq Elt x0 (injdroite x) *) intros x0 temp; elim temp; clear temp; intro temp; elim temp; clear temp. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) auto. (* Goal: forall _ : @eq Elt (couple x un) (couple y un), @eq Elt x y *) (* Goal: @eq Elt (injdroite y) (injproducd V2 y) *) (* Goal: or (dans y X) (dans y V2) *) (* Goal: @eq Elt (injdroite x) (injproducd V2 x) *) (* Goal: or (dans x X) (dans x V2) *) intros. (* Goal: @eq Elt x0 (injdroite x) *) absurd (dans x V2); assumption. Qed. Hint Resolve injproducd_V2. Lemma map_injproducd_V2 : map (injproducd V2) V2 = map injdroite V2 :>Ensf. (* Goal: @eq Ensf (map (injproducd V2) V2) (map injdroite V2) *) apply map_egal. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) auto. Qed. Hint Resolve map_injproducd_V2. Lemma N_dans_S_V1' : ~ dans S' V1'. (* Goal: not (@eq Elt (natural O) (natural (S O))) *) (* Goal: @eq Elt zero un *) (* Goal: @ex Elt (fun y : Elt => and (dans y V2) (@eq Elt x (injdroite y))) *) (* Goal: @ex Elt (fun y : Elt => and (dans y V1) (@eq Elt x (injgauche y))) *) (* Goal: @eq Ensf (map injdroite V2) (map (injproducd V2) V2) *) (* Goal: @eq Ensf (map injgauche V1) (map (injproducg V1) V1) *) red in |- *. (* Goal: forall _ : dans S' V1', False *) replace V1' with (map injgauche V1). (* Goal: forall _ : @eq Elt (couple x un) (couple y un), @eq Elt x y *) (* Goal: @eq Elt (injdroite y) (injproducd V2 y) *) (* Goal: or (dans y X) (dans y V2) *) (* Goal: @eq Elt (injdroite x) (injproducd V2 x) *) (* Goal: or (dans x X) (dans x V2) *) intros. (* Goal: False *) (* Goal: @eq Ensf (map injgauche V1) V1' *) elimtype (exists y : Elt, dans y V1 /\ S' = (fun e : Elt => couple e zero) y). (* Goal: forall (x : Elt) (_ : and (dans x V2) (@eq Elt S' (couple x un))), False *) (* Goal: @ex Elt (fun y : Elt => and (dans y V2) (@eq Elt S' (couple y un))) *) (* Goal: @eq Ensf (map injdroite V2) V2' *) intros x temp; elim temp; clear temp. (* Goal: forall (_ : dans x V1) (_ : @eq Elt S' (couple x zero)), False *) (* Goal: @ex Elt (fun y : Elt => and (dans y V1) (@eq Elt S' (couple y zero))) *) (* Goal: @eq Ensf (map injgauche V1) V1' *) intros dans_x_V1 S_egal. (* Goal: False *) (* Goal: @ex Elt (fun y : Elt => and (dans y V1) (@eq Elt S' (couple y zero))) *) (* Goal: @eq Ensf (map injgauche V1) V1' *) absurd (S' = couple x zero). (* Goal: not (@eq Elt S' (couple x un)) *) (* Goal: @eq Elt S' (couple x un) *) (* Goal: @ex Elt (fun y : Elt => and (dans y V2) (@eq Elt S' (couple y un))) *) (* Goal: @eq Ensf (map injdroite V2) V2' *) unfold S', zero in |- *. (* Goal: not (@eq Elt (word x0) (couple x un)) *) (* Goal: @eq Elt (word x0) (couple x un) *) (* Goal: @eq Elt y (injproducd V2 y) *) (* Goal: forall (_ : dans y V2) (_ : @eq Elt (injdroite x) (injproducd V2 y)), @eq Elt x y *) (* Goal: or (dans y X) (dans y V2) *) (* Goal: @eq Elt (injdroite x) (injproducd V2 x) *) (* Goal: or (dans x X) (dans x V2) *) discriminate. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) auto. (* Goal: @ex Elt (fun y : Elt => and (dans y V1) (@eq Elt S' (couple y zero))) *) (* Goal: @eq Ensf (map injgauche V1) V1' *) apply (dans_map (fun e : Elt => couple e zero)). (* Goal: dans S' (map (fun e : Elt => couple e un) V2) *) (* Goal: @eq Ensf (map injdroite V2) V2' *) assumption. (* Goal: @eq Ensf (map injgauche V1) V1' *) unfold V1' in |- *. (* Goal: @eq Ensf (@fst Ensf (prod Ensf (prod Ensf Elt)) G2) X *) simpl in |- *. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) auto. Qed. Hint Resolve N_dans_S_V1'. Lemma N_dans_S_V2' : ~ dans S' V2'. (* Goal: not (@eq Elt (natural O) (natural (S O))) *) (* Goal: @eq Elt zero un *) (* Goal: @ex Elt (fun y : Elt => and (dans y V2) (@eq Elt x (injdroite y))) *) (* Goal: @ex Elt (fun y : Elt => and (dans y V1) (@eq Elt x (injgauche y))) *) (* Goal: @eq Ensf (map injdroite V2) (map (injproducd V2) V2) *) (* Goal: @eq Ensf (map injgauche V1) (map (injproducg V1) V1) *) red in |- *. (* Goal: forall _ : dans S' V2', False *) replace V2' with (map injdroite V2). (* Goal: forall _ : @eq Elt (injdroite x) (injdroite y), @eq Elt x y *) (* Goal: @eq Elt (injdroite y) (injproducd V2 y) *) (* Goal: or (dans y X) (dans y V2) *) (* Goal: @eq Elt (injdroite x) (injproducd V2 x) *) (* Goal: or (dans x X) (dans x V2) *) unfold injdroite in |- *. (* Goal: forall _ : @eq Elt (couple x un) (couple y un), @eq Elt x y *) (* Goal: @eq Elt (injdroite y) (injproducd V2 y) *) (* Goal: or (dans y X) (dans y V2) *) (* Goal: @eq Elt (injdroite x) (injproducd V2 x) *) (* Goal: or (dans x X) (dans x V2) *) intros. (* Goal: False *) (* Goal: @eq Ensf (map injdroite V2) V2' *) elimtype (exists y : Elt, dans y V2 /\ S' = (fun e : Elt => couple e un) y). (* Goal: forall (x : Elt) (_ : and (dans x V2) (@eq Elt S' (couple x un))), False *) (* Goal: @ex Elt (fun y : Elt => and (dans y V2) (@eq Elt S' (couple y un))) *) (* Goal: @eq Ensf (map injdroite V2) V2' *) intros x temp; elim temp; clear temp. (* Goal: forall (_ : dans x V2) (_ : @eq Elt S' (couple x un)), False *) (* Goal: @ex Elt (fun y : Elt => and (dans y V2) (@eq Elt S' (couple y un))) *) (* Goal: @eq Ensf (map injdroite V2) V2' *) intros dans_x_V2 S_egal. (* Goal: False *) (* Goal: @ex Elt (fun y : Elt => and (dans y V2) (@eq Elt S' (couple y un))) *) (* Goal: @eq Ensf (map injdroite V2) V2' *) absurd (S' = couple x un). (* Goal: not (@eq Elt S' (couple x un)) *) (* Goal: @eq Elt S' (couple x un) *) (* Goal: @ex Elt (fun y : Elt => and (dans y V2) (@eq Elt S' (couple y un))) *) (* Goal: @eq Ensf (map injdroite V2) V2' *) unfold S', zero in |- *. (* Goal: not (@eq Elt (word x0) (couple x un)) *) (* Goal: @eq Elt (word x0) (couple x un) *) (* Goal: @eq Elt y (injproducd V2 y) *) (* Goal: forall (_ : dans y V2) (_ : @eq Elt (injdroite x) (injproducd V2 y)), @eq Elt x y *) (* Goal: or (dans y X) (dans y V2) *) (* Goal: @eq Elt (injdroite x) (injproducd V2 x) *) (* Goal: or (dans x X) (dans x V2) *) discriminate. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) auto. (* Goal: @ex Elt (fun y : Elt => and (dans y V2) (@eq Elt S' (couple y un))) *) (* Goal: @eq Ensf (map injdroite V2) V2' *) apply (dans_map (fun e : Elt => couple e un)). (* Goal: dans S' (map (fun e : Elt => couple e un) V2) *) (* Goal: @eq Ensf (map injdroite V2) V2' *) assumption. (* Goal: @eq Ensf (map injdroite V2) V2' *) unfold V2' in |- *. (* Goal: @eq Ensf (@fst Ensf (prod Ensf (prod Ensf Elt)) G2) X *) simpl in |- *. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) auto. Qed. Hint Resolve N_dans_S_V2'. Lemma is_mono_u_X_V1_injproducg_V1 : is_mono (union X V1) (injproducg V1). (* Goal: is_mono (union X V2) (injproducd V2) *) unfold is_mono in |- *. (* Goal: forall (x y : Elt) (_ : dans x (union X V2)) (_ : dans y (union X V2)) (_ : @eq Elt (injproducd V2 x) (injproducd V2 y)), @eq Elt x y *) intros x y dans_x_u dans_y_u. (* Goal: forall _ : @eq Elt (injproducg V1 x) (injproducg V1 y), @eq Elt x y *) elimtype (dans x X \/ dans x V1). (* Goal: forall (_ : dans x V2) (_ : @eq Elt (injproducd V2 x) (injproducd V2 y)), @eq Elt x y *) (* Goal: or (dans x X) (dans x V2) *) intro dans_x. (* Goal: forall _ : @eq Elt (injproducg V1 x) (injproducg V1 y), @eq Elt x y *) (* Goal: forall (_ : dans x V1) (_ : @eq Elt (injproducg V1 x) (injproducg V1 y)), @eq Elt x y *) (* Goal: or (dans x X) (dans x V1) *) replace (injproducg V1 x) with x. (* Goal: forall _ : @eq Elt (injgauche x) (injproducg V1 y), @eq Elt x y *) (* Goal: @eq Elt (injgauche x) (injproducg V1 x) *) (* Goal: or (dans x X) (dans x V1) *) elimtype (dans y X \/ dans y V1). (* Goal: forall (_ : dans y X) (_ : @eq Elt (injdroite x) (injproducd V2 y)), @eq Elt x y *) (* Goal: forall (_ : dans y V2) (_ : @eq Elt (injdroite x) (injproducd V2 y)), @eq Elt x y *) (* Goal: or (dans y X) (dans y V2) *) (* Goal: @eq Elt (injdroite x) (injproducd V2 x) *) (* Goal: or (dans x X) (dans x V2) *) intros dans_y. (* Goal: forall _ : @eq Elt (injgauche x) (injproducg V1 y), @eq Elt x y *) (* Goal: forall (_ : dans y V1) (_ : @eq Elt (injgauche x) (injproducg V1 y)), @eq Elt x y *) (* Goal: or (dans y X) (dans y V1) *) (* Goal: @eq Elt (injgauche x) (injproducg V1 x) *) (* Goal: or (dans x X) (dans x V1) *) replace (injproducg V1 y) with y. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) auto. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) apply sym_equal; auto. (* Goal: forall (_ : dans y X) (_ : @eq Elt (injdroite x) (injproducd V2 y)), @eq Elt x y *) (* Goal: forall (_ : dans y V2) (_ : @eq Elt (injdroite x) (injproducd V2 y)), @eq Elt x y *) (* Goal: or (dans y X) (dans y V2) *) (* Goal: @eq Elt (injdroite x) (injproducd V2 x) *) (* Goal: or (dans x X) (dans x V2) *) intros dans_y. (* Goal: forall _ : @eq Elt (injgauche x) (injproducg V1 y), @eq Elt x y *) (* Goal: or (dans y X) (dans y V1) *) (* Goal: @eq Elt (injgauche x) (injproducg V1 x) *) (* Goal: or (dans x X) (dans x V1) *) replace (injproducg V1 y) with (injgauche y). (* Goal: forall _ : @eq Elt (injgauche x) (injgauche y), @eq Elt x y *) (* Goal: @eq Elt (injgauche y) (injproducg V1 y) *) (* Goal: or (dans y X) (dans y V1) *) (* Goal: @eq Elt (injgauche x) (injproducg V1 x) *) (* Goal: or (dans x X) (dans x V1) *) unfold injgauche in |- *. (* Goal: forall _ : @eq Elt x (couple y un), @eq Elt x y *) (* Goal: @eq Elt (injdroite y) (injproducd V2 y) *) (* Goal: or (dans y X) (dans y V2) *) (* Goal: @eq Elt x (injproducd V2 x) *) (* Goal: forall (_ : dans x V2) (_ : @eq Elt (injproducd V2 x) (injproducd V2 y)), @eq Elt x y *) (* Goal: or (dans x X) (dans x V2) *) elim (Mots_X x dans_x). (* Goal: forall (x0 : Word) (_ : @eq Elt (word x0) x) (_ : @eq Elt x (couple y un)), @eq Elt x y *) (* Goal: @eq Elt (injdroite y) (injproducd V2 y) *) (* Goal: or (dans y X) (dans y V2) *) (* Goal: @eq Elt x (injproducd V2 x) *) (* Goal: forall (_ : dans x V2) (_ : @eq Elt (injproducd V2 x) (injproducd V2 y)), @eq Elt x y *) (* Goal: or (dans x X) (dans x V2) *) intros x0 egal_x egal2_x. (* Goal: @eq Elt x y *) (* Goal: @eq Elt (injgauche y) (injproducg V1 y) *) (* Goal: or (dans y X) (dans y V1) *) (* Goal: @eq Elt x (injproducg V1 x) *) (* Goal: forall (_ : dans x V1) (_ : @eq Elt (injproducg V1 x) (injproducg V1 y)), @eq Elt x y *) (* Goal: or (dans x X) (dans x V1) *) absurd (word x0 = couple y zero). (* Goal: not (@eq Elt (word x0) (couple x un)) *) (* Goal: @eq Elt (word x0) (couple x un) *) (* Goal: @eq Elt y (injproducd V2 y) *) (* Goal: forall (_ : dans y V2) (_ : @eq Elt (injdroite x) (injproducd V2 y)), @eq Elt x y *) (* Goal: or (dans y X) (dans y V2) *) (* Goal: @eq Elt (injdroite x) (injproducd V2 x) *) (* Goal: or (dans x X) (dans x V2) *) discriminate. (* Goal: dans S' (map (fun e : Elt => couple e un) V2) *) (* Goal: @eq Ensf (map injdroite V2) V2' *) rewrite egal_x; assumption. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) apply sym_equal; auto. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) auto. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) apply sym_equal; auto. (* Goal: forall (_ : dans x V2) (_ : @eq Elt (injproducd V2 x) (injproducd V2 y)), @eq Elt x y *) (* Goal: or (dans x X) (dans x V2) *) intro dans_x. (* Goal: forall _ : @eq Elt (injproducg V1 x) (injproducg V1 y), @eq Elt x y *) (* Goal: or (dans x X) (dans x V1) *) replace (injproducg V1 x) with (injgauche x). (* Goal: forall _ : @eq Elt (injgauche x) (injproducg V1 y), @eq Elt x y *) (* Goal: @eq Elt (injgauche x) (injproducg V1 x) *) (* Goal: or (dans x X) (dans x V1) *) elimtype (dans y X \/ dans y V1). (* Goal: forall (_ : dans y X) (_ : @eq Elt (injdroite x) (injproducd V2 y)), @eq Elt x y *) (* Goal: forall (_ : dans y V2) (_ : @eq Elt (injdroite x) (injproducd V2 y)), @eq Elt x y *) (* Goal: or (dans y X) (dans y V2) *) (* Goal: @eq Elt (injdroite x) (injproducd V2 x) *) (* Goal: or (dans x X) (dans x V2) *) intros dans_y. (* Goal: forall _ : @eq Elt (injgauche x) (injproducg V1 y), @eq Elt x y *) (* Goal: forall (_ : dans y V1) (_ : @eq Elt (injgauche x) (injproducg V1 y)), @eq Elt x y *) (* Goal: or (dans y X) (dans y V1) *) (* Goal: @eq Elt (injgauche x) (injproducg V1 x) *) (* Goal: or (dans x X) (dans x V1) *) replace (injproducg V1 y) with y. (* Goal: forall _ : @eq Elt (injgauche x) (injgauche y), @eq Elt x y *) (* Goal: @eq Elt (injgauche y) (injproducg V1 y) *) (* Goal: or (dans y X) (dans y V1) *) (* Goal: @eq Elt (injgauche x) (injproducg V1 x) *) (* Goal: or (dans x X) (dans x V1) *) unfold injgauche in |- *. (* Goal: forall _ : @eq Elt (couple x un) y, @eq Elt x y *) (* Goal: @eq Elt y (injproducd V2 y) *) (* Goal: forall (_ : dans y V2) (_ : @eq Elt (injdroite x) (injproducd V2 y)), @eq Elt x y *) (* Goal: or (dans y X) (dans y V2) *) (* Goal: @eq Elt (injdroite x) (injproducd V2 x) *) (* Goal: or (dans x X) (dans x V2) *) elim (Mots_X y dans_y). (* Goal: forall (x0 : Word) (_ : @eq Elt (word x0) y) (_ : @eq Elt (couple x un) y), @eq Elt x y *) (* Goal: @eq Elt y (injproducd V2 y) *) (* Goal: forall (_ : dans y V2) (_ : @eq Elt (injdroite x) (injproducd V2 y)), @eq Elt x y *) (* Goal: or (dans y X) (dans y V2) *) (* Goal: @eq Elt (injdroite x) (injproducd V2 x) *) (* Goal: or (dans x X) (dans x V2) *) intros x0 egal_y egal2_y. (* Goal: @eq Elt x y *) (* Goal: @eq Elt y (injproducg V1 y) *) (* Goal: forall (_ : dans y V1) (_ : @eq Elt (injgauche x) (injproducg V1 y)), @eq Elt x y *) (* Goal: or (dans y X) (dans y V1) *) (* Goal: @eq Elt (injgauche x) (injproducg V1 x) *) (* Goal: or (dans x X) (dans x V1) *) absurd (word x0 = couple x zero). (* Goal: not (@eq Elt (word x0) (couple x un)) *) (* Goal: @eq Elt (word x0) (couple x un) *) (* Goal: @eq Elt y (injproducd V2 y) *) (* Goal: forall (_ : dans y V2) (_ : @eq Elt (injdroite x) (injproducd V2 y)), @eq Elt x y *) (* Goal: or (dans y X) (dans y V2) *) (* Goal: @eq Elt (injdroite x) (injproducd V2 x) *) (* Goal: or (dans x X) (dans x V2) *) discriminate. (* Goal: dans S' (map (fun e : Elt => couple e un) V2) *) (* Goal: @eq Ensf (map injdroite V2) V2' *) rewrite egal2_y; assumption. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) apply sym_equal; auto. (* Goal: forall _ : @eq Elt (natural O) (natural (S O)), False *) (* Goal: @eq Elt zero un *) (* Goal: @ex Elt (fun y : Elt => and (dans y V2) (@eq Elt x (injdroite y))) *) (* Goal: @ex Elt (fun y : Elt => and (dans y V1) (@eq Elt x (injgauche y))) *) (* Goal: @eq Ensf (map injdroite V2) (map (injproducd V2) V2) *) (* Goal: @eq Ensf (map injgauche V1) (map (injproducg V1) V1) *) intro. (* Goal: forall _ : @eq Elt (injgauche x) (injproducg V1 y), @eq Elt x y *) (* Goal: or (dans y X) (dans y V1) *) (* Goal: @eq Elt (injgauche x) (injproducg V1 x) *) (* Goal: or (dans x X) (dans x V1) *) replace (injproducg V1 y) with (injgauche y). (* Goal: forall _ : @eq Elt (injgauche x) (injgauche y), @eq Elt x y *) (* Goal: @eq Elt (injgauche y) (injproducg V1 y) *) (* Goal: or (dans y X) (dans y V1) *) (* Goal: @eq Elt (injgauche x) (injproducg V1 x) *) (* Goal: or (dans x X) (dans x V1) *) unfold injgauche in |- *. (* Goal: forall _ : @eq Elt (couple x un) (couple y un), @eq Elt x y *) (* Goal: @eq Elt (injdroite y) (injproducd V2 y) *) (* Goal: or (dans y X) (dans y V2) *) (* Goal: @eq Elt (injdroite x) (injproducd V2 x) *) (* Goal: or (dans x X) (dans x V2) *) intros. (* Goal: dans S' (map (fun e : Elt => couple e un) V2) *) (* Goal: @eq Ensf (map injdroite V2) V2' *) apply couple_couple_inv1 with zero zero; assumption. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) apply sym_equal; auto. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) auto. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) apply sym_equal; auto. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) auto. Qed. Hint Resolve is_mono_u_X_V1_injproducg_V1. Lemma is_mono_u_X_V2_injproducd_V2 : is_mono (union X V2) (injproducd V2). (* Goal: is_mono (union X V2) (injproducd V2) *) unfold is_mono in |- *. (* Goal: forall (x y : Elt) (_ : dans x (union X V2)) (_ : dans y (union X V2)) (_ : @eq Elt (injproducd V2 x) (injproducd V2 y)), @eq Elt x y *) intros x y dans_x_u dans_y_u. (* Goal: forall _ : @eq Elt (injproducd V2 x) (injproducd V2 y), @eq Elt x y *) elimtype (dans x X \/ dans x V2). (* Goal: forall (_ : dans x V2) (_ : @eq Elt (injproducd V2 x) (injproducd V2 y)), @eq Elt x y *) (* Goal: or (dans x X) (dans x V2) *) intro dans_x. (* Goal: forall _ : @eq Elt (injproducd V2 x) (injproducd V2 y), @eq Elt x y *) (* Goal: forall (_ : dans x V2) (_ : @eq Elt (injproducd V2 x) (injproducd V2 y)), @eq Elt x y *) (* Goal: or (dans x X) (dans x V2) *) replace (injproducd V2 x) with x. (* Goal: forall _ : @eq Elt (injdroite x) (injproducd V2 y), @eq Elt x y *) (* Goal: @eq Elt (injdroite x) (injproducd V2 x) *) (* Goal: or (dans x X) (dans x V2) *) elimtype (dans y X \/ dans y V2). (* Goal: forall (_ : dans y X) (_ : @eq Elt (injdroite x) (injproducd V2 y)), @eq Elt x y *) (* Goal: forall (_ : dans y V2) (_ : @eq Elt (injdroite x) (injproducd V2 y)), @eq Elt x y *) (* Goal: or (dans y X) (dans y V2) *) (* Goal: @eq Elt (injdroite x) (injproducd V2 x) *) (* Goal: or (dans x X) (dans x V2) *) intros dans_y. (* Goal: forall _ : @eq Elt (injdroite x) (injproducd V2 y), @eq Elt x y *) (* Goal: forall (_ : dans y V2) (_ : @eq Elt (injdroite x) (injproducd V2 y)), @eq Elt x y *) (* Goal: or (dans y X) (dans y V2) *) (* Goal: @eq Elt (injdroite x) (injproducd V2 x) *) (* Goal: or (dans x X) (dans x V2) *) replace (injproducd V2 y) with y. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) auto. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) apply sym_equal; auto. (* Goal: forall (_ : dans y X) (_ : @eq Elt (injdroite x) (injproducd V2 y)), @eq Elt x y *) (* Goal: forall (_ : dans y V2) (_ : @eq Elt (injdroite x) (injproducd V2 y)), @eq Elt x y *) (* Goal: or (dans y X) (dans y V2) *) (* Goal: @eq Elt (injdroite x) (injproducd V2 x) *) (* Goal: or (dans x X) (dans x V2) *) intros dans_y. (* Goal: forall _ : @eq Elt (injdroite x) (injproducd V2 y), @eq Elt x y *) (* Goal: or (dans y X) (dans y V2) *) (* Goal: @eq Elt (injdroite x) (injproducd V2 x) *) (* Goal: or (dans x X) (dans x V2) *) replace (injproducd V2 y) with (injdroite y). (* Goal: forall _ : @eq Elt (injdroite x) (injdroite y), @eq Elt x y *) (* Goal: @eq Elt (injdroite y) (injproducd V2 y) *) (* Goal: or (dans y X) (dans y V2) *) (* Goal: @eq Elt (injdroite x) (injproducd V2 x) *) (* Goal: or (dans x X) (dans x V2) *) unfold injdroite in |- *. (* Goal: forall _ : @eq Elt x (couple y un), @eq Elt x y *) (* Goal: @eq Elt (injdroite y) (injproducd V2 y) *) (* Goal: or (dans y X) (dans y V2) *) (* Goal: @eq Elt x (injproducd V2 x) *) (* Goal: forall (_ : dans x V2) (_ : @eq Elt (injproducd V2 x) (injproducd V2 y)), @eq Elt x y *) (* Goal: or (dans x X) (dans x V2) *) elim (Mots_X x dans_x). (* Goal: forall (x0 : Word) (_ : @eq Elt (word x0) x) (_ : @eq Elt x (couple y un)), @eq Elt x y *) (* Goal: @eq Elt (injdroite y) (injproducd V2 y) *) (* Goal: or (dans y X) (dans y V2) *) (* Goal: @eq Elt x (injproducd V2 x) *) (* Goal: forall (_ : dans x V2) (_ : @eq Elt (injproducd V2 x) (injproducd V2 y)), @eq Elt x y *) (* Goal: or (dans x X) (dans x V2) *) intros x0 egal_x egal2_x. (* Goal: @eq Elt x y *) (* Goal: @eq Elt (injdroite y) (injproducd V2 y) *) (* Goal: or (dans y X) (dans y V2) *) (* Goal: @eq Elt x (injproducd V2 x) *) (* Goal: forall (_ : dans x V2) (_ : @eq Elt (injproducd V2 x) (injproducd V2 y)), @eq Elt x y *) (* Goal: or (dans x X) (dans x V2) *) absurd (word x0 = couple y un). (* Goal: not (@eq Elt (word x0) (couple x un)) *) (* Goal: @eq Elt (word x0) (couple x un) *) (* Goal: @eq Elt y (injproducd V2 y) *) (* Goal: forall (_ : dans y V2) (_ : @eq Elt (injdroite x) (injproducd V2 y)), @eq Elt x y *) (* Goal: or (dans y X) (dans y V2) *) (* Goal: @eq Elt (injdroite x) (injproducd V2 x) *) (* Goal: or (dans x X) (dans x V2) *) discriminate. (* Goal: dans S' (map (fun e : Elt => couple e un) V2) *) (* Goal: @eq Ensf (map injdroite V2) V2' *) rewrite egal_x; assumption. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) apply sym_equal; auto. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) auto. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) apply sym_equal; auto. (* Goal: forall (_ : dans x V2) (_ : @eq Elt (injproducd V2 x) (injproducd V2 y)), @eq Elt x y *) (* Goal: or (dans x X) (dans x V2) *) intro dans_x. (* Goal: forall _ : @eq Elt (injproducd V2 x) (injproducd V2 y), @eq Elt x y *) (* Goal: or (dans x X) (dans x V2) *) replace (injproducd V2 x) with (injdroite x). (* Goal: forall _ : @eq Elt (injdroite x) (injproducd V2 y), @eq Elt x y *) (* Goal: @eq Elt (injdroite x) (injproducd V2 x) *) (* Goal: or (dans x X) (dans x V2) *) elimtype (dans y X \/ dans y V2). (* Goal: forall (_ : dans y X) (_ : @eq Elt (injdroite x) (injproducd V2 y)), @eq Elt x y *) (* Goal: forall (_ : dans y V2) (_ : @eq Elt (injdroite x) (injproducd V2 y)), @eq Elt x y *) (* Goal: or (dans y X) (dans y V2) *) (* Goal: @eq Elt (injdroite x) (injproducd V2 x) *) (* Goal: or (dans x X) (dans x V2) *) intros dans_y. (* Goal: forall _ : @eq Elt (injdroite x) (injproducd V2 y), @eq Elt x y *) (* Goal: forall (_ : dans y V2) (_ : @eq Elt (injdroite x) (injproducd V2 y)), @eq Elt x y *) (* Goal: or (dans y X) (dans y V2) *) (* Goal: @eq Elt (injdroite x) (injproducd V2 x) *) (* Goal: or (dans x X) (dans x V2) *) replace (injproducd V2 y) with y. (* Goal: forall _ : @eq Elt (injdroite x) (injdroite y), @eq Elt x y *) (* Goal: @eq Elt (injdroite y) (injproducd V2 y) *) (* Goal: or (dans y X) (dans y V2) *) (* Goal: @eq Elt (injdroite x) (injproducd V2 x) *) (* Goal: or (dans x X) (dans x V2) *) unfold injdroite in |- *. (* Goal: forall _ : @eq Elt (couple x un) y, @eq Elt x y *) (* Goal: @eq Elt y (injproducd V2 y) *) (* Goal: forall (_ : dans y V2) (_ : @eq Elt (injdroite x) (injproducd V2 y)), @eq Elt x y *) (* Goal: or (dans y X) (dans y V2) *) (* Goal: @eq Elt (injdroite x) (injproducd V2 x) *) (* Goal: or (dans x X) (dans x V2) *) elim (Mots_X y dans_y). (* Goal: forall (x0 : Word) (_ : @eq Elt (word x0) y) (_ : @eq Elt (couple x un) y), @eq Elt x y *) (* Goal: @eq Elt y (injproducd V2 y) *) (* Goal: forall (_ : dans y V2) (_ : @eq Elt (injdroite x) (injproducd V2 y)), @eq Elt x y *) (* Goal: or (dans y X) (dans y V2) *) (* Goal: @eq Elt (injdroite x) (injproducd V2 x) *) (* Goal: or (dans x X) (dans x V2) *) intros x0 egal_y egal2_y. (* Goal: @eq Elt x y *) (* Goal: @eq Elt y (injproducd V2 y) *) (* Goal: forall (_ : dans y V2) (_ : @eq Elt (injdroite x) (injproducd V2 y)), @eq Elt x y *) (* Goal: or (dans y X) (dans y V2) *) (* Goal: @eq Elt (injdroite x) (injproducd V2 x) *) (* Goal: or (dans x X) (dans x V2) *) absurd (word x0 = couple x un). (* Goal: not (@eq Elt (word x0) (couple x un)) *) (* Goal: @eq Elt (word x0) (couple x un) *) (* Goal: @eq Elt y (injproducd V2 y) *) (* Goal: forall (_ : dans y V2) (_ : @eq Elt (injdroite x) (injproducd V2 y)), @eq Elt x y *) (* Goal: or (dans y X) (dans y V2) *) (* Goal: @eq Elt (injdroite x) (injproducd V2 x) *) (* Goal: or (dans x X) (dans x V2) *) discriminate. (* Goal: dans S' (map (fun e : Elt => couple e un) V2) *) (* Goal: @eq Ensf (map injdroite V2) V2' *) rewrite egal2_y; assumption. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) apply sym_equal; auto. (* Goal: forall _ : @eq Elt (natural O) (natural (S O)), False *) (* Goal: @eq Elt zero un *) (* Goal: @ex Elt (fun y : Elt => and (dans y V2) (@eq Elt x (injdroite y))) *) (* Goal: @ex Elt (fun y : Elt => and (dans y V1) (@eq Elt x (injgauche y))) *) (* Goal: @eq Ensf (map injdroite V2) (map (injproducd V2) V2) *) (* Goal: @eq Ensf (map injgauche V1) (map (injproducg V1) V1) *) intro. (* Goal: forall _ : @eq Elt (injdroite x) (injproducd V2 y), @eq Elt x y *) (* Goal: or (dans y X) (dans y V2) *) (* Goal: @eq Elt (injdroite x) (injproducd V2 x) *) (* Goal: or (dans x X) (dans x V2) *) replace (injproducd V2 y) with (injdroite y). (* Goal: forall _ : @eq Elt (injdroite x) (injdroite y), @eq Elt x y *) (* Goal: @eq Elt (injdroite y) (injproducd V2 y) *) (* Goal: or (dans y X) (dans y V2) *) (* Goal: @eq Elt (injdroite x) (injproducd V2 x) *) (* Goal: or (dans x X) (dans x V2) *) unfold injdroite in |- *. (* Goal: forall _ : @eq Elt (couple x un) (couple y un), @eq Elt x y *) (* Goal: @eq Elt (injdroite y) (injproducd V2 y) *) (* Goal: or (dans y X) (dans y V2) *) (* Goal: @eq Elt (injdroite x) (injproducd V2 x) *) (* Goal: or (dans x X) (dans x V2) *) intros. (* Goal: dans S' (map (fun e : Elt => couple e un) V2) *) (* Goal: @eq Ensf (map injdroite V2) V2' *) apply couple_couple_inv1 with un un; assumption. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) apply sym_equal; auto. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) auto. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) apply sym_equal; auto. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) auto. Qed. Hint Resolve is_mono_u_X_V2_injproducd_V2. Lemma egal_LG_1_1' : l_egal (LG X V1 R1 S1) (LG X V1' R1' S1'). (* Goal: l_egal (LG X V2 R2 S2) (LG X V2' R2' S2') *) pattern X at 2 in |- *. (* Goal: (fun e : Ensf => l_egal (LG X V1 R1 S1) (LG e V1' R1' S1')) X *) replace X with X1'. (* Goal: isGram X1' V1' R1' S1' *) unfold X1', V1', R1', S1', GGG1, GG1, G1 in |- *. (* Goal: l_egal (LG X V2 R2 S2) (LG (@fst Ensf (prod Ensf (prod Ensf Elt)) (imageGram (injproducd V2) X V2 R2 S2)) (@fst Ensf (prod Ensf Elt) (@snd Ensf (prod Ensf (prod Ensf Elt)) (imageGram (injproducd V2) X V2 R2 S2))) (@fst Ensf Elt (@snd Ensf (prod Ensf Elt) (@snd Ensf (prod Ensf (prod Ensf Elt)) (imageGram (injproducd V2) X V2 R2 S2)))) (@snd Ensf Elt (@snd Ensf (prod Ensf Elt) (@snd Ensf (prod Ensf (prod Ensf Elt)) (imageGram (injproducd V2) X V2 R2 S2))))) *) (* Goal: @eq Ensf X2' X *) apply egal_LG. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) auto. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) auto. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) red in |- *; auto. (* Goal: @eq Ensf (@fst Ensf (prod Ensf (prod Ensf Elt)) G2) X *) unfold X1' in |- *; simpl in |- *. (* Goal: @eq Ensf (map (injproducd V2) X) X *) apply map_Id. (* Goal: not (@eq Elt (natural O) (natural (S O))) *) (* Goal: @eq Elt zero un *) (* Goal: @ex Elt (fun y : Elt => and (dans y V2) (@eq Elt x (injdroite y))) *) (* Goal: @ex Elt (fun y : Elt => and (dans y V1) (@eq Elt x (injgauche y))) *) (* Goal: @eq Ensf (map injdroite V2) (map (injproducd V2) V2) *) (* Goal: @eq Ensf (map injgauche V1) (map (injproducg V1) V1) *) red in |- *. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) auto. Qed. Hint Resolve egal_LG_1_1'. Lemma egal_LG_2_2' : l_egal (LG X V2 R2 S2) (LG X V2' R2' S2'). (* Goal: l_egal (LG X V2 R2 S2) (LG X V2' R2' S2') *) pattern X at 2 in |- *. (* Goal: (fun e : Ensf => l_egal (LG X V2 R2 S2) (LG e V2' R2' S2')) X *) replace X with X2'. (* Goal: isGram X2' V2' R2' S2' *) unfold X2', V2', R2', S2', GGG2, GG2, G2 in |- *. (* Goal: l_egal (LG X V2 R2 S2) (LG (@fst Ensf (prod Ensf (prod Ensf Elt)) (imageGram (injproducd V2) X V2 R2 S2)) (@fst Ensf (prod Ensf Elt) (@snd Ensf (prod Ensf (prod Ensf Elt)) (imageGram (injproducd V2) X V2 R2 S2))) (@fst Ensf Elt (@snd Ensf (prod Ensf Elt) (@snd Ensf (prod Ensf (prod Ensf Elt)) (imageGram (injproducd V2) X V2 R2 S2)))) (@snd Ensf Elt (@snd Ensf (prod Ensf Elt) (@snd Ensf (prod Ensf (prod Ensf Elt)) (imageGram (injproducd V2) X V2 R2 S2))))) *) (* Goal: @eq Ensf X2' X *) apply egal_LG. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) auto. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) auto. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) red in |- *; auto. (* Goal: @eq Ensf (@fst Ensf (prod Ensf (prod Ensf Elt)) G2) X *) unfold X2' in |- *; simpl in |- *. (* Goal: @eq Ensf (map (injproducd V2) X) X *) apply map_Id. (* Goal: not (@eq Elt (natural O) (natural (S O))) *) (* Goal: @eq Elt zero un *) (* Goal: @ex Elt (fun y : Elt => and (dans y V2) (@eq Elt x (injdroite y))) *) (* Goal: @ex Elt (fun y : Elt => and (dans y V1) (@eq Elt x (injgauche y))) *) (* Goal: @eq Ensf (map injdroite V2) (map (injproducd V2) V2) *) (* Goal: @eq Ensf (map injgauche V1) (map (injproducg V1) V1) *) red in |- *. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) auto. Qed. Hint Resolve egal_LG_2_2'. Lemma egal_X_X1' : X1' = X :>Ensf. (* Goal: @eq Ensf (@fst Ensf (prod Ensf (prod Ensf Elt)) G2) X *) unfold X1' in |- *. simpl in |- *. (* Goal: @eq Ensf (map (injproducd V2) X) X *) apply map_Id. (* Goal: not (@eq Elt (natural O) (natural (S O))) *) (* Goal: @eq Elt zero un *) (* Goal: @ex Elt (fun y : Elt => and (dans y V2) (@eq Elt x (injdroite y))) *) (* Goal: @ex Elt (fun y : Elt => and (dans y V1) (@eq Elt x (injgauche y))) *) (* Goal: @eq Ensf (map injdroite V2) (map (injproducd V2) V2) *) (* Goal: @eq Ensf (map injgauche V1) (map (injproducg V1) V1) *) red in |- *. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) auto. Qed. Lemma egal_X_X2' : X2' = X :>Ensf. (* Goal: @eq Ensf (@fst Ensf (prod Ensf (prod Ensf Elt)) G2) X *) unfold X2' in |- *. simpl in |- *. (* Goal: @eq Ensf (map (injproducd V2) X) X *) apply map_Id. (* Goal: not (@eq Elt (natural O) (natural (S O))) *) (* Goal: @eq Elt zero un *) (* Goal: @ex Elt (fun y : Elt => and (dans y V2) (@eq Elt x (injdroite y))) *) (* Goal: @ex Elt (fun y : Elt => and (dans y V1) (@eq Elt x (injgauche y))) *) (* Goal: @eq Ensf (map injdroite V2) (map (injproducd V2) V2) *) (* Goal: @eq Ensf (map injgauche V1) (map (injproducg V1) V1) *) red in |- *. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) auto. Qed. Lemma Grammaire1' : isGram X V1' R1' S1'. (* Goal: isGram X V1' R1' S1' *) rewrite <- egal_X_X1'. (* Goal: isGram X1' V1' R1' S1' *) unfold X1', V1', R1', S1', GGG1, GG1, G1 in |- *. (* Goal: isGram (@fst Ensf (prod Ensf (prod Ensf Elt)) (imageGram (injproducd V2) X V2 R2 S2)) (@fst Ensf (prod Ensf Elt) (@snd Ensf (prod Ensf (prod Ensf Elt)) (imageGram (injproducd V2) X V2 R2 S2))) (@fst Ensf Elt (@snd Ensf (prod Ensf Elt) (@snd Ensf (prod Ensf (prod Ensf Elt)) (imageGram (injproducd V2) X V2 R2 S2)))) (@snd Ensf Elt (@snd Ensf (prod Ensf Elt) (@snd Ensf (prod Ensf (prod Ensf Elt)) (imageGram (injproducd V2) X V2 R2 S2)))) *) apply image_isGram. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) auto. (* Goal: Mots (@fst Ensf (prod Ensf (prod Ensf Elt)) (imageGram (injproducg V1) X V1 R1 S1)) *) (* Goal: inter (@fst Ensf (prod Ensf (prod Ensf Elt)) (imageGram (injproducg V1) X V1 R1 S1)) (@fst Ensf (prod Ensf Elt) (@snd Ensf (prod Ensf (prod Ensf Elt)) (imageGram (injproducg V1) X V1 R1 S1))) empty *) change (Mots X1') in |- *. (* Goal: Mots X1' *) (* Goal: inter (@fst Ensf (prod Ensf (prod Ensf Elt)) (imageGram (injproducg V1) X V1 R1 S1)) (@fst Ensf (prod Ensf Elt) (@snd Ensf (prod Ensf (prod Ensf Elt)) (imageGram (injproducg V1) X V1 R1 S1))) empty *) rewrite egal_X_X1'. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) auto. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) apply inter_Xim_Vim_empty; auto. Qed. Hint Resolve Grammaire1'. Lemma Grammaire2' : isGram X V2' R2' S2'. (* Goal: isGram X V2' R2' S2' *) rewrite <- egal_X_X2'. (* Goal: isGram X2' V2' R2' S2' *) unfold X2', V2', R2', S2', GGG2, GG2, G2 in |- *. (* Goal: isGram (@fst Ensf (prod Ensf (prod Ensf Elt)) (imageGram (injproducd V2) X V2 R2 S2)) (@fst Ensf (prod Ensf Elt) (@snd Ensf (prod Ensf (prod Ensf Elt)) (imageGram (injproducd V2) X V2 R2 S2))) (@fst Ensf Elt (@snd Ensf (prod Ensf Elt) (@snd Ensf (prod Ensf (prod Ensf Elt)) (imageGram (injproducd V2) X V2 R2 S2)))) (@snd Ensf Elt (@snd Ensf (prod Ensf Elt) (@snd Ensf (prod Ensf (prod Ensf Elt)) (imageGram (injproducd V2) X V2 R2 S2)))) *) apply image_isGram. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) auto. (* Goal: Mots (@fst Ensf (prod Ensf (prod Ensf Elt)) (imageGram (injproducd V2) X V2 R2 S2)) *) (* Goal: inter (@fst Ensf (prod Ensf (prod Ensf Elt)) (imageGram (injproducd V2) X V2 R2 S2)) (@fst Ensf (prod Ensf Elt) (@snd Ensf (prod Ensf (prod Ensf Elt)) (imageGram (injproducd V2) X V2 R2 S2))) empty *) change (Mots X2') in |- *. (* Goal: Mots X2' *) (* Goal: inter (@fst Ensf (prod Ensf (prod Ensf Elt)) (imageGram (injproducd V2) X V2 R2 S2)) (@fst Ensf (prod Ensf Elt) (@snd Ensf (prod Ensf (prod Ensf Elt)) (imageGram (injproducd V2) X V2 R2 S2))) empty *) rewrite egal_X_X2'. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) auto. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) apply inter_Xim_Vim_empty; auto. Qed. Hint Resolve Grammaire2'. Lemma inter_V1'_V2'_empty : inter V1' V2' empty. (* Goal: @eq Ensf (@fst Ensf (prod Ensf (prod Ensf Elt)) G2) X *) unfold V1', V2' in |- *; simpl in |- *. (* Goal: inter (map (injproducg V1) V1) (map (injproducd V2) V2) empty *) unfold inter in |- *. (* Goal: and (inclus empty (map (injproducg V1) V1)) (and (inclus empty (map (injproducd V2) V2)) (forall (x : Elt) (_ : dans x (map (injproducg V1) V1)) (_ : dans x (map (injproducd V2) V2)), dans x empty)) *) split; [ auto | split ]. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) auto. (* Goal: forall (x : Elt) (_ : dans x (map (injproducg V1) V1)) (_ : dans x (map (injproducd V2) V2)), dans x empty *) replace (map (injproducg V1) V1) with (map injgauche V1). (* Goal: forall (x : Elt) (_ : dans x (map injgauche V1)) (_ : dans x (map (injproducd V2) V2)), dans x empty *) (* Goal: @eq Ensf (map injgauche V1) (map (injproducg V1) V1) *) replace (map (injproducd V2) V2) with (map injdroite V2). (* Goal: forall (x : Elt) (_ : dans x (map injgauche V1)) (_ : dans x (map injdroite V2)), dans x empty *) (* Goal: @eq Ensf (map injdroite V2) (map (injproducd V2) V2) *) (* Goal: @eq Ensf (map injgauche V1) (map (injproducg V1) V1) *) intros x dans_map_1 dans_map_2. (* Goal: dans x empty *) (* Goal: @eq Ensf (map injdroite V2) (map (injproducd V2) V2) *) (* Goal: @eq Ensf (map injgauche V1) (map (injproducg V1) V1) *) elimtype (exists y : Elt, dans y V1 /\ x = injgauche y). (* Goal: forall (x0 : Elt) (_ : and (dans x0 V1) (@eq Elt x (injgauche x0))), dans x empty *) (* Goal: @ex Elt (fun y : Elt => and (dans y V1) (@eq Elt x (injgauche y))) *) (* Goal: @eq Ensf (map injdroite V2) (map (injproducd V2) V2) *) (* Goal: @eq Ensf (map injgauche V1) (map (injproducg V1) V1) *) elimtype (exists y : Elt, dans y V2 /\ x = injdroite y). (* Goal: forall (x0 : Elt) (_ : and (dans x0 V2) (@eq Elt x (injdroite x0))) (x1 : Elt) (_ : and (dans x1 V1) (@eq Elt x (injgauche x1))), dans x empty *) (* Goal: @ex Elt (fun y : Elt => and (dans y V2) (@eq Elt x (injdroite y))) *) (* Goal: @ex Elt (fun y : Elt => and (dans y V1) (@eq Elt x (injgauche y))) *) (* Goal: @eq Ensf (map injdroite V2) (map (injproducd V2) V2) *) (* Goal: @eq Ensf (map injgauche V1) (map (injproducg V1) V1) *) intros x2 temp; elim temp; clear temp; intros dans_x2_V2 egal_x2. (* Goal: forall (x0 : Elt) (_ : and (dans x0 V1) (@eq Elt x (injgauche x0))), dans x empty *) (* Goal: @ex Elt (fun y : Elt => and (dans y V2) (@eq Elt x (injdroite y))) *) (* Goal: @ex Elt (fun y : Elt => and (dans y V1) (@eq Elt x (injgauche y))) *) (* Goal: @eq Ensf (map injdroite V2) (map (injproducd V2) V2) *) (* Goal: @eq Ensf (map injgauche V1) (map (injproducg V1) V1) *) intros x1 temp; elim temp; clear temp; intros dans_x1_V1 egal_x1. (* Goal: dans x empty *) (* Goal: @ex Elt (fun y : Elt => and (dans y V2) (@eq Elt x (injdroite y))) *) (* Goal: @ex Elt (fun y : Elt => and (dans y V1) (@eq Elt x (injgauche y))) *) (* Goal: @eq Ensf (map injdroite V2) (map (injproducd V2) V2) *) (* Goal: @eq Ensf (map injgauche V1) (map (injproducg V1) V1) *) absurd (zero = un). (* Goal: not (@eq Elt zero un) *) (* Goal: @eq Elt zero un *) (* Goal: @ex Elt (fun y : Elt => and (dans y V2) (@eq Elt x (injdroite y))) *) (* Goal: @ex Elt (fun y : Elt => and (dans y V1) (@eq Elt x (injgauche y))) *) (* Goal: @eq Ensf (map injdroite V2) (map (injproducd V2) V2) *) (* Goal: @eq Ensf (map injgauche V1) (map (injproducg V1) V1) *) unfold zero, un in |- *. (* Goal: not (@eq Elt (natural O) (natural (S O))) *) (* Goal: @eq Elt zero un *) (* Goal: @ex Elt (fun y : Elt => and (dans y V2) (@eq Elt x (injdroite y))) *) (* Goal: @ex Elt (fun y : Elt => and (dans y V1) (@eq Elt x (injgauche y))) *) (* Goal: @eq Ensf (map injdroite V2) (map (injproducd V2) V2) *) (* Goal: @eq Ensf (map injgauche V1) (map (injproducg V1) V1) *) red in |- *. (* Goal: forall _ : @eq Elt (natural O) (natural (S O)), False *) (* Goal: @eq Elt zero un *) (* Goal: @ex Elt (fun y : Elt => and (dans y V2) (@eq Elt x (injdroite y))) *) (* Goal: @ex Elt (fun y : Elt => and (dans y V1) (@eq Elt x (injgauche y))) *) (* Goal: @eq Ensf (map injdroite V2) (map (injproducd V2) V2) *) (* Goal: @eq Ensf (map injgauche V1) (map (injproducg V1) V1) *) intro. (* Goal: False *) (* Goal: @eq Elt zero un *) (* Goal: @ex Elt (fun y : Elt => and (dans y V2) (@eq Elt x (injdroite y))) *) (* Goal: @ex Elt (fun y : Elt => and (dans y V1) (@eq Elt x (injgauche y))) *) (* Goal: @eq Ensf (map injdroite V2) (map (injproducd V2) V2) *) (* Goal: @eq Ensf (map injgauche V1) (map (injproducg V1) V1) *) cut (0 = 1 :>nat). (* Goal: forall _ : @eq nat O (S O), False *) (* Goal: @eq nat O (S O) *) (* Goal: @eq Elt zero un *) (* Goal: @ex Elt (fun y : Elt => and (dans y V2) (@eq Elt x (injdroite y))) *) (* Goal: @ex Elt (fun y : Elt => and (dans y V1) (@eq Elt x (injgauche y))) *) (* Goal: @eq Ensf (map injdroite V2) (map (injproducd V2) V2) *) (* Goal: @eq Ensf (map injgauche V1) (map (injproducg V1) V1) *) change (0 <> 1 :>nat) in |- *. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) auto. (* Goal: @eq nat O (S O) *) (* Goal: @eq Elt zero un *) (* Goal: @ex Elt (fun y : Elt => and (dans y V2) (@eq Elt x (injdroite y))) *) (* Goal: @ex Elt (fun y : Elt => and (dans y V1) (@eq Elt x (injgauche y))) *) (* Goal: @eq Ensf (map injdroite V2) (map (injproducd V2) V2) *) (* Goal: @eq Ensf (map injgauche V1) (map (injproducg V1) V1) *) change (natural_inv (natural 0) = natural_inv (natural 1) :>nat) in |- *. (* Goal: dans S' (map (fun e : Elt => couple e un) V2) *) (* Goal: @eq Ensf (map injdroite V2) V2' *) apply (f_equal natural_inv); assumption. (* Goal: @eq Elt zero un *) (* Goal: @ex Elt (fun y : Elt => and (dans y V2) (@eq Elt x (injdroite y))) *) (* Goal: @ex Elt (fun y : Elt => and (dans y V1) (@eq Elt x (injgauche y))) *) (* Goal: @eq Ensf (map injdroite V2) (map (injproducd V2) V2) *) (* Goal: @eq Ensf (map injgauche V1) (map (injproducg V1) V1) *) apply couple_couple_inv2 with x1 x2. (* Goal: @eq Elt (couple x1 zero) (couple x2 un) *) (* Goal: @ex Elt (fun y : Elt => and (dans y V2) (@eq Elt x (injdroite y))) *) (* Goal: @ex Elt (fun y : Elt => and (dans y V1) (@eq Elt x (injgauche y))) *) (* Goal: @eq Ensf (map injdroite V2) (map (injproducd V2) V2) *) (* Goal: @eq Ensf (map injgauche V1) (map (injproducg V1) V1) *) replace (couple x1 zero) with x. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) auto. (* Goal: dans S' (map (fun e : Elt => couple e un) V2) *) (* Goal: @eq Ensf (map injdroite V2) V2' *) apply dans_map; assumption. (* Goal: dans S' (map (fun e : Elt => couple e un) V2) *) (* Goal: @eq Ensf (map injdroite V2) V2' *) apply dans_map; assumption. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) auto. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) auto. Qed. Hint Resolve inter_V1'_V2'_empty. Lemma egal_LG_u_1'_2' : l_egal (LG X Vu Ru S') (lunion (LG X V1' R1' S1') (LG X V2' R2' S2')). (* Goal: l_egal (LG X Vu Ru S') (lunion (LG X V1' R1' S1') (LG X V2' R2' S2')) *) unfold Ru, Vu, C', Gim in |- *. (* Goal: l_egal (LG X (@fst Ensf (prod Ensf Elt) (Gunion_disj_p V1' R1' S1' V2' R2' S2' S')) (@fst Ensf Elt (@snd Ensf (prod Ensf Elt) (Gunion_disj_p V1' R1' S1' V2' R2' S2' S'))) S') (lunion (LG X V1' R1' S1') (LG X V2' R2' S2')) *) apply Gunion_disj_LG. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) auto. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) auto. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) auto. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) auto. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) auto. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) auto. Qed. Hint Resolve egal_LG_u_1'_2'. Theorem union_is_LCF : l_egal (LG X Vu Ru S') (lunion (LG X V1 R1 S1) (LG X V2 R2 S2)). (* Goal: l_egal (LG X Vu Ru S') (lunion (LG X V1 R1 S1) (LG X V2 R2 S2)) *) elimtype (l_egal (LG X V1 R1 S1) (LG X V1' R1' S1')). (* Goal: forall (_ : l_inclus (LG X V1 R1 S1) (LG X V1' R1' S1')) (_ : l_inclus (LG X V1' R1' S1') (LG X V1 R1 S1)), l_egal (LG X Vu Ru S') (lunion (LG X V1 R1 S1) (LG X V2 R2 S2)) *) (* Goal: and (l_inclus (LG X V1 R1 S1) (LG X V1' R1' S1')) (l_inclus (LG X V1' R1' S1') (LG X V1 R1 S1)) *) elimtype (l_egal (LG X V2 R2 S2) (LG X V2' R2' S2')). elimtype (l_egal (LG X Vu Ru S') (lunion (LG X V1' R1' S1') (LG X V2' R2' S2'))). intros incl_i_u_1'_2' incl_u_1'_2'_u_i incl_2_2' incl_2'_2 incl_1_1' incl_1'_1. (* Goal: l_egal (LG X Vu Ru S') (lunion (LG X V1 R1 S1) (LG X V2 R2 S2)) *) (* Goal: and (l_inclus (LG X Vu Ru S') (lunion (LG X V1' R1' S1') (LG X V2' R2' S2'))) (l_inclus (lunion (LG X V1' R1' S1') (LG X V2' R2' S2')) (LG X Vu Ru S')) *) (* Goal: and (l_inclus (LG X V2 R2 S2) (LG X V2' R2' S2')) (l_inclus (LG X V2' R2' S2') (LG X V2 R2 S2)) *) (* Goal: and (l_inclus (LG X V1 R1 S1) (LG X V1' R1' S1')) (l_inclus (LG X V1' R1' S1') (LG X V1 R1 S1)) *) unfold l_egal in |- *; split; unfold l_inclus in |- *. (* Goal: forall (w : Word) (_ : LG X Vu Ru S' w), lunion (LG X V1 R1 S1) (LG X V2 R2 S2) w *) (* Goal: forall (w : Word) (_ : lunion (LG X V1 R1 S1) (LG X V2 R2 S2) w), LG X Vu Ru S' w *) (* Goal: and (l_inclus (LG X Vu Ru S') (lunion (LG X V1' R1' S1') (LG X V2' R2' S2'))) (l_inclus (lunion (LG X V1' R1' S1') (LG X V2' R2' S2')) (LG X Vu Ru S')) *) (* Goal: and (l_inclus (LG X V2 R2 S2) (LG X V2' R2' S2')) (l_inclus (LG X V2' R2' S2') (LG X V2 R2 S2)) *) (* Goal: and (l_inclus (LG X V1 R1 S1) (LG X V1' R1' S1')) (l_inclus (LG X V1' R1' S1') (LG X V1 R1 S1)) *) intros w LG_Ru_w. elimtype (lunion (LG X V1' R1' S1') (LG X V2' R2' S2') w); (* Goal: lunion (LG X V1' R1' S1') (LG X V2' R2' S2') w *) (* Goal: and (l_inclus (LG X Vu Ru S') (lunion (LG X V1' R1' S1') (LG X V2' R2' S2'))) (l_inclus (lunion (LG X V1' R1' S1') (LG X V2' R2' S2')) (LG X Vu Ru S')) *) (* Goal: and (l_inclus (LG X V2 R2 S2) (LG X V2' R2' S2')) (l_inclus (LG X V2' R2' S2') (LG X V2 R2 S2)) *) (* Goal: and (l_inclus (LG X V1 R1 S1) (LG X V1' R1' S1')) (l_inclus (LG X V1' R1' S1') (LG X V1 R1 S1)) *) unfold lunion in |- *. (* Goal: forall _ : LG X V1' R1' S1' w, or (LG X V1 R1 S1 w) (LG X V2 R2 S2 w) *) (* Goal: forall _ : LG X V2' R2' S2' w, or (LG X V1 R1 S1 w) (LG X V2 R2 S2 w) *) (* Goal: or (LG X V1' R1' S1' w) (LG X V2' R2' S2' w) *) (* Goal: forall (w : Word) (_ : lunion (LG X V1 R1 S1) (LG X V2 R2 S2) w), LG X Vu Ru S' w *) (* Goal: and (l_inclus (LG X Vu Ru S') (lunion (LG X V1' R1' S1') (LG X V2' R2' S2'))) (l_inclus (lunion (LG X V1' R1' S1') (LG X V2' R2' S2')) (LG X Vu Ru S')) *) (* Goal: and (l_inclus (LG X V2 R2 S2) (LG X V2' R2' S2')) (l_inclus (LG X V2' R2' S2') (LG X V2 R2 S2)) *) (* Goal: and (l_inclus (LG X V1 R1 S1) (LG X V1' R1' S1')) (l_inclus (LG X V1' R1' S1') (LG X V1 R1 S1)) *) intro Hyp; apply or_introl. (* Goal: dans S' (map (fun e : Elt => couple e un) V2) *) (* Goal: @eq Ensf (map injdroite V2) V2' *) apply incl_1'_1; assumption. (* Goal: forall _ : LG X V2' R2' S2' w, or (LG X V1 R1 S1 w) (LG X V2 R2 S2 w) *) (* Goal: or (LG X V1' R1' S1' w) (LG X V2' R2' S2' w) *) (* Goal: forall (w : Word) (_ : lunion (LG X V1 R1 S1) (LG X V2 R2 S2) w), LG X Vu Ru S' w *) (* Goal: and (l_inclus (LG X Vu Ru S') (lunion (LG X V1' R1' S1') (LG X V2' R2' S2'))) (l_inclus (lunion (LG X V1' R1' S1') (LG X V2' R2' S2')) (LG X Vu Ru S')) *) (* Goal: and (l_inclus (LG X V2 R2 S2) (LG X V2' R2' S2')) (l_inclus (LG X V2' R2' S2') (LG X V2 R2 S2)) *) (* Goal: and (l_inclus (LG X V1 R1 S1) (LG X V1' R1' S1')) (l_inclus (LG X V1' R1' S1') (LG X V1 R1 S1)) *) intro Hyp; apply or_intror. (* Goal: dans S' (map (fun e : Elt => couple e un) V2) *) (* Goal: @eq Ensf (map injdroite V2) V2' *) apply incl_2'_2; assumption. (* Goal: or (LG X V1' R1' S1' w) (LG X V2' R2' S2' w) *) (* Goal: forall (w : Word) (_ : lunion (LG X V1 R1 S1) (LG X V2 R2 S2) w), LG X Vu Ru S' w *) (* Goal: and (l_inclus (LG X Vu Ru S') (lunion (LG X V1' R1' S1') (LG X V2' R2' S2'))) (l_inclus (lunion (LG X V1' R1' S1') (LG X V2' R2' S2')) (LG X Vu Ru S')) *) (* Goal: and (l_inclus (LG X V2 R2 S2) (LG X V2' R2' S2')) (l_inclus (LG X V2' R2' S2') (LG X V2 R2 S2)) *) (* Goal: and (l_inclus (LG X V1 R1 S1) (LG X V1' R1' S1')) (l_inclus (LG X V1' R1' S1') (LG X V1 R1 S1)) *) change (lunion (LG X V1' R1' S1') (LG X V2' R2' S2') w) in |- *. (* Goal: dans S' (map (fun e : Elt => couple e un) V2) *) (* Goal: @eq Ensf (map injdroite V2) V2' *) apply incl_i_u_1'_2'; assumption. (* Goal: forall (w : Word) (_ : lunion (LG X V1 R1 S1) (LG X V2 R2 S2) w), LG X Vu Ru S' w *) (* Goal: and (l_inclus (LG X Vu Ru S') (lunion (LG X V1' R1' S1') (LG X V2' R2' S2'))) (l_inclus (lunion (LG X V1' R1' S1') (LG X V2' R2' S2')) (LG X Vu Ru S')) *) (* Goal: and (l_inclus (LG X V2 R2 S2) (LG X V2' R2' S2')) (l_inclus (LG X V2' R2' S2') (LG X V2 R2 S2)) *) (* Goal: and (l_inclus (LG X V1 R1 S1) (LG X V1' R1' S1')) (l_inclus (LG X V1' R1' S1') (LG X V1 R1 S1)) *) intros w lunion_LG_1_2_w. (* Goal: LG X Vu Ru S' w *) (* Goal: and (l_inclus (LG X Vu Ru S') (lunion (LG X V1' R1' S1') (LG X V2' R2' S2'))) (l_inclus (lunion (LG X V1' R1' S1') (LG X V2' R2' S2')) (LG X Vu Ru S')) *) (* Goal: and (l_inclus (LG X V2 R2 S2) (LG X V2' R2' S2')) (l_inclus (LG X V2' R2' S2') (LG X V2 R2 S2)) *) (* Goal: and (l_inclus (LG X V1 R1 S1) (LG X V1' R1' S1')) (l_inclus (LG X V1' R1' S1') (LG X V1 R1 S1)) *) apply incl_u_1'_2'_u_i. (* Goal: lunion (LG X V1' R1' S1') (LG X V2' R2' S2') w *) (* Goal: and (l_inclus (LG X Vu Ru S') (lunion (LG X V1' R1' S1') (LG X V2' R2' S2'))) (l_inclus (lunion (LG X V1' R1' S1') (LG X V2' R2' S2')) (LG X Vu Ru S')) *) (* Goal: and (l_inclus (LG X V2 R2 S2) (LG X V2' R2' S2')) (l_inclus (LG X V2' R2' S2') (LG X V2 R2 S2)) *) (* Goal: and (l_inclus (LG X V1 R1 S1) (LG X V1' R1' S1')) (l_inclus (LG X V1' R1' S1') (LG X V1 R1 S1)) *) unfold lunion in |- *. (* Goal: or (LG X V1' R1' S1' w) (LG X V2' R2' S2' w) *) (* Goal: and (l_inclus (LG X Vu Ru S') (lunion (LG X V1' R1' S1') (LG X V2' R2' S2'))) (l_inclus (lunion (LG X V1' R1' S1') (LG X V2' R2' S2')) (LG X Vu Ru S')) *) (* Goal: and (l_inclus (LG X V2 R2 S2) (LG X V2' R2' S2')) (l_inclus (LG X V2' R2' S2') (LG X V2 R2 S2)) *) (* Goal: and (l_inclus (LG X V1 R1 S1) (LG X V1' R1' S1')) (l_inclus (LG X V1' R1' S1') (LG X V1 R1 S1)) *) elim lunion_LG_1_2_w; intro LG_w. (* Goal: dans S' (map (fun e : Elt => couple e un) V2) *) (* Goal: @eq Ensf (map injdroite V2) V2' *) apply or_introl; apply incl_1_1'; assumption. (* Goal: dans S' (map (fun e : Elt => couple e un) V2) *) (* Goal: @eq Ensf (map injdroite V2) V2' *) apply or_intror; apply incl_2_2'; assumption. change (l_egal (LG X Vu Ru S') (lunion (LG X V1' R1' S1') (LG X V2' R2' S2'))) in |- *. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) auto. (* Goal: and (l_inclus (LG X V2 R2 S2) (LG X V2' R2' S2')) (l_inclus (LG X V2' R2' S2') (LG X V2 R2 S2)) *) (* Goal: and (l_inclus (LG X V1 R1 S1) (LG X V1' R1' S1')) (l_inclus (LG X V1' R1' S1') (LG X V1 R1 S1)) *) change (l_egal (LG X V2 R2 S2) (LG X V2' R2' S2')) in |- *. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) auto. (* Goal: and (l_inclus (LG X V1 R1 S1) (LG X V1' R1' S1')) (l_inclus (LG X V1' R1' S1') (LG X V1 R1 S1)) *) change (l_egal (LG X V1 R1 S1) (LG X V1' R1' S1')) in |- *. (* Goal: l_egal (LG X V1 R1 S1) (LG X V1' R1' S1') *) auto. Qed. End gram5.
(* This program is free software; you can redistribute it and/or *) (* modify it under the terms of the GNU Lesser General Public License *) (* as published by the Free Software Foundation; either version 2.1 *) (* of the License, or (at your option) any later version. *) (* *) (* This program is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* GNU General Public License for more details. *) (* *) (* You should have received a copy of the GNU Lesser General Public *) (* License along with this program; if not, write to the Free *) (* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *) (* 02110-1301 USA *) (* Contribution to the Coq Library V6.3 (July 1999) *) (****************************************************************************) (* The Calculus of Inductive Constructions *) (* *) (* Projet Coq *) (* *) (* INRIA ENS-CNRS *) (* Rocquencourt Lyon *) (* *) (* Coq V5.10 *) (* Nov 25th 1994 *) (* *) (****************************************************************************) (* Reg.v *) (****************************************************************************) (* Formal Language Theory *) (* *) (* Judicael Courant - Jean-Christophe Filliatre *) (* *) (* Developped in V5.8 June-July 1993 *) (* Ported to V5.10 October 1994 *) (****************************************************************************) (* *) (* AUTOMATES FINIS *) (* On definit le predicat (automate q qd qa d), ou q represente *) (* l'ensemble des etats, qd ceux de depart, qa ceux d'arrivee, *) (* et d la relation de transition, comme la conjonction de : *) (* qd et qa sont inclus dans q , et d est inclus dans qxalphxq *) (* *) Require Import Ensf. Require Import Max. Require Import Words. Require Import Dec. Definition automate (q qd qa d : Ensf) : Prop := inclus qa q /\ inclus qd q /\ inclus d (prodcart q (prodcart alph q)). Lemma automate_def1 : forall q qd qa d : Ensf, automate q qd qa d -> inclus d (prodcart q (prodcart alph q)). (* Goal: forall (q qd qa d : Ensf) (_ : automate q qd qa d), inclus qa q *) intros q qd qa d H. (* Goal: automate q qd (sync_qa q qaA dA) (sync_d q dA) *) elim H. (* Goal: forall (_ : inclus qa q) (_ : and (inclus qd q) (inclus d (prodcart q (prodcart alph q)))), inclus qa q *) intros H1 H0; elim H0; clear H0. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) auto. Qed. Lemma automate_def2 : forall q qd qa d : Ensf, automate q qd qa d -> inclus qd q. (* Goal: forall (q qd qa d : Ensf) (_ : automate q qd qa d), inclus qa q *) intros q qd qa d H. (* Goal: automate q qd (sync_qa q qaA dA) (sync_d q dA) *) elim H. (* Goal: forall (_ : inclus qa q) (_ : and (inclus qd q) (inclus d (prodcart q (prodcart alph q)))), inclus qa q *) intros H1 H0; elim H0; clear H0. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) auto. Qed. Lemma automate_def3 : forall q qd qa d : Ensf, automate q qd qa d -> inclus qa q. (* Goal: forall (q qd qa d : Ensf) (_ : automate q qd qa d), inclus qa q *) intros q qd qa d H. (* Goal: automate q qd (sync_qa q qaA dA) (sync_d q dA) *) elim H. (* Goal: forall (_ : inclus qa q) (_ : and (inclus qd q) (inclus d (prodcart q (prodcart alph q)))), inclus qa q *) intros H1 H0; elim H0; clear H0. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) auto. Qed. (* *) (* On definit le predicat (chemin e1 e2 q d w), qui signifie : *) (* On passe de e1 a e2 par le mot w dans un automate d'ensemble *) (* d'etats q et de transition d. *) (* *) Inductive chemin : Elt -> Elt -> Ensf -> Ensf -> Word -> Prop := | chemin_nil : forall (e1 e2 : Elt) (q d : Ensf), dans e1 q -> e1 = e2 :>Elt -> chemin e1 e2 q d nil | chemin_cons : forall (e1 e2 : Elt) (q d : Ensf) (w : Word) (e a : Elt), chemin e1 e2 q d w -> dans e q -> dans a alph -> dans (couple e (couple a e1)) d -> chemin e e2 q d (cons a w). Hint Resolve chemin_nil. (* On definit le meme predicat d'une autre facon, qui sera plus utile *) (* par la suite *) Definition Chemin (e1 e2 : Elt) (q d : Ensf) (w : Word) : Prop := match w return Prop with | nil => (* nil *) dans e1 q /\ e1 = e2 :>Elt (* cons *) | cons a w' => exists e : Elt, chemin e e2 q d w' /\ dans e1 q /\ dans a alph /\ dans (couple e1 (couple a e)) d end. (* On montre l'equivalence entre les 2 definitions : *) Lemma Chemin_chemin : forall (e1 e2 : Elt) (q d : Ensf) (w : Word), Chemin e1 e2 q d w -> chemin e1 e2 q d w. (* Goal: forall (e1 e2 : Elt) (q d : Ensf) (w : Word) (_ : Chemin e1 e2 q d w), chemin e1 e2 q d w *) intros e1 e2 q d. (* Goal: forall (w : Word) (q qd qa d : Ensf) (_ : automate q qd qa d) (e1 e2 : Elt) (_ : chemin e1 e2 q d w), inmonoid alph w *) simple induction w. (* Goal: forall _ : and (inmonoid alph w) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) cut (dans e1 q /\ e1 = e2 :>Elt); auto. (* Goal: forall _ : and (dans e1 q) (@eq Elt e1 e2), chemin e1 e2 q d nil *) (* Goal: forall (e : Elt) (w : Word) (_ : forall _ : Chemin e1 e2 q d w, chemin e1 e2 q d w) (_ : Chemin e1 e2 q d (cons e w)), chemin e1 e2 q d (cons e w) *) intro H0; elim H0; clear H0. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) intros; apply chemin_nil; auto. (* Goal: forall (e : Elt) (w : Word) (_ : forall _ : Chemin e1 e2 q d w, chemin e1 e2 q d w) (_ : Chemin e1 e2 q d (cons e w)), chemin e1 e2 q d (cons e w) *) intros x w0 H H0. cut (exists e : Elt, chemin e e2 q d w0 /\ dans e1 q /\ dans x alph /\ dans (couple e1 (couple x e)) d); (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) auto. (* Goal: forall _ : @ex Elt (fun e : Elt => and (chemin e e2 q d w0) (and (dans e1 q) (and (dans x alph) (dans (couple e1 (couple x e)) d)))), chemin e1 e2 q d (cons x w0) *) intro H1; elim H1. (* Goal: forall (x0 : Elt) (_ : and (chemin x0 e2 q d w0) (and (dans e1 q) (and (dans x alph) (dans (couple e1 (couple x x0)) d)))), chemin e1 e2 q d (cons x w0) *) intros e H2; elim H2; clear H1 H2. (* Goal: forall (_ : chemin e e2 q d w0) (_ : and (dans e1 q) (and (dans x alph) (dans (couple e1 (couple x e)) d))), chemin e1 e2 q d (cons x w0) *) intros H1 H2; elim H2; clear H2. (* Goal: forall (_ : dans e1 q) (_ : and (dans x alph) (dans (couple e1 (couple x e)) d)), chemin e1 e2 q d (cons x w0) *) intros H2 H3; elim H3; clear H3. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intros. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply chemin_cons with e; auto. Qed. Hint Resolve Chemin_chemin. Lemma chemin_Chemin : forall (e1 e2 : Elt) (q d : Ensf) (w : Word), chemin e1 e2 q d w -> Chemin e1 e2 q d w. (* Goal: forall (e1 e2 : Elt) (q d : Ensf) (w : Word) (_ : chemin e1 e2 q d w), Chemin e1 e2 q d w *) intros e1 e2 q d w H; elim H; clear H. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intros. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) red in |- *; simpl in |- *; auto. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intros. (* Goal: Chemin e e3 q0 d0 (cons a w0) *) red in |- *; simpl in |- *. (* Goal: @ex Elt (fun e0 : Elt => and (chemin e0 e3 q0 d0 w0) (and (dans e q0) (and (dans a alph) (dans (couple e (couple a e0)) d0)))) *) exists e0. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) auto. Qed. Hint Resolve chemin_Chemin. (* *) (* Si (q,qd,qa,d) est un automate alors (reconnait q qd qa d) est le *) (* langage reconnu par cet automate. *) (* On le definit est disant que w est dans ce langage s'il est tout *) (* d'abord dans le monoid libre engendre par alph, et s'il existe *) (* 2 etats e1 et e2, repsectivement dans qd et qa, tels que *) (* (chemin e1 e2 q d w) soit vrai. *) (* *) Definition reconnait (q qd qa d : Ensf) (w : Word) : Prop := inmonoid alph w /\ (exists e1 : Elt, (exists e2 : Elt, dans e1 qd /\ dans e2 qa /\ chemin e1 e2 q d w)). (* *) (* Si on a un chemin de e1 a e2 alors e1 et e2 sont dans q. *) (* *) Lemma dans_e1_q : forall (q d : Ensf) (w : Word) (e1 e2 : Elt), chemin e1 e2 q d w -> dans e1 q. (* Goal: forall (q d : Ensf) (w : Word) (e1 e2 : Elt) (_ : chemin e1 e2 q d w), dans e2 q *) intros q d. (* Goal: forall (w : Word) (q qd qa d : Ensf) (_ : automate q qd qa d) (e1 e2 : Elt) (_ : chemin e1 e2 q d w), inmonoid alph w *) simple induction w. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intros. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) cut (Chemin e1 e2 q d nil); auto. (* Goal: forall _ : and (inmonoid alph w) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) cut (dans e1 q /\ e1 = e2 :>Elt); auto. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) intro Ht; elim Ht; auto. (* Goal: forall (e : Elt) (w : Word) (_ : forall (e1 e2 : Elt) (_ : chemin e1 e2 q d w), dans e2 q) (e1 e2 : Elt) (_ : chemin e1 e2 q d (cons e w)), dans e2 q *) intros x w0 H e1 e2 H0. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) cut (Chemin e1 e2 q d (cons x w0)); auto. (* Goal: forall _ : and (inmonoid alph w) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro. cut (exists e : Elt, chemin e e2 q d w0 /\ dans e1 q /\ dans x alph /\ dans (couple e1 (couple x e)) d); (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) auto. (* Goal: forall _ : @ex Elt (fun e : Elt => and (chemin e e2 q d w0) (and (dans e1 q) (and (dans x alph) (dans (couple e1 (couple x e)) d)))), dans e2 q *) intro Ht; elim Ht; clear Ht. (* Goal: forall (x0 : Elt) (_ : and (chemin x0 e2 q d w0) (and (dans e1 q) (and (dans x alph) (dans (couple e1 (couple x x0)) d)))), dans e2 q *) intros e Ht; elim Ht; clear Ht. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) intros H2 Ht; elim Ht; auto. Qed. Lemma dans_e2_q : forall (q d : Ensf) (w : Word) (e1 e2 : Elt), chemin e1 e2 q d w -> dans e2 q. (* Goal: forall (q d : Ensf) (w : Word) (e1 e2 : Elt) (_ : chemin e1 e2 q d w), dans e2 q *) intros q d. (* Goal: forall (w : Word) (q qd qa d : Ensf) (_ : automate q qd qa d) (e1 e2 : Elt) (_ : chemin e1 e2 q d w), inmonoid alph w *) simple induction w. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intros. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) cut (Chemin e1 e2 q d nil); auto. (* Goal: forall _ : and (inmonoid alph w) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) cut (dans e1 q /\ e1 = e2 :>Elt); auto. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) intro Ht; elim Ht; auto. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intros. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) rewrite <- H2; auto. (* Goal: forall (e : Elt) (w : Word) (_ : forall (e1 e2 : Elt) (_ : chemin e1 e2 q d w), dans e2 q) (e1 e2 : Elt) (_ : chemin e1 e2 q d (cons e w)), dans e2 q *) intros x w0 H e1 e2 H0. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) cut (Chemin e1 e2 q d (cons x w0)); auto. (* Goal: forall _ : and (inmonoid alph w) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro. cut (exists e : Elt, chemin e e2 q d w0 /\ dans e1 q /\ dans x alph /\ dans (couple e1 (couple x e)) d); (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) auto. (* Goal: forall _ : @ex Elt (fun e : Elt => and (chemin e e2 q d w0) (and (dans e1 q) (and (dans x alph) (dans (couple e1 (couple x e)) d)))), dans e2 q *) intro Ht; elim Ht; clear Ht. (* Goal: forall (x0 : Elt) (_ : and (chemin x0 e2 q d w0) (and (dans e1 q) (and (dans x alph) (dans (couple e1 (couple x x0)) d)))), dans e2 q *) intros e Ht; elim Ht; clear Ht. (* Goal: forall (_ : chemin e e2 q d w0) (_ : and (dans e1 q) (and (dans x alph) (dans (couple e1 (couple x e)) d))), dans e2 q *) intros H2 Ht. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply (H e e2); auto. Qed. (* *) (* Un chemin est un mot sur X *) (* *) Lemma Cheminmonoid : forall (w : Word) (q qd qa d : Ensf), automate q qd qa d -> forall e1 e2 : Elt, chemin e1 e2 q d w -> inmonoid alph w. (* Goal: forall (w : Word) (q qd qa d : Ensf) (_ : automate q qd qa d) (e1 e2 : Elt) (_ : chemin e1 e2 q d w), inmonoid alph w *) simple induction w. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) auto. (* Goal: forall (e : Elt) (w : Word) (_ : forall (q qd qa d : Ensf) (_ : automate q qd qa d) (e1 e2 : Elt) (_ : chemin e1 e2 q d w), inmonoid alph w) (q qd qa d : Ensf) (_ : automate q qd qa d) (e1 e2 : Elt) (_ : chemin e1 e2 q d (cons e w)), inmonoid alph (cons e w) *) intros x w0 H q qd qa d H0 e1 e2 H1. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) cut (Chemin e1 e2 q d (cons x w0)); auto. (* Goal: forall _ : and (inmonoid alph w) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro. cut (exists e : Elt, chemin e e2 q d w0 /\ dans e1 q /\ dans x alph /\ dans (couple e1 (couple x e)) d); (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) auto. (* Goal: forall _ : @ex Elt (fun e : Elt => and (chemin e e2 q d w0) (and (dans e1 q) (and (dans x alph) (dans (couple e1 (couple x e)) d)))), inmonoid alph (cons x w0) *) intro H3; elim H3; clear H3. (* Goal: forall (x0 : Elt) (_ : and (chemin x0 e2 q d w0) (and (dans e1 q) (and (dans x alph) (dans (couple e1 (couple x x0)) d)))), inmonoid alph (cons x w0) *) intros e H3; elim H3; clear H3. (* Goal: forall (_ : chemin e e2 q d w0) (_ : and (dans e1 q) (and (dans x alph) (dans (couple e1 (couple x e)) d))), inmonoid alph (cons x w0) *) intros H3 H4; elim H4; clear H4. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intros H4 H5; elim H5; clear H5; intros. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply inmonoid_cons; auto. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply (H q qd qa d H0 e e2); auto. Qed. (* *) (* Si le triplet (e1,x,e2) est dans d alors on a *) (* (chemin e1 e2 q d (cons x nil)) *) (* *) Lemma chemin_lettre : forall (e1 e2 x : Elt) (q d : Ensf), dans x alph -> dans e1 q -> dans e2 q -> dans (couple e1 (couple x e2)) d -> chemin e1 e2 q d (cons x nil). (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intros. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply chemin_cons with e2; auto. Qed. (* *) (* AUTOMATES ASYNCHRONES *) (* *) Definition automate_A (q qd qa d : Ensf) : Prop := inclus qa q /\ inclus qd q /\ inclus d (prodcart q (prodcart (add epsilon alph) q)). Lemma automate_A_def2 : forall q qd qa d : Ensf, automate_A q qd qa d -> inclus qd q. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intros. (* Goal: automate q qd (sync_qa q qaA dA) (sync_d q dA) *) elim H. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) intros H0 Ht; elim Ht; auto. Qed. (* *) (* On va definir de meme la notion de chemin sur un automate *) (* asynchrone en rajoutant les transitions par epsilon. *) (* *) Inductive chemin_A (q d : Ensf) : Elt -> Elt -> Word -> Prop := | chemin_A_nil : forall e1 e2 : Elt, dans e1 q -> e1 = e2 :>Elt -> chemin_A q d e1 e2 nil | chemin_A_cons : forall (e1 e e2 x : Elt) (w : Word), chemin_A q d e e2 w -> dans e1 q -> dans x alph -> dans (couple e1 (couple x e)) d -> chemin_A q d e1 e2 (cons x w) | chemin_A_epsilon : forall (e1 e e2 : Elt) (w : Word), chemin_A q d e e2 w -> dans e1 q -> dans (couple e1 (couple epsilon e)) d -> chemin_A q d e1 e2 w. Hint Resolve chemin_A_nil. (* Inversion de la definition... *) Definition Chemin_A (q d : Ensf) (e1 e2 : Elt) (w : Word) : Prop := match w return Prop with | nil => (* nil *) dans e1 q /\ e1 = e2 :>Elt \/ (exists e : Elt, chemin_A q d e e2 nil /\ dans e1 q /\ dans (couple e1 (couple epsilon e)) d) (* cons *) | cons a w => (exists e : Elt, chemin_A q d e e2 w /\ dans e1 q /\ dans a alph /\ dans (couple e1 (couple a e)) d) \/ (exists e : Elt, chemin_A q d e e2 w /\ dans e1 q /\ dans (couple e1 (couple epsilon e)) d) end. (* Si on a un chemin pour une relation de transition d1 alors on a *) (* le meme chemin pour toute relation de transition contenant d1. *) Lemma chemin_A_d1_d2 : forall (q d1 d2 : Ensf) (w : Word) (e1 e2 : Elt), chemin_A q d1 e1 e2 w -> inclus d1 d2 -> chemin_A q d2 e1 e2 w. (* Goal: forall (q d1 d2 : Ensf) (w : Word) (e1 e2 : Elt) (_ : chemin_A q d1 e1 e2 w) (_ : inclus d1 d2), chemin_A q d2 e1 e2 w *) intros q d d2 w e1 e2 H. (* Goal: chemin_A q d e1 e2 w *) elim H; clear H. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) auto. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intros. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply chemin_A_cons with e; auto. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intros. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply chemin_A_epsilon with e; auto. Qed. (* De meme pour deux ensembles d'etats q1 et q2 tesl que q1 est inclus *) (* dans q2. *) Lemma chemin_A_q1_q2 : forall (q1 q2 d : Ensf) (e1 e2 : Elt) (w : Word), chemin_A q1 d e1 e2 w -> inclus q1 q2 -> chemin_A q2 d e1 e2 w. (* Goal: forall (q1 q2 d : Ensf) (e1 e2 : Elt) (w : Word) (_ : chemin_A q1 d e1 e2 w) (_ : inclus q1 q2), chemin_A q2 d e1 e2 w *) intros q1 q2 d w e1 e2 H. (* Goal: chemin_A q d e1 e2 w *) elim H; clear H. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) auto. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intros. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply chemin_A_cons with e; auto. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intros. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply chemin_A_epsilon with e; auto. Qed. (* Si on a un chemin au sens des AF alors on a un chemin au sens des *) (* AA. *) Lemma chemin_chemin_A : forall (q d : Ensf) (w : Word) (e1 e2 : Elt), chemin e1 e2 q d w -> chemin_A q d e1 e2 w. (* Goal: forall (q d : Ensf) (w : Word) (e1 e2 : Elt) (_ : chemin e1 e2 q d w), chemin_A q d e1 e2 w *) intros q d w e1 e2 H. (* Goal: chemin_A q d e1 e2 w *) elim H; clear H. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) auto. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intros. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply chemin_A_cons with e0; auto. Qed. (* *) (* Si on va de e1 a e par w1 et de e a e2 par w2 alors on va de *) (* e1 a e2 par (Append w1 w2). *) (* *) Lemma chemin_Append : forall (e1 e e2 : Elt) (q d : Ensf) (w1 w2 : Word), chemin_A q d e1 e w1 -> chemin_A q d e e2 w2 -> chemin_A q d e1 e2 (Append w1 w2). (* Goal: forall (e1 e e2 : Elt) (q d : Ensf) (w1 w2 : Word) (_ : chemin_A q d e1 e w1) (_ : chemin_A q d e e2 w2), chemin_A q d e1 e2 (Append w1 w2) *) intros e1 e e2 q d w1 w2 H. (* Goal: automate q qd (sync_qa q qaA dA) (sync_d q dA) *) elim H. (* Goal: forall (e1 e3 : Elt) (_ : dans e1 q) (_ : @eq Elt e1 e3) (_ : chemin_A q d e3 e2 w2), chemin_A q d e1 e2 (Append nil w2) *) (* Goal: forall (e1 e e3 x : Elt) (w : Word) (_ : chemin_A q d e e3 w) (_ : forall _ : chemin_A q d e3 e2 w2, chemin_A q d e e2 (Append w w2)) (_ : dans e1 q) (_ : dans x alph) (_ : dans (couple e1 (couple x e)) d) (_ : chemin_A q d e3 e2 w2), chemin_A q d e1 e2 (Append (cons x w) w2) *) (* Goal: forall (e1 e e3 : Elt) (w : Word) (_ : chemin_A q d e e3 w) (_ : forall _ : chemin_A q d e3 e2 w2, chemin_A q d e e2 (Append w w2)) (_ : dans e1 q) (_ : dans (couple e1 (couple epsilon e)) d) (_ : chemin_A q d e3 e2 w2), chemin_A q d e1 e2 (Append w w2) *) intros e0 e3 H0 H1 H2. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) simpl in |- *; rewrite H1; auto. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intros. (* Goal: chemin_A q d e0 e2 (Append (cons x w) w2) *) (* Goal: forall (e1 e e3 : Elt) (w : Word) (_ : chemin_A q d e e3 w) (_ : forall _ : chemin_A q d e3 e2 w2, chemin_A q d e e2 (Append w w2)) (_ : dans e1 q) (_ : dans (couple e1 (couple epsilon e)) d) (_ : chemin_A q d e3 e2 w2), chemin_A q d e1 e2 (Append w w2) *) simpl in |- *. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) cut (chemin_A q d e3 e2 (Append w w2)); auto. (* Goal: forall _ : and (inmonoid alph w) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply chemin_A_cons with e3; auto. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intros. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) cut (chemin_A q d e3 e2 (Append w w2)); auto. (* Goal: forall _ : and (inmonoid alph w) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply chemin_A_epsilon with e3; auto. Qed. (* *) (* Si on a un cheminA de e1 a e2 alors e1 et e2 sont dans q. *) (* *) Lemma dansA_e1_q : forall (q d : Ensf) (w : Word) (e1 e2 : Elt), chemin_A q d e1 e2 w -> dans e1 q. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intros. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) elim H; auto. Qed. Lemma dansA_e2_q : forall (q d : Ensf) (w : Word) (e1 e2 : Elt), chemin_A q d e1 e2 w -> dans e2 q. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intros. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) elim H; auto. (* Goal: forall (e1 e2 : Elt) (_ : dans e1 q) (_ : @eq Elt e1 e2), dans e2 q *) intros e0 e3 H0 H1. (* Goal: dans e3 q *) rewrite <- H1. (* Goal: inmonoid alph w *) assumption. Qed. (* *) (* Un mot reconnu par un automate_A est dans le monoide engendre par *) (* alph. *) (* *) Lemma cheminA_monoid : forall (w : Word) (q qd qaA dA : Ensf), automate_A q qd qaA dA -> forall e1 e2 : Elt, chemin_A q dA e1 e2 w -> inmonoid alph w. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intros. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) elim H0; auto. Qed. (* Pour un chemin de la forme (cons x w) il existe un etat *) (* intermediaire. *) (*--- Lemma chemin_A2_cons_inv : (q,dA:Ensf)(w:Word)(e1,e2,x:Elt) (chemin_A2 q dA (cons x w) e2 e1) -> (<Elt>Ex ([e:Elt]( (chemin_A2 q dA (cons x nil) e e1) /\ (chemin_A2 q dA w e2 e) ))). Intros. Elim H. Intros. Cut (Chemin e0 e2 q dA (cons x w)); Auto. Intro. Cut (<Elt> Ex ([e:Elt] (chemin e e2 q dA w) /\ (dans e0 q) /\ (dans x alph) /\ (dans (couple e0 (couple x e)) dA)) ); Auto. Intro Ht; Elim Ht; Clear Ht. Intros e Ht; Elim Ht; Clear Ht. Intros H3 Ht; Elim Ht; Clear Ht. Intros H4 Ht; Elim Ht; Clear Ht. Intros H5 H6. Exists e. Split. 2:Apply chemin_A2_un; Auto. 2:Apply (inmonoid_cons_inv alph w x); Auto. Cut (chemin e0 e q dA (cons x nil)); Auto. Apply (chemin_cons e e q dA nil e0 x); Auto. Apply chemin_nil; Auto. Apply (dans_e1_q q dA w e e2); Auto. Intros. Elim H1. Intros e0' Ht; Elim Ht; Clear Ht. Intros H4 H5. Exists e0'. Split; Auto. Apply chemin_A2_deux with e; Auto. Save. Lemma chemin_A_cons_inv : (q,dA:Ensf)(w:Word)(e1,e2,x:Elt) (chemin_A e1 e2 q dA (cons x w)) -> (<Elt>Ex ([e:Elt]( (chemin_A e1 e q dA (cons x nil)) /\ (chemin_A e e2 q dA w) ))). Goal. Cut (<Elt>Ex ([e:Elt]( (chemin_A2 q dA (cons x nil) e e1) /\ (chemin_A2 q dA w e2 e) ))). 2:Apply chemin_A2_cons_inv; Auto. Intro Ht; Elim Ht; Clear Ht. Intros e Ht; Elim Ht; Clear Ht. Intros H0 H1. Exists e. Auto. Save. ---*) (* De meme on definit reconnait_A... *) Definition reconnait_A (q qd qa d : Ensf) (w : Word) : Prop := inmonoid alph w /\ (exists e1 : Elt, (exists e2 : Elt, dans e1 qd /\ dans e2 qa /\ chemin_A q d e1 e2 w)). (* *) (* A partir d'une relation de transition asynchrone dA construisons *) (* la relation synchrone d correspondante. On elimine les transitions *) (* avec epsilon en disant : *) (* dans (e,a,e') d <-> (chemin_A e e' q dA (cons a nil)) *) (* *) Definition est_dans_d2 (q dA : Ensf) (e y : Elt) : Prop := match y return Prop with | natural n => (* natural *) False (* couple *) | couple a e' => chemin_A q dA e e' (cons a nil) (* up *) | up e => False (* word *) | word w => False end. Definition est_dans_d (q dA : Ensf) (x : Elt) : Prop := match x return Prop with | natural n => (* natural *) False (* couple *) | couple e y => est_dans_d2 q dA e y (* up *) | up e => False (* word *) | word w => False end. Definition sync_d (q dA : Ensf) : Ensf := tq (est_dans_d q dA) (prodcart q (prodcart alph q)). Definition sync_qa (q qaA dA : Ensf) : Ensf := union qaA (tq (fun e : Elt => exists e' : Elt, dans e' qaA /\ chemin_A q dA e e' nil) q). Hint Unfold sync_qa. (* Les etats de d'arrivee de l'automate fini comprennent ceux de *) (* l'automate asynchrone. *) Lemma inclus_qaA_qa : forall q qaA dA : Ensf, inclus qaA (sync_qa q qaA dA). (* Goal: inclus (sync_qa q qaA dA) q *) (* Goal: and (inclus qd q) (inclus (sync_d q dA) (prodcart q (prodcart alph q))) *) unfold sync_qa in |- *. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) auto. Qed. (* Par definition on a... *) Lemma nouvx_dans_qa : forall (q qaA dA : Ensf) (e : Elt), dans e q -> (exists e' : Elt, dans e' qaA /\ chemin_A q dA e e' nil) -> dans e (sync_qa q qaA dA). (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intros. (* Goal: dans e (sync_qa q qaA dA) *) elim H0; clear H0. (* Goal: forall (x : Elt) (_ : and (dans x qaA) (chemin_A q dA e x nil)), dans e (sync_qa q qaA dA) *) intros e' Ht; elim Ht; clear Ht. (* Goal: forall (_ : dans e' qaA) (_ : chemin_A q dA e e' nil), dans e (sync_qa q qaA dA) *) intros H0 H1. (* Goal: inclus (sync_qa q qaA dA) q *) (* Goal: and (inclus qd q) (inclus (sync_d q dA) (prodcart q (prodcart alph q))) *) unfold sync_qa in |- *. (* Goal: dans e (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply union_d. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply imp_dans_tq; auto. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) exists e'; auto. Qed. (* et aussi... *) Lemma sync_d_def : forall (e1 e2 x : Elt) (q dA : Ensf), dans x alph -> chemin_A q dA e1 e2 (cons x nil) -> dans (couple e1 (couple x e2)) (sync_d q dA). (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intros. (* Goal: inclus (sync_d q dA) (prodcart q (prodcart alph q)) *) unfold sync_d in |- *. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply imp_dans_tq; auto. (* Goal: dans (couple e1 (couple x e2)) (prodcart q (prodcart alph q)) *) apply coupl2_inv. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply (dansA_e1_q q dA (cons x nil) e1 e2); auto. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply coupl2_inv; auto. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply (dansA_e2_q q dA (cons x nil) e1 e2); auto. Qed. Lemma sync_d_def2 : forall (e1 e2 x : Elt) (q dA : Ensf), dans x alph -> dans (couple e1 (couple x e2)) (sync_d q dA) -> chemin_A q dA e1 e2 (cons x nil). intros e1 e2 x q dA H. (* Goal: inclus (sync_d q dA) (prodcart q (prodcart alph q)) *) unfold sync_d in |- *. (* Goal: forall _ : and (inmonoid alph w) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro. cut (dans (couple e1 (couple x e2)) (prodcart q (prodcart alph q)) /\ est_dans_d q dA (couple e1 (couple x e2))). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply dans_tq_imp; auto. (* Goal: forall _ : @ex Elt (fun e : Elt => and (chemin e e2 q d w0) (and (dans e1 q) (and (dans x alph) (dans (couple e1 (couple x e)) d)))), dans e2 q *) intro Ht; elim Ht; clear Ht. intro H1. unfold est_dans_d in |- *. unfold est_dans_d2 in |- *. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) auto. Qed. Lemma trans_dA_d : forall (q dA : Ensf) (e0 e x : Elt), dans e0 q -> dans x alph -> dans e q -> dans (couple e0 (couple x e)) dA -> dans (couple e0 (couple x e)) (sync_d q dA). (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intros. (* Goal: dans (couple e0 (couple x e)) (sync_d q dA) *) cut (chemin_A q dA e0 e (cons x nil)). (* Goal: forall _ : and (inmonoid alph w) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro. (* Goal: inclus (sync_d q dA) (prodcart q (prodcart alph q)) *) unfold sync_d in |- *. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply imp_dans_tq; auto. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) cut (chemin_A q dA e e nil); auto. (* Goal: forall _ : and (inmonoid alph w) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply chemin_A_cons with e; auto. Qed. (* *) (* Commencons par montrer que si (q,qd,qaA,dA) est un automate alors *) (* (q,qd,qa,d) en est un aussi, ou qa=(sunc_qa q qaA dA) et *) (* d=(sync_d q dA). *) (* *) Lemma automateA_automate : forall q qd qaA dA : Ensf, automate_A q qd qaA dA -> automate q qd (sync_qa q qaA dA) (sync_d q dA). (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intros. (* Goal: automate q qd (sync_qa q qaA dA) (sync_d q dA) *) elim H. (* Goal: forall (_ : inclus qaA q) (_ : and (inclus qd q) (inclus dA (prodcart q (prodcart (add epsilon alph) q)))), automate q qd (sync_qa q qaA dA) (sync_d q dA) *) intros H1 H2; elim H2; clear H2; intros H2 H3. (* Goal: automate q qd (sync_qa q qaA dA) (sync_d q dA) *) red in |- *. (* Goal: forall w : Word, and (forall _ : reconnait_A q qd qaA dA w, reconnait q qd (sync_qa q qaA dA) (sync_d q dA) w) (forall _ : reconnait q qd (sync_qa q qaA dA) (sync_d q dA) w, reconnait_A q qd qaA dA w) *) split. (* Goal: inclus (sync_qa q qaA dA) q *) (* Goal: and (inclus qd q) (inclus (sync_d q dA) (prodcart q (prodcart alph q))) *) unfold sync_qa in |- *. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply union_inclus; auto. (* Goal: inclus (tq (est_dans_d q dA) (prodcart q (prodcart alph q))) (prodcart q (prodcart alph q)) *) apply inclus_tq. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) split; auto. (* Goal: inclus (sync_d q dA) (prodcart q (prodcart alph q)) *) unfold sync_d in |- *. (* Goal: inclus (tq (est_dans_d q dA) (prodcart q (prodcart alph q))) (prodcart q (prodcart alph q)) *) apply inclus_tq. Qed. (* *) (* Si on a un chemin de e a e2 dans l'automate fini, avec e2 etat *) (* d'arrivee, et s'il y a une transition de e1 a e2 par epsilon, *) (* alors il y a un chemin de e1 a e2' par le meme mot, avec e2' *) (* etat d'arrivee. *) (* *) Lemma epsilon_chemin : forall (q qaA dA : Ensf) (w : Word) (e1 e e2 : Elt), chemin e e2 q (sync_d q dA) w -> dans (couple e1 (couple epsilon e)) dA -> dans e2 (sync_qa q qaA dA) -> dans e1 q -> exists e2' : Elt, chemin e1 e2' q (sync_d q dA) w /\ dans e2' (sync_qa q qaA dA). intros q qaA dA. (* Goal: forall (w : Word) (q qd qa d : Ensf) (_ : automate q qd qa d) (e1 e2 : Elt) (_ : chemin e1 e2 q d w), inmonoid alph w *) simple induction w. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intros. exists e1. (* Goal: forall w : Word, and (forall _ : reconnait_A q qd qaA dA w, reconnait q qd (sync_qa q qaA dA) (sync_d q dA) w) (forall _ : reconnait q qd (sync_qa q qaA dA) (sync_d q dA) w, reconnait_A q qd qaA dA w) *) split. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) auto. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) cut (Chemin e e2 q (sync_d q dA) nil); auto. intro H3. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) cut (dans e q /\ e = e2 :>Elt); auto. (* Goal: forall _ : @ex Elt (fun e : Elt => and (chemin e e2 q d w0) (and (dans e1 q) (and (dans x alph) (dans (couple e1 (couple x e)) d)))), dans e2 q *) intro Ht; elim Ht; clear Ht. intros H4 H5. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) cut (chemin_A q dA e e2 nil); auto. cut (chemin_A q dA e1 e2 nil). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply chemin_A_epsilon with e; auto. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intros. unfold sync_qa in H1. cut (dans e2 qaA \/ dans e2 (tq (fun e : Elt => exists e' : Elt, dans e' qaA /\ chemin_A q dA e e' nil) q)). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply dans_union; auto. (* Goal: forall _ : @ex Elt (fun e : Elt => and (chemin e e2 q d w0) (and (dans e1 q) (and (dans x alph) (dans (couple e1 (couple x e)) d)))), dans e2 q *) intro Ht; elim Ht; clear Ht. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) intro; apply nouvx_dans_qa; auto. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) exists e2; auto. (* Goal: forall _ : and (inmonoid alph w) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro. cut (dans e2 q /\ (fun e : Elt => exists e' : Elt, dans e' qaA /\ chemin_A q dA e e' nil) e2). 2: apply dans_tq_imp with (f := fun e : Elt => ex (fun e' : Elt => dans e' qaA /\ chemin_A q dA e e' nil)); (* Goal: inmonoid alph w *) assumption. (* Goal: forall _ : @ex Elt (fun e : Elt => and (chemin e e2 q d w0) (and (dans e1 q) (and (dans x alph) (dans (couple e1 (couple x e)) d)))), dans e2 q *) intro Ht; elim Ht; clear Ht. intros H9 Ht; elim Ht; clear Ht. intros e3 Ht; elim Ht; clear Ht. intros H10 H11. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) cut (chemin_A q dA e e3 nil); auto. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: rewrite H5; auto. intro H12. cut (chemin_A q dA e1 e3 nil). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply chemin_A_epsilon with e; auto. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) intro; apply nouvx_dans_qa; auto. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) exists e3; auto. intros x w0 H e1 e e2 H0 H1 H2 H3. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) cut (Chemin e e2 q (sync_d q dA) (cons x w0)); auto. (* Goal: forall _ : and (inmonoid alph w) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro. cut (exists e22 : Elt, chemin e22 e2 q (sync_d q dA) w0 /\ dans e q /\ dans x alph /\ dans (couple e (couple x e22)) (sync_d q dA)); (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) auto. (* Goal: forall _ : @ex Elt (fun e : Elt => and (chemin e e2 q d w0) (and (dans e1 q) (and (dans x alph) (dans (couple e1 (couple x e)) d)))), dans e2 q *) intro Ht; elim Ht; clear Ht. intros e22 Ht; elim Ht; clear Ht. intros H5 Ht; elim Ht; clear Ht. intros H6 Ht; elim Ht; clear Ht; intros H7 H8. exists e2. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) split; auto. cut (chemin_A q dA e e22 (cons x nil)). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply sync_d_def2; auto. (* Goal: forall _ : and (inmonoid alph w) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro. cut (chemin_A q dA e1 e22 (cons x nil)). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply chemin_A_epsilon with e; auto. (* Goal: forall _ : and (inmonoid alph w) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro. cut (dans (couple e1 (couple x e22)) (sync_d q dA)). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply sync_d_def; auto. (* Goal: forall _ : and (inmonoid alph w) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply chemin_cons with e22; auto. Qed. (* *) (* Si on a un chemin de e1 a e2 par w dans un automate asynchrone *) (* avec e2 etat d'arrivee, alors il existe un etat d'arrivee e2' *) (* de l'automate fini correspondant et un chemin de e1 a e2 par w *) (* dans cet automate. *) (* *) Lemma cheminA_chemin : forall q qd qaA dA : Ensf, automate_A q qd qaA dA -> forall (w : Word) (e1 e2 : Elt), chemin_A q dA e1 e2 w -> dans e2 qaA -> exists e2' : Elt, chemin e1 e2' q (sync_d q dA) w /\ dans e2' (sync_qa q qaA dA). intros q qd qaA dA H_aut w. cut (inclus qaA (sync_qa q qaA dA)). 2: apply inclus_qaA_qa. intro H0. intros e1 e2 H1. elim H1. intros e0 e3 H H2 H3. (* Goal: @ex Elt (fun e0 : Elt => and (chemin e0 e3 q0 d0 w0) (and (dans e q0) (and (dans a alph) (dans (couple e (couple a e0)) d0)))) *) exists e0. (* Goal: forall w : Word, and (forall _ : reconnait_A q qd qaA dA w, reconnait q qd (sync_qa q qaA dA) (sync_d q dA) w) (forall _ : reconnait q qd (sync_qa q qaA dA) (sync_d q dA) w, reconnait_A q qd qaA dA w) *) split. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply chemin_nil; auto. rewrite H2. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply dans_trans with qaA; auto. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intros. cut (exists e2' : Elt, chemin e e2' q (sync_d q dA) w0 /\ dans e2' (sync_qa q qaA dA)); (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) auto. (* Goal: forall _ : @ex Elt (fun e : Elt => and (chemin e e2 q d w0) (and (dans e1 q) (and (dans x alph) (dans (couple e1 (couple x e)) d)))), dans e2 q *) intro Ht; elim Ht; clear Ht. intros e2' Ht; elim Ht; clear Ht. intros H7 H8. exists e2'. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) split; auto. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply chemin_cons with e; auto. cut (dans e q). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply (dans_e1_q q (sync_d q dA) w0 e e2'); auto. intro dans_e_q. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply trans_dA_d; auto. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intros. cut (exists e2' : Elt, chemin e e2' q (sync_d q dA) w0 /\ dans e2' (sync_qa q qaA dA)); (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) auto. (* Goal: forall _ : @ex Elt (fun e : Elt => and (chemin e e2 q d w0) (and (dans e1 q) (and (dans x alph) (dans (couple e1 (couple x e)) d)))), dans e2 q *) intro Ht; elim Ht; clear Ht. intros e9 Ht; elim Ht; clear Ht. intros H6 H7. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply (epsilon_chemin q qaA dA w0 e0 e e9); auto. Qed. (* *) (* Montrons maintenant que si (q,qd,qaA,dA) est un automate async. *) (* alors (reconnait_A q qd qaA dA w) -> (reconnait q qd qa d w) *) (* ou qa=(sunc_qa q qaA dA) et d=(sync_d q dA). *) (* *) Lemma reconnaitA_reconnait : forall (q qd qaA dA : Ensf) (w : Word), automate_A q qd qaA dA -> reconnait_A q qd qaA dA w -> reconnait q qd (sync_qa q qaA dA) (sync_d q dA) w. intros q qd qaA dA w H_aut. unfold reconnait_A in |- *. (* Goal: chemin_A q d e1 e2 w *) intro H; elim H; clear H. (* Goal: chemin_A q d e1 e2 w *) intros H1 H; elim H; clear H. (* Goal: chemin_A q d e1 e2 w *) intros e1 H; elim H; clear H. (* Goal: chemin_A q d e1 e2 w *) intros e2 H; elim H; clear H. intros H2 H; elim H; clear H; intros H3 H4. unfold reconnait in |- *. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) split; auto. exists e1. cut (exists e2' : Elt, chemin e1 e2' q (sync_d q dA) w /\ dans e2' (sync_qa q qaA dA)). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply (cheminA_chemin q qd qaA dA H_aut w e1 e2); auto. (* Goal: forall _ : @ex Elt (fun e : Elt => and (chemin e e2 q d w0) (and (dans e1 q) (and (dans x alph) (dans (couple e1 (couple x e)) d)))), dans e2 q *) intro Ht; elim Ht; clear Ht. intros e2' Ht; elim Ht; clear Ht. intros H5 H6. exists e2'. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) auto. Qed. (* *) (* Reciproquement, si on a un chemin de e1 a e2 dans l'automate fini *) (* correspondant a un automate asynchrone, alors on a un chemin de e1 *) (* a e2 dans l'automate asynchrone. *) (* *) Lemma chemin_cheminA : forall q qd qaA dA : Ensf, automate_A q qd qaA dA -> forall (w : Word) (e1 e2 : Elt), chemin e1 e2 q (sync_d q dA) w -> chemin_A q dA e1 e2 w. intros q qd qaA dA H_aut. (* Goal: forall (w : Word) (q qd qa d : Ensf) (_ : automate q qd qa d) (e1 e2 : Elt) (_ : chemin e1 e2 q d w), inmonoid alph w *) simple induction w. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intros. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) cut (Chemin e1 e2 q (sync_d q dA) nil); auto. (* Goal: forall _ : and (inmonoid alph w) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) cut (dans e1 q /\ e1 = e2 :>Elt); auto. (* Goal: forall _ : @ex Elt (fun e : Elt => and (chemin e e2 q d w0) (and (dans e1 q) (and (dans x alph) (dans (couple e1 (couple x e)) d)))), dans e2 q *) intro Ht; elim Ht; clear Ht. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) intros; apply chemin_A_nil; auto. (* Goal: forall (e : Elt) (w : Word) (_ : forall (e1 e2 : Elt) (_ : chemin e1 e2 q d w), dans e2 q) (e1 e2 : Elt) (_ : chemin e1 e2 q d (cons e w)), dans e2 q *) intros x w0 H e1 e2 H0. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) cut (Chemin e1 e2 q (sync_d q dA) (cons x w0)); auto. intro H1. cut (exists e : Elt, chemin e e2 q (sync_d q dA) w0 /\ dans e1 q /\ dans x alph /\ dans (couple e1 (couple x e)) (sync_d q dA)); (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) auto. (* Goal: forall _ : @ex Elt (fun e : Elt => and (chemin e e2 q d w0) (and (dans e1 q) (and (dans x alph) (dans (couple e1 (couple x e)) d)))), dans e2 q *) intro Ht; elim Ht; clear Ht. (* Goal: forall (x0 : Elt) (_ : and (chemin x0 e2 q d w0) (and (dans e1 q) (and (dans x alph) (dans (couple e1 (couple x x0)) d)))), dans e2 q *) intros e Ht; elim Ht; clear Ht. intros H2 Ht; elim Ht; clear Ht. intros H3 H4. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) cut (chemin_A q dA e e2 w0); auto. (* Goal: forall _ : and (inmonoid alph w) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro. elim H4; clear H4; intros H4 H6. cut (chemin_A q dA e1 e (cons x nil)). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply sync_d_def2; auto. (* Goal: forall _ : and (inmonoid alph w) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) replace (cons x w0) with (Append (cons x nil) w0); auto. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply chemin_Append with e; auto. Qed. (* *) (* On en deduit qu'un mot reconnu par l'automate fini associe a un *) (* automate asynchrone etait reconnu par l'automate asynchrone. *) (* *) Lemma reconnait_reconnaitA : forall (q qd qaA dA : Ensf) (w : Word), automate_A q qd qaA dA -> reconnait q qd (sync_qa q qaA dA) (sync_d q dA) w -> reconnait_A q qd qaA dA w. intros q qd qaA dA w H_aut. unfold reconnait in |- *. (* Goal: forall _ : @ex Elt (fun e : Elt => and (chemin e e2 q d w0) (and (dans e1 q) (and (dans x alph) (dans (couple e1 (couple x e)) d)))), dans e2 q *) intro Ht; elim Ht; clear Ht. intros H Ht; elim Ht; clear Ht. intros e1 Ht; elim Ht; clear Ht. intros e2 Ht; elim Ht; clear Ht. intros H0 Ht; elim Ht; clear Ht. intros H1 H2. cut (dans e2 (union qaA (tq (fun e : Elt => exists e' : Elt, dans e' qaA /\ chemin_A q dA e e' nil) q))); (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) auto. intro H3. cut (dans e2 qaA \/ dans e2 (tq (fun e : Elt => exists e' : Elt, dans e' qaA /\ chemin_A q dA e e' nil) q)). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply dans_union; auto. intro H4. unfold reconnait_A in |- *. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) split; auto. exists e1. clear H3; elim H4. (* Goal: forall _ : and (inmonoid alph w) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro. exists e2. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) split; auto. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) split; auto. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply (chemin_cheminA q qd qaA dA H_aut); auto. (* Goal: forall _ : and (inmonoid alph w) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro. cut (dans e2 q /\ (fun e : Elt => exists e' : Elt, dans e' qaA /\ chemin_A q dA e e' nil) e2). 2: apply dans_tq_imp with (f := fun e : Elt => exists e' : Elt, dans e' qaA /\ chemin_A q dA e e' nil); (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) auto. (* Goal: forall _ : @ex Elt (fun e : Elt => and (chemin e e2 q d w0) (and (dans e1 q) (and (dans x alph) (dans (couple e1 (couple x e)) d)))), dans e2 q *) intro Ht; elim Ht; clear Ht. intros H5 Ht; elim Ht; clear Ht. intros e2' Ht; elim Ht; clear Ht. intros H6 H7. exists e2'. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) split; auto. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) split; auto. cut (chemin_A q dA e1 e2 w). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply (chemin_cheminA q qd qaA dA H_aut); auto. (* Goal: forall _ : and (inmonoid alph w) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro. replace w with (Append w nil). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply chemin_Append with e2; auto. apply Append_w_nil. Qed. (* *) (* Et le resultat final : *) (* *) (* Pour tout automate asynchrone (utilisant des transitions avec *) (* epsilon) il existe un automate fini reconnaissant le meme *) (* langage. *) (* *) Lemma async_is_sync : forall q qd qaA dA : Ensf, automate_A q qd qaA dA -> exists d : Ensf, (exists qa : Ensf, automate q qd qa d /\ eqwordset (reconnait_A q qd qaA dA) (reconnait q qd qa d)). (* Goal: forall (q qd qaA dA : Ensf) (_ : automate_A q qd qaA dA), @ex Ensf (fun d : Ensf => @ex Ensf (fun qa : Ensf => and (automate q qd qa d) (eqwordset (reconnait_A q qd qaA dA) (reconnait q qd qa d)))) *) intros q qd qaA dA H. (* Goal: @ex Ensf (fun d : Ensf => @ex Ensf (fun qa : Ensf => and (automate q qd qa d) (eqwordset (reconnait_A q qd qaA dA) (reconnait q qd qa d)))) *) exists (sync_d q dA). (* Goal: @ex Ensf (fun qa : Ensf => and (automate q qd qa (sync_d q dA)) (eqwordset (reconnait_A q qd qaA dA) (reconnait q qd qa (sync_d q dA)))) *) exists (sync_qa q qaA dA). (* Goal: forall w : Word, and (forall _ : reconnait_A q qd qaA dA w, reconnait q qd (sync_qa q qaA dA) (sync_d q dA) w) (forall _ : reconnait q qd (sync_qa q qaA dA) (sync_d q dA) w, reconnait_A q qd qaA dA w) *) split. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply automateA_automate; auto. (* Goal: eqwordset (reconnait_A q qd qaA dA) (reconnait q qd (sync_qa q qaA dA) (sync_d q dA)) *) unfold eqwordset in |- *. (* Goal: forall w : Word, and (forall _ : reconnait_A q qd qaA dA w, reconnait q qd (sync_qa q qaA dA) (sync_d q dA) w) (forall _ : reconnait q qd (sync_qa q qaA dA) (sync_d q dA) w, reconnait_A q qd qaA dA w) *) split. (* Goal: forall _ : and (inmonoid alph w) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply reconnaitA_reconnait; auto. (* Goal: forall _ : and (inmonoid alph w) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply reconnait_reconnaitA; auto. Qed. (* *) (* Les mots reconnus par un automate forment un langage : *) (* par definition meme puisqu'un mot reconnu est dans le monoide *) (* engendre par alph... *) (* *) Lemma Recislang : forall q qd qa d : Ensf, automate q qd qa d -> islanguage alph (reconnait q qd qa d). (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intros. (* Goal: islanguage alph (reconnait q qd qa d) *) unfold islanguage at 1 in |- *. (* Goal: forall _ : and (inmonoid alph w) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro. (* Goal: forall _ : reconnait q qd qa d w, inmonoid alph w *) unfold reconnait at 1 in |- *. (* Goal: forall _ : and (inmonoid alph w) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro. (* Goal: inmonoid alph w *) elim H0. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intros. (* Goal: inmonoid alph w *) assumption. Qed. (* *) (* Le predicat isregular definit les langages reguliers. *) (* *) Definition isregular (l : wordset) : Prop := exists q : Ensf, (exists qd : Ensf, (exists qa : Ensf, (exists d : Ensf, automate q qd qa d /\ eqwordset (reconnait q qd qa d) l))). Definition isregular_A (l : wordset) : Prop := exists q : Ensf, (exists qd : Ensf, (exists qa : Ensf, (exists d : Ensf, automate_A q qd qa d /\ eqwordset (reconnait_A q qd qa d) l))). Lemma isregular_A_isregular : forall l : wordset, isregular_A l -> isregular l. unfold isregular_A in |- *. intros l Ht; elim Ht; clear Ht. intros q Ht; elim Ht; clear Ht. intros qd Ht; elim Ht; clear Ht. intros qaA Ht; elim Ht; clear Ht. intros dA Ht; elim Ht; clear Ht. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intros. cut (exists d : Ensf, (exists qa : Ensf, automate q qd qa d /\ eqwordset (reconnait_A q qd qaA dA) (reconnait q qd qa d))). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply async_is_sync; auto. (* Goal: forall _ : @ex Elt (fun e : Elt => and (chemin e e2 q d w0) (and (dans e1 q) (and (dans x alph) (dans (couple e1 (couple x e)) d)))), dans e2 q *) intro Ht; elim Ht; clear Ht. intros d Ht; elim Ht; clear Ht. intros qa Ht; elim Ht; clear Ht. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intros. unfold isregular in |- *. exists q. exists qd. exists qa. exists d. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) split; auto. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply eqwordset_trans with (reconnait_A q qd qaA dA); auto. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply eqwordset_sym; auto. Qed. Definition isregular_D (l : wordset) : Prop := exists q : Ensf, (exists g0 : Elt, (exists qa : Ensf, (exists d : Ensf, automate q (singleton g0) qa d /\ (forall w : Word, chemin g0 g0 q d w -> w = nil :>Word) /\ eqwordset (reconnait q (singleton g0) qa d) l))). Definition transition_D (g0 x : Elt) : Elt := couple g0 (couple epsilon x). Definition delta_D (g0 : Elt) (qd : Ensf) : Ensf := map (transition_D g0) qd. Lemma automate_A_D : forall (q qd qa d : Ensf) (g0 : Elt), automate q qd qa d -> automate_A (add g0 q) (singleton g0) qa (union d (delta_D g0 qd)). unfold automate_A in |- *. (* Goal: forall w : Word, and (forall _ : reconnait_A q qd qaA dA w, reconnait q qd (sync_qa q qaA dA) (sync_d q dA) w) (forall _ : reconnait q qd (sync_qa q qaA dA) (sync_d q dA) w, reconnait_A q qd qaA dA w) *) split. apply inclus_add. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply automate_def3 with qd d; auto. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) split; auto. apply union_inclus. apply inclus_trans with (prodcart q (prodcart alph q)). (* Goal: inmonoid alph w *) apply automate_def1 with qd qa; assumption. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply cart_inclus; auto. unfold delta_D in |- *. unfold inclus in |- *. intros x H2. cut (exists y : Elt, dans y qd /\ x = transition_D g0 y :>Elt). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply dans_map; auto. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro Ht; elim Ht; clear Ht; intros t Ht; elim Ht; clear Ht; intros. rewrite H1. unfold transition_D in |- *. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply coupl2_inv; auto. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply coupl2_inv; auto. apply dans_add2. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply dans_trans with qd; auto. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply automate_def2 with qa d; auto. Qed. (* *) (* Si on a un chemin_A de e a e2 dans l'automate D et que e est dans *) (* q alors on a un chemin dans l'automate fini. *) (* *) Lemma chemin_D_chemin : forall (q qd qa d : Ensf) (g0 e e2 : Elt) (w : Word), automate q qd qa d -> ~ dans g0 q -> chemin_A (add g0 q) (union d (delta_D g0 qd)) e e2 w -> dans e q -> chemin e e2 q d w. intros q qd qa d g0 e e2 w H_aut H_g0 H. (* Goal: chemin_A q d e1 e2 w *) elim H; clear H. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) auto. intros e1 e0 e3 x w0 H H0 H1 H2 H3 H4. cut (dans (couple e1 (couple x e0)) d \/ dans (couple e1 (couple x e0)) (delta_D g0 qd)); (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) auto. (* Goal: forall _ : @ex Elt (fun e : Elt => and (chemin e e2 q d w0) (and (dans e1 q) (and (dans x alph) (dans (couple e1 (couple x e)) d)))), dans e2 q *) intro Ht; elim Ht; clear Ht. (* Goal: forall _ : and (inmonoid alph w) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro. cut (dans (couple e1 (couple x e0)) (prodcart q (prodcart alph q))). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply dans_trans with d; auto. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply automate_def1 with qd qa; auto. (* Goal: forall _ : and (inmonoid alph w) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro. cut (dans e1 q /\ dans (couple x e0) (prodcart alph q)). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply coupl2; auto. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro Ht; elim Ht; clear Ht; intros. cut (dans x alph /\ dans e0 q). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply coupl2; auto. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro Ht; elim Ht; clear Ht; intros. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply chemin_cons with e0; auto. unfold delta_D in |- *. intro H5. cut (exists y : Elt, dans y qd /\ couple e1 (couple x e0) = transition_D g0 y :>Elt). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply dans_map; auto. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro Ht; elim Ht; clear Ht; intros y' Ht; elim Ht; clear Ht; intros. unfold transition_D in H7. cut (e1 = g0 :>Elt /\ couple x e0 = couple epsilon y' :>Elt). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply equal_couple; auto. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro Ht; elim Ht; clear Ht; intros. cut (x = epsilon :>Elt /\ e0 = y' :>Elt). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply equal_couple; auto. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro Ht; elim Ht; clear Ht; intros. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) absurd (dans x alph); auto. rewrite H10. (* Goal: inmonoid alph w *) red in |- *; intro; apply not_dans_epsilon_alph; assumption. intros e1 e0 e3 w0 H H1 H2 H3 H4. cut (dans (couple e1 (couple epsilon e0)) d \/ dans (couple e1 (couple epsilon e0)) (delta_D g0 qd)); (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) auto. (* Goal: forall _ : @ex Elt (fun e : Elt => and (chemin e e2 q d w0) (and (dans e1 q) (and (dans x alph) (dans (couple e1 (couple x e)) d)))), dans e2 q *) intro Ht; elim Ht; clear Ht. (* Goal: forall _ : and (inmonoid alph w) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro. cut (dans (couple e1 (couple epsilon e0)) (prodcart q (prodcart alph q))). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply dans_trans with d; auto. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply automate_def1 with qd qa; auto. (* Goal: forall _ : and (inmonoid alph w) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro. cut (dans e1 q /\ dans (couple epsilon e0) (prodcart alph q)). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply coupl2; auto. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro Ht; elim Ht; clear Ht; intros. cut (dans epsilon alph /\ dans e0 q). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply coupl2; auto. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro Ht; elim Ht; clear Ht; intros. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) absurd (dans epsilon alph); auto. (* Goal: inmonoid alph w *) red in |- *; intro; apply not_dans_epsilon_alph; assumption. unfold delta_D in |- *. (* Goal: forall _ : and (inmonoid alph w) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro. cut (exists y : Elt, dans y qd /\ couple e1 (couple epsilon e0) = transition_D g0 y :>Elt). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply dans_map; auto. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro Ht; elim Ht; clear Ht; intros y' Ht; elim Ht; clear Ht; intros. unfold transition_D in H6. cut (e1 = g0 :>Elt /\ couple epsilon e0 = couple epsilon y' :>Elt). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply equal_couple; auto. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro Ht; elim Ht; clear Ht; intros. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) absurd (dans g0 q); auto. rewrite <- H7. (* Goal: inmonoid alph w *) assumption. Qed. (* *) (* Si on a un chemin de g0 a e2 avec e2 dans qa alors il existe un *) (* etat e dans qd tel que l'on ait un chemin_A de e a e2 par le meme *) (* mot. *) (* *) Lemma chemin_A_g0_e2 : forall (q qd qa d : Ensf) (g0 e1 e2 : Elt) (w : Word), automate q qd qa d -> ~ dans g0 q -> chemin_A (add g0 q) (union d (delta_D g0 qd)) e1 e2 w -> e1 = g0 :>Elt -> dans e2 qa -> exists e : Elt, dans e qd /\ chemin_A (add g0 q) (union d (delta_D g0 qd)) e e2 w. intros q qd qa d g0 e1 e2 w H_aut H_g0 H. (* Goal: chemin_A q d e1 e2 w *) elim H; clear H. intros e0 e3 H H0 H1 H2. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) absurd (dans g0 q); auto. (* Goal: dans e3 q *) rewrite <- H1. rewrite H0. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply dans_trans with qa; auto. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply automate_def3 with qd d; auto. intros e0 e e3 x w0 H H0 H1 H2 H3 H4 H5. clear H0. cut (dans (couple e0 (couple x e)) d \/ (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) dans (couple e0 (couple x e)) (delta_D g0 qd)); auto. (* Goal: forall _ : @ex Elt (fun e : Elt => and (chemin e e2 q d w0) (and (dans e1 q) (and (dans x alph) (dans (couple e1 (couple x e)) d)))), dans e2 q *) intro Ht; elim Ht; clear Ht. (* Goal: forall _ : and (inmonoid alph w) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro. cut (dans (couple e0 (couple x e)) (prodcart q (prodcart alph q))). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply dans_trans with d; auto. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply automate_def1 with qd qa; auto. (* Goal: forall _ : and (inmonoid alph w) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro. cut (dans e0 q /\ dans (couple x e) (prodcart alph q)). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply coupl2; auto. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro Ht; elim Ht; clear Ht; intros. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) absurd (dans g0 q); auto. rewrite <- H4. (* Goal: inmonoid alph w *) assumption. unfold delta_D in |- *. (* Goal: forall _ : and (inmonoid alph w) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro. cut (exists y : Elt, dans y qd /\ couple e0 (couple x e) = transition_D g0 y :>Elt). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply dans_map; auto. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro Ht; elim Ht; clear Ht; intros y' Ht; elim Ht; clear Ht; intros. unfold transition_D in H7. cut (e0 = g0 :>Elt /\ couple x e = couple epsilon y' :>Elt). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply equal_couple; auto. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro Ht; elim Ht; clear Ht; intros. cut (x = epsilon :>Elt /\ e = y' :>Elt). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply equal_couple; auto. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro Ht; elim Ht; clear Ht; intros. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) absurd (dans x alph); auto. rewrite H10. (* Goal: inmonoid alph w *) red in |- *; intro; apply not_dans_epsilon_alph; assumption. intros e0 e e3 w0 H H0 H1 H2 H3 H4. clear H0. exists e. (* Goal: forall w : Word, and (forall _ : reconnait_A q qd qaA dA w, reconnait q qd (sync_qa q qaA dA) (sync_d q dA) w) (forall _ : reconnait q qd (sync_qa q qaA dA) (sync_d q dA) w, reconnait_A q qd qaA dA w) *) split. (* Goal: inmonoid alph w *) 2: assumption. cut (dans (couple e0 (couple epsilon e)) d \/ dans (couple e0 (couple epsilon e)) (delta_D g0 qd)); (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) auto. (* Goal: forall _ : @ex Elt (fun e : Elt => and (chemin e e2 q d w0) (and (dans e1 q) (and (dans x alph) (dans (couple e1 (couple x e)) d)))), dans e2 q *) intro Ht; elim Ht; clear Ht. (* Goal: forall _ : and (inmonoid alph w) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro. cut (dans (couple e0 (couple epsilon e)) (prodcart q (prodcart alph q))). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply dans_trans with d; auto. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply automate_def1 with qd qa; auto. (* Goal: forall _ : and (inmonoid alph w) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro. cut (dans e0 q /\ dans (couple epsilon e) (prodcart alph q)). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply coupl2; auto. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro Ht; elim Ht; clear Ht; intros. cut (dans epsilon alph /\ dans e q). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply coupl2; auto. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro Ht; elim Ht; clear Ht; intros. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) absurd (dans epsilon alph); auto. (* Goal: inmonoid alph w *) red in |- *; intro; apply not_dans_epsilon_alph; assumption. unfold delta_D in |- *. (* Goal: forall _ : and (inmonoid alph w) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro. cut (exists y : Elt, dans y qd /\ couple e0 (couple epsilon e) = transition_D g0 y :>Elt). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply dans_map; auto. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro Ht; elim Ht; clear Ht; intros y' Ht; elim Ht; clear Ht; intros. unfold transition_D in H6. cut (e0 = g0 :>Elt /\ couple epsilon e = couple epsilon y' :>Elt). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply equal_couple; auto. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro Ht; elim Ht; clear Ht; intros. cut (epsilon = epsilon :>Elt /\ e = y' :>Elt). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply equal_couple; auto. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro Ht; elim Ht; clear Ht; intros. rewrite H10. (* Goal: inmonoid alph w *) assumption. Qed. (* *) (* On ne peut avoir de chemin de e a g0 si e est dans q. *) (* *) Lemma chemin_A_e1_g0_abs : forall (q qd qa d : Ensf) (g0 e e2 : Elt) (w : Word), automate q qd qa d -> dans e q -> ~ dans g0 q -> e2 = g0 :>Elt -> ~ chemin_A (add g0 q) (union d (delta_D g0 qd)) e e2 w. intros q qd qa d g0 e e2 w H_aut H H0 H1. (* Goal: forall _ : and (inmonoid alph w) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) red in |- *; intro. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) cut (dans e q); auto. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) cut (e2 = g0 :>Elt); auto. elim H2. intros e1 e0 H3 H4 H5 H6. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) absurd (dans g0 q); auto. rewrite <- H5. (* Goal: inmonoid alph w *) rewrite <- H4; assumption. intros e1 e0 e3 x w0 H3 H4 H5 H6 H7 H8 H9. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply H4; auto. cut (dans (couple e1 (couple x e0)) d \/ dans (couple e1 (couple x e0)) (delta_D g0 qd)); (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) auto. (* Goal: forall _ : @ex Elt (fun e : Elt => and (chemin e e2 q d w0) (and (dans e1 q) (and (dans x alph) (dans (couple e1 (couple x e)) d)))), dans e2 q *) intro Ht; elim Ht; clear Ht. (* Goal: forall _ : and (inmonoid alph w) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro. cut (dans (couple e1 (couple x e0)) (prodcart q (prodcart alph q))). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply dans_trans with d; auto. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply automate_def1 with qd qa; auto. (* Goal: forall _ : and (inmonoid alph w) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro. cut (dans e1 q /\ dans (couple x e0) (prodcart alph q)). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply coupl2; auto. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro Ht; elim Ht; clear Ht; intros. cut (dans x alph /\ dans e0 q). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply coupl2; auto. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro Ht; elim Ht; clear Ht; intros. (* Goal: inmonoid alph w *) assumption. unfold delta_D in |- *. (* Goal: forall _ : and (inmonoid alph w) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro. cut (exists y : Elt, dans y qd /\ couple e1 (couple x e0) = transition_D g0 y :>Elt). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply dans_map; auto. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro Ht; elim Ht; clear Ht; intros y' Ht; elim Ht; clear Ht; intros. unfold transition_D in H12. cut (e1 = g0 :>Elt /\ couple x e0 = couple epsilon y' :>Elt). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply equal_couple; auto. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro Ht; elim Ht; clear Ht; intros. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) absurd (dans e1 q); auto. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) rewrite H13; auto. intros e1 e0 e3 w0 H3 H4 H5 H6 H7 H8. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply H4; auto. cut (dans (couple e1 (couple epsilon e0)) d \/ dans (couple e1 (couple epsilon e0)) (delta_D g0 qd)); (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) auto. (* Goal: forall _ : @ex Elt (fun e : Elt => and (chemin e e2 q d w0) (and (dans e1 q) (and (dans x alph) (dans (couple e1 (couple x e)) d)))), dans e2 q *) intro Ht; elim Ht; clear Ht. (* Goal: forall _ : and (inmonoid alph w) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro. cut (dans (couple e1 (couple epsilon e0)) (prodcart q (prodcart alph q))). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply dans_trans with d; auto. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply automate_def1 with qd qa; auto. (* Goal: forall _ : and (inmonoid alph w) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro. cut (dans e1 q /\ dans (couple epsilon e0) (prodcart alph q)). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply coupl2; auto. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro Ht; elim Ht; clear Ht; intros. cut (dans epsilon alph /\ dans e0 q). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply coupl2; auto. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro Ht; elim Ht; clear Ht; intros. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) absurd (dans epsilon alph); auto. unfold delta_D in |- *. (* Goal: forall _ : and (inmonoid alph w) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro. cut (exists y : Elt, dans y qd /\ couple e1 (couple epsilon e0) = transition_D g0 y :>Elt). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply dans_map; auto. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro Ht; elim Ht; clear Ht; intros y' Ht; elim Ht; clear Ht; intros. unfold transition_D in H11. cut (e1 = g0 :>Elt /\ couple epsilon e0 = couple epsilon y' :>Elt). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply equal_couple; auto. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro Ht; elim Ht; clear Ht; intros. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) absurd (dans e1 q); auto. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) rewrite H12; auto. Qed. (* *) (* Si on a un chemin_A de e1 a g0 alors c'est forcement par le mot *) (* nil. *) (* *) Lemma chemin_A_e1_g0 : forall (q qd qa d : Ensf) (g0 e1 e2 : Elt) (w : Word), automate q qd qa d -> ~ dans g0 q -> chemin_A (add g0 q) (union d (delta_D g0 qd)) e1 e2 w -> e2 = g0 :>Elt -> w = nil :>Word. intros q qd qa d g0 e1 e2 w H_aut H_g0 H. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) elim H; auto. intros e0 e e3 x w0 H0 H1 H2 H3 H4 H5. absurd (chemin_A (add g0 q) (union d (delta_D g0 qd)) e g0 w0). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: cut (chemin_A (add g0 q) (union d (delta_D g0 qd)) e e3 w0); auto. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: rewrite H5; auto. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply chemin_A_e1_g0_abs with qa; auto. cut (dans (couple e0 (couple x e)) d \/ (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) dans (couple e0 (couple x e)) (delta_D g0 qd)); auto. (* Goal: forall _ : @ex Elt (fun e : Elt => and (chemin e e2 q d w0) (and (dans e1 q) (and (dans x alph) (dans (couple e1 (couple x e)) d)))), dans e2 q *) intro Ht; elim Ht; clear Ht. (* Goal: forall _ : and (inmonoid alph w) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro. cut (dans (couple e0 (couple x e)) (prodcart q (prodcart alph q))). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply dans_trans with d; auto. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply automate_def1 with qd qa; auto. (* Goal: forall _ : and (inmonoid alph w) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro. cut (dans e0 q /\ dans (couple x e) (prodcart alph q)). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply coupl2; auto. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro Ht; elim Ht; clear Ht; intros. cut (dans x alph /\ dans e q). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply coupl2; auto. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro Ht; elim Ht; clear Ht; intros. (* Goal: inmonoid alph w *) assumption. unfold delta_D in |- *. (* Goal: forall _ : and (inmonoid alph w) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro. cut (exists y : Elt, dans y qd /\ couple e0 (couple x e) = transition_D g0 y :>Elt). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply dans_map; auto. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro Ht; elim Ht; clear Ht; intros y' Ht; elim Ht; clear Ht; intros. unfold transition_D in H8. cut (e0 = g0 :>Elt /\ couple x e = couple epsilon y' :>Elt). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply equal_couple; auto. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro Ht; elim Ht; clear Ht; intros. cut (x = epsilon :>Elt /\ e = y' :>Elt). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply equal_couple; auto. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro Ht; elim Ht; clear Ht; intros. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) absurd (dans x alph); auto. rewrite H11. (* Goal: inmonoid alph w *) red in |- *; intro; apply not_dans_epsilon_alph; assumption. Qed. (* *) (* Pour tout automate A=(q,qd,qa,d) l'automate ((add g0 q), *) (* (singleton g0),qa,(union d (delta_D g0 qd))) reconnait le meme *) (* langage que A et possede la propriete que seul le mot nil *) (* permet de passer de g0 a g0 par un chemin. *) (* *) Lemma isregular_isregular_D_1 : forall (q qd qa d : Ensf) (g0 : Elt), automate q qd qa d -> ~ dans g0 q -> eqwordset (reconnait q qd qa d) (reconnait_A (add g0 q) (singleton g0) qa (union d (delta_D g0 qd))) /\ (forall w : Word, chemin_A (add g0 q) (union d (delta_D g0 qd)) g0 g0 w -> w = nil :>Word). (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intros. (* Goal: forall w : Word, and (forall _ : reconnait_A q qd qaA dA w, reconnait q qd (sync_qa q qaA dA) (sync_d q dA) w) (forall _ : reconnait q qd (sync_qa q qaA dA) (sync_d q dA) w, reconnait_A q qd qaA dA w) *) split. (* Goal: eqwordset (reconnait_A q qd qaA dA) (reconnait q qd (sync_qa q qaA dA) (sync_d q dA)) *) unfold eqwordset in |- *. intro w. (* Goal: forall w : Word, and (forall _ : reconnait_A q qd qaA dA w, reconnait q qd (sync_qa q qaA dA) (sync_d q dA) w) (forall _ : reconnait q qd (sync_qa q qaA dA) (sync_d q dA) w, reconnait_A q qd qaA dA w) *) split. unfold reconnait in |- *. intro Ht; elim Ht; clear Ht; intros H1 Ht; elim Ht; clear Ht; intros e1 Ht; elim Ht; clear Ht; intros e2 Ht; elim Ht; clear Ht; (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intros H2 Ht; elim Ht; clear Ht; intros. unfold reconnait_A in |- *. (* Goal: forall w : Word, and (forall _ : reconnait_A q qd qaA dA w, reconnait q qd (sync_qa q qaA dA) (sync_d q dA) w) (forall _ : reconnait q qd (sync_qa q qaA dA) (sync_d q dA) w, reconnait_A q qd qaA dA w) *) split. (* Goal: inmonoid alph w *) assumption. exists g0. exists e2. split; [ auto | split ]. (* Goal: inmonoid alph w *) assumption. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply chemin_A_epsilon with e1; auto. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply chemin_A_d1_d2 with d; auto. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply chemin_A_q1_q2 with q; auto. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply chemin_chemin_A; auto. (* Goal: dans e (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply union_d. unfold delta_D in |- *. replace (couple g0 (couple epsilon e1)) with (transition_D g0 e1); (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) auto. unfold reconnait_A in |- *. intro Ht; elim Ht; clear Ht; intros H1 Ht; elim Ht; clear Ht; intros e1 Ht; elim Ht; clear Ht; intros e2 Ht; elim Ht; clear Ht; (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intros H2 Ht; elim Ht; clear Ht; intros. unfold reconnait in |- *. (* Goal: forall w : Word, and (forall _ : reconnait_A q qd qaA dA w, reconnait q qd (sync_qa q qaA dA) (sync_d q dA) w) (forall _ : reconnait q qd (sync_qa q qaA dA) (sync_d q dA) w, reconnait_A q qd qaA dA w) *) split. (* Goal: inmonoid alph w *) assumption. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) cut (e1 = g0 :>Elt); auto. (* Goal: forall _ : and (inmonoid alph w) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro. cut (exists e : Elt, dans e qd /\ chemin_A (add g0 q) (union d (delta_D g0 qd)) e e2 w). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply chemin_A_g0_e2 with qa e1; auto. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro Ht; elim Ht; clear Ht; intros e Ht; elim Ht; clear Ht; intros. exists e. exists e2. split; [ assumption | split ]. (* Goal: inmonoid alph w *) assumption. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply chemin_D_chemin with qd qa g0; auto. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply dans_trans with qd; auto. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply automate_def2 with qa d; auto. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intros. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply chemin_A_e1_g0 with q qd qa d g0 g0 g0; auto. Qed. (* *) (* Si l est regulier, alors l est regulier au sens de isregular_D, *) (* ie il existe un automate a un seul etat de depart g0 et possedant *) (* la propriete que seul le mot nil permet d'aller de g0 a g0 par *) (* un chemin qui reconnait l. *) (* *) Lemma isregular_isregular_D : forall l : wordset, isregular l -> isregular_D l. intro l. unfold isregular at 1 in |- *. intro Ht; elim Ht; clear Ht; intros q Ht; elim Ht; clear Ht; intros qd Ht; elim Ht; clear Ht; intros qa Ht; elim Ht; clear Ht; (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intros d Ht; elim Ht; clear Ht; intros. cut (exists g0 : Elt, ~ dans g0 q). 2: apply exist_other. intro Ht; elim Ht; clear Ht; intros g0 H1. cut (automate_A (add g0 q) (singleton g0) qa (union d (delta_D g0 qd))). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply automate_A_D; auto. (* Goal: forall _ : and (inmonoid alph w) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro. unfold isregular_D in |- *. exists (add g0 q). exists g0. exists (sync_qa (add g0 q) qa (union d (delta_D g0 qd))). exists (sync_d (add g0 q) (union d (delta_D g0 qd))). (* Goal: forall w : Word, and (forall _ : reconnait_A q qd qaA dA w, reconnait q qd (sync_qa q qaA dA) (sync_d q dA) w) (forall _ : reconnait q qd (sync_qa q qaA dA) (sync_d q dA) w, reconnait_A q qd qaA dA w) *) split. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply automateA_automate; auto. cut (eqwordset (reconnait q qd qa d) (reconnait_A (add g0 q) (singleton g0) qa (union d (delta_D g0 qd))) /\ (forall w : Word, chemin_A (add g0 q) (union d (delta_D g0 qd)) g0 g0 w -> w = nil :>Word)). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply isregular_isregular_D_1; auto. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro Ht; elim Ht; clear Ht; intros. (* Goal: forall w : Word, and (forall _ : reconnait_A q qd qaA dA w, reconnait q qd (sync_qa q qaA dA) (sync_d q dA) w) (forall _ : reconnait q qd (sync_qa q qaA dA) (sync_d q dA) w, reconnait_A q qd qaA dA w) *) split. intros w H5. cut (chemin_A (add g0 q) (union d (delta_D g0 qd)) g0 g0 w). (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) 2: apply chemin_cheminA with (singleton g0) qa; auto. (* Goal: forall _ : and (inmonoid alph w) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply (H4 w); auto. apply eqwordset_trans with (reconnait_A (add g0 q) (singleton g0) qa (union d (delta_D g0 qd))). (* Goal: eqwordset (reconnait_A q qd qaA dA) (reconnait q qd (sync_qa q qaA dA) (sync_d q dA)) *) unfold eqwordset in |- *. intro w. (* Goal: forall w : Word, and (forall _ : reconnait_A q qd qaA dA w, reconnait q qd (sync_qa q qaA dA) (sync_d q dA) w) (forall _ : reconnait q qd (sync_qa q qaA dA) (sync_d q dA) w, reconnait_A q qd qaA dA w) *) split. (* Goal: forall _ : and (inmonoid alph w) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply reconnait_reconnaitA; auto. (* Goal: forall _ : and (inmonoid alph w) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 qd) (and (dans e2 qa) (chemin e1 e2 q d w))))), inmonoid alph w *) intro. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply reconnaitA_reconnait; auto. (* Goal: forall q qaA dA : Ensf, inclus qaA (union qaA (tq (fun e : Elt => @ex Elt (fun e' : Elt => and (dans e' qaA) (chemin_A q dA e e' nil))) q)) *) apply eqwordset_trans with (reconnait q qd qa d); auto. (* Goal: inmonoid alph w *) apply eqwordset_sym; assumption. Qed.
(* This program is free software; you can redistribute it and/or *) (* modify it under the terms of the GNU Lesser General Public License *) (* as published by the Free Software Foundation; either version 2.1 *) (* of the License, or (at your option) any later version. *) (* *) (* This program is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* GNU General Public License for more details. *) (* *) (* You should have received a copy of the GNU Lesser General Public *) (* License along with this program; if not, write to the Free *) (* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *) (* 02110-1301 USA *) (* Contribution to the Coq Library V6.3 (July 1999) *) (****************************************************************************) (* The Calculus of Inductive Constructions *) (* *) (* Projet Coq *) (* *) (* INRIA ENS-CNRS *) (* Rocquencourt Lyon *) (* *) (* Coq V5.10 *) (* Nov 25th 1994 *) (* *) (****************************************************************************) (* Ensf_inter.v *) (****************************************************************************) (* Formal Language Theory *) (* *) (* Judicael Courant - Jean-Christophe Filliatre *) (* *) (* Developped in V5.8 June-July 1993 *) (* Ported to V5.10 October 1994 *) (****************************************************************************) Require Import Ensf_types. Require Import Ensf_dans. Require Import Ensf_union. Require Import Ensf_inclus. (* *) (* INTERSECTION *) (* L'intersection de 2 ensembles est definie comme un predicat sur *) (* 3 ensembles A B C en disant que C est l'intresection de A et B *) (* si C est le plus grand ensemble inclus dans A et dans B *) (* *) Definition inter (A B C : Ensf) : Prop := inclus C A /\ inclus C B /\ (forall x : Elt, dans x A -> dans x B -> dans x C). Lemma union_inter : forall a b c : Ensf, inter a b empty -> inter a c empty -> inter a (union b c) empty. (* Goal: forall (A B C : Ensf) (_ : inter A B C), inter B A C *) unfold inter in |- *. (* Goal: forall (A B C : Ensf) (_ : and (inclus C A) (and (inclus C B) (forall (x : Elt) (_ : dans x A) (_ : dans x B), dans x C))), and (inclus C B) (and (inclus C A) (forall (x : Elt) (_ : dans x B) (_ : dans x A), dans x C)) *) intros. (* Goal: and (inclus empty (union A B)) (and (inclus empty C) (forall (x : Elt) (_ : dans x (union A B)) (_ : dans x C), dans x empty)) *) elim H0; clear H0. (* Goal: forall (_ : inclus empty B) (_ : and (inclus empty C) (forall (x : Elt) (_ : dans x B) (_ : dans x C), dans x empty)), and (inclus empty (union A B)) (and (inclus empty C) (forall (x : Elt) (_ : dans x (union A B)) (_ : dans x C), dans x empty)) *) intros H0 H1; elim H1; clear H1; intros H1 H2. (* Goal: and (inclus empty (union A B)) (and (inclus empty C) (forall (x : Elt) (_ : dans x (union A B)) (_ : dans x C), dans x empty)) *) elim H; clear H. (* Goal: forall (_ : inclus empty A) (_ : and (inclus empty C) (forall (x : Elt) (_ : dans x A) (_ : dans x C), dans x empty)), and (inclus empty (union A B)) (and (inclus empty C) (forall (x : Elt) (_ : dans x (union A B)) (_ : dans x C), dans x empty)) *) intros H3 H4; elim H4; clear H4; intros H4 H5. (* Goal: and (inclus empty C) (forall (x : Elt) (_ : dans x (union A B)) (_ : dans x C), dans x empty) *) split; auto. (* Goal: and (inclus empty (union b c)) (forall (x : Elt) (_ : dans x a) (_ : dans x (union b c)), dans x empty) *) split. (* Goal: inclus empty (union b c) *) (* Goal: forall (x : Elt) (_ : dans x a) (_ : dans x (union b c)), dans x empty *) apply empty_inclus. (* Goal: forall (A B C : Ensf) (_ : and (inclus C A) (and (inclus C B) (forall (x : Elt) (_ : dans x A) (_ : dans x B), dans x C))), and (inclus C B) (and (inclus C A) (forall (x : Elt) (_ : dans x B) (_ : dans x A), dans x C)) *) intros. (* Goal: dans x empty *) cut (dans x b \/ dans x c); auto. (* Goal: forall _ : or (dans x A) (dans x B), dans x empty *) intro H7; elim H7; auto. Qed. Lemma inter_union : forall A B C : Ensf, inter A C empty -> inter B C empty -> inter (union A B) C empty. (* Goal: forall (A B C : Ensf) (_ : inter A B C), inter B A C *) unfold inter in |- *. (* Goal: forall (A B C : Ensf) (_ : and (inclus C A) (and (inclus C B) (forall (x : Elt) (_ : dans x A) (_ : dans x B), dans x C))), and (inclus C B) (and (inclus C A) (forall (x : Elt) (_ : dans x B) (_ : dans x A), dans x C)) *) intros. (* Goal: and (inclus empty (union A B)) (and (inclus empty C) (forall (x : Elt) (_ : dans x (union A B)) (_ : dans x C), dans x empty)) *) elim H0; clear H0. (* Goal: forall (_ : inclus empty B) (_ : and (inclus empty C) (forall (x : Elt) (_ : dans x B) (_ : dans x C), dans x empty)), and (inclus empty (union A B)) (and (inclus empty C) (forall (x : Elt) (_ : dans x (union A B)) (_ : dans x C), dans x empty)) *) intros H0 H1; elim H1; clear H1; intros H1 H2. (* Goal: and (inclus empty (union A B)) (and (inclus empty C) (forall (x : Elt) (_ : dans x (union A B)) (_ : dans x C), dans x empty)) *) elim H; clear H. (* Goal: forall (_ : inclus empty A) (_ : and (inclus empty C) (forall (x : Elt) (_ : dans x A) (_ : dans x C), dans x empty)), and (inclus empty (union A B)) (and (inclus empty C) (forall (x : Elt) (_ : dans x (union A B)) (_ : dans x C), dans x empty)) *) intros H3 H4; elim H4; clear H4; intros H4 H5. (* Goal: and (inclus empty C) (forall (x : Elt) (_ : dans x (union A B)) (_ : dans x C), dans x empty) *) split; auto. (* Goal: and (inclus empty C) (forall (x : Elt) (_ : dans x (union A B)) (_ : dans x C), dans x empty) *) split; auto. (* Goal: forall (A B C : Ensf) (_ : and (inclus C A) (and (inclus C B) (forall (x : Elt) (_ : dans x A) (_ : dans x B), dans x C))), and (inclus C B) (and (inclus C A) (forall (x : Elt) (_ : dans x B) (_ : dans x A), dans x C)) *) intros. (* Goal: dans x empty *) cut (dans x A \/ dans x B); auto. (* Goal: forall _ : or (dans x A) (dans x B), dans x empty *) intro H7; elim H7; auto. Qed. Lemma inter_dans : forall (A B : Ensf) (x : Elt), inter A B empty -> dans x A -> ~ dans x B. (* Goal: forall (A B C : Ensf) (_ : inter A B C), inter B A C *) unfold inter in |- *. (* Goal: forall (A B C : Ensf) (_ : and (inclus C A) (and (inclus C B) (forall (x : Elt) (_ : dans x A) (_ : dans x B), dans x C))), and (inclus C B) (and (inclus C A) (forall (x : Elt) (_ : dans x B) (_ : dans x A), dans x C)) *) intros. (* Goal: not (dans x B) *) elim H; clear H; intros H Ht; elim Ht; clear Ht; intros H1 H2. (* Goal: not (dans x B) *) red in |- *; intro. (* Goal: False *) cut (dans x empty); auto. (* Goal: forall _ : dans x empty, False *) intro. (* Goal: False *) apply dans_empty_imp_P with x; auto. Qed. Lemma sym_inter : forall A B C : Ensf, inter A B C -> inter B A C. (* Goal: forall (A B C : Ensf) (_ : inter A B C), inter B A C *) unfold inter in |- *. (* Goal: forall (A B C : Ensf) (_ : and (inclus C A) (and (inclus C B) (forall (x : Elt) (_ : dans x A) (_ : dans x B), dans x C))), and (inclus C B) (and (inclus C A) (forall (x : Elt) (_ : dans x B) (_ : dans x A), dans x C)) *) intros. (* Goal: and (inclus C B) (and (inclus C A) (forall (x : Elt) (_ : dans x B) (_ : dans x A), dans x C)) *) elim H; clear H; intros H Ht; elim Ht; clear Ht; intros H0 H1. (* Goal: and (inclus C B) (and (inclus C A) (forall (x : Elt) (_ : dans x B) (_ : dans x A), dans x C)) *) auto. Qed.
(* This program is free software; you can redistribute it and/or *) (* modify it under the terms of the GNU Lesser General Public License *) (* as published by the Free Software Foundation; either version 2.1 *) (* of the License, or (at your option) any later version. *) (* *) (* This program is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* GNU General Public License for more details. *) (* *) (* You should have received a copy of the GNU Lesser General Public *) (* License along with this program; if not, write to the Free *) (* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *) (* 02110-1301 USA *) (* Contribution to the Coq Library V6.3 (July 1999) *) (****************************************************************************) (* The Calculus of Inductive Constructions *) (* *) (* Projet Coq *) (* *) (* INRIA ENS-CNRS *) (* Rocquencourt Lyon *) (* *) (* Coq V5.10 *) (* Nov 25th 1994 *) (* *) (****************************************************************************) (* gram2.v *) (****************************************************************************) (* Formal Language Theory *) (* *) (* Judicael Courant - Jean-Christophe Filliatre *) (* *) (* Developped in V5.8 June-July 1993 *) (* Ported to V5.10 October 1994 *) (****************************************************************************) Require Import Ensf. Require Import Words. Require Import more_words. Require Import need. Require Import fonctions. Require Import Relations. Require Import gram. Hint Resolve extension_Id. Section resultats. Variable X V1 R1 : Ensf. Variable S1 : Elt. Variable V2 R2 : Ensf. Variable S2 : Elt. Let C := Gunion V1 R1 V2 R2. Let Vu := fst C. Let Ru := snd C. Lemma inter_X_Vu : isGram X V1 R1 S1 -> isGram X V2 R2 S2 -> inter X Vu empty. (* Goal: forall (_ : isGram X V1 R1 S1) (_ : isGram X V2 R2 S2), inter X Vu empty *) intro G1. (* Goal: forall _ : isGram X V2 R2 S2, inter X Vu empty *) intro G2. (* Goal: inter X Vu empty *) unfold Vu in |- *. (* Goal: inter X (@fst Ensf Ensf C) empty *) unfold C in |- *. (* Goal: inter X (@fst Ensf Ensf (Gunion V1 R1 V2 R2)) empty *) unfold Gunion in |- *. (* Goal: @eq Ensf (add (couple (f (first a)) (word (Word_ext f (word_inv (second a))))) ((fix map (f : forall _ : Elt, Elt) (e : Ensf) {struct e} : Ensf := match e with | empty => empty | add y e0 => add (f y) (map f e0) end) (fun P : Elt => couple (f (first P)) (word (Word_ext f (word_inv (second P))))) R)) (add a R) *) simpl in |- *. (* Goal: inter X (union V1 V2) empty *) apply union_inter. (* Goal: inter X V1 empty *) (* Goal: inter X V2 empty *) apply isGram2 with R1 S1; assumption. (* Goal: inter X V2 empty *) (* Goal: inter V1 V2 empty *) (* Goal: Derive Ru u v *) (* Goal: inmonoid (union X V1) u *) (* Goal: inmonoid (union X V1) u *) apply isGram2 with R2 S2; assumption. Qed. Lemma Gunion_Regles : isGram X V1 R1 S1 -> isGram X V2 R2 S2 -> Regles X Vu Ru. (* Goal: forall (u v : Word) (x : Elt) (_ : Derive R1 u v) (_ : Derive Rim (wef u) (wef v)), Derive Rim (wef (cons x u)) (wef (cons x v)) *) intros. (* Goal: @eq Ensf (add (couple (f (first a)) (word (Word_ext f (word_inv (second a))))) ((fix map (f : forall _ : Elt, Elt) (e : Ensf) {struct e} : Ensf := match e with | empty => empty | add y e0 => add (f y) (map f e0) end) (fun P : Elt => couple (f (first P)) (word (Word_ext f (word_inv (second P))))) R)) (add a R) *) unfold Ru in |- *; unfold C in |- *; unfold Gunion in |- *; simpl in |- *. apply Regles_union; unfold Vu in |- *; unfold C in |- *; (* Goal: @eq Ensf (add (couple (f (first a)) (word (Word_ext f (word_inv (second a))))) ((fix map (f : forall _ : Elt, Elt) (e : Ensf) {struct e} : Ensf := match e with | empty => empty | add y e0 => add (f y) (map f e0) end) (fun P : Elt => couple (f (first P)) (word (Word_ext f (word_inv (second P))))) R)) (add a R) *) unfold Gunion in |- *; simpl in |- *. apply Regles_V with V1; [ auto | apply isGram4 with S1; auto ]. apply Regles_V with V2; [ auto | apply isGram4 with S2; auto ]. Qed. Lemma inmon_Der_imp_Der : Regles X V1 R1 -> Regles X V2 R2 -> inter (union X V1) V2 empty -> forall u v : Word, Derive Ru u v -> inmonoid (union X V1) u -> Derive R1 u v. (* Goal: forall (_ : Regles X V1 R1) (_ : Regles X V2 R2) (_ : inter (union X V1) V2 empty) (u v : Word) (_ : Derive Ru u v) (_ : inmonoid (union X V1) u), Derive R1 u v *) intros Re_1 Re_2 inter_X_V1_V2_empty u v Der_Ru_u. (* Goal: forall _ : inmonoid (union X V2) u, Derive R2 u v *) elim Der_Ru_u. (* Goal: forall (u v : Word) (A : Elt) (_ : dans (couple A (word u)) Ru) (_ : inmonoid (union X V2) (cons A v)), Derive R2 (cons A v) (Append u v) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V2) u, Derive R2 u v) (_ : inmonoid (union X V2) (cons x u)), Derive R2 (cons x u) (cons x v) *) intros u0 v0 A dans_couple_Ru inmon_cons_A_v0. (* Goal: Derive R2 (cons A v0) (Append u0 v0) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V2) u, Derive R2 u v) (_ : inmonoid (union X V2) (cons x u)), Derive R2 (cons x u) (cons x v) *) apply Derive1. (* Goal: dans (couple A (word u0)) R2 *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V2) u, Derive R2 u v) (_ : inmonoid (union X V2) (cons x u)), Derive R2 (cons x u) (cons x v) *) cut (dans (couple A (word u0)) R1 \/ dans (couple A (word u0)) R2). (**) (* Goal: forall _ : @ex Elt (fun x_ant : Elt => and (dans x_ant R1) (@eq Elt x (fonc x_ant))), @ex2 Elt (fun A : Elt => dans A (map f V1)) (fun A : Elt => @ex2 Word (fun B : Word => @eq Elt x (couple A (word B))) (fun B : Word => inmonoid (union (map f X) (map f V1)) B)) *) (* Goal: @ex Elt (fun x_ant : Elt => and (dans x_ant R1) (@eq Elt x (fonc x_ant))) *) intro temp; elim temp; clear temp. (* Goal: inmonoid Xim (wef nil) *) (* Goal: forall (w : Word) (e : Elt) (_ : inmonoid X w) (_ : inmonoid Xim (wef w)) (_ : dans e X), inmonoid Xim (wef (cons e w)) *) auto. (* Goal: forall _ : dans (couple A (word u0)) R2, dans (couple A (word u0)) R1 *) (* Goal: or (dans (couple A (word u0)) R1) (dans (couple A (word u0)) R2) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V1) u, Derive R1 u v) (_ : inmonoid (union X V1) (cons x u)), Derive R1 (cons x u) (cons x v) *) intro dans_R2. (* Goal: dans (couple A (word u0)) R1 *) (* Goal: or (dans (couple A (word u0)) R1) (dans (couple A (word u0)) R2) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V1) u, Derive R1 u v) (_ : inmonoid (union X V1) (cons x u)), Derive R1 (cons x u) (cons x v) *) absurd (inter (union X V1) V2 empty). (* Goal: not (inter (union X V2) V1 empty) *) (* Goal: inter (union X V2) V1 empty *) (* Goal: forall _ : dans (couple A (word u0)) R2, dans (couple A (word u0)) R2 *) (* Goal: or (dans (couple A (word u0)) R1) (dans (couple A (word u0)) R2) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V2) u, Derive R2 u v) (_ : inmonoid (union X V2) (cons x u)), Derive R2 (cons x u) (cons x v) *) red in |- *. (* Goal: forall _ : inter (union X V2) V1 empty, False *) (* Goal: inter (union X V2) V1 empty *) (* Goal: forall _ : dans (couple A (word u0)) R2, dans (couple A (word u0)) R2 *) (* Goal: or (dans (couple A (word u0)) R1) (dans (couple A (word u0)) R2) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V2) u, Derive R2 u v) (_ : inmonoid (union X V2) (cons x u)), Derive R2 (cons x u) (cons x v) *) unfold inter in |- *. (* Goal: forall _ : @ex Elt (fun x_ant : Elt => and (dans x_ant R1) (@eq Elt x (fonc x_ant))), @ex2 Elt (fun A : Elt => dans A (map f V1)) (fun A : Elt => @ex2 Word (fun B : Word => @eq Elt x (couple A (word B))) (fun B : Word => inmonoid (union (map f X) (map f V1)) B)) *) (* Goal: @ex Elt (fun x_ant : Elt => and (dans x_ant R1) (@eq Elt x (fonc x_ant))) *) intro temp; elim temp; clear temp. (* Goal: forall (_ : inclus empty (union X V1)) (_ : and (inclus empty V2) (forall (x : Elt) (_ : dans x (union X V1)) (_ : dans x V2), dans x empty)), False *) (* Goal: inter (union X V1) V2 empty *) (* Goal: or (dans (couple A (word u0)) R1) (dans (couple A (word u0)) R2) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V1) u, Derive R1 u v) (_ : inmonoid (union X V1) (cons x u)), Derive R1 (cons x u) (cons x v) *) intros incl_empty_X_V1 temp; elim temp; clear temp. (* Goal: forall (_ : inclus empty V2) (_ : forall (x : Elt) (_ : dans x (union X V1)) (_ : dans x V2), dans x empty), False *) (* Goal: inter (union X V1) V2 empty *) (* Goal: or (dans (couple A (word u0)) R1) (dans (couple A (word u0)) R2) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V1) u, Derive R1 u v) (_ : inmonoid (union X V1) (cons x u)), Derive R1 (cons x u) (cons x v) *) intros incl_empty_V2 imp. (* Goal: False *) (* Goal: inter (union X V2) V1 empty *) (* Goal: forall _ : dans (couple A (word u0)) R2, dans (couple A (word u0)) R2 *) (* Goal: or (dans (couple A (word u0)) R1) (dans (couple A (word u0)) R2) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V2) u, Derive R2 u v) (_ : inmonoid (union X V2) (cons x u)), Derive R2 (cons x u) (cons x v) *) apply dans_empty_imp_P with A. (* Goal: Derive R1 u0 v0 *) apply imp. (* Goal: dans A (union X V1) *) (* Goal: dans A V2 *) (* Goal: inter (union X V1) V2 empty *) (* Goal: or (dans (couple A (word u0)) R1) (dans (couple A (word u0)) R2) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V1) u, Derive R1 u v) (_ : inmonoid (union X V1) (cons x u)), Derive R1 (cons x u) (cons x v) *) apply inmonoid_cons_inv2 with v0; assumption. (* Goal: dans A V2 *) (* Goal: inter (union X V1) V2 empty *) (* Goal: or (dans (couple A (word u0)) R1) (dans (couple A (word u0)) R2) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V1) u, Derive R1 u v) (_ : inmonoid (union X V1) (cons x u)), Derive R1 (cons x u) (cons x v) *) apply Regles_inv1 with X R2 (word u0); assumption. (* Goal: Id (union X (add a V1')) f *) assumption. (* Goal: Id (union X (add a V1')) f *) (**) apply dans_union; assumption. (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V1) u, Derive R1 u v) (_ : inmonoid (union X V1) (cons x u)), Derive R1 (cons x u) (cons x v) *) intros u0 v0 x Der_Ru imp inmon_cons_x_u0. (* Goal: Derive R1 (cons x u0) (cons x v0) *) apply Derive2. (* Goal: Derive R1 u0 v0 *) apply imp. (* Goal: inmonoid (union X V1) u0 *) apply inmonoid_cons_inv with x. (* Goal: Id (union X (add a V1')) f *) assumption. Qed. Lemma inmon_Der_imp_inmon_R1 : forall u v : Word, Regles X V1 R1 -> Derive R1 u v -> inmonoid (union X V1) u -> inmonoid (union X V1) v. (* Goal: forall (u v : Word) (x : Elt) (_ : Derive R1 u v) (_ : Derive Rim (wef u) (wef v)), Derive Rim (wef (cons x u)) (wef (cons x v)) *) intros. (* Goal: Id (union X (add a V1')) f *) apply in_mon_X_Der_imp_inmon_X with R1 u; assumption. Qed. Lemma inmon_Der_imp_inmon : forall u v : Word, isGram X V1 R1 S1 -> isGram X V2 R2 S2 -> inter V1 V2 empty -> inmonoid (union X V1) u -> Derive Ru u v -> inmonoid (union X V1) v. (* Goal: forall (u v : Word) (_ : isGram X V1 R1 S1) (_ : isGram X V2 R2 S2) (_ : inter V1 V2 empty) (_ : inmonoid (union X V1) u) (_ : Derive Ru u v), inmonoid (union X V1) v *) intros u v G_R1 G_R2 inter_V1_V2_empty inmon_X_V1_u Der_Ru_u_v. (* Goal: inmonoid (union X V1) v *) apply inmon_Der_imp_inmon_R1 with u. (* Goal: Id (union X (add a V1')) f *) apply isGram4 with S1; assumption. (* Goal: Derive R1 u v *) (* Goal: inmonoid (union X V1) u *) apply inmon_Der_imp_Der. (* Goal: Id (union X (add a V1')) f *) apply isGram4 with S1; assumption. (* Goal: Id (union X (add a V1')) f *) apply isGram4 with S2; assumption. (* Goal: inter (union X V1) V2 empty *) (* Goal: Derive Ru u v *) (* Goal: inmonoid (union X V1) u *) (* Goal: inmonoid (union X V1) u *) apply inter_union. (* Goal: inter X V2 empty *) (* Goal: inter V1 V2 empty *) (* Goal: Derive Ru u v *) (* Goal: inmonoid (union X V1) u *) (* Goal: inmonoid (union X V1) u *) apply isGram2 with R2 S2; assumption. (* Goal: Id (union X (add a V1')) f *) assumption. (* Goal: Id (union X (add a V1')) f *) assumption. (* Goal: Id (union X (add a V1')) f *) assumption. (* Goal: Id (union X (add a V1')) f *) assumption. Qed. Lemma Gunion_Derivestar : isGram X V1 R1 S1 -> isGram X V2 R2 S2 -> inter V1 V2 empty -> forall u v : Word, Derivestar Ru u v -> inmonoid (union X V1) u -> Derivestar R1 u v. (* Goal: forall (u v : Word) (_ : Derivestar R1 u v), Derivestar Rim (wef u) (wef v) *) unfold Derivestar in |- *. (* Goal: forall (_ : isGram X V1 R1 S1) (_ : isGram X V2 R2 S2) (_ : inter V1 V2 empty) (u v : Word) (_ : Rstar Word (Derive Ru) u v) (_ : inmonoid (union X V2) u), Rstar Word (Derive R2) u v *) intros G_1 G_2 inter_V1_V2_empty u v Derivestar_Ru. (* Goal: Rstar Word (Derive Rim) (wef u) (wef v) *) pattern u, v in |- *. (* Goal: (fun w w0 : Word => forall _ : inmonoid (union X V2) w, Rstar Word (Derive R2) w w0) u v *) apply Derivestar_Ru. (* Goal: inmonoid Xim (wef nil) *) (* Goal: forall (w : Word) (e : Elt) (_ : inmonoid X w) (_ : inmonoid Xim (wef w)) (_ : dans e X), inmonoid Xim (wef (cons e w)) *) auto. (*Intros. Apply Rstar_reflexive.*) (* Goal: forall (u v w : Word) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V1) v, Rstar Word (Derive R1) v w) (_ : inmonoid (union X V1) u), Rstar Word (Derive R1) u w *) intros u0 v0 w Der_Ru inmon_v0_imp_Rstar_R1_v0 inmon_u0. (*Prolog [Rstar_R inmon_Der_imp_Der isGram4 inter_union isGram2 inmon_Der_imp_inmon ] 6. -> raisonnable seulement sur Cray...*) (* Goal: Rstar Word (Derive R2) u0 w *) apply Rstar_R with v0. (* Goal: Derive R1 u0 v0 *) (* Goal: Rstar Word (Derive R1) v0 w *) prolog [ inmon_Der_imp_Der isGram4 inter_union isGram2 ] 5. (* Apply inmon_Der_imp_Der. Apply isGram4 with S1;Assumption. Apply isGram4 with S2;Assumption. Apply inter_union. Apply isGram2 with R2 S2; Assumption. Assumption. Assumption. Assumption.*) (* Goal: Rstar Word (Derive R1) v0 w *) prolog [ inmon_Der_imp_inmon ] 3. (* Apply inmon_v0_imp_Rstar_R1_v0. Apply inmon_Der_imp_inmon with u0;Assumption.*) Qed. Lemma inmon_Der_imp_Der2 : Regles X V1 R1 -> Regles X V2 R2 -> inter (union X V2) V1 empty -> forall u v : Word, Derive Ru u v -> inmonoid (union X V2) u -> Derive R2 u v. (* Goal: forall (_ : Regles X V1 R1) (_ : Regles X V2 R2) (_ : inter (union X V2) V1 empty) (u v : Word) (_ : Derive Ru u v) (_ : inmonoid (union X V2) u), Derive R2 u v *) intros Re_1 Re_2 inter_X_V2_V1_empty u v Der_Ru_u. (* Goal: forall _ : inmonoid (union X V2) u, Derive R2 u v *) elim Der_Ru_u. (* Goal: forall (u v : Word) (A : Elt) (_ : dans (couple A (word u)) Ru) (_ : inmonoid (union X V2) (cons A v)), Derive R2 (cons A v) (Append u v) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V2) u, Derive R2 u v) (_ : inmonoid (union X V2) (cons x u)), Derive R2 (cons x u) (cons x v) *) intros u0 v0 A dans_couple_Ru inmon_cons_A_v0. (* Goal: Derive R2 (cons A v0) (Append u0 v0) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V2) u, Derive R2 u v) (_ : inmonoid (union X V2) (cons x u)), Derive R2 (cons x u) (cons x v) *) apply Derive1. (* Goal: dans (couple A (word u0)) R2 *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V2) u, Derive R2 u v) (_ : inmonoid (union X V2) (cons x u)), Derive R2 (cons x u) (cons x v) *) cut (dans (couple A (word u0)) R1 \/ dans (couple A (word u0)) R2). (**) (* Goal: forall _ : @ex Elt (fun x_ant : Elt => and (dans x_ant R1) (@eq Elt x (fonc x_ant))), @ex2 Elt (fun A : Elt => dans A (map f V1)) (fun A : Elt => @ex2 Word (fun B : Word => @eq Elt x (couple A (word B))) (fun B : Word => inmonoid (union (map f X) (map f V1)) B)) *) (* Goal: @ex Elt (fun x_ant : Elt => and (dans x_ant R1) (@eq Elt x (fonc x_ant))) *) intro temp; elim temp; clear temp. (* Goal: forall _ : dans (couple A (word u0)) R1, dans (couple A (word u0)) R2 *) (* Goal: forall _ : dans (couple A (word u0)) R2, dans (couple A (word u0)) R2 *) (* Goal: or (dans (couple A (word u0)) R1) (dans (couple A (word u0)) R2) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V2) u, Derive R2 u v) (_ : inmonoid (union X V2) (cons x u)), Derive R2 (cons x u) (cons x v) *) intro dans_R1. (* Goal: dans (couple A (word u0)) R2 *) (* Goal: forall _ : dans (couple A (word u0)) R2, dans (couple A (word u0)) R2 *) (* Goal: or (dans (couple A (word u0)) R1) (dans (couple A (word u0)) R2) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V2) u, Derive R2 u v) (_ : inmonoid (union X V2) (cons x u)), Derive R2 (cons x u) (cons x v) *) absurd (inter (union X V2) V1 empty). (* Goal: not (inter (union X V2) V1 empty) *) (* Goal: inter (union X V2) V1 empty *) (* Goal: forall _ : dans (couple A (word u0)) R2, dans (couple A (word u0)) R2 *) (* Goal: or (dans (couple A (word u0)) R1) (dans (couple A (word u0)) R2) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V2) u, Derive R2 u v) (_ : inmonoid (union X V2) (cons x u)), Derive R2 (cons x u) (cons x v) *) red in |- *. (* Goal: forall _ : inter (union X V2) V1 empty, False *) (* Goal: inter (union X V2) V1 empty *) (* Goal: forall _ : dans (couple A (word u0)) R2, dans (couple A (word u0)) R2 *) (* Goal: or (dans (couple A (word u0)) R1) (dans (couple A (word u0)) R2) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V2) u, Derive R2 u v) (_ : inmonoid (union X V2) (cons x u)), Derive R2 (cons x u) (cons x v) *) unfold inter in |- *. (* Goal: forall _ : and (inclus empty (union X V2)) (and (inclus empty V1) (forall (x : Elt) (_ : dans x (union X V2)) (_ : dans x V1), dans x empty)), False *) (* Goal: inter (union X V2) V1 empty *) (* Goal: forall _ : dans (couple A (word u0)) R2, dans (couple A (word u0)) R2 *) (* Goal: or (dans (couple A (word u0)) R1) (dans (couple A (word u0)) R2) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V2) u, Derive R2 u v) (_ : inmonoid (union X V2) (cons x u)), Derive R2 (cons x u) (cons x v) *) intros (H1, (H2, H3)). (* Intuition. *) (*Intros;*) (* Goal: False *) (* Goal: inter (union X V2) V1 empty *) (* Goal: forall _ : dans (couple A (word u0)) R2, dans (couple A (word u0)) R2 *) (* Goal: or (dans (couple A (word u0)) R1) (dans (couple A (word u0)) R2) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V2) u, Derive R2 u v) (_ : inmonoid (union X V2) (cons x u)), Derive R2 (cons x u) (cons x v) *) apply dans_empty_imp_P with A. (* Goal: dans A empty *) (* Goal: inter (union X V2) V1 empty *) (* Goal: forall _ : dans (couple A (word u0)) R2, dans (couple A (word u0)) R2 *) (* Goal: or (dans (couple A (word u0)) R1) (dans (couple A (word u0)) R2) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V2) u, Derive R2 u v) (_ : inmonoid (union X V2) (cons x u)), Derive R2 (cons x u) (cons x v) *) prolog [ inmonoid_cons_inv2 Regles_inv1 ] 3. (* Intros incl_empty_V1 imp incl_empty_X_V2.*) (* Apply dans_empty_imp_P with A. Apply imp. Apply inmonoid_cons_inv2 with v0;Assumption. Apply Regles_inv1 with X R1 (word u0); Assumption. *) (* Goal: Id (union X (add a V1')) f *) assumption. (* Goal: dans a (add a R) *) (* Goal: Regles X V1 (add a R) *) (* Goal: @eq Ensf ((fix map (f : forall _ : Elt, Elt) (e : Ensf) {struct e} : Ensf := match e with | empty => empty | add y e0 => add (f y) (map f e0) end) (fun P : Elt => couple (f (first P)) (word (Word_ext f (word_inv (second P))))) R) R *) trivial. (* Goal: inmonoid Xim (wef nil) *) (* Goal: forall (w : Word) (e : Elt) (_ : inmonoid X w) (_ : inmonoid Xim (wef w)) (_ : dans e X), inmonoid Xim (wef (cons e w)) *) (**) auto. (* Goal: forall (u v : Word) (x : Elt) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V2) u, Derive R2 u v) (_ : inmonoid (union X V2) (cons x u)), Derive R2 (cons x u) (cons x v) *) prolog [ Derive2 inmonoid_cons_inv ] 10. (* Intros u0 v0 x Der_Ru imp inmon_cons_x_u0. Apply Derive2. Apply imp. Apply inmonoid_cons_inv with x. Assumption.*) Qed. Lemma inmon_Der_imp_inmon_R2 : forall u v : Word, Regles X V2 R2 -> Derive R2 u v -> inmonoid (union X V2) u -> inmonoid (union X V2) v. (* Goal: forall (u v : Word) (_ : Regles X V2 R2) (_ : Derive R2 u v) (_ : inmonoid (union X V2) u), inmonoid (union X V2) v *) intros u v Regles_R2 Der_R2. (* Goal: forall _ : inmonoid (union X V2) u, inmonoid (union X V2) v *) elim Der_R2. (* Goal: forall (u v : Word) (A : Elt) (_ : dans (couple A (word u)) R2) (_ : inmonoid (union X V2) (cons A v)), inmonoid (union X V2) (Append u v) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive R2 u v) (_ : forall _ : inmonoid (union X V2) u, inmonoid (union X V2) v) (_ : inmonoid (union X V2) (cons x u)), inmonoid (union X V2) (cons x v) *) intros; prolog [ inmonoid_cons_inv Regles_inv2 inmonoid_Append ] 3. (* Intros u0 v0 A dans_R2 inmonoid_cons_A_v0. Apply inmonoid_Append. Apply Regles_inv2 with R2 A;Assumption. Apply inmonoid_cons_inv with A; Assumption.*) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive R2 u v) (_ : forall _ : inmonoid (union X V2) u, inmonoid (union X V2) v) (_ : inmonoid (union X V2) (cons x u)), inmonoid (union X V2) (cons x v) *) intros; prolog [ inmonoid_cons_inv2 inmonoid_cons_inv inmonoid_cons ] 4. (*Intros u0 v0 x Der_R2_u0 imp inmon_cons_x_u0. Apply inmonoid_cons. Apply imp. Apply inmonoid_cons_inv with x;Assumption. Apply inmonoid_cons_inv2 with u0;Assumption.*) Qed. Lemma inmon_Der_imp_inmon_2 : forall u v : Word, isGram X V1 R1 S1 -> isGram X V2 R2 S2 -> inter V1 V2 empty -> inmonoid (union X V2) u -> Derive Ru u v -> inmonoid (union X V2) v. (* with Prolog...*) intros; prolog [ inmon_Der_imp_inmon_R2 sym_inter isGram2 inter_union isGram4 inmon_Der_imp_Der2 ] 5. (* without Prolog...*) (*Intros u v G_R1 G_R2 inter_V1_V2_empty inmon_X_V2_u Der_Ru_u_v. Apply inmon_Der_imp_inmon_R2 with u. Apply isGram4 with S2;Assumption. Apply inmon_Der_imp_Der2. Apply isGram4 with S1;Assumption. Apply isGram4 with S2;Assumption. Apply inter_union. Apply isGram2 with R1 S1; Assumption. Apply sym_inter; Assumption. Assumption. Assumption. Assumption.*) Qed. Lemma Gunion_Derivestar2 : isGram X V1 R1 S1 -> isGram X V2 R2 S2 -> inter V1 V2 empty -> forall u v : Word, Derivestar Ru u v -> inmonoid (union X V2) u -> Derivestar R2 u v. (* Goal: forall (u v : Word) (_ : Derivestar R1 u v), Derivestar Rim (wef u) (wef v) *) unfold Derivestar in |- *. (* Goal: forall (_ : isGram X V1 R1 S1) (_ : isGram X V2 R2 S2) (_ : inter V1 V2 empty) (u v : Word) (_ : Rstar Word (Derive Ru) u v) (_ : inmonoid (union X V2) u), Rstar Word (Derive R2) u v *) intros G_1 G_2 inter_V1_V2_empty u v Derivestar_Ru. (* Goal: Rstar Word (Derive Rim) (wef u) (wef v) *) pattern u, v in |- *. (* Goal: (fun w w0 : Word => forall _ : inmonoid (union X V2) w, Rstar Word (Derive R2) w w0) u v *) apply Derivestar_Ru. (* Goal: inmonoid Xim (wef nil) *) (* Goal: forall (w : Word) (e : Elt) (_ : inmonoid X w) (_ : inmonoid Xim (wef w)) (_ : dans e X), inmonoid Xim (wef (cons e w)) *) auto. (*Intros. Apply Rstar_reflexive.*) (* Goal: forall (u v w : Word) (_ : Derive Ru u v) (_ : forall _ : inmonoid (union X V2) v, Rstar Word (Derive R2) v w) (_ : inmonoid (union X V2) u), Rstar Word (Derive R2) u w *) intros u0 v0 w Der_Ru inmon_v0_imp_Rstar_R2_v0 inmon_u0. (* Goal: Rstar Word (Derive R2) u0 w *) apply Rstar_R with v0. (* Goal: Derive R2 u0 v0 *) (* Goal: Rstar Word (Derive R2) v0 w *) prolog [ sym_inter isGram2 inter_union isGram4 inmon_Der_imp_Der2 ] 4. (*Apply inmon_Der_imp_Der2. Apply isGram4 with S1;Assumption. Apply isGram4 with S2;Assumption. Apply inter_union. Apply isGram2 with R1 S1; Assumption. Apply sym_inter;Assumption. Assumption. Assumption.*) (* Goal: Rstar Word (Derive R2) v0 w *) prolog [ inmon_Der_imp_inmon_2 ] 3. (*Apply inmon_v0_imp_Rstar_R2_v0. Apply inmon_Der_imp_inmon_2 with u0;Assumption.*) Qed. Lemma Gunion_isGram : forall S : Elt, isGram X V1 R1 S1 -> isGram X V2 R2 S2 -> dans S Vu -> isGram X Vu Ru S. (* Goal: forall (S : Elt) (_ : isGram X V1 R1 S1) (_ : isGram X V2 R2 S2) (_ : dans S Vu), isGram X Vu Ru S *) prolog [ isGram5 isGram1 inter_X_Vu Gunion_Regles ] 7. (*Intros. Apply isGram5. Apply isGram1 with V1 R1 S1 ; Assumption. Apply inter_X_Vu ; Assumption. Assumption. Apply Gunion_Regles; Assumption.*) Qed. Variable f : Elt -> Elt. Let wef := Word_ext f. Let fet (w : Elt) := word (wef (word_inv w)). Let fonc (P : Elt) := couple (f (first P)) (fet (second P)). Let Gim := imageGram f X V1 R1 S1. Let Xim := fst Gim. Let Gim2 := snd Gim. Let Vim := fst Gim2. Let Gim3 := snd Gim2. Let Rim := fst Gim3. Let Sim := snd Gim3. Lemma dans_Rim : forall (A : Elt) (u : Word), dans (couple A (word u)) R1 -> dans (couple (f A) (word (wef u))) Rim. (* Goal: forall (u v : Word) (x : Elt) (_ : Derive R1 u v) (_ : Derive Rim (wef u) (wef v)), Derive Rim (wef (cons x u)) (wef (cons x v)) *) intros. (* Goal: @eq Ensf (add (couple (f (first a)) (word (Word_ext f (word_inv (second a))))) ((fix map (f : forall _ : Elt, Elt) (e : Ensf) {struct e} : Ensf := match e with | empty => empty | add y e0 => add (f y) (map f e0) end) (fun P : Elt => couple (f (first P)) (word (Word_ext f (word_inv (second P))))) R)) (add a R) *) unfold Rim, Gim3, Gim2, Gim, imageGram in |- *; simpl in |- *. replace (couple (f A) (word (wef u))) with (fonc (couple A (word u))); (* Goal: inmonoid Xim (wef nil) *) (* Goal: forall (w : Word) (e : Elt) (_ : inmonoid X w) (_ : inmonoid Xim (wef w)) (_ : dans e X), inmonoid Xim (wef (cons e w)) *) auto. Qed. Hint Resolve dans_Rim. Lemma image_Regles : Regles X V1 R1 -> Regles Xim Vim Rim. unfold Rim, Vim, Xim, Gim3, Gim2, Gim, imageGram, Regles in |- *; (* Goal: @eq Ensf (add (couple (f (first a)) (word (Word_ext f (word_inv (second a))))) ((fix map (f : forall _ : Elt, Elt) (e : Ensf) {struct e} : Ensf := match e with | empty => empty | add y e0 => add (f y) (map f e0) end) (fun P : Elt => couple (f (first P)) (word (Word_ext f (word_inv (second P))))) R)) (add a R) *) simpl in |- *. (* Goal: forall (_ : forall (x : Elt) (_ : dans x R1), @ex2 Elt (fun A : Elt => dans A V1) (fun A : Elt => @ex2 Word (fun B : Word => @eq Elt x (couple A (word B))) (fun B : Word => inmonoid (union X V1) B))) (x : Elt) (_ : dans x (map (fun P : Elt => couple (f (first P)) (word (Word_ext f (word_inv (second P))))) R1)), @ex2 Elt (fun A : Elt => dans A (map f V1)) (fun A : Elt => @ex2 Word (fun B : Word => @eq Elt x (couple A (word B))) (fun B : Word => inmonoid (union (map f X) (map f V1)) B)) *) intros R_R1 x dans_x. (* Goal: @ex2 Elt (fun A : Elt => dans A (map f V1)) (fun A : Elt => @ex2 Word (fun B : Word => @eq Elt x (couple A (word B))) (fun B : Word => inmonoid (union (map f X) (map f V1)) B)) *) cut (exists x_ant : Elt, dans x_ant R1 /\ x = fonc x_ant :>Elt). (* Goal: forall _ : @ex Elt (fun x_ant : Elt => and (dans x_ant R1) (@eq Elt x (fonc x_ant))), @ex2 Elt (fun A : Elt => dans A (map f V1)) (fun A : Elt => @ex2 Word (fun B : Word => @eq Elt x (couple A (word B))) (fun B : Word => inmonoid (union (map f X) (map f V1)) B)) *) (* Goal: @ex Elt (fun x_ant : Elt => and (dans x_ant R1) (@eq Elt x (fonc x_ant))) *) intro temp; elim temp; clear temp. (* Goal: forall (x0 : Elt) (_ : and (dans x0 R1) (@eq Elt x (fonc x0))), @ex2 Elt (fun A : Elt => dans A (map f V1)) (fun A : Elt => @ex2 Word (fun B : Word => @eq Elt x (couple A (word B))) (fun B : Word => inmonoid (union (map f X) (map f V1)) B)) *) (* Goal: @ex Elt (fun x_ant : Elt => and (dans x_ant R1) (@eq Elt x (fonc x_ant))) *) intros x_ant temp; elim temp; clear temp; intros x_ant_in_R1 x_egal. (* Goal: @ex2 Elt (fun A : Elt => dans A (map f V1)) (fun A : Elt => @ex2 Word (fun B : Word => @eq Elt x (couple A (word B))) (fun B : Word => inmonoid (union (map f X) (map f V1)) B)) *) (* Goal: @ex Elt (fun x_ant : Elt => and (dans x_ant R1) (@eq Elt x (fonc x_ant))) *) elim (R_R1 x_ant x_ant_in_R1). (* Goal: forall (x0 : Elt) (_ : dans x0 V1) (_ : @ex2 Word (fun B : Word => @eq Elt x_ant (couple x0 (word B))) (fun B : Word => inmonoid (union X V1) B)), @ex2 Elt (fun A : Elt => dans A (map f V1)) (fun A : Elt => @ex2 Word (fun B : Word => @eq Elt x (couple A (word B))) (fun B : Word => inmonoid (union (map f X) (map f V1)) B)) *) (* Goal: @ex Elt (fun x_ant : Elt => and (dans x_ant R1) (@eq Elt x (fonc x_ant))) *) intros A_ant dans_A_ant_V1 temp; elim temp; clear temp. (* Goal: forall (x0 : Word) (_ : @eq Elt x_ant (couple A_ant (word x0))) (_ : inmonoid (union X V1) x0), @ex2 Elt (fun A : Elt => dans A (map f V1)) (fun A : Elt => @ex2 Word (fun B : Word => @eq Elt x (couple A (word B))) (fun B : Word => inmonoid (union (map f X) (map f V1)) B)) *) (* Goal: @ex Elt (fun x_ant : Elt => and (dans x_ant R1) (@eq Elt x (fonc x_ant))) *) intros B_ant x_ant_egal inmonoid_x_ant. (* Goal: @ex2 Elt (fun A : Elt => dans A (map f V1)) (fun A : Elt => @ex2 Word (fun B : Word => @eq Elt x (couple A (word B))) (fun B : Word => inmonoid (union (map f X) (map f V1)) B)) *) (* Goal: @ex Elt (fun x_ant : Elt => and (dans x_ant R1) (@eq Elt x (fonc x_ant))) *) exists (f A_ant). (* Goal: Id (union X (add a V1')) f *) apply dans_map_inv; assumption. (* Goal: @ex2 Word (fun B : Word => @eq Elt x (couple (f A_ant) (word B))) (fun B : Word => inmonoid (union (map f X) (map f V1)) B) *) (* Goal: @ex Elt (fun x_ant : Elt => and (dans x_ant R1) (@eq Elt x (fonc x_ant))) *) exists (Word_ext f B_ant). (* Goal: @eq Elt x (couple (f A_ant) (word (Word_ext f B_ant))) *) (* Goal: inmonoid (union (map f X) (map f V1)) (Word_ext f B_ant) *) (* Goal: @ex Elt (fun x_ant : Elt => and (dans x_ant R1) (@eq Elt x (fonc x_ant))) *) rewrite x_egal; unfold fonc in |- *; unfold fet in |- *. rewrite x_ant_egal; unfold first in |- *; unfold second in |- *; (* Goal: @eq Ensf (add (couple (f (first a)) (word (Word_ext f (word_inv (second a))))) ((fix map (f : forall _ : Elt, Elt) (e : Ensf) {struct e} : Ensf := match e with | empty => empty | add y e0 => add (f y) (map f e0) end) (fun P : Elt => couple (f (first P)) (word (Word_ext f (word_inv (second P))))) R)) (add a R) *) unfold word_inv in |- *; simpl in |- *. (* Goal: dans a (add a R) *) (* Goal: Regles X V1 (add a R) *) (* Goal: @eq Ensf ((fix map (f : forall _ : Elt, Elt) (e : Ensf) {struct e} : Ensf := match e with | empty => empty | add y e0 => add (f y) (map f e0) end) (fun P : Elt => couple (f (first P)) (word (Word_ext f (word_inv (second P))))) R) R *) trivial. replace (union (map f X) (map f V1)) with (map f (union X V1)); (* Goal: inmonoid Xim (wef nil) *) (* Goal: forall (w : Word) (e : Elt) (_ : inmonoid X w) (_ : inmonoid Xim (wef w)) (_ : dans e X), inmonoid Xim (wef (cons e w)) *) auto. (* Goal: Id (union X (add a V1')) f *) apply dans_map; assumption. (*1*) Qed. Lemma image_isGram : isGram X V1 R1 S1 -> Mots Xim -> inter Xim Vim empty -> isGram Xim Vim Rim Sim. (* Goal: @eq Ensf (add (couple (f (first a)) (word (Word_ext f (word_inv (second a))))) ((fix map (f : forall _ : Elt, Elt) (e : Ensf) {struct e} : Ensf := match e with | empty => empty | add y e0 => add (f y) (map f e0) end) (fun P : Elt => couple (f (first P)) (word (Word_ext f (word_inv (second P))))) R)) (add a R) *) unfold Sim, Rim, Gim3, Vim, Gim2, Xim, Gim, imageGram in |- *; simpl in |- *. (* Goal: forall (_ : isGram X V1 R1 S1) (_ : Mots (map f X)) (_ : inter (map f X) (map f V1) empty), isGram (map f X) (map f V1) (map (fun P : Elt => couple (f (first P)) (word (Word_ext f (word_inv (second P))))) R1) (f S1) *) prolog [ isGram4 image_Regles isGram3 dans_map_inv isGram5 ] 7. (*Intro is_Gram; Intro Mots ; Intro intersec . Apply isGram5. Assumption. Assumption. Apply dans_map_inv ; Apply isGram3 with X R1 ; Assumption. Apply image_Regles; Apply isGram4 with S1; Assumption.*) Qed. Lemma Id_image_X : Id (union X V1) f -> Xim = X :>Ensf. (* Goal: @eq Ensf (add (couple (f (first a)) (word (Word_ext f (word_inv (second a))))) ((fix map (f : forall _ : Elt, Elt) (e : Ensf) {struct e} : Ensf := match e with | empty => empty | add y e0 => add (f y) (map f e0) end) (fun P : Elt => couple (f (first P)) (word (Word_ext f (word_inv (second P))))) R)) (add a R) *) unfold Xim, Gim, imageGram in |- *; simpl in |- *. (* Goal: forall _ : Id (union X V1) f, @eq Ensf (map f X) X *) elim X. (* Goal: inmonoid Xim (wef nil) *) (* Goal: forall (w : Word) (e : Elt) (_ : inmonoid X w) (_ : inmonoid Xim (wef w)) (_ : dans e X), inmonoid Xim (wef (cons e w)) *) auto. (* Clear X. *) (* Goal: forall (e : Elt) (e0 : Ensf) (_ : forall _ : Id (union e0 V1) f, @eq Ensf (map f e0) e0) (_ : Id (union (add e e0) V1) f), @eq Ensf (map f (add e e0)) (add e e0) *) intros a X' Hyp Id_a_X_V1_f. (* Goal: @eq Ensf (map (fun P : Elt => couple (f (first P)) (word (Word_ext f (word_inv (second P))))) (add a R)) (add a R) *) unfold map in |- *. (* Goal: @eq Ensf (add (couple (f (first a)) (word (Word_ext f (word_inv (second a))))) ((fix map (f : forall _ : Elt, Elt) (e : Ensf) {struct e} : Ensf := match e with | empty => empty | add y e0 => add (f y) (map f e0) end) (fun P : Elt => couple (f (first P)) (word (Word_ext f (word_inv (second P))))) R)) (add a R) *) simpl in |- *. (* Goal: @eq Ensf (add (couple (f (first a)) (word (Word_ext f (word_inv (second a))))) ((fix map (f : forall _ : Elt, Elt) (e : Ensf) {struct e} : Ensf := match e with | empty => empty | add y e0 => add (f y) (map f e0) end) (fun P : Elt => couple (f (first P)) (word (Word_ext f (word_inv (second P))))) R)) (add a R) *) apply add_add. (* Goal: inmonoid Xim (wef nil) *) (* Goal: forall (w : Word) (e : Elt) (_ : inmonoid X w) (_ : inmonoid Xim (wef w)) (_ : dans e X), inmonoid Xim (wef (cons e w)) *) auto. (* Goal: (fun w w0 : Word => Rstar Word (Derive Rim) (wef w) (wef w0)) u v *) apply Hyp. (* Goal: Id (union X' V1) f *) apply Id_inclus with (union (add a X') V1). (* Goal: inclus (union X V1') (union X (add a V1')) *) (* Goal: Id (union X (add a V1')) f *) red in |- *; intros x dans_x_union_X_V1. (* Goal: dans x (union (add a X') V1) *) (* Goal: Id (union (add a X') V1) f *) cut (dans x X' \/ dans x V1). (* Goal: inmonoid Xim (wef nil) *) (* Goal: forall (w : Word) (e : Elt) (_ : inmonoid X w) (_ : inmonoid Xim (wef w)) (_ : dans e X), inmonoid Xim (wef (cons e w)) *) intros [HX| HV1]; auto. (* Goal: inmonoid Xim (wef nil) *) (* Goal: forall (w : Word) (e : Elt) (_ : inmonoid X w) (_ : inmonoid Xim (wef w)) (_ : dans e X), inmonoid Xim (wef (cons e w)) *) auto. (* Goal: Id (union X (add a V1')) f *) assumption. Qed. Lemma Id_image_V : Id (union X V1) f -> Vim = V1 :>Ensf. (* Goal: @eq Ensf (add (couple (f (first a)) (word (Word_ext f (word_inv (second a))))) ((fix map (f : forall _ : Elt, Elt) (e : Ensf) {struct e} : Ensf := match e with | empty => empty | add y e0 => add (f y) (map f e0) end) (fun P : Elt => couple (f (first P)) (word (Word_ext f (word_inv (second P))))) R)) (add a R) *) unfold Vim, Gim2, Gim, imageGram; simpl in |- *. (* Goal: forall _ : Id (union X V1) f, @eq Ensf (map f V1) V1 *) generalize V1; clearbody C Gim; clear V1. (* Goal: inmonoid Xim (wef nil) *) (* Goal: forall (w : Word) (e : Elt) (_ : inmonoid X w) (_ : inmonoid Xim (wef w)) (_ : dans e X), inmonoid Xim (wef (cons e w)) *) simple induction V1; auto. (* Goal: forall (e : Elt) (e0 : Ensf) (_ : forall _ : Id (union X e0) f, @eq Ensf (map f e0) e0) (_ : Id (union X (add e e0)) f), @eq Ensf (map f (add e e0)) (add e e0) *) intros a V1' Hyp Id_X_a_V1_f. (* Goal: @eq Ensf (map (fun P : Elt => couple (f (first P)) (word (Word_ext f (word_inv (second P))))) (add a R)) (add a R) *) unfold map in |- *. (* Goal: @eq Ensf (add (couple (f (first a)) (word (Word_ext f (word_inv (second a))))) ((fix map (f : forall _ : Elt, Elt) (e : Ensf) {struct e} : Ensf := match e with | empty => empty | add y e0 => add (f y) (map f e0) end) (fun P : Elt => couple (f (first P)) (word (Word_ext f (word_inv (second P))))) R)) (add a R) *) simpl in |- *. (* Goal: @eq Ensf (add (couple (f (first a)) (word (Word_ext f (word_inv (second a))))) ((fix map (f : forall _ : Elt, Elt) (e : Ensf) {struct e} : Ensf := match e with | empty => empty | add y e0 => add (f y) (map f e0) end) (fun P : Elt => couple (f (first P)) (word (Word_ext f (word_inv (second P))))) R)) (add a R) *) apply add_add. (* Goal: inmonoid Xim (wef nil) *) (* Goal: forall (w : Word) (e : Elt) (_ : inmonoid X w) (_ : inmonoid Xim (wef w)) (_ : dans e X), inmonoid Xim (wef (cons e w)) *) auto. (* Goal: (fun w w0 : Word => Rstar Word (Derive Rim) (wef w) (wef w0)) u v *) apply Hyp. (* Goal: Id (union X V1') f *) apply Id_inclus with (union X (add a V1')). (* Goal: inclus (union X V1') (union X (add a V1')) *) (* Goal: Id (union X (add a V1')) f *) red in |- *; intros x dans_x_union_X_V1. (* Goal: dans x (union X (add a V1')) *) (* Goal: Id (union X (add a V1')) f *) cut (dans x X \/ dans x V1'). (* Goal: inmonoid Xim (wef nil) *) (* Goal: forall (w : Word) (e : Elt) (_ : inmonoid X w) (_ : inmonoid Xim (wef w)) (_ : dans e X), inmonoid Xim (wef (cons e w)) *) intros [HX| HV1]; auto. (* Goal: inmonoid Xim (wef nil) *) (* Goal: forall (w : Word) (e : Elt) (_ : inmonoid X w) (_ : inmonoid Xim (wef w)) (_ : dans e X), inmonoid Xim (wef (cons e w)) *) auto. (* Goal: Id (union X (add a V1')) f *) assumption. Qed. Lemma Id_image_R : Id (union X V1) f -> isGram X V1 R1 S1 -> Rim = R1 :>Ensf. (* Goal: forall (_ : Id (union X V1) f) (_ : isGram X V1 R1 S1), @eq Ensf Rim R1 *) intros Id_X_V1_f. (* Goal: @eq Ensf (add (couple (f (first a)) (word (Word_ext f (word_inv (second a))))) ((fix map (f : forall _ : Elt, Elt) (e : Ensf) {struct e} : Ensf := match e with | empty => empty | add y e0 => add (f y) (map f e0) end) (fun P : Elt => couple (f (first P)) (word (Word_ext f (word_inv (second P))))) R)) (add a R) *) unfold Rim, Gim3, Gim2, Gim, imageGram in |- *; simpl in |- *. (* Goal: forall _ : isGram X V1 R1 S1, @eq Ensf (map (fun P : Elt => couple (f (first P)) (word (Word_ext f (word_inv (second P))))) R1) R1 *) elim R1. (* Goal: inmonoid Xim (wef nil) *) (* Goal: forall (w : Word) (e : Elt) (_ : inmonoid X w) (_ : inmonoid Xim (wef w)) (_ : dans e X), inmonoid Xim (wef (cons e w)) *) auto. (* Goal: forall (e : Elt) (e0 : Ensf) (_ : forall _ : isGram X V1 e0 S1, @eq Ensf (map (fun P : Elt => couple (f (first P)) (word (Word_ext f (word_inv (second P))))) e0) e0) (_ : isGram X V1 (add e e0) S1), @eq Ensf (map (fun P : Elt => couple (f (first P)) (word (Word_ext f (word_inv (second P))))) (add e e0)) (add e e0) *) intros a R Hyp isGram_X_V1_R1_S1. (* Goal: @eq Ensf (map (fun P : Elt => couple (f (first P)) (word (Word_ext f (word_inv (second P))))) (add a R)) (add a R) *) unfold map in |- *. (* Goal: @eq Ensf (add (couple (f (first a)) (word (Word_ext f (word_inv (second a))))) ((fix map (f : forall _ : Elt, Elt) (e : Ensf) {struct e} : Ensf := match e with | empty => empty | add y e0 => add (f y) (map f e0) end) (fun P : Elt => couple (f (first P)) (word (Word_ext f (word_inv (second P))))) R)) (add a R) *) simpl in |- *. (* Goal: @eq Ensf (add (couple (f (first a)) (word (Word_ext f (word_inv (second a))))) ((fix map (f : forall _ : Elt, Elt) (e : Ensf) {struct e} : Ensf := match e with | empty => empty | add y e0 => add (f y) (map f e0) end) (fun P : Elt => couple (f (first P)) (word (Word_ext f (word_inv (second P))))) R)) (add a R) *) apply add_add. (* Goal: @eq Elt (couple (f (first a)) (word (Word_ext f (word_inv (second a))))) a *) (* Goal: @eq Ensf ((fix map (f : forall _ : Elt, Elt) (e : Ensf) {struct e} : Ensf := match e with | empty => empty | add y e0 => add (f y) (map f e0) end) (fun P : Elt => couple (f (first P)) (word (Word_ext f (word_inv (second P))))) R) R *) cut (Regles X V1 (add a R)). (* Goal: forall _ : Regles X V1 (add a R), @eq Elt (couple (f (first a)) (word (Word_ext f (word_inv (second a))))) a *) (* Goal: Regles X V1 (add a R) *) (* Goal: @eq Ensf ((fix map (f : forall _ : Elt, Elt) (e : Ensf) {struct e} : Ensf := match e with | empty => empty | add y e0 => add (f y) (map f e0) end) (fun P : Elt => couple (f (first P)) (word (Word_ext f (word_inv (second P))))) R) R *) unfold Regles in |- *. (* Goal: forall _ : forall (x : Elt) (_ : dans x (add a R)), @ex2 Elt (fun A : Elt => dans A V1) (fun A : Elt => @ex2 Word (fun B : Word => @eq Elt x (couple A (word B))) (fun B : Word => inmonoid (union X V1) B)), @eq Elt (couple (f (first a)) (word (Word_ext f (word_inv (second a))))) a *) (* Goal: Regles X V1 (add a R) *) (* Goal: @eq Ensf ((fix map (f : forall _ : Elt, Elt) (e : Ensf) {struct e} : Ensf := match e with | empty => empty | add y e0 => add (f y) (map f e0) end) (fun P : Elt => couple (f (first P)) (word (Word_ext f (word_inv (second P))))) R) R *) intro R_a_R. (* Goal: @eq Elt (couple (f (first a)) (word (Word_ext f (word_inv (second a))))) a *) (* Goal: Regles X V1 (add a R) *) (* Goal: @eq Ensf ((fix map (f : forall _ : Elt, Elt) (e : Ensf) {struct e} : Ensf := match e with | empty => empty | add y e0 => add (f y) (map f e0) end) (fun P : Elt => couple (f (first P)) (word (Word_ext f (word_inv (second P))))) R) R *) elim (R_a_R a). (* Goal: forall (x : Elt) (_ : dans x V1) (_ : @ex2 Word (fun B : Word => @eq Elt a (couple x (word B))) (fun B : Word => inmonoid (union X V1) B)), @eq Elt (couple (f (first a)) (word (Word_ext f (word_inv (second a))))) a *) (* Goal: dans a (add a R) *) (* Goal: Regles X V1 (add a R) *) (* Goal: @eq Ensf ((fix map (f : forall _ : Elt, Elt) (e : Ensf) {struct e} : Ensf := match e with | empty => empty | add y e0 => add (f y) (map f e0) end) (fun P : Elt => couple (f (first P)) (word (Word_ext f (word_inv (second P))))) R) R *) intros x dans_x_V1 temp; elim temp; clear temp. (* Goal: forall (x0 : Word) (_ : @eq Elt a (couple x (word x0))) (_ : inmonoid (union X V1) x0), @eq Elt (couple (f (first a)) (word (Word_ext f (word_inv (second a))))) a *) (* Goal: dans a (add a R) *) (* Goal: Regles X V1 (add a R) *) (* Goal: @eq Ensf ((fix map (f : forall _ : Elt, Elt) (e : Ensf) {struct e} : Ensf := match e with | empty => empty | add y e0 => add (f y) (map f e0) end) (fun P : Elt => couple (f (first P)) (word (Word_ext f (word_inv (second P))))) R) R *) intros B egal_a inmonoid_B. (* Goal: @eq Elt (couple (f (first a)) (word (Word_ext f (word_inv (second a))))) a *) (* Goal: dans a (add a R) *) (* Goal: Regles X V1 (add a R) *) (* Goal: @eq Ensf ((fix map (f : forall _ : Elt, Elt) (e : Ensf) {struct e} : Ensf := match e with | empty => empty | add y e0 => add (f y) (map f e0) end) (fun P : Elt => couple (f (first P)) (word (Word_ext f (word_inv (second P))))) R) R *) rewrite egal_a. (* Goal: @eq Ensf (add (couple (f (first a)) (word (Word_ext f (word_inv (second a))))) ((fix map (f : forall _ : Elt, Elt) (e : Ensf) {struct e} : Ensf := match e with | empty => empty | add y e0 => add (f y) (map f e0) end) (fun P : Elt => couple (f (first P)) (word (Word_ext f (word_inv (second P))))) R)) (add a R) *) apply couple_couple; unfold first, second, word_inv in |- *; simpl in |- *. (* Goal: inmonoid Xim (wef nil) *) (* Goal: forall (w : Word) (e : Elt) (_ : inmonoid X w) (_ : inmonoid Xim (wef w)) (_ : dans e X), inmonoid Xim (wef (cons e w)) *) auto. (* Goal: @eq Elt (word (Word_ext f B)) (word B) *) (* Goal: dans a (add a R) *) (* Goal: Regles X V1 (add a R) *) (* Goal: @eq Ensf ((fix map (f : forall _ : Elt, Elt) (e : Ensf) {struct e} : Ensf := match e with | empty => empty | add y e0 => add (f y) (map f e0) end) (fun P : Elt => couple (f (first P)) (word (Word_ext f (word_inv (second P))))) R) R *) apply word_word. (* Goal: inmonoid Xim (wef nil) *) (* Goal: forall (w : Word) (e : Elt) (_ : inmonoid X w) (_ : inmonoid Xim (wef w)) (_ : dans e X), inmonoid Xim (wef (cons e w)) *) cut (Id_words (union X V1) (Word_ext f)); auto. (* Goal: dans a (add a R) *) (* Goal: Regles X V1 (add a R) *) (* Goal: @eq Ensf ((fix map (f : forall _ : Elt, Elt) (e : Ensf) {struct e} : Ensf := match e with | empty => empty | add y e0 => add (f y) (map f e0) end) (fun P : Elt => couple (f (first P)) (word (Word_ext f (word_inv (second P))))) R) R *) trivial. (* Goal: dans a (add a R) *) (* Goal: Regles X V1 (add a R) *) (* Goal: @eq Ensf ((fix map (f : forall _ : Elt, Elt) (e : Ensf) {struct e} : Ensf := match e with | empty => empty | add y e0 => add (f y) (map f e0) end) (fun P : Elt => couple (f (first P)) (word (Word_ext f (word_inv (second P))))) R) R *) apply isGram4 with S1; trivial. (* Goal: @eq Ensf ((fix map (f : forall _ : Elt, Elt) (e : Ensf) {struct e} : Ensf := match e with | empty => empty | add y e0 => add (f y) (map f e0) end) (fun P : Elt => couple (f (first P)) (word (Word_ext f (word_inv (second P))))) R) R *) prolog [ isGram_inclus3 ] 3. (*Apply Hyp. Apply isGram_inclus3 with a; Assumption.*) Qed. Lemma Id_image_S : Id (union X V1) f -> isGram X V1 R1 S1 -> Sim = S1 :>Elt. (* Goal: @eq Ensf (add (couple (f (first a)) (word (Word_ext f (word_inv (second a))))) ((fix map (f : forall _ : Elt, Elt) (e : Ensf) {struct e} : Ensf := match e with | empty => empty | add y e0 => add (f y) (map f e0) end) (fun P : Elt => couple (f (first P)) (word (Word_ext f (word_inv (second P))))) R)) (add a R) *) unfold Sim, Gim3, Gim2, Gim, imageGram in |- *; simpl in |- *. (* Goal: forall (_ : Id (union X V1) f) (_ : isGram X V1 R1 S1), @eq Elt (f S1) S1 *) prolog [ isGram3 union_d ] 6. (*Intros Id_union_X_V1_f isGram_X_V1_R1_S1. Apply Id_union_X_V1_f. Apply union_d. Apply isGram3 with X R1; Assumption.*) Qed. Lemma Gim_egal : Gim = (Xim, (Vim, (Rim, Sim))). (* Goal: @eq (prod Ensf (prod Ensf (prod Ensf Elt))) Gim (@pair Ensf (prod Ensf (prod Ensf Elt)) Xim (@pair Ensf (prod Ensf Elt) Vim (@pair Ensf Elt Rim Sim))) *) unfold Sim, Rim, Gim3, Vim, Gim2, Xim in |- *. (* Goal: @eq (prod Ensf (prod Ensf (prod Ensf Elt))) (@pair Ensf (prod Ensf (prod Ensf Elt)) X (@pair Ensf (prod Ensf Elt) V1 (@pair Ensf Elt R1 S1))) (@pair Ensf (prod Ensf (prod Ensf Elt)) X (@pair Ensf (prod Ensf Elt) V1 (@pair Ensf Elt R1 S1))) *) apply refl_equal. Qed. Lemma Id_image_G : Id (union X V1) f -> isGram X V1 R1 S1 -> Gim = (X, (V1, (R1, S1))). (* Goal: forall (_ : Id (union X V1) f) (_ : isGram X V1 R1 S1), @eq (prod Ensf (prod Ensf (prod Ensf Elt))) Gim (@pair Ensf (prod Ensf (prod Ensf Elt)) X (@pair Ensf (prod Ensf Elt) V1 (@pair Ensf Elt R1 S1))) *) intros Id_u_X_V1_f isG_X_V1_R1_S1. (* Goal: @eq (prod Ensf (prod Ensf (prod Ensf Elt))) Gim (@pair Ensf (prod Ensf (prod Ensf Elt)) X (@pair Ensf (prod Ensf Elt) V1 (@pair Ensf Elt R1 S1))) *) rewrite Gim_egal. (* Goal: @eq (prod Ensf (prod Ensf (prod Ensf Elt))) (@pair Ensf (prod Ensf (prod Ensf Elt)) Xim (@pair Ensf (prod Ensf Elt) Vim (@pair Ensf Elt Rim Sim))) (@pair Ensf (prod Ensf (prod Ensf Elt)) X (@pair Ensf (prod Ensf Elt) V1 (@pair Ensf Elt R1 S1))) *) rewrite (Id_image_S Id_u_X_V1_f isG_X_V1_R1_S1). (* Goal: @eq (prod Ensf (prod Ensf (prod Ensf Elt))) (@pair Ensf (prod Ensf (prod Ensf Elt)) Xim (@pair Ensf (prod Ensf Elt) Vim (@pair Ensf Elt Rim S1))) (@pair Ensf (prod Ensf (prod Ensf Elt)) X (@pair Ensf (prod Ensf Elt) V1 (@pair Ensf Elt R1 S1))) *) rewrite (Id_image_R Id_u_X_V1_f isG_X_V1_R1_S1). (* Goal: @eq (prod Ensf (prod Ensf (prod Ensf Elt))) (@pair Ensf (prod Ensf (prod Ensf Elt)) Xim (@pair Ensf (prod Ensf Elt) Vim (@pair Ensf Elt R1 S1))) (@pair Ensf (prod Ensf (prod Ensf Elt)) X (@pair Ensf (prod Ensf Elt) V1 (@pair Ensf Elt R1 S1))) *) rewrite (Id_image_V Id_u_X_V1_f). (* Goal: @eq (prod Ensf (prod Ensf (prod Ensf Elt))) (@pair Ensf (prod Ensf (prod Ensf Elt)) Xim (@pair Ensf (prod Ensf Elt) V1 (@pair Ensf Elt R1 S1))) (@pair Ensf (prod Ensf (prod Ensf Elt)) X (@pair Ensf (prod Ensf Elt) V1 (@pair Ensf Elt R1 S1))) *) rewrite (Id_image_X Id_u_X_V1_f). (* Goal: @eq (prod Ensf (prod Ensf (prod Ensf Elt))) (@pair Ensf (prod Ensf (prod Ensf Elt)) X (@pair Ensf (prod Ensf Elt) V1 (@pair Ensf Elt R1 S1))) (@pair Ensf (prod Ensf (prod Ensf Elt)) X (@pair Ensf (prod Ensf Elt) V1 (@pair Ensf Elt R1 S1))) *) apply refl_equal. Qed. Lemma Derive_image : forall u v : Word, Derive R1 u v -> Derive Rim (wef u) (wef v). (* Goal: forall (u v : Word) (_ : Derive R1 u v), Derive Rim (wef u) (wef v) *) intros u v H. (* Goal: Derive Rim (wef u) (wef v) *) elim H; clear H u v. (* Goal: forall (u v : Word) (A : Elt) (_ : dans (couple A (word u)) R1), Derive Rim (wef (cons A v)) (wef (Append u v)) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive R1 u v) (_ : Derive Rim (wef u) (wef v)), Derive Rim (wef (cons x u)) (wef (cons x v)) *) intros u v A dans_A. (* Goal: Derive Rim (wef (cons A v)) (wef (Append u v)) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive R1 u v) (_ : Derive Rim (wef u) (wef v)), Derive Rim (wef (cons x u)) (wef (cons x v)) *) replace (wef (cons A v)) with (cons (f A) (wef v)). (* Goal: Derive Rim (cons (f A) (wef v)) (wef (Append u v)) *) (* Goal: @eq Word (cons (f A) (wef v)) (wef (cons A v)) *) (* Goal: forall (u v : Word) (x : Elt) (_ : Derive R1 u v) (_ : Derive Rim (wef u) (wef v)), Derive Rim (wef (cons x u)) (wef (cons x v)) *) replace (wef (Append u v)) with (Append (wef u) (wef v)). (* Goal: inmonoid Xim (wef nil) *) (* Goal: forall (w : Word) (e : Elt) (_ : inmonoid X w) (_ : inmonoid Xim (wef w)) (_ : dans e X), inmonoid Xim (wef (cons e w)) *) auto. (* Goal: inmonoid Xim (wef nil) *) (* Goal: forall (w : Word) (e : Elt) (_ : inmonoid X w) (_ : inmonoid Xim (wef w)) (_ : dans e X), inmonoid Xim (wef (cons e w)) *) apply sym_equal; unfold wef in |- *; apply wef_append; auto. (* Goal: inmonoid Xim (wef nil) *) (* Goal: forall (w : Word) (e : Elt) (_ : inmonoid X w) (_ : inmonoid Xim (wef w)) (_ : dans e X), inmonoid Xim (wef (cons e w)) *) auto. (* Goal: forall (u v : Word) (x : Elt) (_ : Derive R1 u v) (_ : Derive Rim (wef u) (wef v)), Derive Rim (wef (cons x u)) (wef (cons x v)) *) intros. (* Goal: Derive Rim (wef (cons x u)) (wef (cons x v)) *) replace (wef (cons x u)) with (cons (f x) (wef u)). (* Goal: inmonoid Xim (wef nil) *) (* Goal: forall (w : Word) (e : Elt) (_ : inmonoid X w) (_ : inmonoid Xim (wef w)) (_ : dans e X), inmonoid Xim (wef (cons e w)) *) replace (wef (cons x v)) with (cons (f x) (wef v)); auto. (* Goal: inmonoid Xim (wef nil) *) (* Goal: forall (w : Word) (e : Elt) (_ : inmonoid X w) (_ : inmonoid Xim (wef w)) (_ : dans e X), inmonoid Xim (wef (cons e w)) *) auto. Qed. Hint Resolve Derive_image. Lemma Derivestar_image : forall u v : Word, Derivestar R1 u v -> Derivestar Rim (wef u) (wef v). (* Goal: forall (u v : Word) (_ : Derivestar R1 u v), Derivestar Rim (wef u) (wef v) *) unfold Derivestar in |- *. (* Goal: forall (u v : Word) (_ : Rstar Word (Derive R1) u v), Rstar Word (Derive Rim) (wef u) (wef v) *) intros u v Hyp. (* Goal: Rstar Word (Derive Rim) (wef u) (wef v) *) unfold Derivestar, Rstar in Hyp. (* Goal: Rstar Word (Derive Rim) (wef u) (wef v) *) pattern u, v in |- *. (* Goal: (fun w w0 : Word => Rstar Word (Derive Rim) (wef w) (wef w0)) u v *) apply Hyp. (* Goal: inmonoid Xim (wef nil) *) (* Goal: forall (w : Word) (e : Elt) (_ : inmonoid X w) (_ : inmonoid Xim (wef w)) (_ : dans e X), inmonoid Xim (wef (cons e w)) *) auto. (*Intros; Apply Rstar_reflexive. *) (* Goal: forall (u v w : Word) (_ : Derive R1 u v) (_ : Rstar Word (Derive Rim) (wef v) (wef w)), Rstar Word (Derive Rim) (wef u) (wef w) *) intros a b c DeriveR1 Rst. (* Goal: inmonoid Xim (wef nil) *) (* Goal: forall (w : Word) (e : Elt) (_ : inmonoid X w) (_ : inmonoid Xim (wef w)) (_ : dans e X), inmonoid Xim (wef (cons e w)) *) apply Rstar_R with (y := wef b); auto. Qed. Hint Resolve Derivestar_image. Lemma Reconnait_imageGram : forall w : Word, LG X V1 R1 S1 w -> LG Xim Vim Rim Sim (wef w). (* Goal: forall (w : Word) (_ : LG X V1 R1 S1 w), LG Xim Vim Rim Sim (wef w) *) intro w. (* Goal: forall _ : LG X V1 R1 S1 w, LG Xim Vim Rim Sim (wef w) *) unfold LG in |- *. (* Goal: forall _ : and (Derivestar R1 (cons S1 nil) w) (inmonoid X w), and (Derivestar Rim (cons Sim nil) (wef w)) (inmonoid Xim (wef w)) *) intro temp; split; elim temp; clear temp; intros Der inmo. (* Goal: @eq Ensf (add (couple (f (first a)) (word (Word_ext f (word_inv (second a))))) ((fix map (f : forall _ : Elt, Elt) (e : Ensf) {struct e} : Ensf := match e with | empty => empty | add y e0 => add (f y) (map f e0) end) (fun P : Elt => couple (f (first P)) (word (Word_ext f (word_inv (second P))))) R)) (add a R) *) unfold Sim, Gim3, Gim2, Gim, imageGram in |- *; simpl in |- *. (* Goal: inmonoid Xim (wef nil) *) (* Goal: forall (w : Word) (e : Elt) (_ : inmonoid X w) (_ : inmonoid Xim (wef w)) (_ : dans e X), inmonoid Xim (wef (cons e w)) *) replace (cons (f S1) nil) with (wef (cons S1 nil)); auto. (* Goal: inmonoid Xim (wef w) *) elim inmo. (* Goal: inmonoid Xim (wef nil) *) (* Goal: forall (w : Word) (e : Elt) (_ : inmonoid X w) (_ : inmonoid Xim (wef w)) (_ : dans e X), inmonoid Xim (wef (cons e w)) *) auto. (* Goal: forall (w : Word) (e : Elt) (_ : inmonoid X w) (_ : inmonoid Xim (wef w)) (_ : dans e X), inmonoid Xim (wef (cons e w)) *) intros wo el. (* Goal: @eq Ensf (add (couple (f (first a)) (word (Word_ext f (word_inv (second a))))) ((fix map (f : forall _ : Elt, Elt) (e : Ensf) {struct e} : Ensf := match e with | empty => empty | add y e0 => add (f y) (map f e0) end) (fun P : Elt => couple (f (first P)) (word (Word_ext f (word_inv (second P))))) R)) (add a R) *) unfold Xim, Gim, imageGram in |- *; simpl in |- *. (* Goal: inmonoid Xim (wef nil) *) (* Goal: forall (w : Word) (e : Elt) (_ : inmonoid X w) (_ : inmonoid Xim (wef w)) (_ : dans e X), inmonoid Xim (wef (cons e w)) *) replace (wef (cons el wo)) with (cons (f el) (wef wo)); auto. Qed. End resultats. Hint Resolve dans_Rim. Hint Resolve Derive_image. Hint Resolve Derivestar_image. Hint Resolve Reconnait_imageGram.
(* This program is free software; you can redistribute it and/or *) (* modify it under the terms of the GNU Lesser General Public License *) (* as published by the Free Software Foundation; either version 2.1 *) (* of the License, or (at your option) any later version. *) (* *) (* This program is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* GNU General Public License for more details. *) (* *) (* You should have received a copy of the GNU Lesser General Public *) (* License along with this program; if not, write to the Free *) (* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *) (* 02110-1301 USA *) (* Contribution to the Coq Library V6.3 (July 1999) *) (****************************************************************************) (* The Calculus of Inductive Constructions *) (* *) (* Projet Coq *) (* *) (* INRIA ENS-CNRS *) (* Rocquencourt Lyon *) (* *) (* Coq V5.10 *) (* Nov 25th 1994 *) (* *) (****************************************************************************) (* gram3.v *) (****************************************************************************) (* Formal Language Theory *) (* *) (* Judicael Courant - Jean-Christophe Filliatre *) (* *) (* Developped in V5.8 June-July 1993 *) (* Ported to V5.10 October 1994 *) (****************************************************************************) Require Import Ensf. Require Import Words. Require Import more_words. Require Import need. Require Import fonctions. Require Import Relations. Require Import gram. Require Import gram2. Section resultats_iso_image. Variable X V R : Ensf. Variable S : Elt. Variable f : Elt -> Elt. Let Gim := imageGram f X V R S. Let Xim := fst Gim. Let Gim2 := snd Gim. Let Vim := fst Gim2. Let Gim3 := snd Gim2. Let Rim := fst Gim3. Let Sim := snd Gim3. Let invf := inv (union X V) (union Xim Vim) f. Let Gim' := imageGram invf Xim Vim Rim Sim. Let Xim' := fst Gim'. Let Gim2' := snd Gim'. Let Vim' := fst Gim2'. Let Gim3' := snd Gim2'. Let Rim' := fst Gim3'. Let Sim' := snd Gim3'. Hypothesis Gram : isGram X V R S. Lemma Regles_X_V_R : Regles X V R. Proof isGram4 X V R S Gram. Hypothesis Mono : is_mono (union X V) f. Lemma inter_Xim_Vim_empty : inter Xim Vim empty. (* Goal: inter Xim Vim empty *) unfold Xim, Vim in |- *; simpl in |- *. (* Goal: inter (map f X) (map f V) empty *) red in |- *. (* Goal: and (inclus empty (map f X)) (and (inclus empty (map f V)) (forall (x : Elt) (_ : dans x (map f X)) (_ : dans x (map f V)), dans x empty)) *) (*Intuition.*) split; [ idtac | split ]. (* Goal: inclus X (union X V) *) (* Goal: inmonoid X w *) (* Goal: Id_words (union X V) (comp_word weinvf wef) *) (* Goal: @eq Ensf Rim' R *) (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) auto. (* Goal: inclus X (union X V) *) (* Goal: inmonoid X w *) (* Goal: Id_words (union X V) (comp_word weinvf wef) *) (* Goal: @eq Ensf Rim' R *) (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) auto. (* Goal: forall (x : Elt) (_ : dans x (map f X)) (_ : dans x (map f V)), dans x empty *) intros x dans_x_map_f_X dans_x_map_f_V. (* Goal: dans x empty *) elimtype (exists y : Elt, dans y X /\ x = f y :>Elt). (* Goal: forall (x0 : Elt) (_ : and (dans x0 X) (@eq Elt x (f x0))), dans x empty *) (* Goal: @ex Elt (fun y : Elt => and (dans y X) (@eq Elt x (f y))) *) elimtype (exists y : Elt, dans y V /\ x = f y :>Elt). (* Goal: forall (x0 : Elt) (_ : and (dans x0 V) (@eq Elt x (f x0))) (x1 : Elt) (_ : and (dans x1 X) (@eq Elt x (f x1))), dans x empty *) (* Goal: @ex Elt (fun y : Elt => and (dans y V) (@eq Elt x (f y))) *) (* Goal: @ex Elt (fun y : Elt => and (dans y X) (@eq Elt x (f y))) *) intros v temp; elim temp; clear temp. (* Goal: forall (_ : dans v V) (_ : @eq Elt x (f v)) (x0 : Elt) (_ : and (dans x0 X) (@eq Elt x (f x0))), dans x empty *) (* Goal: @ex Elt (fun y : Elt => and (dans y V) (@eq Elt x (f y))) *) (* Goal: @ex Elt (fun y : Elt => and (dans y X) (@eq Elt x (f y))) *) intros dans_v_V x_egal_f_v x_ant temp; elim temp; clear temp. (* Goal: forall (_ : dans x_ant X) (_ : @eq Elt x (f x_ant)), dans x empty *) (* Goal: @ex Elt (fun y : Elt => and (dans y V) (@eq Elt x (f y))) *) (* Goal: @ex Elt (fun y : Elt => and (dans y X) (@eq Elt x (f y))) *) intros dans_x_ant_X x_egal_f_x_ant. (* Goal: dans x empty *) (* Goal: @ex Elt (fun y : Elt => and (dans y V) (@eq Elt x (f y))) *) (* Goal: @ex Elt (fun y : Elt => and (dans y X) (@eq Elt x (f y))) *) elimtype (inter X V empty). (* Goal: forall (_ : inclus empty X) (_ : and (inclus empty V) (forall (x : Elt) (_ : dans x X) (_ : dans x V), dans x empty)), dans x empty *) (* Goal: and (inclus empty X) (and (inclus empty V) (forall (x : Elt) (_ : dans x X) (_ : dans x V), dans x empty)) *) (* Goal: @ex Elt (fun y : Elt => and (dans y V) (@eq Elt x (f y))) *) (* Goal: @ex Elt (fun y : Elt => and (dans y X) (@eq Elt x (f y))) *) intros incl_empty_X temp; elim temp; clear temp. intros incl_empty_V imp. (* Goal: dans x empty *) (* Goal: and (inclus empty X) (and (inclus empty V) (forall (x : Elt) (_ : dans x X) (_ : dans x V), dans x empty)) *) (* Goal: @ex Elt (fun y : Elt => and (dans y V) (@eq Elt x (f y))) *) (* Goal: @ex Elt (fun y : Elt => and (dans y X) (@eq Elt x (f y))) *) apply dans_empty_imp_P with v. (* Goal: dans v empty *) (* Goal: and (inclus empty X) (and (inclus empty V) (forall (x : Elt) (_ : dans x X) (_ : dans x V), dans x empty)) *) (* Goal: @ex Elt (fun y : Elt => and (dans y V) (@eq Elt x (f y))) *) (* Goal: @ex Elt (fun y : Elt => and (dans y X) (@eq Elt x (f y))) *) apply imp. (* Goal: dans v X *) (* Goal: dans v V *) (* Goal: and (inclus empty X) (and (inclus empty V) (forall (x : Elt) (_ : dans x X) (_ : dans x V), dans x empty)) *) (* Goal: @ex Elt (fun y : Elt => and (dans y V) (@eq Elt x (f y))) *) (* Goal: @ex Elt (fun y : Elt => and (dans y X) (@eq Elt x (f y))) *) replace v with x_ant. (* Goal: LG Xim Vim Rim Sim w *) (* Goal: @eq Word w (wef w) *) (* Goal: @eq Word (weinvf (wef w)) w *) (* Goal: @eq Ensf Rim' R *) (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) assumption. (* Goal: @eq Elt x_ant v *) (* Goal: dans v V *) (* Goal: and (inclus empty X) (and (inclus empty V) (forall (x : Elt) (_ : dans x X) (_ : dans x V), dans x empty)) *) (* Goal: @ex Elt (fun y : Elt => and (dans y V) (@eq Elt x (f y))) *) (* Goal: @ex Elt (fun y : Elt => and (dans y X) (@eq Elt x (f y))) *) apply Mono. (* Goal: inclus X (union X V) *) (* Goal: inmonoid X w *) (* Goal: Id_words (union X V) (comp_word weinvf wef) *) (* Goal: @eq Ensf Rim' R *) (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) auto. (* Goal: inclus X (union X V) *) (* Goal: inmonoid X w *) (* Goal: Id_words (union X V) (comp_word weinvf wef) *) (* Goal: @eq Ensf Rim' R *) (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) auto. (* Goal: LG Xim Vim Rim Sim w *) (* Goal: @eq Word w (wef w) *) (* Goal: @eq Word (weinvf (wef w)) w *) (* Goal: @eq Ensf Rim' R *) (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) rewrite <- x_egal_f_x_ant; assumption. (* Goal: LG Xim Vim Rim Sim w *) (* Goal: @eq Word w (wef w) *) (* Goal: @eq Word (weinvf (wef w)) w *) (* Goal: @eq Ensf Rim' R *) (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) assumption. (* Goal: and (inclus empty X) (and (inclus empty V) (forall (x : Elt) (_ : dans x X) (_ : dans x V), dans x empty)) *) (* Goal: @ex Elt (fun y : Elt => and (dans y V) (@eq Elt x (f y))) *) (* Goal: @ex Elt (fun y : Elt => and (dans y X) (@eq Elt x (f y))) *) exact (isGram2 X V R S Gram). (* Goal: inclus X (union X V) *) (* Goal: inmonoid X w *) (* Goal: Id_words (union X V) (comp_word weinvf wef) *) (* Goal: @eq Ensf Rim' R *) (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) auto. (* Goal: inclus X (union X V) *) (* Goal: inmonoid X w *) (* Goal: Id_words (union X V) (comp_word weinvf wef) *) (* Goal: @eq Ensf Rim' R *) (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) auto. Qed. Lemma union_Xim_Vim_map_f_union_X_V : union Xim Vim = map f (union X V) :>Ensf. (* Goal: @eq Ensf (union Xim Vim) (map f (union X V)) *) unfold Xim, Vim, Gim2, Gim, imageGram in |- *; simpl in |- *. (* Goal: @eq Ensf (union (map f X) (map f V)) (map f (union X V)) *) apply map_union. Qed. Lemma Iso : is_iso (union X V) (union Xim Vim) f. (* Goal: is_iso (union X V) (union Xim Vim) f *) rewrite union_Xim_Vim_map_f_union_X_V. (* Goal: inclus X (union X V) *) (* Goal: inmonoid X w *) (* Goal: Id_words (union X V) (comp_word weinvf wef) *) (* Goal: @eq Ensf Rim' R *) (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) auto. Qed. Hint Resolve Iso. Let wef := Word_ext f. Let weinvf := Word_ext invf. Lemma invf_f : Id (union X V) (comp invf f). (* Goal: Id (union X V) (comp invf f) *) (* Goal: isGram X V R S *) unfold invf in |- *. (* Goal: inclus X (union X V) *) (* Goal: inmonoid X w *) (* Goal: Id_words (union X V) (comp_word weinvf wef) *) (* Goal: @eq Ensf Rim' R *) (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) auto. Qed. Lemma weinvf_wef : Id_words (union X V) (comp_word weinvf wef). (* Goal: Id_words (union X V) (comp_word weinvf wef) *) unfold Id_words in |- *. (* Goal: forall (x : Word) (_ : inmonoid (union X V) x), @eq Word (comp_word weinvf wef x) x *) unfold weinvf, wef in |- *. (* Goal: forall (x : Word) (_ : inmonoid (union X V) x), @eq Word (comp_word (Word_ext invf) (Word_ext f) x) x *) intro x. (* Goal: forall _ : inmonoid (union X V) x, @eq Word (comp_word (Word_ext invf) (Word_ext f) x) x *) rewrite <- (comp_Word_ext invf f x). (* Goal: forall _ : inmonoid (union X V) x, @eq Word (Word_ext (comp invf f) x) x *) generalize x. (* Goal: forall (x : Word) (_ : inmonoid (union X V) x), @eq Word (Word_ext (comp invf f) x) x *) apply (extension_Id (union X V) (comp invf f)). (* Goal: Id (union X V) (comp invf f) *) exact invf_f. Qed. Let Rf (g : Elt -> Elt) (P : Elt) := couple (g (first P)) (word (Word_ext g (word_inv (second P)))). Lemma comp_Rf : forall (g f : Elt -> Elt) (x : Elt), dans x R -> comp (Rf g) (Rf f) x = Rf (comp g f) x :>Elt. (* Goal: forall (g f : forall _ : Elt, Elt) (x : Elt) (_ : dans x R), @eq Elt (comp (Rf g) (Rf f) x) (Rf (comp g f) x) *) clear Mono. (* Goal: forall (g f : forall _ : Elt, Elt) (x : Elt) (_ : dans x R), @eq Elt (comp (Rf g) (Rf f) x) (Rf (comp g f) x) *) intros f' g x dans_x_R. (* Goal: @eq Elt (comp (Rf f') (Rf g) x) (Rf (comp f' g) x) *) elim (Regles_X_V_R x dans_x_R). (* Goal: forall (x0 : Elt) (_ : dans x0 V) (_ : @ex2 Word (fun B : Word => @eq Elt x (couple x0 (word B))) (fun B : Word => inmonoid (union X V) B)), @eq Elt (comp (Rf f') (Rf g) x) (Rf (comp f' g) x) *) intros A dans_A_V temp. (* Goal: @eq Elt (comp (Rf f') (Rf g) x) (Rf (comp f' g) x) *) elim temp; clear temp; intros B egal_x inmonoid_B. (* Goal: @eq Elt (comp (Rf f') (Rf g) x) (Rf (comp f' g) x) *) rewrite egal_x. (* Goal: @eq Elt (comp (Rf f') (Rf g) (couple A (word B))) (Rf (comp f' g) (couple A (word B))) *) unfold Rf in |- *. (* Goal: @eq Elt (comp (fun P : Elt => couple (f' (first P)) (word (Word_ext f' (word_inv (second P))))) (fun P : Elt => couple (g (first P)) (word (Word_ext g (word_inv (second P))))) (couple A (word B))) (couple (comp f' g (first (couple A (word B)))) (word (Word_ext (comp f' g) (word_inv (second (couple A (word B))))))) *) unfold comp at 1 in |- *. (* Goal: @eq Elt (couple (f' (first (couple (g (first (couple A (word B)))) (word (Word_ext g (word_inv (second (couple A (word B))))))))) (word (Word_ext f' (word_inv (second (couple (g (first (couple A (word B)))) (word (Word_ext g (word_inv (second (couple A (word B)))))))))))) (couple (comp f' g (first (couple A (word B)))) (word (Word_ext (comp f' g) (word_inv (second (couple A (word B))))))) *) apply couple_couple. (* Goal: @eq Word (weinvf (wef w)) (comp_word weinvf wef w) *) (* Goal: @eq Word (comp_word weinvf wef w) w *) (* Goal: @eq Ensf Rim' R *) (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) apply refl_equal. (* Goal: @eq Word (weinvf (wef w)) (comp_word weinvf wef w) *) (* Goal: @eq Word (comp_word weinvf wef w) w *) (* Goal: @eq Ensf Rim' R *) (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) simpl in |- *. rewrite (comp_Word_ext f' g B). apply refl_equal. Qed. Lemma egalGim'_image_comp : Gim' = imageGram (comp invf f) X V R S :>Ensf * (Ensf * (Ensf * Elt)). (* Goal: @eq (prod Ensf (prod Ensf (prod Ensf Elt))) Gim' (imageGram (comp invf f) X V R S) *) unfold Gim' in |- *. (* Goal: @eq Elt (word (Word_ext f' (word_inv (second (couple (g (first (couple A (word B)))) (word (Word_ext g (word_inv (second (couple A (word B))))))))))) (word (Word_ext (comp f' g) (word_inv (second (couple A (word B)))))) *) unfold Sim, Rim, Gim3, Vim, Gim2, Xim, Gim, imageGram in |- *; simpl in |- *. (* Goal: @eq (prod Ensf Elt) (@pair Ensf Elt (map (fun P : Elt => couple (invf (first P)) (word (Word_ext invf (word_inv (second P))))) (map (fun P : Elt => couple (f (first P)) (word (Word_ext f (word_inv (second P))))) R)) (invf (f S))) (@pair Ensf Elt (map (fun P : Elt => couple (comp invf f (first P)) (word (Word_ext (comp invf f) (word_inv (second P))))) R) (comp invf f S)) *) apply pair_equal. (* Goal: inclus X (union X V) *) (* Goal: inmonoid X w *) (* Goal: Id_words (union X V) (comp_word weinvf wef) *) (* Goal: @eq Ensf Rim' R *) (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) rewrite (map_map_eg_map_comp invf f X); auto. (* Goal: @eq (prod Ensf Elt) (@pair Ensf Elt (map (fun P : Elt => couple (invf (first P)) (word (Word_ext invf (word_inv (second P))))) (map (fun P : Elt => couple (f (first P)) (word (Word_ext f (word_inv (second P))))) R)) (invf (f S))) (@pair Ensf Elt (map (fun P : Elt => couple (comp invf f (first P)) (word (Word_ext (comp invf f) (word_inv (second P))))) R) (comp invf f S)) *) apply pair_equal. (* Goal: inclus X (union X V) *) (* Goal: inmonoid X w *) (* Goal: Id_words (union X V) (comp_word weinvf wef) *) (* Goal: @eq Ensf Rim' R *) (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) rewrite (map_map_eg_map_comp invf f V); auto. (* Goal: @eq (prod Ensf Elt) (@pair Ensf Elt (map (fun P : Elt => couple (invf (first P)) (word (Word_ext invf (word_inv (second P))))) (map (fun P : Elt => couple (f (first P)) (word (Word_ext f (word_inv (second P))))) R)) (invf (f S))) (@pair Ensf Elt (map (fun P : Elt => couple (comp invf f (first P)) (word (Word_ext (comp invf f) (word_inv (second P))))) R) (comp invf f S)) *) apply pair_equal. change (map (Rf invf) (map (Rf f) R) = map (Rf (comp invf f)) R :>Ensf) in |- *. (* Goal: @eq Ensf (map (Rf invf) (map (Rf f) R)) (map (Rf (comp invf f)) R) *) (* Goal: @eq Elt (invf (f S)) (comp invf f S) *) replace (map (Rf (comp invf f)) R) with (map (comp (Rf invf) (Rf f)) R). (* Goal: @eq Ensf (map (Rf invf) (map (Rf f) R)) (map (comp (Rf invf) (Rf f)) R) *) (* Goal: @eq Ensf (map (comp (Rf invf) (Rf f)) R) (map (Rf (comp invf f)) R) *) (* Goal: @eq Elt (invf (f S)) (comp invf f S) *) apply map_map_eg_map_comp. (* Goal: @eq Ensf (map (comp (Rf invf) (Rf f)) R) (map (Rf (comp invf f)) R) *) (* Goal: @eq Elt (invf (f S)) (comp invf f S) *) apply map_egal. (* Goal: forall (x : Elt) (_ : dans x R), @eq Elt (comp (Rf invf) (Rf f) x) (Rf (comp invf f) x) *) (* Goal: @eq Elt (invf (f S)) (comp invf f S) *) exact (comp_Rf invf f). (* Goal: @eq Word (weinvf (wef w)) (comp_word weinvf wef w) *) (* Goal: @eq Word (comp_word weinvf wef w) w *) (* Goal: @eq Ensf Rim' R *) (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) apply refl_equal. Qed. Lemma egalG : Gim' = (X, (V, (R, S))). (* Goal: @eq (prod Ensf (prod Ensf (prod Ensf Elt))) Gim' (@pair Ensf (prod Ensf (prod Ensf Elt)) X (@pair Ensf (prod Ensf Elt) V (@pair Ensf Elt R S))) *) rewrite egalGim'_image_comp. (* Goal: @eq (prod Ensf (prod Ensf (prod Ensf Elt))) (imageGram (comp invf f) X V R S) (@pair Ensf (prod Ensf (prod Ensf Elt)) X (@pair Ensf (prod Ensf Elt) V (@pair Ensf Elt R S))) *) apply Id_image_G. (* Goal: Id (union X V) (comp invf f) *) (* Goal: isGram X V R S *) unfold invf in |- *. (* Goal: inclus X (union X V) *) (* Goal: inmonoid X w *) (* Goal: Id_words (union X V) (comp_word weinvf wef) *) (* Goal: @eq Ensf Rim' R *) (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) auto. (* Goal: inclus X (union X V) *) (* Goal: inmonoid X w *) (* Goal: Id_words (union X V) (comp_word weinvf wef) *) (* Goal: @eq Ensf Rim' R *) (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) auto. Qed. Lemma egalS : Sim' = S :>Elt. (* Goal: @eq Elt Sim' S *) unfold Sim', Rim', Gim3', Vim', Gim2', Xim' in |- *. (* Goal: @eq Ensf (@fst Ensf (prod Ensf Elt) (@snd Ensf (prod Ensf (prod Ensf Elt)) Gim')) V *) rewrite egalG. (* Goal: @eq Word (weinvf (wef w)) (comp_word weinvf wef w) *) (* Goal: @eq Word (comp_word weinvf wef w) w *) (* Goal: @eq Ensf Rim' R *) (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) apply refl_equal. Qed. Lemma egalR : Rim' = R :>Ensf. (* Goal: @eq Ensf Rim' R *) unfold Rim', Gim3', Vim', Gim2', Xim' in |- *. (* Goal: @eq Ensf (@fst Ensf (prod Ensf Elt) (@snd Ensf (prod Ensf (prod Ensf Elt)) Gim')) V *) rewrite egalG. (* Goal: @eq Word (weinvf (wef w)) (comp_word weinvf wef w) *) (* Goal: @eq Word (comp_word weinvf wef w) w *) (* Goal: @eq Ensf Rim' R *) (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) apply refl_equal. Qed. Lemma egalX : Xim' = X :>Ensf. (* Goal: @eq Ensf Vim' V *) unfold Vim', Gim2', Xim' in |- *. (* Goal: @eq Ensf (@fst Ensf (prod Ensf Elt) (@snd Ensf (prod Ensf (prod Ensf Elt)) Gim')) V *) rewrite egalG. (* Goal: @eq Word (weinvf (wef w)) (comp_word weinvf wef w) *) (* Goal: @eq Word (comp_word weinvf wef w) w *) (* Goal: @eq Ensf Rim' R *) (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) apply refl_equal. Qed. Lemma egalV : Vim' = V :>Ensf. (* Goal: @eq Ensf Vim' V *) unfold Vim', Gim2', Xim' in |- *. (* Goal: @eq Ensf (@fst Ensf (prod Ensf Elt) (@snd Ensf (prod Ensf (prod Ensf Elt)) Gim')) V *) rewrite egalG. (* Goal: @eq Word (weinvf (wef w)) (comp_word weinvf wef w) *) (* Goal: @eq Word (comp_word weinvf wef w) w *) (* Goal: @eq Ensf Rim' R *) (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) apply refl_equal. Qed. Lemma Reconnait_imageGram_iso : forall w : Word, inmonoid X w -> LG Xim Vim Rim Sim (wef w) -> LG X V R S w. (* Goal: forall (w : Word) (_ : inmonoid X w) (_ : LG Xim Vim Rim Sim (wef w)), LG X V R S w *) intros w inmonoid_X_w LG_wef_w. (* Goal: LG X V R S w *) rewrite <- egalR. (* Goal: LG X V Rim' S w *) rewrite <- egalS. (* Goal: LG X V Rim' Sim' w *) rewrite <- egalV. (* Goal: LG X Vim' Rim' Sim' w *) rewrite <- egalX. (* Goal: LG Xim' Vim' Rim' Sim' w *) (* Goal: @eq Ensf Rim' R *) (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) replace w with (weinvf (wef w)). (* Goal: LG Xim' Vim' Rim' Sim' (weinvf (wef w)) *) (* Goal: @eq Word (weinvf (wef w)) w *) (* Goal: @eq Ensf Rim' R *) (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) unfold Sim', Rim', Gim3', Vim', Gim2', Xim', Gim', weinvf in |- *. (* Goal: inclus X (union X V) *) (* Goal: inmonoid X w *) (* Goal: Id_words (union X V) (comp_word weinvf wef) *) (* Goal: @eq Ensf Rim' R *) (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) auto. (* Goal: @eq Word (weinvf (wef w)) w *) change (comp_word weinvf wef w = w :>Word) in |- *. (* Goal: @eq Word (comp_word weinvf wef w) w *) apply Id_words_inv with X. (* Goal: LG Xim Vim Rim Sim w *) (* Goal: @eq Word w (wef w) *) (* Goal: @eq Word (weinvf (wef w)) w *) (* Goal: @eq Ensf Rim' R *) (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) assumption. (* Goal: Id_words X (comp_word weinvf wef) *) apply Id_words_inclus with (union X V). (* Goal: inclus X (union X V) *) (* Goal: inmonoid X w *) (* Goal: Id_words (union X V) (comp_word weinvf wef) *) (* Goal: @eq Ensf Rim' R *) (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) auto. (* Goal: Id_words (union X V) (comp_word weinvf wef) *) (* Goal: @eq Ensf Rim' R *) (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) exact weinvf_wef. Qed. Lemma egal_Xim : Id X f -> Xim = X :>Ensf. (* Goal: @eq Elt (word (Word_ext f' (word_inv (second (couple (g (first (couple A (word B)))) (word (Word_ext g (word_inv (second (couple A (word B))))))))))) (word (Word_ext (comp f' g) (word_inv (second (couple A (word B)))))) *) unfold Xim, Gim, imageGram in |- *; simpl in |- *. (* Goal: forall _ : Id X f, @eq Ensf (map f X) X *) intros. (* Goal: LG Xim Vim Rim Sim w *) (* Goal: @eq Word w (wef w) *) (* Goal: @eq Word (weinvf (wef w)) w *) (* Goal: @eq Ensf Rim' R *) (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) apply map_Id; assumption. Qed. Lemma egal_LG : Id X f -> l_egal (LG X V R S) (LG Xim Vim Rim Sim). (* Goal: forall _ : Id X f, l_egal (LG X V R S) (LG Xim Vim Rim Sim) *) unfold l_egal in |- *. (* Goal: forall _ : Id X f, and (l_inclus (LG X V R S) (LG Xim Vim Rim Sim)) (l_inclus (LG Xim Vim Rim Sim) (LG X V R S)) *) intro Id_X. (* Goal: and (l_inclus (LG X V R S) (LG Xim Vim Rim Sim)) (l_inclus (LG Xim Vim Rim Sim) (LG X V R S)) *) unfold l_inclus in |- *. (* Goal: and (forall (w : Word) (_ : LG X V R S w), LG Xim Vim Rim Sim w) (forall (w : Word) (_ : LG Xim Vim Rim Sim w), LG X V R S w) *) split. (* Goal: forall (w : Word) (_ : LG X V R S w), LG Xim Vim Rim Sim w *) (* Goal: forall (w : Word) (_ : LG Xim Vim Rim Sim w), LG X V R S w *) intros w LG_X_w. (* Goal: LG Xim Vim Rim Sim w *) (* Goal: forall (w : Word) (_ : LG Xim Vim Rim Sim w), LG X V R S w *) replace w with (wef w). (* Goal: LG Xim Vim Rim Sim (wef w) *) (* Goal: @eq Word (wef w) w *) (* Goal: forall (w : Word) (_ : LG Xim Vim Rim Sim w), LG X V R S w *) unfold Sim, Rim, Gim3, Vim, Gim2, Xim, Gim, wef in |- *. (* Goal: inclus X (union X V) *) (* Goal: inmonoid X w *) (* Goal: Id_words (union X V) (comp_word weinvf wef) *) (* Goal: @eq Ensf Rim' R *) (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) auto. (* Goal: @eq Word (wef w) w *) (* Goal: @eq Word (weinvf (wef w)) w *) (* Goal: @eq Ensf Rim' R *) (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) apply (Id_words_inv X). (* Goal: inmonoid Xim w *) (* Goal: @eq Ensf Xim X *) (* Goal: Id_words (union X V) (comp_word weinvf wef) *) (* Goal: @eq Ensf Rim' R *) (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) prolog [ LG_inv ] 2. (*Apply LG_inv with V R S;Assumption.*) (* Goal: Id_words X wef *) (* Goal: @eq Word (weinvf (wef w)) w *) (* Goal: @eq Ensf Rim' R *) (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) exact (extension_Id X f Id_X). (* Goal: forall (w : Word) (_ : LG Xim Vim Rim Sim w), LG X V R S w *) intros w LG_Xim_w. (* Goal: LG X V R S w *) replace X with Xim'. (* Goal: LG Xim' V R S w *) (* Goal: @eq Ensf Xim' X *) replace V with Vim'. (* Goal: LG Xim' Vim' R S w *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) replace S with Sim'. (* Goal: LG Xim' Vim' R Sim' w *) (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) replace R with Rim'. (* Goal: LG Xim' Vim' Rim' Sim' w *) (* Goal: @eq Ensf Rim' R *) (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) replace w with (weinvf (wef w)). (* Goal: LG Xim' Vim' Rim' Sim' (weinvf (wef w)) *) (* Goal: @eq Word (weinvf (wef w)) w *) (* Goal: @eq Ensf Rim' R *) (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) unfold Sim', Rim', Gim3', Vim', Gim2', Xim', Gim', weinvf in |- *. (* Goal: LG (@fst Ensf (prod Ensf (prod Ensf Elt)) (imageGram invf Xim Vim Rim Sim)) (@fst Ensf (prod Ensf Elt) (@snd Ensf (prod Ensf (prod Ensf Elt)) (imageGram invf Xim Vim Rim Sim))) (@fst Ensf Elt (@snd Ensf (prod Ensf Elt) (@snd Ensf (prod Ensf (prod Ensf Elt)) (imageGram invf Xim Vim Rim Sim)))) (@snd Ensf Elt (@snd Ensf (prod Ensf Elt) (@snd Ensf (prod Ensf (prod Ensf Elt)) (imageGram invf Xim Vim Rim Sim)))) (Word_ext invf (wef w)) *) (* Goal: @eq Word (weinvf (wef w)) w *) (* Goal: @eq Ensf Rim' R *) (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) apply Reconnait_imageGram. (* Goal: LG Xim Vim Rim Sim (wef w) *) (* Goal: @eq Word (weinvf (wef w)) w *) (* Goal: @eq Ensf Rim' R *) (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) replace (wef w) with w. (* Goal: LG Xim Vim Rim Sim w *) (* Goal: @eq Word w (wef w) *) (* Goal: @eq Word (weinvf (wef w)) w *) (* Goal: @eq Ensf Rim' R *) (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) assumption. (* Goal: @eq Word w (wef w) *) (* Goal: @eq Word (weinvf (wef w)) w *) (* Goal: @eq Ensf Rim' R *) (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) apply sym_equal. (* Goal: @eq Word (wef w) w *) (* Goal: @eq Word (weinvf (wef w)) w *) (* Goal: @eq Ensf Rim' R *) (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) apply (Id_words_inv X). (* Goal: inmonoid X w *) (* Goal: Id_words X wef *) (* Goal: @eq Word (weinvf (wef w)) w *) (* Goal: @eq Ensf Rim' R *) (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) rewrite <- (egal_Xim Id_X). (* Goal: inmonoid Xim w *) (* Goal: @eq Ensf Xim X *) (* Goal: Id_words (union X V) (comp_word weinvf wef) *) (* Goal: @eq Ensf Rim' R *) (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) prolog [ LG_inv ] 2. (*Apply LG_inv with Vim Rim Sim;Assumption.*) (* Goal: Id_words X wef *) (* Goal: @eq Word (weinvf (wef w)) w *) (* Goal: @eq Ensf Rim' R *) (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) exact (extension_Id X f Id_X). (* Goal: @eq Word (weinvf (wef w)) w *) (* Goal: @eq Ensf Rim' R *) (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) pattern w at 2 in |- *; replace w with (comp_word weinvf wef w). (* Goal: @eq Word (weinvf (wef w)) (comp_word weinvf wef w) *) (* Goal: @eq Word (comp_word weinvf wef w) w *) (* Goal: @eq Ensf Rim' R *) (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) apply refl_equal. (* Goal: @eq Word (comp_word weinvf wef w) w *) (* Goal: @eq Ensf Rim' R *) (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) apply Id_words_inv with (union X V). (* Goal: inmonoid (union X V) w *) (* Goal: Id_words (union X V) (comp_word weinvf wef) *) (* Goal: @eq Ensf Rim' R *) (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) apply inmonoid_inclus with X. (* Goal: inclus X (union X V) *) (* Goal: inmonoid X w *) (* Goal: Id_words (union X V) (comp_word weinvf wef) *) (* Goal: @eq Ensf Rim' R *) (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) auto. (* Goal: inmonoid X w *) (* Goal: Id_words (union X V) (comp_word weinvf wef) *) (* Goal: @eq Ensf Rim' R *) (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) replace X with Xim. (* Goal: inmonoid Xim w *) (* Goal: @eq Ensf Xim X *) (* Goal: Id_words (union X V) (comp_word weinvf wef) *) (* Goal: @eq Ensf Rim' R *) (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) prolog [ LG_inv ] 2. (*Apply LG_inv with Vim Rim Sim;Assumption.*) (* Goal: @eq Ensf Xim X *) (* Goal: Id_words (union X V) (comp_word weinvf wef) *) (* Goal: @eq Ensf Rim' R *) (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) exact (egal_Xim Id_X). (* Goal: Id_words (union X V) (comp_word weinvf wef) *) (* Goal: @eq Ensf Rim' R *) (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) exact weinvf_wef. (* Goal: @eq Ensf Rim' R *) (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) exact egalR. (* Goal: @eq Elt Sim' S *) (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) exact egalS. (* Goal: @eq Ensf Vim' V *) (* Goal: @eq Ensf Xim' X *) exact egalV. (* Goal: @eq Ensf Xim' X *) exact egalX. Qed. End resultats_iso_image.
(* This program is free software; you can redistribute it and/or *) (* modify it under the terms of the GNU Lesser General Public License *) (* as published by the Free Software Foundation; either version 2.1 *) (* of the License, or (at your option) any later version. *) (* *) (* This program is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* GNU General Public License for more details. *) (* *) (* You should have received a copy of the GNU Lesser General Public *) (* License along with this program; if not, write to the Free *) (* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *) (* 02110-1301 USA *) (* Contribution to the Coq Library V6.3 (July 1999) *) (****************************************************************************) (* The Calculus of Inductive Constructions *) (* *) (* Projet Coq *) (* *) (* INRIA ENS-CNRS *) (* Rocquencourt Lyon *) (* *) (* Coq V5.10 *) (* Nov 25th 1994 *) (* *) (****************************************************************************) (* Ensf_map.v *) (****************************************************************************) (* Formal Language Theory *) (* *) (* Judicael Courant - Jean-Christophe Filliatre *) (* *) (* Developped in V5.8 June-July 1993 *) (* Ported to V5.10 October 1994 *) (****************************************************************************) Require Import Ensf_types. Require Import Ensf_dans. Require Import Ensf_union. Require Import Ensf_inclus. (* *) (* MAP "a la CAML" *) (* On definit une fonction map qui applique une fonction a tous les *) (* elements d'un ensemble et renvoie l'ensemble des resultats *) (* Ceci permet, entre autres, de definir facilement l'union *) (* disjointe (Voir ci-dessous) *) (* *) Fixpoint map (f : Elt -> Elt) (e : Ensf) {struct e} : Ensf := match e with | empty => empty | add y e => add (f y) (map f e) end. (* *) (* On montre ici le resultat general suivant : *) (* (dans x (map f A)) -> il existe y dans A tel que x=f y *) (* *) Lemma dans_map : forall (f : Elt -> Elt) (a : Ensf) (x : Elt), dans x (map f a) -> exists y : Elt, dans y a /\ x = f y. intros f. simple induction a. simpl in |- *. intros x H. absurd (dans x empty); auto. intros a0 b H x. simpl in |- *. intro. cut (f a0 = x :>Elt \/ dans x (map f b)). 2: apply dans_add; auto. intro H1; elim H1; clear H1. intro; exists a0; auto. intro. cut (exists y : Elt, dans y b /\ x = f y). intro H2; elim H2; clear H2. 2: auto. intros x0 H2; elim H2; clear H2. intros. exists x0. split; auto. Qed. Hint Resolve dans_map. Lemma dans_map_inv : forall (f : Elt -> Elt) (x : Elt) (a : Ensf), dans x a -> dans (f x) (map f a). intros f x. simple induction a. intro. apply (dans_empty_imp_P x); auto. intros a0 b H. simpl in |- *. intro H1. cut (a0 = x :>Elt \/ dans x b). 2: apply dans_add; auto. intro H2; elim H2; clear H2. intro. rewrite H0; auto. auto. Qed. Hint Resolve dans_map_inv. Lemma map_union : forall (f : Elt -> Elt) (a b : Ensf), union (map f a) (map f b) = map f (union a b) :>Ensf. (* Goal: forall (f : forall _ : Elt, Elt) (a b : Ensf), @eq Ensf (union (map f a) (map f b)) (map f (union a b)) *) intro f. simple induction a; simpl in |- *; auto. Qed. Hint Resolve map_union. Lemma dans_map_trans : forall (x : Elt) (f : Elt -> Elt) (a b : Ensf), dans x (map f a) -> inclus a b -> dans x (map f b). intros. cut (exists y : Elt, dans y a /\ x = f y :>Elt). 2: apply dans_map; auto. intro Ht; elim Ht; clear Ht. intros y Ht; elim Ht; clear Ht. intros. cut (dans y b). 2: apply dans_trans with a; auto. intro. rewrite H2. apply dans_map_inv; auto. Qed. Lemma map_egal : forall (f g : Elt -> Elt) (E : Ensf), (forall x : Elt, dans x E -> f x = g x :>Elt) -> map f E = map g E :>Ensf. (* Goal: forall (f g : forall _ : Elt, Elt) (E : Ensf) (_ : forall (x : Elt) (_ : dans x E), @eq Elt (f x) (g x)), @eq Ensf (map f E) (map g E) *) intros f g. simple induction E; simpl in |- *; auto. Qed. Lemma map_inclus : forall (a b : Ensf) (f : Elt -> Elt), inclus a b -> inclus (map f a) (map f b). unfold inclus in |- *. intros. cut (exists y : Elt, dans y a /\ x = f y :>Elt). 2: apply dans_map; auto. intro Ht; elim Ht; clear Ht; intros y Ht; elim Ht; clear Ht; intros. cut (dans y b); auto. intro. replace x with (f y); auto. Qed.
(* This program is free software; you can redistribute it and/or *) (* modify it under the terms of the GNU Lesser General Public License *) (* as published by the Free Software Foundation; either version 2.1 *) (* of the License, or (at your option) any later version. *) (* *) (* This program is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* GNU General Public License for more details. *) (* *) (* You should have received a copy of the GNU Lesser General Public *) (* License along with this program; if not, write to the Free *) (* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *) (* 02110-1301 USA *) (* Contribution to the Coq Library V6.3 (July 1999) *) (****************************************************************************) (* The Calculus of Inductive Constructions *) (* *) (* Projet Coq *) (* *) (* INRIA ENS-CNRS *) (* Rocquencourt Lyon *) (* *) (* Coq V5.10 *) (* Nov 25th 1994 *) (* *) (****************************************************************************) (* Words.v *) (****************************************************************************) (* Formal Language Theory *) (* *) (* Judicael Courant - Jean-Christophe Filliatre *) (* *) (* Developped in V5.8 June-July 1993 *) (* Ported to V5.10 October 1994 *) (****************************************************************************) Require Import Ensf. Parameter alph : Ensf. Parameter epsilon : Elt. Axiom not_dans_epsilon_alph : ~ dans epsilon alph. (* On definit le predicat (inmonoid X w) qui signifie que le mot w *) (* est dans le monoide libre engendre par X. *) Inductive inmonoid (X : Ensf) : Word -> Prop := | inmonoid_nil : inmonoid X nil | inmonoid_cons : forall (w : Word) (e : Elt), inmonoid X w -> dans e X -> inmonoid X (cons e w). Hint Resolve inmonoid_nil. Hint Resolve inmonoid_cons. (* Inversion de la definition *) (* Fixpoint Inmonoid [X:Ensf; w:Word] : Prop := (<Prop>Case w of (* nil *) True (* cons *) [a:Elt][w':Word]( (dans a X) /\ (Inmonoid X w') ) end ). *) Fixpoint Inmonoid (X : Ensf) (w : Word) {struct w} : Prop := match w with | nil => True | cons a w' => dans a X /\ Inmonoid X w' end. Lemma i_I : forall (X : Ensf) (w : Word), inmonoid X w -> Inmonoid X w. (* Goal: forall (X : Ensf) (w : Word) (_ : inmonoid X w), Inmonoid X w *) intros X w H. (* Goal: Inmonoid X w *) elim H. (* Goal: Inmonoid X nil *) (* Goal: forall (w : Word) (e : Elt) (_ : inmonoid X w) (_ : Inmonoid X w) (_ : dans e X), Inmonoid X (cons e w) *) red in |- *; simpl in |- *; exact I. (* Goal: forall (x1 x2 : Elt) (w1 w2 : Word) (_ : @eq Word (cons x1 w1) (cons x2 w2)), @eq Word w1 w2 *) intros. (* Goal: Inmonoid X (cons e w0) *) change (dans e X /\ Inmonoid X w0) in |- *. (* Goal: @eq Word (cons x w0) (cons x w0) *) auto. Qed. Hint Resolve i_I. Lemma I_i : forall (X : Ensf) (w : Word), Inmonoid X w -> inmonoid X w. (* Goal: forall (X : Ensf) (w1 w2 : Word) (_ : inmonoid X w1) (_ : inmonoid X w2), inmonoid X (Append w1 w2) *) intros X. (* Goal: forall w : Word, or (@eq Word w nil) (@ex Elt (fun x : Elt => @ex Word (fun w0 : Word => @eq Word w (cons x w0)))) *) simple induction w. (* Goal: @eq Word (cons x w0) (cons x w0) *) auto. (* Goal: forall (e : Elt) (w : Word) (_ : forall _ : Inmonoid X w, inmonoid X w) (_ : Inmonoid X (cons e w)), inmonoid X (cons e w) *) intros x w0 H H0. (* Goal: @eq Word (cons x w0) (cons x w0) *) cut (dans x X /\ Inmonoid X w0); auto. (* Goal: forall _ : and (dans a X) (Inmonoid X w), dans a X *) intro H1; elim H1; clear H1. (* Goal: @eq Word (cons x w0) (cons x w0) *) auto. Qed. Hint Resolve I_i. Lemma inmonoid_cons_inv : forall (X : Ensf) (w : Word) (a : Elt), inmonoid X (cons a w) -> inmonoid X w. (* Goal: forall (x1 x2 : Elt) (w1 w2 : Word) (_ : @eq Word (cons x1 w1) (cons x2 w2)), @eq Word w1 w2 *) intros. (* Goal: @eq Word (cons x w0) (cons x w0) *) cut (Inmonoid X w); auto. (* Goal: @eq Word (cons x w0) (cons x w0) *) cut (Inmonoid X (cons a w)); auto. (* Goal: forall _ : Inmonoid X (cons a w), Inmonoid X w *) intro H0. (* Goal: @eq Word (cons x w0) (cons x w0) *) cut (dans a X /\ Inmonoid X w); auto. (* Goal: forall _ : and (dans a X) (Inmonoid X w), dans a X *) intro H1; elim H1; clear H1. (* Goal: @eq Word (cons x w0) (cons x w0) *) auto. Qed. Lemma inmonoid_cons_inv2 : forall (X : Ensf) (a : Elt) (w : Word), inmonoid X (cons a w) -> dans a X. (* Goal: forall (x1 x2 : Elt) (w1 w2 : Word) (_ : @eq Word (cons x1 w1) (cons x2 w2)), @eq Word w1 w2 *) intros. (* Goal: @eq Word (cons x w0) (cons x w0) *) cut (Inmonoid X (cons a w)); auto. (* Goal: forall _ : inmonoid X (cons x (Append w w2)), inmonoid X w2 *) intro. (* Goal: @eq Word (cons x w0) (cons x w0) *) cut (dans a X /\ Inmonoid X w); auto. (* Goal: forall _ : and (dans a X) (Inmonoid X w), dans a X *) intro H1; elim H1; clear H1. (* Goal: @eq Word (cons x w0) (cons x w0) *) auto. Qed. Lemma inmonoid_inclus : forall (E F : Ensf) (x : Word), inclus E F -> inmonoid E x -> inmonoid F x. (* Goal: forall (E F : Ensf) (x : Word) (_ : inclus E F) (_ : inmonoid E x), inmonoid F x *) intros E F x inclus_E_F inmonoid_E_x. (* Goal: inmonoid F x *) elim inmonoid_E_x. (* Goal: inmonoid F nil *) (* Goal: forall (w : Word) (e : Elt) (_ : inmonoid E w) (_ : inmonoid F w) (_ : dans e E), inmonoid F (cons e w) *) trivial. (* Goal: forall (w : Word) (e : Elt) (_ : inmonoid E w) (_ : inmonoid F w) (_ : dans e E), inmonoid F (cons e w) *) intros w e inmonoid_E_w inmonoid_F_w dans_e_E. (* Goal: inmonoid F (cons e w) *) apply inmonoid_cons; [ assumption | apply inclus_E_F; assumption ]. Qed. (* *) (* Concatenation de 2 mots : *) (* (Append w1 w2) est la concatenation de w1 et w2 *) (* (append w1 w2 w3) est la proposition "w3 est la conc.de w1 et w2" *) (* *) (* Fixpoint Append [w1:Word] : Word -> Word := [w2:Word] (<Word>Case w1 of (* nil *) w2 (* cons *) [a:Elt][w3:Word](cons a (Append w3 w2)) end ). *) Fixpoint Append (w1 : Word) : Word -> Word := fun w2 : Word => match w1 with | nil => w2 | cons a w3 => cons a (Append w3 w2) end. Lemma Append_w_nil : forall w : Word, Append w nil = w :>Word. (* Goal: forall w : Word, or (@eq Word w nil) (@ex Elt (fun x : Elt => @ex Word (fun w0 : Word => @eq Word w (cons x w0)))) *) simple induction w. (* Goal: @eq Word (cons x w0) (cons x w0) *) auto. (* Goal: forall (e : Elt) (w : Word) (_ : or (@eq Word w nil) (@ex Elt (fun x : Elt => @ex Word (fun w0 : Word => @eq Word w (cons x w0))))), or (@eq Word (cons e w) nil) (@ex Elt (fun x : Elt => @ex Word (fun w0 : Word => @eq Word (cons e w) (cons x w0)))) *) intros x w0 H. (* Goal: @eq Word (cons x w0) (cons x w0) *) replace (Append (cons x w0) nil) with (cons x (Append w0 nil)); auto. (* Goal: @eq Word (cons x w0) (cons x w0) *) rewrite H; auto. Qed. Inductive append : Word -> Word -> Word -> Prop := | append_nil : forall w : Word, append nil w w | append_cons : forall (w1 w2 w3 : Word) (a : Elt), append w1 w2 w3 -> append (cons a w1) w2 (cons a w3). (* Lemmes sur inmonoid et Append... *) Lemma Append_inmonoid_g : forall (X : Ensf) (w1 w2 : Word), inmonoid X (Append w1 w2) -> inmonoid X w1. (* Goal: forall (X : Ensf) (w1 w2 : Word) (_ : inmonoid X w1) (_ : inmonoid X w2), inmonoid X (Append w1 w2) *) intros X. (* Goal: forall (w1 w2 : Word) (_ : inmonoid X w1) (_ : inmonoid X w2), inmonoid X (Append w1 w2) *) simple induction w1. (* Goal: @eq Word (cons x w0) (cons x w0) *) auto. (* Goal: forall (e : Elt) (w : Word) (_ : forall (w2 : Word) (_ : inmonoid X (Append w w2)), inmonoid X w2) (w2 : Word) (_ : inmonoid X (Append (cons e w) w2)), inmonoid X w2 *) intros x w H w2. (* Goal: @eq Word (cons x w0) (cons x w0) *) replace (Append (cons x w) w2) with (cons x (Append w w2)); auto. (* Goal: forall _ : inmonoid X (cons x (Append w w2)), inmonoid X w2 *) intro. (* Goal: inmonoid X (cons x (Append w w2)) *) apply inmonoid_cons. (* Goal: inmonoid X w2 *) apply (H w2). (* Goal: @eq Word (cons x w0) (cons x w0) *) apply inmonoid_cons_inv with x; auto. (* Goal: @eq Word (cons x w0) (cons x w0) *) apply inmonoid_cons_inv2 with (Append w w2); auto. Qed. Lemma Append_inmonoid_d : forall (X : Ensf) (w1 w2 : Word), inmonoid X (Append w1 w2) -> inmonoid X w2. (* Goal: forall (X : Ensf) (w1 w2 : Word) (_ : inmonoid X w1) (_ : inmonoid X w2), inmonoid X (Append w1 w2) *) intros X. (* Goal: forall (w1 w2 : Word) (_ : inmonoid X w1) (_ : inmonoid X w2), inmonoid X (Append w1 w2) *) simple induction w1. (* Goal: @eq Word (cons x w0) (cons x w0) *) auto. (* Goal: forall (e : Elt) (w : Word) (_ : forall (w2 : Word) (_ : inmonoid X (Append w w2)), inmonoid X w2) (w2 : Word) (_ : inmonoid X (Append (cons e w) w2)), inmonoid X w2 *) intros x w H w2. (* Goal: @eq Word (cons x w0) (cons x w0) *) replace (Append (cons x w) w2) with (cons x (Append w w2)); auto. (* Goal: forall _ : inmonoid X (cons x (Append w w2)), inmonoid X w2 *) intro. (* Goal: inmonoid X w2 *) apply (H w2). (* Goal: @eq Word (cons x w0) (cons x w0) *) apply inmonoid_cons_inv with x; auto. Qed. Lemma inmonoid_Append : forall (X : Ensf) (w1 w2 : Word), inmonoid X w1 -> inmonoid X w2 -> inmonoid X (Append w1 w2). (* Goal: forall (X : Ensf) (w1 w2 : Word) (_ : inmonoid X w1) (_ : inmonoid X w2), inmonoid X (Append w1 w2) *) intros X. (* Goal: forall (w1 w2 : Word) (_ : inmonoid X w1) (_ : inmonoid X w2), inmonoid X (Append w1 w2) *) simple induction w1. (* Goal: @eq Word (cons x w0) (cons x w0) *) auto. (* Goal: forall (e : Elt) (w : Word) (_ : forall (w2 : Word) (_ : inmonoid X w) (_ : inmonoid X w2), inmonoid X (Append w w2)) (w2 : Word) (_ : inmonoid X (cons e w)) (_ : inmonoid X w2), inmonoid X (Append (cons e w) w2) *) intros x w H w2 H0 H1. (* Goal: @eq Word (cons x w0) (cons x w0) *) replace (Append (cons x w) w2) with (cons x (Append w w2)); auto. (* Goal: inmonoid X (cons x (Append w w2)) *) apply inmonoid_cons. (* Goal: @eq Word (cons x w0) (cons x w0) *) apply (H w2); auto. (* Goal: @eq Word (cons x w0) (cons x w0) *) apply inmonoid_cons_inv with x; auto. (* Goal: @eq Word (cons x w0) (cons x w0) *) apply inmonoid_cons_inv2 with w; auto. Qed. (* *) (* On definit tout d'abord le type wordset, qui est Word->Prop *) (* et qui definit un ensemble de mots par sa fonction caracteristique. *) (* *) (* L'egalite de 2 wordset est definie comme la double implication. *) (* *) Definition wordset := Word -> Prop. Definition eqwordset (l1 l2 : wordset) : Prop := forall w : Word, (l1 w -> l2 w) /\ (l2 w -> l1 w). Lemma eqwordset_refl : forall L : wordset, eqwordset L L. (* Goal: forall L : wordset, eqwordset L L *) red in |- *. (* Goal: @eq Word (cons x w0) (cons x w0) *) auto. Qed. Lemma eqwordset_sym : forall l1 l2 : wordset, eqwordset l1 l2 -> eqwordset l2 l1. (* Goal: forall (l1 l2 l3 : wordset) (_ : eqwordset l1 l2) (_ : eqwordset l2 l3), eqwordset l1 l3 *) unfold eqwordset in |- *. (* Goal: forall (x1 x2 : Elt) (w1 w2 : Word) (_ : @eq Word (cons x1 w1) (cons x2 w2)), @eq Word w1 w2 *) intros. (* Goal: @eq Word (cons x w0) (cons x w0) *) elim (H w); clear H; intros; auto. Qed. Lemma eqwordset_trans : forall l1 l2 l3 : wordset, eqwordset l1 l2 -> eqwordset l2 l3 -> eqwordset l1 l3. (* Goal: forall (l1 l2 l3 : wordset) (_ : eqwordset l1 l2) (_ : eqwordset l2 l3), eqwordset l1 l3 *) unfold eqwordset in |- *. (* Goal: forall (x1 x2 : Elt) (w1 w2 : Word) (_ : @eq Word (cons x1 w1) (cons x2 w2)), @eq Word w1 w2 *) intros. (* Goal: forall (x1 x2 : Elt) (w1 w2 : Word) (_ : @eq Word (cons x1 w1) (cons x2 w2)), @eq Word w1 w2 *) elim (H0 w); clear H0; intros. (* Goal: forall (x1 x2 : Elt) (w1 w2 : Word) (_ : @eq Word (cons x1 w1) (cons x2 w2)), @eq Word w1 w2 *) elim (H w); clear H; intros. (* Goal: @eq Word (cons x w0) (cons x w0) *) auto. Qed. (* *) (* Le predicat islangage, defini sur les wordset, dit simplement *) (* que les mots du wordset sont sur l'alphabet alph. *) (* *) Definition islanguage (X : Ensf) (L : wordset) : Prop := forall w : Word, L w -> inmonoid X w. (* *) (* Extension aux mots d'une fonction definie sur les elements *) (* *) (* Fixpoint Word_ext [f : Elt -> Elt; w:Word] : Word := (<Word>Case w of (* nil *) nil (* cons *) [a:Elt][w':Word](cons (f a) (Word_ext f w')) end ). *) Fixpoint Word_ext (f : Elt -> Elt) (w : Word) {struct w} : Word := match w with | nil => nil | cons a w' => cons (f a) (Word_ext f w') end. Lemma inmonoid_map : forall (f : Elt -> Elt) (a : Ensf) (w : Word), inmonoid a w -> inmonoid (map f a) (Word_ext f w). (* Goal: forall (x1 x2 : Elt) (w1 w2 : Word) (_ : @eq Word (cons x1 w1) (cons x2 w2)), @eq Word w1 w2 *) intros. (* Goal: inmonoid (map f a) (Word_ext f w) *) elim H; [ unfold Word_ext in |- *; auto | idtac ]. (* Goal: forall (w : Word) (e : Elt) (_ : inmonoid a w) (_ : inmonoid (map f a) (Word_ext f w)) (_ : dans e a), inmonoid (map f a) (Word_ext f (cons e w)) *) intros; unfold Word_ext in |- *; simpl in |- *. (* Goal: @eq Word (cons x w0) (cons x w0) *) apply inmonoid_cons; try apply dans_map_inv; auto. Qed. Hint Resolve inmonoid_map. (* Un petit lemme bien utile par la suite... *) Lemma cons_cons : forall (x1 x2 : Elt) (w1 w2 : Word), x1 = x2 :>Elt -> w1 = w2 :>Word -> cons x1 w1 = cons x2 w2 :>Word. (* Goal: forall (x1 x2 : Elt) (w1 w2 : Word) (_ : @eq Word (cons x1 w1) (cons x2 w2)), @eq Word w1 w2 *) intros. (* Goal: @eq Word (cons x1 w1) (cons x2 w2) *) rewrite H0. (* Goal: @eq Word (cons x1 w2) (cons x2 w2) *) rewrite H. (* Goal: @eq Word (cons x w0) (cons x w0) *) auto. Qed. Hint Resolve cons_cons. Definition fun_consaw_a (w : Word) : Elt := match w return Elt with | nil => (* nil *) zero (* cons *) | cons a w' => a end. Definition fun_consaw_w (w : Word) : Word := match w return Word with | nil => (* nil *) nil (* cons *) | cons a w' => w' end. Lemma cons_cons_inv : forall (x1 x2 : Elt) (w1 w2 : Word), cons x1 w1 = cons x2 w2 -> x1 = x2 /\ w1 = w2. (* Goal: forall (x1 x2 : Elt) (w1 w2 : Word) (_ : @eq Word (cons x1 w1) (cons x2 w2)), @eq Word w1 w2 *) intros. (* Goal: and (@eq Elt x1 x2) (@eq Word w1 w2) *) split. (* Goal: @eq Word (cons x w0) (cons x w0) *) replace x1 with (fun_consaw_a (cons x1 w1)); auto. (* Goal: @eq Word (cons x w0) (cons x w0) *) replace x2 with (fun_consaw_a (cons x2 w2)); auto. (* Goal: @eq Word (cons x w0) (cons x w0) *) apply (f_equal (A:=Word) (B:=Elt)); auto. (* Goal: @eq Word (cons x w0) (cons x w0) *) replace w1 with (fun_consaw_w (cons x1 w1)); auto. (* Goal: @eq Word (cons x w0) (cons x w0) *) replace w2 with (fun_consaw_w (cons x2 w2)); auto. (* Goal: @eq Word (cons x w0) (cons x w0) *) apply (f_equal (A:=Word) (B:=Word)); auto. Qed. Hint Resolve cons_cons_inv. Lemma cons_cons_inv1 : forall (x1 x2 : Elt) (w1 w2 : Word), cons x1 w1 = cons x2 w2 :>Word -> x1 = x2 :>Elt. (* Goal: forall (x1 x2 : Elt) (w1 w2 : Word) (_ : @eq Word (cons x1 w1) (cons x2 w2)), @eq Word w1 w2 *) intros. (* Goal: @eq Elt x1 x2 *) cut (x1 = x2 :>Elt /\ w1 = w2 :>Word); [ intuition | auto ]. Qed. Lemma cons_cons_inv2 : forall (x1 x2 : Elt) (w1 w2 : Word), cons x1 w1 = cons x2 w2 -> w1 = w2. (* Goal: forall (x1 x2 : Elt) (w1 w2 : Word) (_ : @eq Word (cons x1 w1) (cons x2 w2)), @eq Word w1 w2 *) intros. (* Goal: @eq Word w1 w2 *) cut (x1 = x2 /\ w1 = w2); [ intuition | auto ]. Qed. (* *) (* Un mot est soit nil, soit de la forme (cons x w0). *) (* *) Lemma nil_or_cons : forall w : Word, w = nil \/ (exists x : Elt, (exists w0 : Word, w = cons x w0)). (* Goal: forall w : Word, or (@eq Word w nil) (@ex Elt (fun x : Elt => @ex Word (fun w0 : Word => @eq Word w (cons x w0)))) *) simple induction w. (* Goal: @eq Word (cons x w0) (cons x w0) *) left; auto. (* Goal: forall (e : Elt) (w : Word) (_ : or (@eq Word w nil) (@ex Elt (fun x : Elt => @ex Word (fun w0 : Word => @eq Word w (cons x w0))))), or (@eq Word (cons e w) nil) (@ex Elt (fun x : Elt => @ex Word (fun w0 : Word => @eq Word (cons e w) (cons x w0)))) *) intros x w0 H. (* Goal: or (@eq Word (cons x w0) nil) (@ex Elt (fun x0 : Elt => @ex Word (fun w1 : Word => @eq Word (cons x w0) (cons x0 w1)))) *) right. (* Goal: @ex Elt (fun x0 : Elt => @ex Word (fun w1 : Word => @eq Word (cons x w0) (cons x0 w1))) *) exists x. (* Goal: @ex Word (fun w1 : Word => @eq Word (cons x w0) (cons x w1)) *) exists w0. (* Goal: @eq Word (cons x w0) (cons x w0) *) auto. Qed.
(* This program is free software; you can redistribute it and/or *) (* modify it under the terms of the GNU Lesser General Public License *) (* as published by the Free Software Foundation; either version 2.1 *) (* of the License, or (at your option) any later version. *) (* *) (* This program is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* GNU General Public License for more details. *) (* *) (* You should have received a copy of the GNU Lesser General Public *) (* License along with this program; if not, write to the Free *) (* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *) (* 02110-1301 USA *) (* Contribution to the Coq Library V6.3 (July 1999) *) (****************************************************************************) (* The Calculus of Inductive Constructions *) (* *) (* Projet Coq *) (* *) (* INRIA ENS-CNRS *) (* Rocquencourt Lyon *) (* *) (* Coq V5.10 *) (* Nov 25th 1994 *) (* *) (****************************************************************************) (* Max.v *) (****************************************************************************) (* Formal Language Theory *) (* *) (* Judicael Courant - Jean-Christophe Filliatre *) (* *) (* Developped in V5.8 June-July 1993 *) (* Ported to V5.10 October 1994 *) (****************************************************************************) Require Import Le. Require Import Lt. Require Import Ensf. Require Export Arith.Max. (* On definit maintenant (sup x) pour un ensemble x, qui est *) (* - soit O, si x ne contient pas d'entier *) (* - soit (S n), si n est le plus grand entier de x *) (* *) (* Definition Z : Elt -> nat := [x:Elt] (<nat>Case x of (* natural *) [n:nat](S n) (* couple *) [a:Elt][b:Elt]O (* up *) [e:Ensf]O (* word *) [w:Word]O end ). *) Definition Z (x : Elt) : nat := match x with | natural n => S n | _ => 0 end. (* Fixpoint sup [e:Ensf] : nat := (<nat>Case e of (* empty *) O (* add *) [x:Elt][f:Ensf](max (Z x) (sup f)) end ). *) Fixpoint sup (e : Ensf) : nat := match e with | empty => 0 | add x f => max (Z x) (sup f) end. (* Par definition on a : *) Lemma sup_add : forall (x : Elt) (e : Ensf), sup (add x e) = max (Z x) (sup e) :>nat. (* Goal: forall (x : Elt) (e : Ensf), @eq nat (sup (add x e)) (PeanoNat.Nat.max (Z x) (sup e)) *) intros x. (* Goal: forall e : Ensf, @eq nat (sup (add x e)) (PeanoNat.Nat.max (Z x) (sup e)) *) simple induction e; auto. Qed. Hint Resolve sup_add. (* Finalement inutile : *) (* Lemma diff_natural : (n,m:nat)~(<nat>n=m)->~(<Elt>(natural n)=(natural m)). Intros; Red; Intro. Absurd (<nat>n=m). Assumption. Replace n with (natural_inv (natural n)). 2:Auto. Replace m with (natural_inv (natural m)). 2:Auto. Elim H0. Auto. Save. *) (* Finalement inutile *) (* Lemma lt_diff : (n,m:nat)(lt m n)->~(<nat>n=m). Intros. Red. Intro. Cut (lt m n); Auto. Elim H0. Change ~(lt n n). Auto. Save. *) Lemma elt_not_sym : forall a b : Elt, a <> b :>Elt -> b <> a :>Elt. (* Goal: forall (a b : Elt) (_ : not (@eq Elt a b)), not (@eq Elt b a) *) auto. Qed. (* (Z (natural n)) vaut (S n), donc est plus grand que n *) Lemma lt_n_Z : forall n : nat, n < Z (natural n). (* Goal: forall e : Ensf, @ex Elt (fun x : Elt => not (dans x e)) *) intro. (* Goal: forall (a b : Elt) (_ : not (@eq Elt a b)), not (@eq Elt b a) *) replace (Z (natural n)) with (S n); auto. Qed. (* *) (* On montre d'abord que tout entier dans x est strictement plus petit *) (* que (sup x) *) (* *) Lemma lt_n_sup : forall (x : Ensf) (n : nat), dans (natural n) x -> n < sup x. simple induction x. intros. (* Goal: forall (a b : Elt) (_ : not (@eq Elt a b)), not (@eq Elt b a) *) absurd (dans (natural n) empty); auto. intros a b H n H0. replace (sup (add a b)) with (max (Z a) (sup b)). (* Goal: forall (a b : Elt) (_ : not (@eq Elt a b)), not (@eq Elt b a) *) 2: auto. cut (n < Z a \/ n < sup b). (* Goal: forall e : Ensf, @ex Elt (fun x : Elt => not (dans x e)) *) intro. (* Goal: forall (a b : Elt) (_ : not (@eq Elt a b)), not (@eq Elt b a) *) elim H1; auto. intros; apply lt_le_trans with (Z a); auto with arith. intros; apply lt_le_trans with (sup b); auto with arith. cut (a = natural n :>Elt \/ dans (natural n) b). (* Goal: forall (a b : Elt) (_ : not (@eq Elt a b)), not (@eq Elt b a) *) 2: apply dans_add; auto. (* Goal: forall e : Ensf, @ex Elt (fun x : Elt => not (dans x e)) *) intro. elim H1. intro; left. rewrite H2; apply lt_n_Z. intro; right. apply H; assumption. Qed. (* *) (* On en deduit que (natural (sup x)) n'est pas dans x *) (* *) Lemma sup_out : forall x : Ensf, ~ dans (natural (sup x)) x. (* Goal: forall e : Ensf, @ex Elt (fun x : Elt => not (dans x e)) *) intro. (* Goal: not (dans (natural (sup x)) x) *) red in |- *. (* Goal: forall e : Ensf, @ex Elt (fun x : Elt => not (dans x e)) *) intro. (* Goal: False *) cut (sup x < sup x). (* Goal: forall _ : lt (sup x) (sup x), False *) (* Goal: lt (sup x) (sup x) *) change (~ sup x < sup x) in |- *. (* Goal: not (lt (sup x) (sup x)) *) (* Goal: lt (sup x) (sup x) *) apply lt_irrefl. (* Goal: lt (sup x) (sup x) *) apply lt_n_sup. (* Goal: dans (natural (sup x)) x *) assumption. Qed. (* *) (* Le resultat final : *) (* Pout tout ensemble e il existe un element x n'appartenant pas a e *) (* (a savoir (natural (sup x)) ) *) (* *) Lemma exist_other : forall e : Ensf, exists x : Elt, ~ dans x e. (* Goal: forall e : Ensf, @ex Elt (fun x : Elt => not (dans x e)) *) intro. (* Goal: @ex Elt (fun x : Elt => not (dans x e)) *) exists (natural (sup e)). (* Goal: not (dans (natural (sup e)) e) *) apply sup_out. Qed.
(* This program is free software; you can redistribute it and/or *) (* modify it under the terms of the GNU Lesser General Public License *) (* as published by the Free Software Foundation; either version 2.1 *) (* of the License, or (at your option) any later version. *) (* *) (* This program is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* GNU General Public License for more details. *) (* *) (* You should have received a copy of the GNU Lesser General Public *) (* License along with this program; if not, write to the Free *) (* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *) (* 02110-1301 USA *) (* Contribution to the Coq Library V6.3 (July 1999) *) (****************************************************************************) (* The Calculus of Inductive Constructions *) (* *) (* Projet Coq *) (* *) (* INRIA ENS-CNRS *) (* Rocquencourt Lyon *) (* *) (* Coq V5.10 *) (* Nov 25th 1994 *) (* *) (****************************************************************************) (* fonctions.v *) (****************************************************************************) (* Formal Language Theory *) (* *) (* Judicael Courant - Jean-Christophe Filliatre *) (* *) (* Developped in V5.8 June-July 1993 *) (* Ported to V5.10 October 1994 *) (****************************************************************************) Require Import Ensf. Require Import Words. Require Import more_words. Require Import need. Hint Resolve dans_map_inv. Hint Resolve dans_map. Hint Resolve dans_add1. Definition comp (f g : Elt -> Elt) (x : Elt) := f (g x). Lemma map_map_eg_map_comp : forall (f g : Elt -> Elt) (E : Ensf), map f (map g E) = map (comp f g) E :>Ensf. (* Goal: forall f g : forall _ : Elt, Elt, eg_f_W_W (Word_ext (comp f g)) (comp_word (Word_ext f) (Word_ext g)) *) intros f g. (* Goal: forall E : Ensf, @eq Ensf (map f (map g E)) (map (comp f g) E) *) simple induction E; simpl in |- *; auto. Qed. Definition comp_word (f g : Word -> Word) (x : Word) := f (g x). Definition eg_f_W_W (f g : Word -> Word) := forall x : Word, f x = g x :>Word. Lemma comp_Word_ext : forall f g : Elt -> Elt, eg_f_W_W (Word_ext (comp f g)) (comp_word (Word_ext f) (Word_ext g)). (* Goal: forall f g : forall _ : Elt, Elt, eg_f_W_W (Word_ext (comp f g)) (comp_word (Word_ext f) (Word_ext g)) *) intros f g. (* Goal: eg_f_W_W (Word_ext (comp f g)) (comp_word (Word_ext f) (Word_ext g)) *) unfold eg_f_W_W, Word_ext, comp, comp_word in |- *. (* Goal: forall x : Word, @eq Word ((fix Word_ext (f : forall _ : Elt, Elt) (w : Word) {struct w} : Word := match w with | nil => nil | cons a w' => cons (f a) (Word_ext f w') end) (fun x0 : Elt => f (g x0)) x) ((fix Word_ext (f : forall _ : Elt, Elt) (w : Word) {struct w} : Word := match w with | nil => nil | cons a w' => cons (f a) (Word_ext f w') end) f ((fix Word_ext (f : forall _ : Elt, Elt) (w : Word) {struct w} : Word := match w with | nil => nil | cons a w' => cons (f a) (Word_ext f w') end) g x)) *) simple induction x; simpl in |- *; auto. Qed. Hint Resolve comp_Word_ext. Definition Id (E : Ensf) (f : Elt -> Elt) := forall x : Elt, dans x E -> f x = x :>Elt. Lemma Id_inv : forall (E : Ensf) (f : Elt -> Elt) (x : Elt), dans x E -> Id E f -> f x = x :>Elt. (* Goal: eg_f_W_W (Word_ext (comp invf' f)) (comp_word (Word_ext invf') (Word_ext f)) *) auto. Qed. Hint Unfold Id. Lemma Id_inclus : forall (E F : Ensf) (f : Elt -> Elt), inclus F E -> Id E f -> Id F f. (* Goal: eg_f_W_W (Word_ext (comp invf' f)) (comp_word (Word_ext invf') (Word_ext f)) *) auto. Qed. Lemma map_Id : forall (E : Ensf) (f : Elt -> Elt), Id E f -> map f E = E :>Ensf. (* Goal: forall (E : Ensf) (f : forall _ : Elt, Elt) (_ : Id E f), @eq Ensf (map f E) E *) intros E f. (* Goal: forall _ : Id E f, @eq Ensf (map f E) E *) elim E; unfold map in |- *. (* Goal: eg_f_W_W (Word_ext (comp invf' f)) (comp_word (Word_ext invf') (Word_ext f)) *) auto. (* Goal: forall (e : Elt) (e0 : Ensf) (_ : forall _ : Id e0 f, @eq Ensf ((fix map (f : forall _ : Elt, Elt) (e1 : Ensf) {struct e1} : Ensf := match e1 with | empty => empty | add y e2 => add (f y) (map f e2) end) f e0) e0) (_ : Id (add e e0) f), @eq Ensf (add (f e) ((fix map (f : forall _ : Elt, Elt) (e1 : Ensf) {struct e1} : Ensf := match e1 with | empty => empty | add y e2 => add (f y) (map f e2) end) f e0)) (add e e0) *) intros a b Hyp_rec Id_a_b_f. (* Goal: @eq Ensf (add (f a) ((fix map (f : forall _ : Elt, Elt) (e : Ensf) {struct e} : Ensf := match e with | empty => empty | add y e0 => add (f y) (map f e0) end) f b)) (add a b) *) apply add_add. (* Goal: eg_f_W_W (Word_ext (comp invf' f)) (comp_word (Word_ext invf') (Word_ext f)) *) auto. (* Goal: @eq Ensf ((fix map (f : forall _ : Elt, Elt) (e : Ensf) {struct e} : Ensf := match e with | empty => empty | add y e0 => add (f y) (map f e0) end) f b) b *) apply Hyp_rec. (* Goal: eg_f_W_W (Word_ext (comp invf' f)) (comp_word (Word_ext invf') (Word_ext f)) *) apply Id_inclus with (add a b); auto. Qed. Definition Id_words (E : Ensf) (f : Word -> Word) := forall x : Word, inmonoid E x -> f x = x :>Word. Lemma Id_words_inv : forall (E : Ensf) (f : Word -> Word) (x : Word), inmonoid E x -> Id_words E f -> f x = x :>Word. (* Goal: eg_f_W_W (Word_ext (comp invf' f)) (comp_word (Word_ext invf') (Word_ext f)) *) auto. Qed. Lemma Id_words_inclus : forall (E F : Ensf) (f : Word -> Word), inclus F E -> Id_words E f -> Id_words F f. (* Goal: forall (E F : Ensf) (f : forall _ : Word, Word) (_ : inclus F E) (_ : Id_words E f), Id_words F f *) intros E F f inclus_F_E Id_E_f. (* Goal: Id_words E weinvf_wef *) red in |- *. (* Goal: forall (x : Word) (_ : inmonoid F x), @eq Word (f x) x *) intros x inmonoid_F_x. (* Goal: @eq Word (f x) x *) apply Id_E_f. (* Goal: inmonoid E x *) apply inmonoid_inclus with F; assumption. Qed. Lemma extension_Id : forall (E : Ensf) (f : Elt -> Elt), Id E f -> Id_words E (Word_ext f). (* Goal: forall (E : Ensf) (f : forall _ : Elt, Elt) (_ : Id E f), Id_words E (Word_ext f) *) intros E f Id_E_f. (* Goal: Id_words E weinvf_wef *) red in |- *. (* Goal: forall (x : Word) (_ : inmonoid F x), @ex2 Word (fun y : Word => @eq Word x (wef y)) (fun y : Word => inmonoid E y) *) simple induction x; clear x. (* Goal: eg_f_W_W (Word_ext (comp invf' f)) (comp_word (Word_ext invf') (Word_ext f)) *) auto. (* Goal: forall (e : Elt) (w : Word) (_ : forall _ : inmonoid E w, @eq Word (Word_ext f w) w) (_ : inmonoid E (cons e w)), @eq Word (Word_ext f (cons e w)) (cons e w) *) unfold Word_ext in |- *. (* plus simple : Prolog [ cons_cons inmonoid_cons_inv2 inmonoid_cons_inv ] 8.*) (* Goal: forall (e : Elt) (w : Word) (_ : forall _ : inmonoid E w, @eq Word ((fix Word_ext (f : forall _ : Elt, Elt) (w0 : Word) {struct w0} : Word := match w0 with | nil => nil | cons a w' => cons (f a) (Word_ext f w') end) f w) w) (_ : inmonoid E (cons e w)), @eq Word (cons (f e) ((fix Word_ext (f : forall _ : Elt, Elt) (w0 : Word) {struct w0} : Word := match w0 with | nil => nil | cons a w' => cons (f a) (Word_ext f w') end) f w)) (cons e w) *) intros x w Hyp inmonoid_E_cons_x_w. (* Goal: @eq Word (cons (f x) ((fix Word_ext (f : forall _ : Elt, Elt) (w : Word) {struct w} : Word := match w with | nil => nil | cons a w' => cons (f a) (Word_ext f w') end) f w)) (cons x w) *) simpl in |- *. (* Goal: @eq Word (cons x0 w0) (cons e r) *) (* Goal: @ex Elt (fun x : Elt => @ex2 Word (fun w : Word => @eq Word (cons x w) y) (fun w : Word => and (@eq Elt (f x) (f x0)) (@eq Word (wef w) (wef w0)))) *) apply cons_cons. (* Goal: @eq Elt (f x) x *) (* Goal: @eq Word ((fix Word_ext (f : forall _ : Elt, Elt) (w : Word) {struct w} : Word := match w with | nil => nil | cons a w' => cons (f a) (Word_ext f w') end) f w) w *) apply Id_E_f; apply inmonoid_cons_inv2 with w; assumption. (* Goal: @eq Elt x0 e *) (* Goal: @eq Word w0 r *) (* Goal: @ex Elt (fun x : Elt => @ex2 Word (fun w : Word => @eq Word (cons x w) y) (fun w : Word => and (@eq Elt (f x) (f x0)) (@eq Word (wef w) (wef w0)))) *) apply Hyp. (* Goal: inmonoid E w *) apply inmonoid_cons_inv with x; assumption. Qed. Section fonctions. Variable E : Ensf. Variable F : Ensf. Variable f : Elt -> Elt. (*Definition d'une application*) Definition application := forall x : Elt, dans x E -> dans (f x) F. Hint Unfold application. (*Definition de l'injectivite*) Definition is_mono := forall x y : Elt, dans x E -> dans y E -> f x = f y :>Elt -> x = y :>Elt. (*Definition surjectivite*) Definition is_epi := application /\ (forall x : Elt, dans x F -> exists2 y : Elt, x = f y & dans y E). Definition is_iso := is_epi /\ is_mono. Lemma mono_epi_imp_iso : is_mono -> is_epi -> is_iso. (* Goal: eg_f_W_W (Word_ext (comp invf' f)) (comp_word (Word_ext invf') (Word_ext f)) *) intros; red in |- *; auto. Qed. Variable fw : Word -> Word. (*Definition d'une application pour les mots*) Definition application_words := forall x : Word, inmonoid E x -> inmonoid F (fw x). (*Definition de l'injectivite*) Definition is_mono_words := forall x y : Word, inmonoid E x -> inmonoid E y -> fw x = fw y :>Word -> x = y :>Word. (*Definition surjectivite pour les fonctions sur les monoides*) Definition is_epi_words := application_words /\ (forall x : Word, inmonoid F x -> exists2 y : Word, x = fw y & inmonoid E y). Definition is_iso_words := is_mono_words /\ is_epi_words. Lemma mono_epi_imp_iso_words : is_mono_words -> is_epi_words -> is_iso_words. (* Goal: eg_f_W_W (Word_ext (comp invf' f)) (comp_word (Word_ext invf') (Word_ext f)) *) intros; red in |- *; auto. Qed. End fonctions. Hint Resolve mono_epi_imp_iso. Parameter inv : Ensf -> Ensf -> (Elt -> Elt) -> Elt -> Elt. Axiom dans_inv_f : forall (E F : Ensf) (f : Elt -> Elt), is_iso E F f -> forall x : Elt, dans x F -> dans (inv E F f x) E. Hint Resolve dans_inv_f. Axiom inv1 : forall (E F : Ensf) (f : Elt -> Elt), is_iso E F f -> forall x : Elt, dans x E -> inv E F f (f x) = x :>Elt. Hint Resolve inv1. Axiom inv2 : forall (E F : Ensf) (f : Elt -> Elt), is_iso E F f -> forall x : Elt, dans x F -> f (inv E F f x) = x :>Elt. Hint Resolve inv2. Lemma inv1' : forall (E F : Ensf) (f : Elt -> Elt), is_iso E F f -> Id E (comp (inv E F f) f). (* Goal: forall (E F : Ensf) (f : forall _ : Elt, Elt) (_ : is_iso E F f), Id E (comp (inv E F f) f) *) unfold Id, comp in |- *. (* Goal: forall (_ : @eq Elt (f e) (f x0)) (_ : @eq Word (wef r) (wef w0)), @eq Word (cons x0 w0) y *) (* Goal: @ex Elt (fun x : Elt => @ex2 Word (fun w : Word => @eq Word (cons x w) y) (fun w : Word => and (@eq Elt (f x) (f x0)) (@eq Word (wef w) (wef w0)))) *) intros. (* Goal: eg_f_W_W (Word_ext (comp invf' f)) (comp_word (Word_ext invf') (Word_ext f)) *) auto. Qed. Hint Resolve inv1'. (* On etend la fonction f : Elt-> Elt definie sur V*) (*en la fonction F=(extension V f)*) (*definie sur Elt par F(x) = f(x) sur V et F(x)=x ailleurs*) Axiom extension_spec : forall (V : Ensf) (f : Elt -> Elt) (x : Elt), {y : Elt | dans x V /\ y = f x :>Elt \/ ~ dans x V /\ y = x :>Elt}. (* Lemma extension_spec : (V:Ensf)(f:Elt->Elt)(x:Elt) {y:Elt | ((dans x V)/\<Elt>y=(f x)) \/ (~(dans x V)/\<Elt>y=x)}. Realizer [V:Ensf][f:Elt -> Elt][x : Elt] (<Elt> Match (Dans_spec x V) with (*true*) (f x) (*false*) x ) . Program_all. Save. *) Definition extension (V : Ensf) (f : Elt -> Elt) (x : Elt) := let (y, p) return Elt := extension_spec V f x in y. Lemma extension_in : forall (e : Ensf) (f : Elt -> Elt) (x : Elt), dans x e -> extension e f x = f x :>Elt. (* Goal: forall (e : Ensf) (f : forall _ : Elt, Elt) (x : Elt) (_ : not (dans x e)), @eq Elt (extension e f x) x *) unfold extension in |- *. (* Goal: forall (e : Ensf) (f : forall _ : Elt, Elt) (x : Elt) (_ : dans x e), @eq Elt (let (y, _) := extension_spec e f x in y) (f x) *) intros e f x dans_x_e. (* Goal: @eq Elt (let (y, _) := extension_spec e f x in y) x *) elim (extension_spec e f x). (* Goal: forall (x0 : Elt) (_ : and (dans x0 E) (@eq Elt x (f x0))), @ex2 Elt (fun y : Elt => @eq Elt x (f y)) (fun y : Elt => dans y E) *) (* Goal: @ex Elt (fun y : Elt => and (dans y E) (@eq Elt x (f y))) *) intro. (* Goal: eg_f_W_W (Word_ext (comp invf' f)) (comp_word (Word_ext invf') (Word_ext f)) *) tauto. Qed. Lemma extension_out : forall (e : Ensf) (f : Elt -> Elt) (x : Elt), ~ dans x e -> extension e f x = x :>Elt. (* Goal: forall (e : Ensf) (f : forall _ : Elt, Elt) (x : Elt) (_ : not (dans x e)), @eq Elt (extension e f x) x *) unfold extension in |- *. (* Goal: forall (e : Ensf) (f : forall _ : Elt, Elt) (x : Elt) (_ : not (dans x e)), @eq Elt (let (y, _) := extension_spec e f x in y) x *) intros e f x N_dans_x_e. (* Goal: @eq Elt (let (y, _) := extension_spec e f x in y) x *) elim (extension_spec e f x). (* Goal: eg_f_W_W (Word_ext (comp invf' f)) (comp_word (Word_ext invf') (Word_ext f)) *) intro; tauto. Qed. Section fonctions2. Variable E : Ensf. Variable F : Ensf. Variable f : Elt -> Elt. Hint Unfold application. Lemma is_epi_f_over_image : is_epi E (map f E) f. (* Goal: is_epi_words E F wef *) split. (* Goal: eg_f_W_W (Word_ext (comp invf' f)) (comp_word (Word_ext invf') (Word_ext f)) *) auto. (* Goal: forall (_ : @eq Elt (f e) (f x0)) (_ : @eq Word (wef r) (wef w0)), @eq Word (cons x0 w0) y *) (* Goal: @ex Elt (fun x : Elt => @ex2 Word (fun w : Word => @eq Word (cons x w) y) (fun w : Word => and (@eq Elt (f x) (f x0)) (@eq Word (wef w) (wef w0)))) *) intros. (* Goal: @ex2 Elt (fun y : Elt => @eq Elt x (f y)) (fun y : Elt => dans y E) *) cut (exists y : Elt, dans y E /\ x = f y :>Elt). (* Goal: forall _ : @ex2 Elt (fun x_ant : Elt => @eq Elt x (f x_ant)) (fun x_ant : Elt => dans x_ant E), @ex2 Word (fun y : Word => @eq Word (cons x w) (wef y)) (fun y : Word => inmonoid E y) *) (* Goal: @ex2 Elt (fun x_ant : Elt => @eq Elt x (f x_ant)) (fun x_ant : Elt => dans x_ant E) *) (* Goal: @ex2 Word (fun y : Word => @eq Word w (wef y)) (fun y : Word => inmonoid E y) *) intro temp; elim temp; clear temp. (* Goal: forall (x0 : Elt) (_ : and (dans x0 E) (@eq Elt x (f x0))), @ex2 Elt (fun y : Elt => @eq Elt x (f y)) (fun y : Elt => dans y E) *) (* Goal: @ex Elt (fun y : Elt => and (dans y E) (@eq Elt x (f y))) *) intro. intuition. (* Goal: @ex2 Elt (fun y : Elt => @eq Elt x (f y)) (fun y : Elt => dans y E) *) (* Goal: @ex Elt (fun y : Elt => and (dans y E) (@eq Elt x (f y))) *) prolog [ ex_intro2 ] 4. (*Intros y temp; Elim temp; Clear temp ; Intros dans_y egal_y. Exists y;Auto.*) (* Goal: eg_f_W_W (Word_ext (comp invf' f)) (comp_word (Word_ext invf') (Word_ext f)) *) auto. Qed. Hint Resolve is_epi_f_over_image. Lemma mono_imp_iso_over_image : is_mono E f -> is_iso E (map f E) f. (* Goal: eg_f_W_W (Word_ext (comp invf' f)) (comp_word (Word_ext invf') (Word_ext f)) *) auto. Qed. Let invf := inv E F f. Hint Unfold invf. Lemma inv_is_mono : is_iso E F f -> is_mono F invf. (* Goal: forall (_ : @eq Elt (f e) (f x0)) (_ : @eq Word (wef r) (wef w0)), @eq Word (cons x0 w0) y *) (* Goal: @ex Elt (fun x : Elt => @ex2 Word (fun w : Word => @eq Word (cons x w) y) (fun w : Word => and (@eq Elt (f x) (f x0)) (@eq Word (wef w) (wef w0)))) *) intros. (* Goal: Id_words E weinvf_wef *) red in |- *. (* Goal: forall (x y : Elt) (_ : dans x F) (_ : dans y F) (_ : @eq Elt (invf x) (invf y)), @eq Elt x y *) intros x y dans_x dans_y egal_inv. (* Goal: @eq Elt x y *) replace x with (f (inv E F f x)). (* Goal: @eq Elt (f (inv E F f x)) y *) (* Goal: @eq Elt (f (inv E F f x)) x *) replace y with (f (inv E F f y)). (* Goal: @eq Elt (f (inv E F f x)) (f (inv E F f y)) *) (* Goal: @eq Elt (f (inv E F f y)) y *) (* Goal: @eq Elt (f (inv E F f x)) x *) apply (f_equal (A:=Elt) (B:=Elt)); assumption. (* Goal: eg_f_W_W (Word_ext (comp invf' f)) (comp_word (Word_ext invf') (Word_ext f)) *) auto. (* Goal: eg_f_W_W (Word_ext (comp invf' f)) (comp_word (Word_ext invf') (Word_ext f)) *) auto. Qed. Lemma inv_is_epi : is_iso E F f -> is_epi F E invf. (* Goal: forall _ : is_iso E F f, is_epi F E invf *) unfold invf in |- *. (* Goal: forall _ : is_iso E F f, Id_words E weinvf_wef *) intro is_iso_f. (* Goal: is_epi_words E F wef *) split. (* Goal: eg_f_W_W (Word_ext (comp invf' f)) (comp_word (Word_ext invf') (Word_ext f)) *) auto. (* Hint : dans_inv_f*) (* Hints Resolve inv1 .*) (* Goal: forall (x : Elt) (_ : dans x E), @ex2 Elt (fun y : Elt => @eq Elt x (inv E F f y)) (fun y : Elt => dans y F) *) intros x dans_x. (* Goal: @ex2 Elt (fun y : Elt => @eq Elt x (inv E F f y)) (fun y : Elt => dans y F) *) exists (f x); [ apply sym_equal; auto | elim is_iso_f ]. (* Goal: forall (_ : is_epi E F f) (_ : is_mono E f), dans (f x) F *) intros is_epi_f. elim is_epi_f. (* Goal: eg_f_W_W (Word_ext (comp invf' f)) (comp_word (Word_ext invf') (Word_ext f)) *) auto. Qed. Let wef := Word_ext f. Lemma application_imp_application_words : application E F f -> application_words E F wef. (* Goal: forall (_ : forall x : Word, @eq Word (Word_ext (comp invf' f) x) (comp_word (Word_ext invf') (Word_ext f) x)) (_ : inmonoid E x), @eq Word (comp_word (Word_ext invf') (Word_ext f) x) x *) (* Goal: eg_f_W_W (Word_ext (comp invf' f)) (comp_word (Word_ext invf') (Word_ext f)) *) intro Hyp. (* Goal: Id_words E weinvf_wef *) red in |- *. (* Goal: forall (x : Word) (_ : inmonoid E x), inmonoid F (wef x) *) intros x inmon; elim inmon; clear inmon. (* Goal: eg_f_W_W (Word_ext (comp invf' f)) (comp_word (Word_ext invf') (Word_ext f)) *) auto. (* Goal: forall (_ : @eq Elt (f e) (f x0)) (_ : @eq Word (wef r) (wef w0)), @eq Word (cons x0 w0) y *) (* Goal: @ex Elt (fun x : Elt => @ex2 Word (fun w : Word => @eq Word (cons x w) y) (fun w : Word => and (@eq Elt (f x) (f x0)) (@eq Word (wef w) (wef w0)))) *) intros. (* Goal: eg_f_W_W (Word_ext (comp invf' f)) (comp_word (Word_ext invf') (Word_ext f)) *) replace (wef (cons e w)) with (cons (f e) (wef w)); auto. Qed. Hint Resolve application_imp_application_words. Lemma is_mono_f_imp_is_mono_words : is_mono E f -> is_mono_words E wef. (* Goal: forall (_ : forall x : Word, @eq Word (Word_ext (comp invf' f) x) (comp_word (Word_ext invf') (Word_ext f) x)) (_ : inmonoid E x), @eq Word (comp_word (Word_ext invf') (Word_ext f) x) x *) (* Goal: eg_f_W_W (Word_ext (comp invf' f)) (comp_word (Word_ext invf') (Word_ext f)) *) intro Hyp. (* Goal: Id_words E weinvf_wef *) red in |- *. (* Goal: forall (x y : Word) (_ : inmonoid E x) (_ : inmonoid E y) (_ : @eq Word (wef x) (wef y)), @eq Word x y *) simple induction x. (* Goal: forall (_ : @eq Elt (f e) (f x0)) (_ : @eq Word (wef r) (wef w0)), @eq Word (cons x0 w0) y *) (* Goal: @ex Elt (fun x : Elt => @ex2 Word (fun w : Word => @eq Word (cons x w) y) (fun w : Word => and (@eq Elt (f x) (f x0)) (@eq Word (wef w) (wef w0)))) *) intros. (* Goal: @eq Word nil y *) (* Goal: forall (e : Elt) (w : Word) (_ : forall (y : Word) (_ : inmonoid E w) (_ : inmonoid E y) (_ : @eq Word (wef w) (wef y)), @eq Word w y) (y : Word) (_ : inmonoid E (cons e w)) (_ : inmonoid E y) (_ : @eq Word (wef (cons e w)) (wef y)), @eq Word (cons e w) y *) apply sym_equal. (* Goal: @eq Word y nil *) (* Goal: forall (e : Elt) (w : Word) (_ : forall (y : Word) (_ : inmonoid E w) (_ : inmonoid E y) (_ : @eq Word (wef w) (wef y)), @eq Word w y) (y : Word) (_ : inmonoid E (cons e w)) (_ : inmonoid E y) (_ : @eq Word (wef (cons e w)) (wef y)), @eq Word (cons e w) y *) apply wef_nil with f. (* Goal: eg_f_W_W (Word_ext (comp invf' f)) (comp_word (Word_ext invf') (Word_ext f)) *) auto. (* Goal: forall (_ : @eq Elt (f e) (f x0)) (_ : @eq Word (wef r) (wef w0)), @eq Word (cons x0 w0) y *) (* Goal: @ex Elt (fun x : Elt => @ex2 Word (fun w : Word => @eq Word (cons x w) y) (fun w : Word => and (@eq Elt (f x) (f x0)) (@eq Word (wef w) (wef w0)))) *) intros x0 w0. intros. cut (exists x : Elt, (exists2 w : Word, cons x w = y & f x = f x0 /\ wef w = wef w0)). (* Goal: forall _ : @ex2 Elt (fun x_ant : Elt => @eq Elt x (f x_ant)) (fun x_ant : Elt => dans x_ant E), @ex2 Word (fun y : Word => @eq Word (cons x w) (wef y)) (fun y : Word => inmonoid E y) *) (* Goal: @ex2 Elt (fun x_ant : Elt => @eq Elt x (f x_ant)) (fun x_ant : Elt => dans x_ant E) *) (* Goal: @ex2 Word (fun y : Word => @eq Word w (wef y)) (fun y : Word => inmonoid E y) *) intro temp; elim temp; clear temp. (* Goal: forall (x : Elt) (_ : @ex2 Word (fun w : Word => @eq Word (cons x w) y) (fun w : Word => and (@eq Elt (f x) (f x0)) (@eq Word (wef w) (wef w0)))), @eq Word (cons x0 w0) y *) (* Goal: @ex Elt (fun x : Elt => @ex2 Word (fun w : Word => @eq Word (cons x w) y) (fun w : Word => and (@eq Elt (f x) (f x0)) (@eq Word (wef w) (wef w0)))) *) intro e. (* Goal: forall _ : @ex2 Elt (fun x_ant : Elt => @eq Elt x (f x_ant)) (fun x_ant : Elt => dans x_ant E), @ex2 Word (fun y : Word => @eq Word (cons x w) (wef y)) (fun y : Word => inmonoid E y) *) (* Goal: @ex2 Elt (fun x_ant : Elt => @eq Elt x (f x_ant)) (fun x_ant : Elt => dans x_ant E) *) (* Goal: @ex2 Word (fun y : Word => @eq Word w (wef y)) (fun y : Word => inmonoid E y) *) intro temp; elim temp; clear temp. (* Goal: forall (x : Word) (_ : @eq Word (cons e x) y) (_ : and (@eq Elt (f e) (f x0)) (@eq Word (wef x) (wef w0))), @eq Word (cons x0 w0) y *) (* Goal: @ex Elt (fun x : Elt => @ex2 Word (fun w : Word => @eq Word (cons x w) y) (fun w : Word => and (@eq Elt (f x) (f x0)) (@eq Word (wef w) (wef w0)))) *) intro r. (* Goal: forall (_ : @eq Word (cons e r) y) (_ : and (@eq Elt (f e) (f x0)) (@eq Word (wef r) (wef w0))), @eq Word (cons x0 w0) y *) (* Goal: @ex Elt (fun x : Elt => @ex2 Word (fun w : Word => @eq Word (cons x w) y) (fun w : Word => and (@eq Elt (f x) (f x0)) (@eq Word (wef w) (wef w0)))) *) intros y_egal temp. (* Goal: @eq Word (cons x0 w0) y *) (* Goal: @ex Elt (fun x : Elt => @ex2 Word (fun w : Word => @eq Word (cons x w) y) (fun w : Word => and (@eq Elt (f x) (f x0)) (@eq Word (wef w) (wef w0)))) *) elim temp; clear temp. (* Goal: forall (_ : @eq Elt (f e) (f x0)) (_ : @eq Word (wef r) (wef w0)), @eq Word (cons x0 w0) y *) (* Goal: @ex Elt (fun x : Elt => @ex2 Word (fun w : Word => @eq Word (cons x w) y) (fun w : Word => and (@eq Elt (f x) (f x0)) (@eq Word (wef w) (wef w0)))) *) intros. (* Goal: @eq Word (cons x0 w0) y *) (* Goal: @ex Elt (fun x : Elt => @ex2 Word (fun w : Word => @eq Word (cons x w) y) (fun w : Word => and (@eq Elt (f x) (f x0)) (@eq Word (wef w) (wef w0)))) *) rewrite <- y_egal. (* Goal: @eq Word (cons x0 w0) (cons e r) *) (* Goal: @ex Elt (fun x : Elt => @ex2 Word (fun w : Word => @eq Word (cons x w) y) (fun w : Word => and (@eq Elt (f x) (f x0)) (@eq Word (wef w) (wef w0)))) *) apply cons_cons. (* Goal: @eq Elt x0 e *) (* Goal: @eq Word w0 r *) (* Goal: @ex Elt (fun x : Elt => @ex2 Word (fun w : Word => @eq Word (cons x w) y) (fun w : Word => and (@eq Elt (f x) (f x0)) (@eq Word (wef w) (wef w0)))) *) apply Hyp. (*; Auto.*) (* Goal: dans x0 E *) (* Goal: dans e E *) (* Goal: @eq Elt (f x0) (f e) *) (* Goal: @eq Word w0 r *) (* Goal: @ex Elt (fun x : Elt => @ex2 Word (fun w : Word => @eq Word (cons x w) y) (fun w : Word => and (@eq Elt (f x) (f x0)) (@eq Word (wef w) (wef w0)))) *) apply inmonoid_cons_inv2 with w0; assumption. (* Goal: dans e E *) (* Goal: @eq Elt (f x0) (f e) *) (* Goal: @eq Word w0 r *) (* Goal: @ex Elt (fun x : Elt => @ex2 Word (fun w : Word => @eq Word (cons x w) y) (fun w : Word => and (@eq Elt (f x) (f x0)) (@eq Word (wef w) (wef w0)))) *) apply inmonoid_cons_inv2 with r; rewrite y_egal; assumption. (* Goal: eg_f_W_W (Word_ext (comp invf' f)) (comp_word (Word_ext invf') (Word_ext f)) *) auto. (* Goal: @eq Word w0 r *) (* Goal: @ex Elt (fun x : Elt => @ex2 Word (fun w : Word => @eq Word (cons x w) y) (fun w : Word => and (@eq Elt (f x) (f x0)) (@eq Word (wef w) (wef w0)))) *) apply H. (* Goal: inmonoid E w0 *) (* Goal: inmonoid E r *) (* Goal: @eq Word (wef w0) (wef r) *) (* Goal: @ex Elt (fun x : Elt => @ex2 Word (fun w : Word => @eq Word (cons x w) y) (fun w : Word => and (@eq Elt (f x) (f x0)) (@eq Word (wef w) (wef w0)))) *) apply (inmonoid_cons_inv E w0 x0); assumption. (* Goal: inmonoid E r *) (* Goal: @eq Word (wef w0) (wef r) *) (* Goal: @ex Elt (fun x : Elt => @ex2 Word (fun w : Word => @eq Word (cons x w) y) (fun w : Word => and (@eq Elt (f x) (f x0)) (@eq Word (wef w) (wef w0)))) *) apply (inmonoid_cons_inv E r e); rewrite y_egal; assumption. (* Goal: eg_f_W_W (Word_ext (comp invf' f)) (comp_word (Word_ext invf') (Word_ext f)) *) auto. (*Resolution du Cut*) (* Goal: @ex Elt (fun x : Elt => @ex2 Word (fun w : Word => @eq Word (cons x w) y) (fun w : Word => and (@eq Elt (f x) (f x0)) (@eq Word (wef w) (wef w0)))) *) unfold wef in |- *. (* Apply wef_cons.*) (* Goal: eg_f_W_W (Word_ext (comp invf' f)) (comp_word (Word_ext invf') (Word_ext f)) *) auto. Qed. Hint Resolve is_mono_f_imp_is_mono_words. Lemma is_epi_f_imp_is_epi_words : is_epi E F f -> is_epi_words E F wef. (* Goal: forall _ : @ex2 Elt (fun x_ant : Elt => @eq Elt x (f x_ant)) (fun x_ant : Elt => dans x_ant E), @ex2 Word (fun y : Word => @eq Word (cons x w) (wef y)) (fun y : Word => inmonoid E y) *) (* Goal: @ex2 Elt (fun x_ant : Elt => @eq Elt x (f x_ant)) (fun x_ant : Elt => dans x_ant E) *) (* Goal: @ex2 Word (fun y : Word => @eq Word w (wef y)) (fun y : Word => inmonoid E y) *) intro temp; elim temp; clear temp. (* Goal: forall (_ : application E F f) (_ : forall (x : Elt) (_ : dans x F), @ex2 Elt (fun y : Elt => @eq Elt x (f y)) (fun y : Elt => dans y E)), is_epi_words E F wef *) intro application_f. (* Goal: forall _ : forall (x : Elt) (_ : dans x F), @ex2 Elt (fun y : Elt => @eq Elt x (f y)) (fun y : Elt => dans y E), is_epi_words E F wef *) intro is_epi_f. (* Goal: is_epi_words E F wef *) split. (* Goal: eg_f_W_W (Word_ext (comp invf' f)) (comp_word (Word_ext invf') (Word_ext f)) *) auto. (* Goal: forall (x : Word) (_ : inmonoid F x), @ex2 Word (fun y : Word => @eq Word x (wef y)) (fun y : Word => inmonoid E y) *) simple induction x; clear x. (* Goal: eg_f_W_W (Word_ext (comp invf' f)) (comp_word (Word_ext invf') (Word_ext f)) *) exists nil; auto. (* Goal: forall (e : Elt) (w : Word) (_ : forall _ : inmonoid F w, @ex2 Word (fun y : Word => @eq Word w (wef y)) (fun y : Word => inmonoid E y)) (_ : inmonoid F (cons e w)), @ex2 Word (fun y : Word => @eq Word (cons e w) (wef y)) (fun y : Word => inmonoid E y) *) intros x w Hyp inmonoid_F_cons. (* Goal: @ex2 Word (fun y : Word => @eq Word (cons x w) (wef y)) (fun y : Word => inmonoid E y) *) cut (exists2 y : Word, w = wef y & inmonoid E y). (*1*) (* Goal: forall _ : @ex2 Elt (fun x_ant : Elt => @eq Elt x (f x_ant)) (fun x_ant : Elt => dans x_ant E), @ex2 Word (fun y : Word => @eq Word (cons x w) (wef y)) (fun y : Word => inmonoid E y) *) (* Goal: @ex2 Elt (fun x_ant : Elt => @eq Elt x (f x_ant)) (fun x_ant : Elt => dans x_ant E) *) (* Goal: @ex2 Word (fun y : Word => @eq Word w (wef y)) (fun y : Word => inmonoid E y) *) intro temp; elim temp; clear temp. (* Goal: forall (x0 : Word) (_ : @eq Word w (wef x0)) (_ : inmonoid E x0), @ex2 Word (fun y : Word => @eq Word (cons x w) (wef y)) (fun y : Word => inmonoid E y) *) (* Goal: @ex2 Word (fun y : Word => @eq Word w (wef y)) (fun y : Word => inmonoid E y) *) intros y1 y1_egal inmonoid_y1. (* Goal: @ex2 Word (fun y : Word => @eq Word (cons x w) (wef y)) (fun y : Word => inmonoid E y) *) (* Goal: @ex2 Word (fun y : Word => @eq Word w (wef y)) (fun y : Word => inmonoid E y) *) cut (exists2 x_ant : Elt, x = f x_ant & dans x_ant E). (*2*) (* Goal: forall _ : @ex2 Elt (fun x_ant : Elt => @eq Elt x (f x_ant)) (fun x_ant : Elt => dans x_ant E), @ex2 Word (fun y : Word => @eq Word (cons x w) (wef y)) (fun y : Word => inmonoid E y) *) (* Goal: @ex2 Elt (fun x_ant : Elt => @eq Elt x (f x_ant)) (fun x_ant : Elt => dans x_ant E) *) (* Goal: @ex2 Word (fun y : Word => @eq Word w (wef y)) (fun y : Word => inmonoid E y) *) intro temp; elim temp; clear temp. (* Goal: forall (x0 : Elt) (_ : @eq Elt x (f x0)) (_ : dans x0 E), @ex2 Word (fun y : Word => @eq Word (cons x w) (wef y)) (fun y : Word => inmonoid E y) *) (* Goal: @ex2 Elt (fun x_ant : Elt => @eq Elt x (f x_ant)) (fun x_ant : Elt => dans x_ant E) *) (* Goal: @ex2 Word (fun y : Word => @eq Word w (wef y)) (fun y : Word => inmonoid E y) *) intros x_ant x_egal dans_x_ant. (* Goal: @ex2 Word (fun y : Word => @eq Word (cons x w) (wef y)) (fun y : Word => inmonoid E y) *) (* Goal: @ex2 Elt (fun x_ant : Elt => @eq Elt x (f x_ant)) (fun x_ant : Elt => dans x_ant E) *) (* Goal: @ex2 Word (fun y : Word => @eq Word w (wef y)) (fun y : Word => inmonoid E y) *) exists (cons x_ant y1). (* Goal: @eq Word (cons x w) (wef (cons x_ant y1)) *) (* Goal: inmonoid E (cons x_ant y1) *) (* Goal: @ex2 Elt (fun x_ant : Elt => @eq Elt x (f x_ant)) (fun x_ant : Elt => dans x_ant E) *) (* Goal: @ex2 Word (fun y : Word => @eq Word w (wef y)) (fun y : Word => inmonoid E y) *) unfold wef, Word_ext in |- *. (* Goal: eg_f_W_W (Word_ext (comp invf' f)) (comp_word (Word_ext invf') (Word_ext f)) *) auto. (* Goal: eg_f_W_W (Word_ext (comp invf' f)) (comp_word (Word_ext invf') (Word_ext f)) *) auto. (* inmonoid_cons *) (*Cut2*) (* Goal: @ex2 Elt (fun x_ant : Elt => @eq Elt x (f x_ant)) (fun x_ant : Elt => dans x_ant E) *) (* Goal: @ex2 Word (fun y : Word => @eq Word w (wef y)) (fun y : Word => inmonoid E y) *) prolog [ inmonoid_cons_inv2 ] 3. (*Apply is_epi_f. Apply inmonoid_cons_inv2 with w; Assumption.*) (*Cut1*) (* Goal: @ex2 Word (fun y : Word => @eq Word w (wef y)) (fun y : Word => inmonoid E y) *) prolog [ inmonoid_cons_inv ] 3. (*Apply Hyp; Apply inmonoid_cons_inv with x; Assumption.*) Qed. Hint Resolve is_epi_f_imp_is_epi_words. Lemma is_iso_f_imp_is_iso_words : is_iso E F f -> is_iso_words E F wef. (* Goal: forall _ : is_iso E F f, Id_words E weinvf_wef *) intro is_iso_f. (* Goal: forall (_ : @eq Elt (f e) (f x0)) (_ : @eq Word (wef r) (wef w0)), @eq Word (cons x0 w0) y *) (* Goal: @ex Elt (fun x : Elt => @ex2 Word (fun w : Word => @eq Word (cons x w) y) (fun w : Word => and (@eq Elt (f x) (f x0)) (@eq Word (wef w) (wef w0)))) *) elim is_iso_f; intros. (* Goal: eg_f_W_W (Word_ext (comp invf' f)) (comp_word (Word_ext invf') (Word_ext f)) *) split; auto. Qed. Let invf' := inv E F f. Let weinvf := Word_ext invf'. Let weinvf_wef := comp_word weinvf wef. Lemma is_iso_f_imp_Id_words_weinvf_wef : is_iso E F f -> Id_words E weinvf_wef. (* Goal: forall _ : is_iso E F f, Id_words E weinvf_wef *) intro is_iso_f. (* Goal: Id_words E weinvf_wef *) red in |- *. (* Goal: forall (x : Word) (_ : inmonoid E x), @eq Word (weinvf_wef x) x *) intro x. (* Goal: forall _ : inmonoid E x, @eq Word (weinvf_wef x) x *) unfold weinvf_wef, weinvf, wef in |- *. cut (eg_f_W_W (Word_ext (comp invf' f)) (comp_word (Word_ext invf') (Word_ext f))). (* Goal: forall (_ : eg_f_W_W (Word_ext (comp invf' f)) (comp_word (Word_ext invf') (Word_ext f))) (_ : inmonoid E x), @eq Word (comp_word (Word_ext invf') (Word_ext f) x) x *) (* Goal: eg_f_W_W (Word_ext (comp invf' f)) (comp_word (Word_ext invf') (Word_ext f)) *) unfold eg_f_W_W in |- *. (* Goal: forall (_ : forall x : Word, @eq Word (Word_ext (comp invf' f) x) (comp_word (Word_ext invf') (Word_ext f) x)) (_ : inmonoid E x), @eq Word (comp_word (Word_ext invf') (Word_ext f) x) x *) (* Goal: eg_f_W_W (Word_ext (comp invf' f)) (comp_word (Word_ext invf') (Word_ext f)) *) intro Hyp. (* Goal: forall _ : inmonoid E x, @eq Word (comp_word (Word_ext invf') (Word_ext f) x) x *) (* Goal: eg_f_W_W (Word_ext (comp invf' f)) (comp_word (Word_ext invf') (Word_ext f)) *) rewrite <- (Hyp x). (* Goal: forall _ : inmonoid E x, @eq Word (Word_ext (comp invf' f) x) x *) (* Goal: eg_f_W_W (Word_ext (comp invf' f)) (comp_word (Word_ext invf') (Word_ext f)) *) generalize x. (* Goal: forall (x : Word) (_ : inmonoid E x), @eq Word (Word_ext (comp invf' f) x) x *) (* Goal: eg_f_W_W (Word_ext (comp invf' f)) (comp_word (Word_ext invf') (Word_ext f)) *) change (Id_words E (Word_ext (comp invf' f))) in |- *. (* Goal: Id_words E (Word_ext (comp invf' f)) *) (* Goal: eg_f_W_W (Word_ext (comp invf' f)) (comp_word (Word_ext invf') (Word_ext f)) *) apply extension_Id. (* Goal: Id E (comp invf' f) *) (* Goal: eg_f_W_W (Word_ext (comp invf' f)) (comp_word (Word_ext invf') (Word_ext f)) *) unfold invf' in |- *. (* Goal: eg_f_W_W (Word_ext (comp invf' f)) (comp_word (Word_ext invf') (Word_ext f)) *) auto. (*Cut*) (* Goal: eg_f_W_W (Word_ext (comp invf' f)) (comp_word (Word_ext invf') (Word_ext f)) *) auto. Qed. End fonctions2. Hint Resolve mono_imp_iso_over_image.
(* This program is free software; you can redistribute it and/or *) (* modify it under the terms of the GNU Lesser General Public License *) (* as published by the Free Software Foundation; either version 2.1 *) (* of the License, or (at your option) any later version. *) (* *) (* This program is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* GNU General Public License for more details. *) (* *) (* You should have received a copy of the GNU Lesser General Public *) (* License along with this program; if not, write to the Free *) (* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *) (* 02110-1301 USA *) (* Contribution to the Coq Library V6.3 (July 1999) *) (****************************************************************************) (* The Calculus of Inductive Constructions *) (* *) (* Projet Coq *) (* *) (* INRIA ENS-CNRS *) (* Rocquencourt Lyon *) (* *) (* Coq V5.10 *) (* Nov 25th 1994 *) (* *) (****************************************************************************) (* Ensf_dans.v *) (****************************************************************************) (* Formal Language Theory *) (* *) (* Judicael Courant - Jean-Christophe Filliatre *) (* *) (* Developped in V5.8 June-July 1993 *) (* Ported to V5.10 October 1994 *) (****************************************************************************) Require Import Ensf_types. (* *) (* APPARTENANCE : *) (* On definit le predicat (dans x E) pour un element x et un *) (* ensemble E. *) (* *) Inductive dans : Elt -> Ensf -> Prop := | dans_add1 : forall (x : Elt) (e : Ensf), dans x (add x e) | dans_add2 : forall (x y : Elt) (e : Ensf), dans x e -> dans x (add y e). Hint Resolve dans_add1 dans_add2. (* Quelques resultats concernant l'appartenance... *) Lemma dans_add : forall (x y : Elt) (e : Ensf), dans x (add y e) -> y = x \/ dans x e. (* Goal: forall (x y : Elt) (e : Ensf) (_ : dans x (add y e)), or (@eq Elt y x) (dans x e) *) intros x y e H. (* Goal: @eq Elt x e *) simple inversion H. (* Goal: or (@eq Elt y x) (dans x e) *) (* Goal: forall _ : dans x0 e0, or (@eq Elt y x) (dans x e) *) left. (* Goal: @eq Elt y x *) (* Goal: forall _ : dans x0 e0, or (@eq Elt y x) (dans x e) *) injection H1. (* Goal: forall (x : Elt) (P : Prop) (_ : dans x empty), P *) intros. (* Goal: @eq Elt y x *) (* Goal: forall _ : dans x0 e0, or (@eq Elt y x) (dans x e) *) apply trans_equal with x0; [ auto | assumption ]. (* Goal: forall _ : dans x0 e0, or (@eq Elt y x) (dans x e) *) intro. (* Goal: or (@eq Elt y x) (dans x e) *) right. (* Goal: dans x e *) injection H2. (* Goal: forall (x : Elt) (P : Prop) (_ : dans x empty), P *) intros. (* Goal: dans x e *) rewrite <- H3. (* Goal: dans x e0 *) rewrite <- H1. (* Goal: dans x0 e0 *) assumption. Qed. Lemma dans_add_contr : forall (x y : Elt) (e : Ensf), y <> x -> ~ dans x e -> ~ dans x (add y e). (* Goal: forall _ : dans x0 e0, or (@eq Elt y x) (dans x e) *) intros; red in |- *; intro. absurd (y = x \/ dans x e). 2: apply dans_add; auto. red in |- *. (* Goal: forall _ : dans x0 e0, or (@eq Elt y x) (dans x e) *) intro. elim H2; auto. Qed. Lemma empty_empty : forall E : Elt, ~ dans E empty. (* Goal: forall E : Elt, not (dans E empty) *) unfold not in |- *; intros E H. (* Goal: False *) simple inversion H; [ discriminate H1 | discriminate H2 ]. Qed. Hint Resolve empty_empty. Lemma dans_empty_imp_P : forall (x : Elt) (P : Prop), dans x empty -> P. (* Goal: forall (x : Elt) (P : Prop) (_ : dans x empty), P *) intros. (* Goal: P *) elimtype False. (* Goal: False *) cut (~ dans x empty); auto. Qed. Lemma singl2 : forall x : Elt, dans x (singleton x). (* Goal: forall (x e : Elt) (_ : dans x (singleton e)), @eq Elt x e *) unfold singleton in |- *. (* Goal: forall x : Elt, dans x (add x empty) *) auto. Qed. Hint Resolve singl2. Unset Structural Injection. Lemma singl2_inv : forall x e : Elt, dans x (singleton e) -> x = e :>Elt. (* Goal: forall (x e : Elt) (_ : dans x (singleton e)), @eq Elt x e *) unfold singleton in |- *. (* Goal: forall (x e : Elt) (_ : dans x (add e empty)), @eq Elt x e *) intros x e H. (* Goal: @eq Elt x e *) simple inversion H. (* Goal: forall (x : Elt) (P : Prop) (_ : dans x empty), P *) injection H1; intros. (* Goal: dans x0 e0 *) rewrite <- H0; assumption. (* Goal: forall (x : Elt) (P : Prop) (_ : dans x empty), P *) injection H2; intros. (* Goal: @eq Elt x e *) apply dans_empty_imp_P with x0. (* Goal: dans x0 e0 *) rewrite <- H0; assumption. Qed. Hint Resolve singl2_inv.
(* This program is free software; you can redistribute it and/or *) (* modify it under the terms of the GNU Lesser General Public License *) (* as published by the Free Software Foundation; either version 2.1 *) (* of the License, or (at your option) any later version. *) (* *) (* This program is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* GNU General Public License for more details. *) (* *) (* You should have received a copy of the GNU Lesser General Public *) (* License along with this program; if not, write to the Free *) (* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *) (* 02110-1301 USA *) (* Contribution to the Coq Library V6.3 (July 1999) *) (****************************************************************************) (* The Calculus of Inductive Constructions *) (* *) (* Projet Coq *) (* *) (* INRIA ENS-CNRS *) (* Rocquencourt Lyon *) (* *) (* Coq V5.10 *) (* Nov 25th 1994 *) (* *) (****************************************************************************) (* RatReg.v *) (****************************************************************************) (* Formal Language Theory *) (* *) (* Judicael Courant - Jean-Christophe Filliatre *) (* *) (* Developped in V5.8 June-July 1993 *) (* Ported to V5.10 October 1994 *) (****************************************************************************) Require Import Ensf. Require Import Max. Require Import Words. Require Import Dec. Require Import Reg. Require Import Rat. (************************************************************************) (* *) (* Un langage reduit a un mot est regulier. *) (* *) (************************************************************************) (* Le mot vide est reconnu par un automate reduit a un etat (zero) *) (* et sans transition. *) Lemma lwordnil_is_reg1 : reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) nil. (* Goal: reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) nil *) unfold reconnait at 1 in |- *. (* Goal: and (automate_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (eqwordset (reconnait_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (lconc l1 l2)) *) split. (* Goal: inmonoid alph nil *) (* Goal: @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 (singleton zero)) (and (dans e2 (singleton zero)) (chemin e1 e2 (singleton zero) (prodcart empty (prodcart alph empty)) nil)))) *) apply inmonoid_nil. (* Goal: @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 (singleton zero)) (and (dans e2 (singleton zero)) (chemin e1 e2 (singleton zero) (prodcart empty (prodcart alph empty)) nil)))) *) exists zero; exists zero. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) auto. Qed. (* Seul le mot vide est reconnu par l'automate ci-dessus. *) Lemma lwordnil_is_reg2 : forall w : Word, reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w -> w = nil :>Word. (* Goal: reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) nil *) unfold reconnait at 1 in |- *. (* Goal: forall (w : Word) (e0 e1 e2 e3 a : Elt) (q d : Ensf) (_ : chemin e1 e2 q d w), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) w *) simple induction w. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) auto. intros x w0 H H0. clear H. elim H0; intros; clear H0. elim H1; intros; clear H1. elim H0; intros; clear H0. elim H1; intros; clear H1. elim H2; intros; clear H2. cut (Chemin x0 x1 (singleton zero) (prodcart empty (prodcart alph empty)) (cons x w0)). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: auto. unfold Chemin in |- *; simpl in |- *. intro H2. absurd (dans x0 empty). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) auto. elim H2; intros; clear H2. elim H4; intros; clear H4. elim H5; intros; clear H5. elim H6; intros; clear H6. cut (dans x0 empty /\ dans (couple x x2) (prodcart alph empty)). 2: apply coupl2; assumption. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) tauto. Qed. (* *) (* Pour pouvoir construire un automate qui reconnait (cons a w) a *) (* partir d'un automate qui reconnait w, il faut un resultat un peu *) (* plus precis que "il existe un automate tel que...". *) (* *) (* On precise que cet automate a un unique etat de depart. *) (* *) Lemma lwordnil_is_regS : exists q : Ensf, (exists e : Elt, (exists qa : Ensf, (exists d : Ensf, automate q (singleton e) qa d /\ eqwordset (reconnait q (singleton e) qa d) (lword nil)))). (* Goal: @ex Ensf (fun qa : Ensf => @ex Ensf (fun d : Ensf => and (automate (singleton zero) (singleton zero) qa d) (eqwordset (reconnait (singleton zero) (singleton zero) qa d) (lword nil)))) *) exists (singleton zero). (* Goal: @ex Elt (fun e : Elt => @ex Ensf (fun qa : Ensf => @ex Ensf (fun d : Ensf => and (automate (singleton zero) (singleton e) qa d) (eqwordset (reconnait (singleton zero) (singleton e) qa d) (lword nil))))) *) exists zero. (* Goal: @ex Ensf (fun qa : Ensf => @ex Ensf (fun d : Ensf => and (automate (singleton zero) (singleton zero) qa d) (eqwordset (reconnait (singleton zero) (singleton zero) qa d) (lword nil)))) *) exists (singleton zero). (* Goal: @ex Ensf (fun d : Ensf => and (automate (singleton zero) (singleton zero) (singleton zero) d) (eqwordset (reconnait (singleton zero) (singleton zero) (singleton zero) d) (lword nil))) *) exists (prodcart empty (prodcart alph empty)). (* Goal: and (automate_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (eqwordset (reconnait_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (lconc l1 l2)) *) split. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) red in |- *; auto. (* Goal: and (automate_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (eqwordset (reconnait_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (lconc l1 l2)) *) red in |- *; split. (* Goal: automate (union_disj q1 q2) (union_disj qd1 qd2) (union_disj qa1 qa2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)) *) (* Goal: eqwordset (reconnait (union_disj q1 q2) (union_disj qd1 qd2) (union_disj qa1 qa2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) (lunion l1 l2) *) red in |- *. symmetry in |- *; apply lwordnil_is_reg2. (* Goal: reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) (* Goal: forall _ : lword nil w, reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) assumption. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. (* Goal: reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) compute in H. (* Goal: reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) rewrite <- H. (* Goal: reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) nil *) apply lwordnil_is_reg1. Qed. (* D'ou bien sur... *) Lemma lwordnil_is_reg : isregular (lword nil). cut (exists q : Ensf, (exists e : Elt, (exists qa : Ensf, (exists d : Ensf, automate q (singleton e) qa d /\ eqwordset (reconnait q (singleton e) qa d) (lword nil))))). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply lwordnil_is_regS; auto. intro H; elim H; clear H. intros q H; elim H; clear H. intros e H; elim H; clear H. intros qa H; elim H; clear H. intros d H; elim H; clear H. (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intros. (* Goal: automate (union_disj q1 q2) (union_disj qd1 qd2) (union_disj qa1 qa2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)) *) (* Goal: eqwordset (reconnait (union_disj q1 q2) (union_disj qd1 qd2) (union_disj qa1 qa2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) (lunion l1 l2) *) red in |- *. exists q. exists (singleton e). exists qa. exists d. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) auto. Qed. (* Le gros morceau... *) (* On commence par montrer que si on a un chemin pour w alors on *) (* toujours ce chemin en rajoutant un etat et une transition. *) Lemma extension_qd : forall (w : Word) (e0 e1 e2 e3 a : Elt) (q d : Ensf), chemin e1 e2 q d w -> chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) w. (* Goal: forall (w : Word) (e0 e1 e2 e3 a : Elt) (q d : Ensf) (_ : chemin e1 e2 q d w), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) w *) simple induction w. (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intros. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) cut (Chemin e1 e2 q d nil); auto. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) cut (dans e1 q /\ e1 = e2 :>Elt); auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) intro H1; elim H1; auto. (* Goal: forall (e : Elt) (w : Word) (_ : forall (e0 e1 e2 e3 a : Elt) (q d : Ensf) (_ : chemin e1 e2 q d w), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) w) (e0 e1 e2 e3 a : Elt) (q d : Ensf) (_ : chemin e1 e2 q d (cons e w)), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons e w) *) intros x w0 H e0 e1 e2 e3 a q d H0. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) cut (Chemin e1 e2 q d (cons x w0)); auto. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. cut (exists e : Elt, chemin e e2 q d w0 /\ dans e1 q /\ dans x alph /\ dans (couple e1 (couple x e)) d); (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) auto. (* Goal: forall _ : @ex Elt (fun e : Elt => and (chemin e e2 q d w0) (and (dans e1 q) (and (dans x alph) (dans (couple e1 (couple x e)) d)))), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro H2; elim H2; clear H2. (* Goal: forall (x0 : Elt) (_ : and (chemin x0 e2 q d w0) (and (dans e1 q) (and (dans x alph) (dans (couple e1 (couple x x0)) d)))), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intros e H2; elim H2; clear H2. (* Goal: forall (_ : chemin e e2 q d w0) (_ : and (dans e1 q) (and (dans x alph) (dans (couple e1 (couple x e)) d))), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intros H2 H3; elim H3; clear H3. (* Goal: forall (_ : dans e1 q) (_ : and (dans x alph) (dans (couple e1 (couple x e)) d)), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intros H3 H4; elim H4; clear H4. (* Goal: forall (_ : dans x alph) (_ : dans (couple e1 (couple x e)) d), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intros H4 H5. apply (chemin_cons e e2 (add e0 q) (add (couple e0 (couple a e3)) d) w0 e1 x); (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) auto. Qed. (* Si un automate reconnait un mot w sans utiliser l'etat e0 alors *) (* l'automate obtenu en supprimant cet etat ainsi que la transition *) (* correspondante reconnait toujours w. *) Lemma restriction_aut : forall (w : Word) (e0 e e2 e3 a : Elt) (q d : Ensf), ~ dans e0 q -> dans e q -> inclus d (prodcart q (prodcart alph q)) -> chemin e e2 (add e0 q) (add (couple e0 (couple a e3)) d) w -> chemin e e2 q d w. (* Goal: forall (w : Word) (e0 e1 e2 e3 a : Elt) (q d : Ensf) (_ : chemin e1 e2 q d w), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) w *) simple induction w. (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intros. cut (Chemin e e2 (add e0 q) (add (couple e0 (couple a e3)) d) nil); (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) auto. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) cut (dans e (add e0 q) /\ e = e2 :>Elt); auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) intro H4; elim H4; auto. intros x w0 H e0 e e2 e3 a q d H0 H1 H2 H3. cut (Chemin e e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0)); (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) auto. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. cut (exists e12 : Elt, chemin e12 e2 (add e0 q) (add (couple e0 (couple a e3)) d) w0 /\ dans e (add e0 q) /\ dans x alph /\ dans (couple e (couple x e12)) (add (couple e0 (couple a e3)) d)); (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) auto. intro H5; elim H5; clear H5. intros e12 H5; elim H5; clear H5. intros H5 H6; elim H6; clear H6. intros H6 H7; elim H7; clear H7. intros H7 H8. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply (chemin_cons e12 e2 q d w0 e x); auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply (H e0 e12 e2 e3 a q d); auto. cut (couple e0 (couple a e3) = couple e (couple x e12) :>Elt \/ dans (couple e (couple x e12)) d). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply dans_add; auto. intro H9; elim H9; clear H9. intro H9; injection H9 as H12 H11 H10. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) absurd (dans e0 q); auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) rewrite H12; auto. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. cut (dans (couple e (couple x e12)) (prodcart q (prodcart alph q))). 2: apply (dans_trans (couple e (couple x e12)) d (prodcart q (prodcart alph q))); (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) auto. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) cut (dans e q /\ dans (couple x e12) (prodcart alph q)); auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply coupl2; auto. intro H11; elim H11; clear H11. (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intros. cut (dans x alph /\ dans e12 q). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply coupl2; auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) tauto. cut (couple e0 (couple a e3) = couple e (couple x e12) :>Elt \/ dans (couple e (couple x e12)) d). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply dans_add; auto. intro H9; elim H9; clear H9. intro H9; injection H9 as H12 H11 H10. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) absurd (dans e0 q); auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) rewrite H12; auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) auto. Qed. (* Si un automate reconnait w alors en lui rajoutant un etat e0 *) (* et la bonne trnasition il reconnait (cons a w). *) Lemma extension_aut : forall (w : Word) (e0 e a : Elt) (q qa d : Ensf), reconnait q (singleton e) qa d w -> ~ dans e0 q -> dans a alph -> reconnait (add e0 q) (singleton e0) qa (add (couple e0 (couple a e)) d) (cons a w). (* Goal: forall (w : Word) (e0 e a : Elt) (q qa d : Ensf) (_ : reconnait q (singleton e) qa d w) (_ : not (dans e0 q)) (_ : dans a alph), reconnait (add e0 q) (singleton e0) qa (add (couple e0 (couple a e)) d) (cons a w) *) unfold reconnait in |- *. (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intros. elim H; clear H. (* Goal: forall (_ : inmonoid alph w) (_ : @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 (singleton e)) (and (dans e2 qa) (chemin e1 e2 q d w))))), and (inmonoid alph (cons a w)) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 (singleton e0)) (and (dans e2 qa) (chemin e1 e2 (add e0 q) (add (couple e0 (couple a e)) d) (cons a w)))))) *) intros H H2; elim H2; clear H2. (* Goal: forall (x : Elt) (_ : @ex Elt (fun e2 : Elt => and (dans x (singleton e)) (and (dans e2 qa) (chemin x e2 q d w)))), and (inmonoid alph (cons a w)) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 (singleton e0)) (and (dans e2 qa) (chemin e1 e2 (add e0 q) (add (couple e0 (couple a e)) d) (cons a w)))))) *) intros e12 H2; elim H2; clear H2. (* Goal: forall (x : Elt) (_ : and (dans e12 (singleton e)) (and (dans x qa) (chemin e12 x q d w))), and (inmonoid alph (cons a w)) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 (singleton e0)) (and (dans e2 qa) (chemin e1 e2 (add e0 q) (add (couple e0 (couple a e)) d) (cons a w)))))) *) intros e2 H2; elim H2; clear H2. (* Goal: forall (_ : dans e12 (singleton e)) (_ : and (dans e2 qa) (chemin e12 e2 q d w)), and (inmonoid alph (cons a w)) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 (singleton e0)) (and (dans e2 qa) (chemin e1 e2 (add e0 q) (add (couple e0 (couple a e)) d) (cons a w)))))) *) intros H2 H3. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) split; auto. (* Goal: @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 (singleton e0)) (and (dans e2 qa) (chemin e1 e2 (add e0 q) (add (couple e0 (couple a e)) d) (cons a w))))) *) exists e0. (* Goal: @ex Elt (fun e2 : Elt => and (dans e0 (singleton e0)) (and (dans e2 qa) (chemin e0 e2 (add e0 q) (add (couple e0 (couple a e)) d) (cons a w)))) *) exists e2. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) split; auto. (* Goal: and (dans e2 qa) (chemin e0 e2 (add e0 q) (add (couple e0 (couple a e)) d) (cons a w)) *) elim H3; clear H3; intros H3 H4. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) split; auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) cut (e12 = e :>Elt); auto. (* Goal: forall _ : @eq Elt e12 e, chemin e0 e2 (add e0 q) (add (couple e0 (couple a e)) d) (cons a w) *) intro H5; rewrite <- H5. apply (chemin_cons e12 e2 (add e0 q) (add (couple e0 (couple a e12)) d) w e0 a); (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply extension_qd; auto. Qed. (* *) (* Si un automate (q (singleton e) qa d) reconnait exactement {w0} *) (* et si e0 n'est pas dans q alors l'automate ((add e0 q) *) (* (singleton e0) qa (add (e0,a,e) d)) reconnait exactement *) (* {cons a w0}. *) (* *) Axiom auto_cons : forall (q qa d : Ensf) (e0 e a : Elt) (w0 : Word), dans a alph -> automate q (singleton e) qa d -> eqwordset (reconnait q (singleton e) qa d) (lword w0) -> ~ dans e0 q -> eqwordset (reconnait (add e0 q) (singleton e0) qa (add (couple e0 (couple a e)) d)) (lword (cons a w0)). (*--- Cette preuve est correcte mais tres longue : on laisse l'axiome... PASSER CETTE PREUVE EN V5.10 Lemma auto_cons : (q,qa,d:Ensf)(e0,e,a:Elt)(w0:Word) (dans a alph) -> (automate q (singleton e) qa d) -> (eqwordset (reconnait q (singleton e) qa d) (lword w0) ) -> ~(dans e0 q) -> (eqwordset (reconnait (add e0 q) (singleton e0) qa (add (couple e0 (couple a e)) d) ) (lword (cons a w0)) ). Goal. Unfold eqwordset. Unfold lword. Intros q qa d e0 e a w0 dans_a_alph H H0 H1 w; Pattern w; Apply induction_word. Split. Intro. Elim H2; Clear H2. Intros H2 H3; Elim H3; Clear H3. Intros e1 H3; Elim H3; Clear H3. Intros e2 H3; Elim H3; Clear H3. Intros H3 H4; Elim H4; Clear H4. Intros. Cut <Elt>e1=e0; Auto. Intro. Elim H. Intros H7 H8. Cut <Elt>e1=e2. 2:Cut (Chemin e1 e2 (add e0 q) (add (couple e0 (couple a e)) d) nil); Auto. 2:Intro; Cut ( (dans e1 (add e0 q)) /\ (<Elt>e1=e2) ); Auto. 2:Intro H10; Elim H10; Auto. Intro H9. Cut (dans e2 q). 2:Apply (dans_trans e2 qa q); Auto. Intro H10. Absurd (dans e0 q); Auto. Rewrite <- H6. Rewrite H9. Assumption. Intro. Cut False. Apply False_imp_P. Apply (diff_cons_nil a w0); Auto. Apply (diff_cons_nil a w0); Auto. Intros. Split. Intro H3; Elim H3; Clear H3. Intros H3 H4; Elim H4; Clear H4. Intros e1 H4; Elim H4; Clear H4. Intros e2 H4; Elim H4; Clear H4. Intros H4 H5; Elim H5; Clear H5. Intros H5 H6. Cut (Chemin e1 e2 (add e0 q) (add (couple e0 (couple a e)) d) (cons x w1)); Auto. Intro H7; Elim H7; Clear H7. Intros e12 H7; Elim H7; Clear H7. Intros H7 H8; Elim H8; Clear H8. Intros H8 H9; Elim H9; Clear H9. Intros H9 H10. Cut <Elt>e1=e0; Auto. Intro H11; Clear H4. Cut (inclus d (prodcart q (prodcart alph q))). 2:Apply (automate_def1 q (singleton e) qa d); Auto. Intro H12. Cut (<Elt>(couple e0 (couple a e))=(couple e1 (couple x e12)) \/ (dans (couple e1 (couple x e12)) d)). 2:Apply dans_add; Auto. Intro H4; Elim H4; Clear H4. Intro. Cut <Elt>a=x. Intro. 2:Cut <Elt>(couple a e)=(couple x e12). 2:Intro. 2:Replace a with (first (couple a e)); Auto. 2:Replace x with (first (couple x e12)); Auto. 2:Apply (f_equal Elt Elt); Auto. 2:Replace (couple a e) with (second (couple e0 (couple a e))); Auto. 2:Replace (couple x e12) with (second (couple e1 (couple x e12))); Auto. 2:Apply (f_equal Elt Elt); Auto. Apply cons_cons; Auto. 2:Intro. 2:Absurd (dans e0 q); Auto. 2:Cut (dans (couple e1 (couple x e12)) (prodcart q (prodcart alph q))). 2:Intro. 3:Apply (dans_trans (couple e1 (couple x e12)) d); Auto. 2:Cut (dans e1 q). 2:Rewrite H11; Auto. 2:Cut ( (dans e1 q) /\ (dans (couple x e12) (prodcart alph q))); Auto. 2:Intro H14; Elim H14; Clear H14. 2:Auto. 2:Apply coupl2; Auto. Cut <Elt>e12=e. 2:Replace e12 with (second (second (couple e1 (couple x e12)))); Auto. 2:Replace e with (second (second (couple e0 (couple a e)))); Auto. 2:Apply (f_equal Elt Elt). 2:Apply (f_equal Elt Elt); Auto. Intro. Cut (chemin e e2 (add e0 q) (add (couple e0 (couple a e)) d) w1). 2:Cut (chemin e12 e2 (add e0 q) (add (couple e0 (couple a e)) d) w1); Auto. 2:Rewrite H14; Auto. Clear H7; Intro H7. Cut (reconnait q (singleton e) qa d w1). Elim (H0 w1). Auto. Unfold reconnait. Split. Apply (inmonoid_cons_inv alph w1 x); Auto. Exists e. Exists e2. Split; Auto. Split; Auto. Apply (restriction_aut w1 e0 e e2 e a q d ); Auto. Cut (inclus (singleton e) q). Intro; Apply inclus_singl; Auto. Apply (automate_def2 q (singleton e) qa d); Auto. Intro H3. Cut ((<Elt>a=x)/\(<Word>w0=w1)). 2:Apply cons_cons_inv; Auto. Intro H4; Elim H4; Clear H4. Intros. Rewrite <- H4. Rewrite <- H5. Apply extension_aut; Auto. Elim (H0 w0). Auto. Save. ----*) (* *) (* Un langage reduit a un seul mot est regulier. *) (* A partir d'un automate qui reconnait {w} on rajoute un nouvel etat *) (* (en utilisant le lemme exist_other) et la relation adequate *) (* pour construire un automate reconnaissant {cons a w}. *) (* *) Lemma lword_is_regS : forall w : Word, inmonoid alph w -> exists q : Ensf, (exists e : Elt, (exists qa : Ensf, (exists d : Ensf, automate q (singleton e) qa d /\ eqwordset (reconnait q (singleton e) qa d) (lword w)))). (* Goal: forall (w : Word) (e0 e1 e2 e3 a : Elt) (q d : Ensf) (_ : chemin e1 e2 q d w), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) w *) simple induction w. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. apply lwordnil_is_regS. intros a w0 H H4. cut (inmonoid alph w0). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply (inmonoid_cons_inv alph w0 a); auto. intro H5. cut (exists q : Ensf, (exists e : Elt, (exists qa : Ensf, (exists d : Ensf, automate q (singleton e) qa d /\ eqwordset (reconnait q (singleton e) qa d) (lword w0))))); (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) auto. clear H; intro H; elim H; clear H. intros q H0; elim H0; clear H0. intros e H0; elim H0; clear H0. intros qa H0; elim H0; clear H0. intros d H0; elim H0; clear H0. (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intros. cut (exists e0 : Elt, ~ dans e0 q). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply exist_other; auto. (* Goal: forall _ : @ex Elt (fun e : Elt => and (chemin e e2 q d w0) (and (dans e1 q) (and (dans x alph) (dans (couple e1 (couple x e)) d)))), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro H2; elim H2; clear H2. intros e0 H2. exists (add e0 q). (* Goal: @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 (singleton e0)) (and (dans e2 qa) (chemin e1 e2 (add e0 q) (add (couple e0 (couple a e)) d) (cons a w))))) *) exists e0. exists qa. exists (add (couple e0 (couple a e)) d). elim H; clear H. intros H H1. (* Goal: @ex Ensf (fun q : Ensf => @ex Ensf (fun qd : Ensf => @ex Ensf (fun qa : Ensf => @ex Ensf (fun d : Ensf => and (automate q qd qa d) (eqwordset (reconnait q qd qa d) (lunion l1 l2)))))) *) elim H1; clear H1. (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intros. (* Goal: and (automate_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (eqwordset (reconnait_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (lconc l1 l2)) *) split. (* Goal: automate (union_disj q1 q2) (union_disj qd1 qd2) (union_disj qa1 qa2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)) *) (* Goal: eqwordset (reconnait (union_disj q1 q2) (union_disj qd1 qd2) (union_disj qa1 qa2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) (lunion l1 l2) *) red in |- *. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) split; auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) split; auto. apply add_inclus. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply coupl2_inv; auto. (* Goal: dans (couple (couple e1 zero) (couple x (couple e zero))) (prodcart (map injgauche q1) (prodcart alph (map injgauche q1))) *) apply coupl2_inv. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply (inmonoid_cons_inv2 alph a w0); auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) cut (dans e q); auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply (inclus_trans d (prodcart q (prodcart alph q))); auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply auto_cons; auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply (inmonoid_cons_inv2 alph a w0); auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) unfold automate in |- *; auto. Qed. (* *) (* Finalement, on montre qu'un langage reduit a un mot est regulier : *) (* *) Lemma lword_is_reg : forall w : Word, inmonoid alph w -> isregular (lword w). (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lunion l1 l2) *) unfold isregular in |- *. (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intros. cut (exists q : Ensf, (exists e : Elt, (exists qa : Ensf, (exists d : Ensf, automate q (singleton e) qa d /\ eqwordset (reconnait q (singleton e) qa d) (lword w))))). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply lword_is_regS; auto. intro H0; elim H0; clear H0. intros q H0; elim H0; clear H0. intros e H0; elim H0; clear H0. intros qa H0; elim H0; clear H0. intros d H0; elim H0; clear H0. intros H0 H1. exists q. exists (singleton e). exists qa. exists d. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) auto. Qed. (************************************************************************) (* *) (* L'union de 2 langages reguliers est un langage regulier. *) (* *) (************************************************************************) (* *) (* A partir d'une relation d1 (partie de q1 x alph x q1) on construit *) (* la relation d1', qui est la meme relation, mais pour les etats *) (* (e,zero) au lieu de e. *) (* De meme pour une relation d2 avec e -> (e,un). *) (* *) Definition est_dans_d'_2 (d : Ensf) (e y : Elt) : Prop := match y return Prop with | natural n => (* natural *) False (* couple *) | couple a e' => dans (couple (first e) (couple a (first e'))) d (* up *) | up e => False (* word *) | word w => False end. Definition est_dans_d' (d1 : Ensf) (x : Elt) : Prop := match x return Prop with | natural n => (* natural *) False (* couple *) | couple e y => est_dans_d'_2 d1 e y (* up *) | up e => False (* word *) | word w => False end. Definition injg_d1 (q1 d1 : Ensf) : Ensf := tq (est_dans_d' d1) (prodcart (map injgauche q1) (prodcart alph (map injgauche q1))). Definition injd_d2 (q2 d2 : Ensf) : Ensf := tq (est_dans_d' d2) (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))). Lemma d_is_good : forall q1 q2 d1 d2 : Ensf, inclus (union (injg_d1 q1 d1) (injd_d2 q2 d2)) (prodcart (union_disj q1 q2) (prodcart alph (union_disj q1 q2))). (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intros. (* Goal: inclus (union (injg_d1 q1 d1) (injd_d2 q2 d2)) (prodcart (union_disj q1 q2) (prodcart alph (union_disj q1 q2))) *) apply union_inclus. apply inclus_trans with (prodcart (map injgauche q1) (prodcart alph (map injgauche q1))). (* Goal: dans (couple (couple e1 zero) (couple x (couple e zero))) (injg_d1 q1 d1) *) unfold injg_d1 in |- *. (* Goal: inclus (tq (est_dans_d' d2) (prodcart (map injdroite q2) (prodcart alph (map injdroite q2)))) (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) *) (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union_disj q1 q2) (prodcart alph (union_disj q1 q2))) *) apply inclus_tq. (* Goal: dans (couple e1 zero) (union_disj q1 q2) *) (* Goal: dans (couple (couple e1 zero) (couple x (couple e zero))) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) *) unfold union_disj in |- *. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) auto. apply inclus_trans with (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))). (* Goal: inclus (injd_d2 q2 d2) (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) *) (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union_disj q1 q2) (prodcart alph (union_disj q1 q2))) *) unfold injd_d2 in |- *. (* Goal: inclus (tq (est_dans_d' d2) (prodcart (map injdroite q2) (prodcart alph (map injdroite q2)))) (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) *) (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union_disj q1 q2) (prodcart alph (union_disj q1 q2))) *) apply inclus_tq. (* Goal: dans (couple e1 zero) (union_disj q1 q2) *) (* Goal: dans (couple (couple e1 zero) (couple x (couple e zero))) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) *) unfold union_disj in |- *. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) auto. Qed. (* *) (* Deux petits lemmes sur la relation de transition construite *) (* ci-dessus. *) (* *) Lemma transition_dans_d1 : forall (q1 d1 q2 d2 : Ensf) (e1 x e : Elt), dans (couple e1 (couple x e)) (union (injg_d1 q1 d1) (injd_d2 q2 d2)) -> dans e1 (map injgauche q1) -> dans e (map injgauche q1). (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intros. cut (dans (couple e1 (couple x e)) (injg_d1 q1 d1) \/ (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) dans (couple e1 (couple x e)) (injd_d2 q2 d2)); auto. intro Ht; elim Ht; clear Ht. (* Goal: dans (couple (couple e1 zero) (couple x (couple e zero))) (injg_d1 q1 d1) *) unfold injg_d1 in |- *. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. cut (dans (couple e1 (couple x e)) (prodcart (map injgauche q1) (prodcart alph (map injgauche q1))) /\ est_dans_d' d1 (couple e1 (couple x e))). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply dans_tq_imp; auto. (* Goal: forall (_ : dans e12 (singleton e)) (_ : and (dans e2 qa) (chemin e12 e2 q d w)), and (inmonoid alph (cons a w)) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 (singleton e0)) (and (dans e2 qa) (chemin e1 e2 (add e0 q) (add (couple e0 (couple a e)) d) (cons a w)))))) *) intro Ht; elim Ht; clear Ht; intros H2 H3. cut (dans e1 (map injgauche q1) /\ dans (couple x e) (prodcart alph (map injgauche q1))). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply coupl2; auto. (* Goal: forall (_ : dans x alph) (_ : dans (couple e1 (couple x e)) d), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro Ht; elim Ht; clear Ht; intros H4 H5. cut (dans x alph /\ dans e (map injgauche q1)). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply coupl2; auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) intro Ht; elim Ht; clear Ht; auto. (* Goal: inclus (injd_d2 q2 d2) (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) *) (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union_disj q1 q2) (prodcart alph (union_disj q1 q2))) *) unfold injd_d2 in |- *. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. cut (dans (couple e1 (couple x e)) (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) /\ est_dans_d' d2 (couple e1 (couple x e))). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply dans_tq_imp; auto. (* Goal: forall (_ : dans e12 (singleton e)) (_ : and (dans e2 qa) (chemin e12 e2 q d w)), and (inmonoid alph (cons a w)) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 (singleton e0)) (and (dans e2 qa) (chemin e1 e2 (add e0 q) (add (couple e0 (couple a e)) d) (cons a w)))))) *) intro Ht; elim Ht; clear Ht; intros H2 H3. cut (dans e1 (map injdroite q2) /\ dans (couple x e) (prodcart alph (map injdroite q2))). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply coupl2; auto. (* Goal: forall (_ : dans x alph) (_ : dans (couple e1 (couple x e)) d), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro Ht; elim Ht; clear Ht; intros H4 H5. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) absurd (dans e1 (map injdroite q2)); auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply absurd_injg_injd with q1; auto. Qed. Lemma restriction_transition_d1 : forall (q1 d1 q2 d2 : Ensf) (e1 x e : Elt), dans (couple e1 (couple x e)) (union (injg_d1 q1 d1) (injd_d2 q2 d2)) -> dans e1 (map injgauche q1) -> dans (couple (first e1) (couple x (first e))) d1. (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intros. cut (dans (couple e1 (couple x e)) (injg_d1 q1 d1) \/ (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) dans (couple e1 (couple x e)) (injd_d2 q2 d2)); auto. intro Ht; elim Ht; clear Ht. (* Goal: dans (couple (couple e1 zero) (couple x (couple e zero))) (injg_d1 q1 d1) *) unfold injg_d1 in |- *. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. cut (dans (couple e1 (couple x e)) (prodcart (map injgauche q1) (prodcart alph (map injgauche q1))) /\ est_dans_d' d1 (couple e1 (couple x e))). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply dans_tq_imp; auto. (* Goal: forall (_ : dans e12 (singleton e)) (_ : and (dans e2 qa) (chemin e12 e2 q d w)), and (inmonoid alph (cons a w)) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 (singleton e0)) (and (dans e2 qa) (chemin e1 e2 (add e0 q) (add (couple e0 (couple a e)) d) (cons a w)))))) *) intro Ht; elim Ht; clear Ht; intros H2 H3. (* Goal: reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) (* Goal: forall _ : lword nil w, reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) assumption. (* Goal: inclus (injd_d2 q2 d2) (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) *) (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union_disj q1 q2) (prodcart alph (union_disj q1 q2))) *) unfold injd_d2 in |- *. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. cut (dans (couple e1 (couple x e)) (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) /\ est_dans_d' d2 (couple e1 (couple x e))). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply dans_tq_imp; auto. (* Goal: forall (_ : dans e12 (singleton e)) (_ : and (dans e2 qa) (chemin e12 e2 q d w)), and (inmonoid alph (cons a w)) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 (singleton e0)) (and (dans e2 qa) (chemin e1 e2 (add e0 q) (add (couple e0 (couple a e)) d) (cons a w)))))) *) intro Ht; elim Ht; clear Ht; intros H2 H3. cut (dans e1 (map injdroite q2) /\ dans (couple x e) (prodcart alph (map injdroite q2))). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply coupl2; auto. (* Goal: forall (_ : dans x alph) (_ : dans (couple e1 (couple x e)) d), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro Ht; elim Ht; clear Ht; intros H4 H5. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) absurd (dans e1 (map injdroite q2)); auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply absurd_injg_injd with q1; auto. Qed. (* *) (* Si on a un chemin dans l'automate reconnaissant l'union de l1 et *) (* et l2 commencant sur un etat de l'automate reconnaissant l1 *) (* alors le mot reconnu est reconnu par l1. *) (* *) Lemma chemin_restriction_1 : forall (q1 qd1 qa1 d1 q2 qa2 d2 : Ensf) (w : Word) (e1 e2 : Elt), automate q1 qd1 qa1 d1 -> chemin e1 e2 (union_disj q1 q2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)) w -> dans e1 (map injgauche q1) -> dans e2 (union_disj qa1 qa2) -> chemin (first e1) (first e2) q1 d1 w /\ dans e2 (map injgauche qa1). intros q1 qd1 qa1 d1 q2 qa2 d2. (* Goal: forall (w : Word) (e0 e1 e2 e3 a : Elt) (q d : Ensf) (_ : chemin e1 e2 q d w), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) w *) simple induction w. intros e1 e2 H H0 H1 H2. cut (Chemin e1 e2 (union_disj q1 q2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)) nil); (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) auto. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) cut (dans e1 (union_disj q1 q2) /\ e1 = e2 :>Elt); auto. (* Goal: forall (_ : dans x alph) (_ : dans (couple e1 (couple x e)) d), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro Ht; elim Ht; clear Ht; intros H4 H5. (* Goal: and (automate_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (eqwordset (reconnait_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (lconc l1 l2)) *) split. apply chemin_nil. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply (f_equal (A:=Elt) (B:=Elt)); auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply dans_map_injg; auto. unfold union_disj in H2. cut (dans e2 (map injgauche qa1) \/ dans e2 (map injdroite qa2)); (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) auto. intro Ht; elim Ht; clear Ht. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) auto. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) absurd (dans e2 (map injdroite qa2)); auto. rewrite <- H5. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply absurd_injg_injd with q1; auto. intros x w0 H e1 e2 H0 H1 H2 H3. cut (Chemin e1 e2 (union_disj q1 q2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)) (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) (cons x w0)); auto. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. cut (exists e : Elt, chemin e e2 (union_disj q1 q2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)) w0 /\ dans e1 (union_disj q1 q2) /\ dans x alph /\ dans (couple e1 (couple x e)) (union (injg_d1 q1 d1) (injd_d2 q2 d2))); (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) auto. intro Ht; elim Ht; clear Ht. intros e Ht; elim Ht; clear Ht. intros H5 Ht; elim Ht; clear Ht. intros H6 Ht; elim Ht; clear Ht; intros H7 H8. cut (dans e (map injgauche q1)). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply transition_dans_d1 with d1 q2 d2 e1 x; auto. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. cut (chemin (first e) (first e2) q1 d1 w0 /\ dans e2 (map injgauche qa1)); (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) auto. intro Ht; elim Ht; clear Ht; intros H10 H11. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) split; auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply chemin_cons with (first e); auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply dans_map_injg; auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply restriction_transition_d1 with q1 q2 d2; auto. Qed. (* De meme pour l2... *) Axiom chemin_restriction_2 : forall (q2 qd2 qa2 d2 q1 qa1 d1 : Ensf) (w : Word) (e1 e2 : Elt), automate q2 qd2 qa2 d2 -> chemin e1 e2 (union_disj q1 q2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)) w -> dans e1 (map injdroite q2) -> dans e2 (union_disj qa1 qa2) -> chemin (first e1) (first e2) q2 d2 w /\ dans e2 (map injdroite qa2). (* *) (* Inversement, si on a un chemin dans l'automate reconnaissant l1 *) (* pour un mot w alors on a un chemin dans l'automate reconnaissant *) (* l'union de l1 et l2 pour w. *) (* *) Lemma chemin_extension_1 : forall (q1 qd1 qa1 d1 q2 d2 : Ensf) (w : Word) (e1 e2 : Elt), automate q1 qd1 qa1 d1 -> chemin e1 e2 q1 d1 w -> dans e1 q1 -> dans e2 qa1 -> chemin (couple e1 zero) (couple e2 zero) (union_disj q1 q2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)) w. intros q1 qd1 qa1 d1 q2 d2. (* Goal: forall (w : Word) (e0 e1 e2 e3 a : Elt) (q d : Ensf) (_ : chemin e1 e2 q d w), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) w *) simple induction w. intros e1 e2 H_aut. (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intros. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) cut (Chemin e1 e2 q1 d1 nil); auto. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) cut (dans e1 q1 /\ e1 = e2 :>Elt); auto. intro Ht; elim Ht; clear Ht. intros H3 H4. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply chemin_nil; auto. (* Goal: dans (couple e1 zero) (union_disj q1 q2) *) (* Goal: dans (couple (couple e1 zero) (couple x (couple e zero))) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) *) unfold union_disj in |- *. (* Goal: dans (couple (couple e1 zero) (couple x (couple e zero))) (union (injg_d1 q1 d1) (injd_d2 q2 d2)) *) apply union_g. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) replace (couple e1 zero) with (injgauche e1); auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) rewrite H4; auto. intros x w0 H e1 e2 H_aut. (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intros. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) cut (Chemin e1 e2 q1 d1 (cons x w0)); auto. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. cut (exists e : Elt, chemin e e2 q1 d1 w0 /\ dans e1 q1 /\ dans x alph /\ dans (couple e1 (couple x e)) d1); (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) auto. intro Ht; elim Ht; clear Ht. intros e Ht; elim Ht; clear Ht. intros H4 Ht; elim Ht; clear Ht. intros H5 Ht; elim Ht; clear Ht. intros H6 H7. cut (dans e q1). intro dans_e_q1. 2: cut (inclus d1 (prodcart q1 (prodcart alph q1))). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 3: apply automate_def1 with qd1 qa1; auto. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) 2: intro. 2: cut (dans (couple e1 (couple x e)) (prodcart q1 (prodcart alph q1))). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 3: apply dans_trans with d1; auto. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) 2: intro. 2: cut (dans e1 q1 /\ dans (couple x e) (prodcart alph q1)). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 3: apply coupl2; auto. 2: intro Ht; elim Ht; clear Ht. 2: intros H10 H11. 2: cut (dans x alph /\ dans e q1). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 3: apply coupl2; auto. 2: intro Ht; elim Ht; clear Ht. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply chemin_cons with (couple e zero); auto. (* Goal: dans (couple e1 zero) (union_disj q1 q2) *) (* Goal: dans (couple (couple e1 zero) (couple x (couple e zero))) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) *) unfold union_disj in |- *. (* Goal: dans (couple (couple e1 zero) (couple x (couple e zero))) (union (injg_d1 q1 d1) (injd_d2 q2 d2)) *) apply union_g. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) replace (couple e1 zero) with (injgauche e1); auto. (* Goal: dans (couple (couple e1 zero) (couple x (couple e zero))) (union (injg_d1 q1 d1) (injd_d2 q2 d2)) *) apply union_g. (* Goal: dans (couple (couple e1 zero) (couple x (couple e zero))) (injg_d1 q1 d1) *) unfold injg_d1 in |- *. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply imp_dans_tq; auto. (* Goal: dans (couple (couple e1 zero) (couple x (couple e zero))) (prodcart (map injgauche q1) (prodcart alph (map injgauche q1))) *) apply coupl2_inv. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) replace (couple e1 zero) with (injgauche e1); auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply coupl2_inv; auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) replace (couple e zero) with (injgauche e); auto. Qed. (* De meme pour l2... *) Axiom chemin_extension_2 : forall (q2 qd2 qa2 d2 q1 d1 : Ensf) (w : Word) (e1 e2 : Elt), automate q2 qd2 qa2 d2 -> chemin e1 e2 q2 d2 w -> dans e1 q2 -> dans e2 qa2 -> chemin (couple e1 un) (couple e2 un) (union_disj q1 q2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)) w. (* *) (* Si l'automate 1 reconnait l1 et l'automate 2 reconnait l2 alors *) (* l'automate ci-dessous reconnait l'union de l1 et l2. *) (* *) Lemma lunion_is_reg1 : forall (q1 qd1 qa1 d1 q2 qd2 qa2 d2 : Ensf) (l1 l2 : wordset), automate q1 qd1 qa1 d1 -> eqwordset (reconnait q1 qd1 qa1 d1) l1 -> automate q2 qd2 qa2 d2 -> eqwordset (reconnait q2 qd2 qa2 d2) l2 -> eqwordset (reconnait (union_disj q1 q2) (union_disj qd1 qd2) (union_disj qa1 qa2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) (lunion l1 l2). (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intros. unfold eqwordset in |- *. intro w. (* Goal: and (automate_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (eqwordset (reconnait_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (lconc l1 l2)) *) split. (* Goal: forall (w : Word) (e0 e a : Elt) (q qa d : Ensf) (_ : reconnait q (singleton e) qa d w) (_ : not (dans e0 q)) (_ : dans a alph), reconnait (add e0 q) (singleton e0) qa (add (couple e0 (couple a e)) d) (cons a w) *) unfold reconnait in |- *. intro Ht; elim Ht; clear Ht. intros H3 Ht; elim Ht; clear Ht. intros e1 Ht; elim Ht; clear Ht. intros e2 Ht; elim Ht; clear Ht. intros H4 Ht; elim Ht; clear Ht. intros H5 H6. unfold union_disj in H4. cut (dans e1 (map injgauche qd1) \/ dans e1 (map injdroite qd2)); (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) auto. intro Ht; elim Ht; clear Ht. (* Goal: forall _ : Chemin e1 x1 q1 d1 (cons x w), chemin_A (union_disj q1 q2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) (couple e1 zero) (couple e2 un) (cons x (Append w w2)) *) intro H7. unfold lunion in |- *. left. cut (chemin (first e1) (first e2) q1 d1 w /\ dans e2 (map injgauche qa1)). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply chemin_restriction_1 with qd1 q2 qa2 d2; auto. 2: cut (inclus qd1 q1). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 3: apply automate_def2 with qa1 d1; auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: intro; apply dans_map_trans with qd1; auto. intro Ht; elim Ht; clear Ht; intros H8 H9. unfold eqwordset in H0. elim (H0 w). intros H10 H11. apply H10. (* Goal: forall (w : Word) (e0 e a : Elt) (q qa d : Ensf) (_ : reconnait q (singleton e) qa d w) (_ : not (dans e0 q)) (_ : dans a alph), reconnait (add e0 q) (singleton e0) qa (add (couple e0 (couple a e)) d) (cons a w) *) unfold reconnait in |- *. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) split; auto. exists (first e1). exists (first e2). (* Goal: and (automate_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (eqwordset (reconnait_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (lconc l1 l2)) *) split. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply dans_map_injg; auto. (* Goal: and (automate_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (eqwordset (reconnait_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (lconc l1 l2)) *) split. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply dans_map_injg; auto. (* Goal: reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) (* Goal: forall _ : lword nil w, reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) assumption. (* Goal: forall _ : Chemin e1 x1 q1 d1 (cons x w), chemin_A (union_disj q1 q2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) (couple e1 zero) (couple e2 un) (cons x (Append w w2)) *) intro H7. unfold lunion in |- *. right. cut (chemin (first e1) (first e2) q2 d2 w /\ dans e2 (map injdroite qa2)). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply chemin_restriction_2 with qd2 q1 qa1 d1; auto. 2: cut (inclus qd2 q2). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 3: apply automate_def2 with qa2 d2; auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: intro; apply dans_map_trans with qd2; auto. intro Ht; elim Ht; clear Ht; intros H8 H9. unfold eqwordset in H2. elim (H2 w). intros H10 H11. apply H10. (* Goal: forall (w : Word) (e0 e a : Elt) (q qa d : Ensf) (_ : reconnait q (singleton e) qa d w) (_ : not (dans e0 q)) (_ : dans a alph), reconnait (add e0 q) (singleton e0) qa (add (couple e0 (couple a e)) d) (cons a w) *) unfold reconnait in |- *. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) split; auto. exists (first e1). exists (first e2). (* Goal: and (automate_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (eqwordset (reconnait_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (lconc l1 l2)) *) split. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply dans_map_injd; auto. (* Goal: and (automate_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (eqwordset (reconnait_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (lconc l1 l2)) *) split. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply dans_map_injd; auto. (* Goal: reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) (* Goal: forall _ : lword nil w, reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) assumption. unfold lunion in |- *. intro Ht; elim Ht; clear Ht. intro H3. unfold eqwordset in H0. elim (H0 w). (* Goal: forall (_ : dans x alph) (_ : dans (couple e1 (couple x e)) d), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intros H4 H5. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) cut (reconnait q1 qd1 qa1 d1 w); auto. intro Ht; elim Ht; clear Ht. intros H6 Ht; elim Ht; clear Ht. intros e1 Ht; elim Ht; clear Ht. intros e2 Ht; elim Ht; clear Ht. intros H7 Ht; elim Ht; clear Ht. intros H8 H9. (* Goal: forall (w : Word) (e0 e a : Elt) (q qa d : Ensf) (_ : reconnait q (singleton e) qa d w) (_ : not (dans e0 q)) (_ : dans a alph), reconnait (add e0 q) (singleton e0) qa (add (couple e0 (couple a e)) d) (cons a w) *) unfold reconnait in |- *. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) split; auto. exists (couple e1 zero). exists (couple e2 zero). (* Goal: and (automate_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (eqwordset (reconnait_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (lconc l1 l2)) *) split. (* Goal: dans (couple e1 zero) (union_disj q1 q2) *) (* Goal: dans (couple (couple e1 zero) (couple x (couple e zero))) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) *) unfold union_disj in |- *. (* Goal: dans (couple (couple e1 zero) (couple x (couple e zero))) (union (injg_d1 q1 d1) (injd_d2 q2 d2)) *) apply union_g. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) replace (couple e1 zero) with (injgauche e1); auto. (* Goal: and (automate_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (eqwordset (reconnait_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (lconc l1 l2)) *) split. (* Goal: dans (couple e1 zero) (union_disj q1 q2) *) (* Goal: dans (couple (couple e1 zero) (couple x (couple e zero))) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) *) unfold union_disj in |- *. (* Goal: dans (couple (couple e1 zero) (couple x (couple e zero))) (union (injg_d1 q1 d1) (injd_d2 q2 d2)) *) apply union_g. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) replace (couple e2 zero) with (injgauche e2); auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply chemin_extension_1 with qd1 qa1; auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply dans_trans with qd1; auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply automate_def2 with qa1 d1; auto. intro H3. unfold eqwordset in H2. elim (H2 w). (* Goal: forall (_ : dans x alph) (_ : dans (couple e1 (couple x e)) d), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intros H4 H5. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) cut (reconnait q2 qd2 qa2 d2 w); auto. intro Ht; elim Ht; clear Ht. intros H6 Ht; elim Ht; clear Ht. intros e1 Ht; elim Ht; clear Ht. intros e2 Ht; elim Ht; clear Ht. intros H7 Ht; elim Ht; clear Ht. intros H8 H9. (* Goal: forall (w : Word) (e0 e a : Elt) (q qa d : Ensf) (_ : reconnait q (singleton e) qa d w) (_ : not (dans e0 q)) (_ : dans a alph), reconnait (add e0 q) (singleton e0) qa (add (couple e0 (couple a e)) d) (cons a w) *) unfold reconnait in |- *. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) split; auto. exists (couple e1 un). exists (couple e2 un). (* Goal: and (automate_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (eqwordset (reconnait_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (lconc l1 l2)) *) split. (* Goal: dans (couple e1 zero) (union_disj q1 q2) *) (* Goal: dans (couple (couple e1 zero) (couple x (couple e zero))) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) *) unfold union_disj in |- *. (* Goal: dans (couple (couple e1 zero) (couple x (couple e zero))) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) *) apply union_d. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) replace (couple e1 un) with (injdroite e1); auto. (* Goal: and (automate_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (eqwordset (reconnait_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (lconc l1 l2)) *) split. (* Goal: dans (couple e1 zero) (union_disj q1 q2) *) (* Goal: dans (couple (couple e1 zero) (couple x (couple e zero))) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) *) unfold union_disj in |- *. (* Goal: dans (couple (couple e1 zero) (couple x (couple e zero))) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) *) apply union_d. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) replace (couple e2 un) with (injdroite e2); auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply chemin_extension_2 with qd2 qa2; auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply dans_trans with qd2; auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply automate_def2 with qa2 d2; auto. Qed. (* *) (* Si les langages l1 et l2 sont reguliers alors le langage *) (* (lunion l1 l2) est aussi regulier. *) (* *) Lemma lunion_is_reg : forall l1 l2 : wordset, isregular l1 -> isregular l2 -> isregular (lunion l1 l2). (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lunion l1 l2) *) unfold isregular in |- *. (* Goal: forall (l1 l2 : wordset) (_ : @ex Ensf (fun q : Ensf => @ex Ensf (fun qd : Ensf => @ex Ensf (fun qa : Ensf => @ex Ensf (fun d : Ensf => and (automate q qd qa d) (eqwordset (reconnait q qd qa d) l1)))))) (_ : @ex Ensf (fun q : Ensf => @ex Ensf (fun qd : Ensf => @ex Ensf (fun qa : Ensf => @ex Ensf (fun d : Ensf => and (automate q qd qa d) (eqwordset (reconnait q qd qa d) l2)))))), @ex Ensf (fun q : Ensf => @ex Ensf (fun qd : Ensf => @ex Ensf (fun qa : Ensf => @ex Ensf (fun d : Ensf => and (automate q qd qa d) (eqwordset (reconnait q qd qa d) (lunion l1 l2)))))) *) intros l1 l2 H1 H2. (* Goal: @ex Ensf (fun q : Ensf => @ex Ensf (fun qd : Ensf => @ex Ensf (fun qa : Ensf => @ex Ensf (fun d : Ensf => and (automate q qd qa d) (eqwordset (reconnait q qd qa d) (lunion l1 l2)))))) *) elim H1; clear H1. intros q1 H1; elim H1; clear H1; intros qd1 H1; elim H1; clear H1; intros qa1 H1; elim H1; clear H1; intros d1 H1; elim H1; clear H1. (* Goal: forall (_ : automate q1 qd1 qa1 d1) (_ : eqwordset (reconnait q1 qd1 qa1 d1) l1), @ex Ensf (fun q : Ensf => @ex Ensf (fun qd : Ensf => @ex Ensf (fun qa : Ensf => @ex Ensf (fun d : Ensf => and (automate q qd qa d) (eqwordset (reconnait q qd qa d) (lunion l1 l2)))))) *) intros H1_aut H1_eq. (* Goal: @ex Ensf (fun q : Ensf => @ex Ensf (fun qd : Ensf => @ex Ensf (fun qa : Ensf => @ex Ensf (fun d : Ensf => and (automate q qd qa d) (eqwordset (reconnait q qd qa d) (lunion l1 l2)))))) *) elim H2; clear H2. intros q2 H2; elim H2; clear H2; intros qd2 H2; elim H2; clear H2; intros qa2 H2; elim H2; clear H2; intros d2 H2; elim H2; clear H2. (* Goal: forall (_ : automate q2 qd2 qa2 d2) (_ : eqwordset (reconnait q2 qd2 qa2 d2) l2), @ex Ensf (fun q : Ensf => @ex Ensf (fun qd : Ensf => @ex Ensf (fun qa : Ensf => @ex Ensf (fun d : Ensf => and (automate q qd qa d) (eqwordset (reconnait q qd qa d) (lunion l1 l2)))))) *) intros H2_aut H2_eq. (* Goal: @ex Ensf (fun q : Ensf => @ex Ensf (fun qd : Ensf => @ex Ensf (fun qa : Ensf => @ex Ensf (fun d : Ensf => and (automate_A q qd qa d) (eqwordset (reconnait_A q qd qa d) (lconc l1 l2)))))) *) exists (union_disj q1 q2). (* Goal: @ex Ensf (fun qd : Ensf => @ex Ensf (fun qa : Ensf => @ex Ensf (fun d : Ensf => and (automate (union_disj q1 q2) qd qa d) (eqwordset (reconnait (union_disj q1 q2) qd qa d) (lunion l1 l2))))) *) exists (union_disj qd1 qd2). (* Goal: @ex Ensf (fun qa : Ensf => @ex Ensf (fun d : Ensf => and (automate (union_disj q1 q2) (union_disj qd1 qd2) qa d) (eqwordset (reconnait (union_disj q1 q2) (union_disj qd1 qd2) qa d) (lunion l1 l2)))) *) exists (union_disj qa1 qa2). (* Goal: @ex Ensf (fun d : Ensf => and (automate (union_disj q1 q2) (union_disj qd1 qd2) (union_disj qa1 qa2) d) (eqwordset (reconnait (union_disj q1 q2) (union_disj qd1 qd2) (union_disj qa1 qa2) d) (lunion l1 l2))) *) exists (union (injg_d1 q1 d1) (injd_d2 q2 d2)). (* Goal: and (automate_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (eqwordset (reconnait_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (lconc l1 l2)) *) split. (* Goal: automate (union_disj q1 q2) (union_disj qd1 qd2) (union_disj qa1 qa2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)) *) (* Goal: eqwordset (reconnait (union_disj q1 q2) (union_disj qd1 qd2) (union_disj qa1 qa2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) (lunion l1 l2) *) red in |- *. (* Goal: and (automate_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (eqwordset (reconnait_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (lconc l1 l2)) *) split. (* Goal: inclus (union_disj qd1 qd2) (union_disj q1 q2) *) (* Goal: inclus (union (injg_d1 q1 d1) (injd_d2 q2 d2)) (prodcart (union_disj q1 q2) (prodcart alph (union_disj q1 q2))) *) (* Goal: eqwordset (reconnait (union_disj q1 q2) (union_disj qd1 qd2) (union_disj qa1 qa2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) (lunion l1 l2) *) apply inclus_union_disj. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply automate_def3 with qd1 d1; auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply automate_def3 with qd2 d2; auto. (* Goal: and (automate_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (eqwordset (reconnait_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (lconc l1 l2)) *) split. (* Goal: inclus (union_disj qd1 qd2) (union_disj q1 q2) *) (* Goal: inclus (union (injg_d1 q1 d1) (injd_d2 q2 d2)) (prodcart (union_disj q1 q2) (prodcart alph (union_disj q1 q2))) *) (* Goal: eqwordset (reconnait (union_disj q1 q2) (union_disj qd1 qd2) (union_disj qa1 qa2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) (lunion l1 l2) *) apply inclus_union_disj. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply automate_def2 with qa1 d1; auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply automate_def2 with qa2 d2; auto. (* Goal: inclus (union (injg_d1 q1 d1) (injd_d2 q2 d2)) (prodcart (union_disj q1 q2) (prodcart alph (union_disj q1 q2))) *) (* Goal: eqwordset (reconnait (union_disj q1 q2) (union_disj qd1 qd2) (union_disj qa1 qa2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) (lunion l1 l2) *) apply d_is_good. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply lunion_is_reg1; auto. Qed. (************************************************************************) (* *) (* La concatenation de 2 langages reguliers est un langage regulier. *) (* *) (************************************************************************) (* On definit (pont qa1 qd2) comme l'ensemble des transitions *) (* (e,epsilon,e') avec e dans qa1 et e' dans qd2. *) Definition transition_pont (x : Elt) : Elt := match x return Elt with | natural n => (* natural *) zero (* couple *) | couple e e' => couple (couple e zero) (couple epsilon (couple e' un)) (* up *) | up e => zero (* word *) | word w => zero end. Definition pont (qa1 qd2 : Ensf) : Ensf := map transition_pont (prodcart qa1 qd2). (* L'automate construit pour reconnaitre l1.l2 est bien un automate *) (* asynchrone. *) Lemma automate_lconc_isgood : forall q1 qd1 qa1 d1 q2 qd2 qa2 d2 : Ensf, automate q1 qd1 qa1 d1 -> automate q2 qd2 qa2 d2 -> automate_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))). (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intros. (* Goal: automate (union_disj q1 q2) (union_disj qd1 qd2) (union_disj qa1 qa2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)) *) (* Goal: eqwordset (reconnait (union_disj q1 q2) (union_disj qd1 qd2) (union_disj qa1 qa2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) (lunion l1 l2) *) red in |- *. (* Goal: and (automate_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (eqwordset (reconnait_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (lconc l1 l2)) *) split. (* Goal: dans (couple e1 zero) (union_disj q1 q2) *) (* Goal: dans (couple (couple e1 zero) (couple x (couple e zero))) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) *) unfold union_disj in |- *. apply inclus_d2. apply map_inclus. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply automate_def3 with qd2 d2; auto. (* Goal: and (automate_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (eqwordset (reconnait_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (lconc l1 l2)) *) split. (* Goal: dans (couple e1 zero) (union_disj q1 q2) *) (* Goal: dans (couple (couple e1 zero) (couple x (couple e zero))) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) *) unfold union_disj in |- *. apply inclus_g2. apply map_inclus. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply automate_def2 with qa1 d1; auto. (* Goal: inclus (union (injg_d1 q1 d1) (injd_d2 q2 d2)) (prodcart (union_disj q1 q2) (prodcart alph (union_disj q1 q2))) *) apply union_inclus. (* Goal: dans (couple (couple e1 zero) (couple epsilon (couple x2 un))) (pont qa1 qd2) *) (* Goal: forall (e : Elt) (w : Word) (_ : forall (e1 : Elt) (_ : automate q1 qd1 qa1 d1) (_ : automate q2 qd2 qa2 d2) (_ : chemin e1 x1 q1 d1 w) (_ : dans x1 qa1) (_ : chemin x2 e2 q2 d2 w2) (_ : dans x2 qd2) (_ : dans e2 qa2), chemin_A (union_disj q1 q2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) (couple e1 zero) (couple e2 un) (Append w w2)) (e1 : Elt) (_ : automate q1 qd1 qa1 d1) (_ : automate q2 qd2 qa2 d2) (_ : chemin e1 x1 q1 d1 (cons e w)) (_ : dans x1 qa1) (_ : chemin x2 e2 q2 d2 w2) (_ : dans x2 qd2) (_ : dans e2 qa2), chemin_A (union_disj q1 q2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) (couple e1 zero) (couple e2 un) (Append (cons e w) w2) *) unfold pont in |- *. unfold inclus in |- *. (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intros. cut (exists y : Elt, dans y (prodcart qa1 qd2) /\ x = transition_pont y :>Elt). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply dans_map; auto. intro Ht; elim Ht; clear Ht. (* Goal: forall (_ : dans e12 (singleton e)) (_ : and (dans e2 qa) (chemin e12 e2 q d w)), and (inmonoid alph (cons a w)) (@ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 (singleton e0)) (and (dans e2 qa) (chemin e1 e2 (add e0 q) (add (couple e0 (couple a e)) d) (cons a w)))))) *) intros y Ht; elim Ht; clear Ht; intros H2 H3. cut (exists y1 : Elt, (exists y2 : Elt, dans y1 qa1 /\ dans y2 qd2 /\ y = couple y1 y2 :>Elt)). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply coupl3; auto. intro Ht; elim Ht; clear Ht. intros y1 Ht; elim Ht; clear Ht. intros y2 Ht; elim Ht; clear Ht. intros H4 Ht; elim Ht; clear Ht; intros H5 H6. cut (x = couple (couple y1 zero) (couple epsilon (couple y2 un)) :>Elt). 2: rewrite H3. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: rewrite H6; auto. (* Goal: forall _ : Chemin e1 x1 q1 d1 (cons x w), chemin_A (union_disj q1 q2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) (couple e1 zero) (couple e2 un) (cons x (Append w w2)) *) intro H7. rewrite H7. (* Goal: dans (couple (couple e1 zero) (couple x (couple e zero))) (prodcart (map injgauche q1) (prodcart alph (map injgauche q1))) *) apply coupl2_inv. (* Goal: dans (couple e1 zero) (union_disj q1 q2) *) (* Goal: dans (couple (couple e1 zero) (couple x (couple e zero))) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) *) unfold union_disj in |- *. (* Goal: dans (couple (couple e1 zero) (couple x (couple e zero))) (union (injg_d1 q1 d1) (injd_d2 q2 d2)) *) apply union_g. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) replace (couple y1 zero) with (injgauche y1); auto. apply dans_map_inv. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply dans_trans with qa1; auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply automate_def3 with qd1 d1; auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply coupl2_inv; auto. (* Goal: dans (couple e1 zero) (union_disj q1 q2) *) (* Goal: dans (couple (couple e1 zero) (couple x (couple e zero))) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) *) unfold union_disj in |- *. (* Goal: dans (couple (couple e1 zero) (couple x (couple e zero))) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) *) apply union_d. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) replace (couple y2 un) with (injdroite y2); auto. apply dans_map_inv. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply dans_trans with qd2; auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply automate_def2 with qa2 d2; auto. (* Goal: inclus (union (injg_d1 q1 d1) (injd_d2 q2 d2)) (prodcart (union_disj q1 q2) (prodcart alph (union_disj q1 q2))) *) apply union_inclus. apply inclus_trans with (prodcart (map injgauche q1) (prodcart alph (map injgauche q1))). (* Goal: dans (couple (couple e1 zero) (couple x (couple e zero))) (injg_d1 q1 d1) *) unfold injg_d1 in |- *. (* Goal: inclus (tq (est_dans_d' d2) (prodcart (map injdroite q2) (prodcart alph (map injdroite q2)))) (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) *) (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union_disj q1 q2) (prodcart alph (union_disj q1 q2))) *) apply inclus_tq. (* Goal: dans (couple e1 zero) (union_disj q1 q2) *) (* Goal: dans (couple (couple e1 zero) (couple x (couple e zero))) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) *) unfold union_disj in |- *. apply cart_inclus. apply inclus_g. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply cart_inclus; auto. apply inclus_trans with (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))). (* Goal: inclus (injd_d2 q2 d2) (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) *) (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union_disj q1 q2) (prodcart alph (union_disj q1 q2))) *) unfold injd_d2 in |- *. (* Goal: inclus (tq (est_dans_d' d2) (prodcart (map injdroite q2) (prodcart alph (map injdroite q2)))) (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) *) (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union_disj q1 q2) (prodcart alph (union_disj q1 q2))) *) apply inclus_tq. (* Goal: dans (couple e1 zero) (union_disj q1 q2) *) (* Goal: dans (couple (couple e1 zero) (couple x (couple e zero))) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) *) unfold union_disj in |- *. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply cart_inclus; auto. Qed. (* Si on a une transition (e0,x,e) avec e0 dans (map injgauche q1) *) (* et x dans alph, alors e est dans (map injgauche q1). *) Lemma transition_a_gauche : forall (q1 qa1 d1 q2 qd2 d2 : Ensf) (e0 x e : Elt), dans e0 (map injgauche q1) -> dans x alph -> dans (couple e0 (couple x e)) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) -> dans e (map injgauche q1). (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intros. cut (dans (couple e0 (couple x e)) (pont qa1 qd2) \/ dans (couple e0 (couple x e)) (union (injg_d1 q1 d1) (injd_d2 q2 d2))); (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) auto. intro Ht; elim Ht; clear Ht. (* Goal: dans (couple (couple e1 zero) (couple epsilon (couple x2 un))) (pont qa1 qd2) *) (* Goal: forall (e : Elt) (w : Word) (_ : forall (e1 : Elt) (_ : automate q1 qd1 qa1 d1) (_ : automate q2 qd2 qa2 d2) (_ : chemin e1 x1 q1 d1 w) (_ : dans x1 qa1) (_ : chemin x2 e2 q2 d2 w2) (_ : dans x2 qd2) (_ : dans e2 qa2), chemin_A (union_disj q1 q2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) (couple e1 zero) (couple e2 un) (Append w w2)) (e1 : Elt) (_ : automate q1 qd1 qa1 d1) (_ : automate q2 qd2 qa2 d2) (_ : chemin e1 x1 q1 d1 (cons e w)) (_ : dans x1 qa1) (_ : chemin x2 e2 q2 d2 w2) (_ : dans x2 qd2) (_ : dans e2 qa2), chemin_A (union_disj q1 q2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) (couple e1 zero) (couple e2 un) (Append (cons e w) w2) *) unfold pont in |- *. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. cut (exists y : Elt, dans y (prodcart qa1 qd2) /\ couple e0 (couple x e) = transition_pont y :>Elt). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply dans_map; auto. intro Ht; elim Ht; clear Ht; intros y Ht; elim Ht; clear Ht; intros H3 H4. cut (exists y1 : Elt, (exists y2 : Elt, dans y1 qa1 /\ dans y2 qd2 /\ y = couple y1 y2 :>Elt)). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply coupl3; auto. intro Ht; elim Ht; clear Ht; intros y1 Ht; elim Ht; clear Ht; intros y2 Ht; elim Ht; clear Ht; intros H5 Ht; elim Ht; clear Ht; intros H6 H7. cut (couple e0 (couple x e) = transition_pont (couple y1 y2) :>Elt). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: rewrite <- H7; auto. unfold transition_pont in |- *. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. cut (couple x e = couple epsilon (couple y2 un) :>Elt). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply couple_couple_inv2 with e0 (couple y1 zero); auto. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. cut (x = epsilon :>Elt). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply couple_couple_inv1 with e (couple y2 un); auto. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) absurd (dans x alph); auto. rewrite H10. (* Goal: reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) (* Goal: forall _ : lword nil w, reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) red in |- *; intro; apply not_dans_epsilon_alph; assumption. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. clear H1. cut (dans (couple e0 (couple x e)) (injg_d1 q1 d1) \/ (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) dans (couple e0 (couple x e)) (injd_d2 q2 d2)); auto. intro Ht; elim Ht; clear Ht. (* Goal: dans (couple (couple e1 zero) (couple x (couple e zero))) (injg_d1 q1 d1) *) unfold injg_d1 in |- *. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. cut (dans (couple e0 (couple x e)) (prodcart (map injgauche q1) (prodcart alph (map injgauche q1))) /\ est_dans_d' d1 (couple e0 (couple x e))). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply dans_tq_imp; auto. (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intro Ht; elim Ht; clear Ht; intros. cut (dans e0 (map injgauche q1) /\ dans (couple x e) (prodcart alph (map injgauche q1))). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply coupl2; auto. (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intro Ht; elim Ht; clear Ht; intros. cut (dans x alph /\ dans e (map injgauche q1)). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply coupl2; auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) intro Ht; elim Ht; auto. (* Goal: inclus (injd_d2 q2 d2) (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) *) (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union_disj q1 q2) (prodcart alph (union_disj q1 q2))) *) unfold injd_d2 in |- *. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. cut (dans (couple e0 (couple x e)) (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) /\ est_dans_d' d2 (couple e0 (couple x e))). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply dans_tq_imp; auto. (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intro Ht; elim Ht; clear Ht; intros. cut (dans e0 (map injdroite q2) /\ dans (couple x e) (prodcart alph (map injdroite q2))). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply coupl2; auto. (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intro Ht; elim Ht; clear Ht; intros. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) absurd (dans e0 (map injdroite q2)); auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply absurd_injg_injd with q1; auto. Qed. (* Si on a la transition (e0,x,e) dans la relation de l'automate *) (* reconnaissant la concatenation , que e0 est dans (map injgauche q1) *) (* et x dans alph, alors on a la transition (first e0,x,first e) *) (* dans d1. *) Lemma transition_a_gauche_2 : forall (q1 qa1 d1 q2 qd2 d2 : Ensf) (e0 x e : Elt), dans e0 (map injgauche q1) -> dans x alph -> dans (couple e0 (couple x e)) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) -> dans (couple (first e0) (couple x (first e))) d1. (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intros. cut (dans (couple e0 (couple x e)) (pont qa1 qd2) \/ dans (couple e0 (couple x e)) (union (injg_d1 q1 d1) (injd_d2 q2 d2))); (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) auto. intro Ht; elim Ht; clear Ht. (* Goal: dans (couple (couple e1 zero) (couple epsilon (couple x2 un))) (pont qa1 qd2) *) (* Goal: forall (e : Elt) (w : Word) (_ : forall (e1 : Elt) (_ : automate q1 qd1 qa1 d1) (_ : automate q2 qd2 qa2 d2) (_ : chemin e1 x1 q1 d1 w) (_ : dans x1 qa1) (_ : chemin x2 e2 q2 d2 w2) (_ : dans x2 qd2) (_ : dans e2 qa2), chemin_A (union_disj q1 q2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) (couple e1 zero) (couple e2 un) (Append w w2)) (e1 : Elt) (_ : automate q1 qd1 qa1 d1) (_ : automate q2 qd2 qa2 d2) (_ : chemin e1 x1 q1 d1 (cons e w)) (_ : dans x1 qa1) (_ : chemin x2 e2 q2 d2 w2) (_ : dans x2 qd2) (_ : dans e2 qa2), chemin_A (union_disj q1 q2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) (couple e1 zero) (couple e2 un) (Append (cons e w) w2) *) unfold pont in |- *. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. cut (exists y : Elt, dans y (prodcart qa1 qd2) /\ couple e0 (couple x e) = transition_pont y :>Elt). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply dans_map; auto. intro Ht; elim Ht; clear Ht; intros y Ht; elim Ht; clear Ht; intros H3 H4. cut (exists y1 : Elt, (exists y2 : Elt, dans y1 qa1 /\ dans y2 qd2 /\ y = couple y1 y2 :>Elt)). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply coupl3; auto. intro Ht; elim Ht; clear Ht; intros y1 Ht; elim Ht; clear Ht; intros y2 Ht; elim Ht; clear Ht; intros H5 Ht; elim Ht; clear Ht; intros H6 H7. cut (couple e0 (couple x e) = transition_pont (couple y1 y2) :>Elt). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: rewrite <- H7; auto. unfold transition_pont in |- *. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. cut (couple x e = couple epsilon (couple y2 un) :>Elt). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply couple_couple_inv2 with e0 (couple y1 zero); auto. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. cut (x = epsilon :>Elt). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply couple_couple_inv1 with e (couple y2 un); auto. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) absurd (dans x alph); auto. rewrite H10. (* Goal: reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) (* Goal: forall _ : lword nil w, reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) red in |- *; intro; apply not_dans_epsilon_alph; assumption. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. clear H1. cut (dans (couple e0 (couple x e)) (injg_d1 q1 d1) \/ (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) dans (couple e0 (couple x e)) (injd_d2 q2 d2)); auto. intro Ht; elim Ht; clear Ht. (* Goal: dans (couple (couple e1 zero) (couple x (couple e zero))) (injg_d1 q1 d1) *) unfold injg_d1 in |- *. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. cut (dans (couple e0 (couple x e)) (prodcart (map injgauche q1) (prodcart alph (map injgauche q1))) /\ est_dans_d' d1 (couple e0 (couple x e))). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply dans_tq_imp; auto. (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intro Ht; elim Ht; clear Ht; intros. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) auto. (* Goal: inclus (injd_d2 q2 d2) (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) *) (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union_disj q1 q2) (prodcart alph (union_disj q1 q2))) *) unfold injd_d2 in |- *. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. cut (dans (couple e0 (couple x e)) (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) /\ est_dans_d' d2 (couple e0 (couple x e))). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply dans_tq_imp; auto. (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intro Ht; elim Ht; clear Ht; intros. cut (dans e0 (map injdroite q2) /\ dans (couple x e) (prodcart alph (map injdroite q2))). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply coupl2; auto. (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intro Ht; elim Ht; clear Ht; intros. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) absurd (dans e0 (map injdroite q2)); auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply absurd_injg_injd with q1; auto. Qed. (* De meme pour d2... *) Axiom transition_a_droite_2 : forall (q1 qa1 d1 q2 qd2 d2 : Ensf) (e0 x e : Elt), dans e0 (map injdroite q2) -> dans x alph -> dans (couple e0 (couple x e)) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) -> dans (couple (first e0) (couple x (first e))) d2. (* Si on a une transition (e0,epsilon,e) alors (first e0) est dans qa1 *) (* et (first e) est dans qd2. *) Lemma transition_dans_pont : forall (q1 qa1 d1 q2 qd2 d2 : Ensf) (e0 e : Elt), dans (couple e0 (couple epsilon e)) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) -> dans e0 (map injgauche qa1) /\ dans e (map injdroite qd2). (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intros. cut (dans (couple e0 (couple epsilon e)) (pont qa1 qd2) \/ dans (couple e0 (couple epsilon e)) (union (injg_d1 q1 d1) (injd_d2 q2 d2))); (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) auto. intro Ht; elim Ht; clear Ht. (* Goal: dans (couple (couple e1 zero) (couple epsilon (couple x2 un))) (pont qa1 qd2) *) (* Goal: forall (e : Elt) (w : Word) (_ : forall (e1 : Elt) (_ : automate q1 qd1 qa1 d1) (_ : automate q2 qd2 qa2 d2) (_ : chemin e1 x1 q1 d1 w) (_ : dans x1 qa1) (_ : chemin x2 e2 q2 d2 w2) (_ : dans x2 qd2) (_ : dans e2 qa2), chemin_A (union_disj q1 q2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) (couple e1 zero) (couple e2 un) (Append w w2)) (e1 : Elt) (_ : automate q1 qd1 qa1 d1) (_ : automate q2 qd2 qa2 d2) (_ : chemin e1 x1 q1 d1 (cons e w)) (_ : dans x1 qa1) (_ : chemin x2 e2 q2 d2 w2) (_ : dans x2 qd2) (_ : dans e2 qa2), chemin_A (union_disj q1 q2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) (couple e1 zero) (couple e2 un) (Append (cons e w) w2) *) unfold pont in |- *. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. cut (exists y : Elt, dans y (prodcart qa1 qd2) /\ couple e0 (couple epsilon e) = transition_pont y :>Elt). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply dans_map; auto. intro Ht; elim Ht; clear Ht; intros y Ht; elim Ht; clear Ht; intros H3 H4. cut (exists y1 : Elt, (exists y2 : Elt, dans y1 qa1 /\ dans y2 qd2 /\ y = couple y1 y2 :>Elt)). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply coupl3; auto. intro Ht; elim Ht; clear Ht; intros y1 Ht; elim Ht; clear Ht; intros y2 Ht; elim Ht; clear Ht; intros H5 Ht; elim Ht; clear Ht; intros H6 H7. cut (couple e0 (couple epsilon e) = transition_pont (couple y1 y2) :>Elt). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: rewrite <- H7; auto. unfold transition_pont in |- *. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. cut (e0 = couple y1 zero :>Elt). 2: apply couple_couple_inv1 with (couple epsilon e) (couple epsilon (couple y2 un)); (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) auto. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. cut (couple epsilon e = couple epsilon (couple y2 un) :>Elt). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply couple_couple_inv2 with e0 (couple y1 zero); auto. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. cut (e = couple y2 un :>Elt). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply couple_couple_inv2 with epsilon epsilon; auto. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. (* Goal: and (automate_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (eqwordset (reconnait_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (lconc l1 l2)) *) split. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) replace e0 with (couple y1 zero); auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) replace (couple y1 zero) with (injgauche y1); auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) replace e with (couple y2 un); auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) replace (couple y2 un) with (injdroite y2); auto. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. cut (dans (couple e0 (couple epsilon e)) (injg_d1 q1 d1) \/ dans (couple e0 (couple epsilon e)) (injd_d2 q2 d2)); (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) auto. intro Ht; elim Ht; clear Ht. (* Goal: dans (couple (couple e1 zero) (couple x (couple e zero))) (injg_d1 q1 d1) *) unfold injg_d1 in |- *. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. cut (dans (couple e0 (couple epsilon e)) (prodcart (map injgauche q1) (prodcart alph (map injgauche q1))) /\ est_dans_d' d1 (couple e0 (couple epsilon e))). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply dans_tq_imp; auto. (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intro Ht; elim Ht; clear Ht; intros. cut (dans e0 (map injgauche q1) /\ dans (couple epsilon e) (prodcart alph (map injgauche q1))). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply coupl2; auto. (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intro Ht; elim Ht; clear Ht; intros. cut (dans epsilon alph /\ dans e (map injgauche q1)). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply coupl2; auto. (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intro Ht; elim Ht; clear Ht; intros. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) absurd (dans epsilon alph); auto. (* Goal: reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) (* Goal: forall _ : lword nil w, reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) red in |- *; intro; apply not_dans_epsilon_alph; assumption. (* Goal: inclus (injd_d2 q2 d2) (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) *) (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union_disj q1 q2) (prodcart alph (union_disj q1 q2))) *) unfold injd_d2 in |- *. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. cut (dans (couple e0 (couple epsilon e)) (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) /\ est_dans_d' d2 (couple e0 (couple epsilon e))). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply dans_tq_imp; auto. (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intro Ht; elim Ht; clear Ht; intros. cut (dans e0 (map injdroite q2) /\ dans (couple epsilon e) (prodcart alph (map injdroite q2))). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply coupl2; auto. (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intro Ht; elim Ht; clear Ht; intros. cut (dans epsilon alph /\ dans e (map injdroite q2)). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply coupl2; auto. (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intro Ht; elim Ht; clear Ht; intros. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) absurd (dans epsilon alph); auto. (* Goal: reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) (* Goal: forall _ : lword nil w, reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) red in |- *; intro; apply not_dans_epsilon_alph; assumption. Qed. (* Si on a une transition dans le pont alors c'est par epsilon. *) Lemma dans_pont_imp_epsilon : forall (qa1 qd2 : Ensf) (e1 x e0 : Elt), dans (couple e1 (couple x e0)) (pont qa1 qd2) -> x = epsilon :>Elt. intros qa1 qd2 e1 x e0. (* Goal: dans (couple (couple e1 zero) (couple epsilon (couple x2 un))) (pont qa1 qd2) *) (* Goal: forall (e : Elt) (w : Word) (_ : forall (e1 : Elt) (_ : automate q1 qd1 qa1 d1) (_ : automate q2 qd2 qa2 d2) (_ : chemin e1 x1 q1 d1 w) (_ : dans x1 qa1) (_ : chemin x2 e2 q2 d2 w2) (_ : dans x2 qd2) (_ : dans e2 qa2), chemin_A (union_disj q1 q2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) (couple e1 zero) (couple e2 un) (Append w w2)) (e1 : Elt) (_ : automate q1 qd1 qa1 d1) (_ : automate q2 qd2 qa2 d2) (_ : chemin e1 x1 q1 d1 (cons e w)) (_ : dans x1 qa1) (_ : chemin x2 e2 q2 d2 w2) (_ : dans x2 qd2) (_ : dans e2 qa2), chemin_A (union_disj q1 q2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) (couple e1 zero) (couple e2 un) (Append (cons e w) w2) *) unfold pont in |- *. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. cut (exists y : Elt, dans y (prodcart qa1 qd2) /\ couple e1 (couple x e0) = transition_pont y :>Elt). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply dans_map; auto. intro Ht; elim Ht; clear Ht; intros y Ht; elim Ht; clear Ht; intros H0 H1. cut (exists y1 : Elt, (exists y2 : Elt, dans y1 qa1 /\ dans y2 qd2 /\ y = couple y1 y2 :>Elt)). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply coupl3; auto. intro Ht; elim Ht; clear Ht; intros y1 Ht; elim Ht; clear Ht; intros y2 Ht; elim Ht; clear Ht; intros H2 Ht; elim Ht; clear Ht; intros H3 H4. cut (couple e1 (couple x e0) = transition_pont (couple y1 y2) :>Elt). (* Goal: reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) (* Goal: forall _ : lword nil w, reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) 2: rewrite <- H4; assumption. unfold transition_pont in |- *. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. cut (couple x e0 = couple epsilon (couple y2 un) :>Elt). (* Goal: reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) (* Goal: forall _ : lword nil w, reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) 2: apply couple_couple_inv2 with e1 (couple y1 zero); assumption. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. (* Goal: reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) (* Goal: forall _ : lword nil w, reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) apply couple_couple_inv1 with e0 (couple y2 un); assumption. Qed. (* Si on a un chemin asynchrone uniquement dans l'automate 2 alors *) (* on a le meme chemin au sens des automates finis. *) Lemma chemin_A_chemin_2 : forall (q1 qa1 d1 q2 qd2 d2 : Ensf) (e e3 : Elt) (w0 : Word), chemin_A (union_disj q1 q2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) e e3 w0 -> dans e (map injdroite q2) -> dans e3 (map injdroite q2) -> chemin (first e) (first e3) q2 d2 w0. intros q1 qa1 d1 q2 qd2 d2 e e3 w0 H. elim H; clear H. (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intros. apply chemin_nil. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply dans_map_injd; auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply (f_equal (A:=Elt) (B:=Elt)); auto. intros e1 e0 e2 x w H H0 H1 H2 H3 H4 H5. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply chemin_cons with (first e0); auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply H0; auto. cut (dans (couple e1 (couple x e0)) (pont qa1 qd2) \/ dans (couple e1 (couple x e0)) (union (injg_d1 q1 d1) (injd_d2 q2 d2))); (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) auto. intro Ht; elim Ht; clear Ht. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. cut (x = epsilon :>Elt). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply dans_pont_imp_epsilon with qa1 qd2 e1 e0; auto. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) absurd (dans x alph); auto. rewrite H7. (* Goal: reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) (* Goal: forall _ : lword nil w, reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) red in |- *; intro; apply not_dans_epsilon_alph; assumption. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. cut (dans (couple e1 (couple x e0)) (injg_d1 q1 d1) \/ dans (couple e1 (couple x e0)) (injd_d2 q2 d2)); (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) auto. intro Ht; elim Ht; clear Ht. (* Goal: dans (couple (couple e1 zero) (couple x (couple e zero))) (injg_d1 q1 d1) *) unfold injg_d1 in |- *. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. cut (dans (couple e1 (couple x e0)) (prodcart (map injgauche q1) (prodcart alph (map injgauche q1))) /\ est_dans_d' d1 (couple e1 (couple x e0))). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply dans_tq_imp; auto. (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intro Ht; elim Ht; clear Ht; intros. cut (dans e1 (map injgauche q1) /\ dans (couple x e0) (prodcart alph (map injgauche q1))). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply coupl2; auto. (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intro Ht; elim Ht; clear Ht; intros. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) absurd (dans e1 (map injdroite q2)); auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply absurd_injg_injd with q1; auto. (* Goal: inclus (injd_d2 q2 d2) (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) *) (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union_disj q1 q2) (prodcart alph (union_disj q1 q2))) *) unfold injd_d2 in |- *. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. cut (dans (couple e1 (couple x e0)) (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) /\ est_dans_d' d2 (couple e1 (couple x e0))). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply dans_tq_imp; auto. (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intro Ht; elim Ht; clear Ht; intros. cut (dans e1 (map injdroite q2) /\ dans (couple x e0) (prodcart alph (map injdroite q2))). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply coupl2; auto. (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intro Ht; elim Ht; clear Ht; intros. cut (dans x alph /\ dans e0 (map injdroite q2)). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply coupl2; auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) intro Ht; elim Ht; auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply dans_map_injd; auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply transition_a_droite_2 with q1 qa1 d1 q2 qd2; auto. intros e1 e0 e2 w H H0 H1 H2 H3 H4. cut (dans e1 (map injgauche qa1) /\ dans e0 (map injdroite qd2)). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply transition_dans_pont with q1 d1 q2 d2; auto. intro Ht; elim Ht; clear Ht. (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intros. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) absurd (dans e1 (map injdroite q2)); auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply absurd_injg_injd with qa1; auto. Qed. (* Si on a un chemin par w de e1 a e2 avec e1 dans (map injgauche q1) *) (* et e2 dans (map injdroite q2) alors on passe necessairement par *) (* le pont. *) Lemma par_le_pont : forall (q1 qd1 qa1 d1 q2 qd2 qa2 d2 : Ensf) (e1 e2 : Elt) (w : Word), automate q1 qd1 qa1 d1 -> automate q2 qd2 qa2 d2 -> chemin_A (union_disj q1 q2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) e1 e2 w -> dans e1 (map injgauche q1) -> dans e2 (map injdroite q2) -> exists x1 : Elt, (exists x2 : Elt, (exists w1 : Word, (exists w2 : Word, dans x1 qa1 /\ dans x2 qd2 /\ chemin (first e1) x1 q1 d1 w1 /\ chemin x2 (first e2) q2 d2 w2 /\ w = Append w1 w2 :>Word))). intros q1 qd1 qa1 d1 q2 qd2 qa2 d2 e1 e2 w H_aut1 H_aut2 H. (* Goal: isregular L *) elim H. intros e0 e3 H0 H1 H2 H3. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) absurd (dans e3 (map injdroite q2)); auto. apply absurd_injg_injd with q1. (* Goal: reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) (* Goal: forall _ : lword nil w, reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) rewrite <- H1; assumption. intros e0 e e3 x w0 H0 H1 H2 H3 H4 H5 H6. cut (dans e (map injgauche q1)). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply transition_a_gauche with qa1 d1 q2 qd2 d2 e0 x; auto. (* Goal: forall _ : Chemin e1 x1 q1 d1 (cons x w), chemin_A (union_disj q1 q2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) (couple e1 zero) (couple e2 un) (cons x (Append w w2)) *) intro H7. elim (H1 H7 H6); clear H1. intros x1 Ht; elim Ht; clear Ht; intros x2 Ht; elim Ht; clear Ht; intros w1' Ht; elim Ht; clear Ht; intros w2 Ht; elim Ht; clear Ht; intros H8 Ht; elim Ht; clear Ht; intros H9 Ht; elim Ht; clear Ht; intros H10 Ht; elim Ht; clear Ht; intros H11 H12. exists x1. exists x2. exists (cons x w1'). exists w2. split; [ assumption | split; [ assumption | split ] ]. (* Goal: and (automate_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (eqwordset (reconnait_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (lconc l1 l2)) *) 2: split. (* Goal: reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) (* Goal: forall _ : lword nil w, reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) 2: assumption. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: rewrite H12; auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply chemin_cons with (first e); auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply dans_map_injg; auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply transition_a_gauche_2 with q1 qa1 q2 qd2 d2; auto. intros e0 e e3 w0 H0 H1 H2 H3 H4 H5. clear H1. exists (first e0). exists (first e). exists nil. exists w0. cut (dans e0 (map injgauche qa1) /\ dans e (map injdroite qd2)). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply transition_dans_pont with q1 d1 q2 d2; auto. intro Ht; elim Ht; clear Ht; intros H6 H7. split; [ apply dans_map_injg; assumption | split ]. (* Goal: reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) (* Goal: forall _ : lword nil w, reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) apply dans_map_injd; assumption. (* Goal: and (automate_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (eqwordset (reconnait_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (lconc l1 l2)) *) split. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply chemin_nil; auto. apply dans_trans with qa1. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply dans_map_injg; auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply automate_def3 with qd1 d1; auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) split; auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply chemin_A_chemin_2 with q1 qa1 d1 qd2; auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply dans_map_trans with qd2; auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply automate_def2 with qa2 d2; auto. Qed. (* Si l1 reconnait w1 et l2 reconnait w2 alors l'automate construit *) (* ici reconnait (Append w1 w2). *) Lemma reconnait_Append : forall (q1 qd1 qa1 d1 q2 qd2 qa2 d2 : Ensf) (w2 : Word) (x1 x2 e2 : Elt) (w1 : Word) (e1 : Elt), automate q1 qd1 qa1 d1 -> automate q2 qd2 qa2 d2 -> chemin e1 x1 q1 d1 w1 -> dans x1 qa1 -> chemin x2 e2 q2 d2 w2 -> dans x2 qd2 -> dans e2 qa2 -> chemin_A (union_disj q1 q2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) (couple e1 zero) (couple e2 un) (Append w1 w2). (* Goal: forall (q1 qd1 qa1 d1 q2 qd2 qa2 d2 : Ensf) (w2 : Word) (x1 x2 e2 : Elt) (w1 : Word) (e1 : Elt) (_ : automate q1 qd1 qa1 d1) (_ : automate q2 qd2 qa2 d2) (_ : chemin e1 x1 q1 d1 w1) (_ : dans x1 qa1) (_ : chemin x2 e2 q2 d2 w2) (_ : dans x2 qd2) (_ : dans e2 qa2), chemin_A (union_disj q1 q2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) (couple e1 zero) (couple e2 un) (Append w1 w2) *) intros q1 qd1 qa1 d1 q2 qd2 qa2 d2 w2 x1 x2 e2. (* Goal: forall (w1 : Word) (e1 : Elt) (_ : automate q1 qd1 qa1 d1) (_ : automate q2 qd2 qa2 d2) (_ : chemin e1 x1 q1 d1 w1) (_ : dans x1 qa1) (_ : chemin x2 e2 q2 d2 w2) (_ : dans x2 qd2) (_ : dans e2 qa2), chemin_A (union_disj q1 q2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) (couple e1 zero) (couple e2 un) (Append w1 w2) *) simple induction w1. (* Goal: forall (e1 : Elt) (_ : automate q1 qd1 qa1 d1) (_ : automate q2 qd2 qa2 d2) (_ : chemin e1 x1 q1 d1 nil) (_ : dans x1 qa1) (_ : chemin x2 e2 q2 d2 w2) (_ : dans x2 qd2) (_ : dans e2 qa2), chemin_A (union_disj q1 q2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) (couple e1 zero) (couple e2 un) (Append nil w2) *) (* Goal: forall (e : Elt) (w : Word) (_ : forall (e1 : Elt) (_ : automate q1 qd1 qa1 d1) (_ : automate q2 qd2 qa2 d2) (_ : chemin e1 x1 q1 d1 w) (_ : dans x1 qa1) (_ : chemin x2 e2 q2 d2 w2) (_ : dans x2 qd2) (_ : dans e2 qa2), chemin_A (union_disj q1 q2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) (couple e1 zero) (couple e2 un) (Append w w2)) (e1 : Elt) (_ : automate q1 qd1 qa1 d1) (_ : automate q2 qd2 qa2 d2) (_ : chemin e1 x1 q1 d1 (cons e w)) (_ : dans x1 qa1) (_ : chemin x2 e2 q2 d2 w2) (_ : dans x2 qd2) (_ : dans e2 qa2), chemin_A (union_disj q1 q2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) (couple e1 zero) (couple e2 un) (Append (cons e w) w2) *) intros e1 H_aut1 H_aut2 H H0 H1 H2 H3. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) cut (Chemin e1 x1 q1 d1 nil); auto. (* Goal: forall _ : Chemin e1 x1 q1 d1 nil, chemin_A (union_disj q1 q2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) (couple e1 zero) (couple e2 un) (Append nil w2) *) (* Goal: forall (e : Elt) (w : Word) (_ : forall (e1 : Elt) (_ : automate q1 qd1 qa1 d1) (_ : automate q2 qd2 qa2 d2) (_ : chemin e1 x1 q1 d1 w) (_ : dans x1 qa1) (_ : chemin x2 e2 q2 d2 w2) (_ : dans x2 qd2) (_ : dans e2 qa2), chemin_A (union_disj q1 q2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) (couple e1 zero) (couple e2 un) (Append w w2)) (e1 : Elt) (_ : automate q1 qd1 qa1 d1) (_ : automate q2 qd2 qa2 d2) (_ : chemin e1 x1 q1 d1 (cons e w)) (_ : dans x1 qa1) (_ : chemin x2 e2 q2 d2 w2) (_ : dans x2 qd2) (_ : dans e2 qa2), chemin_A (union_disj q1 q2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) (couple e1 zero) (couple e2 un) (Append (cons e w) w2) *) intro H4. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) cut (dans e1 q1 /\ e1 = x1 :>Elt); auto. intro Ht; elim Ht; clear Ht; intros H5 H6. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) replace (Append nil w2) with w2; auto. (* Goal: chemin_A (union_disj q1 q2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) (couple e1 zero) (couple e2 un) w2 *) (* Goal: forall (e : Elt) (w : Word) (_ : forall (e1 : Elt) (_ : automate q1 qd1 qa1 d1) (_ : automate q2 qd2 qa2 d2) (_ : chemin e1 x1 q1 d1 w) (_ : dans x1 qa1) (_ : chemin x2 e2 q2 d2 w2) (_ : dans x2 qd2) (_ : dans e2 qa2), chemin_A (union_disj q1 q2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) (couple e1 zero) (couple e2 un) (Append w w2)) (e1 : Elt) (_ : automate q1 qd1 qa1 d1) (_ : automate q2 qd2 qa2 d2) (_ : chemin e1 x1 q1 d1 (cons e w)) (_ : dans x1 qa1) (_ : chemin x2 e2 q2 d2 w2) (_ : dans x2 qd2) (_ : dans e2 qa2), chemin_A (union_disj q1 q2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) (couple e1 zero) (couple e2 un) (Append (cons e w) w2) *) apply chemin_A_epsilon with (couple x2 un). apply chemin_A_d1_d2 with (union (injg_d1 q1 d1) (injd_d2 q2 d2)); (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) auto. (* Goal: chemin_A (union_disj q1 q2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)) (couple x2 un) (couple e2 un) w2 *) (* Goal: dans (couple e1 zero) (union_disj q1 q2) *) (* Goal: dans (couple (couple e1 zero) (couple epsilon (couple x2 un))) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) *) (* Goal: forall (e : Elt) (w : Word) (_ : forall (e1 : Elt) (_ : automate q1 qd1 qa1 d1) (_ : automate q2 qd2 qa2 d2) (_ : chemin e1 x1 q1 d1 w) (_ : dans x1 qa1) (_ : chemin x2 e2 q2 d2 w2) (_ : dans x2 qd2) (_ : dans e2 qa2), chemin_A (union_disj q1 q2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) (couple e1 zero) (couple e2 un) (Append w w2)) (e1 : Elt) (_ : automate q1 qd1 qa1 d1) (_ : automate q2 qd2 qa2 d2) (_ : chemin e1 x1 q1 d1 (cons e w)) (_ : dans x1 qa1) (_ : chemin x2 e2 q2 d2 w2) (_ : dans x2 qd2) (_ : dans e2 qa2), chemin_A (union_disj q1 q2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) (couple e1 zero) (couple e2 un) (Append (cons e w) w2) *) apply chemin_chemin_A. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply chemin_extension_2 with qd2 qa2; auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply dans_trans with qd2; auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply automate_def2 with qa2 d2; auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) replace (couple e1 zero) with (injgauche e1); auto. (* Goal: dans (couple e1 zero) (union_disj q1 q2) *) (* Goal: dans (couple (couple e1 zero) (couple x (couple e zero))) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) *) unfold union_disj in |- *. (* Goal: dans (couple (couple e1 zero) (couple x (couple e zero))) (union (injg_d1 q1 d1) (injd_d2 q2 d2)) *) apply union_g. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply dans_map_inv; auto. (* Goal: dans (couple (couple e1 zero) (couple x (couple e zero))) (union (injg_d1 q1 d1) (injd_d2 q2 d2)) *) apply union_g. (* Goal: dans (couple (couple e1 zero) (couple epsilon (couple x2 un))) (pont qa1 qd2) *) (* Goal: forall (e : Elt) (w : Word) (_ : forall (e1 : Elt) (_ : automate q1 qd1 qa1 d1) (_ : automate q2 qd2 qa2 d2) (_ : chemin e1 x1 q1 d1 w) (_ : dans x1 qa1) (_ : chemin x2 e2 q2 d2 w2) (_ : dans x2 qd2) (_ : dans e2 qa2), chemin_A (union_disj q1 q2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) (couple e1 zero) (couple e2 un) (Append w w2)) (e1 : Elt) (_ : automate q1 qd1 qa1 d1) (_ : automate q2 qd2 qa2 d2) (_ : chemin e1 x1 q1 d1 (cons e w)) (_ : dans x1 qa1) (_ : chemin x2 e2 q2 d2 w2) (_ : dans x2 qd2) (_ : dans e2 qa2), chemin_A (union_disj q1 q2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) (couple e1 zero) (couple e2 un) (Append (cons e w) w2) *) unfold pont in |- *. (* Goal: dans (couple (couple e1 zero) (couple epsilon (couple x2 un))) (map transition_pont (prodcart qa1 qd2)) *) (* Goal: forall (e : Elt) (w : Word) (_ : forall (e1 : Elt) (_ : automate q1 qd1 qa1 d1) (_ : automate q2 qd2 qa2 d2) (_ : chemin e1 x1 q1 d1 w) (_ : dans x1 qa1) (_ : chemin x2 e2 q2 d2 w2) (_ : dans x2 qd2) (_ : dans e2 qa2), chemin_A (union_disj q1 q2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) (couple e1 zero) (couple e2 un) (Append w w2)) (e1 : Elt) (_ : automate q1 qd1 qa1 d1) (_ : automate q2 qd2 qa2 d2) (_ : chemin e1 x1 q1 d1 (cons e w)) (_ : dans x1 qa1) (_ : chemin x2 e2 q2 d2 w2) (_ : dans x2 qd2) (_ : dans e2 qa2), chemin_A (union_disj q1 q2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) (couple e1 zero) (couple e2 un) (Append (cons e w) w2) *) rewrite H6. replace (couple (couple x1 zero) (couple epsilon (couple x2 un))) with (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) (transition_pont (couple x1 x2)); auto. (* Goal: forall (e : Elt) (w : Word) (_ : forall (e1 : Elt) (_ : automate q1 qd1 qa1 d1) (_ : automate q2 qd2 qa2 d2) (_ : chemin e1 x1 q1 d1 w) (_ : dans x1 qa1) (_ : chemin x2 e2 q2 d2 w2) (_ : dans x2 qd2) (_ : dans e2 qa2), chemin_A (union_disj q1 q2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) (couple e1 zero) (couple e2 un) (Append w w2)) (e1 : Elt) (_ : automate q1 qd1 qa1 d1) (_ : automate q2 qd2 qa2 d2) (_ : chemin e1 x1 q1 d1 (cons e w)) (_ : dans x1 qa1) (_ : chemin x2 e2 q2 d2 w2) (_ : dans x2 qd2) (_ : dans e2 qa2), chemin_A (union_disj q1 q2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) (couple e1 zero) (couple e2 un) (Append (cons e w) w2) *) intros x w H e1 H0 H1 H2 H3 H4 H5 H6. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) replace (Append (cons x w) w2) with (cons x (Append w w2)); auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) cut (Chemin e1 x1 q1 d1 (cons x w)); auto. (* Goal: forall _ : Chemin e1 x1 q1 d1 (cons x w), chemin_A (union_disj q1 q2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) (couple e1 zero) (couple e2 un) (cons x (Append w w2)) *) intro H7. cut (exists e : Elt, chemin e x1 q1 d1 w /\ dans e1 q1 /\ dans x alph /\ dans (couple e1 (couple x e)) d1); (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) auto. intro Ht; elim Ht; clear Ht; intros e Ht; elim Ht; clear Ht; intros H8 Ht; elim Ht; clear Ht; intros H9 Ht; elim Ht; clear Ht; intros H10 H11. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply chemin_A_cons with (couple e zero); auto. (* Goal: dans (couple e1 zero) (union_disj q1 q2) *) (* Goal: dans (couple (couple e1 zero) (couple x (couple e zero))) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) *) unfold union_disj in |- *. (* Goal: dans (couple (couple e1 zero) (couple x (couple e zero))) (union (injg_d1 q1 d1) (injd_d2 q2 d2)) *) apply union_g. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) replace (couple e1 zero) with (injgauche e1); auto. (* Goal: dans (couple (couple e1 zero) (couple x (couple e zero))) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) *) apply union_d. (* Goal: dans (couple (couple e1 zero) (couple x (couple e zero))) (union (injg_d1 q1 d1) (injd_d2 q2 d2)) *) apply union_g. (* Goal: dans (couple (couple e1 zero) (couple x (couple e zero))) (injg_d1 q1 d1) *) unfold injg_d1 in |- *. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply imp_dans_tq; auto. (* Goal: dans (couple (couple e1 zero) (couple x (couple e zero))) (prodcart (map injgauche q1) (prodcart alph (map injgauche q1))) *) apply coupl2_inv. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) replace (couple e1 zero) with (injgauche e1); auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply coupl2_inv; auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) replace (couple e zero) with (injgauche e); auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply dans_map_inv; auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply dans_e1_q with d1 w x1; auto. Qed. (* Si l'automate 1 reconnait l1 et si l'automate 2 reconnait l2 *) (* alors l'automate ci-dessous reconnait l1.l2 . *) Lemma lconc_is_reg1 : forall (q1 qd1 qa1 d1 q2 qd2 qa2 d2 : Ensf) (l1 l2 : wordset), automate q1 qd1 qa1 d1 -> eqwordset (reconnait q1 qd1 qa1 d1) l1 -> automate q2 qd2 qa2 d2 -> eqwordset (reconnait q2 qd2 qa2 d2) l2 -> eqwordset (reconnait_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (lconc l1 l2). (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intros. unfold eqwordset in |- *. intro w. (* Goal: and (automate_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (eqwordset (reconnait_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (lconc l1 l2)) *) split. unfold reconnait_A in |- *. intro Ht; elim Ht; clear Ht. intros H3 Ht; elim Ht; clear Ht. intros e1 Ht; elim Ht; clear Ht. intros e2 Ht; elim Ht; clear Ht. intros H4 Ht; elim Ht; clear Ht. intros H5 H6. cut (exists x1 : Elt, (exists x2 : Elt, (exists w1 : Word, (exists w2 : Word, dans x1 qa1 /\ dans x2 qd2 /\ chemin (first e1) x1 q1 d1 w1 /\ chemin x2 (first e2) q2 d2 w2 /\ w = Append w1 w2 :>Word)))). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply par_le_pont with qd1 qa2; auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply dans_map_trans with qd1; auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply automate_def2 with qa1 d1; auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply dans_map_trans with qa2; auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply automate_def3 with qd2 d2; auto. intros Ht; elim Ht; clear Ht. intros x1 Ht; elim Ht; clear Ht. intros x2 Ht; elim Ht; clear Ht. intros w1 Ht; elim Ht; clear Ht. intros w2 Ht; elim Ht; clear Ht. intros H7 Ht; elim Ht; clear Ht. intros H8 Ht; elim Ht; clear Ht. intros H9 Ht; elim Ht; clear Ht. intros H10 H11. unfold lconc in |- *. exists w1. exists w2. (* Goal: and (automate_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (eqwordset (reconnait_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (lconc l1 l2)) *) split. unfold eqwordset in H0; elim (H0 w1). (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intros. apply H12. (* Goal: forall (w : Word) (e0 e a : Elt) (q qa d : Ensf) (_ : reconnait q (singleton e) qa d w) (_ : not (dans e0 q)) (_ : dans a alph), reconnait (add e0 q) (singleton e0) qa (add (couple e0 (couple a e)) d) (cons a w) *) unfold reconnait in |- *. (* Goal: and (automate_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (eqwordset (reconnait_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (lconc l1 l2)) *) split. apply Append_inmonoid_g with w2. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) rewrite <- H11; auto. exists (first e1). exists x1. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) split; auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply dans_map_injg; auto. (* Goal: and (automate_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (eqwordset (reconnait_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (lconc l1 l2)) *) split. unfold eqwordset in H2; elim (H2 w2). (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intros. apply H12. (* Goal: forall (w : Word) (e0 e a : Elt) (q qa d : Ensf) (_ : reconnait q (singleton e) qa d w) (_ : not (dans e0 q)) (_ : dans a alph), reconnait (add e0 q) (singleton e0) qa (add (couple e0 (couple a e)) d) (cons a w) *) unfold reconnait in |- *. (* Goal: and (automate_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (eqwordset (reconnait_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (lconc l1 l2)) *) split. apply Append_inmonoid_d with w1. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) rewrite <- H11; auto. exists x2. exists (first e2). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) split; auto. split; [ apply dans_map_injd; auto | auto ]. (* Goal: reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) (* Goal: forall _ : lword nil w, reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) assumption. unfold lconc in |- *. intro Ht; elim Ht; clear Ht. intros w1 Ht; elim Ht; clear Ht. intros w2 Ht; elim Ht; clear Ht. intros H3 Ht; elim Ht; clear Ht. (* Goal: forall (_ : dans x alph) (_ : dans (couple e1 (couple x e)) d), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intros H4 H5. cut (reconnait q1 qd1 qa1 d1 w1). 2: unfold eqwordset in H0. (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) 2: elim (H0 w1); intros. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: auto. intro H6. cut (reconnait q2 qd2 qa2 d2 w2). 2: unfold eqwordset in H2. (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) 2: elim (H2 w2); intros. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: auto. (* Goal: forall _ : Chemin e1 x1 q1 d1 (cons x w), chemin_A (union_disj q1 q2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) (couple e1 zero) (couple e2 un) (cons x (Append w w2)) *) intro H7. rewrite H5. elim H6. intros H8 Ht; elim Ht; clear Ht; intros e1 Ht; elim Ht; clear Ht; intros x1 Ht; elim Ht; clear Ht; intros H9 Ht; elim Ht; clear Ht; intros H10 H11. elim H7. intros H12 Ht; elim Ht; clear Ht; intros x2 Ht; elim Ht; clear Ht; intros e2 Ht; elim Ht; clear Ht; intros H13 Ht; elim Ht; clear Ht; intros H14 H15. unfold reconnait_A in |- *. (* Goal: and (automate_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (eqwordset (reconnait_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (lconc l1 l2)) *) split. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply inmonoid_Append; auto. exists (couple e1 zero). exists (couple e2 un). (* Goal: and (automate_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (eqwordset (reconnait_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (lconc l1 l2)) *) split. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) replace (couple e1 zero) with (injgauche e1); auto. (* Goal: and (automate_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (eqwordset (reconnait_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (lconc l1 l2)) *) split. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) replace (couple e2 un) with (injdroite e2); auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply reconnait_Append with qd1 qa2 x1 x2; auto. Qed. (* Si les langages l1 et l2 sont reguliers alors l1.l2 est aussi *) (* regulier. *) Lemma lconc_is_reg : forall l1 l2 : wordset, isregular l1 -> isregular l2 -> isregular (lconc l1 l2). (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intros. (* Goal: isregular (lconc l1 l2) *) unfold isregular in H. elim H; clear H. intros q1 H; elim H; clear H; intros qd1 H; elim H; clear H; intros qa1 H; elim H; clear H; intros d1 H; elim H; clear H. (* Goal: forall (_ : automate q1 qd1 qa1 d1) (_ : eqwordset (reconnait q1 qd1 qa1 d1) l1), isregular (lconc l1 l2) *) intros H_aut H_eq. (* Goal: isregular (lconc l1 l2) *) unfold isregular in H0. (* Goal: isregular (lconc l1 l2) *) elim H0; clear H0. intros q2 H0; elim H0; clear H0; intros qd2 H0; elim H0; clear H0; intros qa2 H0; elim H0; clear H0; intros d2 H0; elim H0; clear H0. (* Goal: forall (_ : automate q2 qd2 qa2 d2) (_ : eqwordset (reconnait q2 qd2 qa2 d2) l2), isregular (lconc l1 l2) *) intros H0_aut H0_eq. (* Goal: isregular (lconc l1 l2) *) apply isregular_A_isregular. (* Goal: isregular_A (lconc l1 l2) *) unfold isregular_A in |- *. (* Goal: @ex Ensf (fun q : Ensf => @ex Ensf (fun qd : Ensf => @ex Ensf (fun qa : Ensf => @ex Ensf (fun d : Ensf => and (automate_A q qd qa d) (eqwordset (reconnait_A q qd qa d) (lconc l1 l2)))))) *) exists (union_disj q1 q2). (* Goal: @ex Ensf (fun qd : Ensf => @ex Ensf (fun qa : Ensf => @ex Ensf (fun d : Ensf => and (automate_A (union_disj q1 q2) qd qa d) (eqwordset (reconnait_A (union_disj q1 q2) qd qa d) (lconc l1 l2))))) *) exists (map injgauche qd1). (* Goal: @ex Ensf (fun qa : Ensf => @ex Ensf (fun d : Ensf => and (automate_A (union_disj q1 q2) (map injgauche qd1) qa d) (eqwordset (reconnait_A (union_disj q1 q2) (map injgauche qd1) qa d) (lconc l1 l2)))) *) exists (map injdroite qa2). (* Goal: @ex Ensf (fun d : Ensf => and (automate_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) d) (eqwordset (reconnait_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) d) (lconc l1 l2))) *) exists (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))). (* Goal: and (automate_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (eqwordset (reconnait_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (lconc l1 l2)) *) split. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply automate_lconc_isgood; auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply lconc_is_reg1; auto. Qed. (************************************************************************) (* *) (* Si l est regulier alors l* est aussi regulier. *) (* *) (************************************************************************) Definition transition_back (g0 x : Elt) : Elt := couple x (couple epsilon g0). Definition delta (g0 : Elt) (qa : Ensf) : Ensf := map (transition_back g0) qa. Definition fun_d_dstar (g0 : Elt) (qa d : Ensf) : Ensf := union d (delta g0 qa). Lemma dstar_is_good : forall (q qa d : Ensf) (g0 : Elt), automate q (singleton g0) qa d -> inclus (fun_d_dstar g0 qa d) (prodcart q (prodcart (add epsilon alph) q)). (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intros. unfold fun_d_dstar in |- *. (* Goal: inclus (union (injg_d1 q1 d1) (injd_d2 q2 d2)) (prodcart (union_disj q1 q2) (prodcart alph (union_disj q1 q2))) *) apply union_inclus. cut (inclus d (prodcart q (prodcart alph q))). (* Goal: reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) (* Goal: forall _ : lword nil w, reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) 2: apply automate_def1 with (singleton g0) qa; assumption. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply inclus_trans with (prodcart q (prodcart alph q)); auto. unfold delta in |- *. unfold inclus in |- *. (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intros. cut (exists y : Elt, dans y qa /\ x = transition_back g0 y :>Elt). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply dans_map; auto. intro Ht; elim Ht; clear Ht; intros y Ht; elim Ht; clear Ht; intros H1 H2. rewrite H2. unfold transition_back in |- *. (* Goal: dans (couple (couple e1 zero) (couple x (couple e zero))) (prodcart (map injgauche q1) (prodcart alph (map injgauche q1))) *) apply coupl2_inv. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply dans_trans with qa; auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply automate_def3 with (singleton g0) d; auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply coupl2_inv; auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply dans_trans with (singleton g0); auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply automate_def2 with qa d; auto. Qed. (* *) (* Si on a une transition (e0,x,e) dans d* avec x dans alph alors *) (* cette transition est dans d. *) (* *) Lemma transition_dans_l : forall (q qa d : Ensf) (g0 e0 x e : Elt), automate q (singleton g0) qa d -> dans x alph -> dans (couple e0 (couple x e)) (fun_d_dstar g0 qa d) -> dans (couple e0 (couple x e)) d. intros q qa d g0 e0 x e H H0. unfold fun_d_dstar in |- *. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. cut (dans (couple e0 (couple x e)) d \/ (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) dans (couple e0 (couple x e)) (delta g0 qa)); auto. intro Ht; elim Ht; clear Ht. (* Goal: reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) (* Goal: forall _ : lword nil w, reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) intro; assumption. unfold delta in |- *. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. cut (exists y : Elt, dans y qa /\ couple e0 (couple x e) = transition_back g0 y :>Elt). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply dans_map; auto. (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intro Ht; elim Ht; clear Ht; intros y Ht; elim Ht; clear Ht; intros. unfold transition_back in H4. cut (e0 = y :>Elt /\ couple x e = couple epsilon g0 :>Elt). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply equal_couple; auto. (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intro Ht; elim Ht; clear Ht; intros. cut (x = epsilon :>Elt /\ e = g0 :>Elt). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply equal_couple; auto. (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intro Ht; elim Ht; clear Ht; intros. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) absurd (dans x alph); auto. rewrite H7. (* Goal: reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) (* Goal: forall _ : lword nil w, reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) red in |- *; intro; apply not_dans_epsilon_alph; assumption. Qed. (* *) (* Si on a une transition (e0,epsilon,e) dans d* alors on a *) (* e0 dans qa et e=g0. *) (* *) Lemma transition_par_epsilon : forall (q qa d : Ensf) (g0 e0 e : Elt), automate q (singleton g0) qa d -> dans (couple e0 (couple epsilon e)) (fun_d_dstar g0 qa d) -> dans e0 qa /\ e = g0 :>Elt. (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intros. unfold fun_d_dstar in H0. cut (dans (couple e0 (couple epsilon e)) d \/ dans (couple e0 (couple epsilon e)) (delta g0 qa)); (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) auto. intro Ht; elim Ht; clear Ht. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. cut (inclus d (prodcart q (prodcart alph q))). (* Goal: reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) (* Goal: forall _ : lword nil w, reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) 2: apply automate_def1 with (singleton g0) qa; assumption. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. cut (dans (couple e0 (couple epsilon e)) (prodcart q (prodcart alph q))). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply dans_trans with d; auto. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. cut (dans e0 q /\ dans (couple epsilon e) (prodcart alph q)). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply coupl2; auto. (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intro Ht; elim Ht; clear Ht; intros. cut (dans epsilon alph /\ dans e q). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply coupl2; auto. (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intro Ht; elim Ht; clear Ht; intros. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) absurd (dans epsilon alph); auto. (* Goal: reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) (* Goal: forall _ : lword nil w, reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) red in |- *; intro; apply not_dans_epsilon_alph; assumption. unfold delta in |- *. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. cut (exists y : Elt, dans y qa /\ couple e0 (couple epsilon e) = transition_back g0 y :>Elt). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply dans_map; auto. (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intro Ht; elim Ht; clear Ht; intros y Ht; elim Ht; clear Ht; intros. unfold transition_back in H3. cut (e0 = y :>Elt /\ couple epsilon e = couple epsilon g0 :>Elt). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply equal_couple; auto. (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intro Ht; elim Ht; clear Ht; intros. cut (epsilon = epsilon :>Elt /\ e = g0 :>Elt). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply equal_couple; auto. (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intro Ht; elim Ht; clear Ht; intros. rewrite H4. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) auto. Qed. (* *) (* Si on a un chemin de g0 a g0 dans A alors c'est par le mot nil. *) (* *) Lemma chemin_g0_g0 : forall (q qa d : Ensf) (g0 : Elt) (w0 : Word), automate q (singleton g0) qa d -> (forall e x : Elt, dans (couple g0 (couple x e)) d -> x = epsilon :>Elt) -> chemin g0 g0 q d w0 -> w0 = nil :>Word. intros q qa d g0 w0 H_aut H_g0. generalize w0; clear w0; simple induction w0. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) auto. intros x w H H0. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) cut (Chemin g0 g0 q d (cons x w)); auto. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. cut (exists e : Elt, chemin e g0 q d w /\ dans g0 q /\ dans x alph /\ dans (couple g0 (couple x e)) d); (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) auto. intro Ht; elim Ht; clear Ht; intros e Ht; elim Ht; clear Ht; intros H2 Ht; elim Ht; clear Ht; intros H3 Ht; elim Ht; clear Ht; (* Goal: forall (_ : dans x alph) (_ : dans (couple e1 (couple x e)) d), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intros H4 H5. cut (x = epsilon :>Elt). (* Goal: reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) (* Goal: forall _ : lword nil w, reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) 2: apply (H_g0 e x); assumption. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) absurd (dans x alph); auto. (* Goal: dans (couple (couple e1 zero) (couple epsilon (couple x2 un))) (map transition_pont (prodcart qa1 qd2)) *) (* Goal: forall (e : Elt) (w : Word) (_ : forall (e1 : Elt) (_ : automate q1 qd1 qa1 d1) (_ : automate q2 qd2 qa2 d2) (_ : chemin e1 x1 q1 d1 w) (_ : dans x1 qa1) (_ : chemin x2 e2 q2 d2 w2) (_ : dans x2 qd2) (_ : dans e2 qa2), chemin_A (union_disj q1 q2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) (couple e1 zero) (couple e2 un) (Append w w2)) (e1 : Elt) (_ : automate q1 qd1 qa1 d1) (_ : automate q2 qd2 qa2 d2) (_ : chemin e1 x1 q1 d1 (cons e w)) (_ : dans x1 qa1) (_ : chemin x2 e2 q2 d2 w2) (_ : dans x2 qd2) (_ : dans e2 qa2), chemin_A (union_disj q1 q2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) (couple e1 zero) (couple e2 un) (Append (cons e w) w2) *) rewrite H6. (* Goal: reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) (* Goal: forall _ : lword nil w, reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) red in |- *; intro; apply not_dans_epsilon_alph; assumption. Qed. (* *) (* Si on a un chemin dans A* de e1 a e2 par w alors : *) (* - soit on a une chemin dans A de e1 a e2 par w. *) (* - soit il existe un etat e et 2 mots w1 et w2 tels que on a *) (* un chemin de e1 a e par w1, e est dans qa, w2 est dans l* *) (* et w=w1.w2 *) (* *) Lemma lstar_is_reg2_bis : forall (q qa d : Ensf) (g0 e1 e2 : Elt) (w : Word) (l : wordset), automate q (singleton g0) qa d -> eqwordset (reconnait q (singleton g0) qa d) l -> (forall w : Word, chemin g0 g0 q d w -> w = nil :>Word) -> chemin_A q (fun_d_dstar g0 qa d) e1 e2 w -> e2 = g0 :>Elt -> chemin e1 e2 q d w \/ (exists e : Elt, (exists w1 : Word, (exists w2 : Word, chemin e1 e q d w1 /\ dans e qa /\ lstar l w2 /\ w = Append w1 w2 :>Word))). intros q qa d g0 e1 e2 w l H H_eq H_g0 H0. elim H0. (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intros. left. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply chemin_nil; auto. intros e0 e e3 x w0 H1 H2 H3 H4 H5 H6. cut (dans (couple e0 (couple x e)) d). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply transition_dans_l with q qa g0; auto. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. (* Goal: @ex Ensf (fun q : Ensf => @ex Ensf (fun qd : Ensf => @ex Ensf (fun qa : Ensf => @ex Ensf (fun d : Ensf => and (automate q qd qa d) (eqwordset (reconnait q qd qa d) (lunion l1 l2)))))) *) elim H2; clear H2. (* Goal: reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) (* Goal: forall _ : lword nil w, reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) 3: assumption. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. left. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply chemin_cons with e; auto. intro Ht; elim Ht; clear Ht; intros x1 Ht; elim Ht; clear Ht; intros w1 Ht; elim Ht; clear Ht; intros w2 Ht; elim Ht; clear Ht; intros H8 Ht; elim Ht; clear Ht; intros H9 Ht; elim Ht; clear Ht; intros H10 H11. right. exists x1. exists (cons x w1). exists w2. (* Goal: and (automate_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (eqwordset (reconnait_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (lconc l1 l2)) *) split. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply chemin_cons with e; auto. split; [ assumption | split ]. (* Goal: reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) (* Goal: forall _ : lword nil w, reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) assumption. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) replace (Append (cons x w1) w2) with (cons x (Append w1 w2)); auto. intros e0 e e3 w0 H1 H2 H3 H4 H5. right. cut (dans e0 qa /\ e = g0 :>Elt). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply transition_par_epsilon with q d; auto. (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intro Ht; elim Ht; clear Ht; intros. (* Goal: @ex Ensf (fun q : Ensf => @ex Ensf (fun qd : Ensf => @ex Ensf (fun qa : Ensf => @ex Ensf (fun d : Ensf => and (automate q qd qa d) (eqwordset (reconnait q qd qa d) (lunion l1 l2)))))) *) elim H2; clear H2. (* Goal: reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) (* Goal: forall _ : lword nil w, reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) 3: assumption. rewrite H7. rewrite H5. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. cut (w0 = nil :>Word). (* Goal: reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) (* Goal: forall _ : lword nil w, reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) 2: apply (H_g0 w0); assumption. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. (* Goal: @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 (singleton e0)) (and (dans e2 qa) (chemin e1 e2 (add e0 q) (add (couple e0 (couple a e)) d) (cons a w))))) *) exists e0. exists nil. exists nil. (* Goal: and (automate_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (eqwordset (reconnait_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (lconc l1 l2)) *) split. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply chemin_nil; auto. split; [ assumption | split ]. unfold lstar in |- *. exists 0. unfold lpuiss in |- *. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) unfold lword in |- *; auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) rewrite H8; auto. intro Ht; elim Ht; clear Ht; intros x1 Ht; elim Ht; clear Ht; intros w1 Ht; elim Ht; clear Ht; intros w2 Ht; elim Ht; clear Ht; intros H8 Ht; elim Ht; clear Ht; intros H9 Ht; elim Ht; clear Ht; intros H10 H11. (* Goal: @ex Elt (fun e1 : Elt => @ex Elt (fun e2 : Elt => and (dans e1 (singleton e0)) (and (dans e2 qa) (chemin e1 e2 (add e0 q) (add (couple e0 (couple a e)) d) (cons a w))))) *) exists e0. exists nil. exists (Append w1 w2). (* Goal: and (automate_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (eqwordset (reconnait_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (lconc l1 l2)) *) split. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply chemin_nil; auto. split; [ assumption | split ]. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: replace (Append nil (Append w1 w2)) with (Append w1 w2); auto. elim H10. intros n H12. unfold lstar in |- *. exists (S n). change (lconc l (lpuiss n l) (Append w1 w2)) in |- *. unfold lconc in |- *. exists w1. exists w2. (* Goal: and (automate_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (eqwordset (reconnait_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (lconc l1 l2)) *) split. 2: split; [ assumption | auto ]. unfold eqwordset in H_eq. (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) elim (H_eq w1); intros. apply H2. (* Goal: forall (w : Word) (e0 e a : Elt) (q qa d : Ensf) (_ : reconnait q (singleton e) qa d w) (_ : not (dans e0 q)) (_ : dans a alph), reconnait (add e0 q) (singleton e0) qa (add (couple e0 (couple a e)) d) (cons a w) *) unfold reconnait in |- *. (* Goal: and (automate_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (eqwordset (reconnait_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (lconc l1 l2)) *) split. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply (Cheminmonoid w1 q (singleton g0) qa d H e x1 H8); auto. exists e. exists x1. split; [ rewrite H7; auto | split; [ assumption | assumption ] ]. Qed. (* *) (* On montre ici que si l'automate A* reconnait w alors w est dans l* *) (* *) Lemma lstar_is_reg1 : forall (q qa d : Ensf) (l : wordset) (g0 : Elt) (w : Word), automate q (singleton g0) qa d -> (forall w : Word, chemin g0 g0 q d w -> w = nil :>Word) -> eqwordset (reconnait q (singleton g0) qa d) l -> reconnait_A q (singleton g0) (singleton g0) (fun_d_dstar g0 qa d) w -> lstar l w. (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intros. elim H2; clear H2; intros H2 Ht; elim Ht; clear Ht; intros e1 Ht; elim Ht; clear Ht; intros e2 Ht; elim Ht; clear Ht; intros H3 Ht; (* Goal: forall (_ : dans x alph) (_ : dans (couple e1 (couple x e)) d), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) elim Ht; clear Ht; intros H4 H5. cut (chemin e1 e2 q d w \/ (exists e : Elt, (exists w1 : Word, (exists w2 : Word, chemin e1 e q d w1 /\ dans e qa /\ lstar l w2 /\ w = Append w1 w2 :>Word)))). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply lstar_is_reg2_bis with g0; auto. intro Ht; elim Ht; clear Ht. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) cut (e1 = g0 :>Elt); auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) cut (e2 = g0 :>Elt); auto. (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intros. cut (chemin g0 g0 q d w). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: cut (chemin e1 e2 q d w); auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: rewrite H7; rewrite H8; auto. (* Goal: forall _ : Chemin e1 e2 q d (cons x w0), chemin e1 e2 (add e0 q) (add (couple e0 (couple a e3)) d) (cons x w0) *) intro. cut (w = nil :>Word). (* Goal: reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) (* Goal: forall _ : lword nil w, reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) 2: apply (H0 w); assumption. intro H10. rewrite H10. unfold lstar in |- *. exists 0. unfold lpuiss in |- *. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) unfold lword in |- *; auto. intro Ht; elim Ht; clear Ht; intros e Ht; elim Ht; clear Ht; intros w1 Ht; elim Ht; clear Ht; intros w2 Ht; elim Ht; clear Ht; intros H6 Ht; elim Ht; clear Ht; intros H7 Ht; elim Ht; clear Ht; intros H8 H9. elim H8. intros n H10. unfold lstar in |- *. exists (S n). change (lconc l (lpuiss n l) w) in |- *. unfold lconc in |- *. exists w1. exists w2. (* Goal: and (automate_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (eqwordset (reconnait_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (lconc l1 l2)) *) split. 2: split; [ assumption | assumption ]. unfold eqwordset in H1. (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) elim (H1 w1); intros. apply H11. (* Goal: forall (w : Word) (e0 e a : Elt) (q qa d : Ensf) (_ : reconnait q (singleton e) qa d w) (_ : not (dans e0 q)) (_ : dans a alph), reconnait (add e0 q) (singleton e0) qa (add (couple e0 (couple a e)) d) (cons a w) *) unfold reconnait in |- *. (* Goal: and (automate_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (eqwordset (reconnait_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (lconc l1 l2)) *) split. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply (Cheminmonoid w1 q (singleton g0) qa d H e1 e H6); auto. exists e1. exists e. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) auto. Qed. (* *) (* Et enfin le resultat : si l est regulier alors l* l'est aussi. *) (* *) Lemma lstar_is_reg : forall l : wordset, isregular l -> isregular (lstar l). intros l H. cut (isregular_D l). (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) 2: apply isregular_isregular_D; auto. clear H; intro H; elim H; clear H. intros q H; elim H; clear H; intros g0 H; elim H; clear H; intros qa H; elim H; clear H; intros d H; elim H; clear H. intros H_aut Ht; elim Ht; clear Ht; intros H_g0 H_eq. (* Goal: isregular (lconc l1 l2) *) apply isregular_A_isregular. (* Goal: isregular_A (lconc l1 l2) *) unfold isregular_A in |- *. exists q. exists (singleton g0). exists (singleton g0). exists (fun_d_dstar g0 qa d). (* Goal: and (automate_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (eqwordset (reconnait_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (lconc l1 l2)) *) split. (* Goal: automate (union_disj q1 q2) (union_disj qd1 qd2) (union_disj qa1 qa2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)) *) (* Goal: eqwordset (reconnait (union_disj q1 q2) (union_disj qd1 qd2) (union_disj qa1 qa2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) (lunion l1 l2) *) red in |- *. elim H_aut. intros H0 H1; elim H1; clear H1; intros H1 H2. split; [ assumption | split ]. (* Goal: reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) (* Goal: forall _ : lword nil w, reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) assumption. (* Goal: reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) (* Goal: forall _ : lword nil w, reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) apply dstar_is_good; assumption. unfold eqwordset in |- *. intro w. (* Goal: and (automate_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (eqwordset (reconnait_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (lconc l1 l2)) *) split. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) intro; apply lstar_is_reg1 with q qa d g0; auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) intro; pattern w in |- *; apply induction_star with l; auto. simple induction n. unfold lpuiss in |- *. unfold lword in |- *. (* Goal: forall (l1 l2 : wordset) (_ : isregular l1) (_ : isregular l2), isregular (lconc l1 l2) *) intros. rewrite <- H0. unfold reconnait_A in |- *. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) split; auto. exists g0. exists g0. split; [ auto | split ]. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply chemin_A_nil; auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply dans_trans with (singleton g0); auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply automate_def2 with qa d; auto. intros y H1 w0. change (lconc l (lpuiss y l) w0 -> reconnait_A q (singleton g0) (singleton g0) (fun_d_dstar g0 qa d) w0) in |- *. unfold lconc in |- *. intros Ht; elim Ht; clear Ht; intros w1 Ht; elim Ht; clear Ht; intros w2 Ht; elim Ht; clear Ht; intros H2 Ht; elim Ht; clear Ht; intros H3 H4. cut (reconnait_A q (singleton g0) (singleton g0) (fun_d_dstar g0 qa d) w2); (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) auto. intro H5. unfold eqwordset in H_eq. elim (H_eq w1); intros H6 H7. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) cut (reconnait q (singleton g0) qa d w1); auto. intro H8. clear H6 H7 H1 H_eq. elim H8; clear H8; intros H8 Ht; elim Ht; clear Ht; intros e1 Ht; elim Ht; clear Ht; intros e2 Ht; elim Ht; clear Ht; intros H9 Ht; elim Ht; clear Ht; intros H10 H11. elim H5; clear H5; intros H12 Ht; elim Ht; clear Ht; intros e3 Ht; elim Ht; clear Ht; intros e4 Ht; elim Ht; clear Ht; intros H13 Ht; elim Ht; clear Ht; intros H14 H15. unfold reconnait_A in |- *. (* Goal: and (automate_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (eqwordset (reconnait_A (union_disj q1 q2) (map injgauche qd1) (map injdroite qa2) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2)))) (lconc l1 l2)) *) split. rewrite H4. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply inmonoid_Append; auto. exists e1. exists e4. split; [ assumption | split ]. (* Goal: reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) (* Goal: forall _ : lword nil w, reconnait (singleton zero) (singleton zero) (singleton zero) (prodcart empty (prodcart alph empty)) w *) assumption. rewrite H4. apply chemin_Append with e2. apply chemin_A_d1_d2 with d. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply chemin_chemin_A; auto. unfold fun_d_dstar in |- *. apply inclus_g. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply chemin_A_epsilon with e3; auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply dans_trans with qa; auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) apply automate_def3 with (singleton g0) d; auto. unfold fun_d_dstar in |- *. (* Goal: dans (couple (couple e1 zero) (couple x (couple e zero))) (union (pont qa1 qd2) (union (injg_d1 q1 d1) (injd_d2 q2 d2))) *) apply union_d. unfold delta in |- *. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) cut (e3 = g0 :>Elt); auto. intro H16. rewrite H16. replace (couple e2 (couple epsilon g0)) with (transition_back g0 e2); (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) auto. Qed. (************************************************************************) (* *) (* LE RESULTAT FINAL : *) (* Tout langage rationnel est regulier. *) (* *) (************************************************************************) Lemma rat_is_reg : forall L : wordset, isrationnal L -> isregular L. (* Goal: forall (L : wordset) (_ : isrationnal L), isregular L *) intros L H. (* Goal: isregular L *) elim H. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) intros; apply lword_is_reg; auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) intros; apply lunion_is_reg; auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) intros; apply lconc_is_reg; auto. (* Goal: inclus (prodcart (map injdroite q2) (prodcart alph (map injdroite q2))) (prodcart (union (map injgauche q1) (map injdroite q2)) (prodcart alph (union (map injgauche q1) (map injdroite q2)))) *) intros; apply lstar_is_reg; auto. Qed.
(* This program is free software; you can redistribute it and/or *) (* modify it under the terms of the GNU Lesser General Public License *) (* as published by the Free Software Foundation; either version 2.1 *) (* of the License, or (at your option) any later version. *) (* *) (* This program is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* GNU General Public License for more details. *) (* *) (* You should have received a copy of the GNU Lesser General Public *) (* License along with this program; if not, write to the Free *) (* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *) (* 02110-1301 USA *) (* Contribution to the Coq Library V6.3 (July 1999) *) (****************************************************************************) (* The Calculus of Inductive Constructions *) (* *) (* Projet Coq *) (* *) (* INRIA ENS-CNRS *) (* Rocquencourt Lyon *) (* *) (* Coq V5.10 *) (* Nov 25th 1994 *) (* *) (****************************************************************************) (* gram_g.v *) (****************************************************************************) (* Formal Language Theory *) (* *) (* Judicael Courant - Jean-Christophe Filliatre *) (* *) (* Developped in V5.8 June-July 1993 *) (* Ported to V5.10 October 1994 *) (****************************************************************************) Require Import Ensf. Require Import Words. Require Import fonctions. Require Import Relations. Require Import gram. Inductive Deriveg (X R : Ensf) : Word -> Word -> Prop := | Deriveg1 : forall (u v : Word) (A : Elt), dans (couple A (word u)) R -> Deriveg X R (cons A v) (Append u v) | Deriveg2 : forall (u v : Word) (x : Elt), dans x X -> Deriveg X R u v -> Deriveg X R (cons x u) (cons x v). Hint Resolve Deriveg1. Hint Resolve Deriveg2. Definition Derivegstar (X R : Ensf) := Rstar Word (Deriveg X R). Lemma Deriveg_Derive : forall (X R : Ensf) (u v : Word), Deriveg X R u v -> Derive R u v. (* Goal: forall (X R : Ensf) (u v : Word) (_ : Deriveg X R u v), Derive R u v *) intros X R u v Der_g. (* Goal: Derive R u v *) elim Der_g. (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : Derive R u v), Derive R (cons x u) (cons x v) *) intros. (* Goal: Derive R (cons A v0) (Append u0 v0) *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : Derive R u v), Derive R (cons x u) (cons x v) *) apply Derive1; auto. (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : Derive R u v), Derive R (cons x u) (cons x v) *) intros. (* Goal: Derive R (cons x u0) (cons x v0) *) apply Derive2; auto. Qed. Lemma Derivegstar_Derivestar : forall (X R : Ensf) (u v : Word), Derivegstar X R u v -> Derivestar R u v. (* Goal: forall (X R : Ensf) (u v : Word) (_ : Derivegstar X R u v), Derivestar R u v *) unfold Derivegstar, Rstar, Derivestar in |- *. (* Goal: forall (X R : Ensf) (u v : Word) (_ : forall (P : forall (_ : Word) (_ : Word), Prop) (_ : forall u0 : Word, P u0 u0) (_ : forall (u0 v0 w : Word) (_ : Deriveg X R u0 v0) (_ : P v0 w), P u0 w), P u v), Rstar Word (Derive R) u v *) intros X R x y Derivegstar_x_y. (* Goal: Rstar Word (Derive R) x y *) pattern x, y in |- *. (* Goal: (fun w w0 : Word => Rstar Word (Derive R) w w0) x y *) apply Derivegstar_x_y. (* Goal: forall u : Word, Rstar Word (Derive R) u u *) (* Goal: forall (u v w : Word) (_ : Deriveg X R u v) (_ : Rstar Word (Derive R) v w), Rstar Word (Derive R) u w *) intro. apply Rstar_reflexive. (* Goal: forall (u v w : Word) (_ : Deriveg X R u v) (_ : Rstar Word (Derive R) v w), Rstar Word (Derive R) u w *) intros u v w Der Der_star. (* Goal: Rstar Word (Derive R) u w *) apply Rstar_R with v. (* Goal: Derive R u v *) (* Goal: Rstar Word (Derive R) v w *) apply Deriveg_Derive with X; assumption. (* Goal: Rstar Word (Derive R) v w *) assumption. Qed. Axiom Derivestar_Derivegstar : forall (X R : Ensf) (u v : Word), Derivestar R u v -> Derivegstar X R u v. Hint Resolve Derivestar_Derivegstar.
(* This program is free software; you can redistribute it and/or *) (* modify it under the terms of the GNU Lesser General Public License *) (* as published by the Free Software Foundation; either version 2.1 *) (* of the License, or (at your option) any later version. *) (* *) (* This program is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* GNU General Public License for more details. *) (* *) (* You should have received a copy of the GNU Lesser General Public *) (* License along with this program; if not, write to the Free *) (* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *) (* 02110-1301 USA *) (* Contribution to the Coq Library V6.3 (July 1999) *) (****************************************************************************) (* The Calculus of Inductive Constructions *) (* *) (* Projet Coq *) (* *) (* INRIA ENS-CNRS *) (* Rocquencourt Lyon *) (* *) (* Coq V5.10 *) (* Nov 25th 1994 *) (* *) (****************************************************************************) (* gram_aut.v *) (****************************************************************************) (* Formal Language Theory *) (* *) (* Judicael Courant - Jean-Christophe Filliatre *) (* *) (* Developped in V5.8 June-July 1993 *) (* Ported to V5.10 October 1994 *) (****************************************************************************) Require Import Ensf. Require Import Words. Require Import more_words. Require Import need. Require Import Relations. Require Import gram. Require Import gram_g. Require Import PushdownAutomata. Section APD. Variable X V R : Ensf. Variable S' : Elt. Hypothesis Gram : isGram X V R S'. Lemma Regles_X_V_R : Regles X V R. (* Goal: Regles X V R *) (* Goal: dans (couple A (word u)) R *) (* Goal: dans A X *) (* Goal: @eq Word (Append a b) (cons A v) *) (* Goal: inmonoid X a *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : @ex2 Word (fun w : Word => @eq Word (Append (cut1 u) w) v) (fun w : Word => Deriveg X R (cut2 u) w)), @ex2 Word (fun w : Word => @eq Word (Append (cut1 (cons x u)) w) (cons x v)) (fun w : Word => Deriveg X R (cut2 (cons x u)) w) *) apply isGram4 with S'. (* Goal: isGram X V R S' *) (* Goal: dans x0 X *) (* Goal: dans x0 V *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : forall (u0 v0 : Word) (_ : @eq Word (Append u0 v0) u) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) v) (fun w : Word => Deriveg X R v0 w)) (u0 v0 : Word) (_ : @eq Word (Append u0 v0) (cons x u)) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) (cons x v)) (fun w : Word => Deriveg X R v0 w) *) exact Gram. Qed. Let P := union X V. Let f_R_d (a : Elt) := couple (word (cons (first a) nil)) (couple (eps X) (second a)). Let f_X_d (x : Elt) := couple (word (cons x nil)) (couple x (word nil)). Let d := union (map f_R_d R) (map f_X_d X). Let wd := cons S' nil. Let wa := nil. Lemma Trans : Transition X P d. (* Goal: l_egal (LA X wd wa d) (LG X V R S') *) red in |- *. (* Goal: forall (x : Elt) (_ : dans x d), @ex2 Word (fun w1 : Word => inmonoid P w1) (fun w1 : Word => @ex2 Elt (fun y : Elt => dans y (add (eps X) X)) (fun y : Elt => @ex2 Word (fun w2 : Word => inmonoid P w2) (fun w2 : Word => @eq Elt x (couple (word w1) (couple y (word w2)))))) *) intros x dans_x_d. (* Goal: @ex2 Word (fun w1 : Word => inmonoid P w1) (fun w1 : Word => @ex2 Elt (fun y : Elt => dans y (add (eps X) X)) (fun y : Elt => @ex2 Word (fun w2 : Word => inmonoid P w2) (fun w2 : Word => @eq Elt x (couple (word w1) (couple y (word w2)))))) *) elimtype (dans x (map f_R_d R) \/ dans x (map f_X_d X)). (* Goal: forall _ : dans x (map f_X_d X), @ex2 Word (fun w1 : Word => inmonoid P w1) (fun w1 : Word => @ex2 Elt (fun y : Elt => dans y (add (eps X) X)) (fun y : Elt => @ex2 Word (fun w2 : Word => inmonoid P w2) (fun w2 : Word => @eq Elt x (couple (word w1) (couple y (word w2)))))) *) (* Goal: or (dans x (map f_R_d R)) (dans x (map f_X_d X)) *) intros dans_x. (* Goal: @ex2 Word (fun w1 : Word => inmonoid P w1) (fun w1 : Word => @ex2 Elt (fun y : Elt => dans y (add (eps X) X)) (fun y : Elt => @ex2 Word (fun w2 : Word => inmonoid P w2) (fun w2 : Word => @eq Elt x (couple (word w1) (couple y (word w2)))))) *) (* Goal: forall _ : dans x (map f_X_d X), @ex2 Word (fun w1 : Word => inmonoid P w1) (fun w1 : Word => @ex2 Elt (fun y : Elt => dans y (add (eps X) X)) (fun y : Elt => @ex2 Word (fun w2 : Word => inmonoid P w2) (fun w2 : Word => @eq Elt x (couple (word w1) (couple y (word w2)))))) *) (* Goal: or (dans x (map f_R_d R)) (dans x (map f_X_d X)) *) elimtype (exists y : Elt, dans y R /\ x = f_R_d y). (* Goal: forall (x0 : Elt) (_ : and (dans x0 X) (@eq Elt x (f_X_d x0))), @ex2 Word (fun w1 : Word => inmonoid P w1) (fun w1 : Word => @ex2 Elt (fun y : Elt => dans y (add (eps X) X)) (fun y : Elt => @ex2 Word (fun w2 : Word => inmonoid P w2) (fun w2 : Word => @eq Elt x (couple (word w1) (couple y (word w2)))))) *) (* Goal: @ex Elt (fun y : Elt => and (dans y X) (@eq Elt x (f_X_d y))) *) (* Goal: or (dans x (map f_R_d R)) (dans x (map f_X_d X)) *) intros y temp; elim temp; clear temp. (* Goal: forall _ : @eq Elt (couple (word w1) (couple x0 (word w2))) (f_R_d r), @eq Elt x0 (eps X) *) (* Goal: @ex Elt (fun r : Elt => and (dans r R) (@eq Elt (couple (word w1) (couple x0 (word w2))) (f_R_d r))) *) (* Goal: forall _ : dans (couple (word w1) (couple x0 (word w2))) (map f_X_d X), Derive_P_A_2 (@pair Word Word (Append w1 w) (cons x0 u)) (@pair Word Word (Append w2 w) u) *) (* Goal: or (dans (couple (word w1) (couple x0 (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple x0 (word w2))) (map f_X_d X)) *) (* Goal: forall (w w1 w2 u : Word) (_ : dans (couple (word w1) (couple (eps X) (word w2))) (union (map f_R_d R) (map f_X_d X))), Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) unfold f_R_d in |- *. (* Goal: forall (_ : dans y R) (_ : @eq Elt x (couple (word (cons (first y) nil)) (couple (eps X) (second y)))), @ex2 Word (fun w1 : Word => inmonoid P w1) (fun w1 : Word => @ex2 Elt (fun y : Elt => dans y (add (eps X) X)) (fun y : Elt => @ex2 Word (fun w2 : Word => inmonoid P w2) (fun w2 : Word => @eq Elt x (couple (word w1) (couple y (word w2)))))) *) (* Goal: @ex Elt (fun y : Elt => and (dans y R) (@eq Elt x (f_R_d y))) *) (* Goal: forall _ : dans x (map f_X_d X), @ex2 Word (fun w1 : Word => inmonoid P w1) (fun w1 : Word => @ex2 Elt (fun y : Elt => dans y (add (eps X) X)) (fun y : Elt => @ex2 Word (fun w2 : Word => inmonoid P w2) (fun w2 : Word => @eq Elt x (couple (word w1) (couple y (word w2)))))) *) (* Goal: or (dans x (map f_R_d R)) (dans x (map f_X_d X)) *) intros dans_y_R eg_x_f_y. (* Goal: @ex2 Word (fun w1 : Word => inmonoid P w1) (fun w1 : Word => @ex2 Elt (fun y : Elt => dans y (add (eps X) X)) (fun y : Elt => @ex2 Word (fun w2 : Word => inmonoid P w2) (fun w2 : Word => @eq Elt x (couple (word w1) (couple y (word w2)))))) *) (* Goal: @ex Elt (fun y : Elt => and (dans y R) (@eq Elt x (f_R_d y))) *) (* Goal: forall _ : dans x (map f_X_d X), @ex2 Word (fun w1 : Word => inmonoid P w1) (fun w1 : Word => @ex2 Elt (fun y : Elt => dans y (add (eps X) X)) (fun y : Elt => @ex2 Word (fun w2 : Word => inmonoid P w2) (fun w2 : Word => @eq Elt x (couple (word w1) (couple y (word w2)))))) *) (* Goal: or (dans x (map f_R_d R)) (dans x (map f_X_d X)) *) exists (cons (first y) nil). (* Goal: inmonoid P (cons S' nil) *) (* Goal: and (inmonoid P wa) (Transition X P d) *) apply inmonoid_cons. (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) trivial. (* Goal: @eq Elt x (couple (word (cons (first y) nil)) (couple (eps X) (word (word_inv (second y))))) *) (* Goal: @ex Elt (fun y : Elt => and (dans y R) (@eq Elt x (f_R_d y))) *) (* Goal: forall _ : dans x (map f_X_d X), @ex2 Word (fun w1 : Word => inmonoid P w1) (fun w1 : Word => @ex2 Elt (fun y : Elt => dans y (add (eps X) X)) (fun y : Elt => @ex2 Word (fun w2 : Word => inmonoid P w2) (fun w2 : Word => @eq Elt x (couple (word w1) (couple y (word w2)))))) *) (* Goal: or (dans x (map f_R_d R)) (dans x (map f_X_d X)) *) elim (Regles_X_V_R y dans_y_R). (* Goal: forall (x0 : Elt) (_ : dans x0 V) (_ : @ex2 Word (fun B : Word => @eq Elt y (couple x0 (word B))) (fun B : Word => inmonoid (union X V) B)), @eq Elt x (couple (word (cons (first y) nil)) (couple (eps X) (word (word_inv (second y))))) *) (* Goal: @ex Elt (fun y : Elt => and (dans y R) (@eq Elt x (f_R_d y))) *) (* Goal: forall _ : dans x (map f_X_d X), @ex2 Word (fun w1 : Word => inmonoid P w1) (fun w1 : Word => @ex2 Elt (fun y : Elt => dans y (add (eps X) X)) (fun y : Elt => @ex2 Word (fun w2 : Word => inmonoid P w2) (fun w2 : Word => @eq Elt x (couple (word w1) (couple y (word w2)))))) *) (* Goal: or (dans x (map f_R_d R)) (dans x (map f_X_d X)) *) intros f_y dans_f_y_V temp; elim temp; clear temp. (* Goal: forall (x0 : Word) (_ : @eq Elt y (couple f_y (word x0))) (_ : inmonoid (union X V) x0), @eq Elt x (couple (word (cons (first y) nil)) (couple (eps X) (word (word_inv (second y))))) *) (* Goal: @ex Elt (fun y : Elt => and (dans y R) (@eq Elt x (f_R_d y))) *) (* Goal: forall _ : dans x (map f_X_d X), @ex2 Word (fun w1 : Word => inmonoid P w1) (fun w1 : Word => @ex2 Elt (fun y : Elt => dans y (add (eps X) X)) (fun y : Elt => @ex2 Word (fun w2 : Word => inmonoid P w2) (fun w2 : Word => @eq Elt x (couple (word w1) (couple y (word w2)))))) *) (* Goal: or (dans x (map f_R_d R)) (dans x (map f_X_d X)) *) intros u eg_y inmono_u. (* Goal: @eq Elt (word u) (second y) *) (* Goal: @ex Elt (fun y : Elt => and (dans y R) (@eq Elt x (f_R_d y))) *) (* Goal: forall _ : dans x (map f_X_d X), @ex2 Word (fun w1 : Word => inmonoid P w1) (fun w1 : Word => @ex2 Elt (fun y : Elt => dans y (add (eps X) X)) (fun y : Elt => @ex2 Word (fun w2 : Word => inmonoid P w2) (fun w2 : Word => @eq Elt x (couple (word w1) (couple y (word w2)))))) *) (* Goal: or (dans x (map f_R_d R)) (dans x (map f_X_d X)) *) rewrite eg_y. (* Goal: dans (first (couple f_y (word u))) P *) (* Goal: @ex2 Elt (fun y : Elt => dans y (add (eps X) X)) (fun y0 : Elt => @ex2 Word (fun w2 : Word => inmonoid P w2) (fun w2 : Word => @eq Elt x (couple (word (cons (first y) nil)) (couple y0 (word w2))))) *) (* Goal: @ex Elt (fun y : Elt => and (dans y R) (@eq Elt x (f_R_d y))) *) (* Goal: forall _ : dans x (map f_X_d X), @ex2 Word (fun w1 : Word => inmonoid P w1) (fun w1 : Word => @ex2 Elt (fun y : Elt => dans y (add (eps X) X)) (fun y : Elt => @ex2 Word (fun w2 : Word => inmonoid P w2) (fun w2 : Word => @eq Elt x (couple (word w1) (couple y (word w2)))))) *) (* Goal: or (dans x (map f_R_d R)) (dans x (map f_X_d X)) *) unfold first in |- *. (* Goal: dans S' P *) (* Goal: and (inmonoid P wa) (Transition X P d) *) unfold P in |- *. (* Goal: and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) auto. (* Goal: @ex2 Elt (fun y : Elt => dans y (add (eps X) X)) (fun y0 : Elt => @ex2 Word (fun w2 : Word => inmonoid P w2) (fun w2 : Word => @eq Elt x (couple (word (cons (first y) nil)) (couple y0 (word w2))))) *) (* Goal: @ex Elt (fun y : Elt => and (dans y R) (@eq Elt x (f_R_d y))) *) (* Goal: forall _ : dans x (map f_X_d X), @ex2 Word (fun w1 : Word => inmonoid P w1) (fun w1 : Word => @ex2 Elt (fun y : Elt => dans y (add (eps X) X)) (fun y : Elt => @ex2 Word (fun w2 : Word => inmonoid P w2) (fun w2 : Word => @eq Elt x (couple (word w1) (couple y (word w2)))))) *) (* Goal: or (dans x (map f_R_d R)) (dans x (map f_X_d X)) *) exists (eps X). (* Goal: and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) auto. (* Goal: @ex2 Word (fun w2 : Word => inmonoid P w2) (fun w2 : Word => @eq Elt x (couple (word (cons (first y) nil)) (couple (eps X) (word w2)))) *) (* Goal: @ex Elt (fun y : Elt => and (dans y R) (@eq Elt x (f_R_d y))) *) (* Goal: forall _ : dans x (map f_X_d X), @ex2 Word (fun w1 : Word => inmonoid P w1) (fun w1 : Word => @ex2 Elt (fun y : Elt => dans y (add (eps X) X)) (fun y : Elt => @ex2 Word (fun w2 : Word => inmonoid P w2) (fun w2 : Word => @eq Elt x (couple (word w1) (couple y (word w2)))))) *) (* Goal: or (dans x (map f_R_d R)) (dans x (map f_X_d X)) *) exists (word_inv (second y)). (* Goal: @eq Elt x (couple (word (cons (first y) nil)) (couple (eps X) (word (word_inv (second y))))) *) (* Goal: @ex Elt (fun y : Elt => and (dans y R) (@eq Elt x (f_R_d y))) *) (* Goal: forall _ : dans x (map f_X_d X), @ex2 Word (fun w1 : Word => inmonoid P w1) (fun w1 : Word => @ex2 Elt (fun y : Elt => dans y (add (eps X) X)) (fun y : Elt => @ex2 Word (fun w2 : Word => inmonoid P w2) (fun w2 : Word => @eq Elt x (couple (word w1) (couple y (word w2)))))) *) (* Goal: or (dans x (map f_R_d R)) (dans x (map f_X_d X)) *) elim (Regles_X_V_R y dans_y_R). (* Goal: forall (x0 : Elt) (_ : dans x0 V) (_ : @ex2 Word (fun B : Word => @eq Elt y (couple x0 (word B))) (fun B : Word => inmonoid (union X V) B)), @eq Elt x (couple (word (cons (first y) nil)) (couple (eps X) (word (word_inv (second y))))) *) (* Goal: @ex Elt (fun y : Elt => and (dans y R) (@eq Elt x (f_R_d y))) *) (* Goal: forall _ : dans x (map f_X_d X), @ex2 Word (fun w1 : Word => inmonoid P w1) (fun w1 : Word => @ex2 Elt (fun y : Elt => dans y (add (eps X) X)) (fun y : Elt => @ex2 Word (fun w2 : Word => inmonoid P w2) (fun w2 : Word => @eq Elt x (couple (word w1) (couple y (word w2)))))) *) (* Goal: or (dans x (map f_R_d R)) (dans x (map f_X_d X)) *) intros f_y dans_f_y_V temp; elim temp; clear temp. (* Goal: forall (x0 : Word) (_ : @eq Elt y (couple f_y (word x0))) (_ : inmonoid (union X V) x0), @eq Elt x (couple (word (cons (first y) nil)) (couple (eps X) (word (word_inv (second y))))) *) (* Goal: @ex Elt (fun y : Elt => and (dans y R) (@eq Elt x (f_R_d y))) *) (* Goal: forall _ : dans x (map f_X_d X), @ex2 Word (fun w1 : Word => inmonoid P w1) (fun w1 : Word => @ex2 Elt (fun y : Elt => dans y (add (eps X) X)) (fun y : Elt => @ex2 Word (fun w2 : Word => inmonoid P w2) (fun w2 : Word => @eq Elt x (couple (word w1) (couple y (word w2)))))) *) (* Goal: or (dans x (map f_R_d R)) (dans x (map f_X_d X)) *) intros u eg_y inmono_u. (* Goal: @eq Elt (word u) (second y) *) (* Goal: @ex Elt (fun y : Elt => and (dans y R) (@eq Elt x (f_R_d y))) *) (* Goal: forall _ : dans x (map f_X_d X), @ex2 Word (fun w1 : Word => inmonoid P w1) (fun w1 : Word => @ex2 Elt (fun y : Elt => dans y (add (eps X) X)) (fun y : Elt => @ex2 Word (fun w2 : Word => inmonoid P w2) (fun w2 : Word => @eq Elt x (couple (word w1) (couple y (word w2)))))) *) (* Goal: or (dans x (map f_R_d R)) (dans x (map f_X_d X)) *) rewrite eg_y. (* Goal: inmonoid P (word_inv (second (couple f_y (word u)))) *) (* Goal: @eq Elt x (couple (word (cons (first y) nil)) (couple (eps X) (word (word_inv (second y))))) *) (* Goal: @ex Elt (fun y : Elt => and (dans y R) (@eq Elt x (f_R_d y))) *) (* Goal: forall _ : dans x (map f_X_d X), @ex2 Word (fun w1 : Word => inmonoid P w1) (fun w1 : Word => @ex2 Elt (fun y : Elt => dans y (add (eps X) X)) (fun y : Elt => @ex2 Word (fun w2 : Word => inmonoid P w2) (fun w2 : Word => @eq Elt x (couple (word w1) (couple y (word w2)))))) *) (* Goal: or (dans x (map f_R_d R)) (dans x (map f_X_d X)) *) unfold second in |- *. (* Goal: inmonoid P (word_inv (word u)) *) (* Goal: @eq Elt x (couple (word (cons (first y) nil)) (couple (eps X) (word (word_inv (second y))))) *) (* Goal: @ex Elt (fun y : Elt => and (dans y R) (@eq Elt x (f_R_d y))) *) (* Goal: forall _ : dans x (map f_X_d X), @ex2 Word (fun w1 : Word => inmonoid P w1) (fun w1 : Word => @ex2 Elt (fun y : Elt => dans y (add (eps X) X)) (fun y : Elt => @ex2 Word (fun w2 : Word => inmonoid P w2) (fun w2 : Word => @eq Elt x (couple (word w1) (couple y (word w2)))))) *) (* Goal: or (dans x (map f_R_d R)) (dans x (map f_X_d X)) *) unfold word_inv in |- *. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: @eq Elt x (couple (word (cons (first y) nil)) (couple (eps X) (word (word_inv (second y))))) *) (* Goal: @ex Elt (fun y : Elt => and (dans y R) (@eq Elt x (f_R_d y))) *) (* Goal: forall _ : dans x (map f_X_d X), @ex2 Word (fun w1 : Word => inmonoid P w1) (fun w1 : Word => @ex2 Elt (fun y : Elt => dans y (add (eps X) X)) (fun y : Elt => @ex2 Word (fun w2 : Word => inmonoid P w2) (fun w2 : Word => @eq Elt x (couple (word w1) (couple y (word w2)))))) *) (* Goal: or (dans x (map f_R_d R)) (dans x (map f_X_d X)) *) elim (Regles_X_V_R y dans_y_R). (* Goal: forall (x0 : Elt) (_ : dans x0 V) (_ : @ex2 Word (fun B : Word => @eq Elt y (couple x0 (word B))) (fun B : Word => inmonoid (union X V) B)), @eq Elt x (couple (word (cons (first y) nil)) (couple (eps X) (word (word_inv (second y))))) *) (* Goal: @ex Elt (fun y : Elt => and (dans y R) (@eq Elt x (f_R_d y))) *) (* Goal: forall _ : dans x (map f_X_d X), @ex2 Word (fun w1 : Word => inmonoid P w1) (fun w1 : Word => @ex2 Elt (fun y : Elt => dans y (add (eps X) X)) (fun y : Elt => @ex2 Word (fun w2 : Word => inmonoid P w2) (fun w2 : Word => @eq Elt x (couple (word w1) (couple y (word w2)))))) *) (* Goal: or (dans x (map f_R_d R)) (dans x (map f_X_d X)) *) intros f_y dans_f_y_V temp; elim temp; clear temp. (* Goal: forall (x0 : Word) (_ : @eq Elt y (couple f_y (word x0))) (_ : inmonoid (union X V) x0), @eq Elt x (couple (word (cons (first y) nil)) (couple (eps X) (word (word_inv (second y))))) *) (* Goal: @ex Elt (fun y : Elt => and (dans y R) (@eq Elt x (f_R_d y))) *) (* Goal: forall _ : dans x (map f_X_d X), @ex2 Word (fun w1 : Word => inmonoid P w1) (fun w1 : Word => @ex2 Elt (fun y : Elt => dans y (add (eps X) X)) (fun y : Elt => @ex2 Word (fun w2 : Word => inmonoid P w2) (fun w2 : Word => @eq Elt x (couple (word w1) (couple y (word w2)))))) *) (* Goal: or (dans x (map f_R_d R)) (dans x (map f_X_d X)) *) intros u eg_y inmono_u. (* Goal: @eq Elt x (couple (word (cons (first y) nil)) (couple (eps X) (word (word_inv (second y))))) *) (* Goal: @ex Elt (fun y : Elt => and (dans y R) (@eq Elt x (f_R_d y))) *) (* Goal: forall _ : dans x (map f_X_d X), @ex2 Word (fun w1 : Word => inmonoid P w1) (fun w1 : Word => @ex2 Elt (fun y : Elt => dans y (add (eps X) X)) (fun y : Elt => @ex2 Word (fun w2 : Word => inmonoid P w2) (fun w2 : Word => @eq Elt x (couple (word w1) (couple y (word w2)))))) *) (* Goal: or (dans x (map f_R_d R)) (dans x (map f_X_d X)) *) replace (word (word_inv (second y))) with (second y). (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: @eq Elt (second y) (word (word_inv (second y))) *) (* Goal: @ex Elt (fun y : Elt => and (dans y R) (@eq Elt x (f_R_d y))) *) (* Goal: forall _ : dans x (map f_X_d X), @ex2 Word (fun w1 : Word => inmonoid P w1) (fun w1 : Word => @ex2 Elt (fun y : Elt => dans y (add (eps X) X)) (fun y : Elt => @ex2 Word (fun w2 : Word => inmonoid P w2) (fun w2 : Word => @eq Elt x (couple (word w1) (couple y (word w2)))))) *) (* Goal: or (dans x (map f_R_d R)) (dans x (map f_X_d X)) *) replace (second y) with (word u). (* Goal: @eq Word (cons x w) (cons x w) *) (* Goal: sumbool (dans x X) (not (dans x X)) *) apply refl_equal. (* Goal: @eq Elt (word u) (second y) *) (* Goal: @ex Elt (fun y : Elt => and (dans y R) (@eq Elt x (f_R_d y))) *) (* Goal: forall _ : dans x (map f_X_d X), @ex2 Word (fun w1 : Word => inmonoid P w1) (fun w1 : Word => @ex2 Elt (fun y : Elt => dans y (add (eps X) X)) (fun y : Elt => @ex2 Word (fun w2 : Word => inmonoid P w2) (fun w2 : Word => @eq Elt x (couple (word w1) (couple y (word w2)))))) *) (* Goal: or (dans x (map f_R_d R)) (dans x (map f_X_d X)) *) rewrite eg_y. (* Goal: @eq Word (cons x w) (cons x w) *) (* Goal: sumbool (dans x X) (not (dans x X)) *) apply refl_equal. (* Goal: @ex Elt (fun r : Elt => and (dans r X) (@eq Elt (couple (word w1) (couple (eps X) (word w2))) (f_X_d r))) *) (* Goal: or (dans (couple (word w1) (couple (eps X) (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X)) *) apply dans_map. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: forall _ : dans x (map f_X_d X), @ex2 Word (fun w1 : Word => inmonoid P w1) (fun w1 : Word => @ex2 Elt (fun y : Elt => dans y (add (eps X) X)) (fun y : Elt => @ex2 Word (fun w2 : Word => inmonoid P w2) (fun w2 : Word => @eq Elt x (couple (word w1) (couple y (word w2)))))) *) (* Goal: or (dans x (map f_R_d R)) (dans x (map f_X_d X)) *) intros dans_x. (* Goal: @ex2 Word (fun w1 : Word => inmonoid P w1) (fun w1 : Word => @ex2 Elt (fun y : Elt => dans y (add (eps X) X)) (fun y : Elt => @ex2 Word (fun w2 : Word => inmonoid P w2) (fun w2 : Word => @eq Elt x (couple (word w1) (couple y (word w2)))))) *) (* Goal: or (dans x (map f_R_d R)) (dans x (map f_X_d X)) *) elimtype (exists y : Elt, dans y X /\ x = f_X_d y). (* Goal: forall (x0 : Elt) (_ : and (dans x0 X) (@eq Elt x (f_X_d x0))), @ex2 Word (fun w1 : Word => inmonoid P w1) (fun w1 : Word => @ex2 Elt (fun y : Elt => dans y (add (eps X) X)) (fun y : Elt => @ex2 Word (fun w2 : Word => inmonoid P w2) (fun w2 : Word => @eq Elt x (couple (word w1) (couple y (word w2)))))) *) (* Goal: @ex Elt (fun y : Elt => and (dans y X) (@eq Elt x (f_X_d y))) *) (* Goal: or (dans x (map f_R_d R)) (dans x (map f_X_d X)) *) intros y temp; elim temp; clear temp. (* Goal: forall (_ : dans y X) (_ : @eq Elt x (f_X_d y)), @ex2 Word (fun w1 : Word => inmonoid P w1) (fun w1 : Word => @ex2 Elt (fun y : Elt => dans y (add (eps X) X)) (fun y : Elt => @ex2 Word (fun w2 : Word => inmonoid P w2) (fun w2 : Word => @eq Elt x (couple (word w1) (couple y (word w2)))))) *) (* Goal: @ex Elt (fun y : Elt => and (dans y X) (@eq Elt x (f_X_d y))) *) (* Goal: or (dans x (map f_R_d R)) (dans x (map f_X_d X)) *) unfold f_X_d in |- *. (* Goal: forall (_ : dans y X) (_ : @eq Elt x (couple (word (cons y nil)) (couple y (word nil)))), @ex2 Word (fun w1 : Word => inmonoid P w1) (fun w1 : Word => @ex2 Elt (fun y : Elt => dans y (add (eps X) X)) (fun y : Elt => @ex2 Word (fun w2 : Word => inmonoid P w2) (fun w2 : Word => @eq Elt x (couple (word w1) (couple y (word w2)))))) *) (* Goal: @ex Elt (fun y : Elt => and (dans y X) (@eq Elt x (f_X_d y))) *) (* Goal: or (dans x (map f_R_d R)) (dans x (map f_X_d X)) *) intros dans_y_X eg_x_f_y. (* Goal: @ex2 Word (fun w1 : Word => inmonoid P w1) (fun w1 : Word => @ex2 Elt (fun y : Elt => dans y (add (eps X) X)) (fun y : Elt => @ex2 Word (fun w2 : Word => inmonoid P w2) (fun w2 : Word => @eq Elt x (couple (word w1) (couple y (word w2)))))) *) (* Goal: @ex Elt (fun y : Elt => and (dans y X) (@eq Elt x (f_X_d y))) *) (* Goal: or (dans x (map f_R_d R)) (dans x (map f_X_d X)) *) exists (cons y nil). (* Goal: inmonoid P (cons S' nil) *) (* Goal: and (inmonoid P wa) (Transition X P d) *) apply inmonoid_cons. (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) trivial. (* Goal: dans S' P *) (* Goal: and (inmonoid P wa) (Transition X P d) *) unfold P in |- *. (* Goal: and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) auto. (* Goal: @ex2 Elt (fun y : Elt => dans y (add (eps X) X)) (fun y0 : Elt => @ex2 Word (fun w2 : Word => inmonoid P w2) (fun w2 : Word => @eq Elt x (couple (word (cons y nil)) (couple y0 (word w2))))) *) (* Goal: @ex Elt (fun y : Elt => and (dans y X) (@eq Elt x (f_X_d y))) *) (* Goal: or (dans x (map f_R_d R)) (dans x (map f_X_d X)) *) exists y. (* Goal: and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) auto. (* Goal: @sigT Word (fun a : Word => @sig Word (fun b : Word => and (inmonoid X a) (and (@eq Word (Append a b) (cons x w)) (or (@eq Word b nil) (@ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w : Word => @eq Word b (cons x w)))))))) *) (* Goal: sumbool (dans x X) (not (dans x X)) *) exists nil. (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) trivial. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: @ex Elt (fun r : Elt => and (dans r X) (@eq Elt (couple (word w1) (couple (eps X) (word w2))) (f_X_d r))) *) (* Goal: or (dans (couple (word w1) (couple (eps X) (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X)) *) apply dans_map. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) auto. Qed. Lemma X_P_wd_wa_d : P_automata X P wd wa d. (* Goal: l_egal (LA X wd wa d) (LG X V R S') *) red in |- *. (* Goal: and (forall (w : Word) (_ : and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w)), and (Derivestar R (cons S' nil) w) (inmonoid X w)) (forall (w : Word) (_ : and (Derivestar R (cons S' nil) w) (inmonoid X w)), and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w)) *) split. (* Goal: inmonoid P wd *) (* Goal: and (inmonoid P wa) (Transition X P d) *) unfold wd in |- *. (* Goal: inmonoid P (cons S' nil) *) (* Goal: and (inmonoid P wa) (Transition X P d) *) apply inmonoid_cons. (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) trivial. (* Goal: dans S' P *) (* Goal: and (inmonoid P wa) (Transition X P d) *) unfold P in |- *. (* Goal: dans (couple (word (cons x0 nil)) (couple x0 (word nil))) (union (map f_R_d R) (map f_X_d X)) *) (* Goal: @eq Word (Append nil w) w *) (* Goal: @eq Word (Append (cons x0 nil) w) (cons x0 w) *) (* Goal: forall (v w u : Word) (x : Elt) (_ : dans (couple x (word u)) R), Derive_P_A X d (@pair Word Word (cons x w) v) (@pair Word Word (Append u w) v) *) apply union_d. (* Goal: dans S' V *) (* Goal: and (inmonoid P wa) (Transition X P d) *) apply isGram3 with X R. (* Goal: isGram X V R S' *) (* Goal: dans x0 X *) (* Goal: dans x0 V *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : forall (u0 v0 : Word) (_ : @eq Word (Append u0 v0) u) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) v) (fun w : Word => Deriveg X R v0 w)) (u0 v0 : Word) (_ : @eq Word (Append u0 v0) (cons x u)) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) (cons x v)) (fun w : Word => Deriveg X R v0 w) *) exact Gram. (* Goal: and (forall (w : Word) (_ : and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w)), and (Derivestar R (cons S' nil) w) (inmonoid X w)) (forall (w : Word) (_ : and (Derivestar R (cons S' nil) w) (inmonoid X w)), and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w)) *) split. (* Goal: inmonoid P wa *) (* Goal: Transition X P d *) apply inmonoid_nil. (* Goal: Transition X P d *) exact Trans. Qed. Lemma cut_spec : forall u : Word, {a : Word & {b : Word | inmonoid X a /\ Append a b = u /\ (b = nil \/ ex2 (fun x : Elt => ~ dans x X) (fun x : Elt => exists w : Word, b = cons x w))}}. (* Goal: forall u : Word, @sigT Word (fun a : Word => @sig Word (fun b : Word => and (inmonoid X a) (and (@eq Word (Append a b) u) (or (@eq Word b nil) (@ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w : Word => @eq Word b (cons x w)))))))) *) intro u. (* Goal: @sigT Word (fun a : Word => @sig Word (fun b : Word => and (inmonoid X a) (and (@eq Word (Append a b) u) (or (@eq Word b nil) (@ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w : Word => @eq Word b (cons x w)))))))) *) pattern u in |- *. (* Goal: (fun w : Word => @sigT Word (fun a : Word => @sig Word (fun b : Word => and (inmonoid X a) (and (@eq Word (Append a b) w) (or (@eq Word b nil) (@ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w0 : Word => @eq Word b (cons x w0))))))))) u *) apply Word_rec. (* Goal: @sigT Word (fun a : Word => @sig Word (fun b : Word => and (inmonoid X a) (and (@eq Word (Append a b) (cons x w)) (or (@eq Word b nil) (@ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w : Word => @eq Word b (cons x w)))))))) *) (* Goal: sumbool (dans x X) (not (dans x X)) *) exists nil. (* Goal: @sigT Word (fun a : Word => @sig Word (fun b : Word => and (inmonoid X a) (and (@eq Word (Append a b) (cons x w)) (or (@eq Word b nil) (@ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w : Word => @eq Word b (cons x w)))))))) *) (* Goal: sumbool (dans x X) (not (dans x X)) *) exists nil. (* Goal: and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) auto. (* Goal: forall (e : Elt) (w : Word) (_ : @sigT Word (fun a : Word => @sig Word (fun b : Word => and (inmonoid X a) (and (@eq Word (Append a b) w) (or (@eq Word b nil) (@ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w0 : Word => @eq Word b (cons x w0))))))))), @sigT Word (fun a : Word => @sig Word (fun b : Word => and (inmonoid X a) (and (@eq Word (Append a b) (cons e w)) (or (@eq Word b nil) (@ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w0 : Word => @eq Word b (cons x w0)))))))) *) intros x w Hyp. (* Goal: @sigT Word (fun a : Word => @sig Word (fun b : Word => and (inmonoid X a) (and (@eq Word (Append a b) (cons x w)) (or (@eq Word b nil) (@ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w : Word => @eq Word b (cons x w)))))))) *) elim Hyp. (* Goal: forall (x0 : Word) (_ : @sig Word (fun b : Word => and (inmonoid X x0) (and (@eq Word (Append x0 b) w) (or (@eq Word b nil) (@ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w : Word => @eq Word b (cons x w)))))))), @sigT Word (fun a : Word => @sig Word (fun b : Word => and (inmonoid X a) (and (@eq Word (Append a b) (cons x w)) (or (@eq Word b nil) (@ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w : Word => @eq Word b (cons x w)))))))) *) intros a' spec; elim spec. (* Goal: forall (x0 : Word) (_ : and (inmonoid X x') (and (@eq Word (Append x' x0) (cons a w)) (or (@eq Word x0 nil) (@ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w : Word => @eq Word x0 (cons x w))))))) (_ : @eq Word (Append x b) w) (_ : or (@eq Word b nil) (@ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w : Word => @eq Word b (cons x w))))), @eq Word (@fst Word Word (@pair Word Word x' x0)) (cons a (@fst Word Word (@pair Word Word x b))) *) intros b' temp; elim temp; clear temp. (* Goal: forall (_ : inmonoid X a') (_ : and (@eq Word (Append a' b') w) (or (@eq Word b' nil) (@ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w : Word => @eq Word b' (cons x w)))))), @sigT Word (fun a : Word => @sig Word (fun b : Word => and (inmonoid X a) (and (@eq Word (Append a b) (cons x w)) (or (@eq Word b nil) (@ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w : Word => @eq Word b (cons x w)))))))) *) intros inmonoid_a' temp; elim temp; clear temp. (* Goal: forall (_ : @eq Word (Append a' b') w) (_ : or (@eq Word b' nil) (@ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w : Word => @eq Word b' (cons x w))))), @sigT Word (fun a : Word => @sig Word (fun b : Word => and (inmonoid X a) (and (@eq Word (Append a b) (cons x w)) (or (@eq Word b nil) (@ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w : Word => @eq Word b (cons x w)))))))) *) intros spec_App spec_or. (* Goal: @sigT Word (fun a : Word => @sig Word (fun b : Word => and (inmonoid X a) (and (@eq Word (Append a b) (cons x w)) (or (@eq Word b nil) (@ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w : Word => @eq Word b (cons x w)))))))) *) elimtype ({dans x X} + {~ dans x X}). (* Goal: forall _ : dans x X, @sigT Word (fun a0 : Word => @sig Word (fun b : Word => and (inmonoid X a0) (and (@eq Word (Append a0 b) (cons x w)) (or (@eq Word b nil) (@ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w : Word => @eq Word b (cons x w)))))))) *) (* Goal: forall _ : not (dans x X), @sigT Word (fun a : Word => @sig Word (fun b0 : Word => and (inmonoid X a) (and (@eq Word (Append a b0) (cons x w)) (or (@eq Word b0 nil) (@ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w : Word => @eq Word b0 (cons x w)))))))) *) (* Goal: sumbool (dans x X) (not (dans x X)) *) intro dans_x_X. (* Goal: @sigT Word (fun a : Word => @sig Word (fun b : Word => and (inmonoid X a) (and (@eq Word (Append a b) (cons x w)) (or (@eq Word b nil) (@ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w : Word => @eq Word b (cons x w)))))))) *) (* Goal: forall _ : not (dans x X), @sigT Word (fun a : Word => @sig Word (fun b0 : Word => and (inmonoid X a) (and (@eq Word (Append a b0) (cons x w)) (or (@eq Word b0 nil) (@ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w : Word => @eq Word b0 (cons x w)))))))) *) (* Goal: sumbool (dans x X) (not (dans x X)) *) exists (cons x a'). (* Goal: @sig Word (fun b : Word => and (inmonoid X (cons x a')) (and (@eq Word (Append (cons x a') b) (cons x w)) (or (@eq Word b nil) (@ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w : Word => @eq Word b (cons x w))))))) *) (* Goal: forall _ : not (dans x X), @sigT Word (fun a : Word => @sig Word (fun b0 : Word => and (inmonoid X a) (and (@eq Word (Append a b0) (cons x w)) (or (@eq Word b0 nil) (@ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w : Word => @eq Word b0 (cons x w)))))))) *) (* Goal: sumbool (dans x X) (not (dans x X)) *) exists b'. (* Goal: and (forall (w : Word) (_ : and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w)), and (Derivestar R (cons S' nil) w) (inmonoid X w)) (forall (w : Word) (_ : and (Derivestar R (cons S' nil) w) (inmonoid X w)), and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w)) *) split. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) apply inmonoid_cons; assumption. (* Goal: and (forall (w : Word) (_ : and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w)), and (Derivestar R (cons S' nil) w) (inmonoid X w)) (forall (w : Word) (_ : and (Derivestar R (cons S' nil) w) (inmonoid X w)), and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w)) *) split. (* Goal: @eq Word (Append (cons x0 (cut1 u)) w) (cons x0 v) *) (* Goal: @eq Word (cons x0 (cut1 u)) (cut1 (cons x0 u)) *) (* Goal: Deriveg X R (cut2 (cons x0 u)) w *) unfold Append in |- *. (* Goal: forall (_ : Derive_P_A_3 (@pair Word Conf u1 (@pair Word Word u2 u3)) (@pair Word Conf v1 (@pair Word Word v2 v3))) (_ : forall _ : inmonoid X (@fst Word Conf (@pair Word Conf v1 (@pair Word Word v2 v3))), Rstar Word (Deriveg X R) (Append (@fst Word Conf (@pair Word Conf v1 (@pair Word Word v2 v3))) (@fst Word Word (@snd Word Conf (@pair Word Conf v1 (@pair Word Word v2 v3))))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w)))) (_ : inmonoid X (@fst Word Conf (@pair Word Conf u1 (@pair Word Word u2 u3)))), Rstar Word (Deriveg X R) (Append (@fst Word Conf (@pair Word Conf u1 (@pair Word Word u2 u3))) (@fst Word Word (@snd Word Conf (@pair Word Conf u1 (@pair Word Word u2 u3))))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w))) *) simpl in |- *. (* Goal: and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) auto. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) elim spec_or; intro; assumption. (* Goal: forall _ : not (dans x X), @sigT Word (fun a : Word => @sig Word (fun b0 : Word => and (inmonoid X a) (and (@eq Word (Append a b0) (cons x w)) (or (@eq Word b0 nil) (@ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w : Word => @eq Word b0 (cons x w)))))))) *) (* Goal: sumbool (dans x X) (not (dans x X)) *) intro N_dans_x_X. (* Goal: @sigT Word (fun a : Word => @sig Word (fun b : Word => and (inmonoid X a) (and (@eq Word (Append a b) (cons x w)) (or (@eq Word b nil) (@ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w : Word => @eq Word b (cons x w)))))))) *) (* Goal: sumbool (dans x X) (not (dans x X)) *) exists nil. (* Goal: @sig Word (fun b : Word => and (inmonoid X nil) (and (@eq Word (Append nil b) (cons x w)) (or (@eq Word b nil) (@ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w : Word => @eq Word b (cons x w))))))) *) (* Goal: sumbool (dans x X) (not (dans x X)) *) exists (cons x w). (* Goal: and (forall (w : Word) (_ : and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w)), and (Derivestar R (cons S' nil) w) (inmonoid X w)) (forall (w : Word) (_ : and (Derivestar R (cons S' nil) w) (inmonoid X w)), and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w)) *) split. (* Goal: and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) auto. (* Goal: and (forall (w : Word) (_ : and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w)), and (Derivestar R (cons S' nil) w) (inmonoid X w)) (forall (w : Word) (_ : and (Derivestar R (cons S' nil) w) (inmonoid X w)), and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w)) *) split. (* Goal: and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) auto. (* Goal: or (@ex2 Elt (fun a : Elt => dans a X) (fun a : Elt => and (@eq Word (@fst Word Word (@pair Word Word (cons x0 w) v)) (cons a (@fst Word Word (@pair Word Word (Append u w) v)))) (@eq Word (@snd Word Word (@pair Word Word (cons x0 w) v)) (cons a (@snd Word Word (@pair Word Word (Append u w) v)))))) (@ex Elt (fun a : Elt => @ex2 Word (fun w0 : Word => @eq Word (cons a w0) (@fst Word Word (@pair Word Word (cons x0 w) v))) (fun w0 : Word => @ex2 Word (fun u : Word => dans (couple a (word u)) R) (fun u0 : Word => @eq Word (Append u0 w0) (@fst Word Word (@pair Word Word (Append u w) v)))))) *) apply or_intror. (* Goal: @ex2 Elt (fun x : Elt => not (dans x X)) (fun x0 : Elt => @ex Word (fun w0 : Word => @eq Word (cons x w) (cons x0 w0))) *) (* Goal: sumbool (dans x X) (not (dans x X)) *) exists x. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: @ex2 Word (fun w0 : Word => @eq Word (cons x0 w0) (@fst Word Word (@pair Word Word (cons x0 w) v))) (fun w0 : Word => @ex2 Word (fun u : Word => dans (couple x0 (word u)) R) (fun u0 : Word => @eq Word (Append u0 w0) (@fst Word Word (@pair Word Word (Append u w) v)))) *) exists w. (* Goal: @eq Word (cons x w) (cons x w) *) (* Goal: sumbool (dans x X) (not (dans x X)) *) apply refl_equal. (* Goal: sumbool (dans x X) (not (dans x X)) *) exact (Dans_spec x X). Qed. Definition cut (u : Word) := let (a, s) := cut_spec u in (a, let (b, s2) := s in b). Definition cut1 (u : Word) := fst (cut u). Definition cut2 (u : Word) := snd (cut u). Lemma cut_unicite : forall u a b a' b' : Word, inmonoid X a /\ Append a b = u /\ (b = nil \/ ex2 (fun x : Elt => ~ dans x X) (fun x : Elt => exists w : Word, b = cons x w)) -> inmonoid X a' /\ Append a' b' = u /\ (b' = nil \/ ex2 (fun x : Elt => ~ dans x X) (fun x : Elt => exists w : Word, b' = cons x w)) -> a = a'. intros u a b a' b' temp1 temp2; elim temp1; elim temp2; clear temp1; clear temp2. intros inmon temp inmon' temp'; elim temp; elim temp'; clear temp; clear temp'. (* Goal: forall (_ : @eq Word (Append a b) u) (_ : or (@eq Word b nil) (@ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w : Word => @eq Word b (cons x w))))) (_ : @eq Word (Append a' b') u) (_ : or (@eq Word b' nil) (@ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w : Word => @eq Word b' (cons x w))))), @eq Word a a' *) intros App spec_or App' spec_or'. elimtype (exists w : Word, a = Append a' w /\ b' = Append w b \/ a' = Append a w /\ b = Append w b'). (* Goal: forall (x : Word) (p : @sig Word (fun b : Word => and (inmonoid X x) (and (@eq Word (Append x b) w) (or (@eq Word b nil) (@ex2 Elt (fun x0 : Elt => not (dans x0 X)) (fun x0 : Elt => @ex Word (fun w : Word => @eq Word b (cons x0 w)))))))), @eq Word (@fst Word Word (let (a0, s) := cut_spec (cons a w) in @pair Word Word a0 (let (b, _) := s in b))) (cons a (@fst Word Word (@pair Word Word x (let (b, _) := p in b)))) *) intros x temp; elim temp; clear temp. (* Goal: forall _ : and (@eq Word a (Append a' x)) (@eq Word b' (Append x b)), @eq Word a a' *) (* Goal: forall _ : and (@eq Word a' (Append a x)) (@eq Word b (Append x b')), @eq Word a a' *) (* Goal: @ex Word (fun w : Word => or (and (@eq Word a (Append a' w)) (@eq Word b' (Append w b))) (and (@eq Word a' (Append a w)) (@eq Word b (Append w b')))) *) pattern a' at 2 in |- *. (* Goal: (fun w : Word => forall _ : and (@eq Word a (Append a' x)) (@eq Word b' (Append x b)), @eq Word a w) a' *) (* Goal: forall _ : and (@eq Word a' (Append a x)) (@eq Word b (Append x b')), @eq Word a a' *) (* Goal: @ex Word (fun w : Word => or (and (@eq Word a (Append a' w)) (@eq Word b' (Append w b))) (and (@eq Word a' (Append a w)) (@eq Word b (Append w b')))) *) replace a' with (Append a' nil). (* Goal: forall _ : and (@eq Word a' (Append a x)) (@eq Word b (Append x b')), @eq Word (Append a nil) a' *) (* Goal: @eq Word (Append a nil) a *) (* Goal: @ex Word (fun w : Word => or (and (@eq Word a (Append a' w)) (@eq Word b' (Append w b))) (and (@eq Word a' (Append a w)) (@eq Word b (Append w b')))) *) generalize x; clear x; simple induction x. (* Goal: forall _ : and (@eq Word a' (Append a nil)) (@eq Word b (Append nil b')), @eq Word (Append a nil) a' *) (* Goal: forall (e : Elt) (w : Word) (_ : forall _ : and (@eq Word a' (Append a w)) (@eq Word b (Append w b')), @eq Word (Append a nil) a') (_ : and (@eq Word a' (Append a (cons e w))) (@eq Word b (Append (cons e w) b'))), @eq Word (Append a nil) a' *) (* Goal: @eq Word (Append a nil) a *) (* Goal: @ex Word (fun w : Word => or (and (@eq Word a (Append a' w)) (@eq Word b' (Append w b))) (and (@eq Word a' (Append a w)) (@eq Word b (Append w b')))) *) intro temp; elim temp. (* Goal: and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) auto. (* Goal: forall (e : Elt) (w : Word) (_ : forall _ : and (@eq Word a' (Append a w)) (@eq Word b (Append w b')), @eq Word (Append a nil) a') (_ : and (@eq Word a' (Append a (cons e w))) (@eq Word b (Append (cons e w) b'))), @eq Word (Append a nil) a' *) (* Goal: @eq Word (Append a nil) a *) (* Goal: @ex Word (fun w : Word => or (and (@eq Word a (Append a' w)) (@eq Word b' (Append w b))) (and (@eq Word a' (Append a w)) (@eq Word b (Append w b')))) *) intros x0 w Hyp temp; elim temp; clear temp. (* Goal: forall (_ : @eq Word a (Append a' (cons x0 w))) (_ : @eq Word b' (Append (cons x0 w) b)), @eq Word a (Append a' nil) *) (* Goal: @eq Word (Append a' nil) a' *) (* Goal: forall _ : and (@eq Word a' (Append a x)) (@eq Word b (Append x b')), @eq Word a a' *) (* Goal: @ex Word (fun w : Word => or (and (@eq Word a (Append a' w)) (@eq Word b' (Append w b))) (and (@eq Word a' (Append a w)) (@eq Word b (Append w b')))) *) intros a_eg b'_eg. (* Goal: @eq Word (Append a nil) a' *) (* Goal: @eq Word (Append a nil) a *) (* Goal: @ex Word (fun w : Word => or (and (@eq Word a (Append a' w)) (@eq Word b' (Append w b))) (and (@eq Word a' (Append a w)) (@eq Word b (Append w b')))) *) absurd (dans x0 X). (* Goal: not (dans x0 X) *) (* Goal: dans x0 X *) (* Goal: @eq Word (Append a' nil) a' *) (* Goal: forall _ : and (@eq Word a' (Append a x)) (@eq Word b (Append x b')), @eq Word a a' *) (* Goal: @ex Word (fun w : Word => or (and (@eq Word a (Append a' w)) (@eq Word b' (Append w b))) (and (@eq Word a' (Append a w)) (@eq Word b (Append w b')))) *) elim spec_or'. (* Goal: forall _ : @eq Word b' nil, not (dans x0 X) *) (* Goal: forall _ : @ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w : Word => @eq Word b' (cons x w))), not (dans x0 X) *) (* Goal: dans x0 X *) (* Goal: @eq Word (Append a' nil) a' *) (* Goal: forall _ : and (@eq Word a' (Append a x)) (@eq Word b (Append x b')), @eq Word a a' *) (* Goal: @ex Word (fun w : Word => or (and (@eq Word a (Append a' w)) (@eq Word b' (Append w b))) (and (@eq Word a' (Append a w)) (@eq Word b (Append w b')))) *) rewrite b'_eg. (* Goal: forall _ : @eq Word (Append (cons x0 w) b') nil, not (dans x0 X) *) (* Goal: forall _ : @ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w : Word => @eq Word b (cons x w))), not (dans x0 X) *) (* Goal: dans x0 X *) (* Goal: @eq Word (Append a nil) a *) (* Goal: @ex Word (fun w : Word => or (and (@eq Word a (Append a' w)) (@eq Word b' (Append w b))) (and (@eq Word a' (Append a w)) (@eq Word b (Append w b')))) *) intro cons_nil. (* Goal: not (dans x0 X) *) (* Goal: forall _ : @ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w : Word => @eq Word b' (cons x w))), not (dans x0 X) *) (* Goal: dans x0 X *) (* Goal: @eq Word (Append a' nil) a' *) (* Goal: forall _ : and (@eq Word a' (Append a x)) (@eq Word b (Append x b')), @eq Word a a' *) (* Goal: @ex Word (fun w : Word => or (and (@eq Word a (Append a' w)) (@eq Word b' (Append w b))) (and (@eq Word a' (Append a w)) (@eq Word b (Append w b')))) *) absurd (cons x0 (Append w b) = nil). (* Goal: not (@eq Word (cons x0 (Append w v)) nil) *) (* Goal: @eq Word (cons x0 (Append w v)) nil *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) (* Goal: forall (e : Elt) (w : Word) (_ : forall (y : Word) (_ : Rstar Conf Derive_P_A_2 (@pair Word Word w y) (@pair Word Word nil nil)) (u v : Word) (_ : @eq Word (Append u v) w) (_ : inmonoid X u), @ex2 Word (fun w0 : Word => @eq Word (Append u w0) y) (fun w0 : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w0) (@pair Word Word nil nil))) (y : Word) (_ : Rstar Conf Derive_P_A_2 (@pair Word Word (cons e w) y) (@pair Word Word nil nil)) (u v : Word) (_ : @eq Word (Append u v) (cons e w)) (_ : inmonoid X u), @ex2 Word (fun w0 : Word => @eq Word (Append u w0) y) (fun w0 : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w0) (@pair Word Word nil nil)) *) discriminate. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: forall (_ : @ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) (_ : @eq Word (Append u v) (cons x0 u0)) (_ : inmonoid X u), @ex2 Word (fun w : Word => @eq Word (Append u w) (cons x0 v0)) (fun w : Word => Deriveg X R v w) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) intro temp; elim temp; clear temp. (* Goal: forall (x : Elt) (_ : not (dans x X)) (_ : @ex Word (fun w : Word => @eq Word b (cons x w))), not (dans x0 X) *) (* Goal: dans x0 X *) (* Goal: @eq Word (Append a nil) a *) (* Goal: @ex Word (fun w : Word => or (and (@eq Word a (Append a' w)) (@eq Word b' (Append w b))) (and (@eq Word a' (Append a w)) (@eq Word b (Append w b')))) *) intros x1 N_dans_x1 temp; elim temp; clear temp. (* Goal: forall (x : Word) (_ : @eq Word b' (cons x1 x)), not (dans x0 X) *) (* Goal: dans x0 X *) (* Goal: @eq Word (Append a' nil) a' *) (* Goal: forall _ : and (@eq Word a' (Append a x)) (@eq Word b (Append x b')), @eq Word a a' *) (* Goal: @ex Word (fun w : Word => or (and (@eq Word a (Append a' w)) (@eq Word b' (Append w b))) (and (@eq Word a' (Append a w)) (@eq Word b (Append w b')))) *) intros w' b'_eg_2. (* Goal: dans x0 X *) (* Goal: Derivestar_P_A_2 (@pair Word Word (cons x0 w) y) (@pair Word Word nil nil) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) replace x0 with x1. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: @eq Elt x1 x0 *) (* Goal: dans x0 X *) (* Goal: @eq Word (Append a' nil) a' *) (* Goal: forall _ : and (@eq Word a' (Append a x)) (@eq Word b (Append x b')), @eq Word a a' *) (* Goal: @ex Word (fun w : Word => or (and (@eq Word a (Append a' w)) (@eq Word b' (Append w b))) (and (@eq Word a' (Append a w)) (@eq Word b (Append w b')))) *) apply cons_cons_inv1 with w' (Append w b). (* Goal: @eq Word (cons x1 w') (cons x0 (Append w b)) *) (* Goal: dans x0 X *) (* Goal: @eq Word (Append a' nil) a' *) (* Goal: forall _ : and (@eq Word a' (Append a x)) (@eq Word b (Append x b')), @eq Word a a' *) (* Goal: @ex Word (fun w : Word => or (and (@eq Word a (Append a' w)) (@eq Word b' (Append w b))) (and (@eq Word a' (Append a w)) (@eq Word b (Append w b')))) *) rewrite <- b'_eg_2. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: dans x0 X *) (* Goal: dans x0 V *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : forall (u0 v0 : Word) (_ : @eq Word (Append u0 v0) u) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) v) (fun w : Word => Deriveg X R v0 w)) (u0 v0 : Word) (_ : @eq Word (Append u0 v0) (cons x u)) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) (cons x v)) (fun w : Word => Deriveg X R v0 w) *) apply inmonoid_cons_inv2 with w. (* Goal: inmonoid X (cons x0 w) *) (* Goal: @eq Word (Append a' nil) a' *) (* Goal: forall _ : and (@eq Word a' (Append a x)) (@eq Word b (Append x b')), @eq Word a a' *) (* Goal: @ex Word (fun w : Word => or (and (@eq Word a (Append a' w)) (@eq Word b' (Append w b))) (and (@eq Word a' (Append a w)) (@eq Word b (Append w b')))) *) apply inmonoid_Append_inv2 with a'. (* Goal: inmonoid X (Append a' (cons x0 w)) *) (* Goal: @eq Word (Append a' nil) a' *) (* Goal: forall _ : and (@eq Word a' (Append a x)) (@eq Word b (Append x b')), @eq Word a a' *) (* Goal: @ex Word (fun w : Word => or (and (@eq Word a (Append a' w)) (@eq Word b' (Append w b))) (and (@eq Word a' (Append a w)) (@eq Word b (Append w b')))) *) rewrite <- a_eg. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: @eq Word (Append a nil) a *) (* Goal: @ex Word (fun w : Word => or (and (@eq Word a (Append a' w)) (@eq Word b' (Append w b))) (and (@eq Word a' (Append a w)) (@eq Word b (Append w b')))) *) apply Append_w_nil. (* Goal: forall _ : and (@eq Word a' (Append a x)) (@eq Word b (Append x b')), @eq Word a a' *) (* Goal: @ex Word (fun w : Word => or (and (@eq Word a (Append a' w)) (@eq Word b' (Append w b))) (and (@eq Word a' (Append a w)) (@eq Word b (Append w b')))) *) pattern a at 2 in |- *. (* Goal: (fun w : Word => forall _ : and (@eq Word a' (Append a x)) (@eq Word b (Append x b')), @eq Word w a') a *) (* Goal: @ex Word (fun w : Word => or (and (@eq Word a (Append a' w)) (@eq Word b' (Append w b))) (and (@eq Word a' (Append a w)) (@eq Word b (Append w b')))) *) replace a with (Append a nil). (* Goal: forall _ : and (@eq Word a' (Append a x)) (@eq Word b (Append x b')), @eq Word (Append a nil) a' *) (* Goal: @eq Word (Append a nil) a *) (* Goal: @ex Word (fun w : Word => or (and (@eq Word a (Append a' w)) (@eq Word b' (Append w b))) (and (@eq Word a' (Append a w)) (@eq Word b (Append w b')))) *) generalize x; clear x; simple induction x. (* Goal: forall _ : and (@eq Word a' (Append a nil)) (@eq Word b (Append nil b')), @eq Word (Append a nil) a' *) (* Goal: forall (e : Elt) (w : Word) (_ : forall _ : and (@eq Word a' (Append a w)) (@eq Word b (Append w b')), @eq Word (Append a nil) a') (_ : and (@eq Word a' (Append a (cons e w))) (@eq Word b (Append (cons e w) b'))), @eq Word (Append a nil) a' *) (* Goal: @eq Word (Append a nil) a *) (* Goal: @ex Word (fun w : Word => or (and (@eq Word a (Append a' w)) (@eq Word b' (Append w b))) (and (@eq Word a' (Append a w)) (@eq Word b (Append w b')))) *) intro temp; elim temp. (* Goal: and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) auto. (* Goal: forall (e : Elt) (w : Word) (_ : forall _ : and (@eq Word a' (Append a w)) (@eq Word b (Append w b')), @eq Word (Append a nil) a') (_ : and (@eq Word a' (Append a (cons e w))) (@eq Word b (Append (cons e w) b'))), @eq Word (Append a nil) a' *) (* Goal: @eq Word (Append a nil) a *) (* Goal: @ex Word (fun w : Word => or (and (@eq Word a (Append a' w)) (@eq Word b' (Append w b))) (and (@eq Word a' (Append a w)) (@eq Word b (Append w b')))) *) intros x0 w Hyp temp; elim temp; clear temp. (* Goal: forall (_ : @eq Word a' (Append a (cons x0 w))) (_ : @eq Word b (Append (cons x0 w) b')), @eq Word (Append a nil) a' *) (* Goal: @eq Word (Append a nil) a *) (* Goal: @ex Word (fun w : Word => or (and (@eq Word a (Append a' w)) (@eq Word b' (Append w b))) (and (@eq Word a' (Append a w)) (@eq Word b (Append w b')))) *) intros a'_eg b_eg. (* Goal: @eq Word (Append a nil) a' *) (* Goal: @eq Word (Append a nil) a *) (* Goal: @ex Word (fun w : Word => or (and (@eq Word a (Append a' w)) (@eq Word b' (Append w b))) (and (@eq Word a' (Append a w)) (@eq Word b (Append w b')))) *) absurd (dans x0 X). (* Goal: not (dans x0 X) *) (* Goal: dans x0 X *) (* Goal: @eq Word (Append a nil) a *) (* Goal: @ex Word (fun w : Word => or (and (@eq Word a (Append a' w)) (@eq Word b' (Append w b))) (and (@eq Word a' (Append a w)) (@eq Word b (Append w b')))) *) elim spec_or. (* Goal: forall _ : @eq Word b nil, not (dans x0 X) *) (* Goal: forall _ : @ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w : Word => @eq Word b (cons x w))), not (dans x0 X) *) (* Goal: dans x0 X *) (* Goal: @eq Word (Append a nil) a *) (* Goal: @ex Word (fun w : Word => or (and (@eq Word a (Append a' w)) (@eq Word b' (Append w b))) (and (@eq Word a' (Append a w)) (@eq Word b (Append w b')))) *) rewrite b_eg. (* Goal: forall _ : @eq Word (Append (cons x0 w) b') nil, not (dans x0 X) *) (* Goal: forall _ : @ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w : Word => @eq Word b (cons x w))), not (dans x0 X) *) (* Goal: dans x0 X *) (* Goal: @eq Word (Append a nil) a *) (* Goal: @ex Word (fun w : Word => or (and (@eq Word a (Append a' w)) (@eq Word b' (Append w b))) (and (@eq Word a' (Append a w)) (@eq Word b (Append w b')))) *) intro cons_nil. (* Goal: not (dans x0 X) *) (* Goal: forall _ : @ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w : Word => @eq Word b (cons x w))), not (dans x0 X) *) (* Goal: dans x0 X *) (* Goal: @eq Word (Append a nil) a *) (* Goal: @ex Word (fun w : Word => or (and (@eq Word a (Append a' w)) (@eq Word b' (Append w b))) (and (@eq Word a' (Append a w)) (@eq Word b (Append w b')))) *) absurd (cons x0 (Append w b') = nil). (* Goal: not (@eq Word (cons x0 (Append w v)) nil) *) (* Goal: @eq Word (cons x0 (Append w v)) nil *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) (* Goal: forall (e : Elt) (w : Word) (_ : forall (y : Word) (_ : Rstar Conf Derive_P_A_2 (@pair Word Word w y) (@pair Word Word nil nil)) (u v : Word) (_ : @eq Word (Append u v) w) (_ : inmonoid X u), @ex2 Word (fun w0 : Word => @eq Word (Append u w0) y) (fun w0 : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w0) (@pair Word Word nil nil))) (y : Word) (_ : Rstar Conf Derive_P_A_2 (@pair Word Word (cons e w) y) (@pair Word Word nil nil)) (u v : Word) (_ : @eq Word (Append u v) (cons e w)) (_ : inmonoid X u), @ex2 Word (fun w0 : Word => @eq Word (Append u w0) y) (fun w0 : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w0) (@pair Word Word nil nil)) *) discriminate. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: forall (_ : @ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) (_ : @eq Word (Append u v) (cons x0 u0)) (_ : inmonoid X u), @ex2 Word (fun w : Word => @eq Word (Append u w) (cons x0 v0)) (fun w : Word => Deriveg X R v w) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) intro temp; elim temp; clear temp. (* Goal: forall (x : Elt) (_ : not (dans x X)) (_ : @ex Word (fun w : Word => @eq Word b (cons x w))), not (dans x0 X) *) (* Goal: dans x0 X *) (* Goal: @eq Word (Append a nil) a *) (* Goal: @ex Word (fun w : Word => or (and (@eq Word a (Append a' w)) (@eq Word b' (Append w b))) (and (@eq Word a' (Append a w)) (@eq Word b (Append w b')))) *) intros x1 N_dans_x1 temp; elim temp; clear temp. (* Goal: forall (x : Word) (_ : @eq Word b (cons x1 x)), not (dans x0 X) *) (* Goal: dans x0 X *) (* Goal: @eq Word (Append a nil) a *) (* Goal: @ex Word (fun w : Word => or (and (@eq Word a (Append a' w)) (@eq Word b' (Append w b))) (and (@eq Word a' (Append a w)) (@eq Word b (Append w b')))) *) intros w' b_eg_2. (* Goal: dans x0 X *) (* Goal: Derivestar_P_A_2 (@pair Word Word (cons x0 w) y) (@pair Word Word nil nil) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) replace x0 with x1. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: @eq Elt x1 x0 *) (* Goal: dans x0 X *) (* Goal: @eq Word (Append a nil) a *) (* Goal: @ex Word (fun w : Word => or (and (@eq Word a (Append a' w)) (@eq Word b' (Append w b))) (and (@eq Word a' (Append a w)) (@eq Word b (Append w b')))) *) apply cons_cons_inv1 with w' (Append w b'). (* Goal: @eq Word (cons x1 w') (cons x0 (Append w b')) *) (* Goal: dans x0 X *) (* Goal: @eq Word (Append a nil) a *) (* Goal: @ex Word (fun w : Word => or (and (@eq Word a (Append a' w)) (@eq Word b' (Append w b))) (and (@eq Word a' (Append a w)) (@eq Word b (Append w b')))) *) rewrite <- b_eg_2. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: dans x0 X *) (* Goal: dans x0 V *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : forall (u0 v0 : Word) (_ : @eq Word (Append u0 v0) u) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) v) (fun w : Word => Deriveg X R v0 w)) (u0 v0 : Word) (_ : @eq Word (Append u0 v0) (cons x u)) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) (cons x v)) (fun w : Word => Deriveg X R v0 w) *) apply inmonoid_cons_inv2 with w. (* Goal: inmonoid X (cons x0 w) *) (* Goal: @eq Word (Append a nil) a *) (* Goal: @ex Word (fun w : Word => or (and (@eq Word a (Append a' w)) (@eq Word b' (Append w b))) (and (@eq Word a' (Append a w)) (@eq Word b (Append w b')))) *) apply inmonoid_Append_inv2 with a. (* Goal: inmonoid X (Append a (cons x0 w)) *) (* Goal: @eq Word (Append a nil) a *) (* Goal: @ex Word (fun w : Word => or (and (@eq Word a (Append a' w)) (@eq Word b' (Append w b))) (and (@eq Word a' (Append a w)) (@eq Word b (Append w b')))) *) rewrite <- a'_eg. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: @eq Word (Append a nil) a *) (* Goal: @ex Word (fun w : Word => or (and (@eq Word a (Append a' w)) (@eq Word b' (Append w b))) (and (@eq Word a' (Append a w)) (@eq Word b (Append w b')))) *) apply Append_w_nil. (* Goal: @ex Word (fun w : Word => or (and (@eq Word a (Append a' w)) (@eq Word b' (Append w b))) (and (@eq Word a' (Append a w)) (@eq Word b (Append w b')))) *) apply Append_Append. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) rewrite App'; assumption. Qed. Lemma inmonoid_cut1 : forall w : Word, inmonoid X (cut1 w). (* Goal: forall w : Word, @eq Word w (Append (cut1 w) (cut2 w)) *) intro w. (* Goal: @eq Word nil (cut1 (cons A v)) *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : @ex2 Word (fun w : Word => @eq Word (Append (cut1 u) w) v) (fun w : Word => Deriveg X R (cut2 u) w)), @ex2 Word (fun w : Word => @eq Word (Append (cut1 (cons x u)) w) (cons x v)) (fun w : Word => Deriveg X R (cut2 (cons x u)) w) *) unfold cut1, cut in |- *. (* Goal: @eq Word (@fst Word Word (let (a0, s) := cut_spec (cons a w) in @pair Word Word a0 (let (b, _) := s in b))) (cons a (@fst Word Word (let (a, s) := cut_spec w in @pair Word Word a (let (b, _) := s in b)))) *) elim (cut_spec w). (* Goal: forall (x : Word) (p : @sig Word (fun b : Word => and (inmonoid X x) (and (@eq Word (Append x b) (cons A v)) (or (@eq Word b nil) (@ex2 Elt (fun x0 : Elt => not (dans x0 X)) (fun x0 : Elt => @ex Word (fun w : Word => @eq Word b (cons x0 w)))))))), @eq Word (@snd Word Word (@pair Word Word x (let (b, _) := p in b))) (cons A v) *) intros a temp; elim temp; clear temp. (* Goal: forall (x : Word) (_ : and (inmonoid X a) (and (@eq Word (Append a x) (cons A v)) (or (@eq Word x nil) (@ex2 Elt (fun x0 : Elt => not (dans x0 X)) (fun x0 : Elt => @ex Word (fun w : Word => @eq Word x (cons x0 w))))))), @eq Word nil (@fst Word Word (@pair Word Word a x)) *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : @ex2 Word (fun w : Word => @eq Word (Append (cut1 u) w) v) (fun w : Word => Deriveg X R (cut2 u) w)), @ex2 Word (fun w : Word => @eq Word (Append (cut1 (cons x u)) w) (cons x v)) (fun w : Word => Deriveg X R (cut2 (cons x u)) w) *) intros b temp; elim temp; clear temp. (* Goal: and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) simpl in |- *; auto. Qed. Lemma cut_Append : forall w : Word, w = Append (cut1 w) (cut2 w). (* Goal: forall w : Word, @eq Word w (Append (cut1 w) (cut2 w)) *) intro w. (* Goal: @eq Word w (Append (cut1 w) (cut2 w)) *) unfold cut1, cut2, cut in |- *. (* Goal: @eq Word (@fst Word Word (let (a0, s) := cut_spec (cons a w) in @pair Word Word a0 (let (b, _) := s in b))) (cons a (@fst Word Word (let (a, s) := cut_spec w in @pair Word Word a (let (b, _) := s in b)))) *) elim (cut_spec w). (* Goal: forall (x : Word) (p : @sig Word (fun b : Word => and (inmonoid X x) (and (@eq Word (Append x b) (cons A v)) (or (@eq Word b nil) (@ex2 Elt (fun x0 : Elt => not (dans x0 X)) (fun x0 : Elt => @ex Word (fun w : Word => @eq Word b (cons x0 w)))))))), @eq Word (@snd Word Word (@pair Word Word x (let (b, _) := p in b))) (cons A v) *) intros a temp; elim temp; clear temp. (* Goal: forall (x : Word) (_ : and (inmonoid X a) (and (@eq Word (Append a x) (cons A v)) (or (@eq Word x nil) (@ex2 Elt (fun x0 : Elt => not (dans x0 X)) (fun x0 : Elt => @ex Word (fun w : Word => @eq Word x (cons x0 w))))))), @eq Word nil (@fst Word Word (@pair Word Word a x)) *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : @ex2 Word (fun w : Word => @eq Word (Append (cut1 u) w) v) (fun w : Word => Deriveg X R (cut2 u) w)), @ex2 Word (fun w : Word => @eq Word (Append (cut1 (cons x u)) w) (cons x v)) (fun w : Word => Deriveg X R (cut2 (cons x u)) w) *) intros b temp; elim temp; clear temp. (* Goal: forall (_ : inmonoid X a) (_ : and (@eq Word (Append a b) w) (or (@eq Word b nil) (@ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w : Word => @eq Word b (cons x w)))))), @eq Word w (Append (@fst Word Word (@pair Word Word a b)) (@snd Word Word (@pair Word Word a b))) *) intros inm temp; elim temp. (* Goal: and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) simpl in |- *; auto. Qed. Lemma cut1_cons : forall (a : Elt) (w : Word), dans a X -> cut1 (cons a w) = cons a (cut1 w). (* Goal: forall (a : Elt) (w : Word) (_ : dans a X), @eq Word (cut1 (cons a w)) (cons a (cut1 w)) *) intros a w dans_a_X. (* Goal: @eq Word nil (cut1 (cons A v)) *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : @ex2 Word (fun w : Word => @eq Word (Append (cut1 u) w) v) (fun w : Word => Deriveg X R (cut2 u) w)), @ex2 Word (fun w : Word => @eq Word (Append (cut1 (cons x u)) w) (cons x v)) (fun w : Word => Deriveg X R (cut2 (cons x u)) w) *) unfold cut1, cut in |- *. (* Goal: @eq Word (@fst Word Word (let (a0, s) := cut_spec (cons a w) in @pair Word Word a0 (let (b, _) := s in b))) (cons a (@fst Word Word (let (a, s) := cut_spec w in @pair Word Word a (let (b, _) := s in b)))) *) elim (cut_spec w). (* Goal: forall (x : Word) (p : @sig Word (fun b : Word => and (inmonoid X x) (and (@eq Word (Append x b) w) (or (@eq Word b nil) (@ex2 Elt (fun x0 : Elt => not (dans x0 X)) (fun x0 : Elt => @ex Word (fun w : Word => @eq Word b (cons x0 w)))))))), @eq Word (@fst Word Word (let (a0, s) := cut_spec (cons a w) in @pair Word Word a0 (let (b, _) := s in b))) (cons a (@fst Word Word (@pair Word Word x (let (b, _) := p in b)))) *) intros x temp; elim temp; clear temp. (* Goal: forall (x : Word) (_ : and (inmonoid X a) (and (@eq Word (Append a x) (cons A v)) (or (@eq Word x nil) (@ex2 Elt (fun x0 : Elt => not (dans x0 X)) (fun x0 : Elt => @ex Word (fun w : Word => @eq Word x (cons x0 w))))))), @eq Word nil (@fst Word Word (@pair Word Word a x)) *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : @ex2 Word (fun w : Word => @eq Word (Append (cut1 u) w) v) (fun w : Word => Deriveg X R (cut2 u) w)), @ex2 Word (fun w : Word => @eq Word (Append (cut1 (cons x u)) w) (cons x v)) (fun w : Word => Deriveg X R (cut2 (cons x u)) w) *) intros b temp; elim temp; clear temp. (* Goal: forall (_ : inmonoid X x) (_ : and (@eq Word (Append x b) w) (or (@eq Word b nil) (@ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w : Word => @eq Word b (cons x w)))))), @eq Word (@fst Word Word (let (a0, s) := cut_spec (cons a w) in @pair Word Word a0 (let (b, _) := s in b))) (cons a (@fst Word Word (@pair Word Word x b))) *) intros inmon_X_x temp; elim temp; clear temp. (* Goal: forall (_ : @eq Word (Append x b) w) (_ : or (@eq Word b nil) (@ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w : Word => @eq Word b (cons x w))))), @eq Word (@fst Word Word (let (a0, s) := cut_spec (cons a w) in @pair Word Word a0 (let (b, _) := s in b))) (cons a (@fst Word Word (@pair Word Word x b))) *) elim (cut_spec (cons a w)). (* Goal: forall (x0 : Word) (p : @sig Word (fun b : Word => and (inmonoid X x0) (and (@eq Word (Append x0 b) (cons a w)) (or (@eq Word b nil) (@ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w : Word => @eq Word b (cons x w)))))))) (_ : @eq Word (Append x b) w) (_ : or (@eq Word b nil) (@ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w : Word => @eq Word b (cons x w))))), @eq Word (@fst Word Word (@pair Word Word x0 (let (b, _) := p in b))) (cons a (@fst Word Word (@pair Word Word x b))) *) intros x' temp; elim temp; clear temp. (* Goal: forall (x0 : Word) (_ : and (inmonoid X x') (and (@eq Word (Append x' x0) (cons a w)) (or (@eq Word x0 nil) (@ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w : Word => @eq Word x0 (cons x w))))))) (_ : @eq Word (Append x b) w) (_ : or (@eq Word b nil) (@ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w : Word => @eq Word b (cons x w))))), @eq Word (@fst Word Word (@pair Word Word x' x0)) (cons a (@fst Word Word (@pair Word Word x b))) *) intros b' temp; elim temp; clear temp. (* Goal: forall (_ : inmonoid X x') (_ : and (@eq Word (Append x' b') (cons a w)) (or (@eq Word b' nil) (@ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w : Word => @eq Word b' (cons x w)))))) (_ : @eq Word (Append x b) w) (_ : or (@eq Word b nil) (@ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w : Word => @eq Word b (cons x w))))), @eq Word (@fst Word Word (@pair Word Word x' b')) (cons a (@fst Word Word (@pair Word Word x b))) *) intros inmon_X_x' temp; elim temp; clear temp. (* Goal: forall (_ : @eq Word (Append x' b') (cons a w)) (_ : or (@eq Word b' nil) (@ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w : Word => @eq Word b' (cons x w))))) (_ : @eq Word (Append x b) w) (_ : or (@eq Word b nil) (@ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w : Word => @eq Word b (cons x w))))), @eq Word (@fst Word Word (@pair Word Word x' b')) (cons a (@fst Word Word (@pair Word Word x b))) *) intros App_eg' spec' App_eg spec. (* Goal: forall (_ : Derive_P_A_3 (@pair Word Conf u1 (@pair Word Word u2 u3)) (@pair Word Conf v1 (@pair Word Word v2 v3))) (_ : forall _ : inmonoid X (@fst Word Conf (@pair Word Conf v1 (@pair Word Word v2 v3))), Rstar Word (Deriveg X R) (Append (@fst Word Conf (@pair Word Conf v1 (@pair Word Word v2 v3))) (@fst Word Word (@snd Word Conf (@pair Word Conf v1 (@pair Word Word v2 v3))))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w)))) (_ : inmonoid X (@fst Word Conf (@pair Word Conf u1 (@pair Word Word u2 u3)))), Rstar Word (Deriveg X R) (Append (@fst Word Conf (@pair Word Conf u1 (@pair Word Word u2 u3))) (@fst Word Word (@snd Word Conf (@pair Word Conf u1 (@pair Word Word u2 u3))))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w))) *) simpl in |- *. (* Goal: @eq Word x' (cons a x) *) cut (inmonoid X x'). (* Goal: forall _ : inmonoid X x', @eq Word x' (cons a x) *) (* Goal: inmonoid X x' *) cut (Append x' b' = cons a w). (* Goal: forall (_ : @eq Word (Append x' b') (cons a w)) (_ : inmonoid X x'), @eq Word x' (cons a x) *) (* Goal: @eq Word (Append x' b') (cons a w) *) (* Goal: inmonoid X x' *) clear inmon_X_x' App_eg'. (* Goal: forall (_ : @eq Word (Append x' b') (cons a w)) (_ : inmonoid X x'), @eq Word x' (cons a x) *) (* Goal: @eq Word (Append x' b') (cons a w) *) (* Goal: inmonoid X x' *) generalize x'; clear x'; simple induction x'. (* Goal: forall (_ : @eq Word (Append nil b') (cons a w)) (_ : inmonoid X nil), @eq Word nil (cons a x) *) (* Goal: forall (e : Elt) (w0 : Word) (_ : forall (_ : @eq Word (Append w0 b') (cons a w)) (_ : inmonoid X w0), @eq Word w0 (cons a x)) (_ : @eq Word (Append (cons e w0) b') (cons a w)) (_ : inmonoid X (cons e w0)), @eq Word (cons e w0) (cons a x) *) (* Goal: @eq Word (Append x' b') (cons a w) *) (* Goal: inmonoid X x' *) intro App_nil_b'_eg_cons_a_w. (* Goal: forall _ : inmonoid X nil, @eq Word nil (cons a x) *) (* Goal: forall (e : Elt) (w0 : Word) (_ : forall (_ : @eq Word (Append w0 b') (cons a w)) (_ : inmonoid X w0), @eq Word w0 (cons a x)) (_ : @eq Word (Append (cons e w0) b') (cons a w)) (_ : inmonoid X (cons e w0)), @eq Word (cons e w0) (cons a x) *) (* Goal: @eq Word (Append x' b') (cons a w) *) (* Goal: inmonoid X x' *) absurd (dans a X). (* Goal: not (dans a X) *) (* Goal: dans a X *) (* Goal: forall (e : Elt) (w0 : Word) (_ : forall (_ : @eq Word (Append w0 b') (cons a w)) (_ : inmonoid X w0), @eq Word w0 (cons a x)) (_ : @eq Word (Append (cons e w0) b') (cons a w)) (_ : inmonoid X (cons e w0)), @eq Word (cons e w0) (cons a x) *) (* Goal: @eq Word (Append x' b') (cons a w) *) (* Goal: inmonoid X x' *) elim spec'. (* Goal: forall _ : @eq Word b' nil, not (dans a X) *) (* Goal: forall _ : @ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w : Word => @eq Word b' (cons x w))), not (dans a X) *) (* Goal: dans a X *) (* Goal: forall (e : Elt) (w0 : Word) (_ : forall (_ : @eq Word (Append w0 b') (cons a w)) (_ : inmonoid X w0), @eq Word w0 (cons a x)) (_ : @eq Word (Append (cons e w0) b') (cons a w)) (_ : inmonoid X (cons e w0)), @eq Word (cons e w0) (cons a x) *) (* Goal: @eq Word (Append x' b') (cons a w) *) (* Goal: inmonoid X x' *) intro b'_nil. (* Goal: not (dans a X) *) (* Goal: forall _ : @ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w : Word => @eq Word b' (cons x w))), not (dans a X) *) (* Goal: dans a X *) (* Goal: forall (e : Elt) (w0 : Word) (_ : forall (_ : @eq Word (Append w0 b') (cons a w)) (_ : inmonoid X w0), @eq Word w0 (cons a x)) (_ : @eq Word (Append (cons e w0) b') (cons a w)) (_ : inmonoid X (cons e w0)), @eq Word (cons e w0) (cons a x) *) (* Goal: @eq Word (Append x' b') (cons a w) *) (* Goal: inmonoid X x' *) absurd (cons a w = nil). (* Goal: not (@eq Word (cons x0 (Append w v)) nil) *) (* Goal: @eq Word (cons x0 (Append w v)) nil *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) (* Goal: forall (e : Elt) (w : Word) (_ : forall (y : Word) (_ : Rstar Conf Derive_P_A_2 (@pair Word Word w y) (@pair Word Word nil nil)) (u v : Word) (_ : @eq Word (Append u v) w) (_ : inmonoid X u), @ex2 Word (fun w0 : Word => @eq Word (Append u w0) y) (fun w0 : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w0) (@pair Word Word nil nil))) (y : Word) (_ : Rstar Conf Derive_P_A_2 (@pair Word Word (cons e w) y) (@pair Word Word nil nil)) (u v : Word) (_ : @eq Word (Append u v) (cons e w)) (_ : inmonoid X u), @ex2 Word (fun w0 : Word => @eq Word (Append u w0) y) (fun w0 : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w0) (@pair Word Word nil nil)) *) discriminate. (* Goal: @eq Word (cons a w) nil *) (* Goal: forall _ : @ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w : Word => @eq Word b' (cons x w))), not (dans a X) *) (* Goal: dans a X *) (* Goal: forall (e : Elt) (w0 : Word) (_ : forall (_ : @eq Word (Append w0 b') (cons a w)) (_ : inmonoid X w0), @eq Word w0 (cons a x)) (_ : @eq Word (Append (cons e w0) b') (cons a w)) (_ : inmonoid X (cons e w0)), @eq Word (cons e w0) (cons a x) *) (* Goal: @eq Word (Append x' b') (cons a w) *) (* Goal: inmonoid X x' *) rewrite <- b'_nil. (* Goal: @eq Word (cons a w) b' *) (* Goal: forall _ : @ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w : Word => @eq Word b' (cons x w))), not (dans a X) *) (* Goal: dans a X *) (* Goal: forall (e : Elt) (w0 : Word) (_ : forall (_ : @eq Word (Append w0 b') (cons a w)) (_ : inmonoid X w0), @eq Word w0 (cons a x)) (_ : @eq Word (Append (cons e w0) b') (cons a w)) (_ : inmonoid X (cons e w0)), @eq Word (cons e w0) (cons a x) *) (* Goal: @eq Word (Append x' b') (cons a w) *) (* Goal: inmonoid X x' *) rewrite <- App_nil_b'_eg_cons_a_w. (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) trivial. (* Goal: forall (_ : @ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) (_ : @eq Word (Append u v) (cons x0 u0)) (_ : inmonoid X u), @ex2 Word (fun w : Word => @eq Word (Append u w) (cons x0 v0)) (fun w : Word => Deriveg X R v w) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) intro temp; elim temp; clear temp. (* Goal: forall (x : Elt) (_ : not (dans x X)) (_ : @ex Word (fun w : Word => @eq Word b' (cons x w))), not (dans a X) *) (* Goal: dans a X *) (* Goal: forall (e : Elt) (w0 : Word) (_ : forall (_ : @eq Word (Append w0 b') (cons a w)) (_ : inmonoid X w0), @eq Word w0 (cons a x)) (_ : @eq Word (Append (cons e w0) b') (cons a w)) (_ : inmonoid X (cons e w0)), @eq Word (cons e w0) (cons a x) *) (* Goal: @eq Word (Append x' b') (cons a w) *) (* Goal: inmonoid X x' *) intros x0 N_dans_x0_X temp; elim temp; clear temp. (* Goal: forall (x : Word) (_ : @eq Word b' (cons x0 x)), not (dans a X) *) (* Goal: dans a X *) (* Goal: forall (e : Elt) (w0 : Word) (_ : forall (_ : @eq Word (Append w0 b') (cons a w)) (_ : inmonoid X w0), @eq Word w0 (cons a x)) (_ : @eq Word (Append (cons e w0) b') (cons a w)) (_ : inmonoid X (cons e w0)), @eq Word (cons e w0) (cons a x) *) (* Goal: @eq Word (Append x' b') (cons a w) *) (* Goal: inmonoid X x' *) intros w1 eg_b'_cons. (* Goal: not (dans a X) *) (* Goal: dans a X *) (* Goal: forall (e : Elt) (w0 : Word) (_ : forall (_ : @eq Word (Append w0 b') (cons a w)) (_ : inmonoid X w0), @eq Word w0 (cons a x)) (_ : @eq Word (Append (cons e w0) b') (cons a w)) (_ : inmonoid X (cons e w0)), @eq Word (cons e w0) (cons a x) *) (* Goal: @eq Word (Append x' b') (cons a w) *) (* Goal: inmonoid X x' *) replace a with x0. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: @eq Elt x0 a *) (* Goal: dans a X *) (* Goal: forall (e : Elt) (w0 : Word) (_ : forall (_ : @eq Word (Append w0 b') (cons a w)) (_ : inmonoid X w0), @eq Word w0 (cons a x)) (_ : @eq Word (Append (cons e w0) b') (cons a w)) (_ : inmonoid X (cons e w0)), @eq Word (cons e w0) (cons a x) *) (* Goal: @eq Word (Append x' b') (cons a w) *) (* Goal: inmonoid X x' *) apply cons_cons_inv1 with w1 w. (* Goal: @eq Word (cons x0 w1) (cons a w) *) (* Goal: dans a X *) (* Goal: forall (e : Elt) (w0 : Word) (_ : forall (_ : @eq Word (Append w0 b') (cons a w)) (_ : inmonoid X w0), @eq Word w0 (cons a x)) (_ : @eq Word (Append (cons e w0) b') (cons a w)) (_ : inmonoid X (cons e w0)), @eq Word (cons e w0) (cons a x) *) (* Goal: @eq Word (Append x' b') (cons a w) *) (* Goal: inmonoid X x' *) rewrite <- eg_b'_cons. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: forall (e : Elt) (w0 : Word) (_ : forall (_ : @eq Word (Append w0 b') (cons a w)) (_ : inmonoid X w0), @eq Word w0 (cons a x)) (_ : @eq Word (Append (cons e w0) b') (cons a w)) (_ : inmonoid X (cons e w0)), @eq Word (cons e w0) (cons a x) *) (* Goal: @eq Word (Append x' b') (cons a w) *) (* Goal: inmonoid X x' *) intros x0 w0 Hyp App_eg_cons inmon_cons. (* Goal: @eq Word (cons x1 (Append w1 we)) (cons x0 v2) *) (* Goal: @eq Word (cons x1 (Append w1 we)) (Append (cons x1 w1) we) *) (* Goal: Rstar Conf Derive_P_A_2 (@pair Word Word v we) (@pair Word Word nil nil) *) (* Goal: @ex2 Word (fun w : Word => @eq Word (Append w1 w) v2) (fun w : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w) (@pair Word Word nil nil)) *) (* Goal: @ex2 Word (fun v2 : Word => @eq Word y (cons x0 v2)) (fun v2 : Word => Derivestar_P_A_2 (@pair Word Word w v2) (@pair Word Word nil nil)) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) apply cons_cons. (* Goal: @eq Elt x0 a *) (* Goal: @eq Word w0 x *) (* Goal: @eq Word (Append x' b') (cons a w) *) (* Goal: inmonoid X x' *) apply cons_cons_inv1 with (Append w0 b') w. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: @eq Word w0 x *) (* Goal: @eq Word (Append x' b') (cons a w) *) (* Goal: inmonoid X x' *) apply cut_unicite with w b' b. (* Goal: and (forall (w : Word) (_ : and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w)), and (Derivestar R (cons S' nil) w) (inmonoid X w)) (forall (w : Word) (_ : and (Derivestar R (cons S' nil) w) (inmonoid X w)), and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w)) *) split. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) apply inmonoid_cons_inv with x0; assumption. (* Goal: and (forall (w : Word) (_ : and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w)), and (Derivestar R (cons S' nil) w) (inmonoid X w)) (forall (w : Word) (_ : and (Derivestar R (cons S' nil) w) (inmonoid X w)), and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w)) *) split. (* Goal: @eq Word (Append w0 b') w *) (* Goal: or (@eq Word b' nil) (@ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w : Word => @eq Word b' (cons x w)))) *) (* Goal: and (inmonoid X x) (and (@eq Word (Append x b) w) (or (@eq Word b nil) (@ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w : Word => @eq Word b (cons x w)))))) *) (* Goal: @eq Word (Append x' b') (cons a w) *) (* Goal: inmonoid X x' *) apply cons_cons_inv2 with x0 a. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) split; auto. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. Qed. Lemma cut1_Append : forall u v : Word, inmonoid X u -> cut1 (Append u v) = Append u (cut1 v). (* Goal: forall (u v : Word) (_ : inmonoid X u), @eq Word (cut1 (Append u v)) (Append u (cut1 v)) *) intros u v. (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) generalize u; clear u; simple induction u. (* Goal: and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) auto. (* Goal: forall (e : Elt) (w : Word) (_ : forall _ : inmonoid X w, @eq Word (cut1 (Append w v)) (Append w (cut1 v))) (_ : inmonoid X (cons e w)), @eq Word (cut1 (Append (cons e w) v)) (Append (cons e w) (cut1 v)) *) intros x w Hyp inmon_x_w. (* Goal: @eq Word (cut1 (Append (cons x w) v)) (Append (cons x w) (cut1 v)) *) replace (cut1 (Append (cons x w) v)) with (cons x (cut1 (Append w v))). (* Goal: @eq Word (cons x (cut1 (Append w v))) (Append (cons x w) (cut1 v)) *) (* Goal: @eq Word (cons x (cut1 (Append w v))) (cut1 (Append (cons x w) v)) *) replace (Append (cons x w) (cut1 v)) with (cons x (Append w (cut1 v))). (* Goal: @eq Word (cons x1 (Append w1 we)) (cons x0 v2) *) (* Goal: @eq Word (cons x1 (Append w1 we)) (Append (cons x1 w1) we) *) (* Goal: Rstar Conf Derive_P_A_2 (@pair Word Word v we) (@pair Word Word nil nil) *) (* Goal: @ex2 Word (fun w : Word => @eq Word (Append w1 w) v2) (fun w : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w) (@pair Word Word nil nil)) *) (* Goal: @ex2 Word (fun v2 : Word => @eq Word y (cons x0 v2)) (fun v2 : Word => Derivestar_P_A_2 (@pair Word Word w v2) (@pair Word Word nil nil)) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) apply cons_cons. (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) trivial. (* Goal: Rstar Word (Deriveg X R) (Append v1 v2) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w))) *) apply Hyp. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) apply inmonoid_cons_inv with x; assumption. (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) trivial. (* Goal: @eq Word (Append s2 nil) (Append nil y) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) apply sym_equal. (* Goal: @eq Word (Append (cons x0 (cut1 u)) w) (cons x0 v) *) (* Goal: @eq Word (cons x0 (cut1 u)) (cut1 (cons x0 u)) *) (* Goal: Deriveg X R (cut2 (cons x0 u)) w *) unfold Append in |- *. (* Goal: forall (_ : Derive_P_A_3 (@pair Word Conf u1 (@pair Word Word u2 u3)) (@pair Word Conf v1 (@pair Word Word v2 v3))) (_ : forall _ : inmonoid X (@fst Word Conf (@pair Word Conf v1 (@pair Word Word v2 v3))), Rstar Word (Deriveg X R) (Append (@fst Word Conf (@pair Word Conf v1 (@pair Word Word v2 v3))) (@fst Word Word (@snd Word Conf (@pair Word Conf v1 (@pair Word Word v2 v3))))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w)))) (_ : inmonoid X (@fst Word Conf (@pair Word Conf u1 (@pair Word Word u2 u3)))), Rstar Word (Deriveg X R) (Append (@fst Word Conf (@pair Word Conf u1 (@pair Word Word u2 u3))) (@fst Word Word (@snd Word Conf (@pair Word Conf u1 (@pair Word Word u2 u3))))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w))) *) simpl in |- *. (* Goal: @eq Word (cut1 (cons x0 u)) (cons x0 (cut1 u)) *) (* Goal: Deriveg X R (cut2 (cons x0 u)) w *) apply cut1_cons. (* Goal: dans x0 X *) (* Goal: dans x0 V *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : forall (u0 v0 : Word) (_ : @eq Word (Append u0 v0) u) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) v) (fun w : Word => Deriveg X R v0 w)) (u0 v0 : Word) (_ : @eq Word (Append u0 v0) (cons x u)) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) (cons x v)) (fun w : Word => Deriveg X R v0 w) *) apply inmonoid_cons_inv2 with w. (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) trivial. Qed. Axiom cut2_cons : forall (A : Elt) (v : Word), dans A X -> cut2 (cons A v) = cut2 v. Lemma cut2_cons_N : forall (A : Elt) (v : Word), ~ dans A X -> cut2 (cons A v) = cons A v. (* Goal: forall (A : Elt) (v : Word) (_ : not (dans A X)), @eq Word (cut2 (cons A v)) (cons A v) *) intros A v N_dans_A_X. (* Goal: @eq Word (cut2 (cons A v)) (cons A v) *) unfold cut2, cut in |- *. (* Goal: @eq Word nil (@fst Word Word (let (a, s) := cut_spec (cons A v) in @pair Word Word a (let (b, _) := s in b))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : @ex2 Word (fun w : Word => @eq Word (Append (cut1 u) w) v) (fun w : Word => Deriveg X R (cut2 u) w)), @ex2 Word (fun w : Word => @eq Word (Append (cut1 (cons x u)) w) (cons x v)) (fun w : Word => Deriveg X R (cut2 (cons x u)) w) *) elim (cut_spec (cons A v)). (* Goal: forall (x : Word) (p : @sig Word (fun b : Word => and (inmonoid X x) (and (@eq Word (Append x b) (cons A v)) (or (@eq Word b nil) (@ex2 Elt (fun x0 : Elt => not (dans x0 X)) (fun x0 : Elt => @ex Word (fun w : Word => @eq Word b (cons x0 w)))))))), @eq Word (@snd Word Word (@pair Word Word x (let (b, _) := p in b))) (cons A v) *) intros a temp; elim temp; clear temp. (* Goal: forall (x : Word) (_ : and (inmonoid X a) (and (@eq Word (Append a x) (cons A v)) (or (@eq Word x nil) (@ex2 Elt (fun x0 : Elt => not (dans x0 X)) (fun x0 : Elt => @ex Word (fun w : Word => @eq Word x (cons x0 w))))))), @eq Word nil (@fst Word Word (@pair Word Word a x)) *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : @ex2 Word (fun w : Word => @eq Word (Append (cut1 u) w) v) (fun w : Word => Deriveg X R (cut2 u) w)), @ex2 Word (fun w : Word => @eq Word (Append (cut1 (cons x u)) w) (cons x v)) (fun w : Word => Deriveg X R (cut2 (cons x u)) w) *) intros b temp; elim temp; clear temp. (* Goal: forall (_ : inmonoid X a) (_ : and (@eq Word (Append a b) (cons A v)) (or (@eq Word b nil) (@ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w : Word => @eq Word b (cons x w)))))), @eq Word nil (@fst Word Word (@pair Word Word a b)) *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : @ex2 Word (fun w : Word => @eq Word (Append (cut1 u) w) v) (fun w : Word => Deriveg X R (cut2 u) w)), @ex2 Word (fun w : Word => @eq Word (Append (cut1 (cons x u)) w) (cons x v)) (fun w : Word => Deriveg X R (cut2 (cons x u)) w) *) intros inmon_a temp; elim temp; clear temp. (* Goal: forall (_ : @eq Word (Append a b) (cons A v)) (_ : or (@eq Word b nil) (@ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w : Word => @eq Word b (cons x w))))), @eq Word nil (@fst Word Word (@pair Word Word a b)) *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : @ex2 Word (fun w : Word => @eq Word (Append (cut1 u) w) v) (fun w : Word => Deriveg X R (cut2 u) w)), @ex2 Word (fun w : Word => @eq Word (Append (cut1 (cons x u)) w) (cons x v)) (fun w : Word => Deriveg X R (cut2 (cons x u)) w) *) intros App_eg spec_or. (* Goal: @eq Word nil (@fst Word Word (@pair Word Word a b)) *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : @ex2 Word (fun w : Word => @eq Word (Append (cut1 u) w) v) (fun w : Word => Deriveg X R (cut2 u) w)), @ex2 Word (fun w : Word => @eq Word (Append (cut1 (cons x u)) w) (cons x v)) (fun w : Word => Deriveg X R (cut2 (cons x u)) w) *) cut (inmonoid X a). (* Goal: forall _ : inmonoid X a, @eq Word nil (@fst Word Word (@pair Word Word a b)) *) (* Goal: inmonoid X a *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : @ex2 Word (fun w : Word => @eq Word (Append (cut1 u) w) v) (fun w : Word => Deriveg X R (cut2 u) w)), @ex2 Word (fun w : Word => @eq Word (Append (cut1 (cons x u)) w) (cons x v)) (fun w : Word => Deriveg X R (cut2 (cons x u)) w) *) cut (Append a b = cons A v). (* Goal: forall (_ : @eq Word (Append a b) (cons A v)) (_ : inmonoid X a), @eq Word (@snd Word Word (@pair Word Word a b)) (cons A v) *) (* Goal: @eq Word (Append a b) (cons A v) *) (* Goal: inmonoid X a *) clear App_eg inmon_a. (* Goal: forall (_ : @eq Word (Append a b) (cons A v)) (_ : inmonoid X a), @eq Word nil (@fst Word Word (@pair Word Word a b)) *) (* Goal: @eq Word (Append a b) (cons A v) *) (* Goal: inmonoid X a *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : @ex2 Word (fun w : Word => @eq Word (Append (cut1 u) w) v) (fun w : Word => Deriveg X R (cut2 u) w)), @ex2 Word (fun w : Word => @eq Word (Append (cut1 (cons x u)) w) (cons x v)) (fun w : Word => Deriveg X R (cut2 (cons x u)) w) *) generalize a; clear a; simple induction a. (* Goal: and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) auto. (* Goal: forall (e : Elt) (w : Word) (_ : forall (_ : @eq Word (Append w b) (cons A v)) (_ : inmonoid X w), @eq Word (@snd Word Word (@pair Word Word w b)) (cons A v)) (_ : @eq Word (Append (cons e w) b) (cons A v)) (_ : inmonoid X (cons e w)), @eq Word (@snd Word Word (@pair Word Word (cons e w) b)) (cons A v) *) (* Goal: @eq Word (Append a b) (cons A v) *) (* Goal: inmonoid X a *) intros x w Hyp App_eg_x_w inmon. (* Goal: @eq Word nil (@fst Word Word (@pair Word Word (cons x0 w) b)) *) (* Goal: @eq Word (Append a b) (cons A v) *) (* Goal: inmonoid X a *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : @ex2 Word (fun w : Word => @eq Word (Append (cut1 u) w) v) (fun w : Word => Deriveg X R (cut2 u) w)), @ex2 Word (fun w : Word => @eq Word (Append (cut1 (cons x u)) w) (cons x v)) (fun w : Word => Deriveg X R (cut2 (cons x u)) w) *) absurd (dans A X). (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: dans A X *) (* Goal: @eq Word (Append a b) (cons A v) *) (* Goal: inmonoid X a *) replace A with x. (* Goal: dans x0 X *) (* Goal: dans x0 V *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : forall (u0 v0 : Word) (_ : @eq Word (Append u0 v0) u) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) v) (fun w : Word => Deriveg X R v0 w)) (u0 v0 : Word) (_ : @eq Word (Append u0 v0) (cons x u)) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) (cons x v)) (fun w : Word => Deriveg X R v0 w) *) apply inmonoid_cons_inv2 with w. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: @eq Elt x0 A *) (* Goal: @eq Word (Append a b) (cons A v) *) (* Goal: inmonoid X a *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : @ex2 Word (fun w : Word => @eq Word (Append (cut1 u) w) v) (fun w : Word => Deriveg X R (cut2 u) w)), @ex2 Word (fun w : Word => @eq Word (Append (cut1 (cons x u)) w) (cons x v)) (fun w : Word => Deriveg X R (cut2 (cons x u)) w) *) apply cons_cons_inv1 with (Append w b) v. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. Qed. Lemma Deriveg_imp_Deriveg_cut : forall x y : Word, Deriveg X R x y -> ex2 (fun w : Word => Append (cut1 x) w = y) (fun w : Word => Deriveg X R (cut2 x) w). (* Goal: forall (x y : prod Word Word) (_ : Derive_P_A X (union (map f_R_d R) (map f_X_d X)) x y), Derive_P_A_2 x y *) intros x y Der. (* Goal: Derive_P_A_2 x y *) elim Der. (* Goal: forall (u : prod Word Conf) (_ : inmonoid X (@fst Word Conf u)), Rstar Word (Deriveg X R) (Append (@fst Word Conf u) (@fst Word Word (@snd Word Conf u))) (Append (@fst Word Conf u) (@fst Word Word (@snd Word Conf u))) *) (* Goal: forall (u v w : prod Word Conf) (_ : Derive_P_A_3 u v) (_ : forall _ : inmonoid X (@fst Word Conf v), Rstar Word (Deriveg X R) (Append (@fst Word Conf v) (@fst Word Word (@snd Word Conf v))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w)))) (_ : inmonoid X (@fst Word Conf u)), Rstar Word (Deriveg X R) (Append (@fst Word Conf u) (@fst Word Word (@snd Word Conf u))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w))) *) intros. (* Goal: @ex2 Word (fun w : Word => @eq Word (Append (cut1 (cons A v)) w) (Append u v)) (fun w : Word => Deriveg X R (cut2 (cons A v)) w) *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : @ex2 Word (fun w : Word => @eq Word (Append (cut1 u) w) v) (fun w : Word => Deriveg X R (cut2 u) w)), @ex2 Word (fun w : Word => @eq Word (Append (cut1 (cons x u)) w) (cons x v)) (fun w : Word => Deriveg X R (cut2 (cons x u)) w) *) replace (cut1 (cons A v)) with nil. (* Goal: @ex2 Word (fun w : Word => @eq Word (Append nil w) (Append u v)) (fun w : Word => Deriveg X R (cut2 (cons A v)) w) *) (* Goal: @eq Word nil (cut1 (cons A v)) *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : @ex2 Word (fun w : Word => @eq Word (Append (cut1 u) w) v) (fun w : Word => Deriveg X R (cut2 u) w)), @ex2 Word (fun w : Word => @eq Word (Append (cut1 (cons x u)) w) (cons x v)) (fun w : Word => Deriveg X R (cut2 (cons x u)) w) *) exists (Append u v). (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) trivial. (* Goal: Deriveg X R (cut2 (cons A v)) (Append u v) *) (* Goal: @eq Word nil (cut1 (cons A v)) *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : @ex2 Word (fun w : Word => @eq Word (Append (cut1 u) w) v) (fun w : Word => Deriveg X R (cut2 u) w)), @ex2 Word (fun w : Word => @eq Word (Append (cut1 (cons x u)) w) (cons x v)) (fun w : Word => Deriveg X R (cut2 (cons x u)) w) *) replace (cut2 (cons A v)) with (cons A v). (* Goal: Deriveg X R (cons x0 w) (Append u w) *) (* Goal: Rstar Word (Deriveg X R) (Append s0 (Append u w)) (Append s0 (Append u w)) *) apply Deriveg1. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: @eq Word (Append s2 nil) (Append nil y) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) apply sym_equal. (* Goal: @eq Word (cut2 (cons A v)) (cons A v) *) (* Goal: @eq Word nil (cut1 (cons A v)) *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : @ex2 Word (fun w : Word => @eq Word (Append (cut1 u) w) v) (fun w : Word => Deriveg X R (cut2 u) w)), @ex2 Word (fun w : Word => @eq Word (Append (cut1 (cons x u)) w) (cons x v)) (fun w : Word => Deriveg X R (cut2 (cons x u)) w) *) apply cut2_cons_N. (* Goal: not (dans A X) *) (* Goal: dans A X *) (* Goal: @eq Word (Append a b) (cons A v) *) (* Goal: inmonoid X a *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : @ex2 Word (fun w : Word => @eq Word (Append (cut1 u) w) v) (fun w : Word => Deriveg X R (cut2 u) w)), @ex2 Word (fun w : Word => @eq Word (Append (cut1 (cons x u)) w) (cons x v)) (fun w : Word => Deriveg X R (cut2 (cons x u)) w) *) apply inter_dans with V. (* Goal: inter V X empty *) (* Goal: dans A V *) (* Goal: dans A X *) (* Goal: @eq Word (Append a b) (cons A v) *) (* Goal: inmonoid X a *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : @ex2 Word (fun w : Word => @eq Word (Append (cut1 u) w) v) (fun w : Word => Deriveg X R (cut2 u) w)), @ex2 Word (fun w : Word => @eq Word (Append (cut1 (cons x u)) w) (cons x v)) (fun w : Word => Deriveg X R (cut2 (cons x u)) w) *) apply sym_inter. (* Goal: inter X V empty *) (* Goal: dans x0 X *) (* Goal: dans x0 V *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : forall (u0 v0 : Word) (_ : @eq Word (Append u0 v0) u) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) v) (fun w : Word => Deriveg X R v0 w)) (u0 v0 : Word) (_ : @eq Word (Append u0 v0) (cons x u)) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) (cons x v)) (fun w : Word => Deriveg X R v0 w) *) apply isGram2 with R S'. (* Goal: isGram X V R S' *) (* Goal: dans x0 X *) (* Goal: dans x0 V *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : forall (u0 v0 : Word) (_ : @eq Word (Append u0 v0) u) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) v) (fun w : Word => Deriveg X R v0 w)) (u0 v0 : Word) (_ : @eq Word (Append u0 v0) (cons x u)) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) (cons x v)) (fun w : Word => Deriveg X R v0 w) *) exact Gram. (* Goal: dans A V *) (* Goal: dans A X *) (* Goal: @eq Word (Append a b) (cons A v) *) (* Goal: inmonoid X a *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : @ex2 Word (fun w : Word => @eq Word (Append (cut1 u) w) v) (fun w : Word => Deriveg X R (cut2 u) w)), @ex2 Word (fun w : Word => @eq Word (Append (cut1 (cons x u)) w) (cons x v)) (fun w : Word => Deriveg X R (cut2 (cons x u)) w) *) apply Regles_inv1 with X R (word u). (* Goal: Regles X V R *) (* Goal: dans (couple A (word u)) R *) (* Goal: dans A X *) (* Goal: @eq Word (Append a b) (cons A v) *) (* Goal: inmonoid X a *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : @ex2 Word (fun w : Word => @eq Word (Append (cut1 u) w) v) (fun w : Word => Deriveg X R (cut2 u) w)), @ex2 Word (fun w : Word => @eq Word (Append (cut1 (cons x u)) w) (cons x v)) (fun w : Word => Deriveg X R (cut2 (cons x u)) w) *) apply isGram4 with S'. (* Goal: isGram X V R S' *) (* Goal: dans x0 X *) (* Goal: dans x0 V *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : forall (u0 v0 : Word) (_ : @eq Word (Append u0 v0) u) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) v) (fun w : Word => Deriveg X R v0 w)) (u0 v0 : Word) (_ : @eq Word (Append u0 v0) (cons x u)) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) (cons x v)) (fun w : Word => Deriveg X R v0 w) *) exact Gram. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: @eq Word nil (cut1 (cons A v)) *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : @ex2 Word (fun w : Word => @eq Word (Append (cut1 u) w) v) (fun w : Word => Deriveg X R (cut2 u) w)), @ex2 Word (fun w : Word => @eq Word (Append (cut1 (cons x u)) w) (cons x v)) (fun w : Word => Deriveg X R (cut2 (cons x u)) w) *) unfold cut1, cut in |- *. (* Goal: @eq Word nil (@fst Word Word (let (a, s) := cut_spec (cons A v) in @pair Word Word a (let (b, _) := s in b))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : @ex2 Word (fun w : Word => @eq Word (Append (cut1 u) w) v) (fun w : Word => Deriveg X R (cut2 u) w)), @ex2 Word (fun w : Word => @eq Word (Append (cut1 (cons x u)) w) (cons x v)) (fun w : Word => Deriveg X R (cut2 (cons x u)) w) *) elim (cut_spec (cons A v)). (* Goal: forall (x : Word) (p : @sig Word (fun b : Word => and (inmonoid X x) (and (@eq Word (Append x b) (cons A v)) (or (@eq Word b nil) (@ex2 Elt (fun x0 : Elt => not (dans x0 X)) (fun x0 : Elt => @ex Word (fun w : Word => @eq Word b (cons x0 w)))))))), @eq Word nil (@fst Word Word (@pair Word Word x (let (b, _) := p in b))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : @ex2 Word (fun w : Word => @eq Word (Append (cut1 u) w) v) (fun w : Word => Deriveg X R (cut2 u) w)), @ex2 Word (fun w : Word => @eq Word (Append (cut1 (cons x u)) w) (cons x v)) (fun w : Word => Deriveg X R (cut2 (cons x u)) w) *) intros a p. (* Goal: @eq Word nil (@fst Word Word (@pair Word Word a (let (b, _) := p in b))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : @ex2 Word (fun w : Word => @eq Word (Append (cut1 u) w) v) (fun w : Word => Deriveg X R (cut2 u) w)), @ex2 Word (fun w : Word => @eq Word (Append (cut1 (cons x u)) w) (cons x v)) (fun w : Word => Deriveg X R (cut2 (cons x u)) w) *) elim p. (* Goal: forall (x : Word) (_ : and (inmonoid X a) (and (@eq Word (Append a x) (cons A v)) (or (@eq Word x nil) (@ex2 Elt (fun x0 : Elt => not (dans x0 X)) (fun x0 : Elt => @ex Word (fun w : Word => @eq Word x (cons x0 w))))))), @eq Word nil (@fst Word Word (@pair Word Word a x)) *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : @ex2 Word (fun w : Word => @eq Word (Append (cut1 u) w) v) (fun w : Word => Deriveg X R (cut2 u) w)), @ex2 Word (fun w : Word => @eq Word (Append (cut1 (cons x u)) w) (cons x v)) (fun w : Word => Deriveg X R (cut2 (cons x u)) w) *) intros b temp; elim temp; clear temp. (* Goal: forall (_ : inmonoid X a) (_ : and (@eq Word (Append a b) (cons A v)) (or (@eq Word b nil) (@ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w : Word => @eq Word b (cons x w)))))), @eq Word nil (@fst Word Word (@pair Word Word a b)) *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : @ex2 Word (fun w : Word => @eq Word (Append (cut1 u) w) v) (fun w : Word => Deriveg X R (cut2 u) w)), @ex2 Word (fun w : Word => @eq Word (Append (cut1 (cons x u)) w) (cons x v)) (fun w : Word => Deriveg X R (cut2 (cons x u)) w) *) intros inmon_a temp; elim temp; clear temp. (* Goal: forall (_ : @eq Word (Append a b) (cons A v)) (_ : or (@eq Word b nil) (@ex2 Elt (fun x : Elt => not (dans x X)) (fun x : Elt => @ex Word (fun w : Word => @eq Word b (cons x w))))), @eq Word nil (@fst Word Word (@pair Word Word a b)) *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : @ex2 Word (fun w : Word => @eq Word (Append (cut1 u) w) v) (fun w : Word => Deriveg X R (cut2 u) w)), @ex2 Word (fun w : Word => @eq Word (Append (cut1 (cons x u)) w) (cons x v)) (fun w : Word => Deriveg X R (cut2 (cons x u)) w) *) intros App_eg spec_or. (* Goal: @eq Word nil (@fst Word Word (@pair Word Word a b)) *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : @ex2 Word (fun w : Word => @eq Word (Append (cut1 u) w) v) (fun w : Word => Deriveg X R (cut2 u) w)), @ex2 Word (fun w : Word => @eq Word (Append (cut1 (cons x u)) w) (cons x v)) (fun w : Word => Deriveg X R (cut2 (cons x u)) w) *) cut (inmonoid X a). (**)(*pour l'induction*) (* Goal: forall _ : inmonoid X a, @eq Word nil (@fst Word Word (@pair Word Word a b)) *) (* Goal: inmonoid X a *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : @ex2 Word (fun w : Word => @eq Word (Append (cut1 u) w) v) (fun w : Word => Deriveg X R (cut2 u) w)), @ex2 Word (fun w : Word => @eq Word (Append (cut1 (cons x u)) w) (cons x v)) (fun w : Word => Deriveg X R (cut2 (cons x u)) w) *) cut (Append a b = cons A v). (***)(*pour l'induction*) (* Goal: forall (_ : @eq Word (Append a b) (cons A v)) (_ : inmonoid X a), @eq Word nil (@fst Word Word (@pair Word Word a b)) *) (* Goal: @eq Word (Append a b) (cons A v) *) (* Goal: inmonoid X a *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : @ex2 Word (fun w : Word => @eq Word (Append (cut1 u) w) v) (fun w : Word => Deriveg X R (cut2 u) w)), @ex2 Word (fun w : Word => @eq Word (Append (cut1 (cons x u)) w) (cons x v)) (fun w : Word => Deriveg X R (cut2 (cons x u)) w) *) clear App_eg inmon_a p. (* Goal: forall (_ : @eq Word (Append a b) (cons A v)) (_ : inmonoid X a), @eq Word nil (@fst Word Word (@pair Word Word a b)) *) (* Goal: @eq Word (Append a b) (cons A v) *) (* Goal: inmonoid X a *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : @ex2 Word (fun w : Word => @eq Word (Append (cut1 u) w) v) (fun w : Word => Deriveg X R (cut2 u) w)), @ex2 Word (fun w : Word => @eq Word (Append (cut1 (cons x u)) w) (cons x v)) (fun w : Word => Deriveg X R (cut2 (cons x u)) w) *) generalize a; clear a; simple induction a. (* Goal: and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) auto. (* Goal: forall (e : Elt) (w : Word) (_ : forall (_ : @eq Word (Append w b) (cons A v)) (_ : inmonoid X w), @eq Word nil (@fst Word Word (@pair Word Word w b))) (_ : @eq Word (Append (cons e w) b) (cons A v)) (_ : inmonoid X (cons e w)), @eq Word nil (@fst Word Word (@pair Word Word (cons e w) b)) *) (* Goal: @eq Word (Append a b) (cons A v) *) (* Goal: inmonoid X a *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : @ex2 Word (fun w : Word => @eq Word (Append (cut1 u) w) v) (fun w : Word => Deriveg X R (cut2 u) w)), @ex2 Word (fun w : Word => @eq Word (Append (cut1 (cons x u)) w) (cons x v)) (fun w : Word => Deriveg X R (cut2 (cons x u)) w) *) intros x0 w Hyp App inmon. (* Goal: @eq Word nil (@fst Word Word (@pair Word Word (cons x0 w) b)) *) (* Goal: @eq Word (Append a b) (cons A v) *) (* Goal: inmonoid X a *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : @ex2 Word (fun w : Word => @eq Word (Append (cut1 u) w) v) (fun w : Word => Deriveg X R (cut2 u) w)), @ex2 Word (fun w : Word => @eq Word (Append (cut1 (cons x u)) w) (cons x v)) (fun w : Word => Deriveg X R (cut2 (cons x u)) w) *) absurd (dans A X). (* Goal: forall (u : prod Word Conf) (_ : inmonoid X (@fst Word Conf u)), Rstar Word (Deriveg X R) (Append (@fst Word Conf u) (@fst Word Word (@snd Word Conf u))) (Append (@fst Word Conf u) (@fst Word Word (@snd Word Conf u))) *) (* Goal: forall (u v w : prod Word Conf) (_ : Derive_P_A_3 u v) (_ : forall _ : inmonoid X (@fst Word Conf v), Rstar Word (Deriveg X R) (Append (@fst Word Conf v) (@fst Word Word (@snd Word Conf v))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w)))) (_ : inmonoid X (@fst Word Conf u)), Rstar Word (Deriveg X R) (Append (@fst Word Conf u) (@fst Word Word (@snd Word Conf u))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w))) *) intros. (* Goal: not (dans A X) *) (* Goal: dans A X *) (* Goal: @eq Word (Append a b) (cons A v) *) (* Goal: inmonoid X a *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : @ex2 Word (fun w : Word => @eq Word (Append (cut1 u) w) v) (fun w : Word => Deriveg X R (cut2 u) w)), @ex2 Word (fun w : Word => @eq Word (Append (cut1 (cons x u)) w) (cons x v)) (fun w : Word => Deriveg X R (cut2 (cons x u)) w) *) apply inter_dans with V. (* Goal: inter V X empty *) (* Goal: dans A V *) (* Goal: dans A X *) (* Goal: @eq Word (Append a b) (cons A v) *) (* Goal: inmonoid X a *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : @ex2 Word (fun w : Word => @eq Word (Append (cut1 u) w) v) (fun w : Word => Deriveg X R (cut2 u) w)), @ex2 Word (fun w : Word => @eq Word (Append (cut1 (cons x u)) w) (cons x v)) (fun w : Word => Deriveg X R (cut2 (cons x u)) w) *) apply sym_inter. (* Goal: inter X V empty *) (* Goal: dans x0 X *) (* Goal: dans x0 V *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : forall (u0 v0 : Word) (_ : @eq Word (Append u0 v0) u) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) v) (fun w : Word => Deriveg X R v0 w)) (u0 v0 : Word) (_ : @eq Word (Append u0 v0) (cons x u)) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) (cons x v)) (fun w : Word => Deriveg X R v0 w) *) apply isGram2 with R S'. (* Goal: isGram X V R S' *) (* Goal: dans x0 X *) (* Goal: dans x0 V *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : forall (u0 v0 : Word) (_ : @eq Word (Append u0 v0) u) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) v) (fun w : Word => Deriveg X R v0 w)) (u0 v0 : Word) (_ : @eq Word (Append u0 v0) (cons x u)) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) (cons x v)) (fun w : Word => Deriveg X R v0 w) *) exact Gram. (* Goal: dans A V *) (* Goal: dans A X *) (* Goal: @eq Word (Append a b) (cons A v) *) (* Goal: inmonoid X a *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : @ex2 Word (fun w : Word => @eq Word (Append (cut1 u) w) v) (fun w : Word => Deriveg X R (cut2 u) w)), @ex2 Word (fun w : Word => @eq Word (Append (cut1 (cons x u)) w) (cons x v)) (fun w : Word => Deriveg X R (cut2 (cons x u)) w) *) apply Regles_inv1 with X R (word u). (* Goal: Regles X V R *) (* Goal: dans (couple A (word u)) R *) (* Goal: dans A X *) (* Goal: @eq Word (Append a b) (cons A v) *) (* Goal: inmonoid X a *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : @ex2 Word (fun w : Word => @eq Word (Append (cut1 u) w) v) (fun w : Word => Deriveg X R (cut2 u) w)), @ex2 Word (fun w : Word => @eq Word (Append (cut1 (cons x u)) w) (cons x v)) (fun w : Word => Deriveg X R (cut2 (cons x u)) w) *) apply isGram4 with S'. (* Goal: isGram X V R S' *) (* Goal: dans x0 X *) (* Goal: dans x0 V *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : forall (u0 v0 : Word) (_ : @eq Word (Append u0 v0) u) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) v) (fun w : Word => Deriveg X R v0 w)) (u0 v0 : Word) (_ : @eq Word (Append u0 v0) (cons x u)) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) (cons x v)) (fun w : Word => Deriveg X R v0 w) *) exact Gram. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: dans x0 X *) (* Goal: dans x0 V *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : forall (u0 v0 : Word) (_ : @eq Word (Append u0 v0) u) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) v) (fun w : Word => Deriveg X R v0 w)) (u0 v0 : Word) (_ : @eq Word (Append u0 v0) (cons x u)) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) (cons x v)) (fun w : Word => Deriveg X R v0 w) *) apply inmonoid_cons_inv2 with w. (* Goal: inmonoid X (cons A w) *) (* Goal: @eq Word (Append a b) (cons A v) *) (* Goal: inmonoid X a *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : @ex2 Word (fun w : Word => @eq Word (Append (cut1 u) w) v) (fun w : Word => Deriveg X R (cut2 u) w)), @ex2 Word (fun w : Word => @eq Word (Append (cut1 (cons x u)) w) (cons x v)) (fun w : Word => Deriveg X R (cut2 (cons x u)) w) *) replace A with x0. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: @eq Elt x0 A *) (* Goal: @eq Word (Append a b) (cons A v) *) (* Goal: inmonoid X a *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : @ex2 Word (fun w : Word => @eq Word (Append (cut1 u) w) v) (fun w : Word => Deriveg X R (cut2 u) w)), @ex2 Word (fun w : Word => @eq Word (Append (cut1 (cons x u)) w) (cons x v)) (fun w : Word => Deriveg X R (cut2 (cons x u)) w) *) apply cons_cons_inv1 with (Append w b) v. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (**) (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (***) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : @ex2 Word (fun w : Word => @eq Word (Append (cut1 u) w) v) (fun w : Word => Deriveg X R (cut2 u) w)), @ex2 Word (fun w : Word => @eq Word (Append (cut1 (cons x u)) w) (cons x v)) (fun w : Word => Deriveg X R (cut2 (cons x u)) w) *) intros u v x0 dans_x0_X Deriveg_X_R_u_v temp. (* Goal: @ex2 Word (fun w : Word => @eq Word (Append (cut1 (cons x0 u)) w) (cons x0 v)) (fun w : Word => Deriveg X R (cut2 (cons x0 u)) w) *) elim temp; clear temp. (* Goal: forall (x : Word) (_ : @eq Word (Append (cut1 u) x) v) (_ : Deriveg X R (cut2 u) x), @ex2 Word (fun w : Word => @eq Word (Append (cut1 (cons x0 u)) w) (cons x0 v)) (fun w : Word => Deriveg X R (cut2 (cons x0 u)) w) *) intros w eg_App_cut Der_g_cut2. (* Goal: @ex2 Word (fun w0 : Word => @eq Word (cons x0 w0) (@fst Word Word (@pair Word Word (cons x0 w) v))) (fun w0 : Word => @ex2 Word (fun u : Word => dans (couple x0 (word u)) R) (fun u0 : Word => @eq Word (Append u0 w0) (@fst Word Word (@pair Word Word (Append u w) v)))) *) exists w. (* Goal: @eq Word (Append (cut1 (cons x0 u)) w) (cons x0 v) *) (* Goal: Deriveg X R (cut2 (cons x0 u)) w *) replace (cut1 (cons x0 u)) with (cons x0 (cut1 u)). (* Goal: @eq Word (Append (cons x0 (cut1 u)) w) (cons x0 v) *) (* Goal: @eq Word (cons x0 (cut1 u)) (cut1 (cons x0 u)) *) (* Goal: Deriveg X R (cut2 (cons x0 u)) w *) unfold Append in |- *. (* Goal: forall (_ : Derive_P_A_3 (@pair Word Conf u1 (@pair Word Word u2 u3)) (@pair Word Conf v1 (@pair Word Word v2 v3))) (_ : forall _ : inmonoid X (@fst Word Conf (@pair Word Conf v1 (@pair Word Word v2 v3))), Rstar Word (Deriveg X R) (Append (@fst Word Conf (@pair Word Conf v1 (@pair Word Word v2 v3))) (@fst Word Word (@snd Word Conf (@pair Word Conf v1 (@pair Word Word v2 v3))))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w)))) (_ : inmonoid X (@fst Word Conf (@pair Word Conf u1 (@pair Word Word u2 u3)))), Rstar Word (Deriveg X R) (Append (@fst Word Conf (@pair Word Conf u1 (@pair Word Word u2 u3))) (@fst Word Word (@snd Word Conf (@pair Word Conf u1 (@pair Word Word u2 u3))))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w))) *) simpl in |- *. (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) apply cons_cons; trivial. (* Goal: @eq Word (Append s2 nil) (Append nil y) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) apply sym_equal. (* Goal: @eq Word (cut1 (cons x0 u)) (cons x0 (cut1 u)) *) (* Goal: Deriveg X R (cut2 (cons x0 u)) w *) apply cut1_cons. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: Deriveg X R (cut2 (cons x0 u)) w *) replace (cut2 (cons x0 u)) with (cut2 u). (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: @eq Word (Append s2 nil) (Append nil y) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) apply sym_equal. (* Goal: @eq Word (cut2 (cons x0 u)) (cut2 u) *) apply cut2_cons. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. Qed. Lemma Deriveg_imp_Deriveg_App : forall x y : Word, Deriveg X R x y -> forall u v : Word, Append u v = x -> inmonoid X u -> ex2 (fun w : Word => Append u w = y) (fun w : Word => Deriveg X R v w). (* Goal: forall (x y : Word) (_ : Deriveg X R x y) (u v : Word) (_ : @eq Word (Append u v) x) (_ : inmonoid X u), @ex2 Word (fun w : Word => @eq Word (Append u w) y) (fun w : Word => Deriveg X R v w) *) intros x y Derg. (* Goal: forall (u v : Word) (_ : @eq Word (Append u v) x) (_ : inmonoid X u), @ex2 Word (fun w : Word => @eq Word (Append u w) y) (fun w : Word => Deriveg X R v w) *) elim Derg. (* Goal: forall (u v : Word) (A : Elt) (_ : dans (couple A (word u)) R) (u0 v0 : Word) (_ : @eq Word (Append u0 v0) (cons A v)) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) (Append u v)) (fun w : Word => Deriveg X R v0 w) *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : forall (u0 v0 : Word) (_ : @eq Word (Append u0 v0) u) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) v) (fun w : Word => Deriveg X R v0 w)) (u0 v0 : Word) (_ : @eq Word (Append u0 v0) (cons x u)) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) (cons x v)) (fun w : Word => Deriveg X R v0 w) *) intros u0 v0 A dans_A_u0_R u v eg_App. (* Goal: @ex2 Word (fun w : Word => @eq Word (Append u w) y) (fun w : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w) (@pair Word Word nil nil)) *) elimtype (u = nil \/ (exists w : Word, (exists x : Elt, u = cons x w))). (* Goal: forall _ : @eq Word u nil, @ex2 Word (fun w : Word => @eq Word (Append u w) y) (fun w : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w) (@pair Word Word nil nil)) *) (* Goal: forall _ : @ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w))), @ex2 Word (fun w : Word => @eq Word (Append u w) y) (fun w : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w) (@pair Word Word nil nil)) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) intros u_eg. (* Goal: forall _ : inmonoid X u, @ex2 Word (fun w : Word => @eq Word (Append u w) (Append u0 v0)) (fun w : Word => Deriveg X R v w) *) (* Goal: forall (_ : @ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) (_ : inmonoid X u), @ex2 Word (fun w : Word => @eq Word (Append u w) (Append u0 v0)) (fun w : Word => Deriveg X R v w) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : forall (u0 v0 : Word) (_ : @eq Word (Append u0 v0) u) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) v) (fun w : Word => Deriveg X R v0 w)) (u0 v0 : Word) (_ : @eq Word (Append u0 v0) (cons x u)) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) (cons x v)) (fun w : Word => Deriveg X R v0 w) *) exists (Append u0 v0). (* Goal: @eq Word (Append u v) v *) (* Goal: forall _ : @ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w))), @ex2 Word (fun w : Word => @eq Word (Append u w) y) (fun w : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w) (@pair Word Word nil nil)) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) rewrite u_eg. (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) trivial. (* Goal: Deriveg X R v (Append u0 v0) *) (* Goal: forall (_ : @ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) (_ : inmonoid X u), @ex2 Word (fun w : Word => @eq Word (Append u w) (Append u0 v0)) (fun w : Word => Deriveg X R v w) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : forall (u0 v0 : Word) (_ : @eq Word (Append u0 v0) u) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) v) (fun w : Word => Deriveg X R v0 w)) (u0 v0 : Word) (_ : @eq Word (Append u0 v0) (cons x u)) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) (cons x v)) (fun w : Word => Deriveg X R v0 w) *) replace v with (cons A v0). (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) apply Deriveg1; assumption. (* Goal: @eq Word (cons x0 w) v *) (* Goal: forall _ : @ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w))), @ex2 Word (fun w : Word => @eq Word (Append u w) y) (fun w : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w) (@pair Word Word nil nil)) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) replace v with (Append u v). (* Goal: and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) auto. (* Goal: @eq Word (Append u v) v *) (* Goal: forall _ : @ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w))), @ex2 Word (fun w : Word => @eq Word (Append u w) y) (fun w : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w) (@pair Word Word nil nil)) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) rewrite u_eg. (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) trivial. (* Goal: forall (_ : @ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) (_ : @eq Word (Append u v) (cons x0 u0)) (_ : inmonoid X u), @ex2 Word (fun w : Word => @eq Word (Append u w) (cons x0 v0)) (fun w : Word => Deriveg X R v w) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) intro temp; elim temp; clear temp. (* Goal: @ex2 Word (fun w : Word => @eq Word (Append (cut1 (cons x0 u)) w) (cons x0 v)) (fun w : Word => Deriveg X R (cut2 (cons x0 u)) w) *) intros w temp; elim temp; clear temp. (* Goal: forall (x : Elt) (_ : @eq Word u (cons x w)) (_ : inmonoid X u), @ex2 Word (fun w : Word => @eq Word (Append u w) (Append u0 v0)) (fun w : Word => Deriveg X R v w) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : forall (u0 v0 : Word) (_ : @eq Word (Append u0 v0) u) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) v) (fun w : Word => Deriveg X R v0 w)) (u0 v0 : Word) (_ : @eq Word (Append u0 v0) (cons x u)) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) (cons x v)) (fun w : Word => Deriveg X R v0 w) *) intros x0 u_eg inmon_u. (* Goal: forall _ : @eq Word (Append u0 w) (@fst Word Word z), @ex2 Word (fun v2 : Word => @eq Word v (cons x v2)) (fun v2 : Word => Derivestar_P_A_2 (@pair Word Word u v2) (@pair Word Word nil nil)) *) (* Goal: Derive_P_A_2_nind (@pair Word Word (cons x u) v) z *) (* Goal: or (@eq (prod Word Word) (@pair Word Word (cons x u) v) (@pair Word Word nil nil)) (@ex2 Conf (fun z : Conf => Derive_P_A_2 (@pair Word Word (cons x u) v) z) (fun z : Conf => Rstar (prod Word Word) Derive_P_A_2 z (@pair Word Word nil nil))) *) absurd (dans x0 V). (* Goal: not (dans x0 V) *) (* Goal: dans x0 V *) (* Goal: Derive_P_A_2_nind (@pair Word Word (cons x u) v) z *) (* Goal: or (@eq (prod Word Word) (@pair Word Word (cons x u) v) (@pair Word Word nil nil)) (@ex2 Conf (fun z : Conf => Derive_P_A_2 (@pair Word Word (cons x u) v) z) (fun z : Conf => Rstar (prod Word Word) Derive_P_A_2 z (@pair Word Word nil nil))) *) apply inter_dans with X. (* Goal: inter X V empty *) (* Goal: dans x0 X *) (* Goal: dans x0 V *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : forall (u0 v0 : Word) (_ : @eq Word (Append u0 v0) u) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) v) (fun w : Word => Deriveg X R v0 w)) (u0 v0 : Word) (_ : @eq Word (Append u0 v0) (cons x u)) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) (cons x v)) (fun w : Word => Deriveg X R v0 w) *) apply isGram2 with R S'. (* Goal: isGram X V R S' *) (* Goal: dans x0 X *) (* Goal: dans x0 V *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : forall (u0 v0 : Word) (_ : @eq Word (Append u0 v0) u) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) v) (fun w : Word => Deriveg X R v0 w)) (u0 v0 : Word) (_ : @eq Word (Append u0 v0) (cons x u)) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) (cons x v)) (fun w : Word => Deriveg X R v0 w) *) exact Gram. (* Goal: dans x0 X *) (* Goal: dans x0 V *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : forall (u0 v0 : Word) (_ : @eq Word (Append u0 v0) u) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) v) (fun w : Word => Deriveg X R v0 w)) (u0 v0 : Word) (_ : @eq Word (Append u0 v0) (cons x u)) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) (cons x v)) (fun w : Word => Deriveg X R v0 w) *) apply inmonoid_cons_inv2 with w. (* Goal: @eq Word (cons A v0) (Append (cons x0 w) v) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : forall (u0 v0 : Word) (_ : @eq Word (Append u0 v0) u) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) v) (fun w : Word => Deriveg X R v0 w)) (u0 v0 : Word) (_ : @eq Word (Append u0 v0) (cons x u)) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) (cons x v)) (fun w : Word => Deriveg X R v0 w) *) rewrite <- u_eg. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: dans x0 V *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : forall (u0 v0 : Word) (_ : @eq Word (Append u0 v0) u) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) v) (fun w : Word => Deriveg X R v0 w)) (u0 v0 : Word) (_ : @eq Word (Append u0 v0) (cons x u)) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) (cons x v)) (fun w : Word => Deriveg X R v0 w) *) replace x0 with A. (* Goal: dans x0 V *) (* Goal: Derive_P_A_2_nind (@pair Word Word (cons x u) v) z *) (* Goal: or (@eq (prod Word Word) (@pair Word Word (cons x u) v) (@pair Word Word nil nil)) (@ex2 Conf (fun z : Conf => Derive_P_A_2 (@pair Word Word (cons x u) v) z) (fun z : Conf => Rstar (prod Word Word) Derive_P_A_2 z (@pair Word Word nil nil))) *) apply Regles_inv1 with X R (word u0). (* Goal: Regles X V R *) (* Goal: dans (couple x0 (word u0)) R *) (* Goal: Derive_P_A_2_nind (@pair Word Word (cons x u) v) z *) (* Goal: or (@eq (prod Word Word) (@pair Word Word (cons x u) v) (@pair Word Word nil nil)) (@ex2 Conf (fun z : Conf => Derive_P_A_2 (@pair Word Word (cons x u) v) z) (fun z : Conf => Rstar (prod Word Word) Derive_P_A_2 z (@pair Word Word nil nil))) *) exact Regles_X_V_R. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: @eq Elt A x0 *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : forall (u0 v0 : Word) (_ : @eq Word (Append u0 v0) u) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) v) (fun w : Word => Deriveg X R v0 w)) (u0 v0 : Word) (_ : @eq Word (Append u0 v0) (cons x u)) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) (cons x v)) (fun w : Word => Deriveg X R v0 w) *) apply cons_cons_inv1 with v0 (Append w v). (* Goal: @eq Word (cons A v0) (cons x0 (Append w v)) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : forall (u0 v0 : Word) (_ : @eq Word (Append u0 v0) u) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) v) (fun w : Word => Deriveg X R v0 w)) (u0 v0 : Word) (_ : @eq Word (Append u0 v0) (cons x u)) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) (cons x v)) (fun w : Word => Deriveg X R v0 w) *) change (cons A v0 = Append (cons x0 w) v) in |- *. (* Goal: @eq Word (cons A v0) (Append (cons x0 w) v) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : forall (u0 v0 : Word) (_ : @eq Word (Append u0 v0) u) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) v) (fun w : Word => Deriveg X R v0 w)) (u0 v0 : Word) (_ : @eq Word (Append u0 v0) (cons x u)) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) (cons x v)) (fun w : Word => Deriveg X R v0 w) *) rewrite <- u_eg. (* Goal: and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) auto. (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : forall (u0 v0 : Word) (_ : @eq Word (Append u0 v0) u) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) v) (fun w : Word => Deriveg X R v0 w)) (u0 v0 : Word) (_ : @eq Word (Append u0 v0) (cons x u)) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) (cons x v)) (fun w : Word => Deriveg X R v0 w) *) clear eg_App. (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) generalize u; clear u; simple induction u. (* Goal: and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) auto. (* Goal: forall (e : Elt) (w : Word) (_ : or (@eq Word w nil) (@ex Word (fun w0 : Word => @ex Elt (fun x : Elt => @eq Word w (cons x w0))))), or (@eq Word (cons e w) nil) (@ex Word (fun w0 : Word => @ex Elt (fun x : Elt => @eq Word (cons e w) (cons x w0)))) *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : forall (u0 v0 : Word) (_ : @eq Word (Append u0 v0) u) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) v) (fun w : Word => Deriveg X R v0 w)) (u0 v0 : Word) (_ : @eq Word (Append u0 v0) (cons x u)) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) (cons x v)) (fun w : Word => Deriveg X R v0 w) *) intros x0 w hyp. (* Goal: or (@ex2 Elt (fun a : Elt => dans a X) (fun a : Elt => and (@eq Word (@fst Word Word (@pair Word Word (cons x0 w) v)) (cons a (@fst Word Word (@pair Word Word (Append u w) v)))) (@eq Word (@snd Word Word (@pair Word Word (cons x0 w) v)) (cons a (@snd Word Word (@pair Word Word (Append u w) v)))))) (@ex Elt (fun a : Elt => @ex2 Word (fun w0 : Word => @eq Word (cons a w0) (@fst Word Word (@pair Word Word (cons x0 w) v))) (fun w0 : Word => @ex2 Word (fun u : Word => dans (couple a (word u)) R) (fun u0 : Word => @eq Word (Append u0 w0) (@fst Word Word (@pair Word Word (Append u w) v)))))) *) apply or_intror. (* Goal: @ex2 Word (fun w0 : Word => @eq Word (cons x0 w0) (@fst Word Word (@pair Word Word (cons x0 w) v))) (fun w0 : Word => @ex2 Word (fun u : Word => dans (couple x0 (word u)) R) (fun u0 : Word => @eq Word (Append u0 w0) (@fst Word Word (@pair Word Word (Append u w) v)))) *) exists w. (* Goal: @ex Elt (fun a : Elt => @ex2 Word (fun w0 : Word => @eq Word (cons a w0) (@fst Word Word (@pair Word Word (cons x0 w) v))) (fun w0 : Word => @ex2 Word (fun u : Word => dans (couple a (word u)) R) (fun u0 : Word => @eq Word (Append u0 w0) (@fst Word Word (@pair Word Word (Append u w) v))))) *) exists x0. (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) trivial. (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : forall (u0 v0 : Word) (_ : @eq Word (Append u0 v0) u) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) v) (fun w : Word => Deriveg X R v0 w)) (u0 v0 : Word) (_ : @eq Word (Append u0 v0) (cons x u)) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) (cons x v)) (fun w : Word => Deriveg X R v0 w) *) intros u0 v0 x0 dans_x0_X Derg_u_v Hyp u v. (* Goal: @ex2 Word (fun w : Word => @eq Word (Append u w) y) (fun w : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w) (@pair Word Word nil nil)) *) elimtype (u = nil \/ (exists w : Word, (exists x : Elt, u = cons x w))). (* Goal: forall (_ : @eq Word u nil) (_ : @eq Word (Append u v) (cons x0 u0)) (_ : inmonoid X u), @ex2 Word (fun w : Word => @eq Word (Append u w) (cons x0 v0)) (fun w : Word => Deriveg X R v w) *) (* Goal: forall (_ : @ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) (_ : @eq Word (Append u v) (cons x0 u0)) (_ : inmonoid X u), @ex2 Word (fun w : Word => @eq Word (Append u w) (cons x0 v0)) (fun w : Word => Deriveg X R v w) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) intro eg_u. (* Goal: @eq Word (cons x1 (Append w1 v)) (Append u v) *) (* Goal: Derivestar_P_A_2 (@pair Word Word (cons x0 w) y) (@pair Word Word nil nil) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) rewrite eg_u. (* Goal: forall (_ : @eq Word (Append nil v) nil) (_ : inmonoid X nil), @ex2 Word (fun w : Word => @eq Word (Append nil w) y) (fun w : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w) (@pair Word Word nil nil)) *) (* Goal: forall (_ : @ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) (_ : @eq Word (Append u v) nil) (_ : inmonoid X u), @ex2 Word (fun w : Word => @eq Word (Append u w) y) (fun w : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w) (@pair Word Word nil nil)) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) (* Goal: forall (e : Elt) (w : Word) (_ : forall (y : Word) (_ : Rstar Conf Derive_P_A_2 (@pair Word Word w y) (@pair Word Word nil nil)) (u v : Word) (_ : @eq Word (Append u v) w) (_ : inmonoid X u), @ex2 Word (fun w0 : Word => @eq Word (Append u w0) y) (fun w0 : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w0) (@pair Word Word nil nil))) (y : Word) (_ : Rstar Conf Derive_P_A_2 (@pair Word Word (cons e w) y) (@pair Word Word nil nil)) (u v : Word) (_ : @eq Word (Append u v) (cons e w)) (_ : inmonoid X u), @ex2 Word (fun w0 : Word => @eq Word (Append u w0) y) (fun w0 : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w0) (@pair Word Word nil nil)) *) intros App_eg inmon_nil. (* Goal: @ex2 Word (fun w : Word => @eq Word (Append nil w) (cons x0 v0)) (fun w : Word => Deriveg X R v w) *) (* Goal: forall (_ : @ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) (_ : @eq Word (Append u v) (cons x0 u0)) (_ : inmonoid X u), @ex2 Word (fun w : Word => @eq Word (Append u w) (cons x0 v0)) (fun w : Word => Deriveg X R v w) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) exists (cons x0 v0). (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) trivial. (* Goal: Deriveg X R v (cons x0 v0) *) (* Goal: forall (_ : @ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) (_ : @eq Word (Append u v) (cons x0 u0)) (_ : inmonoid X u), @ex2 Word (fun w : Word => @eq Word (Append u w) (cons x0 v0)) (fun w : Word => Deriveg X R v w) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) replace v with (cons x0 u0). (* Goal: Deriveg X R (cons x0 (Append w x)) (cons x0 (Append w y)) *) apply Deriveg2. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: forall (_ : @ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) (_ : @eq Word (Append u v) (cons x0 u0)) (_ : inmonoid X u), @ex2 Word (fun w : Word => @eq Word (Append u w) (cons x0 v0)) (fun w : Word => Deriveg X R v w) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) intro temp; elim temp; clear temp. (* Goal: @ex2 Word (fun w : Word => @eq Word (Append (cut1 (cons x0 u)) w) (cons x0 v)) (fun w : Word => Deriveg X R (cut2 (cons x0 u)) w) *) intros w temp; elim temp; clear temp. (* Goal: forall (x : Elt) (_ : @eq Word u (cons x w)) (_ : @eq Word (Append u v) (cons x0 u0)) (_ : inmonoid X u), @ex2 Word (fun w : Word => @eq Word (Append u w) (cons x0 v0)) (fun w : Word => Deriveg X R v w) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) intros x1 u_eg. (* Goal: @eq Word (Append u v) v *) (* Goal: forall _ : @ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w))), @ex2 Word (fun w : Word => @eq Word (Append u w) y) (fun w : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w) (@pair Word Word nil nil)) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) rewrite u_eg. (* Goal: forall (_ : @eq Word (Append (cons x1 w) v) (cons x0 u0)) (_ : inmonoid X (cons x1 w)), @ex2 Word (fun w0 : Word => @eq Word (Append (cons x1 w) w0) (cons x0 v0)) (fun w : Word => Deriveg X R v w) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) intros App_cons_eg inmonoid_X_cons_x1_w. elimtype (ex2 (fun w1 : Word => Append w w1 = v0) (fun w1 : Word => Deriveg X R v w1)). (* Goal: forall (x : Word) (_ : @eq Word (Append w x) v0) (_ : Deriveg X R v x), @ex2 Word (fun w0 : Word => @eq Word (Append (cons x1 w) w0) (cons x0 v0)) (fun w : Word => Deriveg X R v w) *) (* Goal: @ex2 Word (fun w1 : Word => @eq Word (Append w w1) v0) (fun w1 : Word => Deriveg X R v w1) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) intros w0 App_eg Der_v_w0. (* Goal: @ex2 Word (fun w0 : Word => @eq Word (Append (cons x1 w) w0) (cons x0 v0)) (fun w : Word => Deriveg X R v w) *) (* Goal: @ex2 Word (fun w1 : Word => @eq Word (Append w w1) v0) (fun w1 : Word => Deriveg X R v w1) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) exists w0. (* Goal: @eq Word (Append (cons x1 w) w0) (cons x0 v0) *) (* Goal: Deriveg X R v w0 *) (* Goal: @ex2 Word (fun w1 : Word => @eq Word (Append w w1) v0) (fun w1 : Word => Deriveg X R v w1) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) change (cons x1 (Append w w0) = cons x0 v0) in |- *. (* Goal: @eq Word (cons x1 (Append w1 we)) (cons x0 v2) *) (* Goal: @eq Word (cons x1 (Append w1 we)) (Append (cons x1 w1) we) *) (* Goal: Rstar Conf Derive_P_A_2 (@pair Word Word v we) (@pair Word Word nil nil) *) (* Goal: @ex2 Word (fun w : Word => @eq Word (Append w1 w) v2) (fun w : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w) (@pair Word Word nil nil)) *) (* Goal: @ex2 Word (fun v2 : Word => @eq Word y (cons x0 v2)) (fun v2 : Word => Derivestar_P_A_2 (@pair Word Word w v2) (@pair Word Word nil nil)) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) apply cons_cons. (* Goal: @eq Elt x1 x0 *) (* Goal: @eq Word (Append w w0) v0 *) (* Goal: Deriveg X R v w0 *) (* Goal: @ex2 Word (fun w1 : Word => @eq Word (Append w w1) v0) (fun w1 : Word => Deriveg X R v w1) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) apply cons_cons_inv1 with (Append w v) u0. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: Rstar Word (Deriveg X R) (Append v1 v2) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w))) *) apply Hyp. (* Goal: @eq Word (Append w1 v) w *) (* Goal: inmonoid X w1 *) (* Goal: @ex2 Word (fun v2 : Word => @eq Word y (cons x0 v2)) (fun v2 : Word => Derivestar_P_A_2 (@pair Word Word w v2) (@pair Word Word nil nil)) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) apply cons_cons_inv2 with x1 x0. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: inmonoid X w1 *) (* Goal: @ex2 Word (fun v2 : Word => @eq Word y (cons x0 v2)) (fun v2 : Word => Derivestar_P_A_2 (@pair Word Word w v2) (@pair Word Word nil nil)) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) apply inmonoid_cons_inv with x1. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) generalize u; clear u; simple induction u. (* Goal: and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) auto. (* Goal: forall (e : Elt) (w : Word) (_ : or (@eq Word w nil) (@ex Word (fun w0 : Word => @ex Elt (fun x : Elt => @eq Word w (cons x w0))))), or (@eq Word (cons e w) nil) (@ex Word (fun w0 : Word => @ex Elt (fun x : Elt => @eq Word (cons e w) (cons x w0)))) *) intros x2 w hyp. (* Goal: or (@ex2 Elt (fun a : Elt => dans a X) (fun a : Elt => and (@eq Word (@fst Word Word (@pair Word Word (cons x0 w) v)) (cons a (@fst Word Word (@pair Word Word (Append u w) v)))) (@eq Word (@snd Word Word (@pair Word Word (cons x0 w) v)) (cons a (@snd Word Word (@pair Word Word (Append u w) v)))))) (@ex Elt (fun a : Elt => @ex2 Word (fun w0 : Word => @eq Word (cons a w0) (@fst Word Word (@pair Word Word (cons x0 w) v))) (fun w0 : Word => @ex2 Word (fun u : Word => dans (couple a (word u)) R) (fun u0 : Word => @eq Word (Append u0 w0) (@fst Word Word (@pair Word Word (Append u w) v)))))) *) apply or_intror. (* Goal: @ex2 Word (fun w0 : Word => @eq Word (cons x0 w0) (@fst Word Word (@pair Word Word (cons x0 w) v))) (fun w0 : Word => @ex2 Word (fun u : Word => dans (couple x0 (word u)) R) (fun u0 : Word => @eq Word (Append u0 w0) (@fst Word Word (@pair Word Word (Append u w) v)))) *) exists w. (* Goal: @ex Elt (fun x : Elt => @eq Word (cons x2 w) (cons x w)) *) exists x2. (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) trivial. Qed. Lemma Derivegstar_imp_Der_inmon : forall x y : Word, Derivegstar X R x y -> forall u v : Word, Append u v = x -> inmonoid X u -> ex2 (fun w : Word => Append u w = y) (fun w : Word => Derivegstar X R v w). (* Goal: (fun a a' : prod Word Conf => forall _ : inmonoid X (@fst Word Conf a), Derivegstar X R (Append (@fst Word Conf a) (@fst Word Word (@snd Word Conf a))) (Append (@fst Word Conf a') (@fst Word Word (@snd Word Conf a')))) (@pair Word (prod Word Word) s (@pair Word Word x y)) (@pair Word (prod Word Word) s' (@pair Word Word x' y')) *) unfold Derivegstar in |- *. (* Goal: forall (x y : Conf) (_ : forall (P : forall (_ : Conf) (_ : Conf), Prop) (_ : forall u : Conf, P u u) (_ : forall (u v w : Conf) (_ : Derive_P_A_2 u v) (_ : P v w), P u w), P x y) (s : Word), @ex Word (fun s2 : Word => Rstar (prod Word Conf) Derive_P_A_3 (@pair Word Conf s x) (@pair Word Conf s2 y)) *) intros x y Der_star. (* Goal: forall (u v : Word) (_ : @eq Word (Append u v) x) (_ : inmonoid X u), @ex2 Word (fun w : Word => @eq Word (Append u w) y) (fun w : Word => Rstar Word (Deriveg X R) v w) *) unfold Rstar in Der_star. (* Goal: forall s : Word, @ex Word (fun s2 : Word => Rstar (prod Word Conf) Derive_P_A_3 (@pair Word Conf s x) (@pair Word Conf s2 y)) *) pattern x, y in |- *. (* Goal: (fun c c0 : Conf => forall s : Word, @ex Word (fun s2 : Word => Rstar (prod Word Conf) Derive_P_A_3 (@pair Word Conf s c) (@pair Word Conf s2 c0))) x y *) apply Der_star. (* Goal: forall (u u0 v : Word) (_ : @eq Word (Append u0 v) u) (_ : inmonoid X u0), @ex2 Word (fun w : Word => @eq Word (Append u0 w) u) (fun w : Word => Rstar Word (Deriveg X R) v w) *) (* Goal: forall (u v w : Word) (_ : Deriveg X R u v) (_ : forall (u0 v0 : Word) (_ : @eq Word (Append u0 v0) v) (_ : inmonoid X u0), @ex2 Word (fun w0 : Word => @eq Word (Append u0 w0) w) (fun w0 : Word => Rstar Word (Deriveg X R) v0 w0)) (u0 v0 : Word) (_ : @eq Word (Append u0 v0) u) (_ : inmonoid X u0), @ex2 Word (fun w0 : Word => @eq Word (Append u0 w0) w) (fun w0 : Word => Rstar Word (Deriveg X R) v0 w0) *) intros; exists v. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: Rstar Word (Deriveg X R) (Append (@fst Word Conf u) (@fst Word Word (@snd Word Conf u))) (Append (@fst Word Conf u) (@fst Word Word (@snd Word Conf u))) *) (* Goal: forall (u v w : prod Word Conf) (_ : Derive_P_A_3 u v) (_ : forall _ : inmonoid X (@fst Word Conf v), Rstar Word (Deriveg X R) (Append (@fst Word Conf v) (@fst Word Word (@snd Word Conf v))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w)))) (_ : inmonoid X (@fst Word Conf u)), Rstar Word (Deriveg X R) (Append (@fst Word Conf u) (@fst Word Word (@snd Word Conf u))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w))) *) apply Rstar_reflexive. (* Goal: forall (u v w : Word) (_ : Deriveg X R u v) (_ : forall (u0 v0 : Word) (_ : @eq Word (Append u0 v0) v) (_ : inmonoid X u0), @ex2 Word (fun w0 : Word => @eq Word (Append u0 w0) w) (fun w0 : Word => Rstar Word (Deriveg X R) v0 w0)) (u0 v0 : Word) (_ : @eq Word (Append u0 v0) u) (_ : inmonoid X u0), @ex2 Word (fun w0 : Word => @eq Word (Append u0 w0) w) (fun w0 : Word => Rstar Word (Deriveg X R) v0 w0) *) intros u v w Der_u_v Hyp u0 v0 App_eg inmon_u0. elimtype (ex2 (fun w1 : Word => Append u0 w1 = v) (fun w1 : Word => Deriveg X R v0 w1)). (* Goal: forall (x : Word) (_ : @eq Word (Append u0 x) v) (_ : Deriveg X R v0 x), @ex2 Word (fun w0 : Word => @eq Word (Append u0 w0) w) (fun w : Word => Rstar Word (Deriveg X R) v0 w) *) (* Goal: @ex2 Word (fun w1 : Word => @eq Word (Append u0 w1) v) (fun w1 : Word => Deriveg X R v0 w1) *) intros w0 App_eg_u0_w0 Deriveg_v0_x0. elimtype (ex2 (fun w1 : Word => Append u0 w1 = w) (fun w1 : Word => Rstar Word (Deriveg X R) w0 w1)). (* Goal: forall (x : Word) (_ : @eq Word (Append u0 x) w) (_ : Rstar Word (Deriveg X R) w0 x), @ex2 Word (fun w0 : Word => @eq Word (Append u0 w0) w) (fun w : Word => Rstar Word (Deriveg X R) v0 w) *) (* Goal: @ex2 Word (fun w1 : Word => @eq Word (Append u0 w1) w) (fun w1 : Word => Rstar Word (Deriveg X R) w0 w1) *) (* Goal: @ex2 Word (fun w1 : Word => @eq Word (Append u0 w1) v) (fun w1 : Word => Deriveg X R v0 w1) *) intros w1 App_eg_u0_w1_w Rstar_Der. (* Goal: @ex2 Word (fun w0 : Word => @eq Word (Append u0 w0) w) (fun w : Word => Rstar Word (Deriveg X R) v0 w) *) (* Goal: @ex2 Word (fun w1 : Word => @eq Word (Append u0 w1) w) (fun w1 : Word => Rstar Word (Deriveg X R) w0 w1) *) (* Goal: @ex2 Word (fun w1 : Word => @eq Word (Append u0 w1) v) (fun w1 : Word => Deriveg X R v0 w1) *) exists w1. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: Rstar Word (Deriveg X R) v0 w1 *) (* Goal: @ex2 Word (fun w1 : Word => @eq Word (Append u0 w1) w) (fun w1 : Word => Rstar Word (Deriveg X R) w0 w1) *) (* Goal: @ex2 Word (fun w1 : Word => @eq Word (Append u0 w1) v) (fun w1 : Word => Deriveg X R v0 w1) *) apply Rstar_R with w0. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) apply Hyp; assumption. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) apply Deriveg_imp_Deriveg_App with u; assumption. Qed. Inductive Derive_P_A_2 : Conf -> Conf -> Prop := | Derive_X : forall (w u : Word) (x : Elt), dans x X -> Derive_P_A_2 (cons x w, cons x u) (w, u) | Derive_V : forall (v w u : Word) (x : Elt), dans (couple x (word u)) R -> Derive_P_A_2 (cons x w, v) (Append u w, v). Definition Derive_P_A_2_nind (x y : Conf) := ex2 (fun a : Elt => dans a X) (fun a : Elt => fst x = cons a (fst y) /\ snd x = cons a (snd y)) \/ (exists a : Elt, ex2 (fun w : Word => cons a w = fst x) (fun w : Word => ex2 (fun u : Word => dans (couple a (word u)) R) (fun u : Word => Append u w = fst y))). Lemma Derive_P_A_2_inv : forall x y : Conf, Derive_P_A_2 x y -> Derive_P_A_2_nind x y. (* Goal: forall (x y : prod Word Word) (_ : Derive_P_A X (union (map f_R_d R) (map f_X_d X)) x y), Derive_P_A_2 x y *) intros x y Der. (* Goal: forall _ : Derive_P_A_2_nind (@pair Word Word (cons x u) v) z, @ex2 Word (fun v2 : Word => @eq Word v (cons x v2)) (fun v2 : Word => Derivestar_P_A_2 (@pair Word Word u v2) (@pair Word Word nil nil)) *) (* Goal: Derive_P_A_2_nind (@pair Word Word (cons x u) v) z *) (* Goal: or (@eq (prod Word Word) (@pair Word Word (cons x u) v) (@pair Word Word nil nil)) (@ex2 Conf (fun z : Conf => Derive_P_A_2 (@pair Word Word (cons x u) v) z) (fun z : Conf => Rstar (prod Word Word) Derive_P_A_2 z (@pair Word Word nil nil))) *) unfold Derive_P_A_2_nind in |- *. (* Goal: Derive_P_A_2 x y *) elim Der. (* Goal: forall (w u : Word) (x : Elt) (_ : dans x X), @ex Word (fun s2 : Word => Derive_P_A_3 (@pair Word Conf s (@pair Word Word (cons x w) (cons x u))) (@pair Word Conf s2 (@pair Word Word w u))) *) (* Goal: forall (v w u : Word) (x : Elt) (_ : dans (couple x (word u)) R), @ex Word (fun s2 : Word => Derive_P_A_3 (@pair Word Conf s (@pair Word Word (cons x w) v)) (@pair Word Conf s2 (@pair Word Word (Append u w) v))) *) intros w u x0 dans_x0_X. (* Goal: or (@ex2 Elt (fun a : Elt => dans a X) (fun a : Elt => and (@eq Word (@fst Word Word (@pair Word Word (cons x0 w) (cons x0 u))) (cons a (@fst Word Word (@pair Word Word w u)))) (@eq Word (@snd Word Word (@pair Word Word (cons x0 w) (cons x0 u))) (cons a (@snd Word Word (@pair Word Word w u)))))) (@ex Elt (fun a : Elt => @ex2 Word (fun w0 : Word => @eq Word (cons a w0) (@fst Word Word (@pair Word Word (cons x0 w) (cons x0 u)))) (fun w0 : Word => @ex2 Word (fun u : Word => dans (couple a (word u)) R) (fun u0 : Word => @eq Word (Append u0 w0) (@fst Word Word (@pair Word Word w u)))))) *) (* Goal: forall (v w u : Word) (x : Elt) (_ : dans (couple x (word u)) R), or (@ex2 Elt (fun a : Elt => dans a X) (fun a : Elt => and (@eq Word (@fst Word Word (@pair Word Word (cons x w) v)) (cons a (@fst Word Word (@pair Word Word (Append u w) v)))) (@eq Word (@snd Word Word (@pair Word Word (cons x w) v)) (cons a (@snd Word Word (@pair Word Word (Append u w) v)))))) (@ex Elt (fun a : Elt => @ex2 Word (fun w0 : Word => @eq Word (cons a w0) (@fst Word Word (@pair Word Word (cons x w) v))) (fun w0 : Word => @ex2 Word (fun u0 : Word => dans (couple a (word u0)) R) (fun u0 : Word => @eq Word (Append u0 w0) (@fst Word Word (@pair Word Word (Append u w) v)))))) *) apply or_introl. (* Goal: and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) exists x0; auto. (* Goal: forall (v w u : Word) (x : Elt) (_ : dans (couple x (word u)) R), or (@ex2 Elt (fun a : Elt => dans a X) (fun a : Elt => and (@eq Word (@fst Word Word (@pair Word Word (cons x w) v)) (cons a (@fst Word Word (@pair Word Word (Append u w) v)))) (@eq Word (@snd Word Word (@pair Word Word (cons x w) v)) (cons a (@snd Word Word (@pair Word Word (Append u w) v)))))) (@ex Elt (fun a : Elt => @ex2 Word (fun w0 : Word => @eq Word (cons a w0) (@fst Word Word (@pair Word Word (cons x w) v))) (fun w0 : Word => @ex2 Word (fun u0 : Word => dans (couple a (word u0)) R) (fun u0 : Word => @eq Word (Append u0 w0) (@fst Word Word (@pair Word Word (Append u w) v)))))) *) intros v w u x0 dans_couple_Der. (* Goal: or (@ex2 Elt (fun a : Elt => dans a X) (fun a : Elt => and (@eq Word (@fst Word Word (@pair Word Word (cons x0 w) v)) (cons a (@fst Word Word (@pair Word Word (Append u w) v)))) (@eq Word (@snd Word Word (@pair Word Word (cons x0 w) v)) (cons a (@snd Word Word (@pair Word Word (Append u w) v)))))) (@ex Elt (fun a : Elt => @ex2 Word (fun w0 : Word => @eq Word (cons a w0) (@fst Word Word (@pair Word Word (cons x0 w) v))) (fun w0 : Word => @ex2 Word (fun u : Word => dans (couple a (word u)) R) (fun u0 : Word => @eq Word (Append u0 w0) (@fst Word Word (@pair Word Word (Append u w) v)))))) *) apply or_intror. (* Goal: @ex Elt (fun a : Elt => @ex2 Word (fun w0 : Word => @eq Word (cons a w0) (@fst Word Word (@pair Word Word (cons x0 w) v))) (fun w0 : Word => @ex2 Word (fun u : Word => dans (couple a (word u)) R) (fun u0 : Word => @eq Word (Append u0 w0) (@fst Word Word (@pair Word Word (Append u w) v))))) *) exists x0. (* Goal: @ex2 Word (fun w0 : Word => @eq Word (cons x0 w0) (@fst Word Word (@pair Word Word (cons x0 w) v))) (fun w0 : Word => @ex2 Word (fun u : Word => dans (couple x0 (word u)) R) (fun u0 : Word => @eq Word (Append u0 w0) (@fst Word Word (@pair Word Word (Append u w) v)))) *) exists w. (* Goal: and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) auto. (* Goal: and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) exists u; auto. Qed. Definition Derivestar_P_A_2 := Rstar Conf Derive_P_A_2. Lemma Der_cons_inv : forall (x : Elt) (u v : Word), dans x X -> Derivestar_P_A_2 (cons x u, v) (nil, nil) -> ex2 (fun v2 : Word => v = cons x v2) (fun v2 : Word => Derivestar_P_A_2 (u, v2) (nil, nil)). (* Goal: forall (x : Elt) (u v : Word) (_ : dans x X) (_ : Derivestar_P_A_2 (@pair Word Word (cons x u) v) (@pair Word Word nil nil)), @ex2 Word (fun v2 : Word => @eq Word v (cons x v2)) (fun v2 : Word => Derivestar_P_A_2 (@pair Word Word u v2) (@pair Word Word nil nil)) *) intros x u v dans_x_X Der_star. elimtype ((cons x u, v) = (nil, nil) \/ ex2 (fun z : Conf => Derive_P_A_2 (cons x u, v) z) (fun z : Conf => Rstar (Word * Word) Derive_P_A_2 z (nil, nil))). (* Goal: forall _ : @eq Elt (couple (word w1) (couple x0 (word w2))) (couple (word (cons (first r) nil)) (couple (eps X) (second r))), @eq Elt x0 (eps X) *) (* Goal: @ex Elt (fun r : Elt => and (dans r R) (@eq Elt (couple (word w1) (couple x0 (word w2))) (f_R_d r))) *) (* Goal: forall _ : dans (couple (word w1) (couple x0 (word w2))) (map f_X_d X), Derive_P_A_2 (@pair Word Word (Append w1 w) (cons x0 u)) (@pair Word Word (Append w2 w) u) *) (* Goal: or (dans (couple (word w1) (couple x0 (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple x0 (word w2))) (map f_X_d X)) *) (* Goal: forall (w w1 w2 u : Word) (_ : dans (couple (word w1) (couple (eps X) (word w2))) (union (map f_R_d R) (map f_X_d X))), Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) intro eg. (* Goal: @ex2 Word (fun v2 : Word => @eq Word v (cons x v2)) (fun v2 : Word => Derivestar_P_A_2 (@pair Word Word u v2) (@pair Word Word nil nil)) *) (* Goal: forall _ : @ex2 Conf (fun z : Conf => Derive_P_A_2 (@pair Word Word (cons x u) v) z) (fun z : Conf => Rstar (prod Word Word) Derive_P_A_2 z (@pair Word Word nil nil)), @ex2 Word (fun v2 : Word => @eq Word v (cons x v2)) (fun v2 : Word => Derivestar_P_A_2 (@pair Word Word u v2) (@pair Word Word nil nil)) *) (* Goal: or (@eq (prod Word Word) (@pair Word Word (cons x u) v) (@pair Word Word nil nil)) (@ex2 Conf (fun z : Conf => Derive_P_A_2 (@pair Word Word (cons x u) v) z) (fun z : Conf => Rstar (prod Word Word) Derive_P_A_2 z (@pair Word Word nil nil))) *) absurd (cons x u = nil). (* Goal: not (@eq Word (cons x0 (Append w v)) nil) *) (* Goal: @eq Word (cons x0 (Append w v)) nil *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) (* Goal: forall (e : Elt) (w : Word) (_ : forall (y : Word) (_ : Rstar Conf Derive_P_A_2 (@pair Word Word w y) (@pair Word Word nil nil)) (u v : Word) (_ : @eq Word (Append u v) w) (_ : inmonoid X u), @ex2 Word (fun w0 : Word => @eq Word (Append u w0) y) (fun w0 : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w0) (@pair Word Word nil nil))) (y : Word) (_ : Rstar Conf Derive_P_A_2 (@pair Word Word (cons e w) y) (@pair Word Word nil nil)) (u v : Word) (_ : @eq Word (Append u v) (cons e w)) (_ : inmonoid X u), @ex2 Word (fun w0 : Word => @eq Word (Append u w0) y) (fun w0 : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w0) (@pair Word Word nil nil)) *) discriminate. (* Goal: @eq Word (cons x u) nil *) (* Goal: forall _ : @ex2 Conf (fun z : Conf => Derive_P_A_2 (@pair Word Word (cons x u) v) z) (fun z : Conf => Rstar (prod Word Word) Derive_P_A_2 z (@pair Word Word nil nil)), @ex2 Word (fun v2 : Word => @eq Word v (cons x v2)) (fun v2 : Word => Derivestar_P_A_2 (@pair Word Word u v2) (@pair Word Word nil nil)) *) (* Goal: or (@eq (prod Word Word) (@pair Word Word (cons x u) v) (@pair Word Word nil nil)) (@ex2 Conf (fun z : Conf => Derive_P_A_2 (@pair Word Word (cons x u) v) z) (fun z : Conf => Rstar (prod Word Word) Derive_P_A_2 z (@pair Word Word nil nil))) *) change (fst (cons x u, v) = fst (nil, nil)) in |- *. (* Goal: @eq Word (@fst Word Word (@pair Word Word (cons x u) v)) (@fst Word Word (@pair Word Word nil nil)) *) (* Goal: forall _ : @ex2 Conf (fun z : Conf => Derive_P_A_2 (@pair Word Word (cons x u) v) z) (fun z : Conf => Rstar (prod Word Word) Derive_P_A_2 z (@pair Word Word nil nil)), @ex2 Word (fun v2 : Word => @eq Word v (cons x v2)) (fun v2 : Word => Derivestar_P_A_2 (@pair Word Word u v2) (@pair Word Word nil nil)) *) (* Goal: or (@eq (prod Word Word) (@pair Word Word (cons x u) v) (@pair Word Word nil nil)) (@ex2 Conf (fun z : Conf => Derive_P_A_2 (@pair Word Word (cons x u) v) z) (fun z : Conf => Rstar (prod Word Word) Derive_P_A_2 z (@pair Word Word nil nil))) *) apply (f_equal (fst (A:=Word) (B:=Word))). (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: forall _ : @ex2 Conf (fun z : Conf => Derive_P_A_2 (@pair Word Word (cons x u) v) z) (fun z : Conf => Rstar (prod Word Word) Derive_P_A_2 z (@pair Word Word nil nil)), @ex2 Word (fun v2 : Word => @eq Word v (cons x v2)) (fun v2 : Word => Derivestar_P_A_2 (@pair Word Word u v2) (@pair Word Word nil nil)) *) (* Goal: or (@eq (prod Word Word) (@pair Word Word (cons x u) v) (@pair Word Word nil nil)) (@ex2 Conf (fun z : Conf => Derive_P_A_2 (@pair Word Word (cons x u) v) z) (fun z : Conf => Rstar (prod Word Word) Derive_P_A_2 z (@pair Word Word nil nil))) *) intro temp; elim temp; clear temp; intros z Der Der_star_2. (* Goal: @ex2 Word (fun v2 : Word => @eq Word v (cons x v2)) (fun v2 : Word => Derivestar_P_A_2 (@pair Word Word u v2) (@pair Word Word nil nil)) *) (* Goal: or (@eq (prod Word Word) (@pair Word Word (cons x u) v) (@pair Word Word nil nil)) (@ex2 Conf (fun z : Conf => Derive_P_A_2 (@pair Word Word (cons x u) v) z) (fun z : Conf => Rstar (prod Word Word) Derive_P_A_2 z (@pair Word Word nil nil))) *) cut (Derive_P_A_2_nind (cons x u, v) z). (* Goal: forall _ : Derive_P_A_2_nind (@pair Word Word (cons x u) v) z, @ex2 Word (fun v2 : Word => @eq Word v (cons x v2)) (fun v2 : Word => Derivestar_P_A_2 (@pair Word Word u v2) (@pair Word Word nil nil)) *) (* Goal: Derive_P_A_2_nind (@pair Word Word (cons x u) v) z *) (* Goal: or (@eq (prod Word Word) (@pair Word Word (cons x u) v) (@pair Word Word nil nil)) (@ex2 Conf (fun z : Conf => Derive_P_A_2 (@pair Word Word (cons x u) v) z) (fun z : Conf => Rstar (prod Word Word) Derive_P_A_2 z (@pair Word Word nil nil))) *) unfold Derive_P_A_2_nind in |- *. (* Goal: forall (_ : @ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) (_ : @eq Word (Append u v) (cons x0 u0)) (_ : inmonoid X u), @ex2 Word (fun w : Word => @eq Word (Append u w) (cons x0 v0)) (fun w : Word => Deriveg X R v w) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) intro temp; elim temp; clear temp; intro temp; elim temp; clear temp. (* Goal: forall (_ : Derive_P_A_3 (@pair Word Conf u1 (@pair Word Word u2 u3)) (@pair Word Conf v1 (@pair Word Word v2 v3))) (_ : forall _ : inmonoid X (@fst Word Conf (@pair Word Conf v1 (@pair Word Word v2 v3))), Rstar Word (Deriveg X R) (Append (@fst Word Conf (@pair Word Conf v1 (@pair Word Word v2 v3))) (@fst Word Word (@snd Word Conf (@pair Word Conf v1 (@pair Word Word v2 v3))))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w)))) (_ : inmonoid X (@fst Word Conf (@pair Word Conf u1 (@pair Word Word u2 u3)))), Rstar Word (Deriveg X R) (Append (@fst Word Conf (@pair Word Conf u1 (@pair Word Word u2 u3))) (@fst Word Word (@snd Word Conf (@pair Word Conf u1 (@pair Word Word u2 u3))))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w))) *) simpl in |- *. (* Goal: @ex2 Word (fun w : Word => @eq Word (Append (cut1 (cons x0 u)) w) (cons x0 v)) (fun w : Word => Deriveg X R (cut2 (cons x0 u)) w) *) intros x0 dans_x0_X temp; elim temp; clear temp. (* Goal: forall (_ : @eq Word (cons x u) (cons x0 (@fst Word Word z))) (_ : @eq Word v (cons x0 (@snd Word Word z))), @ex2 Word (fun v2 : Word => @eq Word v (cons x v2)) (fun v2 : Word => Derivestar_P_A_2 (@pair Word Word u v2) (@pair Word Word nil nil)) *) (* Goal: forall (x0 : Elt) (_ : @ex2 Word (fun w : Word => @eq Word (cons x0 w) (@fst Word Word (@pair Word Word (cons x u) v))) (fun w : Word => @ex2 Word (fun u : Word => dans (couple x0 (word u)) R) (fun u : Word => @eq Word (Append u w) (@fst Word Word z)))), @ex2 Word (fun v2 : Word => @eq Word v (cons x v2)) (fun v2 : Word => Derivestar_P_A_2 (@pair Word Word u v2) (@pair Word Word nil nil)) *) (* Goal: Derive_P_A_2_nind (@pair Word Word (cons x u) v) z *) (* Goal: or (@eq (prod Word Word) (@pair Word Word (cons x u) v) (@pair Word Word nil nil)) (@ex2 Conf (fun z : Conf => Derive_P_A_2 (@pair Word Word (cons x u) v) z) (fun z : Conf => Rstar (prod Word Word) Derive_P_A_2 z (@pair Word Word nil nil))) *) intros eg_cons_x_x0 eg_v_cons. (* Goal: @ex2 Word (fun v2 : Word => @eq Word v (cons x v2)) (fun v2 : Word => Derivestar_P_A_2 (@pair Word Word u v2) (@pair Word Word nil nil)) *) (* Goal: forall (x0 : Elt) (_ : @ex2 Word (fun w : Word => @eq Word (cons x0 w) (@fst Word Word (@pair Word Word (cons x u) v))) (fun w : Word => @ex2 Word (fun u : Word => dans (couple x0 (word u)) R) (fun u : Word => @eq Word (Append u w) (@fst Word Word z)))), @ex2 Word (fun v2 : Word => @eq Word v (cons x v2)) (fun v2 : Word => Derivestar_P_A_2 (@pair Word Word u v2) (@pair Word Word nil nil)) *) (* Goal: Derive_P_A_2_nind (@pair Word Word (cons x u) v) z *) (* Goal: or (@eq (prod Word Word) (@pair Word Word (cons x u) v) (@pair Word Word nil nil)) (@ex2 Conf (fun z : Conf => Derive_P_A_2 (@pair Word Word (cons x u) v) z) (fun z : Conf => Rstar (prod Word Word) Derive_P_A_2 z (@pair Word Word nil nil))) *) exists (snd z). (* Goal: @eq Word v (cons x (@snd Word Word z)) *) (* Goal: Derivestar_P_A_2 (@pair Word Word u (@snd Word Word z)) (@pair Word Word nil nil) *) (* Goal: forall (x0 : Elt) (_ : @ex2 Word (fun w : Word => @eq Word (cons x0 w) (@fst Word Word (@pair Word Word (cons x u) v))) (fun w : Word => @ex2 Word (fun u : Word => dans (couple x0 (word u)) R) (fun u : Word => @eq Word (Append u w) (@fst Word Word z)))), @ex2 Word (fun v2 : Word => @eq Word v (cons x v2)) (fun v2 : Word => Derivestar_P_A_2 (@pair Word Word u v2) (@pair Word Word nil nil)) *) (* Goal: Derive_P_A_2_nind (@pair Word Word (cons x u) v) z *) (* Goal: or (@eq (prod Word Word) (@pair Word Word (cons x u) v) (@pair Word Word nil nil)) (@ex2 Conf (fun z : Conf => Derive_P_A_2 (@pair Word Word (cons x u) v) z) (fun z : Conf => Rstar (prod Word Word) Derive_P_A_2 z (@pair Word Word nil nil))) *) replace x with x0. (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) trivial. (* Goal: @eq Elt x0 x *) (* Goal: Derivestar_P_A_2 (@pair Word Word u (@snd Word Word z)) (@pair Word Word nil nil) *) (* Goal: forall (x0 : Elt) (_ : @ex2 Word (fun w : Word => @eq Word (cons x0 w) (@fst Word Word (@pair Word Word (cons x u) v))) (fun w : Word => @ex2 Word (fun u : Word => dans (couple x0 (word u)) R) (fun u : Word => @eq Word (Append u w) (@fst Word Word z)))), @ex2 Word (fun v2 : Word => @eq Word v (cons x v2)) (fun v2 : Word => Derivestar_P_A_2 (@pair Word Word u v2) (@pair Word Word nil nil)) *) (* Goal: Derive_P_A_2_nind (@pair Word Word (cons x u) v) z *) (* Goal: or (@eq (prod Word Word) (@pair Word Word (cons x u) v) (@pair Word Word nil nil)) (@ex2 Conf (fun z : Conf => Derive_P_A_2 (@pair Word Word (cons x u) v) z) (fun z : Conf => Rstar (prod Word Word) Derive_P_A_2 z (@pair Word Word nil nil))) *) apply cons_cons_inv1 with (fst z) u. (* Goal: and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) auto. (* Goal: Derivestar_P_A_2 (@pair Word Word (cons x0 u0) (cons x0 x1)) (@pair Word Word nil nil) *) (* Goal: @ex2 Word (fun v2 : Word => @eq Word w0 (cons x0 v2)) (fun v2 : Word => Derivestar_P_A_2 (@pair Word Word v0 v2) (@pair Word Word nil nil)) *) unfold Derivestar_P_A_2 in |- *. (* Goal: Rstar Conf Derive_P_A_2 (@pair Word Word u (@snd Word Word z)) (@pair Word Word nil nil) *) (* Goal: forall (x0 : Elt) (_ : @ex2 Word (fun w : Word => @eq Word (cons x0 w) (@fst Word Word (@pair Word Word (cons x u) v))) (fun w : Word => @ex2 Word (fun u : Word => dans (couple x0 (word u)) R) (fun u : Word => @eq Word (Append u w) (@fst Word Word z)))), @ex2 Word (fun v2 : Word => @eq Word v (cons x v2)) (fun v2 : Word => Derivestar_P_A_2 (@pair Word Word u v2) (@pair Word Word nil nil)) *) (* Goal: Derive_P_A_2_nind (@pair Word Word (cons x u) v) z *) (* Goal: or (@eq (prod Word Word) (@pair Word Word (cons x u) v) (@pair Word Word nil nil)) (@ex2 Conf (fun z : Conf => Derive_P_A_2 (@pair Word Word (cons x u) v) z) (fun z : Conf => Rstar (prod Word Word) Derive_P_A_2 z (@pair Word Word nil nil))) *) replace u with (fst z). (* Goal: Rstar Conf Derive_P_A_2 (@pair Word Word (@fst Word Word z) (@snd Word Word z)) (@pair Word Word nil nil) *) (* Goal: @eq Word (@fst Word Word z) u *) (* Goal: forall (x0 : Elt) (_ : @ex2 Word (fun w : Word => @eq Word (cons x0 w) (@fst Word Word (@pair Word Word (cons x u) v))) (fun w : Word => @ex2 Word (fun u : Word => dans (couple x0 (word u)) R) (fun u : Word => @eq Word (Append u w) (@fst Word Word z)))), @ex2 Word (fun v2 : Word => @eq Word v (cons x v2)) (fun v2 : Word => Derivestar_P_A_2 (@pair Word Word u v2) (@pair Word Word nil nil)) *) (* Goal: Derive_P_A_2_nind (@pair Word Word (cons x u) v) z *) (* Goal: or (@eq (prod Word Word) (@pair Word Word (cons x u) v) (@pair Word Word nil nil)) (@ex2 Conf (fun z : Conf => Derive_P_A_2 (@pair Word Word (cons x u) v) z) (fun z : Conf => Rstar (prod Word Word) Derive_P_A_2 z (@pair Word Word nil nil))) *) cut (Rstar (Word * Word) Derive_P_A_2 z (nil, nil)). (* Goal: forall _ : Rstar (prod Word Word) Derive_P_A_2 z (@pair Word Word nil nil), Rstar Conf Derive_P_A_2 (@pair Word Word (@fst Word Word z) (@snd Word Word z)) (@pair Word Word nil nil) *) (* Goal: Rstar (prod Word Word) Derive_P_A_2 z (@pair Word Word nil nil) *) (* Goal: @eq Word (@fst Word Word z) u *) (* Goal: forall (x0 : Elt) (_ : @ex2 Word (fun w : Word => @eq Word (cons x0 w) (@fst Word Word (@pair Word Word (cons x u) v))) (fun w : Word => @ex2 Word (fun u : Word => dans (couple x0 (word u)) R) (fun u : Word => @eq Word (Append u w) (@fst Word Word z)))), @ex2 Word (fun v2 : Word => @eq Word v (cons x v2)) (fun v2 : Word => Derivestar_P_A_2 (@pair Word Word u v2) (@pair Word Word nil nil)) *) (* Goal: Derive_P_A_2_nind (@pair Word Word (cons x u) v) z *) (* Goal: or (@eq (prod Word Word) (@pair Word Word (cons x u) v) (@pair Word Word nil nil)) (@ex2 Conf (fun z : Conf => Derive_P_A_2 (@pair Word Word (cons x u) v) z) (fun z : Conf => Rstar (prod Word Word) Derive_P_A_2 z (@pair Word Word nil nil))) *) elim z. (* Goal: and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) auto. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: @eq Word (@fst Word Word z) u *) (* Goal: forall (x0 : Elt) (_ : @ex2 Word (fun w : Word => @eq Word (cons x0 w) (@fst Word Word (@pair Word Word (cons x u) v))) (fun w : Word => @ex2 Word (fun u : Word => dans (couple x0 (word u)) R) (fun u : Word => @eq Word (Append u w) (@fst Word Word z)))), @ex2 Word (fun v2 : Word => @eq Word v (cons x v2)) (fun v2 : Word => Derivestar_P_A_2 (@pair Word Word u v2) (@pair Word Word nil nil)) *) (* Goal: Derive_P_A_2_nind (@pair Word Word (cons x u) v) z *) (* Goal: or (@eq (prod Word Word) (@pair Word Word (cons x u) v) (@pair Word Word nil nil)) (@ex2 Conf (fun z : Conf => Derive_P_A_2 (@pair Word Word (cons x u) v) z) (fun z : Conf => Rstar (prod Word Word) Derive_P_A_2 z (@pair Word Word nil nil))) *) apply cons_cons_inv2 with x0 x. (* Goal: and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) auto. (* Goal: forall (_ : Derive_P_A_3 (@pair Word Conf u1 (@pair Word Word u2 u3)) (@pair Word Conf v1 (@pair Word Word v2 v3))) (_ : forall _ : inmonoid X (@fst Word Conf (@pair Word Conf v1 (@pair Word Word v2 v3))), Rstar Word (Deriveg X R) (Append (@fst Word Conf (@pair Word Conf v1 (@pair Word Word v2 v3))) (@fst Word Word (@snd Word Conf (@pair Word Conf v1 (@pair Word Word v2 v3))))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w)))) (_ : inmonoid X (@fst Word Conf (@pair Word Conf u1 (@pair Word Word u2 u3)))), Rstar Word (Deriveg X R) (Append (@fst Word Conf (@pair Word Conf u1 (@pair Word Word u2 u3))) (@fst Word Word (@snd Word Conf (@pair Word Conf u1 (@pair Word Word u2 u3))))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w))) *) simpl in |- *. intros x0 temp; elim temp; clear temp; intros w eg temp; elim temp; clear temp. (* Goal: forall (x1 : Word) (_ : dans (couple x0 (word x1)) R) (_ : @eq Word (Append x1 w) (@fst Word Word z)), @ex2 Word (fun v2 : Word => @eq Word v (cons x v2)) (fun v2 : Word => Derivestar_P_A_2 (@pair Word Word u v2) (@pair Word Word nil nil)) *) (* Goal: Derive_P_A_2_nind (@pair Word Word (cons x u) v) z *) (* Goal: or (@eq (prod Word Word) (@pair Word Word (cons x u) v) (@pair Word Word nil nil)) (@ex2 Conf (fun z : Conf => Derive_P_A_2 (@pair Word Word (cons x u) v) z) (fun z : Conf => Rstar (prod Word Word) Derive_P_A_2 z (@pair Word Word nil nil))) *) intros u0 dans_couple. (* Goal: forall _ : @eq Word (Append u0 w) (@fst Word Word z), @ex2 Word (fun v2 : Word => @eq Word v (cons x v2)) (fun v2 : Word => Derivestar_P_A_2 (@pair Word Word u v2) (@pair Word Word nil nil)) *) (* Goal: Derive_P_A_2_nind (@pair Word Word (cons x u) v) z *) (* Goal: or (@eq (prod Word Word) (@pair Word Word (cons x u) v) (@pair Word Word nil nil)) (@ex2 Conf (fun z : Conf => Derive_P_A_2 (@pair Word Word (cons x u) v) z) (fun z : Conf => Rstar (prod Word Word) Derive_P_A_2 z (@pair Word Word nil nil))) *) absurd (dans x0 V). (* Goal: not (dans x0 V) *) (* Goal: dans x0 V *) (* Goal: Derive_P_A_2_nind (@pair Word Word (cons x u) v) z *) (* Goal: or (@eq (prod Word Word) (@pair Word Word (cons x u) v) (@pair Word Word nil nil)) (@ex2 Conf (fun z : Conf => Derive_P_A_2 (@pair Word Word (cons x u) v) z) (fun z : Conf => Rstar (prod Word Word) Derive_P_A_2 z (@pair Word Word nil nil))) *) apply inter_dans with X. (* Goal: inter X V empty *) (* Goal: dans x0 X *) (* Goal: dans x0 V *) (* Goal: Derive_P_A_2_nind (@pair Word Word (cons x u) v) z *) (* Goal: or (@eq (prod Word Word) (@pair Word Word (cons x u) v) (@pair Word Word nil nil)) (@ex2 Conf (fun z : Conf => Derive_P_A_2 (@pair Word Word (cons x u) v) z) (fun z : Conf => Rstar (prod Word Word) Derive_P_A_2 z (@pair Word Word nil nil))) *) exact (isGram2 X V R S' Gram). (* Goal: dans x0 X *) (* Goal: dans x0 V *) (* Goal: Derive_P_A_2_nind (@pair Word Word (cons x u) v) z *) (* Goal: or (@eq (prod Word Word) (@pair Word Word (cons x u) v) (@pair Word Word nil nil)) (@ex2 Conf (fun z : Conf => Derive_P_A_2 (@pair Word Word (cons x u) v) z) (fun z : Conf => Rstar (prod Word Word) Derive_P_A_2 z (@pair Word Word nil nil))) *) replace x0 with x. (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) trivial. (* Goal: @eq Elt x x0 *) (* Goal: dans x0 V *) (* Goal: Derive_P_A_2_nind (@pair Word Word (cons x u) v) z *) (* Goal: or (@eq (prod Word Word) (@pair Word Word (cons x u) v) (@pair Word Word nil nil)) (@ex2 Conf (fun z : Conf => Derive_P_A_2 (@pair Word Word (cons x u) v) z) (fun z : Conf => Rstar (prod Word Word) Derive_P_A_2 z (@pair Word Word nil nil))) *) apply cons_cons_inv1 with u w. (* Goal: and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) auto. (* Goal: dans x0 V *) (* Goal: Derive_P_A_2_nind (@pair Word Word (cons x u) v) z *) (* Goal: or (@eq (prod Word Word) (@pair Word Word (cons x u) v) (@pair Word Word nil nil)) (@ex2 Conf (fun z : Conf => Derive_P_A_2 (@pair Word Word (cons x u) v) z) (fun z : Conf => Rstar (prod Word Word) Derive_P_A_2 z (@pair Word Word nil nil))) *) apply Regles_inv1 with X R (word u0). (* Goal: Regles X V R *) (* Goal: dans (couple x0 (word u0)) R *) (* Goal: Derive_P_A_2_nind (@pair Word Word (cons x u) v) z *) (* Goal: or (@eq (prod Word Word) (@pair Word Word (cons x u) v) (@pair Word Word nil nil)) (@ex2 Conf (fun z : Conf => Derive_P_A_2 (@pair Word Word (cons x u) v) z) (fun z : Conf => Rstar (prod Word Word) Derive_P_A_2 z (@pair Word Word nil nil))) *) exact Regles_X_V_R. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: Derive_P_A_2_nind (@pair Word Word (cons x u) v) z *) (* Goal: or (@eq (prod Word Word) (@pair Word Word (cons x u) v) (@pair Word Word nil nil)) (@ex2 Conf (fun z : Conf => Derive_P_A_2 (@pair Word Word (cons x u) v) z) (fun z : Conf => Rstar (prod Word Word) Derive_P_A_2 z (@pair Word Word nil nil))) *) apply Derive_P_A_2_inv. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: or (@eq (prod Word Word) (@pair Word Word (cons x u) v) (@pair Word Word nil nil)) (@ex2 Conf (fun z : Conf => Derive_P_A_2 (@pair Word Word (cons x u) v) z) (fun z : Conf => Rstar (prod Word Word) Derive_P_A_2 z (@pair Word Word nil nil))) *) apply Rstar_inv. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. Qed. Lemma Derive_P_A_2_imp_Der_P_A_2_App : forall x y : Word, Derivestar_P_A_2 (x, y) (nil, nil) -> forall u v : Word, Append u v = x -> inmonoid X u -> ex2 (fun w : Word => Append u w = y) (fun w : Word => Derivestar_P_A_2 (v, w) (nil, nil)). (* Goal: Derivestar_P_A_2 (@pair Word Word (cons x0 u0) (cons x0 x1)) (@pair Word Word nil nil) *) (* Goal: @ex2 Word (fun v2 : Word => @eq Word w0 (cons x0 v2)) (fun v2 : Word => Derivestar_P_A_2 (@pair Word Word v0 v2) (@pair Word Word nil nil)) *) unfold Derivestar_P_A_2 in |- *. (* Goal: forall (x : Word) (_ : inmonoid X x), Rstar Conf Derive_P_A_2 (@pair Word Word x x) (@pair Word Word nil nil) *) simple induction x. (* Goal: forall (y : Word) (_ : Rstar Conf Derive_P_A_2 (@pair Word Word nil y) (@pair Word Word nil nil)) (u v : Word) (_ : @eq Word (Append u v) nil) (_ : inmonoid X u), @ex2 Word (fun w : Word => @eq Word (Append u w) y) (fun w : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w) (@pair Word Word nil nil)) *) (* Goal: forall (e : Elt) (w : Word) (_ : forall (y : Word) (_ : Rstar Conf Derive_P_A_2 (@pair Word Word w y) (@pair Word Word nil nil)) (u v : Word) (_ : @eq Word (Append u v) w) (_ : inmonoid X u), @ex2 Word (fun w0 : Word => @eq Word (Append u w0) y) (fun w0 : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w0) (@pair Word Word nil nil))) (y : Word) (_ : Rstar Conf Derive_P_A_2 (@pair Word Word (cons e w) y) (@pair Word Word nil nil)) (u v : Word) (_ : @eq Word (Append u v) (cons e w)) (_ : inmonoid X u), @ex2 Word (fun w0 : Word => @eq Word (Append u w0) y) (fun w0 : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w0) (@pair Word Word nil nil)) *) intros y Der_P_A_2 u v. (* Goal: @ex2 Word (fun w : Word => @eq Word (Append u w) y) (fun w : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w) (@pair Word Word nil nil)) *) elimtype (u = nil \/ (exists w : Word, (exists x : Elt, u = cons x w))). (* Goal: forall _ : @eq Word u nil, @ex2 Word (fun w : Word => @eq Word (Append u w) y) (fun w : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w) (@pair Word Word nil nil)) *) (* Goal: forall _ : @ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w))), @ex2 Word (fun w : Word => @eq Word (Append u w) y) (fun w : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w) (@pair Word Word nil nil)) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) intros u_eg. (* Goal: @eq Word (Append u v) v *) (* Goal: forall _ : @ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w))), @ex2 Word (fun w : Word => @eq Word (Append u w) y) (fun w : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w) (@pair Word Word nil nil)) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) rewrite u_eg. (* Goal: forall (_ : @eq Word (Append nil v) nil) (_ : inmonoid X nil), @ex2 Word (fun w : Word => @eq Word (Append nil w) y) (fun w : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w) (@pair Word Word nil nil)) *) (* Goal: forall (_ : @ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) (_ : @eq Word (Append u v) nil) (_ : inmonoid X u), @ex2 Word (fun w : Word => @eq Word (Append u w) y) (fun w : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w) (@pair Word Word nil nil)) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) (* Goal: forall (e : Elt) (w : Word) (_ : forall (y : Word) (_ : Rstar Conf Derive_P_A_2 (@pair Word Word w y) (@pair Word Word nil nil)) (u v : Word) (_ : @eq Word (Append u v) w) (_ : inmonoid X u), @ex2 Word (fun w0 : Word => @eq Word (Append u w0) y) (fun w0 : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w0) (@pair Word Word nil nil))) (y : Word) (_ : Rstar Conf Derive_P_A_2 (@pair Word Word (cons e w) y) (@pair Word Word nil nil)) (u v : Word) (_ : @eq Word (Append u v) (cons e w)) (_ : inmonoid X u), @ex2 Word (fun w0 : Word => @eq Word (Append u w0) y) (fun w0 : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w0) (@pair Word Word nil nil)) *) intros App_eg inmon_nil. (* Goal: and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) exists y; auto. (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) replace v with nil; trivial. (* Goal: @ex2 Word (fun w : Word => @eq Word (Append (cut1 (cons x0 u)) w) (cons x0 v)) (fun w : Word => Deriveg X R (cut2 (cons x0 u)) w) *) intro temp; elim temp; clear temp; intros w temp; elim temp; clear temp. (* Goal: forall (x : Elt) (_ : @eq Word u (cons x w)) (_ : @eq Word (Append u v) nil) (_ : inmonoid X u), @ex2 Word (fun w : Word => @eq Word (Append u w) y) (fun w : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w) (@pair Word Word nil nil)) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) (* Goal: forall (e : Elt) (w : Word) (_ : forall (y : Word) (_ : Rstar Conf Derive_P_A_2 (@pair Word Word w y) (@pair Word Word nil nil)) (u v : Word) (_ : @eq Word (Append u v) w) (_ : inmonoid X u), @ex2 Word (fun w0 : Word => @eq Word (Append u w0) y) (fun w0 : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w0) (@pair Word Word nil nil))) (y : Word) (_ : Rstar Conf Derive_P_A_2 (@pair Word Word (cons e w) y) (@pair Word Word nil nil)) (u v : Word) (_ : @eq Word (Append u v) (cons e w)) (_ : inmonoid X u), @ex2 Word (fun w0 : Word => @eq Word (Append u w0) y) (fun w0 : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w0) (@pair Word Word nil nil)) *) intros x0 eg_u. (* Goal: @eq Word (cons x1 (Append w1 v)) (Append u v) *) (* Goal: Derivestar_P_A_2 (@pair Word Word (cons x0 w) y) (@pair Word Word nil nil) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) rewrite eg_u. (* Goal: forall (_ : @eq Word (Append (cons x0 w) v) nil) (_ : inmonoid X (cons x0 w)), @ex2 Word (fun w0 : Word => @eq Word (Append (cons x0 w) w0) y) (fun w : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w) (@pair Word Word nil nil)) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) (* Goal: forall (e : Elt) (w : Word) (_ : forall (y : Word) (_ : Rstar Conf Derive_P_A_2 (@pair Word Word w y) (@pair Word Word nil nil)) (u v : Word) (_ : @eq Word (Append u v) w) (_ : inmonoid X u), @ex2 Word (fun w0 : Word => @eq Word (Append u w0) y) (fun w0 : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w0) (@pair Word Word nil nil))) (y : Word) (_ : Rstar Conf Derive_P_A_2 (@pair Word Word (cons e w) y) (@pair Word Word nil nil)) (u v : Word) (_ : @eq Word (Append u v) (cons e w)) (_ : inmonoid X u), @ex2 Word (fun w0 : Word => @eq Word (Append u w0) y) (fun w0 : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w0) (@pair Word Word nil nil)) *) intros cons_eg_nil. (* Goal: forall _ : inmonoid X (cons x0 w), @ex2 Word (fun w0 : Word => @eq Word (Append (cons x0 w) w0) y) (fun w : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w) (@pair Word Word nil nil)) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) (* Goal: forall (e : Elt) (w : Word) (_ : forall (y : Word) (_ : Rstar Conf Derive_P_A_2 (@pair Word Word w y) (@pair Word Word nil nil)) (u v : Word) (_ : @eq Word (Append u v) w) (_ : inmonoid X u), @ex2 Word (fun w0 : Word => @eq Word (Append u w0) y) (fun w0 : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w0) (@pair Word Word nil nil))) (y : Word) (_ : Rstar Conf Derive_P_A_2 (@pair Word Word (cons e w) y) (@pair Word Word nil nil)) (u v : Word) (_ : @eq Word (Append u v) (cons e w)) (_ : inmonoid X u), @ex2 Word (fun w0 : Word => @eq Word (Append u w0) y) (fun w0 : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w0) (@pair Word Word nil nil)) *) absurd (cons x0 (Append w v) = nil). (* Goal: not (@eq Word (cons x0 (Append w v)) nil) *) (* Goal: @eq Word (cons x0 (Append w v)) nil *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) (* Goal: forall (e : Elt) (w : Word) (_ : forall (y : Word) (_ : Rstar Conf Derive_P_A_2 (@pair Word Word w y) (@pair Word Word nil nil)) (u v : Word) (_ : @eq Word (Append u v) w) (_ : inmonoid X u), @ex2 Word (fun w0 : Word => @eq Word (Append u w0) y) (fun w0 : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w0) (@pair Word Word nil nil))) (y : Word) (_ : Rstar Conf Derive_P_A_2 (@pair Word Word (cons e w) y) (@pair Word Word nil nil)) (u v : Word) (_ : @eq Word (Append u v) (cons e w)) (_ : inmonoid X u), @ex2 Word (fun w0 : Word => @eq Word (Append u w0) y) (fun w0 : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w0) (@pair Word Word nil nil)) *) discriminate. (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) trivial. (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) generalize u; clear u; simple induction u. (* Goal: and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) auto. (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) intros x1 w1 Hyp; apply or_intror; exists w1; exists x1; trivial. (* Goal: forall (e : Elt) (w : Word) (_ : forall (y : Word) (_ : Rstar Conf Derive_P_A_2 (@pair Word Word w y) (@pair Word Word nil nil)) (u v : Word) (_ : @eq Word (Append u v) w) (_ : inmonoid X u), @ex2 Word (fun w0 : Word => @eq Word (Append u w0) y) (fun w0 : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w0) (@pair Word Word nil nil))) (y : Word) (_ : Rstar Conf Derive_P_A_2 (@pair Word Word (cons e w) y) (@pair Word Word nil nil)) (u v : Word) (_ : @eq Word (Append u v) (cons e w)) (_ : inmonoid X u), @ex2 Word (fun w0 : Word => @eq Word (Append u w0) y) (fun w0 : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w0) (@pair Word Word nil nil)) *) intros x0 w Hyp y Der_star_cons u v App_eg inmon_X. (* Goal: @ex2 Word (fun w : Word => @eq Word (Append u w) y) (fun w : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w) (@pair Word Word nil nil)) *) elimtype (u = nil \/ (exists w : Word, (exists x : Elt, u = cons x w))). (* Goal: forall _ : @eq Word u nil, @ex2 Word (fun w : Word => @eq Word (Append u w) y) (fun w : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w) (@pair Word Word nil nil)) *) (* Goal: forall _ : @ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w))), @ex2 Word (fun w : Word => @eq Word (Append u w) y) (fun w : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w) (@pair Word Word nil nil)) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) intros u_eg. (* Goal: @eq Word (Append u v) v *) (* Goal: forall _ : @ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w))), @ex2 Word (fun w : Word => @eq Word (Append u w) y) (fun w : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w) (@pair Word Word nil nil)) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) rewrite u_eg. (* Goal: @ex2 Word (fun w : Word => @eq Word (Append nil w) y) (fun w : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w) (@pair Word Word nil nil)) *) (* Goal: forall _ : @ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w))), @ex2 Word (fun w : Word => @eq Word (Append u w) y) (fun w : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w) (@pair Word Word nil nil)) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) replace v with (cons x0 w). (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) exists y; trivial. (* Goal: @eq Word (cons x0 w) v *) (* Goal: forall _ : @ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w))), @ex2 Word (fun w : Word => @eq Word (Append u w) y) (fun w : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w) (@pair Word Word nil nil)) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) replace v with (Append u v). (* Goal: and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) auto. (* Goal: @eq Word (Append u v) v *) (* Goal: forall _ : @ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w))), @ex2 Word (fun w : Word => @eq Word (Append u w) y) (fun w : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w) (@pair Word Word nil nil)) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) rewrite u_eg. (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) trivial. (* Goal: @ex2 Word (fun w : Word => @eq Word (Append (cut1 (cons x0 u)) w) (cons x0 v)) (fun w : Word => Deriveg X R (cut2 (cons x0 u)) w) *) intro temp; elim temp; clear temp; intros w1 temp; elim temp; clear temp. (* Goal: forall (x : Elt) (_ : @eq Word u (cons x w1)), @ex2 Word (fun w : Word => @eq Word (Append u w) y) (fun w : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w) (@pair Word Word nil nil)) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) intros x1 eg_u. (* Goal: @eq Word (cons x1 (Append w1 v)) (Append u v) *) (* Goal: Derivestar_P_A_2 (@pair Word Word (cons x0 w) y) (@pair Word Word nil nil) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) rewrite eg_u. elimtype (ex2 (fun v2 : Word => y = cons x0 v2) (fun v2 : Word => Derivestar_P_A_2 (w, v2) (nil, nil))). (* Goal: forall (x : Word) (_ : @eq Word y (cons x0 x)) (_ : Derivestar_P_A_2 (@pair Word Word w x) (@pair Word Word nil nil)), @ex2 Word (fun w : Word => @eq Word (Append (cons x1 w1) w) y) (fun w : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w) (@pair Word Word nil nil)) *) (* Goal: @ex2 Word (fun v2 : Word => @eq Word y (cons x0 v2)) (fun v2 : Word => Derivestar_P_A_2 (@pair Word Word w v2) (@pair Word Word nil nil)) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) intros v2 y_eg Der_w_v2. elimtype (ex2 (fun w : Word => Append w1 w = v2) (fun w : Word => Rstar Conf Derive_P_A_2 (v, w) (nil, nil))). (* Goal: forall (x : Word) (_ : @eq Word (Append w1 x) v2) (_ : Rstar Conf Derive_P_A_2 (@pair Word Word v x) (@pair Word Word nil nil)), @ex2 Word (fun w : Word => @eq Word (Append (cons x1 w1) w) y) (fun w : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w) (@pair Word Word nil nil)) *) (* Goal: @ex2 Word (fun w : Word => @eq Word (Append w1 w) v2) (fun w : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w) (@pair Word Word nil nil)) *) (* Goal: @ex2 Word (fun v2 : Word => @eq Word y (cons x0 v2)) (fun v2 : Word => Derivestar_P_A_2 (@pair Word Word w v2) (@pair Word Word nil nil)) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) intros we App_w1_we_eg_v2 Rstar_Der. (* Goal: @ex2 Word (fun w : Word => @eq Word (Append (cons x1 w1) w) y) (fun w : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w) (@pair Word Word nil nil)) *) (* Goal: @ex2 Word (fun w : Word => @eq Word (Append w1 w) v2) (fun w : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w) (@pair Word Word nil nil)) *) (* Goal: @ex2 Word (fun v2 : Word => @eq Word y (cons x0 v2)) (fun v2 : Word => Derivestar_P_A_2 (@pair Word Word w v2) (@pair Word Word nil nil)) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) exists we. (* Goal: @eq Word (Append (cons x1 w1) we) y *) (* Goal: Rstar Conf Derive_P_A_2 (@pair Word Word v we) (@pair Word Word nil nil) *) (* Goal: @ex2 Word (fun w : Word => @eq Word (Append w1 w) v2) (fun w : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w) (@pair Word Word nil nil)) *) (* Goal: @ex2 Word (fun v2 : Word => @eq Word y (cons x0 v2)) (fun v2 : Word => Derivestar_P_A_2 (@pair Word Word w v2) (@pair Word Word nil nil)) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) rewrite y_eg. (* Goal: @eq Word (Append (cons x1 w1) we) (cons x0 v2) *) (* Goal: Rstar Conf Derive_P_A_2 (@pair Word Word v we) (@pair Word Word nil nil) *) (* Goal: @ex2 Word (fun w : Word => @eq Word (Append w1 w) v2) (fun w : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w) (@pair Word Word nil nil)) *) (* Goal: @ex2 Word (fun v2 : Word => @eq Word y (cons x0 v2)) (fun v2 : Word => Derivestar_P_A_2 (@pair Word Word w v2) (@pair Word Word nil nil)) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) replace (Append (cons x1 w1) we) with (cons x1 (Append w1 we)). (* Goal: @eq Word (cons x1 (Append w1 we)) (cons x0 v2) *) (* Goal: @eq Word (cons x1 (Append w1 we)) (Append (cons x1 w1) we) *) (* Goal: Rstar Conf Derive_P_A_2 (@pair Word Word v we) (@pair Word Word nil nil) *) (* Goal: @ex2 Word (fun w : Word => @eq Word (Append w1 w) v2) (fun w : Word => Rstar Conf Derive_P_A_2 (@pair Word Word v w) (@pair Word Word nil nil)) *) (* Goal: @ex2 Word (fun v2 : Word => @eq Word y (cons x0 v2)) (fun v2 : Word => Derivestar_P_A_2 (@pair Word Word w v2) (@pair Word Word nil nil)) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) apply cons_cons. (* Goal: @eq Elt x1 x0 *) (* Goal: Derivestar_P_A_2 (@pair Word Word (cons x0 w) y) (@pair Word Word nil nil) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) apply cons_cons_inv1 with (Append w1 v) w. (* Goal: @eq Word (cons x1 (Append w1 v)) (cons x0 w) *) (* Goal: Derivestar_P_A_2 (@pair Word Word (cons x0 w) y) (@pair Word Word nil nil) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) rewrite <- App_eg. (* Goal: @eq Word (cons x1 (Append w1 v)) (Append u v) *) (* Goal: Derivestar_P_A_2 (@pair Word Word (cons x0 w) y) (@pair Word Word nil nil) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) rewrite eg_u. (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) trivial. (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) trivial. (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) trivial. (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) trivial. (* Goal: Rstar Word (Deriveg X R) (Append v1 v2) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w))) *) apply Hyp. (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) trivial. (* Goal: @eq Word (Append w1 v) w *) (* Goal: inmonoid X w1 *) (* Goal: @ex2 Word (fun v2 : Word => @eq Word y (cons x0 v2)) (fun v2 : Word => Derivestar_P_A_2 (@pair Word Word w v2) (@pair Word Word nil nil)) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) apply cons_cons_inv2 with x1 x0. (* Goal: @eq Word (cons x1 (Append w1 v)) (cons x0 w) *) (* Goal: Derivestar_P_A_2 (@pair Word Word (cons x0 w) y) (@pair Word Word nil nil) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) rewrite <- App_eg. (* Goal: @eq Word (cons x1 (Append w1 v)) (Append u v) *) (* Goal: Derivestar_P_A_2 (@pair Word Word (cons x0 w) y) (@pair Word Word nil nil) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) rewrite eg_u. (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) trivial. (* Goal: inmonoid X w1 *) (* Goal: @ex2 Word (fun v2 : Word => @eq Word y (cons x0 v2)) (fun v2 : Word => Derivestar_P_A_2 (@pair Word Word w v2) (@pair Word Word nil nil)) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) apply inmonoid_cons_inv with x1. (* Goal: inmonoid X (cons x1 w1) *) (* Goal: @eq Elt x1 x0 *) (* Goal: Derivestar_P_A_2 (@pair Word Word (cons x0 w) y) (@pair Word Word nil nil) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) rewrite <- eg_u. (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) trivial. (* Goal: @ex2 Word (fun v2 : Word => @eq Word w0 (cons x0 v2)) (fun v2 : Word => Derivestar_P_A_2 (@pair Word Word v0 v2) (@pair Word Word nil nil)) *) apply Der_cons_inv. (* Goal: dans x0 X *) (* Goal: Derivestar_P_A_2 (@pair Word Word (cons x0 w) y) (@pair Word Word nil nil) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) replace x0 with x1. (* Goal: dans x1 X *) (* Goal: @eq Elt x1 x0 *) (* Goal: Derivestar_P_A_2 (@pair Word Word (cons x0 w) y) (@pair Word Word nil nil) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) apply inmonoid_cons_inv2 with w1. (* Goal: inmonoid X (cons x1 w1) *) (* Goal: @eq Elt x1 x0 *) (* Goal: Derivestar_P_A_2 (@pair Word Word (cons x0 w) y) (@pair Word Word nil nil) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) rewrite <- eg_u. (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) trivial. (* Goal: @eq Elt x1 x0 *) (* Goal: Derivestar_P_A_2 (@pair Word Word (cons x0 w) y) (@pair Word Word nil nil) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) apply cons_cons_inv1 with (Append w1 v) w. (* Goal: @eq Word (cons x1 (Append w1 v)) (cons x0 w) *) (* Goal: Derivestar_P_A_2 (@pair Word Word (cons x0 w) y) (@pair Word Word nil nil) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) rewrite <- App_eg. (* Goal: @eq Word (cons x1 (Append w1 v)) (Append u v) *) (* Goal: Derivestar_P_A_2 (@pair Word Word (cons x0 w) y) (@pair Word Word nil nil) *) (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) rewrite eg_u. (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) trivial. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) clear inmon_X App_eg. (* Goal: or (@eq Word u nil) (@ex Word (fun w : Word => @ex Elt (fun x : Elt => @eq Word u (cons x w)))) *) generalize u; clear u; simple induction u. (* Goal: and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) auto. (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) intros x1 w1 tmp; apply or_intror; exists w1; exists x1; trivial. Qed. Lemma Derive_P_A_2_imp_Der_P_A_2_cons : forall (u : Elt) (x y : Word), Derivestar_P_A_2 (cons u x, y) (nil, nil) -> dans u X -> ex2 (fun w : Word => cons u w = y) (fun w : Word => Derivestar_P_A_2 (x, w) (nil, nil)). (* Goal: forall (u : prod Word Conf) (_ : inmonoid X (@fst Word Conf u)), Rstar Word (Deriveg X R) (Append (@fst Word Conf u) (@fst Word Word (@snd Word Conf u))) (Append (@fst Word Conf u) (@fst Word Word (@snd Word Conf u))) *) (* Goal: forall (u v w : prod Word Conf) (_ : Derive_P_A_3 u v) (_ : forall _ : inmonoid X (@fst Word Conf v), Rstar Word (Deriveg X R) (Append (@fst Word Conf v) (@fst Word Word (@snd Word Conf v))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w)))) (_ : inmonoid X (@fst Word Conf u)), Rstar Word (Deriveg X R) (Append (@fst Word Conf u) (@fst Word Word (@snd Word Conf u))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w))) *) intros. elimtype (ex2 (fun w : Word => Append (cons u nil) w = y) (fun w : Word => Derivestar_P_A_2 (x, w) (nil, nil))). (* Goal: forall (x0 : Word) (_ : @eq Word (Append (cons u nil) x0) y) (_ : Derivestar_P_A_2 (@pair Word Word x x0) (@pair Word Word nil nil)), @ex2 Word (fun w : Word => @eq Word (cons u w) y) (fun w : Word => Derivestar_P_A_2 (@pair Word Word x w) (@pair Word Word nil nil)) *) (* Goal: @ex2 Word (fun w : Word => @eq Word (Append (cons u nil) w) y) (fun w : Word => Derivestar_P_A_2 (@pair Word Word x w) (@pair Word Word nil nil)) *) intros w eg_App Der. (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) exists w; trivial. (* Goal: and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) apply Derive_P_A_2_imp_Der_P_A_2_App with (cons u x); auto. Qed. Lemma Derivestar_P_A_2_x : forall x : Word, inmonoid X x -> Derivestar_P_A_2 (x, x) (nil, nil). (* Goal: Derivestar_P_A_2 (@pair Word Word (cons x0 u0) (cons x0 x1)) (@pair Word Word nil nil) *) (* Goal: @ex2 Word (fun v2 : Word => @eq Word w0 (cons x0 v2)) (fun v2 : Word => Derivestar_P_A_2 (@pair Word Word v0 v2) (@pair Word Word nil nil)) *) unfold Derivestar_P_A_2 in |- *. (* Goal: forall (x : Word) (_ : inmonoid X x), Rstar Conf Derive_P_A_2 (@pair Word Word x x) (@pair Word Word nil nil) *) simple induction x. (* Goal: forall _ : inmonoid X nil, Rstar Conf Derive_P_A_2 (@pair Word Word nil nil) (@pair Word Word nil nil) *) (* Goal: forall (e : Elt) (w : Word) (_ : forall _ : inmonoid X w, Rstar Conf Derive_P_A_2 (@pair Word Word w w) (@pair Word Word nil nil)) (_ : inmonoid X (cons e w)), Rstar Conf Derive_P_A_2 (@pair Word Word (cons e w) (cons e w)) (@pair Word Word nil nil) *) intro. (* Goal: Rstar Word (Deriveg X R) (Append (@fst Word Conf u) (@fst Word Word (@snd Word Conf u))) (Append (@fst Word Conf u) (@fst Word Word (@snd Word Conf u))) *) (* Goal: forall (u v w : prod Word Conf) (_ : Derive_P_A_3 u v) (_ : forall _ : inmonoid X (@fst Word Conf v), Rstar Word (Deriveg X R) (Append (@fst Word Conf v) (@fst Word Word (@snd Word Conf v))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w)))) (_ : inmonoid X (@fst Word Conf u)), Rstar Word (Deriveg X R) (Append (@fst Word Conf u) (@fst Word Word (@snd Word Conf u))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w))) *) apply Rstar_reflexive. (* Goal: forall (e : Elt) (w : Word) (_ : forall _ : inmonoid X w, Rstar Conf Derive_P_A_2 (@pair Word Word w w) (@pair Word Word nil nil)) (_ : inmonoid X (cons e w)), Rstar Conf Derive_P_A_2 (@pair Word Word (cons e w) (cons e w)) (@pair Word Word nil nil) *) intros x0 w Hyp inmon. (* Goal: Rstar Conf Derive_P_A_2 (@pair Word Word (cons x0 w) (cons x0 w)) (@pair Word Word nil nil) *) apply Rstar_R with (w, w). (* Goal: Derive_P_A_2 (@pair Word Word (cons x0 w) (cons x0 u)) (@pair Word Word w u) *) (* Goal: @eq Word (cons x0 w) (Append (cons x0 nil) w) *) (* Goal: @eq Word w (Append nil w) *) (* Goal: @eq Word nil w2 *) (* Goal: @eq Word (cons x0 nil) w1 *) (* Goal: @ex Elt (fun r : Elt => and (dans r X) (@eq Elt (couple (word w1) (couple x0 (word w2))) (f_X_d r))) *) (* Goal: or (dans (couple (word w1) (couple x0 (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple x0 (word w2))) (map f_X_d X)) *) (* Goal: forall (w w1 w2 u : Word) (_ : dans (couple (word w1) (couple (eps X) (word w2))) (union (map f_R_d R) (map f_X_d X))), Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) apply Derive_X. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) apply inmonoid_cons_inv2 with w; assumption. (* Goal: Rstar Word (Deriveg X R) (Append v1 v2) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w))) *) apply Hyp. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) apply inmonoid_cons_inv with x0; assumption. Qed. Hint Resolve Derivestar_P_A_2_x. Lemma Derivegstar_imp_Derivestar_P_A_2 : forall x y : Word, Derivegstar X R x y -> inmonoid X y -> Derivestar_P_A_2 (x, y) (nil, nil). (* Goal: forall (x y : Word) (_ : Derivegstar X R x y) (_ : inmonoid X y), Derivestar_P_A_2 (@pair Word Word x y) (@pair Word Word nil nil) *) unfold Derivegstar, Rstar in |- *. (* Goal: forall (x y : Conf) (_ : forall (P : forall (_ : Conf) (_ : Conf), Prop) (_ : forall u : Conf, P u u) (_ : forall (u v w : Conf) (_ : Derive_P_A_2 u v) (_ : P v w), P u w), P x y) (s : Word), @ex Word (fun s2 : Word => Rstar (prod Word Conf) Derive_P_A_3 (@pair Word Conf s x) (@pair Word Conf s2 y)) *) intros x y Der_star. (* Goal: forall s : Word, @ex Word (fun s2 : Word => Rstar (prod Word Conf) Derive_P_A_3 (@pair Word Conf s x) (@pair Word Conf s2 y)) *) pattern x, y in |- *. (* Goal: (fun c c0 : Conf => forall s : Word, @ex Word (fun s2 : Word => Rstar (prod Word Conf) Derive_P_A_3 (@pair Word Conf s c) (@pair Word Conf s2 c0))) x y *) apply Der_star. (* Goal: and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) auto. (* Goal: forall (u v w : Word) (_ : Deriveg X R u v) (_ : forall _ : inmonoid X w, Derivestar_P_A_2 (@pair Word Word v w) (@pair Word Word nil nil)) (_ : inmonoid X w), Derivestar_P_A_2 (@pair Word Word u w) (@pair Word Word nil nil) *) intros u v w Derg_u_v. (* Goal: forall (_ : forall _ : inmonoid X w, Derivestar_P_A_2 (@pair Word Word v w) (@pair Word Word nil nil)) (_ : inmonoid X w), Derivestar_P_A_2 (@pair Word Word u w) (@pair Word Word nil nil) *) generalize w. (* Goal: forall (w : Word) (_ : forall _ : inmonoid X w, Derivestar_P_A_2 (@pair Word Word v w) (@pair Word Word nil nil)) (_ : inmonoid X w), Derivestar_P_A_2 (@pair Word Word u w) (@pair Word Word nil nil) *) elim Derg_u_v. (* Goal: forall (u v : Word) (A : Elt) (_ : dans (couple A (word u)) R) (w : Word) (_ : forall _ : inmonoid X w, Derivestar_P_A_2 (@pair Word Word (Append u v) w) (@pair Word Word nil nil)) (_ : inmonoid X w), Derivestar_P_A_2 (@pair Word Word (cons A v) w) (@pair Word Word nil nil) *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : forall (w : Word) (_ : forall _ : inmonoid X w, Derivestar_P_A_2 (@pair Word Word v w) (@pair Word Word nil nil)) (_ : inmonoid X w), Derivestar_P_A_2 (@pair Word Word u w) (@pair Word Word nil nil)) (w : Word) (_ : forall _ : inmonoid X w, Derivestar_P_A_2 (@pair Word Word (cons x v) w) (@pair Word Word nil nil)) (_ : inmonoid X w), Derivestar_P_A_2 (@pair Word Word (cons x u) w) (@pair Word Word nil nil) *) intros u0 v0 A dans_couple w0 Hyp inmon_w0. (* Goal: Derivestar_P_A_2 (@pair Word Word (cons x0 u0) (cons x0 x1)) (@pair Word Word nil nil) *) (* Goal: @ex2 Word (fun v2 : Word => @eq Word w0 (cons x0 v2)) (fun v2 : Word => Derivestar_P_A_2 (@pair Word Word v0 v2) (@pair Word Word nil nil)) *) unfold Derivestar_P_A_2 in |- *. (* Goal: Rstar Conf Derive_P_A_2 (@pair Word Word (cons A v0) w0) (@pair Word Word nil nil) *) (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : forall (w : Word) (_ : forall _ : inmonoid X w, Derivestar_P_A_2 (@pair Word Word v w) (@pair Word Word nil nil)) (_ : inmonoid X w), Derivestar_P_A_2 (@pair Word Word u w) (@pair Word Word nil nil)) (w : Word) (_ : forall _ : inmonoid X w, Derivestar_P_A_2 (@pair Word Word (cons x v) w) (@pair Word Word nil nil)) (_ : inmonoid X w), Derivestar_P_A_2 (@pair Word Word (cons x u) w) (@pair Word Word nil nil) *) apply Rstar_R with (Append u0 v0, w0). (* Goal: Derive_P_A_2 (@pair Word Word (cons (first r) w) u) (@pair Word Word (Append w2 w) u) *) (* Goal: @eq Word (cons (first r) w) (Append (cons (first r) nil) w) *) (* Goal: @eq Word (cons (first r) nil) w1 *) (* Goal: @ex Elt (fun r : Elt => and (dans r R) (@eq Elt (couple (word w1) (couple (eps X) (word w2))) (f_R_d r))) *) (* Goal: forall _ : dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X), Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) (* Goal: or (dans (couple (word w1) (couple (eps X) (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X)) *) apply Derive_V. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) apply Hyp; assumption. (* Goal: forall (u v : Word) (x : Elt) (_ : dans x X) (_ : Deriveg X R u v) (_ : forall (w : Word) (_ : forall _ : inmonoid X w, Derivestar_P_A_2 (@pair Word Word v w) (@pair Word Word nil nil)) (_ : inmonoid X w), Derivestar_P_A_2 (@pair Word Word u w) (@pair Word Word nil nil)) (w : Word) (_ : forall _ : inmonoid X w, Derivestar_P_A_2 (@pair Word Word (cons x v) w) (@pair Word Word nil nil)) (_ : inmonoid X w), Derivestar_P_A_2 (@pair Word Word (cons x u) w) (@pair Word Word nil nil) *) intros u0 v0 x0 dans_x0_v0 Der_u0_v0 Hyp1 w0 Hyp2 inmon_w0. elimtype (ex2 (fun v2 : Word => w0 = cons x0 v2) (fun v2 : Word => Derivestar_P_A_2 (v0, v2) (nil, nil))). (* Goal: forall (x : Word) (_ : @eq Word w0 (cons x0 x)) (_ : Derivestar_P_A_2 (@pair Word Word v0 x) (@pair Word Word nil nil)), Derivestar_P_A_2 (@pair Word Word (cons x0 u0) w0) (@pair Word Word nil nil) *) (* Goal: @ex2 Word (fun v2 : Word => @eq Word w0 (cons x0 v2)) (fun v2 : Word => Derivestar_P_A_2 (@pair Word Word v0 v2) (@pair Word Word nil nil)) *) intros x1 w0_eg_cons Derivestar_v0_x1. (* Goal: Derivestar_P_A_2 (@pair Word Word (cons x0 u0) w0) (@pair Word Word nil nil) *) (* Goal: @ex2 Word (fun v2 : Word => @eq Word w0 (cons x0 v2)) (fun v2 : Word => Derivestar_P_A_2 (@pair Word Word v0 v2) (@pair Word Word nil nil)) *) rewrite w0_eg_cons. (* Goal: Derivestar_P_A_2 (@pair Word Word (cons x0 u0) (cons x0 x1)) (@pair Word Word nil nil) *) (* Goal: @ex2 Word (fun v2 : Word => @eq Word w0 (cons x0 v2)) (fun v2 : Word => Derivestar_P_A_2 (@pair Word Word v0 v2) (@pair Word Word nil nil)) *) unfold Derivestar_P_A_2 in |- *. (* Goal: Rstar Conf Derive_P_A_2 (@pair Word Word (cons x0 u0) (cons x0 x1)) (@pair Word Word nil nil) *) (* Goal: @ex2 Word (fun v2 : Word => @eq Word w0 (cons x0 v2)) (fun v2 : Word => Derivestar_P_A_2 (@pair Word Word v0 v2) (@pair Word Word nil nil)) *) apply Rstar_R with (u0, x1). (* Goal: Derive_P_A_2 (@pair Word Word (cons x0 w) (cons x0 u)) (@pair Word Word w u) *) (* Goal: @eq Word (cons x0 w) (Append (cons x0 nil) w) *) (* Goal: @eq Word w (Append nil w) *) (* Goal: @eq Word nil w2 *) (* Goal: @eq Word (cons x0 nil) w1 *) (* Goal: @ex Elt (fun r : Elt => and (dans r X) (@eq Elt (couple (word w1) (couple x0 (word w2))) (f_X_d r))) *) (* Goal: or (dans (couple (word w1) (couple x0 (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple x0 (word w2))) (map f_X_d X)) *) (* Goal: forall (w w1 w2 u : Word) (_ : dans (couple (word w1) (couple (eps X) (word w2))) (union (map f_R_d R) (map f_X_d X))), Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) apply Derive_X. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: Rstar Conf Derive_P_A_2 (@pair Word Word u0 x1) (@pair Word Word nil nil) *) (* Goal: @ex2 Word (fun v2 : Word => @eq Word w0 (cons x0 v2)) (fun v2 : Word => Derivestar_P_A_2 (@pair Word Word v0 v2) (@pair Word Word nil nil)) *) apply Hyp1. (* Goal: and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) auto. (* Goal: inmonoid X x1 *) (* Goal: @ex2 Word (fun v2 : Word => @eq Word w0 (cons x0 v2)) (fun v2 : Word => Derivestar_P_A_2 (@pair Word Word v0 v2) (@pair Word Word nil nil)) *) apply inmonoid_cons_inv with x0. (* Goal: inmonoid X (cons x0 x1) *) (* Goal: @ex2 Word (fun v2 : Word => @eq Word w0 (cons x0 v2)) (fun v2 : Word => Derivestar_P_A_2 (@pair Word Word v0 v2) (@pair Word Word nil nil)) *) rewrite <- w0_eg_cons. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: @ex2 Word (fun v2 : Word => @eq Word w0 (cons x0 v2)) (fun v2 : Word => Derivestar_P_A_2 (@pair Word Word v0 v2) (@pair Word Word nil nil)) *) apply Der_cons_inv. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: Derivestar_P_A_2 (@pair Word Word (cons x0 v0) w0) (@pair Word Word nil nil) *) exact (Hyp2 inmon_w0). Qed. Hint Resolve Derivegstar_imp_Derivestar_P_A_2. (*equivalence de Derive_P_A_2 et Derive_P_A*) (*premiere implication*) Lemma Derive_P_A_2_imp_Derive_P_A : forall x y : Word * Word, Derive_P_A_2 x y -> Derive_P_A X d x y. (* Goal: forall (x y : prod Word Word) (_ : Derive_P_A X (union (map f_R_d R) (map f_X_d X)) x y), Derive_P_A_2 x y *) intros x y Der. (* Goal: Derive_P_A_2 x y *) elim Der. (* Goal: forall (w u : Word) (x : Elt) (_ : dans x X), @ex Word (fun s2 : Word => Derive_P_A_3 (@pair Word Conf s (@pair Word Word (cons x w) (cons x u))) (@pair Word Conf s2 (@pair Word Word w u))) *) (* Goal: forall (v w u : Word) (x : Elt) (_ : dans (couple x (word u)) R), @ex Word (fun s2 : Word => Derive_P_A_3 (@pair Word Conf s (@pair Word Word (cons x w) v)) (@pair Word Conf s2 (@pair Word Word (Append u w) v))) *) intros w u x0 dans_x0_X. (* Goal: Derive_P_A X d (@pair Word Word (cons x0 w) v) (@pair Word Word (Append u w) v) *) replace (cons x0 w) with (Append (cons x0 nil) w). (* Goal: Derive_P_A X d (@pair Word Word (Append (cons x0 nil) w) (cons x0 u)) (@pair Word Word w u) *) (* Goal: @eq Word (Append (cons x0 nil) w) (cons x0 w) *) (* Goal: forall (v w u : Word) (x : Elt) (_ : dans (couple x (word u)) R), Derive_P_A X d (@pair Word Word (cons x w) v) (@pair Word Word (Append u w) v) *) pattern w at 2 in |- *. (* Goal: (fun w0 : Word => Derive_P_A X d (@pair Word Word (Append (cons x0 nil) w) (cons x0 u)) (@pair Word Word w0 u)) w *) (* Goal: @eq Word (Append (cons x0 nil) w) (cons x0 w) *) (* Goal: forall (v w u : Word) (x : Elt) (_ : dans (couple x (word u)) R), Derive_P_A X d (@pair Word Word (cons x w) v) (@pair Word Word (Append u w) v) *) replace w with (Append nil w). (* Goal: Derive_P_A X d (@pair Word Word (Append (cons x0 nil) w) (cons x0 u)) (@pair Word Word (Append nil w) u) *) (* Goal: @eq Word (Append nil w) w *) (* Goal: @eq Word (Append (cons x0 nil) w) (cons x0 w) *) (* Goal: forall (v w u : Word) (x : Elt) (_ : dans (couple x (word u)) R), Derive_P_A X d (@pair Word Word (cons x w) v) (@pair Word Word (Append u w) v) *) apply Derive_cons. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: forall (w w1 w2 u : Word) (_ : dans (couple (word w1) (couple (eps X) (word w2))) (union (map f_R_d R) (map f_X_d X))), Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) unfold d in |- *. (* Goal: dans (couple (word (cons x0 nil)) (couple x0 (word nil))) (union (map f_R_d R) (map f_X_d X)) *) (* Goal: @eq Word (Append nil w) w *) (* Goal: @eq Word (Append (cons x0 nil) w) (cons x0 w) *) (* Goal: forall (v w u : Word) (x : Elt) (_ : dans (couple x (word u)) R), Derive_P_A X d (@pair Word Word (cons x w) v) (@pair Word Word (Append u w) v) *) apply union_d. (* Goal: dans (couple (word (cons x0 nil)) (couple x0 (word nil))) (map f_X_d X) *) (* Goal: @eq Word (Append nil w) w *) (* Goal: @eq Word (Append (cons x0 nil) w) (cons x0 w) *) (* Goal: forall (v w u : Word) (x : Elt) (_ : dans (couple x (word u)) R), Derive_P_A X d (@pair Word Word (cons x w) v) (@pair Word Word (Append u w) v) *) change (dans (f_X_d x0) (map f_X_d X)) in |- *. (* Goal: dans (f_R_d (couple x0 (word u))) (map f_R_d R) *) (* Goal: @eq Elt (f_R_d (couple x0 (word u))) (couple (word (cons x0 nil)) (couple (eps X) (word u))) *) (* Goal: @eq Word (Append (cons x0 nil) w) (cons x0 w) *) apply dans_map_inv. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) trivial. (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) trivial. (* Goal: forall (v w u : Word) (x : Elt) (_ : dans (couple x (word u)) R), @ex Word (fun s2 : Word => Derive_P_A_3 (@pair Word Conf s (@pair Word Word (cons x w) v)) (@pair Word Conf s2 (@pair Word Word (Append u w) v))) *) intros v w u x0 dans_couple. (* Goal: Derive_P_A X d (@pair Word Word (cons x0 w) v) (@pair Word Word (Append u w) v) *) replace (cons x0 w) with (Append (cons x0 nil) w). (* Goal: Derive_P_A X d (@pair Word Word (Append (cons x0 nil) w) v) (@pair Word Word (Append u w) v) *) (* Goal: @eq Word (Append (cons x0 nil) w) (cons x0 w) *) apply Derive_eps. (* Goal: forall (w w1 w2 u : Word) (_ : dans (couple (word w1) (couple (eps X) (word w2))) (union (map f_R_d R) (map f_X_d X))), Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) unfold d in |- *. (* Goal: dans (couple (word (cons x0 nil)) (couple (eps X) (word u))) (union (map f_R_d R) (map f_X_d X)) *) (* Goal: @eq Word (Append (cons x0 nil) w) (cons x0 w) *) apply union_g. replace (couple (word (cons x0 nil)) (couple (eps X) (word u))) with (f_R_d (couple x0 (word u))). (* Goal: dans (f_R_d (couple x0 (word u))) (map f_R_d R) *) (* Goal: @eq Elt (f_R_d (couple x0 (word u))) (couple (word (cons x0 nil)) (couple (eps X) (word u))) *) (* Goal: @eq Word (Append (cons x0 nil) w) (cons x0 w) *) apply dans_map_inv. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: forall _ : @eq Elt (couple (word w1) (couple x0 (word w2))) (f_R_d r), @eq Elt x0 (eps X) *) (* Goal: @ex Elt (fun r : Elt => and (dans r R) (@eq Elt (couple (word w1) (couple x0 (word w2))) (f_R_d r))) *) (* Goal: forall _ : dans (couple (word w1) (couple x0 (word w2))) (map f_X_d X), Derive_P_A_2 (@pair Word Word (Append w1 w) (cons x0 u)) (@pair Word Word (Append w2 w) u) *) (* Goal: or (dans (couple (word w1) (couple x0 (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple x0 (word w2))) (map f_X_d X)) *) (* Goal: forall (w w1 w2 u : Word) (_ : dans (couple (word w1) (couple (eps X) (word w2))) (union (map f_R_d R) (map f_X_d X))), Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) unfold f_R_d in |- *. (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) trivial. (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) trivial. Qed. Hint Resolve Derive_P_A_2_imp_Derive_P_A. Lemma Derivestar_P_A_2_imp_Derivestar_P_A : forall x y : Word * Word, Derivestar_P_A_2 x y -> Derivestar_P_A X d x y. (* Goal: forall (x y : prod Word Word) (_ : Derivestar_P_A_2 x y), Derivestar_P_A X d x y *) unfold Derivestar_P_A_2, Rstar, Derivestar_P_A in |- *. (* Goal: forall (x y : prod Word Word) (_ : forall (P : forall (_ : Conf) (_ : Conf), Prop) (_ : forall u : Conf, P u u) (_ : forall (u v w : Conf) (_ : Derive_P_A_2 u v) (_ : P v w), P u w), P x y), Rstar Conf (Derive_P_A X d) x y *) intros x y Rstar_Der. (* Goal: forall s : Word, @ex Word (fun s2 : Word => Rstar (prod Word Conf) Derive_P_A_3 (@pair Word Conf s x) (@pair Word Conf s2 y)) *) pattern x, y in |- *. (* Goal: (fun p p0 : prod Word Word => Rstar Conf (Derive_P_A X d) p p0) x y *) apply Rstar_Der. (* Goal: forall (u : prod Word Conf) (_ : inmonoid X (@fst Word Conf u)), Rstar Word (Deriveg X R) (Append (@fst Word Conf u) (@fst Word Word (@snd Word Conf u))) (Append (@fst Word Conf u) (@fst Word Word (@snd Word Conf u))) *) (* Goal: forall (u v w : prod Word Conf) (_ : Derive_P_A_3 u v) (_ : forall _ : inmonoid X (@fst Word Conf v), Rstar Word (Deriveg X R) (Append (@fst Word Conf v) (@fst Word Word (@snd Word Conf v))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w)))) (_ : inmonoid X (@fst Word Conf u)), Rstar Word (Deriveg X R) (Append (@fst Word Conf u) (@fst Word Word (@snd Word Conf u))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w))) *) intros. (* Goal: Rstar Word (Deriveg X R) (Append (@fst Word Conf u) (@fst Word Word (@snd Word Conf u))) (Append (@fst Word Conf u) (@fst Word Word (@snd Word Conf u))) *) (* Goal: forall (u v w : prod Word Conf) (_ : Derive_P_A_3 u v) (_ : forall _ : inmonoid X (@fst Word Conf v), Rstar Word (Deriveg X R) (Append (@fst Word Conf v) (@fst Word Word (@snd Word Conf v))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w)))) (_ : inmonoid X (@fst Word Conf u)), Rstar Word (Deriveg X R) (Append (@fst Word Conf u) (@fst Word Word (@snd Word Conf u))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w))) *) apply Rstar_reflexive. (* Goal: forall (u v w : Conf) (_ : Derive_P_A_2 u v) (_ : Rstar Conf (Derive_P_A X d) v w), Rstar Conf (Derive_P_A X d) u w *) intros u v w Hyp1 Hyp2. (* Goal: and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) apply Rstar_R with v; auto. Qed. Hint Resolve Derivestar_P_A_2_imp_Derivestar_P_A. (*seconde implication*) Lemma Derive_P_A_imp_Derive_P_A_2 : forall x y : Word * Word, Derive_P_A X d x y -> Derive_P_A_2 x y. (* Goal: forall (w w1 w2 u : Word) (_ : dans (couple (word w1) (couple (eps X) (word w2))) (union (map f_R_d R) (map f_X_d X))), Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) unfold d in |- *. (* Goal: forall (x y : prod Word Word) (_ : Derive_P_A X (union (map f_R_d R) (map f_X_d X)) x y), Derive_P_A_2 x y *) intros x y Der. (* Goal: Derive_P_A_2 x y *) elim Der. (* Goal: forall (w w1 w2 u : Word) (x : Elt) (_ : dans x X) (_ : dans (couple (word w1) (couple x (word w2))) (union (map f_R_d R) (map f_X_d X))), Derive_P_A_2 (@pair Word Word (Append w1 w) (cons x u)) (@pair Word Word (Append w2 w) u) *) (* Goal: forall (w w1 w2 u : Word) (_ : dans (couple (word w1) (couple (eps X) (word w2))) (union (map f_R_d R) (map f_X_d X))), Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) intros w w1 w2 u x0 dans_x0_X dans_couple_d. elimtype (dans (couple (word w1) (couple x0 (word w2))) (map f_R_d R) \/ dans (couple (word w1) (couple x0 (word w2))) (map f_X_d X)). (* Goal: forall _ : dans (couple (word w1) (couple (eps X) (word w2))) (map f_R_d R), Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) (* Goal: forall _ : dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X), Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) (* Goal: or (dans (couple (word w1) (couple (eps X) (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X)) *) intros dans_couple. (* Goal: Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) (* Goal: @ex Elt (fun r : Elt => and (dans r X) (@eq Elt (couple (word w1) (couple (eps X) (word w2))) (f_X_d r))) *) (* Goal: or (dans (couple (word w1) (couple (eps X) (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X)) *) absurd (dans (eps X) X). (* Goal: not (dans (eps X) X) *) (* Goal: dans (eps X) X *) (* Goal: @ex Elt (fun r : Elt => and (dans r X) (@eq Elt (couple (word w1) (couple (eps X) (word w2))) (f_X_d r))) *) (* Goal: or (dans (couple (word w1) (couple (eps X) (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X)) *) apply not_dans_X_eps. (* Goal: dans (eps X) X *) (* Goal: forall _ : dans (couple (word w1) (couple x0 (word w2))) (map f_X_d X), Derive_P_A_2 (@pair Word Word (Append w1 w) (cons x0 u)) (@pair Word Word (Append w2 w) u) *) (* Goal: or (dans (couple (word w1) (couple x0 (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple x0 (word w2))) (map f_X_d X)) *) (* Goal: forall (w w1 w2 u : Word) (_ : dans (couple (word w1) (couple (eps X) (word w2))) (union (map f_R_d R) (map f_X_d X))), Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) replace (eps X) with x0. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. elimtype (exists r : Elt, dans r R /\ couple (word w1) (couple x0 (word w2)) = f_R_d r). (* Goal: forall (x : Elt) (_ : and (dans x R) (@eq Elt (couple (word w1) (couple x0 (word w2))) (f_R_d x))), @eq Elt x0 (eps X) *) (* Goal: @ex Elt (fun r : Elt => and (dans r R) (@eq Elt (couple (word w1) (couple x0 (word w2))) (f_R_d r))) *) (* Goal: forall _ : dans (couple (word w1) (couple x0 (word w2))) (map f_X_d X), Derive_P_A_2 (@pair Word Word (Append w1 w) (cons x0 u)) (@pair Word Word (Append w2 w) u) *) (* Goal: or (dans (couple (word w1) (couple x0 (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple x0 (word w2))) (map f_X_d X)) *) (* Goal: forall (w w1 w2 u : Word) (_ : dans (couple (word w1) (couple (eps X) (word w2))) (union (map f_R_d R) (map f_X_d X))), Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) intros r temp; elim temp; clear temp; intros dans_r_R. (* Goal: forall _ : @eq Elt (couple (word w1) (couple x0 (word w2))) (f_R_d r), @eq Elt x0 (eps X) *) (* Goal: @ex Elt (fun r : Elt => and (dans r R) (@eq Elt (couple (word w1) (couple x0 (word w2))) (f_R_d r))) *) (* Goal: forall _ : dans (couple (word w1) (couple x0 (word w2))) (map f_X_d X), Derive_P_A_2 (@pair Word Word (Append w1 w) (cons x0 u)) (@pair Word Word (Append w2 w) u) *) (* Goal: or (dans (couple (word w1) (couple x0 (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple x0 (word w2))) (map f_X_d X)) *) (* Goal: forall (w w1 w2 u : Word) (_ : dans (couple (word w1) (couple (eps X) (word w2))) (union (map f_R_d R) (map f_X_d X))), Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) unfold f_R_d in |- *. (* Goal: forall _ : @eq Elt (couple (word w1) (couple x0 (word w2))) (couple (word (cons (first r) nil)) (couple (eps X) (second r))), @eq Elt x0 (eps X) *) (* Goal: @ex Elt (fun r : Elt => and (dans r R) (@eq Elt (couple (word w1) (couple x0 (word w2))) (f_R_d r))) *) (* Goal: forall _ : dans (couple (word w1) (couple x0 (word w2))) (map f_X_d X), Derive_P_A_2 (@pair Word Word (Append w1 w) (cons x0 u)) (@pair Word Word (Append w2 w) u) *) (* Goal: or (dans (couple (word w1) (couple x0 (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple x0 (word w2))) (map f_X_d X)) *) (* Goal: forall (w w1 w2 u : Word) (_ : dans (couple (word w1) (couple (eps X) (word w2))) (union (map f_R_d R) (map f_X_d X))), Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) intro eg. (* Goal: @eq Elt x0 (eps X) *) (* Goal: @ex Elt (fun r : Elt => and (dans r R) (@eq Elt (couple (word w1) (couple x0 (word w2))) (f_R_d r))) *) (* Goal: forall _ : dans (couple (word w1) (couple x0 (word w2))) (map f_X_d X), Derive_P_A_2 (@pair Word Word (Append w1 w) (cons x0 u)) (@pair Word Word (Append w2 w) u) *) (* Goal: or (dans (couple (word w1) (couple x0 (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple x0 (word w2))) (map f_X_d X)) *) (* Goal: forall (w w1 w2 u : Word) (_ : dans (couple (word w1) (couple (eps X) (word w2))) (union (map f_R_d R) (map f_X_d X))), Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) apply couple_couple_inv1 with (word w2) (second r). (* Goal: @eq Elt (couple x0 (word w2)) (couple (eps X) (second r)) *) (* Goal: @ex Elt (fun r : Elt => and (dans r R) (@eq Elt (couple (word w1) (couple x0 (word w2))) (f_R_d r))) *) (* Goal: forall _ : dans (couple (word w1) (couple x0 (word w2))) (map f_X_d X), Derive_P_A_2 (@pair Word Word (Append w1 w) (cons x0 u)) (@pair Word Word (Append w2 w) u) *) (* Goal: or (dans (couple (word w1) (couple x0 (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple x0 (word w2))) (map f_X_d X)) *) (* Goal: forall (w w1 w2 u : Word) (_ : dans (couple (word w1) (couple (eps X) (word w2))) (union (map f_R_d R) (map f_X_d X))), Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) apply couple_couple_inv2 with (word w1) (word (cons (first r) nil)). (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: @ex Elt (fun r : Elt => and (dans r X) (@eq Elt (couple (word w1) (couple (eps X) (word w2))) (f_X_d r))) *) (* Goal: or (dans (couple (word w1) (couple (eps X) (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X)) *) apply dans_map. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: forall _ : dans (couple (word w1) (couple (eps X) (word w2))) (map f_R_d R), Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) (* Goal: forall _ : dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X), Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) (* Goal: or (dans (couple (word w1) (couple (eps X) (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X)) *) intros dans_couple. elimtype (exists r : Elt, dans r X /\ couple (word w1) (couple x0 (word w2)) = f_X_d r). (* Goal: forall (x : Elt) (_ : and (dans x X) (@eq Elt (couple (word w1) (couple (eps X) (word w2))) (f_X_d x))), Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) (* Goal: @ex Elt (fun r : Elt => and (dans r X) (@eq Elt (couple (word w1) (couple (eps X) (word w2))) (f_X_d r))) *) (* Goal: or (dans (couple (word w1) (couple (eps X) (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X)) *) intros r temp; elim temp; clear temp; intros dans_r_X eg. (* Goal: Derive_P_A_2 (@pair Word Word (Append w1 w) (cons x0 u)) (@pair Word Word (Append w2 w) u) *) (* Goal: @ex Elt (fun r : Elt => and (dans r X) (@eq Elt (couple (word w1) (couple x0 (word w2))) (f_X_d r))) *) (* Goal: or (dans (couple (word w1) (couple x0 (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple x0 (word w2))) (map f_X_d X)) *) (* Goal: forall (w w1 w2 u : Word) (_ : dans (couple (word w1) (couple (eps X) (word w2))) (union (map f_R_d R) (map f_X_d X))), Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) replace w1 with (cons x0 nil). (* Goal: Derive_P_A_2 (@pair Word Word (Append (cons x0 nil) w) (cons x0 u)) (@pair Word Word (Append w2 w) u) *) (* Goal: @eq Word (cons x0 nil) w1 *) (* Goal: @ex Elt (fun r : Elt => and (dans r X) (@eq Elt (couple (word w1) (couple x0 (word w2))) (f_X_d r))) *) (* Goal: or (dans (couple (word w1) (couple x0 (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple x0 (word w2))) (map f_X_d X)) *) (* Goal: forall (w w1 w2 u : Word) (_ : dans (couple (word w1) (couple (eps X) (word w2))) (union (map f_R_d R) (map f_X_d X))), Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) replace w2 with nil. (* Goal: forall (_ : Derive_P_A_3 (@pair Word Conf u1 (@pair Word Word u2 u3)) (@pair Word Conf v1 (@pair Word Word v2 v3))) (_ : forall _ : inmonoid X (@fst Word Conf (@pair Word Conf v1 (@pair Word Word v2 v3))), Rstar Word (Deriveg X R) (Append (@fst Word Conf (@pair Word Conf v1 (@pair Word Word v2 v3))) (@fst Word Word (@snd Word Conf (@pair Word Conf v1 (@pair Word Word v2 v3))))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w)))) (_ : inmonoid X (@fst Word Conf (@pair Word Conf u1 (@pair Word Word u2 u3)))), Rstar Word (Deriveg X R) (Append (@fst Word Conf (@pair Word Conf u1 (@pair Word Word u2 u3))) (@fst Word Word (@snd Word Conf (@pair Word Conf u1 (@pair Word Word u2 u3))))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w))) *) simpl in |- *. (* Goal: Derive_P_A_2 (@pair Word Word (cons x0 w) (cons x0 u)) (@pair Word Word w u) *) (* Goal: @eq Word nil w2 *) (* Goal: @eq Word (cons x0 nil) w1 *) (* Goal: @ex Elt (fun r : Elt => and (dans r X) (@eq Elt (couple (word w1) (couple x0 (word w2))) (f_X_d r))) *) (* Goal: or (dans (couple (word w1) (couple x0 (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple x0 (word w2))) (map f_X_d X)) *) (* Goal: forall (w w1 w2 u : Word) (_ : dans (couple (word w1) (couple (eps X) (word w2))) (union (map f_R_d R) (map f_X_d X))), Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) replace (Append nil w) with w. (* Goal: Derive_P_A_2 (@pair Word Word (cons x0 w) (cons x0 u)) (@pair Word Word w u) *) (* Goal: @eq Word w (Append nil w) *) (* Goal: @eq Word nil w2 *) (* Goal: @eq Word (cons x0 nil) w1 *) (* Goal: @ex Elt (fun r : Elt => and (dans r X) (@eq Elt (couple (word w1) (couple x0 (word w2))) (f_X_d r))) *) (* Goal: or (dans (couple (word w1) (couple x0 (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple x0 (word w2))) (map f_X_d X)) *) (* Goal: forall (w w1 w2 u : Word) (_ : dans (couple (word w1) (couple (eps X) (word w2))) (union (map f_R_d R) (map f_X_d X))), Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) replace (Append (cons x0 nil) w) with (cons x0 w). (* Goal: Derive_P_A_2 (@pair Word Word (cons x0 w) (cons x0 u)) (@pair Word Word w u) *) (* Goal: @eq Word (cons x0 w) (Append (cons x0 nil) w) *) (* Goal: @eq Word w (Append nil w) *) (* Goal: @eq Word nil w2 *) (* Goal: @eq Word (cons x0 nil) w1 *) (* Goal: @ex Elt (fun r : Elt => and (dans r X) (@eq Elt (couple (word w1) (couple x0 (word w2))) (f_X_d r))) *) (* Goal: or (dans (couple (word w1) (couple x0 (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple x0 (word w2))) (map f_X_d X)) *) (* Goal: forall (w w1 w2 u : Word) (_ : dans (couple (word w1) (couple (eps X) (word w2))) (union (map f_R_d R) (map f_X_d X))), Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) apply Derive_X. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) trivial. (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) trivial. (* Goal: @eq Word (cons (first r) nil) w1 *) (* Goal: @ex Elt (fun r : Elt => and (dans r R) (@eq Elt (couple (word w1) (couple (eps X) (word w2))) (f_R_d r))) *) (* Goal: forall _ : dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X), Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) (* Goal: or (dans (couple (word w1) (couple (eps X) (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X)) *) apply word_word_inv. (* Goal: @eq Elt (word nil) (word w2) *) (* Goal: @eq Word (cons x0 nil) w1 *) (* Goal: @ex Elt (fun r : Elt => and (dans r X) (@eq Elt (couple (word w1) (couple x0 (word w2))) (f_X_d r))) *) (* Goal: or (dans (couple (word w1) (couple x0 (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple x0 (word w2))) (map f_X_d X)) *) (* Goal: forall (w w1 w2 u : Word) (_ : dans (couple (word w1) (couple (eps X) (word w2))) (union (map f_R_d R) (map f_X_d X))), Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) apply couple_couple_inv2 with r x0. (* Goal: @eq Elt (couple r (word nil)) (couple (eps X) (word w2)) *) (* Goal: @ex Elt (fun r : Elt => and (dans r X) (@eq Elt (couple (word w1) (couple (eps X) (word w2))) (f_X_d r))) *) (* Goal: or (dans (couple (word w1) (couple (eps X) (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X)) *) apply couple_couple_inv2 with (word (cons r nil)) (word w1). (* Goal: and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) auto. (* Goal: @eq Word (cons x0 nil) w1 *) (* Goal: @ex Elt (fun r : Elt => and (dans r X) (@eq Elt (couple (word w1) (couple x0 (word w2))) (f_X_d r))) *) (* Goal: or (dans (couple (word w1) (couple x0 (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple x0 (word w2))) (map f_X_d X)) *) (* Goal: forall (w w1 w2 u : Word) (_ : dans (couple (word w1) (couple (eps X) (word w2))) (union (map f_R_d R) (map f_X_d X))), Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) replace x0 with r. (* Goal: @eq Word (cons (first r) nil) w1 *) (* Goal: @ex Elt (fun r : Elt => and (dans r R) (@eq Elt (couple (word w1) (couple (eps X) (word w2))) (f_R_d r))) *) (* Goal: forall _ : dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X), Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) (* Goal: or (dans (couple (word w1) (couple (eps X) (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X)) *) apply word_word_inv. (* Goal: @eq Elt (word (cons r nil)) (word w1) *) (* Goal: @eq Elt r x0 *) (* Goal: @ex Elt (fun r : Elt => and (dans r X) (@eq Elt (couple (word w1) (couple x0 (word w2))) (f_X_d r))) *) (* Goal: or (dans (couple (word w1) (couple x0 (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple x0 (word w2))) (map f_X_d X)) *) (* Goal: forall (w w1 w2 u : Word) (_ : dans (couple (word w1) (couple (eps X) (word w2))) (union (map f_R_d R) (map f_X_d X))), Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) apply couple_couple_inv1 with (couple r (word nil)) (couple x0 (word w2)). (* Goal: and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) auto. (* Goal: @eq Elt r (eps X) *) (* Goal: @ex Elt (fun r : Elt => and (dans r X) (@eq Elt (couple (word w1) (couple (eps X) (word w2))) (f_X_d r))) *) (* Goal: or (dans (couple (word w1) (couple (eps X) (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X)) *) apply couple_couple_inv1 with (word nil) (word w2). (* Goal: @eq Elt (couple r (word nil)) (couple (eps X) (word w2)) *) (* Goal: @ex Elt (fun r : Elt => and (dans r X) (@eq Elt (couple (word w1) (couple (eps X) (word w2))) (f_X_d r))) *) (* Goal: or (dans (couple (word w1) (couple (eps X) (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X)) *) apply couple_couple_inv2 with (word (cons r nil)) (word w1). (* Goal: and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) auto. (* Goal: @ex Elt (fun r : Elt => and (dans r X) (@eq Elt (couple (word w1) (couple (eps X) (word w2))) (f_X_d r))) *) (* Goal: or (dans (couple (word w1) (couple (eps X) (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X)) *) apply dans_map. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) auto. (* Goal: forall (w w1 w2 u : Word) (_ : dans (couple (word w1) (couple (eps X) (word w2))) (union (map f_R_d R) (map f_X_d X))), Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) unfold d in |- *. (* Goal: forall (w w1 w2 u : Word) (_ : dans (couple (word w1) (couple (eps X) (word w2))) (union (map f_R_d R) (map f_X_d X))), Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) intros w w1 w2 u dans_couple_d. elimtype (dans (couple (word w1) (couple (eps X) (word w2))) (map f_R_d R) \/ dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X)). (* Goal: forall _ : dans (couple (word w1) (couple (eps X) (word w2))) (map f_R_d R), Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) (* Goal: forall _ : dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X), Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) (* Goal: or (dans (couple (word w1) (couple (eps X) (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X)) *) intros dans_couple. (* Apply Derive_V.*) elimtype (exists r : Elt, dans r R /\ couple (word w1) (couple (eps X) (word w2)) = f_R_d r). (* Goal: forall (x : Elt) (_ : and (dans x R) (@eq Elt (couple (word w1) (couple (eps X) (word w2))) (f_R_d x))), Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) (* Goal: @ex Elt (fun r : Elt => and (dans r R) (@eq Elt (couple (word w1) (couple (eps X) (word w2))) (f_R_d r))) *) (* Goal: forall _ : dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X), Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) (* Goal: or (dans (couple (word w1) (couple (eps X) (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X)) *) intros r temp; elim temp; clear temp; intros dans_r_R eg. (* Goal: Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) (* Goal: @ex Elt (fun r : Elt => and (dans r R) (@eq Elt (couple (word w1) (couple (eps X) (word w2))) (f_R_d r))) *) (* Goal: forall _ : dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X), Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) (* Goal: or (dans (couple (word w1) (couple (eps X) (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X)) *) replace w1 with (cons (first r) nil). (* Goal: Derive_P_A_2 (@pair Word Word (Append (cons (first r) nil) w) u) (@pair Word Word (Append w2 w) u) *) (* Goal: @eq Word (cons (first r) nil) w1 *) (* Goal: @ex Elt (fun r : Elt => and (dans r R) (@eq Elt (couple (word w1) (couple (eps X) (word w2))) (f_R_d r))) *) (* Goal: forall _ : dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X), Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) (* Goal: or (dans (couple (word w1) (couple (eps X) (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X)) *) replace (Append (cons (first r) nil) w) with (cons (first r) w). (* Goal: Derive_P_A_2 (@pair Word Word (cons (first r) w) u) (@pair Word Word (Append w2 w) u) *) (* Goal: @eq Word (cons (first r) w) (Append (cons (first r) nil) w) *) (* Goal: @eq Word (cons (first r) nil) w1 *) (* Goal: @ex Elt (fun r : Elt => and (dans r R) (@eq Elt (couple (word w1) (couple (eps X) (word w2))) (f_R_d r))) *) (* Goal: forall _ : dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X), Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) (* Goal: or (dans (couple (word w1) (couple (eps X) (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X)) *) apply Derive_V. (* Goal: dans (couple (first r) (word w2)) R *) (* Goal: @eq Word (cons (first r) w) (Append (cons (first r) nil) w) *) (* Goal: @eq Word (cons (first r) nil) w1 *) (* Goal: @ex Elt (fun r : Elt => and (dans r R) (@eq Elt (couple (word w1) (couple (eps X) (word w2))) (f_R_d r))) *) (* Goal: forall _ : dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X), Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) (* Goal: or (dans (couple (word w1) (couple (eps X) (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X)) *) replace (word w2) with (second r). elimtype (ex2 (fun A : Elt => dans A V) (fun A : Elt => ex2 (fun B : Word => r = couple A (word B)) (fun B : Word => inmonoid (union X V) B))). (* Goal: forall (x : Elt) (_ : dans x V) (_ : @ex2 Word (fun B : Word => @eq Elt r (couple x (word B))) (fun B : Word => inmonoid (union X V) B)), dans (couple (first r) (second r)) R *) (* Goal: @ex2 Elt (fun A : Elt => dans A V) (fun A : Elt => @ex2 Word (fun B : Word => @eq Elt r (couple A (word B))) (fun B : Word => inmonoid (union X V) B)) *) (* Goal: @eq Elt (second r) (word w2) *) (* Goal: @eq Word (cons (first r) w) (Append (cons (first r) nil) w) *) (* Goal: @eq Word (cons (first r) nil) w1 *) (* Goal: @ex Elt (fun r : Elt => and (dans r R) (@eq Elt (couple (word w1) (couple (eps X) (word w2))) (f_R_d r))) *) (* Goal: forall _ : dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X), Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) (* Goal: or (dans (couple (word w1) (couple (eps X) (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X)) *) intros A dans_A_V temp; elim temp; clear temp; intros B eg_r inmon_B. (* Goal: dans (couple (first r) (second r)) R *) (* Goal: @ex2 Elt (fun A : Elt => dans A V) (fun A : Elt => @ex2 Word (fun B : Word => @eq Elt r (couple A (word B))) (fun B : Word => inmonoid (union X V) B)) *) (* Goal: @eq Elt (second r) (word w2) *) (* Goal: @eq Word (cons (first r) w) (Append (cons (first r) nil) w) *) (* Goal: @eq Word (cons (first r) nil) w1 *) (* Goal: @ex Elt (fun r : Elt => and (dans r R) (@eq Elt (couple (word w1) (couple (eps X) (word w2))) (f_R_d r))) *) (* Goal: forall _ : dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X), Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) (* Goal: or (dans (couple (word w1) (couple (eps X) (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X)) *) rewrite eg_r. (* Goal: dans (couple (first (couple A (word B))) (second (couple A (word B)))) R *) (* Goal: @ex2 Elt (fun A : Elt => dans A V) (fun A : Elt => @ex2 Word (fun B : Word => @eq Elt r (couple A (word B))) (fun B : Word => inmonoid (union X V) B)) *) (* Goal: @eq Elt (second r) (word w2) *) (* Goal: @eq Word (cons (first r) w) (Append (cons (first r) nil) w) *) (* Goal: @eq Word (cons (first r) nil) w1 *) (* Goal: @ex Elt (fun r : Elt => and (dans r R) (@eq Elt (couple (word w1) (couple (eps X) (word w2))) (f_R_d r))) *) (* Goal: forall _ : dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X), Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) (* Goal: or (dans (couple (word w1) (couple (eps X) (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X)) *) replace (first (couple A (word B))) with A. (* Goal: dans (couple A (second (couple A (word B)))) R *) (* Goal: @eq Elt A (first (couple A (word B))) *) (* Goal: @ex2 Elt (fun A : Elt => dans A V) (fun A : Elt => @ex2 Word (fun B : Word => @eq Elt r (couple A (word B))) (fun B : Word => inmonoid (union X V) B)) *) (* Goal: @eq Elt (second r) (word w2) *) (* Goal: @eq Word (cons (first r) w) (Append (cons (first r) nil) w) *) (* Goal: @eq Word (cons (first r) nil) w1 *) (* Goal: @ex Elt (fun r : Elt => and (dans r R) (@eq Elt (couple (word w1) (couple (eps X) (word w2))) (f_R_d r))) *) (* Goal: forall _ : dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X), Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) (* Goal: or (dans (couple (word w1) (couple (eps X) (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X)) *) replace (second (couple A (word B))) with (word B). (* Goal: dans (couple A (word B)) R *) (* Goal: @eq Elt (word B) (second (couple A (word B))) *) (* Goal: @eq Elt A (first (couple A (word B))) *) (* Goal: @ex2 Elt (fun A : Elt => dans A V) (fun A : Elt => @ex2 Word (fun B : Word => @eq Elt r (couple A (word B))) (fun B : Word => inmonoid (union X V) B)) *) (* Goal: @eq Elt (second r) (word w2) *) (* Goal: @eq Word (cons (first r) w) (Append (cons (first r) nil) w) *) (* Goal: @eq Word (cons (first r) nil) w1 *) (* Goal: @ex Elt (fun r : Elt => and (dans r R) (@eq Elt (couple (word w1) (couple (eps X) (word w2))) (f_R_d r))) *) (* Goal: forall _ : dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X), Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) (* Goal: or (dans (couple (word w1) (couple (eps X) (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X)) *) rewrite <- eg_r. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) trivial. (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) trivial. (* Goal: @ex2 Elt (fun A : Elt => dans A V) (fun A : Elt => @ex2 Word (fun B : Word => @eq Elt r (couple A (word B))) (fun B : Word => inmonoid (union X V) B)) *) (* Goal: @eq Elt (second r) (word w2) *) (* Goal: @eq Word (cons (first r) w) (Append (cons (first r) nil) w) *) (* Goal: @eq Word (cons (first r) nil) w1 *) (* Goal: @ex Elt (fun r : Elt => and (dans r R) (@eq Elt (couple (word w1) (couple (eps X) (word w2))) (f_R_d r))) *) (* Goal: forall _ : dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X), Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) (* Goal: or (dans (couple (word w1) (couple (eps X) (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X)) *) apply Regles_X_V_R. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: @eq Elt (second r) (word w2) *) (* Goal: @eq Word (cons (first r) w) (Append (cons (first r) nil) w) *) (* Goal: @eq Word (cons (first r) nil) w1 *) (* Goal: @ex Elt (fun r : Elt => and (dans r R) (@eq Elt (couple (word w1) (couple (eps X) (word w2))) (f_R_d r))) *) (* Goal: forall _ : dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X), Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) (* Goal: or (dans (couple (word w1) (couple (eps X) (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X)) *) apply couple_couple_inv2 with (eps X) (eps X). (* Goal: @eq Elt (couple (eps X) (second r)) (couple (eps X) (word w2)) *) (* Goal: @eq Word (cons (first r) w) (Append (cons (first r) nil) w) *) (* Goal: @eq Word (cons (first r) nil) w1 *) (* Goal: @ex Elt (fun r : Elt => and (dans r R) (@eq Elt (couple (word w1) (couple (eps X) (word w2))) (f_R_d r))) *) (* Goal: forall _ : dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X), Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) (* Goal: or (dans (couple (word w1) (couple (eps X) (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X)) *) apply couple_couple_inv2 with (word (cons (first r) nil)) (word w1). (* Goal: and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) auto. (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) trivial. (* Goal: @eq Word (cons (first r) nil) w1 *) (* Goal: @ex Elt (fun r : Elt => and (dans r R) (@eq Elt (couple (word w1) (couple (eps X) (word w2))) (f_R_d r))) *) (* Goal: forall _ : dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X), Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) (* Goal: or (dans (couple (word w1) (couple (eps X) (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X)) *) apply word_word_inv. apply couple_couple_inv1 with (couple (eps X) (second r)) (couple (eps X) (word w2)). (* Goal: and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) auto. (* Goal: @ex Elt (fun r : Elt => and (dans r X) (@eq Elt (couple (word w1) (couple (eps X) (word w2))) (f_X_d r))) *) (* Goal: or (dans (couple (word w1) (couple (eps X) (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X)) *) apply dans_map. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: forall _ : dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X), Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) (* Goal: or (dans (couple (word w1) (couple (eps X) (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X)) *) intro dans_couple. elimtype (exists r : Elt, dans r X /\ couple (word w1) (couple (eps X) (word w2)) = f_X_d r). (* Goal: forall (x : Elt) (_ : and (dans x X) (@eq Elt (couple (word w1) (couple (eps X) (word w2))) (f_X_d x))), Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) (* Goal: @ex Elt (fun r : Elt => and (dans r X) (@eq Elt (couple (word w1) (couple (eps X) (word w2))) (f_X_d r))) *) (* Goal: or (dans (couple (word w1) (couple (eps X) (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X)) *) intros r temp; elim temp; clear temp; intros dans_r_X eg. (* Goal: Derive_P_A_2 (@pair Word Word (Append w1 w) u) (@pair Word Word (Append w2 w) u) *) (* Goal: @ex Elt (fun r : Elt => and (dans r X) (@eq Elt (couple (word w1) (couple (eps X) (word w2))) (f_X_d r))) *) (* Goal: or (dans (couple (word w1) (couple (eps X) (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X)) *) absurd (dans (eps X) X). (* Goal: not (dans (eps X) X) *) (* Goal: dans (eps X) X *) (* Goal: @ex Elt (fun r : Elt => and (dans r X) (@eq Elt (couple (word w1) (couple (eps X) (word w2))) (f_X_d r))) *) (* Goal: or (dans (couple (word w1) (couple (eps X) (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X)) *) apply not_dans_X_eps. (* Goal: dans (eps X) X *) (* Goal: @ex Elt (fun r : Elt => and (dans r X) (@eq Elt (couple (word w1) (couple (eps X) (word w2))) (f_X_d r))) *) (* Goal: or (dans (couple (word w1) (couple (eps X) (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X)) *) replace (eps X) with r. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: @eq Elt r (eps X) *) (* Goal: @ex Elt (fun r : Elt => and (dans r X) (@eq Elt (couple (word w1) (couple (eps X) (word w2))) (f_X_d r))) *) (* Goal: or (dans (couple (word w1) (couple (eps X) (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X)) *) apply couple_couple_inv1 with (word nil) (word w2). (* Goal: @eq Elt (couple r (word nil)) (couple (eps X) (word w2)) *) (* Goal: @ex Elt (fun r : Elt => and (dans r X) (@eq Elt (couple (word w1) (couple (eps X) (word w2))) (f_X_d r))) *) (* Goal: or (dans (couple (word w1) (couple (eps X) (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X)) *) apply couple_couple_inv2 with (word (cons r nil)) (word w1). (* Goal: and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) auto. (* Goal: @ex Elt (fun r : Elt => and (dans r X) (@eq Elt (couple (word w1) (couple (eps X) (word w2))) (f_X_d r))) *) (* Goal: or (dans (couple (word w1) (couple (eps X) (word w2))) (map f_R_d R)) (dans (couple (word w1) (couple (eps X) (word w2))) (map f_X_d X)) *) apply dans_map. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) auto. Qed. Hint Resolve Derive_P_A_imp_Derive_P_A_2. Lemma Derivestar_P_A_imp_Derivestar_P_A_2 : forall x y : Word * Word, Derivestar_P_A X d x y -> Derivestar_P_A_2 x y. (* Goal: forall (x y : prod Word Word) (_ : Derivestar_P_A X d x y), Derivestar_P_A_2 x y *) unfold Derivestar_P_A, Rstar, Derivestar_P_A_2 in |- *. (* Goal: forall (x y : Conf) (_ : forall (P : forall (_ : Conf) (_ : Conf), Prop) (_ : forall u : Conf, P u u) (_ : forall (u v w : Conf) (_ : Derive_P_A_2 u v) (_ : P v w), P u w), P x y) (s : Word), @ex Word (fun s2 : Word => Rstar (prod Word Conf) Derive_P_A_3 (@pair Word Conf s x) (@pair Word Conf s2 y)) *) intros x y Der_star. (* Goal: forall s : Word, @ex Word (fun s2 : Word => Rstar (prod Word Conf) Derive_P_A_3 (@pair Word Conf s x) (@pair Word Conf s2 y)) *) pattern x, y in |- *. (* Goal: (fun c c0 : Conf => forall s : Word, @ex Word (fun s2 : Word => Rstar (prod Word Conf) Derive_P_A_3 (@pair Word Conf s c) (@pair Word Conf s2 c0))) x y *) apply Der_star. (* Goal: forall (u : prod Word Conf) (_ : inmonoid X (@fst Word Conf u)), Rstar Word (Deriveg X R) (Append (@fst Word Conf u) (@fst Word Word (@snd Word Conf u))) (Append (@fst Word Conf u) (@fst Word Word (@snd Word Conf u))) *) (* Goal: forall (u v w : prod Word Conf) (_ : Derive_P_A_3 u v) (_ : forall _ : inmonoid X (@fst Word Conf v), Rstar Word (Deriveg X R) (Append (@fst Word Conf v) (@fst Word Word (@snd Word Conf v))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w)))) (_ : inmonoid X (@fst Word Conf u)), Rstar Word (Deriveg X R) (Append (@fst Word Conf u) (@fst Word Word (@snd Word Conf u))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w))) *) intros. (* Goal: Rstar Word (Deriveg X R) (Append (@fst Word Conf u) (@fst Word Word (@snd Word Conf u))) (Append (@fst Word Conf u) (@fst Word Word (@snd Word Conf u))) *) (* Goal: forall (u v w : prod Word Conf) (_ : Derive_P_A_3 u v) (_ : forall _ : inmonoid X (@fst Word Conf v), Rstar Word (Deriveg X R) (Append (@fst Word Conf v) (@fst Word Word (@snd Word Conf v))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w)))) (_ : inmonoid X (@fst Word Conf u)), Rstar Word (Deriveg X R) (Append (@fst Word Conf u) (@fst Word Word (@snd Word Conf u))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w))) *) apply Rstar_reflexive. (* Goal: forall (u v w : Conf) (_ : Derive_P_A X d u v) (_ : Rstar Conf Derive_P_A_2 v w), Rstar Conf Derive_P_A_2 u w *) intros u v w Deri_u_v Rstar_v_w. (* Goal: and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) apply Rstar_R with v; auto. Qed. Hint Resolve Derivestar_P_A_imp_Derivestar_P_A_2. (**************************************************************) (*Tout mot reconnu par la grammaire est reconnu par l'automate*) (**************************************************************) Theorem Derivestar_imp_Derivestar_P_A : forall x y : Word, Derivestar R x y -> inmonoid X y -> Derivestar_P_A X d (x, y) (nil, nil). (* Goal: and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) auto. Qed. (**************************************************************) Inductive Derive_P_A_3 : Word * Conf -> Word * Conf -> Prop := | Derive3_X : forall (w u s : Word) (x : Elt), dans x X -> Derive_P_A_3 (s, (cons x w, cons x u)) (Append s (cons x nil), (w, u)) | Derive3_V : forall (v w u s : Word) (x : Elt), dans (couple x (word u)) R -> Derive_P_A_3 (s, (cons x w, v)) (s, (Append u w, v)). Definition Derivestar_P_A_3 := Rstar (Word * Conf) Derive_P_A_3. Lemma Conserve_App_s_u : forall s1 s2 u1 u2 v1 v2 : Word, Derive_P_A_3 (s1, (u1, v1)) (s2, (u2, v2)) -> Append s1 v1 = Append s2 v2. (* Goal: forall (s1 s2 u1 u2 v1 v2 : Word) (_ : Derive_P_A_3 (@pair Word (prod Word Word) s1 (@pair Word Word u1 v1)) (@pair Word (prod Word Word) s2 (@pair Word Word u2 v2))), @eq Word (Append s1 v1) (Append s2 v2) *) intros s1 s2 u1 u2 v1 v2 Derive_P_A_3_s1_v1_s2_v2. change ((fun a b : Word * Conf => Append (fst a) (snd (snd a)) = Append (fst b) (snd (snd b))) (s1, (u1, v1)) (s2, (u2, v2))) in |- *. (* Goal: forall (_ : Derive_P_A_3 (@pair Word Conf u1 (@pair Word Word u2 u3)) (@pair Word Conf v1 (@pair Word Word v2 v3))) (_ : forall _ : inmonoid X (@fst Word Conf (@pair Word Conf v1 (@pair Word Word v2 v3))), Rstar Word (Deriveg X R) (Append (@fst Word Conf (@pair Word Conf v1 (@pair Word Word v2 v3))) (@fst Word Word (@snd Word Conf (@pair Word Conf v1 (@pair Word Word v2 v3))))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w)))) (_ : inmonoid X (@fst Word Conf (@pair Word Conf u1 (@pair Word Word u2 u3)))), Rstar Word (Deriveg X R) (Append (@fst Word Conf (@pair Word Conf u1 (@pair Word Word u2 u3))) (@fst Word Word (@snd Word Conf (@pair Word Conf u1 (@pair Word Word u2 u3))))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w))) *) elim Derive_P_A_3_s1_v1_s2_v2; simpl in |- *. (* Goal: forall (_ : Word) (u s : Word) (x : Elt) (_ : dans x X), @eq Word (Append s (cons x u)) (Append (Append s (cons x nil)) u) *) (* Goal: forall (v _ : Word) (u s : Word) (x : Elt) (_ : dans (couple x (word u)) R), @eq Word (Append s v) (Append s v) *) intros w u s x dans_x_X. (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) replace (cons x u) with (Append (cons x nil) u); trivial. (* Goal: and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) auto. Qed. Lemma Derisvestar_P_A_3_conserve : forall s1 s2 u1 u2 v1 v2 : Word, Derivestar_P_A_3 (s1, (u1, v1)) (s2, (u2, v2)) -> Append s1 v1 = Append s2 v2. (* Goal: forall (x y x' y' s s' : Word) (_ : Derivestar_P_A_3 (@pair Word (prod Word Word) s (@pair Word Word x y)) (@pair Word (prod Word Word) s' (@pair Word Word x' y'))) (_ : inmonoid X s), Derivegstar X R (Append s x) (Append s' x') *) unfold Derivestar_P_A_3, Rstar in |- *. (* Goal: forall (s1 s2 u1 u2 v1 v2 : Word) (_ : forall (P : forall (_ : prod Word Conf) (_ : prod Word Conf), Prop) (_ : forall u : prod Word Conf, P u u) (_ : forall (u v w : prod Word Conf) (_ : Derive_P_A_3 u v) (_ : P v w), P u w), P (@pair Word (prod Word Word) s1 (@pair Word Word u1 v1)) (@pair Word (prod Word Word) s2 (@pair Word Word u2 v2))), @eq Word (Append s1 v1) (Append s2 v2) *) intros s1 s2 u1 u2 v1 v2 Derivestar_P_A_3_s1_v1_s2_v2. change ((fun a b : Word * Conf => Append (fst a) (snd (snd a)) = Append (fst b) (snd (snd b))) (s1, (u1, v1)) (s2, (u2, v2))) in |- *. (* Goal: (fun a b : prod Word Conf => @eq Word (Append (@fst Word Conf a) (@snd Word Word (@snd Word Conf a))) (Append (@fst Word Conf b) (@snd Word Word (@snd Word Conf b)))) (@pair Word (prod Word Word) s1 (@pair Word Word u1 v1)) (@pair Word (prod Word Word) s2 (@pair Word Word u2 v2)) *) apply Derivestar_P_A_3_s1_v1_s2_v2. (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) trivial. (* Goal: forall (u v w : prod Word Conf) (_ : Derive_P_A_3 u v) (_ : forall _ : inmonoid X (@fst Word Conf v), Rstar Word (Deriveg X R) (Append (@fst Word Conf v) (@fst Word Word (@snd Word Conf v))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w)))) (_ : inmonoid X (@fst Word Conf u)), Rstar Word (Deriveg X R) (Append (@fst Word Conf u) (@fst Word Word (@snd Word Conf u))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w))) *) intros u v w. (* Goal: forall (_ : Derive_P_A_3 u v) (_ : forall _ : inmonoid X (@fst Word Conf v), Rstar Word (Deriveg X R) (Append (@fst Word Conf v) (@fst Word Word (@snd Word Conf v))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w)))) (_ : inmonoid X (@fst Word Conf u)), Rstar Word (Deriveg X R) (Append (@fst Word Conf u) (@fst Word Word (@snd Word Conf u))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w))) *) elim u. intros uu1 uuc. elim uuc. intros uu2 uu3. (* Goal: forall (_ : Derive_P_A_3 (@pair Word Conf u1 (@pair Word Word u2 u3)) v) (_ : forall _ : inmonoid X (@fst Word Conf v), Rstar Word (Deriveg X R) (Append (@fst Word Conf v) (@fst Word Word (@snd Word Conf v))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w)))) (_ : inmonoid X (@fst Word Conf (@pair Word Conf u1 (@pair Word Word u2 u3)))), Rstar Word (Deriveg X R) (Append (@fst Word Conf (@pair Word Conf u1 (@pair Word Word u2 u3))) (@fst Word Word (@snd Word Conf (@pair Word Conf u1 (@pair Word Word u2 u3))))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w))) *) elim v. intros vv1 vvc. elim vvc. intros vv2 vv3. (* Goal: forall (_ : Derive_P_A_3 (@pair Word Conf u1 (@pair Word Word u2 u3)) (@pair Word Conf v1 (@pair Word Word v2 v3))) (_ : forall _ : inmonoid X (@fst Word Conf (@pair Word Conf v1 (@pair Word Word v2 v3))), Rstar Word (Deriveg X R) (Append (@fst Word Conf (@pair Word Conf v1 (@pair Word Word v2 v3))) (@fst Word Word (@snd Word Conf (@pair Word Conf v1 (@pair Word Word v2 v3))))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w)))) (_ : inmonoid X (@fst Word Conf (@pair Word Conf u1 (@pair Word Word u2 u3)))), Rstar Word (Deriveg X R) (Append (@fst Word Conf (@pair Word Conf u1 (@pair Word Word u2 u3))) (@fst Word Word (@snd Word Conf (@pair Word Conf u1 (@pair Word Word u2 u3))))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w))) *) simpl in |- *. (* Goal: forall (_ : Derive_P_A_3 (@pair Word Conf uu1 (@pair Word Word uu2 uu3)) (@pair Word Conf vv1 (@pair Word Word vv2 vv3))) (_ : @eq Word (Append vv1 vv3) (Append (@fst Word Conf w) (@snd Word Word (@snd Word Conf w)))), @eq Word (Append uu1 uu3) (Append (@fst Word Conf w) (@snd Word Word (@snd Word Conf w))) *) intros Der eg1. (* Goal: @eq Word (Append uu1 uu3) (Append (@fst Word Conf w) (@snd Word Word (@snd Word Conf w))) *) rewrite <- eg1. (* Goal: @eq Word (Append uu1 uu3) (Append vv1 vv3) *) apply Conserve_App_s_u with uu2 vv2. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. Qed. Lemma Derive_P_A_2_imp_Derive_P_A_3 : forall (s : Word) (x y : Conf), Derive_P_A_2 x y -> exists s2 : Word, Derive_P_A_3 (s, x) (s2, y). (* Goal: forall (s : Word) (x y : Conf) (_ : Derive_P_A_2 x y), @ex Word (fun s2 : Word => Derive_P_A_3 (@pair Word Conf s x) (@pair Word Conf s2 y)) *) intros s x y Derive_P_A_2_x_y. (* Goal: @ex Word (fun s2 : Word => Derive_P_A_3 (@pair Word Conf s x) (@pair Word Conf s2 y)) *) elim Derive_P_A_2_x_y. (* Goal: forall (w u : Word) (x : Elt) (_ : dans x X), @ex Word (fun s2 : Word => Derive_P_A_3 (@pair Word Conf s (@pair Word Word (cons x w) (cons x u))) (@pair Word Conf s2 (@pair Word Word w u))) *) (* Goal: forall (v w u : Word) (x : Elt) (_ : dans (couple x (word u)) R), @ex Word (fun s2 : Word => Derive_P_A_3 (@pair Word Conf s (@pair Word Word (cons x w) v)) (@pair Word Conf s2 (@pair Word Word (Append u w) v))) *) intros w u x0 dans_x0_X. (* Goal: @ex Word (fun s2 : Word => Derive_P_A_3 (@pair Word Conf s (@pair Word Word (cons x0 w) (cons x0 u))) (@pair Word Conf s2 (@pair Word Word w u))) *) (* Goal: forall (v w u : Word) (x : Elt) (_ : dans (couple x (word u)) R), @ex Word (fun s2 : Word => Derive_P_A_3 (@pair Word Conf s (@pair Word Word (cons x w) v)) (@pair Word Conf s2 (@pair Word Word (Append u w) v))) *) exists (Append s (cons x0 nil)). (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) apply Derive3_X; assumption. (* Goal: forall (v w u : Word) (x : Elt) (_ : dans (couple x (word u)) R), @ex Word (fun s2 : Word => Derive_P_A_3 (@pair Word Conf s (@pair Word Word (cons x w) v)) (@pair Word Conf s2 (@pair Word Word (Append u w) v))) *) intros v w u x0 dans_couple. (* Goal: forall (u : Conf) (s : Word), @ex Word (fun s2 : Word => Rstar (prod Word Conf) Derive_P_A_3 (@pair Word Conf s u) (@pair Word Conf s2 u)) *) (* Goal: forall (u v w : Conf) (_ : Derive_P_A_2 u v) (_ : forall s : Word, @ex Word (fun s2 : Word => Rstar (prod Word Conf) Derive_P_A_3 (@pair Word Conf s v) (@pair Word Conf s2 w))) (s : Word), @ex Word (fun s2 : Word => Rstar (prod Word Conf) Derive_P_A_3 (@pair Word Conf s u) (@pair Word Conf s2 w)) *) intros; exists s. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) apply Derive3_V; assumption. Qed. Lemma Derivestar_P_A_2_imp_Derivestar_P_A_3 : forall x y : Conf, Derivestar_P_A_2 x y -> forall s : Word, exists s2 : Word, Derivestar_P_A_3 (s, x) (s2, y). (* Goal: forall (x y : Conf) (_ : Derivestar_P_A_2 x y) (s : Word), @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word Conf s x) (@pair Word Conf s2 y)) *) unfold Derivestar_P_A_2, Rstar, Derivestar_P_A_3 in |- *. (* Goal: forall (x y : Conf) (_ : forall (P : forall (_ : Conf) (_ : Conf), Prop) (_ : forall u : Conf, P u u) (_ : forall (u v w : Conf) (_ : Derive_P_A_2 u v) (_ : P v w), P u w), P x y) (s : Word), @ex Word (fun s2 : Word => Rstar (prod Word Conf) Derive_P_A_3 (@pair Word Conf s x) (@pair Word Conf s2 y)) *) intros x y Der_star. (* Goal: forall s : Word, @ex Word (fun s2 : Word => Rstar (prod Word Conf) Derive_P_A_3 (@pair Word Conf s x) (@pair Word Conf s2 y)) *) pattern x, y in |- *. (* Goal: (fun c c0 : Conf => forall s : Word, @ex Word (fun s2 : Word => Rstar (prod Word Conf) Derive_P_A_3 (@pair Word Conf s c) (@pair Word Conf s2 c0))) x y *) apply Der_star. (* Goal: forall (u : Conf) (s : Word), @ex Word (fun s2 : Word => Rstar (prod Word Conf) Derive_P_A_3 (@pair Word Conf s u) (@pair Word Conf s2 u)) *) (* Goal: forall (u v w : Conf) (_ : Derive_P_A_2 u v) (_ : forall s : Word, @ex Word (fun s2 : Word => Rstar (prod Word Conf) Derive_P_A_3 (@pair Word Conf s v) (@pair Word Conf s2 w))) (s : Word), @ex Word (fun s2 : Word => Rstar (prod Word Conf) Derive_P_A_3 (@pair Word Conf s u) (@pair Word Conf s2 w)) *) intros; exists s. (* Goal: Rstar Word (Deriveg X R) (Append (@fst Word Conf u) (@fst Word Word (@snd Word Conf u))) (Append (@fst Word Conf u) (@fst Word Word (@snd Word Conf u))) *) (* Goal: forall (u v w : prod Word Conf) (_ : Derive_P_A_3 u v) (_ : forall _ : inmonoid X (@fst Word Conf v), Rstar Word (Deriveg X R) (Append (@fst Word Conf v) (@fst Word Word (@snd Word Conf v))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w)))) (_ : inmonoid X (@fst Word Conf u)), Rstar Word (Deriveg X R) (Append (@fst Word Conf u) (@fst Word Word (@snd Word Conf u))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w))) *) apply Rstar_reflexive. (* Goal: forall (u v w : Conf) (_ : Derive_P_A_2 u v) (_ : forall s : Word, @ex Word (fun s2 : Word => Rstar (prod Word Conf) Derive_P_A_3 (@pair Word Conf s v) (@pair Word Conf s2 w))) (s : Word), @ex Word (fun s2 : Word => Rstar (prod Word Conf) Derive_P_A_3 (@pair Word Conf s u) (@pair Word Conf s2 w)) *) intros u v w Der_u_v Ex_v_w s. (* Goal: @ex Word (fun s2 : Word => Rstar (prod Word Conf) Derive_P_A_3 (@pair Word Conf s u) (@pair Word Conf s2 w)) *) elimtype (exists s2 : Word, Derive_P_A_3 (s, u) (s2, v)). (* Goal: forall (x : Word) (_ : Derive_P_A_3 (@pair Word Conf s u) (@pair Word Conf x v)), @ex Word (fun s2 : Word => Rstar (prod Word Conf) Derive_P_A_3 (@pair Word Conf s u) (@pair Word Conf s2 w)) *) (* Goal: @ex Word (fun s2 : Word => Derive_P_A_3 (@pair Word Conf s u) (@pair Word Conf s2 v)) *) intros s1 Der_3_s_u_s1_v. (* Goal: @ex Word (fun s2 : Word => Rstar (prod Word Conf) Derive_P_A_3 (@pair Word Conf s u) (@pair Word Conf s2 w)) *) (* Goal: @ex Word (fun s2 : Word => Derive_P_A_3 (@pair Word Conf s u) (@pair Word Conf s2 v)) *) elim (Ex_v_w s1). (* Goal: forall (x : Word) (_ : Rstar (prod Word Conf) Derive_P_A_3 (@pair Word Conf s1 v) (@pair Word Conf x w)), @ex Word (fun s2 : Word => Rstar (prod Word Conf) Derive_P_A_3 (@pair Word Conf s u) (@pair Word Conf s2 w)) *) (* Goal: @ex Word (fun s2 : Word => Derive_P_A_3 (@pair Word Conf s u) (@pair Word Conf s2 v)) *) intros s2 Rstar_s1_v_s2_w. (* Goal: @ex Word (fun s2 : Word => Rstar (prod Word Conf) Derive_P_A_3 (@pair Word Conf s u) (@pair Word Conf s2 w)) *) (* Goal: @ex Word (fun s2 : Word => Derive_P_A_3 (@pair Word Conf s u) (@pair Word Conf s2 v)) *) exists s2. (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) apply Rstar_R with (s1, v); trivial. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) apply Derive_P_A_2_imp_Derive_P_A_3; assumption. Qed. Lemma Deriveg_imp_Deriveg_App_2 : forall x y a : Word, inmonoid X a -> Deriveg X R x y -> Deriveg X R (Append a x) (Append a y). (* Goal: forall (x y a : Word) (_ : inmonoid X a) (_ : Deriveg X R x y), Deriveg X R (Append a x) (Append a y) *) intros x y. (* Goal: forall (a : Word) (_ : inmonoid X a) (_ : Deriveg X R x y), Deriveg X R (Append a x) (Append a y) *) simple induction a. (* Goal: and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) auto. (* Goal: forall (e : Elt) (w : Word) (_ : forall (_ : inmonoid X w) (_ : Deriveg X R x y), Deriveg X R (Append w x) (Append w y)) (_ : inmonoid X (cons e w)) (_ : Deriveg X R x y), Deriveg X R (Append (cons e w) x) (Append (cons e w) y) *) intros x0 w Hyp inmonoid_X_cons_x0_w Der_x_y. (* Goal: Deriveg X R (Append (cons x0 w) x) (Append (cons x0 w) y) *) change (Deriveg X R (cons x0 (Append w x)) (cons x0 (Append w y))) in |- *. (* Goal: Deriveg X R (cons x0 (Append w x)) (cons x0 (Append w y)) *) apply Deriveg2. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) apply inmonoid_cons_inv2 with w; assumption. (* Goal: Rstar Word (Deriveg X R) (Append v1 v2) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w))) *) apply Hyp. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) apply inmonoid_cons_inv with x0; assumption. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. Qed. Lemma Derive_P_A_3_imp_Derivegstar : forall x y x' y' s s' : Word, Derive_P_A_3 (s, (x, y)) (s', (x', y')) -> inmonoid X s -> Derivegstar X R (Append s x) (Append s' x'). (* Goal: forall (x y x' y' s s' : Word) (_ : Derive_P_A_3 (@pair Word (prod Word Word) s (@pair Word Word x y)) (@pair Word (prod Word Word) s' (@pair Word Word x' y'))) (_ : inmonoid X s), inmonoid X s' *) intros x y x' y' s s' Der. change ((fun a a' : Word * Conf => inmonoid X (fst a) -> Derivegstar X R (Append (fst a) (fst (snd a))) (Append (fst a') (fst (snd a')))) (s, (x, y)) (s', (x', y'))) in |- *. (* Goal: (fun a a' : prod Word Conf => forall _ : inmonoid X (@fst Word Conf a), Derivegstar X R (Append (@fst Word Conf a) (@fst Word Word (@snd Word Conf a))) (Append (@fst Word Conf a') (@fst Word Word (@snd Word Conf a')))) (@pair Word (prod Word Word) s (@pair Word Word x y)) (@pair Word (prod Word Word) s' (@pair Word Word x' y')) *) unfold Derivegstar in |- *. (* Goal: forall (_ : Derive_P_A_3 (@pair Word Conf u1 (@pair Word Word u2 u3)) (@pair Word Conf v1 (@pair Word Word v2 v3))) (_ : forall _ : inmonoid X (@fst Word Conf (@pair Word Conf v1 (@pair Word Word v2 v3))), Rstar Word (Deriveg X R) (Append (@fst Word Conf (@pair Word Conf v1 (@pair Word Word v2 v3))) (@fst Word Word (@snd Word Conf (@pair Word Conf v1 (@pair Word Word v2 v3))))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w)))) (_ : inmonoid X (@fst Word Conf (@pair Word Conf u1 (@pair Word Word u2 u3)))), Rstar Word (Deriveg X R) (Append (@fst Word Conf (@pair Word Conf u1 (@pair Word Word u2 u3))) (@fst Word Word (@snd Word Conf (@pair Word Conf u1 (@pair Word Word u2 u3))))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w))) *) elim Der; simpl in |- *. (* Goal: forall (w _ : Word) (s : Word) (x : Elt) (_ : dans x X) (_ : inmonoid X s), Rstar Word (Deriveg X R) (Append s (cons x w)) (Append (Append s (cons x nil)) w) *) (* Goal: forall (_ : Word) (w u s : Word) (x : Elt) (_ : dans (couple x (word u)) R) (_ : inmonoid X s), Rstar Word (Deriveg X R) (Append s (cons x w)) (Append s (Append u w)) *) intros w u s0 x0 dans_x0_X inmon_s. replace (Append (Append s0 (cons x0 nil)) w) with (Append s0 (Append (cons x0 nil) w)). (* Goal: Rstar Word (Deriveg X R) (Append (@fst Word Conf u) (@fst Word Word (@snd Word Conf u))) (Append (@fst Word Conf u) (@fst Word Word (@snd Word Conf u))) *) (* Goal: forall (u v w : prod Word Conf) (_ : Derive_P_A_3 u v) (_ : forall _ : inmonoid X (@fst Word Conf v), Rstar Word (Deriveg X R) (Append (@fst Word Conf v) (@fst Word Word (@snd Word Conf v))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w)))) (_ : inmonoid X (@fst Word Conf u)), Rstar Word (Deriveg X R) (Append (@fst Word Conf u) (@fst Word Word (@snd Word Conf u))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w))) *) apply Rstar_reflexive. (* Goal: and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) auto. (* Goal: forall (_ : Word) (w u s : Word) (x : Elt) (_ : dans (couple x (word u)) R) (_ : inmonoid X s), Rstar Word (Deriveg X R) (Append s (cons x w)) (Append s (Append u w)) *) intros v w u s0 x0 dans_couple_x0_u_R inmon_s. (* Goal: Rstar Word (Deriveg X R) (Append s0 (cons x0 w)) (Append s0 (Append u w)) *) apply Rstar_R with (Append s0 (Append u w)). (* Goal: Deriveg X R (Append s0 (cons x0 w)) (Append s0 (Append u w)) *) (* Goal: Rstar Word (Deriveg X R) (Append s0 (Append u w)) (Append s0 (Append u w)) *) apply Deriveg_imp_Deriveg_App_2. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: Deriveg X R (cons x0 w) (Append u w) *) (* Goal: Rstar Word (Deriveg X R) (Append s0 (Append u w)) (Append s0 (Append u w)) *) apply Deriveg1. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: Rstar Word (Deriveg X R) (Append (@fst Word Conf u) (@fst Word Word (@snd Word Conf u))) (Append (@fst Word Conf u) (@fst Word Word (@snd Word Conf u))) *) (* Goal: forall (u v w : prod Word Conf) (_ : Derive_P_A_3 u v) (_ : forall _ : inmonoid X (@fst Word Conf v), Rstar Word (Deriveg X R) (Append (@fst Word Conf v) (@fst Word Word (@snd Word Conf v))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w)))) (_ : inmonoid X (@fst Word Conf u)), Rstar Word (Deriveg X R) (Append (@fst Word Conf u) (@fst Word Word (@snd Word Conf u))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w))) *) apply Rstar_reflexive. Qed. Lemma Derive_P_A_3_conserve_inmonoid_s : forall x y x' y' s s' : Word, Derive_P_A_3 (s, (x, y)) (s', (x', y')) -> inmonoid X s -> inmonoid X s'. (* Goal: forall (x y x' y' s s' : Word) (_ : Derive_P_A_3 (@pair Word (prod Word Word) s (@pair Word Word x y)) (@pair Word (prod Word Word) s' (@pair Word Word x' y'))) (_ : inmonoid X s), inmonoid X s' *) intros x y x' y' s s' Der. change ((fun a a' : Word * Conf => inmonoid X (fst a) -> inmonoid X (fst a')) (s, (x, y)) (s', (x', y'))) in |- *. (* Goal: forall (_ : Derive_P_A_3 (@pair Word Conf u1 (@pair Word Word u2 u3)) (@pair Word Conf v1 (@pair Word Word v2 v3))) (_ : forall _ : inmonoid X (@fst Word Conf (@pair Word Conf v1 (@pair Word Word v2 v3))), Rstar Word (Deriveg X R) (Append (@fst Word Conf (@pair Word Conf v1 (@pair Word Word v2 v3))) (@fst Word Word (@snd Word Conf (@pair Word Conf v1 (@pair Word Word v2 v3))))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w)))) (_ : inmonoid X (@fst Word Conf (@pair Word Conf u1 (@pair Word Word u2 u3)))), Rstar Word (Deriveg X R) (Append (@fst Word Conf (@pair Word Conf u1 (@pair Word Word u2 u3))) (@fst Word Word (@snd Word Conf (@pair Word Conf u1 (@pair Word Word u2 u3))))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w))) *) elim Der; simpl in |- *. (* Goal: forall (u : prod Word Conf) (_ : inmonoid X (@fst Word Conf u)), Rstar Word (Deriveg X R) (Append (@fst Word Conf u) (@fst Word Word (@snd Word Conf u))) (Append (@fst Word Conf u) (@fst Word Word (@snd Word Conf u))) *) (* Goal: forall (u v w : prod Word Conf) (_ : Derive_P_A_3 u v) (_ : forall _ : inmonoid X (@fst Word Conf v), Rstar Word (Deriveg X R) (Append (@fst Word Conf v) (@fst Word Word (@snd Word Conf v))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w)))) (_ : inmonoid X (@fst Word Conf u)), Rstar Word (Deriveg X R) (Append (@fst Word Conf u) (@fst Word Word (@snd Word Conf u))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w))) *) intros. (* Goal: and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) apply inmonoid_Append; auto. (* Goal: and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) auto. Qed. Lemma Derivestar_P_A_3_imp_Derivegstar : forall x y x' y' s s' : Word, Derivestar_P_A_3 (s, (x, y)) (s', (x', y')) -> inmonoid X s -> Derivegstar X R (Append s x) (Append s' x'). (* Goal: forall (x y x' y' s s' : Word) (_ : Derivestar_P_A_3 (@pair Word (prod Word Word) s (@pair Word Word x y)) (@pair Word (prod Word Word) s' (@pair Word Word x' y'))) (_ : inmonoid X s), Derivegstar X R (Append s x) (Append s' x') *) unfold Derivestar_P_A_3, Rstar in |- *. (* Goal: forall (x y x' y' s s' : Word) (_ : forall (P : forall (_ : prod Word Conf) (_ : prod Word Conf), Prop) (_ : forall u : prod Word Conf, P u u) (_ : forall (u v w : prod Word Conf) (_ : Derive_P_A_3 u v) (_ : P v w), P u w), P (@pair Word (prod Word Word) s (@pair Word Word x y)) (@pair Word (prod Word Word) s' (@pair Word Word x' y'))) (_ : inmonoid X s), Derivegstar X R (Append s x) (Append s' x') *) intros x y x' y' s s' Der_star. change ((fun a a' : Word * Conf => inmonoid X (fst a) -> Derivegstar X R (Append (fst a) (fst (snd a))) (Append (fst a') (fst (snd a')))) (s, (x, y)) (s', (x', y'))) in |- *. (* Goal: (fun a a' : prod Word Conf => forall _ : inmonoid X (@fst Word Conf a), Derivegstar X R (Append (@fst Word Conf a) (@fst Word Word (@snd Word Conf a))) (Append (@fst Word Conf a') (@fst Word Word (@snd Word Conf a')))) (@pair Word (prod Word Word) s (@pair Word Word x y)) (@pair Word (prod Word Word) s' (@pair Word Word x' y')) *) apply Der_star; unfold Derivegstar in |- *. (* Goal: forall (u : prod Word Conf) (_ : inmonoid X (@fst Word Conf u)), Rstar Word (Deriveg X R) (Append (@fst Word Conf u) (@fst Word Word (@snd Word Conf u))) (Append (@fst Word Conf u) (@fst Word Word (@snd Word Conf u))) *) (* Goal: forall (u v w : prod Word Conf) (_ : Derive_P_A_3 u v) (_ : forall _ : inmonoid X (@fst Word Conf v), Rstar Word (Deriveg X R) (Append (@fst Word Conf v) (@fst Word Word (@snd Word Conf v))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w)))) (_ : inmonoid X (@fst Word Conf u)), Rstar Word (Deriveg X R) (Append (@fst Word Conf u) (@fst Word Word (@snd Word Conf u))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w))) *) intros. (* Goal: Rstar Word (Deriveg X R) (Append (@fst Word Conf u) (@fst Word Word (@snd Word Conf u))) (Append (@fst Word Conf u) (@fst Word Word (@snd Word Conf u))) *) (* Goal: forall (u v w : prod Word Conf) (_ : Derive_P_A_3 u v) (_ : forall _ : inmonoid X (@fst Word Conf v), Rstar Word (Deriveg X R) (Append (@fst Word Conf v) (@fst Word Word (@snd Word Conf v))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w)))) (_ : inmonoid X (@fst Word Conf u)), Rstar Word (Deriveg X R) (Append (@fst Word Conf u) (@fst Word Word (@snd Word Conf u))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w))) *) apply Rstar_reflexive. (* Goal: forall (u v w : prod Word Conf) (_ : Derive_P_A_3 u v) (_ : forall _ : inmonoid X (@fst Word Conf v), Rstar Word (Deriveg X R) (Append (@fst Word Conf v) (@fst Word Word (@snd Word Conf v))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w)))) (_ : inmonoid X (@fst Word Conf u)), Rstar Word (Deriveg X R) (Append (@fst Word Conf u) (@fst Word Word (@snd Word Conf u))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w))) *) intros u v w. (* Goal: forall (_ : Derive_P_A_3 u v) (_ : forall _ : inmonoid X (@fst Word Conf v), Rstar Word (Deriveg X R) (Append (@fst Word Conf v) (@fst Word Word (@snd Word Conf v))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w)))) (_ : inmonoid X (@fst Word Conf u)), Rstar Word (Deriveg X R) (Append (@fst Word Conf u) (@fst Word Word (@snd Word Conf u))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w))) *) elim u. intros u1 uc. elim uc. intros u2 u3. (* Goal: forall (_ : Derive_P_A_3 (@pair Word Conf u1 (@pair Word Word u2 u3)) v) (_ : forall _ : inmonoid X (@fst Word Conf v), Rstar Word (Deriveg X R) (Append (@fst Word Conf v) (@fst Word Word (@snd Word Conf v))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w)))) (_ : inmonoid X (@fst Word Conf (@pair Word Conf u1 (@pair Word Word u2 u3)))), Rstar Word (Deriveg X R) (Append (@fst Word Conf (@pair Word Conf u1 (@pair Word Word u2 u3))) (@fst Word Word (@snd Word Conf (@pair Word Conf u1 (@pair Word Word u2 u3))))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w))) *) elim v. intros v1 vc. elim vc. intros v2 v3. (* Goal: forall (_ : Derive_P_A_3 (@pair Word Conf u1 (@pair Word Word u2 u3)) (@pair Word Conf v1 (@pair Word Word v2 v3))) (_ : forall _ : inmonoid X (@fst Word Conf (@pair Word Conf v1 (@pair Word Word v2 v3))), Rstar Word (Deriveg X R) (Append (@fst Word Conf (@pair Word Conf v1 (@pair Word Word v2 v3))) (@fst Word Word (@snd Word Conf (@pair Word Conf v1 (@pair Word Word v2 v3))))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w)))) (_ : inmonoid X (@fst Word Conf (@pair Word Conf u1 (@pair Word Word u2 u3)))), Rstar Word (Deriveg X R) (Append (@fst Word Conf (@pair Word Conf u1 (@pair Word Word u2 u3))) (@fst Word Word (@snd Word Conf (@pair Word Conf u1 (@pair Word Word u2 u3))))) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w))) *) simpl in |- *. (* Goal: forall (_ : Derive_P_A_3 (@pair Word Conf u1 (@pair Word Word u2 u3)) (@pair Word Conf v1 (@pair Word Word v2 v3))) (_ : forall _ : inmonoid X v1, Rstar Word (Deriveg X R) (Append v1 v2) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w)))) (_ : inmonoid X u1), Rstar Word (Deriveg X R) (Append u1 u2) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w))) *) intros Der_3_u_v Hyp inmon_u1. (* Goal: Rstar Word (Deriveg X R) (Append u1 u2) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w))) *) apply Rstar_transitive with (Append v1 v2). (* Goal: Rstar Word (Deriveg X R) (Append u1 u2) (Append v1 v2) *) (* Goal: Rstar Word (Deriveg X R) (Append v1 v2) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w))) *) change (Derivegstar X R (Append u1 u2) (Append v1 v2)) in |- *. (* Goal: Derivegstar X R (Append u1 u2) (Append v1 v2) *) (* Goal: Rstar Word (Deriveg X R) (Append v1 v2) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w))) *) apply Derive_P_A_3_imp_Derivegstar with u3 v3. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: Rstar Word (Deriveg X R) (Append v1 v2) (Append (@fst Word Conf w) (@fst Word Word (@snd Word Conf w))) *) apply Hyp. (* Goal: inmonoid X v1 *) apply Derive_P_A_3_conserve_inmonoid_s with u2 u3 v2 v3 u1. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. Qed. (*Tout mot reconnu par l'automate est reconnu par la grammaire*) Theorem Derivestar_P_A_imp_Derivestar : forall x y : Word, Derivestar_P_A X d (x, y) (nil, nil) -> Derivestar R x y. (* Goal: forall (x y : Word) (_ : Derivestar_P_A X d (@pair Word Word x y) (@pair Word Word nil nil)), Derivestar R x y *) intros x y Derivestar_P_A_x_y_nil_nil. (* Goal: Derivestar R x y *) elimtype (exists s2 : Word, Derivestar_P_A_3 (nil, (x, y)) (s2, (nil, nil))). (* Goal: forall (x0 : Word) (_ : Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) x0 (@pair Word Word nil nil))), Derivestar R x y *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) intros s2 Derivestar_P_A_3_x_y. (* Goal: Derivestar R x y *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) apply Derivegstar_Derivestar with X. (* Goal: Derivegstar X R x y *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) replace x with (Append nil x). (* Goal: Derivegstar X R (Append nil x) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) replace y with (Append s2 nil). (* Goal: Derivegstar X R (Append nil x) (Append s2 nil) *) (* Goal: @eq Word (Append s2 nil) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) apply Derivestar_P_A_3_imp_Derivegstar with y nil. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) trivial. (* Goal: @eq Word (Append s2 nil) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) replace y with (Append nil y). (* Goal: @eq Word (Append s2 nil) (Append nil y) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) apply sym_equal. (* Goal: @eq Word (Append nil y) (Append s2 nil) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) apply Derisvestar_P_A_3_conserve with x nil. (* Goal: Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil)) *) (* Goal: @eq Word (Append nil y) y *) (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) assumption. (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) trivial. (* Goal: @eq Word (Append nil x) x *) (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) trivial. (* Goal: @ex Word (fun s2 : Word => Derivestar_P_A_3 (@pair Word (prod Word Word) nil (@pair Word Word x y)) (@pair Word (prod Word Word) s2 (@pair Word Word nil nil))) *) apply Derivestar_P_A_2_imp_Derivestar_P_A_3. (* Goal: and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) auto. Qed. Hint Resolve Derivestar_P_A_imp_Derivestar. (******************************************) (*equivalence de G et de l'automate a pile*) (******************************************) Theorem equiv_APD_Gram : l_egal (LA X wd wa d) (LG X V R S'). (* Goal: l_egal (LA X wd wa d) (LG X V R S') *) red in |- *. (* Goal: and (l_inclus (LA X wd wa d) (LG X V R S')) (l_inclus (LG X V R S') (LA X wd wa d)) *) unfold l_inclus, LA, LG in |- *. (* Goal: and (forall (w : Word) (_ : and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w)), and (Derivestar R (cons S' nil) w) (inmonoid X w)) (forall (w : Word) (_ : and (Derivestar R (cons S' nil) w) (inmonoid X w)), and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w)) *) split. (* Goal: forall (w : Word) (_ : and (Derivestar R (cons S' nil) w) (inmonoid X w)), and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) intros w temp; elim temp; intros Der inmon. (* Goal: and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) auto. (* Goal: forall (w : Word) (_ : and (Derivestar R (cons S' nil) w) (inmonoid X w)), and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) intros w temp; elim temp; intros Der inmon. (* Goal: and (Derivestar_P_A X d (@pair Word Word wd w) (@pair Word Word wa nil)) (inmonoid X w) *) auto. Qed. End APD.
From mathcomp Require Import all_ssreflect all_algebra all_field. Set Implicit Arguments. Unset Strict Implicit. Unset Printing Implicit Defensive. Import GRing.Theory Num.Theory UnityRootTheory. Open Scope ring_scope. (** Starting from cyril exercise *) Section PreliminaryLemmas. (** * Preliminaries Let's extend the library on rings and algebraic numbers with some easy lemmas first. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) ** Question -2: prove that if a product of natural numbers is 1 then each factor is 1. Note that we do not consider nat but the copy of nat which is embeded in the algebraic numbers algC. The theorem already exists for nat, and we suggest you use a compatibility lemma numbers between nat and Cnat *) Lemma Cnat_mul_eq1 : {in Cnat &, forall x y, (x * y == 1) = (x == 1) && (y == 1)}. Proof. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by move=> x y /CnatP [n ->] /CnatP [m ->]; rewrite -natrM !pnatr_eq1 muln_eq1. Qed. Lemma Cnat_add_eq1 : {in Cnat &, forall x y, (x + y == 1) = ((x == 1) && (y == 0)) || ((x == 0) && (y == 1))}. Proof. (* Goal: forall _ : is_true (coprimeGI z x), is_true (eqGI (gcdGI z (@GRing.mul GI_ringType x y)) (gcdGI z y)) *) move=> x y /CnatP [n ->] /CnatP [m ->]; rewrite -natrD !pnatr_eq1 ?pnatr_eq0. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by move: n m => [|[|?]] [|[|?]]. Qed. (** (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) ** Question -1: The real part of product *) Lemma algReM (x y : algC) : (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) 'Re (x * y) = 'Re x * 'Re y - 'Im x * 'Im y. Proof. rewrite {1}[x]algCrect {1}[y]algCrect mulC_rect Re_rect //; by rewrite rpredD ?rpredN // rpredM // ?Creal_Re ?Creal_Im. Qed. (** ** Question 0: The imaginary part of product *) Lemma algImM (x y : algC) : 'Im (x * y) = 'Re x * 'Im y + 'Re y * 'Im x. Proof. rewrite {1}[x]algCrect {1}[y]algCrect mulC_rect Im_rect //; by rewrite rpredD ?rpredN // rpredM // ?Creal_Re ?Creal_Im. Qed. Lemma algReV (x : algC) : (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) 'Re (x^-1) = 'Re x / `|x| ^+ 2. Proof. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have [|/mulfV H] := boolP (x^* == 0). (* Goal: forall (_ : @eq bool (@in_mem GI a (@mem GI (seq_predType eqGIType) (@cons GI a l))) (andb (primeGI a) (andb (negb (@eq_op eqGIType (@GRing.exp GI_ringType p (S k)) (GRing.zero GI_zmodType))) (dvdGI a (@GRing.exp GI_ringType p (S k)))))) (_ : is_true (@in_mem GI p (@mem GI (seq_predType eqGIType) (@cons GI a l)))), is_true (eqGI a p) *) rewrite conjC_eq0 => /eqP->. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite invr0 normr0 (Creal_ReP _ _) ?mul0r. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite -{1}[_ ^-1]mul1r -H -mulrA -invfM. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite {1}[x]algCrect conjC_rect ?Creal_Re ?Creal_Im //. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have F : (x^* * x)^-1 \is Creal. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite rpredV CrealE rmorphM conjCK mulrC. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite mulrBl -mulrN -['i * _ * _]mulrA Re_rect ?normCKC //. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite rpredM ?Creal_Re. by rewrite mulrN rpredN rpredM // Creal_Im. Qed. Lemma algImV (x : algC) : (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) 'Im (x^-1) = - ('Im x / `|x| ^+ 2). Proof. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have [|/mulfV H] := boolP (x^* == 0). (* Goal: forall (_ : @eq bool (@in_mem GI a (@mem GI (seq_predType eqGIType) (@cons GI a l))) (andb (primeGI a) (andb (negb (@eq_op eqGIType (@GRing.exp GI_ringType p (S k)) (GRing.zero GI_zmodType))) (dvdGI a (@GRing.exp GI_ringType p (S k)))))) (_ : is_true (@in_mem GI p (@mem GI (seq_predType eqGIType) (@cons GI a l)))), is_true (eqGI a p) *) rewrite conjC_eq0 => /eqP->. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite invr0 normr0 (Creal_ImP _ _) ?mul0r ?oppr0. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite -{1}[_ ^-1]mul1r -H -mulrA -invfM. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite {1}[x]algCrect conjC_rect ?Creal_Re ?Creal_Im //. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have F : (x^* * x)^-1 \is Creal. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite rpredV CrealE rmorphM conjCK mulrC. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite mulrBl -mulrN -['i * _ * _]mulrA Im_rect ?normCKC //. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) - by rewrite mulrN. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) - by rewrite rpredM ?Creal_Re. by rewrite mulrN rpredN rpredM // Creal_Im. Qed. Lemma algRe_div (x y : algC) : 'Re (x/y) = ('Re x * 'Re y + 'Im x * 'Im y) / `|y| ^+ 2. Proof. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite algReM algReV algImV mulrN opprK mulrA ['Im x * _]mulrA mulrDl. Qed. Lemma algIm_div (x y : algC) : (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) 'Im (x/y) = ('Re y * 'Im x - 'Re x * 'Im y) / `|y| ^+ 2. Proof. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite algImM algReV algImV addrC mulrN mulrA ['Re x * _]mulrA mulrBl. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite mulrAC. Qed. Definition cdivz (x y : int) : int := (let q := (x %/ y) in if (y == 0) || (2%:R * (x %% y)%Z <= `|y|) then (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) q else q + (-1) ^+ (y < 0)%R)%Z. Infix "%c/" := cdivz (at level 40) : int_scope. Lemma cdivz0 x : (x %c/ 0)%Z = 0. Proof. by rewrite /cdivz eqxx divz0. Qed. Lemma cdiv0z y : (0 %c/ y)%Z = 0. Proof. by rewrite /cdivz div0z mod0z mulr0 normr_ge0 orbT. Qed. Lemma cdivz1 x : (x %c/ 1)%Z = x. Proof. by rewrite /cdivz oner_eq0 divz1 modz1 normr1 mulr0. Qed. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) Lemma cdivzz x : x != 0 -> (x %c/ x)%Z = 1. Proof. (* Goal: forall (_ : is_true (negb (@eq_op (GRing.Zmodule.eqType (GRing.Ring.zmodType GI_ringType)) y (GRing.zero (GRing.Ring.zmodType GI_ringType))))) (_ : is_true (negb (@eq_op (GRing.Zmodule.eqType (GRing.Ring.zmodType GI_ringType)) z (GRing.zero (GRing.Ring.zmodType GI_ringType))))), @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) move=> xNz. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite /cdivz (negPf xNz) divzz xNz modzz mulr0. Qed. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) Definition cmodz (x y : int) : int := x - (x %c/ y)%Z * y. Infix "%c%" := cmodz (at level 40) : int_scope. Lemma cdivz_eq (x y : int) : x = (x %c/ y)%Z * y + (x %c% y)%Z. Proof. by rewrite /cmodz addrC subrK. Qed. Lemma cmodz0 x : (x %c% 0)%Z = x. Proof. by rewrite {2}(cdivz_eq x 0) mulr0 add0r. Qed. Lemma cmod0z y : (0 %c% y)%Z = 0. Proof. by rewrite {2}(cdivz_eq 0 y) cdiv0z mul0r add0r. Qed. Lemma cmodz1 x : (x %c% 1)%Z = 0. Proof. by rewrite /cmodz cdivz1 mulr1 subrr. Qed. Lemma cmodzz x : (x %c% x)%Z = 0. Proof. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) have [/eqP->|xNz] := boolP (x == 0); first by rewrite cmod0z. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite /cmodz cdivzz // mul1r subrr. Qed. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) Lemma cmodz_lt (x y : int) : y != 0 -> (2%:R * `|x %c% y| <= `|y|)%Z. Proof. (* Goal: forall _ : is_true (coprimeGI z x), is_true (eqGI (gcdGI z (@GRing.mul GI_ringType x y)) (gcdGI z y)) *) move=> yNz; rewrite /cmodz /cdivz (negPf yNz) /=. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have [mLe|eLm] := boolP (2%:R * (_ %% _)%Z <= `|_|). rewrite {1}(divz_eq x y) [_ * _ + _]addrC addrK. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite [`|(_ %% _)%Z|]ger0_norm // modz_ge0. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite mulrDl opprD addrA {1}(divz_eq x y) [_ * _ + _]addrC addrK. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have F := ltz_mod x yNz. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite -normrEsign ler0_norm; last first. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite subr_le0; apply: ltrW. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite mulrN mulrBr opprB lter_sub_addl (_ : 2%:R = 1 + 1) //. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite mulrDl mul1r ler_add // ltrW // ltrNge. Qed. End PreliminaryLemmas. (** (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) ---- * The ring of Gauss integers (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) - Ref: exercices de mathematiques oraux X-ENS algebre 1 (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) - Exercice 3.10. ENS Lyon *) Section GaussIntegers. (** First we define a predicate for the algebraic numbers which are gauss integers. *) Definition gaussInteger := [qualify a x | ('Re x \in Cint) && ('Im x \in Cint)]. (** ** Question 1: Prove that integers are gauss integers *) (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) Lemma Cint_GI (x : algC) : x \in Cint -> x \is a gaussInteger. Proof. (* Goal: forall _ : is_true (coprimeGI z x), is_true (eqGI (gcdGI z (@GRing.mul GI_ringType x y)) (gcdGI z y)) *) move=> x_int; rewrite qualifE (Creal_ReP _ _) ?(Creal_ImP _ _) ?Creal_Cint //. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite x_int rpred0. Qed. (** ** Question 2: Prove that gauss integers form a subfield *) Lemma GI_subring : subring_closed gaussInteger. Proof. (* Goal: forall (_ : @eq bool (@in_mem GI a (@mem GI (seq_predType eqGIType) (@cons GI a l))) (andb (primeGI a) (andb (negb (@eq_op eqGIType (@GRing.exp GI_ringType p (S k)) (GRing.zero GI_zmodType))) (dvdGI a (@GRing.exp GI_ringType p (S k)))))) (_ : is_true (@in_mem GI p (@mem GI (seq_predType eqGIType) (@cons GI a l)))), is_true (eqGI a p) *) split => [|x y /andP[??] /andP[??]|x y /andP[??] /andP[??]]. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) - by rewrite Cint_GI. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) - by rewrite qualifE !raddfB /= ?rpredB. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite qualifE algReM algImM rpredB ?rpredD // rpredM. Qed. (** There follows the boilerplate to use the proof GI_subring in order to canonically provide a subring structure to the predicate gaussInteger. *) Fact GI_key : pred_key gaussInteger. Proof. by []. Qed. Canonical GI_keyed := KeyedQualifier GI_key. Canonical GI_opprPred := OpprPred GI_subring. Canonical GI_addrPred := AddrPred GI_subring. Canonical GI_mulrPred := MulrPred GI_subring. Canonical GI_zmodPred := ZmodPred GI_subring. Canonical GI_semiringPred := SemiringPred GI_subring. Canonical GI_smulrPred := SmulrPred GI_subring. Canonical GI_subringPred := SubringPred GI_subring. (** Finally, we define the type of Gauss Integer, as a sigma type of algebraic numbers. We soon prove that this is in fact a sub type. *) Record GI := GIof { algGI : algC; algGIP : algGI \is a gaussInteger }. (** We make the defining property of GI a Hint *) Hint Resolve algGIP. (** We provide the subtype property. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) - This makes it possible to use the generic operator "val" to get an algC from a Gauss Integer. *) Canonical GI_subType := [subType for algGI]. (** We deduce that the real and imaginary parts of a GI are integers *) Lemma GIRe (x : GI) : 'Re (val x) \in Cint. Proof. by have /andP [] := algGIP x. Qed. Lemma GIIm (x : GI) : 'Im (val x) \in Cint. Proof. by have /andP [] := algGIP x. Qed. Hint Resolve GIRe GIIm. Canonical ReGI x := GIof (Cint_GI (GIRe x)). Canonical ImGI x := GIof (Cint_GI (GIIm x)). (** We provide a ring structure to the type GI, using the subring canonical property for the predicate gaussInteger *) Definition eqGIMixin := [eqMixin of GI by <:]. Canonical eqGIType := EqType GI eqGIMixin. Definition GI_choiceMixin := [choiceMixin of GI by <:]. Canonical GI_choiceType := ChoiceType GI GI_choiceMixin. Definition GI_countMixin := [countMixin of GI by <:]. Canonical GI_countType := CountType GI GI_countMixin. Definition GI_zmodMixin := [zmodMixin of GI by <:]. Canonical GI_zmodType := ZmodType GI GI_zmodMixin. Definition GI_ringMixin := [ringMixin of GI by <:]. Canonical GI_ringType := RingType GI GI_ringMixin. Definition GI_comRingMixin := [comRingMixin of GI by <:]. Canonical GI_comRingType := ComRingType GI GI_comRingMixin. (* Definition GI_unitRingMixin := [unitRingMixin of GI by <:]. *) (* Canonical GI_unitRingType := UnitRingType GI GI_unitRingMixin. *) (** (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) - Now we build the unitRing and comUnitRing structure of gauss integers. Contrarily to the previous structures, the operator is not the same as on algebraics. Indeed the invertible algebraics are not necessarily invertible gauss integers. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) - Hence, we define the inverse of gauss integers as follow : if the algebraic inverse happens to be a gauss integer we recover the proof and package it together with the element and get a gauss integer, otherwise, we default to the identity. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) - A gauss integer is invertible if the algbraic inverse is a gauss integer. *) (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) Definition invGI (x : GI) := insubd x (val x)^-1. Definition unitGI (x : GI) := (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) (x != 0) && ((val x)^-1 \is a gaussInteger). (** ** Question 3: prove a few facts in order to find a comUnitRingMixin for GI, and then instantiate the interfaces of unitRingType and comUnitRingType. *) Fact mulGIr : {in unitGI, left_inverse 1 invGI *%R}. Proof. (* Goal: forall _ : is_true (coprimeGI z x), is_true (eqGI (gcdGI z (@GRing.mul GI_ringType x y)) (gcdGI z y)) *) move=> x /andP [x_neq0 xVGI]; rewrite /invGI. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by apply: val_inj; rewrite /= insubdK // mulVr ?unitfE. Qed. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) Fact unitGIP (x y : GI) : y * x = 1 -> unitGI x. Proof. (* Goal: forall (_ : @eq bool (@in_mem GI a (@mem GI (seq_predType eqGIType) (@cons GI a l))) (andb (primeGI a) (andb (negb (@eq_op eqGIType (@GRing.exp GI_ringType p (S k)) (GRing.zero GI_zmodType))) (dvdGI a (@GRing.exp GI_ringType p (S k)))))) (_ : is_true (@in_mem GI p (@mem GI (seq_predType eqGIType) (@cons GI a l)))), is_true (eqGI a p) *) rewrite /unitGI => /(congr1 val) /=. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) have [-> /eqP|x_neq0] := altP (x =P 0); first by rewrite mulr0 eq_sym oner_eq0. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by move=> /(canRL (mulfK x_neq0)); rewrite mul1r => <- /=. Qed. Fact unitGI_out : {in [predC unitGI], invGI =1 id}. Proof. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) move=> x; rewrite inE /= -topredE /= /unitGI. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite negb_and negbK => /predU1P [->|/negPf xGIF]; by apply: val_inj; rewrite /invGI ?val_insubd /= ?xGIF // invr0 if_same. Qed. Definition GI_comUnitRingMixin := ComUnitRingMixin mulGIr unitGIP unitGI_out. Canonical GI_unitRingType := UnitRingType GI GI_comUnitRingMixin. Canonical GI_comUnitRingType := [comUnitRingType of GI]. (** ** Question 4: Show that gauss integers are stable by conjugation. *) Lemma conjGIE x : (x^* \is a gaussInteger) = (x \is a gaussInteger). Proof. by rewrite ![_ \is a _]qualifE Re_conj Im_conj rpredN. Qed. (** We use this fact to build the conjugation of a gauss Integers *) Fact conjGI_subproof (x : GI) : (val x)^* \is a gaussInteger. Proof. by rewrite conjGIE. Qed. Canonical conjGI x := GIof (conjGI_subproof x). (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) Fact conjGI_sub : {morph conjGI : a b / a - b}. Proof. by move=> a b; apply/val_eqP; rewrite /= raddfB. Qed. Canonical conjGI_additive := Additive conjGI_sub. Fact conjGI_multiplicative : multiplicative conjGI. Proof. by split=> [a b|]; apply/val_eqP; rewrite /= ?(rmorphM,rmorph1). Qed. Canonical conjGI_rmorphism := AddRMorphism conjGI_multiplicative. Lemma algGI_nat n : algGI n%:R = n%:R. Proof. by elim: n => //= n IH; rewrite -addn1 !natrD -IH. Qed. Lemma conjGI_nat n : conjGI n%:R = n%:R. Proof. by apply/val_eqP; rewrite /= algGI_nat conjC_nat. Qed. Lemma conjGIK : involutive conjGI. Proof. by move=> x; apply/val_eqP/eqP; exact: conjCK. Qed. (** We now define the norm (stasm) for gauss integer, we don't need to specialize it to gauss integer so we define it over algebraic numbers instead. *) Definition gaussNorm (x : algC) := x * x^*. (** ** Question 4: Show that the gaussNorm of x is the square of the complex modulus of x *) Lemma gaussNormE x : gaussNorm x = `|x| ^+ 2. Proof. by rewrite normCK. Qed. (** ** Question 5: Show that the gaussNorm of an gauss integer is a natural number. *) Lemma gaussNormCnat (x : GI) : gaussNorm (val x) \in Cnat. Proof. by rewrite /gaussNorm -normCK normC2_Re_Im rpredD // Cnat_exp_even. Qed. Hint Resolve gaussNormCnat. Delimit Scope GI_scope with GI. Open Scope GI_scope. Definition normGI (x : GI) := truncC (gaussNorm (val x)). Local Notation "'N x" := (normGI x%R) (at level 10) : GI_scope. (** ** Question 6: Show that gaussNorm is multiplicative (on all algC). *) Lemma gaussNorm0 : gaussNorm 0 = 0. Proof. by rewrite /gaussNorm mul0r. Qed. Lemma normGI0 : 'N 0 = 0%N. Proof. by rewrite /normGI gaussNorm0 (natCK 0). Qed. Lemma gaussNorm1 : gaussNorm 1 = 1. Proof. by rewrite /gaussNorm rmorph1 mulr1. Qed. Lemma normGI1 : 'N 1 = 1%N. Proof. by rewrite /normGI gaussNorm1 (natCK 1). Qed. Lemma gaussNormM : {morph gaussNorm : x y / x * y}. Proof. by move=> x y; rewrite /gaussNorm rmorphM mulrACA. Qed. Lemma normGIM x y : 'N (x * y) = ('N x * 'N y)%N. Proof. by rewrite /normGI gaussNormM truncCM. Qed. Lemma normGIX x n : 'N (x ^+ n) = ('N x ^ n)%N. Proof. (* Goal: is_true (eqGI a p) *) (* Goal: is_true (eqGI a p) *) elim: n => [|n IH]. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite expr0 normGI1 expn0. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite exprS normGIM IH expnS. Qed. Lemma gaussNorm_eq0 (x : GI) : (gaussNorm (algGI x) == 0) = (x == 0). Proof. by rewrite gaussNormE sqrf_eq0 normr_eq0. Qed. Lemma normGI_eq0 (x : GI) : ('N x == 0%N) = (x == 0). Proof. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) have /charf0P<- := Cchar. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite truncCK // gaussNorm_eq0. Qed. Lemma normGI_gt0 (x : GI) : ('N x > 0)%N = (x != 0). Proof. by rewrite ltn_neqAle andbT eq_sym normGI_eq0. Qed. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) Lemma normGI_le (x y : GI) : y != 0 -> ('N x <= 'N (x * y))%N. Proof. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite -!normGI_eq0 normGIM; case: ('N _) => // n _. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite leq_pmulr. Qed. Lemma normGI_nat n : 'N n%:R = (n ^ 2)%N. Proof. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite /normGI [val _]algGI_nat gaussNormE normr_nat truncCX // natCK. Qed. Lemma normGIE (x : GI) : ('N(x) = truncC (`|'Re (val x)|) ^ 2 + truncC (`|'Im (val x)|) ^ 2)%N. Proof. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) rewrite /normGI gaussNormE normC2_Re_Im truncCD ?Cnat_exp_even //; last first. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite qualifE Cnat_ge0 // Cnat_exp_even. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite -!truncCX ?Cnat_norm_Cint // !Cint_normK. Qed. Lemma truncC_Cint (x : algC) : (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) x \in Cint -> x = (-1) ^+ (x < 0)%R * (truncC `|x|)%:R. Proof. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by move=> xCint; rewrite {1}[x]CintEsign // truncCK // Cnat_norm_Cint. Qed. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) Lemma normGI_eq1 (x : GI) : ('N(x) == 1)%N = (val x \in [::1;-1;'i;-'i]). Proof. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) apply/idP/idP; last first. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite normGIE !inE => /or4P[] /eqP->; rewrite ?raddfN /= ?(Creal_ReP 1 _) ?(Creal_ImP 1 _) ?Re_i ?Im_i //= ?normrN ?normr1 ?normr0 ?truncC0 ?truncC1. rewrite [val x]algCrect normGIE. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) have /andP[/truncC_Cint {2}-> /truncC_Cint {2}->] := algGIP x. by case: truncC => [|[|m]] //; case: truncC => [|[|n]] // _; rewrite !(mulr1, mulr0, add0r, addr0); case: (_ < _)%R; rewrite ?(expr1, expr0, mulrN, mulr1, inE, eqxx, orbT). Qed. (** ** Question 7: Find the invertible elements of GI (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) - This is question 1 of the CPGE exercice (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) - Suggested strategy: sketch the proof on a paper first, don't let Coq divert you from your proofsketch *) Lemma unitGIE (x : GI) : (x \in GRing.unit) = (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) (val x \in 4.-unity_root). Proof. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have eq_algC (a b : algC) : (a == b) = ('Re a == 'Re b) && ('Im a == 'Im b). (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite {1}[a]algCrect {1}[b]algCrect -subr_eq0 opprD addrACA -mulrBr. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite -normr_eq0 -sqrf_eq0 normC2_rect ?rpredB ?Creal_Re ?Creal_Im //. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite paddr_eq0 ?real_exprn_even_ge0 // ?rpredB ?Creal_Re ?Creal_Im //. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite !expf_eq0 /= !subr_eq0. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) have N1Creal : -1 \is Creal by rewrite rpredN. have oneE : 1 = 1 + 'i * 0 :> algC by rewrite mulr0 addr0. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) have N1E : - 1 = - 1 + 'i * 0 :> algC by rewrite mulr0 addr0. have iE : 'i = 0 + 'i * 1 :> algC by rewrite mulr1 add0r. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) have NiE : - 'i = 0 + 'i * (- 1) :> algC by rewrite mulrN1 add0r. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) have onerN1 : (1 == -1 :> algC) = false. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite -subr_eq0 opprK paddr_eq0 ?oner_eq0 ?ler01. pose my := @id algC. transitivity (gaussNorm (val x) == 1). (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) apply/idP/eqP; last first. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by move=> gNx; apply/unitrPr; exists (conjGI x); apply: val_inj. (* Goal: forall (_ : is_true (negb (@eq_op (GRing.Zmodule.eqType GI_zmodType) y (GRing.zero GI_zmodType)))) (_ : is_true (dvdGI x y)), is_true (leq (normGI x) (normGI y)) *) move=> x_unit; have /(congr1 (gaussNorm \o val)) /= /eqP := mulrV x_unit. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite gaussNormM gaussNorm1 Cnat_mul_eq1 //= => /andP [/eqP]. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite (@mem_unity_roots _ 4 (map my [:: 1; -1; 'i; -'i])) //; last 2 first. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) - rewrite /= !unity_rootE /= [(- 'i) ^+ _]exprNn expr1n -signr_odd ?expr0. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite -[4]/(2 * 2)%N exprM sqrCi -signr_odd ?expr0 mulr1 !eqxx. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) - rewrite /= ![my _](iE, oneE, N1E, NiE). (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite /= !in_cons !in_nil /= !negb_or -!andbA !andbT /=. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite ![_ + 'i * _ == _]eq_algC ?Re_rect ?Im_rect //. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite ![_ == -1]eq_sym ![_ == 1]eq_sym oppr_eq0. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite eqxx onerN1 oner_eq0. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite gaussNormE [val x]algCrect normC2_rect ?Creal_Re ?Creal_Im //. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite Cnat_add_eq1 ?Cnat_exp_even ?expf_eq0 //=. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite -Cint_normK // -['Im _ ^+ 2]Cint_normK //. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite !expr2 !Cnat_mul_eq1 ?andbb ?Cnat_norm_Cint //. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite !real_eqr_norml ?Creal_Re ?Creal_Im ?ler01 ?andbT //=. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite !inE ![my _](iE, oneE, N1E, NiE). rewrite ![_ + 'i * _ == _]eq_algC ?Re_rect ?Im_rect // ?Creal_Re ?Creal_Im //. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite andb_orl andb_orr -orbA. Qed. Lemma algC_eqE (x y : algC) : (x == y) = (('Re x == 'Re y) && ('Im x == 'Im y)). Proof. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) apply/eqP/andP=> [->//|[/eqP H1 /eqP H2]]. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite [x]algCrect H1 H2 -algCrect. Qed. Lemma normGI_unit (x : GI) : ('N(x) == 1)%N = (x \in GRing.unit). Proof. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite normGI_eq1 unitGIE. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite (@mem_unity_roots _ 4 (map id [:: 1; -1; 'i; -'i])) //. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite /= !unity_rootE /= [(- 'i) ^+ _]exprNn expr1n -signr_odd ?expr0. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite -[4]/(2 * 2)%N exprM sqrCi -signr_odd ?expr0 mulr1 !eqxx. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite /= !in_cons !in_nil /= !negb_or -!andbA !andbT /= eqr_opp. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite -addr_eq0 (eqC_nat 2 0) andTb. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite algC_eqE (Creal_ImP _ _) // Im_i (eqC_nat 0 1) andbF andTb. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite algC_eqE raddfN (Creal_ReP _ _) //= Re_i oppr0 (eqC_nat 1 0) andFb andTb. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite algC_eqE !raddfN /= (Creal_ImP _ _) // Im_i oppr0 (eqC_nat 0 1) andbF andTb. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite -addr_eq0 (@mulrn_eq0 _ 'i 2) negb_or neq0Ci. Qed. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) Fact GI_idomainAxiom (x y : GI) : x * y = 0 -> (x == 0) || (y == 0). Proof. (* Goal: forall (_ : is_true (negb (@eq_op (GRing.Zmodule.eqType (GRing.Ring.zmodType GI_ringType)) y (GRing.zero (GRing.Ring.zmodType GI_ringType))))) (_ : is_true (negb (@eq_op (GRing.Zmodule.eqType (GRing.Ring.zmodType GI_ringType)) z (GRing.zero (GRing.Ring.zmodType GI_ringType))))), @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) move=> /(congr1 (gaussNorm \o val)) /= /eqP. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite gaussNorm0 gaussNormM mulf_eq0 !gaussNorm_eq0. Qed. Canonical GI_idomainType := Eval hnf in IdomainType GI GI_idomainAxiom. Fact divGI_subproof (x y : int) : x%:~R + 'i * y%:~R \is a gaussInteger. Proof. by rewrite qualifE /= Re_rect ?Im_rect ?Creal_Cint ?Cint_int. Qed. Definition divGI (x y : GI) : GI := let zr := floorC ('Re (val x) * 'Re (val y) + 'Im (val x) * 'Im (val y)) in (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) let zi := floorC ('Re (val y) * 'Im (val x) - 'Re (val x) * 'Im (val y)) in let n := 'N y in GIof (divGI_subproof (cdivz zr n) (cdivz zi n)). Notation " x %/ y " := (divGI x y) : GI_scope. Lemma divGI0 x : x %/ 0 = 0. Proof. (* Goal: @eq bool (eqGI (gcdGI p x) (GRing.one GI_ringType)) false *) apply/val_eqP=> /=. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite !raddf0 !(mul0r, mulr0, subrr, add0r, floorC0, normGI0, cdiv0z). Qed. Lemma div0GI y : 0 %/ y = 0. Proof. (* Goal: @eq bool (eqGI (gcdGI p x) (GRing.one GI_ringType)) false *) apply/val_eqP=> /=. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite !raddf0 !(mul0r, mulr0, subrr, add0r, floorC0, normGI0, cdiv0z). Qed. Lemma divGI1 x : x %/ 1 = x. Proof. (* Goal: @eq bool (eqGI (gcdGI p x) (GRing.one GI_ringType)) false *) apply/val_eqP=> /=. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have /andP[CR CI] := algGIP x. rewrite normGI1 !cdivz1 (Creal_ReP 1 _) ?(Creal_ImP 1 _) // !(mul1r, mulr1, mulr0, mul0r, addr0, add0r, subr0). (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite 2?floorCK ?Creal_Cint // -algCrect. Qed. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) Lemma divGIxx (x : GI) : x != 0 -> x %/ x = 1. Proof. move=> xNz; apply/val_eqP => /=. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite subrr floorC0 cdiv0z mulr0 addr0. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have := xNz. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite -normGI_eq0. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite /normGI gaussNormE [val x]algCrect normC2_rect ?(Creal_Cint, Cint_int) //. (* Goal: forall (_ : @eq bool (@in_mem GI a (@mem GI (seq_predType eqGIType) (@cons GI a l))) (andb (primeGI a) (andb (negb (@eq_op eqGIType (@GRing.exp GI_ringType p (S k)) (GRing.zero GI_zmodType))) (dvdGI a (@GRing.exp GI_ringType p (S k)))))) (_ : is_true (@in_mem GI p (@mem GI (seq_predType eqGIType) (@cons GI a l)))), is_true (eqGI a p) *) set u :=_ + _ * _ => uNz. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) have->: floorC u = truncC u. (* Goal: @eq bool (eqGI (gcdGI p x) (GRing.one GI_ringType)) false *) apply: floorC_def. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite [(_+ 1)%Z]addrC -intS truncC_itv //. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite addr_ge0 // -expr2 real_exprn_even_ge0 ?(Creal_Cint, Cint_int) //. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite cdivzz ?mul1r ?subrr. Qed. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) Definition modGI (x y : GI) : GI := x - (x %/ y)%GI * y. Notation " x %% y " := (modGI x y) : GI_scope. Lemma modGI0 x : x %% 0 = x. Proof. by apply/val_eqP; rewrite /= !raddf0 !mulr0 subr0. Qed. Lemma mod0GI y : 0 %% y = 0. Proof. (* Goal: @eq bool (eqGI (gcdGI p x) (GRing.one GI_ringType)) false *) apply/val_eqP. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite /= !(raddf0, mul0r, mulr0, add0r, floorC0, cdiv0z). Qed. Lemma modGI1 x : x %% 1 = 0. Proof. by rewrite /modGI divGI1 mulr1 subrr. Qed. Lemma divGI_eq (x y : GI) : x = (x %/ y)%GI * y + (x %% y)%GI. Proof. by rewrite /modGI addrC subrK. Qed. Lemma ltn_modGI(x y : GI) : ('N (x %% y)%GI < 'N y)%N = (y != 0). Proof. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) have [/eqP->|yNz] := boolP (y == 0). (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite normGI0 modGI0. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) have /ltn_pmul2r<-: (0 < 'N(y) ^ 2)%N by rewrite sqrn_gt0 lt0n normGI_eq0. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite -{1}normGI_nat -!normGIM /modGI /divGI. set Ux := floorC _. set Uy := floorC _. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have UxRe : Ux%:~R = 'Re (algGI x / algGI y * ('N y)%:R). (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite algReM ['Re _%:R](Creal_ReP _ _) ?qualifE ?ler0n //. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite ?['Im _%:R](Creal_ImP _ _) ?qualifE ?ler0n // mulr0 subr0. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite /normGI truncCK // algRe_div -gaussNormE divfK; last first. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite gaussNorm_eq0. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite floorCK // rpredD // rpredM. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have UyIm : Uy%:~R = 'Im (algGI x / algGI y * ('N(y))%GI%:R). (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite algImM ['Re _%:R](Creal_ReP _ _) ?qualifE ?ler0n //. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite ?['Im _%:R](Creal_ImP _ _) ?qualifE ?ler0n // mulr0 add0r mulrC. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite /normGI truncCK // algIm_div -gaussNormE divfK; last first. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite gaussNorm_eq0. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite floorCK // rpredB // rpredM. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite ['N (_ * _)]/normGI /= -[algGI x](divfK yNz). (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite -mulrBl -mulrA -[algGI y * _]mulrC mulrA algGI_nat mulrBl. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite [_ * _%:R]algCrect -UxRe -UyIm [_ * _%:R]mulrDl -['i * _ * _]mulrA. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite {1}(cdivz_eq Ux ('N y)) {1}(cdivz_eq Uy ('N y)). (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite subC_rect ![_ + cmodz _ _]addrC. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite rmorphD /= rmorphM /= addrK. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite [(_ + _)%:~R]rmorphD /= rmorphM /= addrK. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite !gaussNormM gaussNormE normC2_rect ?(Creal_Cint, Cint_int) //. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) rewrite truncCM //; last by rewrite rpredD // Cnat_exp_even // Cint_int. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) rewrite mulnC ltn_pmul2l; last by rewrite lt0n normGI_eq0. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite -!rmorphX /= -!rmorphD /=. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite -[_ + _]gez0_abs ?natCK; last first. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite addr_ge0 // exprn_even_ge0. set x1 := _ ^+ 2; set x2 := _ ^+ 2. (* Goal: @eq bool (eqGI (gcdGI p x) (GRing.one GI_ringType)) false *) apply: leq_ltn_trans (_ : (`|x1| + `|x2| < _)%N). (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) have := leq_add_dist (x1) (x1 - x2) (-x2). (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite !opprK subrK opprB [_ + (_ - _)]addrC subrK [(`|_| + _)%N]addnC. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite -(ltn_pmul2l (isT: (0 < 2 ^ 2)%N)) mulnDr. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) apply: leq_ltn_trans (_ : 2 * 'N y ^ 2 < _)%N; last first. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite ltn_mul2r sqrn_gt0 lt0n normGI_eq0 yNz. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have F : Posz ('N y) != 0. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite eqz_nat normGI_eq0. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite mul2n -addnn leq_add // !abszX -!expnMn leq_exp2r // (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) -(@ler_nat [numDomainType of int]) natrM !natz /= cmodz_lt. Qed. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) Lemma ltn_modGIN0 x y : y != 0 -> ('N (x %% y)%GI < 'N y)%N. Proof. by rewrite ltn_modGI. Qed. Lemma modGIxx x : (x %% x)%GI = 0. Proof. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) have [/eqP->|xNz] := boolP (x == 0); first by rewrite mod0GI. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite /modGI divGIxx // mul1r subrr. Qed. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) Lemma divGIKl (x y : GI) : x != 0 -> (y * x %/ x) = y. Proof. (* Goal: forall (_ : is_true (negb (@eq_op (GRing.Zmodule.eqType (GRing.Ring.zmodType GI_ringType)) y (GRing.zero (GRing.Ring.zmodType GI_ringType))))) (_ : is_true (negb (@eq_op (GRing.Zmodule.eqType (GRing.Ring.zmodType GI_ringType)) z (GRing.zero (GRing.Ring.zmodType GI_ringType))))), @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) move=> xNz. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) apply/eqP; rewrite eq_sym -subr_eq0. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) have := xNz; rewrite -(ltn_modGI (y * x)). (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) have -> : ((y * x) %% x)%GI = (y - ((y * x) %/ x)%GI) * x. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite mulrBl {2}(divGI_eq (y * x) x) [_ + (_ %% _)%GI]addrC addrK. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite normGIM -{2}['N x]mul1n ltn_mul2r ltnS leqn0 normGI_eq0 => /andP[]. Qed. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) Lemma divGIKr (x y : GI) : x != 0 -> (x * y %/ x) = y. Proof. by rewrite mulrC; exact: divGIKl. Qed. Lemma modGIKl (x y : GI) : (y * x %% x) = 0. Proof. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) have [/eqP->|xNz] := boolP (x == 0); first by rewrite modGI0 mulr0. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite /modGI divGIKl // subrr. Qed. Lemma modGIKr (x y : GI) : (x * y %% x) = 0. Proof. by rewrite mulrC modGIKl. Qed. Definition dvdGI x y := (y %% x)%GI == 0. Notation " x %| y " := (dvdGI x y) : GI_scope. Lemma dvdGI0 x : (x %| 0)%GI. Proof. by rewrite /dvdGI mod0GI. Qed. Lemma dvdGIP (x y : GI) : reflect (exists q : GI, y = q * x) (x %| y)%GI. Proof. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) apply: (iffP idP) => [/eqP xDy|[q ->]]. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) exists (y %/ x)%GI; first by rewrite {1}(divGI_eq y x) xDy addr0. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite /dvdGI modGIKl. Qed. Lemma dvd0GI x : (0 %| x) = (x == 0). Proof. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) apply/dvdGIP/eqP => [[q ->]|->]; first by rewrite mulr0. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by exists 0; rewrite mulr0. Qed. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) Lemma dvdGI_mull z x y : (x %| y) -> (x %| z * y). Proof. by move=> /dvdGIP[u ->]; apply/dvdGIP; exists (z * u); exact: mulrA. Qed. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) Lemma dvdGI_mulr z x y : (x %| y) -> (x %| y * z). Proof. by rewrite mulrC; exact: dvdGI_mull. Qed. Lemma dvdGIxx x : x %| x. Proof. by rewrite /dvdGI modGIxx. Qed. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) Lemma dvdGI_norm x y : x %| y -> ('N x %| 'N y)%N. Proof. by move=> /dvdGIP[z ->]; rewrite normGIM dvdn_mull // dvdnn. Qed. Lemma dvd1GI x : (1 %| x) . Proof. by apply/dvdGIP; exists x; rewrite mulr1. Qed. Lemma dvdGI1 x : (x %| 1) = ('N x == 1%N). Proof. (* Goal: @eq bool (eqGI (gcdGI p x) (GRing.one GI_ringType)) false *) apply/idP/idP => [H|]. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by have := dvdGI_norm H; rewrite normGI1 dvdn1. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite normGI_unit => H; apply/dvdGIP; exists x^-1. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by apply/eqP; rewrite mulrC eq_sym -unitrE. Qed. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) Lemma divGIK (x y : GI) : x %| y -> (y %/ x)%GI * x = y. Proof. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) have [/eqP->|nZx /dvdGIP[q ->]] := boolP (x == 0). (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite dvd0GI mulr0 => /eqP->. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite divGIKl. Qed. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) Lemma dvdGI_add x y z: (x %| y) -> (x %| z) -> (x %| y + z). Proof. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) move=> /dvdGIP[q1->] /dvdGIP[q2->]; apply/dvdGIP; exists (q1 + q2). (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite mulrDl. Qed. Lemma dvdGI_nat_dvdz_Re n x : (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) n%:R %| x -> (n %| `|floorC ('Re (algGI x))|)%N. Proof. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) case/dvdGIP=> q /val_eqP/eqP /(congr1 (fun x => Re x)) /=. (* Goal: forall _ : @eq Algebraics.Implementation.type (@Im Algebraics.Implementation.numClosedFieldType ax) (@Im Algebraics.Implementation.numClosedFieldType (@GRing.mul Algebraics.Implementation.ringType (algGI q) (algGI (@GRing.natmul (GRing.Ring.zmodType GI_ringType) (GRing.one GI_ringType) n)))), is_true (dvdn n (absz (floorC (@Im Algebraics.Implementation.numClosedFieldType ax)))) *) case: x => /= ax; rewrite qualifE => /andP[Rx Ix]. (* Goal: forall _ : @eq Algebraics.Implementation.type (@Im Algebraics.Implementation.numClosedFieldType ax) (@Im Algebraics.Implementation.numClosedFieldType (@GRing.mul Algebraics.Implementation.ringType (algGI q) (algGI (@GRing.natmul (GRing.Ring.zmodType GI_ringType) (GRing.one GI_ringType) n)))), is_true (dvdn n (absz (floorC (@Im Algebraics.Implementation.numClosedFieldType ax)))) *) case: q => /= aq; rewrite qualifE => /andP[Rq Iq]. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite [aq]algCrect mulrDl algGI_nat -['i * _ * _]mulrA Re_rect; last 2 first. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite rpredM // Creal_Cint // Cint_Cnat. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite rpredM // Creal_Cint // Cint_Cnat. (* Goal: forall (_ : is_true (negb (@eq_op (GRing.Zmodule.eqType (GRing.Ring.zmodType GI_ringType)) y (GRing.zero (GRing.Ring.zmodType GI_ringType))))) (_ : is_true (negb (@eq_op (GRing.Zmodule.eqType (GRing.Ring.zmodType GI_ringType)) z (GRing.zero (GRing.Ring.zmodType GI_ringType))))), @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) move=> /(congr1 Num.norm) /eqP. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite [`|_* _%:R|]normrM -{1}(floorCK Rx) -{1}(floorCK Rq). (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite normr_nat -!intr_norm -(intrM _ _ (Posz n)) eqr_int. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite -2![`|_|]abszE -PoszM => /eqP[H]. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by apply/dvdnP; exists (`|floorC ('Re aq)|)%N. Qed. Lemma dvdGI_nat_dvdz_Im n x : (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) n%:R %| x -> (n %| `|floorC ('Im (algGI x))|)%N. Proof. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) case/dvdGIP=> q /val_eqP/eqP/(congr1 (fun x => Im x)) /=. (* Goal: forall _ : @eq Algebraics.Implementation.type (@Im Algebraics.Implementation.numClosedFieldType ax) (@Im Algebraics.Implementation.numClosedFieldType (@GRing.mul Algebraics.Implementation.ringType (algGI q) (algGI (@GRing.natmul (GRing.Ring.zmodType GI_ringType) (GRing.one GI_ringType) n)))), is_true (dvdn n (absz (floorC (@Im Algebraics.Implementation.numClosedFieldType ax)))) *) case: x => /= ax; rewrite qualifE => /andP[Rx Ix]. (* Goal: forall _ : @eq Algebraics.Implementation.type (@Im Algebraics.Implementation.numClosedFieldType ax) (@Im Algebraics.Implementation.numClosedFieldType (@GRing.mul Algebraics.Implementation.ringType (algGI q) (algGI (@GRing.natmul (GRing.Ring.zmodType GI_ringType) (GRing.one GI_ringType) n)))), is_true (dvdn n (absz (floorC (@Im Algebraics.Implementation.numClosedFieldType ax)))) *) case: q => /= aq; rewrite qualifE => /andP[Rq Iq]. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite [aq]algCrect mulrDl algGI_nat -['i * _ * _]mulrA Im_rect; last 2 first. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite rpredM // Creal_Cint // Cint_Cnat. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite rpredM // Creal_Cint // Cint_Cnat. (* Goal: forall (_ : is_true (negb (@eq_op (GRing.Zmodule.eqType (GRing.Ring.zmodType GI_ringType)) y (GRing.zero (GRing.Ring.zmodType GI_ringType))))) (_ : is_true (negb (@eq_op (GRing.Zmodule.eqType (GRing.Ring.zmodType GI_ringType)) z (GRing.zero (GRing.Ring.zmodType GI_ringType))))), @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) move=> /(congr1 Num.norm) /eqP. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite [`|_* _%:R|]normrM -{1}(floorCK Ix) -{1}(floorCK Iq). (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite normr_nat -!intr_norm -(intrM _ _ (Posz n)) eqr_int. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite -2![`|_|]abszE -PoszM => /eqP[H]. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by apply/dvdnP; exists (`|floorC ('Im aq)|)%N. Qed. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) Lemma conjGI_dvd x y : x %| y -> (conjGI x) %| (conjGI y). Proof. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) case/dvdGIP=> q ->; apply/dvdGIP; exists (conjGI q). (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite rmorphM. Qed. Fact iGI_proof : 'i \is a gaussInteger. Proof. by rewrite qualifE Re_i Im_i Cint0 Cint1. Qed. Definition iGI := GIof iGI_proof. Lemma dvdGI_norm_even x : ~~ odd ('N x) = ((1 + iGI) %| x). Proof. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) apply/idP/idP => [Ex|/dvdGIP[u ->]]; last first. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite normGIM {2}/normGI gaussNormE normC2_Re_Im. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite !raddfD /= Re_i Im_i (Creal_ReP _ _) // (Creal_ImP _ _) //. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite add0r addr0 expr1n (natCK 2) odd_mul negb_and orbT. (* Goal: @eq bool (eqGI (gcdGI p x) (GRing.one GI_ringType)) false *) apply/dvdGIP. have := algGIP x; rewrite qualifE => / andP[]. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType p n)) n *) (* Goal: is_true (eqGI y (GRing.one GI_ringType)) *) have := Ex; rewrite normGIE odd_add !odd_exp /= negb_add. set m := 'Re _; set n := 'Im _ => /eqP Omn Cm Cn. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) suff FF : (n + m)/2%:R + 'i * ((n - m)/2%:R) \is a gaussInteger. exists (GIof FF); apply/val_eqP => /=. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite -{2}['i]mulr1 mulC_rect !mulr1 mul1r -mulrBl -mulrDl. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite opprB [_ + (m - n)]addrC addrA subrK. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite -addrA [_ + (_ - _)]addrC subrK. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have F u : (u * 2%:R = u + u) by rewrite mulrDr mulr1. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite -!F !mulfK 1?[algGI x]algCrect ?(eqC_nat _ 0). (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) rewrite qualifE Re_rect ?Im_rect; last 4 first. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) - by rewrite !(rpredM, rpredV) 1? rpredD ?Creal_Cint. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) - by rewrite !(rpredM, rpredV) 1? rpredB ?rpredD ?Creal_Cint. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) - by rewrite !(rpredM, rpredV) 1? rpredD ?Creal_Cint. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) - by rewrite !(rpredM, rpredV) 1? rpredB ?rpredD ?Creal_Cint. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite (CintEsign Cm) (CintEsign Cn). (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite -(truncCK (Cnat_norm_Cint Cm)) -(truncCK (Cnat_norm_Cint Cn)). (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite -[truncC `|m|]odd_double_half -[truncC `|n|]odd_double_half. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite Omn !natrD !mulrDr ![(-1) ^+ _]signrE. set u := nat_of_bool _; set v := nat_of_bool _; set w := nat_of_bool _. set x1 := _./2; set y1 := _./2. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have F : 2%:R != 0 :> algC by rewrite (eqC_nat 2 0). apply/andP; split. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite addrAC addrA -mulrDl -addrA. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite addrAC !addrA -[1 + 1](natrD _ 1 1) addnn. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite -!muln2 !natrM !mul1r [_ * v%:R]mulrC. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite ![v%:R * _]mulrBr !mulrA !(mulrBl, mulrDl) !mulfK //. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite !mul1r !(rpredB, rpredD, rpredN, rpredM) // Cint_Cnat // Cnat_nat. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite addrAC opprD addrA -mulrBl opprB [(_ - _) + (_ - _)]addrC !addrA subrK. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite -!muln2 !natrM [_ * v%:R]mulrC. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite ![v%:R * _]mulrBr !mulrA !(mulrBl, mulrDl) !mulfK //. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite !mul1r !(rpredB, rpredD, rpredN, rpredM) // Cint_Cnat // Cnat_nat. Qed. Fixpoint gcdGI_rec (n : nat) (xx yy : GI) {struct n} := let rr := modGI xx yy in if rr == 0 then yy else if n is n1.+1 then gcdGI_rec n1 yy rr else rr. Definition gcdGI x y := let: (x1, y1) := if ('N x < 'N y)%N then (y, x) else (x, y) in if x1 == 0 then y1 else gcdGI_rec ('N x1) x1 y1. Lemma gcd0GI : left_id 0 gcdGI. Proof. (* Goal: forall _ : is_true (coprimeGI z x), is_true (eqGI (gcdGI z (@GRing.mul GI_ringType x y)) (gcdGI z y)) *) move=> x; rewrite /gcdGI. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) have [/eqP->|xNz]:= boolP (x == 0). (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite ltnn eqxx. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite normGI0 normGI_gt0 xNz (negPf xNz). (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have : 'N x != 0%N by rewrite normGI_eq0. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by case: ('N _) => [|[|v]]; rewrite //= !(mod0GI, modGI0) (negPf xNz) eqxx. Qed. Lemma gcdGI0 : right_id 0 gcdGI. Proof. (* Goal: forall _ : is_true (coprimeGI z x), is_true (eqGI (gcdGI z (@GRing.mul GI_ringType x y)) (gcdGI z y)) *) move=> x; rewrite /gcdGI. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) have [/eqP->|xNz]:= boolP (x == 0). (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite ltnn eqxx. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite normGI0 /= (negPf xNz). by case: ('N _) => [|[|v]] //= ; rewrite !(modGI0,mod0GI) (negPf xNz) ?eqxx. Qed. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) Lemma gcdGI_recE m n x y : ('N y <= m)%N -> ('N y <= n)%N (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) -> ('N y < 'N x)%N -> gcdGI_rec m x y = gcdGI_rec n x y. Proof. (* Goal: is_true (eqGI a p) *) (* Goal: is_true (eqGI a p) *) elim: m n x y => [|m Hrec] [|n] //= x1 y1. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) - rewrite leqn0 normGI_eq0 => /eqP=> -> _. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite normGI0 normGI_gt0 modGI0 => /negPf-> /=. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by case: n => [|n]; rewrite /= mod0GI eqxx. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) - rewrite leqn0 normGI_eq0 => _ /eqP=> -> _. (* Goal: forall (_ : is_true (leq (minn (normGI z) (normGI y)) (S r))) (_ : is_true (dvdGI x y)) (_ : is_true (dvdGI x z)), is_true (dvdGI x (gcdGI y z)) *) rewrite modGI0; case: (boolP (x1 == 0)) => // x1Nz. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by case: m {Hrec} =>[|m]; rewrite /= mod0GI eqxx. (* Goal: forall (_ : is_true (leq (normGI y1) (S m))) (_ : is_true (leq (normGI y1) (S n))) (_ : is_true (leq (S (normGI y1)) (normGI x1))), @eq GI (if @eq_op eqGIType (modGI x1 y1) (GRing.zero GI_zmodType) then y1 else gcdGI_rec m y1 (modGI x1 y1)) (if @eq_op eqGIType (modGI x1 y1) (GRing.zero GI_zmodType) then y1 else gcdGI_rec n y1 (modGI x1 y1)) *) case: ifP => Epq Sm Sn Sq //; rewrite ?Epq //. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) case: (eqVneq y1 0) => [->|y1Nz]. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by case: n m {Sm Sn Hrec} => [|m] [|n] //=; rewrite mod0GI eqxx. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) apply: Hrec; last by rewrite ltn_modGI. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite -ltnS (leq_trans _ Sm) // ltn_modGI. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite -ltnS (leq_trans _ Sn) // ltn_modGI. Qed. Lemma gcdGIE x y : gcdGI x y = if ('N x < 'N y)%N then gcdGI (y %% x) x else gcdGI (x %% y) y. Proof. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) case: (eqVneq x 0) => [-> | xNz]. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite mod0GI modGI0 gcd0GI gcdGI0 if_same. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) case: (eqVneq y 0) => [-> | yNz]. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite mod0GI modGI0 gcd0GI gcdGI0 if_same. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite /gcdGI. (* Goal: forall (_ : is_true (leq (normGI y1) (S m))) (_ : is_true (leq (normGI y1) (S n))) (_ : is_true (leq (S (normGI y1)) (normGI x1))), @eq GI (if @eq_op eqGIType (modGI x1 y1) (GRing.zero GI_zmodType) then y1 else gcdGI_rec m y1 (modGI x1 y1)) (if @eq_op eqGIType (modGI x1 y1) (GRing.zero GI_zmodType) then y1 else gcdGI_rec n y1 (modGI x1 y1)) *) case: ltnP; rewrite (negPf xNz, negPf yNz) //=. (* Goal: forall _ : is_true (coprimeGI z x), is_true (eqGI (gcdGI z (@GRing.mul GI_ringType x y)) (gcdGI z y)) *) move=> ltxy; rewrite ltn_modGI (negPf xNz) //=. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite -(ltn_predK ltxy) /=; case: eqP => [->|]. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by case: ('N x) => [|[|s]]; rewrite /= modGI0 (negPf xNz) // mod0GI eqxx. (* Goal: forall _ : is_true (coprimeGI z x), is_true (eqGI (gcdGI z (@GRing.mul GI_ringType x y)) (gcdGI z y)) *) move/eqP=> yxNz; rewrite (negPf xNz). (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) apply: gcdGI_recE => //; last by rewrite ltn_modGI. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite -ltnS (ltn_predK ltxy) (leq_trans _ ltxy) ?leqW // ltn_modGI. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite ltnW // ltn_modGI. (* Goal: forall _ : is_true (coprimeGI z x), is_true (eqGI (gcdGI z (@GRing.mul GI_ringType x y)) (gcdGI z y)) *) move=> leyx; rewrite ltn_modGI (negPf yNz) //=. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have x_gt0: ('N x > 0)%N by rewrite normGI_gt0. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite -(prednK x_gt0) /=; case: eqP => [->|]. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by case: ('N y)%N => [|[|s]]; rewrite /= modGI0 (negPf yNz) // mod0GI eqxx. (* Goal: forall _ : is_true (coprimeGI z x), is_true (eqGI (gcdGI z (@GRing.mul GI_ringType x y)) (gcdGI z y)) *) move/eqP=> xyNz; rewrite (negPf yNz). (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) apply: gcdGI_recE => //; last by rewrite ltn_modGI. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite -ltnS (prednK x_gt0) (leq_trans _ leyx) // ltn_modGI. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite ltnW // ltn_modGI. Qed. Lemma gcd1GIE y : gcdGI 1 y = if ('N y == 1)%N then y else 1. Proof. (* Goal: forall (_ : is_true (leq (minn (normGI z) (normGI y)) (S r))) (_ : is_true (dvdGI x y)) (_ : is_true (dvdGI x z)), is_true (dvdGI x (gcdGI y z)) *) rewrite gcdGIE normGI1; case: leqP => [|H]. (* Goal: forall (_ : is_true (leq (minn (normGI z) (normGI y)) (S r))) (_ : is_true (dvdGI x y)) (_ : is_true (dvdGI x z)), is_true (dvdGI x (gcdGI y z)) *) rewrite leq_eqVlt; case: eqP => [/eqP|/= _]. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite -dvdGI1 => /eqP->; rewrite gcd0GI. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite ltnS leqn0 normGI_eq0 => /eqP->. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite modGI0 gcdGI0. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite modGI1 gcd0GI. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by move: H; rewrite ltnNge leq_eqVlt negb_or => /andP[/negPf->]. Qed. Lemma gcd1GI_norm y : 'N(gcdGI 1 y) = 1%N. Proof. by rewrite gcd1GIE; case: eqP; rewrite ?normGI1. Qed. Lemma gcdGI1 y : gcdGI y 1 = 1. Proof. (* Goal: forall (_ : is_true (leq (minn (normGI z) (normGI y)) (S r))) (_ : is_true (dvdGI x y)) (_ : is_true (dvdGI x z)), is_true (dvdGI x (gcdGI y z)) *) rewrite gcdGIE normGI1; case: leqP => [_|]. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) by rewrite modGI1 gcd0GI. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite ltnS leqn0 normGI_eq0 => /eqP->. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite modGI0 gcdGI0. Qed. Lemma gcdGIxx : idempotent gcdGI. Proof. by move=> x; rewrite gcdGIE ltnn modGIxx gcd0GI. Qed. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) Lemma dvdGI_mod d x y : d %| x -> (d %| y) = (d %| y %% x). Proof. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) case: (altP (x =P 0)) => [-> | nZx]; first by rewrite modGI0. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) case: (altP (d =P 0)) => [-> | nZd /dvdGIP[q1 ->]]. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite dvd0GI => /eqP->; rewrite modGI0. (* Goal: @eq bool (eqGI (gcdGI p x) (GRing.one GI_ringType)) false *) apply/dvdGIP/dvdGIP=> [] [q2 Hq2]. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite /modGI Hq2 !mulrA -mulrBl. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by set u := _ - _; exists u. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite (divGI_eq y (q1 * d)) Hq2 mulrA -mulrDl. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by set u := _ + _; exists u. Qed. Lemma dvdGI_gcdlr x y : (gcdGI x y %| x) && (gcdGI x y %| y). Proof. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) elim: {x y}minn {-2}x {-2}y (leqnn (minn ('N y) ('N x))) => [x y|r IH x y]. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite geq_min !leqn0 !normGI_eq0. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by case/pred2P=>->; rewrite (gcd0GI, gcdGI0) dvdGIxx ?andbT dvdGI0. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) case: (eqVneq x 0) => [-> _|nZx]. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite gcd0GI dvdGIxx andbT dvdGI0. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) case: (eqVneq y 0) => [->|nZy]. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite gcdGI0 dvdGIxx /= dvdGI0. (* Goal: forall (_ : is_true (leq (minn (normGI z) (normGI y)) (S r))) (_ : is_true (dvdGI x y)) (_ : is_true (dvdGI x z)), is_true (dvdGI x (gcdGI y z)) *) rewrite gcdGIE minnC /minn; case: ltnP => [lt_xy | le_xy] le_yr. (* Goal: is_true (andb (dvdGI (gcdGI (modGI x y) y) x) (dvdGI (gcdGI (modGI x y) y) y)) *) suffices /IH/andP[E1 E2]: (minn ('N x) ('N (y %% x)%GI) <= r)%N. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite E2 (dvdGI_mod _ E2). (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite geq_min orbC -ltnS (leq_trans _ le_yr) ?ltn_modGI. (* Goal: is_true (andb (dvdGI (gcdGI (modGI x y) y) x) (dvdGI (gcdGI (modGI x y) y) y)) *) suffices /IH/andP[E1 E2] : (minn ('N y) ('N (x %% y)%GI) <= r)%N. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite E2 andbT (dvdGI_mod _ E2). (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite geq_min orbC -ltnS (leq_trans _ le_yr) ?ltn_modGI. Qed. Lemma dvdGI_gcdl x y : gcdGI x y %| x. Proof. by case/andP: (dvdGI_gcdlr x y). Qed. Lemma dvdGI_gcdr x y : gcdGI x y %| y. Proof. by case/andP: (dvdGI_gcdlr x y). Qed. Lemma gcdGI_eq0 x y : (gcdGI x y == 0) = ((x == 0) && (y == 0)). Proof. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) have [/eqP->|/eqP nZx] := boolP (x == 0). (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite gcd0GI. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have := dvdGI_gcdl x y. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by case:eqP => //->; rewrite dvd0GI => /eqP. Qed. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) Lemma dvdGI_leq x y : y != 0 -> x %| y -> ('N x <= 'N y)%N. Proof. (* Goal: forall (_ : is_true (negb (@eq_op (GRing.Zmodule.eqType GI_zmodType) y (GRing.zero GI_zmodType)))) (_ : is_true (dvdGI x y)), is_true (leq (normGI x) (normGI y)) *) move=> nZy /dvdGIP[q qE]; have := nZy. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite qE -normGI_eq0 normGIM muln_eq0 negb_or => /andP[H1 H2]. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite -[X in (X <= _)%N] mul1n leq_pmul2r lt0n. Qed. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) Lemma leq_gcdGIl (x y : GI) : x != 0 -> ('N (gcdGI x y) <= 'N x)%N. Proof. by move=> nZx; apply: dvdGI_leq => //; exact: dvdGI_gcdl. Qed. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) Lemma leq_gcdGIr (x y : GI) : y != 0 -> ('N (gcdGI x y) <= 'N y)%N. Proof. by move=> nZy; move: (dvdGI_gcdr x y); apply: dvdGI_leq. Qed. Lemma dvdGI_trans : transitive dvdGI. Proof. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) move=> x y z /dvdGIP[qx -> /dvdGIP[qy ->]]. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by apply/dvdGIP; exists (qy * qx); rewrite mulrA. Qed. Lemma dvdGI_gcd x y z : x %| gcdGI y z = (x %| y) && (x %| z). Proof. (* Goal: @eq bool (eqGI (gcdGI p x) (GRing.one GI_ringType)) false *) apply/idP/andP=> [dv_xyz | [dv_xy dv_xz]]. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite ?(dvdGI_trans dv_xyz) ?dvdGI_gcdl ?dvdGI_gcdr. (* Goal: forall (_ : is_true (negb (@eq_op (GRing.Zmodule.eqType (GRing.Ring.zmodType GI_ringType)) y (GRing.zero (GRing.Ring.zmodType GI_ringType))))) (_ : is_true (negb (@eq_op (GRing.Zmodule.eqType (GRing.Ring.zmodType GI_ringType)) z (GRing.zero (GRing.Ring.zmodType GI_ringType))))), @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) move: (leqnn (minn ('N z) ('N y))) dv_xy dv_xz. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) elim: {y z}minn {-2}y {-2}z => [|r IH] y z. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite geq_min !leqn0 !normGI_eq0. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by case/pred2P=> ->; rewrite ?(gcd0GI, gcdGI0). (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) case: (eqVneq y 0) => [-> _|nZy]; first by rewrite gcd0GI. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) case: (eqVneq z 0) => [->|nZz]; first by rewrite gcdGI0. (* Goal: forall (_ : is_true (leq (minn (normGI z) (normGI y)) (S r))) (_ : is_true (dvdGI x y)) (_ : is_true (dvdGI x z)), is_true (dvdGI x (gcdGI y z)) *) rewrite gcdGIE minnC /minn; case: ltnP => Czy le_r dv_y dv_z. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) apply: IH => //; last by rewrite -(dvdGI_mod _ dv_y). (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite geq_min orbC -ltnS (leq_trans _ le_r) ?ltn_modGI. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) apply: IH => //; last by rewrite -(dvdGI_mod _ dv_z). (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite geq_min orbC -ltnS (leq_trans _ le_r) ?ltn_modGI. Qed. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) Lemma dvdGI_mul2r (p d x : GI) : p != 0 -> (d * p %| x * p) = (d %| x). Proof. (* Goal: forall _ : is_true (negb (@eq_op eqGIType p (GRing.zero GI_zmodType))), @eq bool (dvdGI (@GRing.mul GI_ringType d p) (@GRing.mul GI_ringType x p)) (dvdGI d x) *) move=> nZp; apply/dvdGIP/dvdGIP=> [] [q Hq]; exists q. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by apply: (mulIf nZp); rewrite -mulrA. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite Hq mulrA. Qed. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) Lemma dvdGI_mul2l (p d x : GI) : p != 0 -> (p * d %| p * x) = (d %| x). Proof. by rewrite ![p *_]mulrC; exact: dvdGI_mul2r. Qed. Definition lcmGI x y := (x * y) %/ gcdGI x y. Lemma mulGI_lcm_gcd x y : lcmGI x y * gcdGI x y = x * y. Proof. by apply/eqP; rewrite divGIK // dvdGI_mull // dvdGI_gcdr. Qed. Lemma lcm0GI y : lcmGI 0 y = 0. Proof. by rewrite /lcmGI mul0r div0GI. Qed. Lemma lcmGI0 x : lcmGI x 0 = 0. Proof. by rewrite /lcmGI mulr0 div0GI. Qed. Lemma lcmGI_eq0 x y : (lcmGI x y == 0) = ((x == 0) || (y == 0)). Proof. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) have [/eqP->|nZx] := boolP (x == 0). (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite lcm0GI eqxx. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) have [/eqP->|nZy] := boolP (y == 0). (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite lcmGI0 eqxx. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite /lcmGI. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have /dvdGIP[q Hq]: gcdGI x y %| x * y by rewrite dvdGI_mulr // dvdGI_gcdl. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite Hq divGIKl ?gcdGI_eq0 ?negb_and ?nZx //. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) case: eqP Hq => // -> /eqP. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite mul0r mulf_eq0 (negPf nZx) (negPf nZy). Qed. Definition eqGI x y := (dvdGI x y) && (dvdGI y x). Lemma eqGIxx : reflexive eqGI. Proof. by move=> x; rewrite /eqGI dvdGIxx. Qed. Lemma eqGI_sym : symmetric eqGI. Proof. by move=> x y; rewrite /eqGI andbC. Qed. Lemma eqGI_trans : transitive eqGI. Proof. (* Goal: forall (_ : is_true (negb (@eq_op (GRing.Zmodule.eqType (GRing.Ring.zmodType GI_ringType)) y (GRing.zero (GRing.Ring.zmodType GI_ringType))))) (_ : is_true (negb (@eq_op (GRing.Zmodule.eqType (GRing.Ring.zmodType GI_ringType)) z (GRing.zero (GRing.Ring.zmodType GI_ringType))))), @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) move=> x y z /andP[U1 V1] /andP[U2 V2]. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite /eqGI (dvdGI_trans U1) // (dvdGI_trans V2). Qed. Infix "%=" := eqGI : GI_scope. Lemma eqGI0 (x : GI) : (x %= 0) = (x == 0). Proof. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) apply/andP/eqP=>[[]|->]; last by rewrite dvdGIxx. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite dvd0GI => _ /eqP. Qed. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) Lemma eqGI_eq0 x y : x %= y -> (x == 0) = (y == 0). Proof. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) have [/eqP->|] := boolP (x == 0). (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite eqGI_sym eqGI0. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) have [/eqP->|//] := boolP (y == 0). (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite eqGI0 => /negP. Qed. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) Lemma eqGI_norm x y : x %= y -> 'N x = 'N y. Proof. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) have [/eqP->|nZx] := boolP (x == 0). (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite eqGI_sym eqGI0 => /eqP->. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) have [/eqP->|nZy] := boolP (y == 0). (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite eqGI0 => /eqP->. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) case/andP => /(dvdGI_leq nZy) H1 /(dvdGI_leq nZx) H2. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by apply/eqP; rewrite eqn_leq H1. Qed. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) Lemma dvdGI_eq_norm x y : 'N x = 'N y -> x %| y -> x %= y. Proof. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) have [/eqP->|nZx] := boolP (x == 0). (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite dvd0GI => _ /eqP->; exact: eqGIxx. (* Goal: forall _ : is_true (coprimeGI z x), is_true (eqGI (gcdGI z (@GRing.mul GI_ringType x y)) (gcdGI z y)) *) move=> xNy xDy; rewrite /eqGI xDy /=. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) case/dvdGIP: xDy => q Hq. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) apply/dvdGIP; exists q^-1. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite Hq mulrA mulVr ?mul1r // -normGI_unit. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) have /eqn_pmul2r<- : (0 < 'N x)%N. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by move: nZx; rewrite -normGI_eq0; case: ('N x). (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite -normGIM -Hq xNy mul1n. Qed. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) Lemma eqGI_nat m n : m%:R %= n%:R -> m = n. Proof. move=> /andP[H1 H2]; apply/eqP. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite -(eqn_exp2r _ _ (isT : 0 < 2)%N) -!normGI_nat eqn_dvd !dvdGI_norm. Qed. Lemma conjGI_gcd x y : conjGI (gcdGI x y) %= gcdGI (conjGI x) (conjGI y). Proof. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite /eqGI dvdGI_gcd !conjGI_dvd //= ?(dvdGI_gcdr,dvdGI_gcdl) //. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite -[X in X %|_]conjGIK. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite conjGI_dvd // dvdGI_gcd -{2}[x]conjGIK -{3}[y]conjGIK !conjGI_dvd // ?(dvdGI_gcdr,dvdGI_gcdl). Qed. Lemma conjGIM_norm x : x * conjGI x = ('N x)%:R. Proof. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by apply/val_eqP; rewrite /= -normCK -gaussNormE algGI_nat truncCK. Qed. Lemma eqGIP (x y : GI) : reflect (exists2 u, normGI u = 1%N & x = u * y) (x %= y). Proof. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) apply: (iffP andP)=> [[xDy yDx]|[u Nu->]]; last first. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) split; apply/dvdGIP; last by exists u. exists (conjGI u); rewrite mulrA [conjGI _ * _]mulrC. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite conjGIM_norm Nu mul1r. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have: 'N x = 'N y by rewrite (@eqGI_norm x y) ///eqGI xDy. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) case/dvdGIP: yDx => u -> /eqP. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite normGIM -{2}['N y]mul1n eqn_mul2r normGI_eq0 => /orP[/eqP->|/eqP Nu]. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by exists 1; rewrite ?mulr0 // normGI1. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by exists u. Qed. Lemma gcdGIC x y : gcdGI x y %= gcdGI y x. Proof. by rewrite /eqGI !(dvdGI_gcd, dvdGI_gcdl, dvdGI_gcdr). Qed. Lemma gcd1GI y : gcdGI 1 y %= 1. Proof. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite /eqGI dvd1GI dvdGI1 gcd1GIE. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by case: (@eqP _ ('N y) 1%N) => [->|]; rewrite ?normGI1. Qed. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) Lemma eqGI_dvdr x y1 y2 : y1 %= y2 -> (x %| y1) = (x %| y2). Proof. move=> /andP[y1Dy2 y2Dy1]; apply/idP/idP. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by move=> /dvdGI_trans /(_ y1Dy2). (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by move=> /dvdGI_trans /(_ y2Dy1). Qed. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) Lemma eqGI_dvdl y x1 x2 : x1 %= x2 -> (x1 %| y) = (x2 %| y). Proof. move=> /andP[x1Dx2 x2Dx1]; apply/idP/idP. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by move=> /(dvdGI_trans x2Dx1). (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by move=> /(dvdGI_trans x1Dx2). Qed. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) Lemma eqGI_gcdr x y1 y2 : y1 %= y2 -> gcdGI x y1 %= gcdGI x y2. Proof. (* Goal: forall _ : is_true (coprimeGI z x), is_true (eqGI (gcdGI z (@GRing.mul GI_ringType x y)) (gcdGI z y)) *) move=> y1Ey2; rewrite /eqGI !(dvdGI_gcd, dvdGI_gcdl, dvdGI_gcdr). (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite -(eqGI_dvdr _ y1Ey2) dvdGI_gcdr (eqGI_dvdr _ y1Ey2) dvdGI_gcdr. Qed. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) Lemma eqGI_gcdl y x1 x2 : x1 %= x2 -> gcdGI x1 y %= gcdGI x2 y. Proof. move=> x1Ex2; apply: eqGI_trans (gcdGIC _ _). (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by apply: eqGI_trans (gcdGIC _ _) _; exact: eqGI_gcdr. Qed. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) Lemma eqGI_mul2r (r p q : GI) : r != 0 -> (p * r %= q * r) = (p %= q). Proof. by move => nZr; rewrite /eqGI !dvdGI_mul2r. Qed. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) Lemma eqGI_mul2l (r p q : GI): r != 0 -> (r * p %= r * q) = (p %= q). Proof. by move => nZr; rewrite /eqGI !dvdGI_mul2l. Qed. Lemma eqGI_mul (p1 p2 q1 q2 : GI) : (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) p1 %= q1 -> p2 %= q2 -> p1 * p2 %= q1 * q2. Proof. move=> /andP[E1 E2] /andP[F1 F2]; apply/andP; split. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) have /dvdGIP[u1->] := E1; have /dvdGIP[v1->] := F1. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by apply/dvdGIP; exists (u1 * v1); rewrite mulrAC [p1 * _]mulrC !mulrA. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) have /dvdGIP[u1->] := E2; have /dvdGIP[v1->] := F2. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by apply/dvdGIP; exists (u1 * v1); rewrite mulrAC [q1 * _]mulrC !mulrA. Qed. Fixpoint egcdGI_rec n (x y : GI) := if y == 0 then (1, 0) else if n is n1.+1 then let: (u, v) := egcdGI_rec n1 y (modGI x y) in (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) (v, u - v * (x %/ y)%GI) else (1, 0). Definition egcdGI (x y : GI) := if ('N y <= 'N x)%N then egcdGI_rec ('N x) x y else let e := egcdGI_rec ('N y) y x in (e.2, e.1). Lemma egcdGI_rec0r n x : egcdGI_rec n x 0 = (1, 0). Proof. by case: n => /= [|n]; rewrite eqxx. Qed. Lemma egcdGI0 x : egcdGI x 0 = (1, 0). Proof. by rewrite /egcdGI normGI0 egcdGI_rec0r. Qed. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) Lemma egcd0GI y : y != 0 -> egcdGI 0 y = (0, 1). Proof. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite /egcdGI normGI0 -normGI_eq0 leqn0 egcdGI_rec0r => /negPf->/=. Qed. Lemma egcdGI_recP : (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) forall n x y, y != 0 -> ('N y <= n)%N -> ('N y <= 'N x)%N -> forall (e := egcdGI_rec n x y), gcdGI_rec n x y = e.1 * x + e.2 * y. Proof. (* Goal: is_true (eqGI a p) *) (* Goal: is_true (eqGI a p) *) elim => [x y nZy|n /= IH x y nZy NyLn NyLNx]. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite leqn0 normGI_eq0 (negPf nZy). (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have NxP : (0 < 'N x)%N. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by apply: leq_trans NyLNx; rewrite ltnNge leqn0 normGI_eq0. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite (negPf nZy). (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have [r0|nZr0] := eqVneq (x %% y) 0. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite r0 egcdGI_rec0r !mul0r subr0 add0r mul1r eqxx. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have NxyLn : ('N(x %% y)%GI <= n)%N. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite -ltnS (leq_trans _ NyLn) // ltn_modGI. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) have NxyLNy : ('N (x %% y)%GI <= 'N y)%N by rewrite ltnW // ltn_modGI. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have := IH _ _ nZr0 NxyLn NxyLNy. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) case: (egcdGI_rec _ _) => u v ->. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite (negPf nZr0) /= /modGI mulrBr mulrBl addrCA mulrA. Qed. Lemma egcdGIP (x y : GI) : gcdGI x y = (egcdGI x y).1 * x + (egcdGI x y).2 * y. Proof. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) have [->|nZy] := eqVneq y 0. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite egcdGI0 gcdGI0 mul1r mulr0 addr0. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) have [->|nZx] := eqVneq x 0. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite mulr0 add0r gcd0GI egcd0GI // mul1r. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite /egcdGI /gcdGI. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) case: leqP => [H|H] /=; last first. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite (negPf nZy) addrC. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by apply: egcdGI_recP; rewrite // ltnW. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite (negPf nZx). (* Goal: @eq bool (eqGI (gcdGI p x) (GRing.one GI_ringType)) false *) apply: egcdGI_recP => //. Qed. Lemma mulGI_gcdr x y z : x * gcdGI y z %= gcdGI (x * y) (x * z). Proof. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) have [/eqP->|nZx] := boolP (x == 0); first by rewrite !mul0r gcd0GI eqGIxx. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite /eqGI dvdGI_gcd !dvdGI_mul2l // dvdGI_gcdl dvdGI_gcdr /=. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite [X in _%|_ * X]egcdGIP mulrDr dvdGI_add // mulrCA dvdGI_mull //. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite dvdGI_gcdl. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite dvdGI_gcdr. Qed. Lemma mulGI_gcdl x y z : gcdGI y z * x %= gcdGI (y * x) (z * x). Proof. by rewrite ![_ * x]mulrC mulGI_gcdr. Qed. Lemma dvdGI_lcm d1 d2 x : lcmGI d1 d2 %| x = (d1 %| x) && (d2 %| x). Proof. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) have [/eqP->|nZd1] := boolP (d1 == 0). (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite lcm0GI dvd0GI; case: eqP => //->; rewrite dvdGI0. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) have [/eqP->|nZd2] := boolP (d2 == 0). (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite lcmGI0 dvd0GI andbC; case: eqP=> //->; rewrite dvdGI0. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) have /dvdGI_mul2r<- : gcdGI d1 d2 != 0 by rewrite gcdGI_eq0 negb_and nZd1. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite mulGI_lcm_gcd (eqGI_dvdr _ (mulGI_gcdr _ _ _)) dvdGI_gcd. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite {1}mulrC !dvdGI_mul2r // andbC. Qed. Section OrdinalGI. Variable n : nat. Inductive ordinalGI : predArgType := OrdinalGI x of ('N x < n)%N. Coercion GI_of_ord i := let: OrdinalGI m _ := i in m. Canonical ordinalGI_subType := [subType for GI_of_ord]. Definition ordinalGI_eqMixin := Eval hnf in [eqMixin of ordinalGI by <:]. Canonical ordinalGI_eqType := Eval hnf in EqType ordinalGI ordinalGI_eqMixin. Definition ordinalGI_choiceMixin := [choiceMixin of ordinalGI by <:]. Canonical ordinalGI_choiceType := Eval hnf in ChoiceType ordinalGI ordinalGI_choiceMixin. Definition ordinalGI_countMixin := [countMixin of ordinalGI by <:]. Canonical ordinalGI_countType := Eval hnf in CountType ordinalGI ordinalGI_countMixin. Canonical ordinalGI_subCountType := [subCountType of ordinalGI]. Lemma ltn_ordGI (i : ordinalGI) : ('N i < n)%N. Proof. exact: valP i. Qed. Lemma ordGI_inj : injective GI_of_ord. Proof. exact: val_inj. Qed. Definition ordGI_enum : seq ordinalGI := pmap insub [seq (let: (n1, n2) := i in (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) (((nat_of_ord n1))%:R - n%:R) + (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) iGI * ((nat_of_ord n2)%:R - n%:R)) | (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) i <- (enum [finType of ('I_n.*2 * 'I_n.*2)%type])]. Lemma ordGI_enum_uniq : uniq ordGI_enum. Proof. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite pmap_sub_uniq // map_inj_in_uniq ?enum_uniq //. move=> /= [x1 x2] [y1 y2] _ _ /val_eqP /eqP /= H. (* Goal: @eq nat (S (logGI_rec p (divGI x p) m1)) (S (logGI_rec p (divGI x p) m2)) *) congr (_ , _); apply/eqP. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have /eqP := congr1 (fun x => Re x) H. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite !Re_rect ?rpredB ?Creal_Cnat ?algGI_nat //. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite - subr_eq0 opprB addrA subrK subr_eq0 eqC_nat. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have /eqP := congr1 (fun x => Im x) H. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite !Im_rect ?rpredB ?Creal_Cnat ?algGI_nat //. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite - subr_eq0 opprB addrA subrK subr_eq0 eqC_nat. Qed. Fact int_norm_nat x y m : (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) x \in Cint -> y \in Cint -> (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) `|x| ^+ 2 + `|y| ^+ 2 < m%:R -> (x + m%:R \in Cnat) && (x + m%:R < m.*2%:R). Proof. (* Goal: forall (_ : is_true (negb (@eq_op (GRing.Zmodule.eqType (GRing.Ring.zmodType GI_ringType)) y (GRing.zero (GRing.Ring.zmodType GI_ringType))))) (_ : is_true (negb (@eq_op (GRing.Zmodule.eqType (GRing.Ring.zmodType GI_ringType)) z (GRing.zero (GRing.Ring.zmodType GI_ringType))))), @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) move=> xCint yCint xyLem. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite CnatEint rpredD // ?Cint_Cnat //=. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have : `|x| ^+ 2 < (Posz m)%:~R ^+ 2. (* Goal: @eq bool (eqGI (gcdGI p x) (GRing.one GI_ringType)) false *) apply: ltr_le_trans (_ : m%:R <= _). (* Goal: @eq bool (eqGI (gcdGI p x) (GRing.one GI_ringType)) false *) apply: ler_lt_trans xyLem. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite ler_addl -realEsqr Creal_Cnat // Cnat_norm_Cint. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite -natrX ler_nat. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by case: (m) => // m1; rewrite (leq_pexp2l _ (isT : (0 < 2)%N)). (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite -{1}(floorCK xCint) -intr_norm -!rmorphX /= ltr_int. pose nD := [numDomainType of algC]. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) case: m{xyLem} => [|m] //. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite -subr_gt0 subr_sqr pmulr_lgt0; last first. (* Goal: @eq bool (eqGI (gcdGI p x) (GRing.one GI_ringType)) false *) apply: ltr_le_trans (_ : Posz m.+1 + 0 <= _) => //. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by apply: ler_add. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite subr_gt0 lter_norml -!(ltr_int nD) floorCK //. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite -subr_gt0 rmorphN opprK => /andP[/ltrW]. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite -[x < _](ltr_add2r m.+1%:R) -natrD addnn => ->. Qed. Lemma mem_ordGI_enum x : x \in ordGI_enum. Proof. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite mem_pmap. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) apply/mapP; exists (GI_of_ord x); last by rewrite valK. (* Goal: @eq bool (eqGI (gcdGI p x) (GRing.one GI_ringType)) false *) apply/mapP. pose xr := truncC ('Re (algGI (GI_of_ord x)) + n%:R). pose yr := truncC ('Im (algGI (GI_of_ord x)) + n%:R). pose nD := [numDomainType of algC]. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have := ltn_ordGI x. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite normGIE -(ltr_nat nD) natrD !natrX !truncCK ?Cnat_norm_Cint //. (* Goal: forall (_ : is_true (negb (@eq_op (GRing.Zmodule.eqType (GRing.Ring.zmodType GI_ringType)) y (GRing.zero (GRing.Ring.zmodType GI_ringType))))) (_ : is_true (negb (@eq_op (GRing.Zmodule.eqType (GRing.Ring.zmodType GI_ringType)) z (GRing.zero (GRing.Ring.zmodType GI_ringType))))), @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) move => HH. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have /andP[Hrx1 Lx1] := int_norm_nat (GIRe _) (GIIm _) HH. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have F1 : (truncC ('Re (val (GI_of_ord x)) + n%:R) < n.*2)%N. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite -(ltr_nat nD) truncCK. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite addrC in HH. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have /andP[Hrx2 Lx2] := int_norm_nat (GIIm _) (GIRe _) HH. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have F2 : (truncC ('Im (val (GI_of_ord x)) + n%:R) < n.*2)%N. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite -(ltr_nat nD) truncCK. exists (Ordinal F1, Ordinal F2); rewrite ?mem_enum //=. (* Goal: @eq bool (eqGI (gcdGI p x) (GRing.one GI_ringType)) false *) apply/val_eqP=> /=. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite !algGI_nat !truncCK // !addrK -algCrect. Qed. Definition ordinalGI_finMixin := Eval hnf in UniqFinMixin ordGI_enum_uniq mem_ordGI_enum. Canonical ordinalGI_finType := Eval hnf in FinType ordinalGI ordinalGI_finMixin. Canonical ordinalGI_subFinType := Eval hnf in [subFinType of ordinalGI]. End OrdinalGI. Definition primeGI (x : GI) := (1 < 'N x)%N && [forall y : ordinalGI ('N x), (y %| x) ==> ('N y == 1%N)]. Lemma nprimeGI0 : ~ primeGI 0. Proof. by case/andP; rewrite normGI0. Qed. Lemma primeGIP x : reflect ((1 < 'N x)%N /\ (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) forall y, ('N y < 'N x)%N -> (y %| x) -> 'N y = 1%N) (primeGI x). Proof. (* Goal: @eq bool (eqGI (gcdGI p x) (GRing.one GI_ringType)) false *) apply: (iffP andP) => [[H1 /forallP H2]|[H1 H2]]. (* Goal: forall (_ : @eq bool (@in_mem GI a (@mem GI (seq_predType eqGIType) (@cons GI a l))) (andb (primeGI a) (andb (negb (@eq_op eqGIType (@GRing.exp GI_ringType p (S k)) (GRing.zero GI_zmodType))) (dvdGI a (@GRing.exp GI_ringType p (S k)))))) (_ : is_true (@in_mem GI p (@mem GI (seq_predType eqGIType) (@cons GI a l)))), is_true (eqGI a p) *) split => // y yLx yDx. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by have /implyP/(_ yDx)/eqP := H2 (OrdinalGI yLx). split => //; apply/forallP => y; apply/implyP => yDx; apply/eqP. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by apply: H2 => //; apply: ltn_ordGI. Qed. Lemma primeGIPn x : reflect (('N x < 2)%N \/ exists2 y, (1 < 'N y < 'N x)%N & (y %| x)) (~~ primeGI x). Proof. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) apply: (iffP idP)=> [|[H|[y /andP[H1 H2] H3]]]; last 2 first. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) - by apply/negP=> /primeGIP[]; rewrite leqNgt H. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) - apply/negP=> /primeGIP[H4 /(_ y H2 H3) H5]. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by have := H1; rewrite H5. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) case: leqP => [H|H _]; last by left. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) case: (boolP [exists z : ordinalGI ('N x), (1 < 'N z)%N && (z %| x)]). move=> /existsP[z /andP[H1z H2z]]; right; exists z => //. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite H1z ltn_ordGI. (* Goal: forall (_ : @eq bool (@in_mem GI a (@mem GI (seq_predType eqGIType) (@cons GI a l))) (andb (primeGI a) (andb (negb (@eq_op eqGIType (@GRing.exp GI_ringType p (S k)) (GRing.zero GI_zmodType))) (dvdGI a (@GRing.exp GI_ringType p (S k)))))) (_ : is_true (@in_mem GI p (@mem GI (seq_predType eqGIType) (@cons GI a l)))), is_true (eqGI a p) *) rewrite negb_exists => /forallP HH /negP[]. (* Goal: @eq bool (coprimeGI p x) (negb (dvdGI p x)) *) (* Goal: forall _ : is_true (eqGI (gcdGI p x) p), @eq bool (coprimeGI p x) (negb (dvdGI p x)) *) rewrite /primeGI H; apply/forallP => z. have := HH z; case: (boolP (_ %| _)) => //. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite andbT -leqNgt leq_eqVlt ltnS leqn0 normGI_eq0. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) have [/eqP->|] := boolP (GI_of_ord z == 0); last by rewrite orbF. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite dvd0GI => /eqP HH1; have := H; rewrite HH1 normGI0. Qed. Definition primesGI (x : GI) := (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) [seq i <- [seq GI_of_ord i| i : ordinalGI ('N x).+1] | primeGI i && (i %| x)]. Lemma mem_primesGI (p x : GI) : (p \in primesGI x) = [&& primeGI p, x != 0 & p %| x]. Proof. (* Goal: @eq bool (eqGI (gcdGI p x) (GRing.one GI_ringType)) false *) apply/idP/idP. (* Goal: forall (_ : @eq bool (@in_mem GI a (@mem GI (seq_predType eqGIType) (@cons GI a l))) (andb (primeGI a) (andb (negb (@eq_op eqGIType (@GRing.exp GI_ringType p (S k)) (GRing.zero GI_zmodType))) (dvdGI a (@GRing.exp GI_ringType p (S k)))))) (_ : is_true (@in_mem GI p (@mem GI (seq_predType eqGIType) (@cons GI a l)))), is_true (eqGI a p) *) rewrite mem_filter => /andP[/andP[H1 H2]] /mapP[[y yL _ /= HH]]. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite H1 H2 andbT /=. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have /primeGIP[] := H1. (* Goal: forall (_ : @eq bool (@in_mem GI a (@mem GI (seq_predType eqGIType) (@cons GI a l))) (andb (primeGI a) (andb (negb (@eq_op eqGIType (@GRing.exp GI_ringType p (S k)) (GRing.zero GI_zmodType))) (dvdGI a (@GRing.exp GI_ringType p (S k)))))) (_ : is_true (@in_mem GI p (@mem GI (seq_predType eqGIType) (@cons GI a l)))), is_true (eqGI a p) *) rewrite HH => HH1 _. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite -normGI_eq0 -leqn0 -ltnNge -ltnS (leq_trans HH1) // ltnW. (* Goal: forall (_ : is_true (negb (@eq_op (GRing.Zmodule.eqType (GRing.Ring.zmodType GI_ringType)) y (GRing.zero (GRing.Ring.zmodType GI_ringType))))) (_ : is_true (negb (@eq_op (GRing.Zmodule.eqType (GRing.Ring.zmodType GI_ringType)) z (GRing.zero (GRing.Ring.zmodType GI_ringType))))), @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) move=> /andP[H1 /andP[H2 H3]]. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have HH : ('N p < ('N x).+1)%N. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite ltnS dvdGI_leq // -normGI_eq0; case: ('N _) H2. rewrite mem_filter H1 H3; apply/mapP; exists (OrdinalGI HH) => //. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite mem_enum. Qed. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) Lemma eqGI_prime x y : x %= y -> primeGI x -> primeGI y. Proof. (* Goal: forall (_ : is_true (eqGI x y)) (_ : is_true (primeGI x)), is_true (primeGI y) *) move=> xEy /primeGIP[H1 H2]; apply/primeGIP; split=> [|y1 Hy1 H1y1]. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite -(eqGI_norm xEy). (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by apply: H2; rewrite ?(eqGI_norm xEy, eqGI_dvdr _ xEy). Qed. Definition pdivGI x : GI := head 1 (primesGI x). (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) Lemma pdivGI_prime x : (1 < 'N x)%N -> primeGI (pdivGI x). Proof. (* Goal: forall (_ : is_true (negb (@eq_op (GRing.Zmodule.eqType (GRing.Ring.zmodType GI_ringType)) y (GRing.zero (GRing.Ring.zmodType GI_ringType))))) (_ : is_true (negb (@eq_op (GRing.Zmodule.eqType (GRing.Ring.zmodType GI_ringType)) z (GRing.zero (GRing.Ring.zmodType GI_ringType))))), @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) move=> Nx. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have [y Py yDz] : exists2 y, primeGI y & (y %| x). (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) elim: {x}S {-2}x (ltnSn ('N x)) Nx => // n IH x NxL ONx. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have [Px|/primeGIPn] := boolP (primeGI x). (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by exists x; rewrite ?dvdGIxx //. (* Goal: forall (_ : @eq bool (@in_mem GI a (@mem GI (seq_predType eqGIType) (@cons GI a l))) (andb (primeGI a) (andb (negb (@eq_op eqGIType (@GRing.exp GI_ringType p (S k)) (GRing.zero GI_zmodType))) (dvdGI a (@GRing.exp GI_ringType p (S k)))))) (_ : is_true (@in_mem GI p (@mem GI (seq_predType eqGIType) (@cons GI a l)))), is_true (eqGI a p) *) rewrite ltnNge ONx => [] [//|[y /andP[H1y H2y] H3y]]. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) case: (IH _ _ H1y) => [|z Pz zDy]; first by apply: (leq_trans H2y _). (* Goal: @ex2 GI (fun y : GI => is_true (primeGI y)) (fun y : GI => is_true (dvdGI y x)) *) (* Goal: is_true (primeGI (pdivGI x)) *) exists z; rewrite ?(dvdGI_trans zDy) //. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have yIp : y \in primesGI x. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite mem_primesGI Py yDz -normGI_eq0; case: ('N _) Nx. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType p n)) n *) suff: pdivGI x \in primesGI x by rewrite mem_primesGI => /andP[]. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite /pdivGI; case: primesGI yIp => //= a l _; rewrite in_cons eqxx. Qed. Lemma pdivGI_dvd x : pdivGI x %| x. Proof. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have := sym_equal (mem_primesGI (pdivGI x) x). (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) rewrite /pdivGI; case: primesGI => [|a l]; first by rewrite dvd1GI. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite /= in_cons eqxx /= => /and3P[]. Qed. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) Lemma pdivGI_leq x : x != 0 -> ('N (pdivGI x) <= 'N x)%N. Proof. by move=> /dvdGI_leq /(_ (pdivGI_dvd _)). Qed. Lemma pdivGI_neq0 x : pdivGI x != 0. Proof. (* Goal: @eq bool (eqGI (gcdGI p x) (GRing.one GI_ringType)) false *) apply/eqP=> H. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have := pdivGI_dvd x. (* Goal: forall (_ : @eq bool (@in_mem GI a (@mem GI (seq_predType eqGIType) (@cons GI a l))) (andb (primeGI a) (andb (negb (@eq_op eqGIType (@GRing.exp GI_ringType p (S k)) (GRing.zero GI_zmodType))) (dvdGI a (@GRing.exp GI_ringType p (S k)))))) (_ : is_true (@in_mem GI p (@mem GI (seq_predType eqGIType) (@cons GI a l)))), is_true (eqGI a p) *) rewrite H dvd0GI => /eqP Zx. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType p n)) n *) (* Goal: is_true (eqGI y (GRing.one GI_ringType)) *) have := fun x => mem_primesGI x 0; rewrite eqxx /=. (* Goal: forall _ : forall x0 : GI, @eq bool (@in_mem GI x0 (@mem GI (seq_predType eqGIType) (primesGI (GRing.zero GI_zmodType)))) (andb (primeGI x0) false), False *) have := H; rewrite Zx /pdivGI; case: primesGI => [/eqP/=| a l _ /(_ a)]. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite oner_eq0. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite in_cons eqxx andbF. Qed. Fixpoint logGI_rec p x n := if (p %| x) then if n is n1.+1 then (logGI_rec p (x %/ p) n1).+1 else 0%N else 0%N. Definition logGI p x := if primeGI p then logGI_rec p x ('N x) else 0%N. Lemma logGI_recE p x m1 m2 : (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) primeGI p -> ('N x <= m1)%N -> ('N x <= m2)%N -> x != 0 -> logGI_rec p x m1 = logGI_rec p x m2. Proof. (* Goal: forall (_ : is_true (negb (@eq_op (GRing.Zmodule.eqType (GRing.Ring.zmodType GI_ringType)) y (GRing.zero (GRing.Ring.zmodType GI_ringType))))) (_ : is_true (negb (@eq_op (GRing.Zmodule.eqType (GRing.Ring.zmodType GI_ringType)) z (GRing.zero (GRing.Ring.zmodType GI_ringType))))), @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) move=> Pp. (* Goal: is_true (eqGI a p) *) (* Goal: is_true (eqGI a p) *) elim: m1 m2 x => [m2 x|m1 IH [|m2 /=] x]. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) - by rewrite leqn0 normGI_eq0 => /eqP->; rewrite eqxx. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) - by rewrite leqn0 normGI_eq0 => _ /eqP->; rewrite eqxx. (* Goal: forall (_ : is_true (negb (@eq_op (GRing.Zmodule.eqType (GRing.Ring.zmodType GI_ringType)) y (GRing.zero (GRing.Ring.zmodType GI_ringType))))) (_ : is_true (negb (@eq_op (GRing.Zmodule.eqType (GRing.Ring.zmodType GI_ringType)) z (GRing.zero (GRing.Ring.zmodType GI_ringType))))), @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) move=> NxLm1 NxLm2 nZx. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have [/dvdGIP[q Hq]|//] := boolP (_ %| _). (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have nZp : p != 0. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by apply: contra nZx => /eqP HH; rewrite Hq HH mulr0. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have nZq : q != 0. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by apply: contra nZx => /eqP HH; rewrite Hq HH mul0r. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have F : ('N (x %/ p)%GI < 'N x)%N. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite Hq divGIKl // normGIM -{1}['N q]muln1. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite ltn_mul2l ltnNge leqn0 normGI_eq0 nZq; case/andP: Pp. (* Goal: @eq nat (S (logGI_rec p (divGI x p) m1)) (S (logGI_rec p (divGI x p) m2)) *) congr (_.+1); apply: IH. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) - by rewrite -ltnS (leq_trans F). (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) - by rewrite -ltnS (leq_trans F). (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite Hq divGIKl. Qed. Lemma logGIE p x : logGI p x = if [&& primeGI p, x != 0 & p %| x] then (logGI p (x %/ p)).+1 else 0%N. Proof. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite /logGI. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have [Pp|//] := boolP (primeGI p). (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite -normGI_eq0. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) case E : ('N x) => /= [|k]. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite if_same. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have [/dvdGIP[q Hq]|//] := boolP (_ %| _). (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) have nZx : x != 0 by rewrite -normGI_eq0 E. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have nZp : p != 0. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by apply: contra nZx => /eqP HH; rewrite Hq HH mulr0. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have nZq : q != 0. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by apply: contra nZx => /eqP HH; rewrite Hq HH mul0r. congr (_).+1. (* Goal: @eq bool (eqGI (gcdGI p x) (GRing.one GI_ringType)) false *) apply: logGI_recE => //. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite -ltnS -E Hq divGIKl // normGIM -{1}['N q]muln1. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite ltn_mul2l ltnNge leqn0 normGI_eq0 nZq; case/andP: Pp. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite Hq divGIKl. Qed. Lemma logGI_gt0 p x : (0 < logGI p x)%N = (p \in primesGI x). Proof. by rewrite logGIE -mem_primesGI; case: (p \in _). Qed. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) Lemma ltn_log0 p x : ('N x < 'N p)%N -> logGI p x = 0%N. Proof. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite logGIE ltnNge. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) have [|nZx] := boolP (x == 0); first by rewrite andbF. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by have [/(dvdGI_leq nZx)->|] /= := boolP (p %| x); last by rewrite andbF. Qed. Lemma logGI0 p : logGI p 0 = 0%N. Proof. by rewrite /logGI normGI0 /= !if_same. Qed. Lemma logGI1 p : logGI p 1 = 0%N. Proof. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite logGIE dvdGI1 /primeGI ltnNge leq_eqVlt negb_or. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by case: ('N p == 1%N); rewrite ?andbF. Qed. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) Lemma pfactor_dvdGI p (n : nat) (x : GI) : primeGI p -> x != 0 -> (p ^+ n %| x) = (n <= logGI p x)%N. Proof. move=> Pp; elim: n x => [|n IHn] x nZx; first by rewrite dvd1GI. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite logGIE Pp nZx. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) have [/dvdGIP[q Hq]/=|nD] := boolP (p %| x); last first. (* Goal: @eq bool (eqGI (gcdGI p x) (GRing.one GI_ringType)) false *) apply/dvdGIP=> [] [/= q qE]. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by case/negP: nD; rewrite qE exprS mulrCA dvdGI_mulr // dvdGIxx. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have nZp : p != 0. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by apply: contra nZx => /eqP HH; rewrite Hq HH mulr0. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have nZq : q != 0. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by apply: contra nZx => /eqP HH; rewrite Hq HH mul0r. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite Hq exprSr dvdGI_mul2r // divGIKl // IHn. Qed. Definition coprimeGI (x y : GI) := 'N(gcdGI x y) == 1%N. Lemma coprimeGI1 x : coprimeGI x 1. Proof. by rewrite /coprimeGI gcdGI1 normGI1. Qed. Lemma coprime1GI x : coprimeGI 1 x. Proof. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite /coprimeGI gcd1GIE. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by have [//|] := boolP ('N x == 1%N); rewrite normGI1. Qed. Lemma coprimeGIE x y : coprimeGI x y = (gcdGI x y %= 1). Proof. by rewrite /coprimeGI /eqGI dvdGI1 dvd1GI andbT. Qed. Lemma coprimeGI_sym: commutative coprimeGI. Proof. (* Goal: forall (_ : is_true (negb (@eq_op (GRing.Zmodule.eqType (GRing.Ring.zmodType GI_ringType)) y (GRing.zero (GRing.Ring.zmodType GI_ringType))))) (_ : is_true (negb (@eq_op (GRing.Zmodule.eqType (GRing.Ring.zmodType GI_ringType)) z (GRing.zero (GRing.Ring.zmodType GI_ringType))))), @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) move=> x y. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite !coprimeGIE; apply/idP/idP=> /(eqGI_trans _)->//; exact: gcdGIC. Qed. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) Lemma Gauss_dvdGI (x y z : GI) : coprimeGI x y -> (x * y %| z) = (x %| z) && (y %| z). Proof. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) have [/eqP-> _|nZx] := boolP (x == 0). (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite mul0r dvd0GI; case: eqP => //->; rewrite dvdGI0. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) have [/eqP-> _|nZy] := boolP (y == 0). (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite mulr0 dvd0GI andbC; case: eqP => //->; rewrite dvdGI0. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite coprimeGIE. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) have /eqGI_mul2l<-: lcmGI x y != 0 by rewrite lcmGI_eq0 negb_or nZx. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite mulr1 mulGI_lcm_gcd => /eqGI_dvdl->. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite dvdGI_lcm. Qed. Lemma coprimeGI_nat m n : (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) coprime m n -> coprimeGI (m%:R) (n%:R). Proof. (* Goal: forall (_ : is_true (negb (@eq_op (GRing.Zmodule.eqType (GRing.Ring.zmodType GI_ringType)) y (GRing.zero (GRing.Ring.zmodType GI_ringType))))) (_ : is_true (negb (@eq_op (GRing.Zmodule.eqType (GRing.Ring.zmodType GI_ringType)) z (GRing.zero (GRing.Ring.zmodType GI_ringType))))), @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) move=> Cmn. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite coprimeGIE /eqGI dvd1GI andbT dvdGI1 -dvdn1. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) have/eqP<-: coprime (m ^ 2) (n ^ 2). (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite coprime_expl // coprime_expr. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite dvdn_gcd -!normGI_nat !dvdGI_norm // ?(dvdGI_gcdr,dvdGI_gcdl). Qed. Lemma Gauss_dvdGIr (x y z : GI) : (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) coprimeGI x y -> (x %| y * z) = (x %| z). Proof. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) have [/eqP->|/dvdGI_mul2r H Cxy] := boolP (y == 0). (* Goal: forall (_ : @eq bool (@in_mem GI a (@mem GI (seq_predType eqGIType) (@cons GI a l))) (andb (primeGI a) (andb (negb (@eq_op eqGIType (@GRing.exp GI_ringType p (S k)) (GRing.zero GI_zmodType))) (dvdGI a (@GRing.exp GI_ringType p (S k)))))) (_ : is_true (@in_mem GI p (@mem GI (seq_predType eqGIType) (@cons GI a l)))), is_true (eqGI a p) *) rewrite /coprimeGI gcdGI0 mul0r dvdGI0 normGI_unit => H. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) apply/sym_equal/idP/dvdGIP; exists (z * x^-1). (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite -mulrA mulVr // mulr1. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite -[in RHS]H Gauss_dvdGI // mulrC. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite [y %|_]dvdGI_mull ?dvdGIxx // andbT. Qed. Lemma Gauss_dvdGIl (x y z : GI) : (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) coprimeGI x y -> (x %| z * y) = (x %| z). Proof. by rewrite mulrC; exact: Gauss_dvdGIr. Qed. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) Lemma coprimeGI_dvdl x y z : x %| y -> coprimeGI y z -> coprimeGI x z. Proof. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) move=> /dvdGIP[q ->]. rewrite !coprimeGIE egcdGIP => /eqGI_dvdr H. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite /eqGI dvd1GI andbT -H mulrA dvdGI_add // !dvdGI_mull ?(dvdGI_gcdl, dvdGI_gcdr). Qed. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) Lemma coprimeGI_dvdr x y z : x %| y -> coprimeGI z y -> coprimeGI z x. Proof. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) move=> /dvdGIP[q ->]. rewrite !coprimeGIE egcdGIP => /eqGI_dvdr H. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite /eqGI dvd1GI andbT -H mulrA dvdGI_add // !dvdGI_mull ?(dvdGI_gcdl, dvdGI_gcdr). Qed. Lemma Gauss_gcdGIr (x y z : GI) : (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) coprimeGI z x -> gcdGI z (x * y) %= gcdGI z y. Proof. (* Goal: forall _ : is_true (coprimeGI z x), is_true (eqGI (gcdGI z (@GRing.mul GI_ringType x y)) (gcdGI z y)) *) move=> Cxy; rewrite /eqGI !dvdGI_gcd dvdGI_mull ?(dvdGI_gcdl, dvdGI_gcdr) //. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite -(@Gauss_dvdGIr _ x) ?dvdGI_gcdr // (coprimeGI_dvdl _ Cxy) // dvdGI_gcdl. Qed. Lemma Gauss_gcdGIl x y z : (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) coprimeGI z y -> gcdGI z (x * y) %= gcdGI z x. Proof. by move=> u; rewrite mulrC; exact: Gauss_gcdGIr. Qed. Lemma coprimeGI_mulr (x y z : GI) : coprimeGI x (y * z) = coprimeGI x y && coprimeGI x z. Proof. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have [H|/= H] := boolP (coprimeGI x y). (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite !coprimeGIE /eqGI !dvd1GI !andbT (eqGI_dvdl _ (Gauss_gcdGIr _ _)). (* Goal: @eq bool (coprimeGI x (@GRing.mul GI_ringType y z)) false *) apply/idP=> H1; case/negP: H; apply: coprimeGI_dvdr H1. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by apply: dvdGI_mulr (dvdGIxx _). Qed. Lemma coprimeGI_mull (x y z : GI) : coprimeGI (y * z) x = coprimeGI y x && coprimeGI z x. Proof. by rewrite ![coprimeGI _ x]coprimeGI_sym -coprimeGI_mulr. Qed. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) Lemma primeGI_neq0 p : primeGI p -> p != 0. Proof. by case/primeGIP; case: eqP => //->; rewrite normGI0. Qed. Lemma coprimeGI_pexpl k (x y : GI) : (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) (0 < k)%N -> coprimeGI (x ^+ k) y = coprimeGI x y. Proof. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) case: k => // k _; elim: k => [|k IHk]; first by rewrite expr1. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite exprS coprimeGI_mull -IHk andbb. Qed. Lemma coprimeGI_pexpr k (x y : GI) : (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) (0 < k)%N -> coprimeGI x (y ^+ k) = coprimeGI x y. Proof. by move=> nZk; rewrite !(coprimeGI_sym x) coprimeGI_pexpl. Qed. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) Lemma coprimeGI_expl k (x y : GI) : coprimeGI x y -> coprimeGI (x ^+ k) y. Proof. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by case: k => [|k] Cxy; rewrite ?coprime1GI // coprimeGI_pexpl. Qed. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) Lemma coprimeGI_expr k x y : coprimeGI x y -> coprimeGI x (y ^+ k). Proof. rewrite !(coprimeGI_sym x); exact: coprimeGI_expl. Qed. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) Lemma primeGI_dvd p x : primeGI p -> (x %| p) = (x %= 1) || (x %= p). Proof. (* Goal: forall (_ : is_true (negb (@eq_op (GRing.Zmodule.eqType (GRing.Ring.zmodType GI_ringType)) y (GRing.zero (GRing.Ring.zmodType GI_ringType))))) (_ : is_true (negb (@eq_op (GRing.Zmodule.eqType (GRing.Ring.zmodType GI_ringType)) z (GRing.zero (GRing.Ring.zmodType GI_ringType))))), @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) move=> Pp. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) apply/idP/orP=> [xDp|[|]/eqGI_dvdl->]; rewrite ?dvdGIxx ?dvd1GI //. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have nZp := primeGI_neq0 Pp. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have := dvdGI_leq nZp xDp. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) rewrite leq_eqVlt => /orP[]; last first. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) case/primeGIP: Pp => _ HH /HH /(_ xDp) /eqP. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite -dvdGI1 /eqGI dvd1GI => ->; left. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) case/dvdGIP: xDp => q ->. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite /eqGI dvdGI_mull ?dvdGIxx // normGIM. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) have [/eqP->|nZx]:= boolP (x == 0). (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite mulr0 dvdGIxx; right. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite -{1}['N x]mul1n eqn_mul2r normGI_eq0 (negPf nZx) eq_sym /=. (* Goal: forall _ : is_true (@eq_op nat_eqType (normGI q) (S O)), or (is_true (andb (dvdGI x (GRing.one GI_ringType)) (dvdGI (GRing.one GI_ringType) x))) (is_true (dvdGI (@GRing.mul GI_ringType q x) x)) *) rewrite normGI_unit => HH; right. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by apply/dvdGIP; exists q^-1; rewrite mulrA mulVr // mul1r. Qed. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) Lemma primeGI_coprime p x : primeGI p -> coprimeGI p x = ~~ (p %| x). Proof. (* Goal: forall (_ : is_true (negb (@eq_op (GRing.Zmodule.eqType (GRing.Ring.zmodType GI_ringType)) y (GRing.zero (GRing.Ring.zmodType GI_ringType))))) (_ : is_true (negb (@eq_op (GRing.Zmodule.eqType (GRing.Ring.zmodType GI_ringType)) z (GRing.zero (GRing.Ring.zmodType GI_ringType))))), @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) move=> Pp. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have nZp := primeGI_neq0 Pp. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have Np_neq1 : ('N p == 1)%N = false. by case/primeGIP: Pp; case: ('N _) => // [[]]. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have: gcdGI p x %| p by exact: dvdGI_gcdl. (* Goal: forall (_ : @eq bool (@in_mem GI a (@mem GI (seq_predType eqGIType) (@cons GI a l))) (andb (primeGI a) (andb (negb (@eq_op eqGIType (@GRing.exp GI_ringType p (S k)) (GRing.zero GI_zmodType))) (dvdGI a (@GRing.exp GI_ringType p (S k)))))) (_ : is_true (@in_mem GI p (@mem GI (seq_predType eqGIType) (@cons GI a l)))), is_true (eqGI a p) *) rewrite primeGI_dvd // => /orP[H|]. (* Goal: @eq bool (coprimeGI p x) (negb (dvdGI p x)) *) (* Goal: forall _ : is_true (eqGI (gcdGI p x) p), @eq bool (coprimeGI p x) (negb (dvdGI p x)) *) rewrite coprimeGIE H; apply/sym_equal/negP => H1. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have: p %|gcdGI p x by rewrite dvdGI_gcd dvdGIxx H1. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite (eqGI_dvdr _ H) dvdGI1 Np_neq1. (* Goal: forall (_ : @eq bool (@in_mem GI a (@mem GI (seq_predType eqGIType) (@cons GI a l))) (andb (primeGI a) (andb (negb (@eq_op eqGIType (@GRing.exp GI_ringType p (S k)) (GRing.zero GI_zmodType))) (dvdGI a (@GRing.exp GI_ringType p (S k)))))) (_ : is_true (@in_mem GI p (@mem GI (seq_predType eqGIType) (@cons GI a l)))), is_true (eqGI a p) *) rewrite eqGI_sym => H. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite (eqGI_dvdl _ H) dvdGI_gcdr /= coprimeGIE. (* Goal: @eq bool (eqGI (gcdGI p x) (GRing.one GI_ringType)) false *) apply/negP => /(eqGI_trans H). (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite /eqGI dvd1GI dvdGI1 Np_neq1. Qed. Lemma pfactor_coprimeGI (p x : GI) : (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) primeGI p -> x != 0 -> {y | coprimeGI p y & x = y * p ^+ logGI p x}. Proof. (* Goal: forall (_ : is_true (primeGI p)) (_ : is_true (negb (@eq_op eqGIType x (GRing.zero GI_zmodType)))), @sig2 GI (fun y : GI => is_true (coprimeGI p y)) (fun y : GI => @eq GI x (@GRing.mul GI_ringType y (@GRing.exp GI_ringType p (logGI p x)))) *) move=> Pp nZx; set k := logGI p x. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have Dk : p ^+ k %| x by rewrite pfactor_dvdGI. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) exists (x %/ p ^+ k); last by rewrite divGIK. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite primeGI_coprime // -(@dvdGI_mul2r (p ^+ k)); last first. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by apply: expf_neq0 (primeGI_neq0 Pp). (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite -exprS divGIK // pfactor_dvdGI // ltnn. Qed. Lemma dvdGI_leq_log (x y z : GI) : (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) z != 0 -> y %| z -> (logGI x y <= logGI x z)%N. Proof. (* Goal: forall (_ : is_true (negb (@eq_op (GRing.Zmodule.eqType (GRing.Ring.zmodType GI_ringType)) y (GRing.zero (GRing.Ring.zmodType GI_ringType))))) (_ : is_true (negb (@eq_op (GRing.Zmodule.eqType (GRing.Ring.zmodType GI_ringType)) z (GRing.zero (GRing.Ring.zmodType GI_ringType))))), @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) move=> nZz yDz. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have [/eqP Zy|nZy] := boolP (y == 0). (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by move: yDz; rewrite Zy dvd0GI (negPf nZz). (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) have [Px|nPx] := boolP (primeGI x); last first. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite /logGI (negPf nPx). (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite -pfactor_dvdGI // (dvdGI_trans _ yDz) // pfactor_dvdGI. Qed. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) Lemma pfactorGIK p n : primeGI p -> logGI p (p ^+ n) = n. Proof. (* Goal: forall (_ : is_true (negb (@eq_op (GRing.Zmodule.eqType (GRing.Ring.zmodType GI_ringType)) y (GRing.zero (GRing.Ring.zmodType GI_ringType))))) (_ : is_true (negb (@eq_op (GRing.Zmodule.eqType (GRing.Ring.zmodType GI_ringType)) z (GRing.zero (GRing.Ring.zmodType GI_ringType))))), @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) move=> Pp. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have nZpn : p ^+ n != 0 by apply: expf_neq0 (primeGI_neq0 _). (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have [y Cyp pnE]:= pfactor_coprimeGI Pp nZpn. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have yDpn : y %| p ^+ n by rewrite pnE dvdGI_mulr ?dvdGIxx. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType p n)) n *) suff: y %= 1. (* Goal: forall (_ : @eq bool (@in_mem GI a (@mem GI (seq_predType eqGIType) (@cons GI a l))) (andb (primeGI a) (andb (negb (@eq_op eqGIType (@GRing.exp GI_ringType p (S k)) (GRing.zero GI_zmodType))) (dvdGI a (@GRing.exp GI_ringType p (S k)))))) (_ : is_true (@in_mem GI p (@mem GI (seq_predType eqGIType) (@cons GI a l)))), is_true (eqGI a p) *) rewrite /eqGI dvd1GI dvdGI1 andbT => /eqP Ny. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType p n)) n *) (* Goal: is_true (eqGI y (GRing.one GI_ringType)) *) have /eqP := congr1 normGI pnE; rewrite normGIM Ny mul1n. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) rewrite !normGIX eqn_exp2l; last by case/primeGIP: Pp. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by move/eqP<-. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) elim: (n) yDpn => [|n1 IH]; first by rewrite expr0 /eqGI dvd1GI andbT. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite exprS Gauss_dvdGIr // coprimeGI_sym. Qed. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) Lemma pdivGI_pfactor p k : primeGI p -> pdivGI (p ^+ k.+1) %= p. Proof. (* Goal: forall (_ : is_true (negb (@eq_op (GRing.Zmodule.eqType (GRing.Ring.zmodType GI_ringType)) y (GRing.zero (GRing.Ring.zmodType GI_ringType))))) (_ : is_true (negb (@eq_op (GRing.Zmodule.eqType (GRing.Ring.zmodType GI_ringType)) z (GRing.zero (GRing.Ring.zmodType GI_ringType))))), @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) move=> Pp. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have nZpn : p ^+ k.+1 != 0 by apply: expf_neq0 (primeGI_neq0 _). (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have: p \in primesGI (p ^+ k.+1). (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite mem_primesGI Pp nZpn. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by apply/dvdGIP; exists (p ^+ k); rewrite -exprSr. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite /pdivGI. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) case: primesGI (fun x => mem_primesGI x (p ^+ k.+1)) => /= [|a l /(_ a)]. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite in_nil. (* Goal: forall (_ : @eq bool (@in_mem GI a (@mem GI (seq_predType eqGIType) (@cons GI a l))) (andb (primeGI a) (andb (negb (@eq_op eqGIType (@GRing.exp GI_ringType p (S k)) (GRing.zero GI_zmodType))) (dvdGI a (@GRing.exp GI_ringType p (S k)))))) (_ : is_true (@in_mem GI p (@mem GI (seq_predType eqGIType) (@cons GI a l)))), is_true (eqGI a p) *) rewrite in_cons eqxx => /= /(@sym_equal _ _ _) /and3P[Pa _ aDp] _. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have [Cap|NCap]:= boolP (coprimeGI a p). (* Goal: is_true (eqGI a p) *) (* Goal: is_true (eqGI a p) *) elim: (k) aDp => [|k1 IHk1]. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by move: Cap; rewrite expr1 primeGI_coprime=> // /negP. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite exprS Gauss_dvdGIr. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have : ~~ coprimeGI p a. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by apply: contra NCap; rewrite coprimeGI_sym. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by move: NCap; rewrite /eqGI !primeGI_coprime // !negbK => ->. Qed. Lemma logGI_Gauss x y z : (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) coprimeGI x y -> logGI x (y * z) = logGI x z. Proof. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) move=> Cxy; have [Pp|PnP] := boolP (primeGI x); last first. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite /logGI (negPf PnP). (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) have [/eqP-> | nZz] := boolP (z == 0); first by rewrite mulr0. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have [/eqP Zy | nZy] := boolP (y == 0). (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by move: Cxy; rewrite Zy primeGI_coprime // dvdGI0. have nZyz: y * z != 0 by rewrite mulf_eq0 (negPf nZy) (negPf nZz). (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (logGI x z) *) apply/eqP; rewrite eqn_leq andbC dvdGI_leq_log ?dvdGI_mull ?dvdGIxx //. (* Goal: is_true (andb true (leq (logGI x (@GRing.mul GI_ringType y z)) (logGI x z))) *) set k := logGI x _; have: x ^+ k %| y * z by rewrite pfactor_dvdGI. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite Gauss_dvdGIr ?coprimeGI_expl // -pfactor_dvdGI. Qed. Lemma logGIM x y z : (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) y != 0 -> z != 0 -> logGI x (y * z) = (logGI x y + logGI x z)%N. Proof. (* Goal: forall (_ : is_true (negb (@eq_op (GRing.Zmodule.eqType (GRing.Ring.zmodType GI_ringType)) y (GRing.zero (GRing.Ring.zmodType GI_ringType))))) (_ : is_true (negb (@eq_op (GRing.Zmodule.eqType (GRing.Ring.zmodType GI_ringType)) z (GRing.zero (GRing.Ring.zmodType GI_ringType))))), @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) move=> nZy nZz. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) have [Pp|/negPf PnP] := boolP (primeGI x); last by rewrite /logGI PnP. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have xlp := pfactor_coprimeGI Pp. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) case/xlp : nZy => y1 Cxy1 yE. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) case/xlp : nZz => z1 Cxz1 zE. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite {1}yE {1}zE mulrCA -mulrA -exprD !logGI_Gauss // pfactorGIK. Qed. Lemma logGIX p x n : logGI p (x ^+ n) = (n * logGI p x)%N. Proof. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) have [Pp|/negPf PnP] := boolP (primeGI p); last by rewrite /logGI PnP. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) elim: n => [|n IHn]; first by rewrite logGI1. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) have [/eqP->|nZx] := boolP (x == 0); first by rewrite expr0n logGI0 muln0. by rewrite exprS logGIM ?IHn // expf_eq0 // negb_and nZx orbT. Qed. Lemma gcdGI_mull_equiv (m n p q : GI) : (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) coprimeGI m n -> m * n = p * q -> m %= gcdGI m p * gcdGI m q. Proof. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) elim: {m}_.+1 {-2}m (ltnSn ('N m)) p q => // k IH m. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) case: (leqP ('N m) 1%N). (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite leq_eqVlt ltnS leqn0 normGI_eq0 => /orP[|/eqP-> _ p q _]; last first. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite mul0r !gcd0GI=> <-; exact: eqGIxx. (* Goal: forall (_ : is_true (negb (@eq_op (GRing.Zmodule.eqType (GRing.Ring.zmodType GI_ringType)) y (GRing.zero (GRing.Ring.zmodType GI_ringType))))) (_ : is_true (negb (@eq_op (GRing.Zmodule.eqType (GRing.Ring.zmodType GI_ringType)) z (GRing.zero (GRing.Ring.zmodType GI_ringType))))), @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) move=> H _ p q _ _. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have G : m %= 1 by rewrite /eqGI dvd1GI dvdGI1 H. have G1 : gcdGI m p %= 1. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite (eqGI_trans (gcdGIC _ _)) // -(gcdGI1 p) eqGI_gcdr. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have G2 : gcdGI m q %= 1. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) by rewrite (eqGI_trans (gcdGIC _ _)) // -(gcdGI1 q) eqGI_gcdr. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (logGI x z) *) apply: eqGI_trans (G) _; rewrite eqGI_sym. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite (eqGI_trans _ G1) // -[X in _ %= X]mulr1 eqGI_mul2l //. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by apply/eqP=> HH; move/eqGI_norm : G1; rewrite normGI1 HH normGI0. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) have [/eqP-> Nx _ p q|nZn] := boolP (n == 0). (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite /coprimeGI gcdGI0; case: ('N _) Nx => // [[]]. (* Goal: forall (_ : is_true (negb (@eq_op (GRing.Zmodule.eqType (GRing.Ring.zmodType GI_ringType)) y (GRing.zero (GRing.Ring.zmodType GI_ringType))))) (_ : is_true (negb (@eq_op (GRing.Zmodule.eqType (GRing.Ring.zmodType GI_ringType)) z (GRing.zero (GRing.Ring.zmodType GI_ringType))))), @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) move=> OLNm MnL1 p q Cmn. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) have nZm : m != 0 by rewrite -normGI_eq0; case: ('N _) OLNm. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) have [/eqP->/eqP|nZp] := boolP (p == 0). (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite mul0r mulf_eq0 (negPf nZm) (negPf nZn). (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) have [/eqP->/eqP|nZq] := boolP (q == 0). (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite mulr0 mulf_eq0 (negPf nZm) (negPf nZn). pose v := pdivGI m. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have Pv : primeGI v := pdivGI_prime OLNm. (* Goal: forall (_ : is_true (negb (@eq_op (GRing.Zmodule.eqType (GRing.Ring.zmodType GI_ringType)) y (GRing.zero (GRing.Ring.zmodType GI_ringType))))) (_ : is_true (negb (@eq_op (GRing.Zmodule.eqType (GRing.Ring.zmodType GI_ringType)) z (GRing.zero (GRing.Ring.zmodType GI_ringType))))), @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) move=> mnE. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have logE : logGI v m = (logGI v p + logGI v q)%N. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite -logGIM // -mnE mulrC logGI_Gauss //. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite coprimeGI_sym (coprimeGI_dvdr (pdivGI_dvd _)) // coprimeGI_sym. (* Goal: forall (_ : is_true (negb (@eq_op (GRing.Zmodule.eqType (GRing.Ring.zmodType GI_ringType)) y (GRing.zero (GRing.Ring.zmodType GI_ringType))))) (_ : is_true (negb (@eq_op (GRing.Zmodule.eqType (GRing.Ring.zmodType GI_ringType)) z (GRing.zero (GRing.Ring.zmodType GI_ringType))))), @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) move: mnE MnL1. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) have [p1 Cp1dm1 ->] := pfactor_coprimeGI Pv nZp. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) have [q1 Cq1dm1 ->] := pfactor_coprimeGI Pv nZq. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite mulrAC !mulrA -mulrA -exprD addnC. move/eqP; move: OLNm Cmn. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) have [m1 Cpdm1 -> OLNm Cmn] := pfactor_coprimeGI Pv nZm. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite -logE [_ * n]mulrAC -subr_eq0 -mulrBl mulf_eq0 subr_eq0. (* Goal: forall (_ : @eq bool (@in_mem GI a (@mem GI (seq_predType eqGIType) (@cons GI a l))) (andb (primeGI a) (andb (negb (@eq_op eqGIType (@GRing.exp GI_ringType p (S k)) (GRing.zero GI_zmodType))) (dvdGI a (@GRing.exp GI_ringType p (S k)))))) (_ : is_true (@in_mem GI p (@mem GI (seq_predType eqGIType) (@cons GI a l)))), is_true (eqGI a p) *) rewrite expf_eq0 (negPf (primeGI_neq0 Pv)) andbF orbF => /eqP mnE mL. rewrite logE !exprD {2}[_ ^+ _ * _]mulrC !mulrA. set u1 := _ ^+ _; set u2 := _ ^+ _. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have F1 : m1 %= gcdGI m1 p1 * gcdGI m1 q1. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) apply: IH => //; last first. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by move: Cmn; rewrite coprimeGI_mull => /andP[]. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite -ltnS (leq_trans _ mL) // ltnS normGIM normGIX. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite -{1}['N m1]muln1 ltn_mul2l -{2}(expn0 ('N v)) ltn_exp2l //. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite logGI_gt0 mem_primesGI Pv nZm pdivGI_dvd. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by move: OLNm; rewrite normGIM; case: ('N _). (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by case/primeGIP: Pv. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have F2 : gcdGI (m1 * u2) p1 %= gcdGI m1 p1. (* Goal: @eq bool (eqGI (gcdGI p x) (GRing.one GI_ringType)) false *) apply: eqGI_trans (gcdGIC _ _) _. (* Goal: @eq bool (eqGI (gcdGI p x) (GRing.one GI_ringType)) false *) apply: eqGI_trans (Gauss_gcdGIl _ _) _ => //. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite coprimeGI_expr // coprimeGI_sym. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by apply: gcdGIC. (* Goal: @eq nat (logGI x (@GRing.mul GI_ringType y z)) (addn (logGI x y) (logGI x z)) *) have F3 : gcdGI (m1 * u1) q1 %= gcdGI m1 q1. (* Goal: @eq bool (eqGI (gcdGI p x) (GRing.one GI_ringType)) false *) apply: eqGI_trans (gcdGIC _ _) _. (* Goal: @eq bool (eqGI (gcdGI p x) (GRing.one GI_ringType)) false *) apply: eqGI_trans (Gauss_gcdGIl _ _) _ => //. by rewrite coprimeGI_expr // coprimeGI_sym. (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by apply: gcdGIC. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite -mulrA. (* Goal: @eq bool (eqGI (gcdGI p x) (GRing.one GI_ringType)) false *) apply: eqGI_trans (eqGI_mul F1 (eqGIxx _)) _. (* Goal: is_true (leq (normGI (divGI x p)) m2) *) (* Goal: is_true (negb (@eq_op eqGIType (divGI x p) (GRing.zero GI_zmodType))) *) rewrite mulrCA !mulrA [u1 * _]mulrC -mulrA. (* Goal: @eq bool (eqGI (gcdGI p x) (GRing.one GI_ringType)) false *) apply: eqGI_mul. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite eqGI_sym. (* Goal: @eq bool (eqGI (gcdGI p x) (GRing.one GI_ringType)) false *) apply: eqGI_trans (eqGI_mul F2 (eqGIxx _)). (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite eqGI_sym mulGI_gcdl. (* Goal: forall _ : is_true (@in_mem GI p (@mem (Equality.sort eqGIType) (seq_predType eqGIType) (primesGI (@GRing.exp GI_ringType p (S k))))), is_true (eqGI (pdivGI (@GRing.exp GI_ringType p (S k))) p) *) rewrite eqGI_sym. (* Goal: @eq bool (eqGI (gcdGI p x) (GRing.one GI_ringType)) false *) apply: eqGI_trans (eqGI_mul F3 (eqGIxx _)). (* Goal: @eq nat (logGI p (@GRing.exp GI_ringType x (S n))) (muln (S n) (logGI p x)) *) by rewrite eqGI_sym mulGI_gcdl. Qed. End GaussIntegers. Delimit Scope GI_scope with GI. Notation "'N x" := (normGI x%R) (at level 10) : GI_scope. Notation " x %| y " := (dvdGI x y) : GI_scope. Notation " x %/ y " := (divGI x y) : GI_scope. Notation " x %% y " := (modGI x y) : GI_scope. Notation " x %= y " := (eqGI x y) : GI_scope. (* End of exercices *)
From mathcomp Require Import all_ssreflect all_algebra all_field. Require Import gauss_int. Set Implicit Arguments. Unset Strict Implicit. Unset Printing Implicit Defensive. Import GRing.Theory Num.Theory UnityRootTheory. Open Scope nat_scope. Definition sum_of_two_square := [qualify a x | [exists a : 'I_x.+1, exists b : 'I_x.+1, x == a ^ 2 + b ^ 2]]. Lemma sum2sP x : reflect (exists m, exists n, x = m ^ 2 + n ^ 2) (x \is a sum_of_two_square). Proof. (* Goal: is_true (primeGI (@GRing.natmul (GRing.Ring.zmodType GI_ringType) (GRing.one GI_ringType) p)) *) (* Goal: is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) apply: (iffP existsP) => [[m /existsP[n /eqP->]]|[m [n ->]]]. (* Goal: forall _ : is_true (@eq_op nat_eqType (modn n d) (modn m d)), is_true (@eq_op nat_eqType (modn (muln (modn (F i) d) n) d) (modn (muln (F i) m) d)) *) by exists m; exists n. have F1 : m < (m ^ 2 + n ^ 2).+1. (* Goal: forall _ : is_true (dvdn p (absz (floorC (@Im Algebraics.Implementation.numClosedFieldType (algGI (conjGI z)))))), is_true (andb true (dvdn p b)) *) rewrite ltnS (leq_trans _ (leq_addr _ _)) //. (* Goal: forall _ : is_true (@eq_op nat_eqType (modn n d) (modn m d)), is_true (@eq_op nat_eqType (modn (muln (modn (F i) d) n) d) (modn (muln (F i) m) d)) *) by case: m => [|[|m]] //; rewrite (leq_exp2l 1). have F2 : n < (m ^ 2 + n ^ 2).+1. (* Goal: forall _ : is_true (dvdn p (absz (floorC (@Im Algebraics.Implementation.numClosedFieldType (algGI (conjGI z)))))), is_true (andb true (dvdn p b)) *) rewrite ltnS (leq_trans _ (leq_addl _ _)) //. (* Goal: forall _ : is_true (@eq_op nat_eqType (modn n d) (modn m d)), is_true (@eq_op nat_eqType (modn (muln (modn (F i) d) n) d) (modn (muln (F i) m) d)) *) by case: (n) => [|[|n1]] //; rewrite (leq_exp2l 1). (* Goal: forall _ : is_true (@eq_op nat_eqType (modn n d) (modn m d)), is_true (@eq_op nat_eqType (modn (muln (modn (F i) d) n) d) (modn (muln (F i) m) d)) *) by exists (Ordinal F1); apply/existsP; exists (Ordinal F2). Qed. Fact sum2s0 : 0 \is a sum_of_two_square. Proof. by apply/sum2sP; exists 0; exists 0. Qed. Fact sum2s1 : 1 \is a sum_of_two_square. Proof. by apply/sum2sP; exists 0; exists 1. Qed. Fact sum2s2 : 2 \is a sum_of_two_square. Proof. by apply/sum2sP; exists 1; exists 1. Qed. Fact sum2sX_even x n : (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) ~~ odd n -> x ^ n \is a sum_of_two_square. Proof. (* Goal: forall _ : is_true (negb (odd n)), is_true (@in_mem nat (expn x n) (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) move=> En; apply/sum2sP; exists (x ^ n./2); exists 0. (* Goal: forall _ : is_true (@eq_op nat_eqType (modn n d) (modn m d)), is_true (@eq_op nat_eqType (modn (muln (modn (F i) d) n) d) (modn (muln (F i) m) d)) *) by rewrite addn0 -{1}[n]odd_double_half (negPf En) -expnM muln2. Qed. Lemma sum2sGP x : reflect (exists m : GI, x = normGI m) (x \is a sum_of_two_square). Proof. (* Goal: is_true (primeGI (@GRing.natmul (GRing.Ring.zmodType GI_ringType) (GRing.one GI_ringType) p)) *) (* Goal: is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) apply: (iffP idP) => [/sum2sP[m [n ->]]|[x1->]]. (* Goal: @ex GI (fun m0 : GI => @eq nat (addn (expn m (S (S O))) (expn n (S (S O)))) (normGI m0)) *) (* Goal: is_true (@in_mem nat (normGI x1) (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) exists (m%:R + iGI * n%:R)%R. by rewrite normGIE /= !algGI_nat Re_rect ?Im_rect ?CrealE ?conjC_nat ?natCK // !normr_nat !natCK. (* Goal: is_true (@in_mem nat (normGI x1) (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) rewrite normGIE; set m := truncC _; set n := truncC _. (* Goal: forall _ : is_true (@eq_op nat_eqType (modn n d) (modn m d)), is_true (@eq_op nat_eqType (modn (muln (modn (F i) d) n) d) (modn (muln (F i) m) d)) *) by apply/sum2sP; exists m; exists n. Qed. Lemma sum2sM x y : (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) x \is a sum_of_two_square -> (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) y \is a sum_of_two_square -> x * y \is a sum_of_two_square. Proof. (* Goal: forall _ : is_true (@in_mem nat x (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))), is_true (@in_mem nat (expn x n) (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) move=> /sum2sGP[x1->] /sum2sGP[y1->]; rewrite -normGIM. (* Goal: forall _ : is_true (@eq_op nat_eqType (modn n d) (modn m d)), is_true (@eq_op nat_eqType (modn (muln (modn (F i) d) n) d) (modn (muln (F i) m) d)) *) by apply/sum2sGP; exists (x1 * y1)%R. Qed. Lemma sum2s_dvd_prime p a b : (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) prime p -> coprime a b -> (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) p %| a ^ 2 + b ^ 2 -> p \is a sum_of_two_square. Proof. (* Goal: forall (_ : is_true (prime p)) (_ : is_true (coprime a b)) (_ : is_true (dvdn p (addn (expn a (S (S O))) (expn b (S (S O)))))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) move=> Pp Cab pDab. (* Goal: is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) have /dvdGI_norm := pdivGI_dvd (p%:R); set x := pdivGI _. (* Goal: is_true (andb true (dvdn p b)) *) have Px : primeGI x. (* Goal: is_true (primeGI x) *) (* Goal: forall _ : is_true (dvdn (normGI x) (normGI (@GRing.natmul (GRing.Ring.zmodType GI_ringType) (GRing.one GI_ringType) p))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) apply: pdivGI_prime; rewrite normGI_nat. (* Goal: forall _ : is_true (@eq_op nat_eqType (modn n d) (modn m d)), is_true (@eq_op nat_eqType (modn (muln (modn (F i) d) n) d) (modn (muln (F i) m) d)) *) by rewrite -{1}(expn0 p) ltn_exp2l // prime_gt1. (* Goal: forall _ : is_true (dvdn p (absz (floorC (@Re Algebraics.Implementation.numClosedFieldType (algGI (conjGI z)))))), is_true (andb (dvdn p a) (dvdn p b)) *) rewrite (normGI_nat p)=> /(dvdn_pfactor _ _ Pp)=> [[[|[|[]]]]] _ //. (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) - by move=> H; case/andP: Px; rewrite H ltnn. (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) - by rewrite expn1=> H; apply/sum2sGP; exists x. (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) rewrite -normGI_nat => H1. (* Goal: is_true (andb true (dvdn p b)) *) have PGIp : primeGI (p%:R). (* Goal: is_true (primeGI (@GRing.natmul (GRing.Ring.zmodType GI_ringType) (GRing.one GI_ringType) p)) *) (* Goal: is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) apply: eqGI_prime Px. (* Goal: forall _ : is_true (@eq_op nat_eqType (modn n d) (modn m d)), is_true (@eq_op nat_eqType (modn (muln (modn (F i) d) n) d) (modn (muln (F i) m) d)) *) by apply: dvdGI_eq_norm (pdivGI_dvd _). (* Goal: is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) pose z := (a%:R + iGI * b%:R)%R. (* Goal: is_true (andb true (dvdn p b)) *) have F : ('N z)%GI = a ^ 2 + b ^ 2. by rewrite normGIE /= !algGI_nat !(Re_rect, Im_rect) ?Creal_Cnat // !normr_nat !natCK. (* Goal: is_true (andb true (dvdn p b)) *) have F1 : (p%:R %| z * conjGI z)%GI%R. (* Goal: forall _ : is_true (dvdn p (absz (floorC (@Im Algebraics.Implementation.numClosedFieldType (algGI (conjGI z)))))), is_true (andb true (dvdn p b)) *) rewrite conjGIM_norm F. (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) case/dvdnP: pDab => q1 ->. (* Goal: forall _ : is_true (@eq_op nat_eqType (modn n d) (modn m d)), is_true (@eq_op nat_eqType (modn (muln (modn (F i) d) n) d) (modn (muln (F i) m) d)) *) by apply/dvdGIP; exists (q1%:R); rewrite natrM. (* Goal: is_true (andb true (dvdn p b)) *) have []: ~ (p %| gcdn a b). (* Goal: forall _ : is_true (@eq_op nat_eqType (modn n d) (modn m d)), is_true (@eq_op nat_eqType (modn (muln (modn (F i) d) n) d) (modn (muln (F i) m) d)) *) by rewrite (eqP Cab) Euclid_dvd1. (* Goal: forall _ : is_true (dvdn p (absz (floorC (@Im Algebraics.Implementation.numClosedFieldType (algGI (conjGI z)))))), is_true (andb true (dvdn p b)) *) rewrite dvdn_gcd. (* Goal: is_true (andb true (dvdn p b)) *) have [F2|] := boolP (p%:R %| z)%GI. (* Goal: is_true (andb true (dvdn p b)) *) have := dvdGI_nat_dvdz_Re F2. rewrite Re_rect /= algGI_nat ?Creal_Cnat //= (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (intCK (Posz a)) /= => ->. (* Goal: is_true (andb true (dvdn p b)) *) have := dvdGI_nat_dvdz_Im F2. by rewrite Im_rect /= algGI_nat ?Creal_Cnat //= (intCK (Posz b)). (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) rewrite -primeGI_coprime // => HH. (* Goal: is_true (andb true (dvdn p b)) *) have F2 : (p%:R %| conjGI z)%GI. (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) by rewrite -(Gauss_dvdGIr _ HH). (* Goal: is_true (andb true (dvdn p b)) *) have := dvdGI_nat_dvdz_Re F2. rewrite Re_conj Re_rect /= algGI_nat ?Creal_Cnat //= (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (intCK (Posz a)) => ->. (* Goal: is_true (andb true (dvdn p b)) *) have := dvdGI_nat_dvdz_Im F2. (* Goal: forall _ : is_true (dvdn p (absz (floorC (@Im Algebraics.Implementation.numClosedFieldType (algGI (conjGI z)))))), is_true (andb true (dvdn p b)) *) rewrite Im_conj Im_rect /= algGI_nat ?Creal_Cnat //=. (* Goal: forall _ : is_true (@eq_op nat_eqType (modn n d) (modn m d)), is_true (@eq_op nat_eqType (modn (muln (modn (F i) d) n) d) (modn (muln (F i) m) d)) *) by rewrite floorCN ?Cint_Cnat // abszN (intCK (Posz b)). Qed. Lemma sum2sX x n : (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) x \is a sum_of_two_square -> x ^ n \is a sum_of_two_square. Proof. (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) move=>/sum2sGP[x1->]; rewrite -normGIX. (* Goal: forall _ : is_true (@eq_op nat_eqType (modn n d) (modn m d)), is_true (@eq_op nat_eqType (modn (muln (modn (F i) d) n) d) (modn (muln (F i) m) d)) *) by apply/sum2sGP; exists (x1 ^+ n)%R. Qed. Lemma sum2sX_prime x n : (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) prime x -> odd n -> (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) x ^ n \is a sum_of_two_square -> x \is a sum_of_two_square. Proof. (* Goal: forall (_ : is_true (prime p)) (_ : is_true (coprime a b)) (_ : is_true (dvdn p (addn (expn a (S (S O))) (expn b (S (S O)))))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) move=> Px On /sum2sP[a [b adE]]. (* Goal: is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) pose u := gcdn a b. (* Goal: is_true (andb true (dvdn p b)) *) have /(dvdn_pfactor _ _ Px)[m] : u ^ 2 %| x ^ n. (* Goal: forall _ : is_true (@eq_op nat_eqType (modn n d) (modn m d)), is_true (@eq_op nat_eqType (modn (muln (modn (F i) d) n) d) (modn (muln (F i) m) d)) *) by rewrite adE dvdn_add // dvdn_exp2r ?(dvdn_gcdr, dvdn_gcdl). (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) rewrite leq_eqVlt => /orP[/eqP->|nLM] uE. move: On; have := congr1 (logn x) uE. (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) rewrite (pfactorK _ Px) lognX => <-. (* Goal: forall _ : is_true (@eq_op nat_eqType (modn n d) (modn m d)), is_true (@eq_op nat_eqType (modn (muln (modn (F i) d) n) d) (modn (muln (F i) m) d)) *) by rewrite mul2n odd_double. (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) have /(sum2s_dvd_prime _ _)->//: x %| (a %/ u) ^ 2 + (b %/ u) ^ 2. (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) apply/dvdnP; exists (x^(n-m).-1); apply/eqP. (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) rewrite -expnSr prednK ?subn_gt0 //. (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) have/eqn_pmul2r<- : (0 < x ^ m) by rewrite expn_gt0 prime_gt0. (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) by rewrite -{1}uE mulnDl -!expnMn -expnD subnK 1?ltnW // !divnK ?(adE, dvdn_gcdr, dvdn_gcdl). (* Goal: forall _ : is_true (dvdn p (absz (floorC (@Im Algebraics.Implementation.numClosedFieldType (algGI (conjGI z)))))), is_true (andb true (dvdn p b)) *) rewrite /coprime. (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) have/eqn_pmul2r<- : (0 < u). (* Goal: is_true (andb true (dvdn p b)) *) have: (0 < u ^ 2) by rewrite uE expn_gt0 prime_gt0. (* Goal: forall _ : is_true (@eq_op nat_eqType (modn n d) (modn m d)), is_true (@eq_op nat_eqType (modn (muln (modn (F i) d) n) d) (modn (muln (F i) m) d)) *) by case: (u). (* Goal: forall _ : is_true (@eq_op nat_eqType (modn n d) (modn m d)), is_true (@eq_op nat_eqType (modn (muln (modn (F i) d) n) d) (modn (muln (F i) m) d)) *) by rewrite muln_gcdl mul1n !divnK ?(adE, dvdn_gcdr, dvdn_gcdl). Qed. Lemma sum2sM_coprime x y : (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) coprime x y -> (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) x * y \is a sum_of_two_square -> x \is a sum_of_two_square. Proof. (* Goal: forall (_ : is_true (prime p)) (_ : is_true (coprime a b)) (_ : is_true (dvdn p (addn (expn a (S (S O))) (expn b (S (S O)))))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) move=> Cxy /sum2sGP[z Hz]. (* Goal: is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) pose t := gcdGI (x%:R) z. apply/sum2sGP; exists t. (* Goal: is_true (primeGI (@GRing.natmul (GRing.Ring.zmodType GI_ringType) (GRing.one GI_ringType) p)) *) (* Goal: is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) apply: eqGI_nat. (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) rewrite -conjGIM_norm. (* Goal: is_true (primeGI (@GRing.natmul (GRing.Ring.zmodType GI_ringType) (GRing.one GI_ringType) p)) *) (* Goal: is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) apply: eqGI_trans (_ : eqGI (t * gcdGI (x%:R) (conjGI z))%R _). (* Goal: is_true (primeGI (@GRing.natmul (GRing.Ring.zmodType GI_ringType) (GRing.one GI_ringType) p)) *) (* Goal: is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) apply: gcdGI_mull_equiv (coprimeGI_nat Cxy) _. (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) by rewrite -natrM Hz conjGIM_norm. (* Goal: is_true (primeGI (@GRing.natmul (GRing.Ring.zmodType GI_ringType) (GRing.one GI_ringType) p)) *) (* Goal: is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) apply: eqGI_mul (eqGIxx _) _. (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) by rewrite -conjGI_nat eqGI_sym conjGI_gcd. Qed. Lemma modn_prod I r (P : pred I) F d : (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) \prod_(i <- r | P i) (F i %% d) = \prod_(i <- r | P i) F i %[mod d]. Proof. (* Goal: @eq nat (modn (@BigOp.bigop nat I (S O) r (fun i : I => @BigBody nat I i muln (P i) (modn (F i) d))) d) (modn (@BigOp.bigop nat I (S O) r (fun i : I => @BigBody nat I i muln (P i) (F i))) d) *) apply/eqP; elim/big_rec2: _ => // i m n _. (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) by rewrite modnMml -modnMmr => /eqP->; rewrite modnMmr. Qed. Lemma sum2sprime p : (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) odd p -> prime p -> p \is a sum_of_two_square = (p %% 4 == 1). Proof. move=> Op Pp; apply/idP/idP=>[/sum2sP[a [b H]]|pM4]. (* Goal: is_true (andb true (dvdn p b)) *) have F c : (c ^ 2 %% 4 == 0) || (c ^ 2 %% 4 == 1). (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) rewrite -modnXm expnS expn1. (* Goal: forall _ : is_true (@eq_op nat_eqType (modn n d) (modn m d)), is_true (@eq_op nat_eqType (modn (muln (modn (F i) d) n) d) (modn (muln (F i) m) d)) *) by move: (c %% 4) (ltn_pmod c (isT: 0 < 4)); do 4 case => //. (* Goal: is_true (andb true (dvdn p b)) *) have : (p %% 4 == 1) || (p %% 4 == 3). (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) rewrite -[p]odd_double_half Op -modnDmr -muln2. (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) have /(_ _ 2)<- := muln_modl (isT: 0 < 2). (* Goal: forall _ : is_true (@eq_op nat_eqType (modn n d) (modn m d)), is_true (@eq_op nat_eqType (modn (muln (modn (F i) d) n) d) (modn (muln (F i) m) d)) *) by move: (_ %% 2) (ltn_pmod p./2 (isT: 0 < 2)); do 2 case => //. (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) rewrite H -modnDm. (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) by move: (F a) (F b) => /orP[] /eqP-> /orP[] /eqP->. (* Goal: is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) pose k := p %/ 4. (* Goal: is_true (andb true (dvdn p b)) *) have p_gt0 := prime_gt0 Pp. (* Goal: is_true (andb true (dvdn p b)) *) have p_gt1 := prime_gt1 Pp. (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) have : (p.-1)`!.+1 %% p == 0 by rewrite -[_ == 0]Wilson. (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) have : \prod_(1 <= i < (k * 2).+1) (p - 1) = 1 %[mod p]. (* Goal: forall _ : is_true (dvdn p (absz (floorC (@Im Algebraics.Implementation.numClosedFieldType (algGI (conjGI z)))))), is_true (andb true (dvdn p b)) *) rewrite prod_nat_const_nat !subn1 /= mulnC expnM. (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) rewrite -modnXm expnS expn1. (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) rewrite -[_ * _ %% _]modnDr -{3}[p]prednK -addn1 //. (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) by rewrite addnA -mulnSr prednK // modnMDl modnXm exp1n. (* Goal: is_true (andb true (dvdn p b)) *) have pE : p = (k * 4).+1 by rewrite (divn_eq p 4) (eqP pM4) addn1. (* Goal: forall _ : is_true (dvdn p (absz (floorC (@Re Algebraics.Implementation.numClosedFieldType (algGI (conjGI z)))))), is_true (andb (dvdn p a) (dvdn p b)) *) rewrite pE => F. (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) have [/eqP-> _|] := boolP (k == 0); first exact: sum2s1. (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) rewrite -leqn0 -ltnNge => Pk. rewrite fact_prod (big_cat_nat _ _ _ (_ : 1 <= (k * 2).+1)) //=; last first. (* Goal: forall _ : is_true (@eq_op nat_eqType (modn n d) (modn m d)), is_true (@eq_op nat_eqType (modn (muln (modn (F i) d) n) d) (modn (muln (F i) m) d)) *) by rewrite ltnS leq_mul2l orbT. set S1 := \prod_(_ <= _ < _ ) _. (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) rewrite -addn1 -modnDml -modnMmr big_nat_rev /=. (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) rewrite -[(k * 2).+1]add1n big_addn. (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) rewrite subSn ?leq_pmul2l // -mulnBr /=. set S2 := \prod_(_ <= _ < _ ) _. (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) rewrite -[S2]muln1 -[S2 * 1 %% _]modnMmr -{}F. (* Goal: forall _ : is_true (dvdn p (absz (floorC (@Im Algebraics.Implementation.numClosedFieldType (algGI (conjGI z)))))), is_true (andb true (dvdn p b)) *) rewrite [S2 * _ %% _]modnMmr. (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) rewrite -[S2 * _]big_split /=. set S3 := \prod_(_ <= _ < _ ) _. (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) suff ->: S3 = S1 %[mod (k * 4).+1]. (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) rewrite modnMmr modnDml -{1}[S1]expn1 -expnSr -[S1]fact_prod. (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) rewrite -pE -{3}[1](exp1n 2) => /sum2s_dvd_prime-> //. (* Goal: forall _ : is_true (@eq_op nat_eqType (modn n d) (modn m d)), is_true (@eq_op nat_eqType (modn (muln (modn (F i) d) n) d) (modn (muln (F i) m) d)) *) by rewrite coprimen1. (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) rewrite -modn_prod -[in RHS]modn_prod. (* Goal: forall _ : is_true (dvdn p (absz (floorC (@Im Algebraics.Implementation.numClosedFieldType (algGI (conjGI z)))))), is_true (andb true (dvdn p b)) *) rewrite big_nat_cond [in RHS]big_nat_cond. congr (_ %% _). (* Goal: is_true (primeGI (@GRing.natmul (GRing.Ring.zmodType GI_ringType) (GRing.one GI_ringType) p)) *) (* Goal: is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) apply: eq_bigr => i /andP[/andP[H1 H2] _]. (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) rewrite add1n addnC -addnS [i + _]addnC subnDA addnK. (* Goal: is_true (andb true (dvdn p b)) *) have H3 : i <= (k * 4).+1. (* Goal: forall _ : is_true (@eq_op nat_eqType (modn n d) (modn m d)), is_true (@eq_op nat_eqType (modn (muln (modn (F i) d) n) d) (modn (muln (F i) m) d)) *) by rewrite ltnW // (leq_trans H2) // ltnS leq_pmul2l. (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) rewrite -modnDr -{3}(subnK H3) addnA -mulnSr subn1 prednK //. (* Goal: forall _ : is_true (@eq_op nat_eqType (modn n d) (modn m d)), is_true (@eq_op nat_eqType (modn (muln (modn (F i) d) n) d) (modn (muln (F i) m) d)) *) by rewrite modnMDl. Qed. (** Main theorem **) Lemma sum2stest n : reflect (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (forall p, prime p -> odd p -> p %| n -> odd (logn p n) -> p %% 4 = 1) (n \is a sum_of_two_square). Proof. (* Goal: is_true (primeGI (@GRing.natmul (GRing.Ring.zmodType GI_ringType) (GRing.one GI_ringType) p)) *) (* Goal: is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) apply: (iffP idP) => [Hs p Pp Op Dp OL|HH]. (* Goal: is_true (andb true (dvdn p b)) *) have Pn : 0 < n by case: (n) OL; rewrite ?logn0. (* Goal: is_true (andb true (dvdn p b)) *) have /(pfactor_coprime Pp)[m Cmp mE] := (Pn). (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) apply/eqP; rewrite -sum2sprime //. apply: sum2sX_prime OL _ => //. (* Goal: forall _ : is_true (dvdn p (absz (floorC (@Im Algebraics.Implementation.numClosedFieldType (algGI (conjGI z)))))), is_true (andb true (dvdn p b)) *) rewrite mE mulnC in Hs. (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) by apply: sum2sM_coprime Hs; rewrite coprime_pexpl // -pfactor_dvdn. (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) have [/eqP->|] := boolP (n == 0); first by apply:sum2s0. (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) rewrite -leqn0 -ltnNge => /prod_prime_decomp->. (* Goal: forall _ : is_true (dvdn p (absz (floorC (@Im Algebraics.Implementation.numClosedFieldType (algGI (conjGI z)))))), is_true (andb true (dvdn p b)) *) rewrite big_seq_cond /=. elim/big_rec: _ => [|i x /andP[]]. exact: sum2s1. (* Goal: forall _ : is_true (dvdn p (absz (floorC (@Re Algebraics.Implementation.numClosedFieldType (algGI (conjGI z)))))), is_true (andb (dvdn p a) (dvdn p b)) *) rewrite prime_decompE => /mapP[p]. (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) rewrite mem_primes => /and3P[Pp Pn pDn] -> _ xS /=. (* Goal: is_true (primeGI (@GRing.natmul (GRing.Ring.zmodType GI_ringType) (GRing.one GI_ringType) p)) *) (* Goal: is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) apply: sum2sM => //. have [OL|] := boolP (odd (logn p n)); last by exact: sum2sX_even. (* Goal: is_true (primeGI (@GRing.natmul (GRing.Ring.zmodType GI_ringType) (GRing.one GI_ringType) p)) *) (* Goal: is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) apply: sum2sX. (* Goal: forall _ : @eq nat (normGI x) (expn p (S O)), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) (* Goal: forall _ : @eq nat (normGI x) (expn p (S (S O))), is_true (@in_mem nat p (@mem nat (predPredType nat) (@has_quality (S O) nat sum_of_two_square))) *) have [Op|/prime_oddPn->//] := boolP (odd p); last by exact: sum2s2. (* Goal: forall _ : is_true (@eq_op nat_eqType (modn n d) (modn m d)), is_true (@eq_op nat_eqType (modn (muln (modn (F i) d) n) d) (modn (muln (F i) m) d)) *) by rewrite sum2sprime // HH. Qed.
(** * Coq codes *) (** ** Dependencies *) Require Export RegExp.Utility. Require Export RegExp.Definitions. (** ** [Empty] *) (** [Empty] corresponds to 0 in Kleene algebra. *) Lemma Empty_false : forall s, Empty ~!= s. Proof. (* Goal: forall (s : string) (r : RegExp), @eq bool (matches (Or Empty r) s) (matches r s) *) induction s. (* Goal: forall r : RegExp, @eq bool (nu r) (nu r) *) (* Goal: forall r : RegExp, @eq bool (matches (Or Empty r) (String a s)) (matches r (String a s)) *) reflexivity. (* Goal: forall r : RegExp, @eq bool (matches (Or Empty r) (String a s)) (matches r (String a s)) *) simpl. apply IHs. Qed. (** ** [Eps] *) (** [Eps] corresponds to 1 in Kleene algebra. *) Lemma Eps_true : Eps ~== EmptyString. Proof. (* Goal: forall r : RegExp, @eq bool (nu r) (nu r) *) (* Goal: forall r : RegExp, @eq bool (matches (Or Empty r) (String a s)) (matches r (String a s)) *) simpl. reflexivity. Qed. Lemma Eps_false : forall s, s <> ""%string -> Eps ~!= s. Proof. (* Goal: forall (s : string) (r : RegExp), @eq bool (matches (Or Empty r) s) (matches r s) *) induction s. (* Goal: forall _ : not (@eq string EmptyString EmptyString), @eq bool (matches Eps EmptyString) false *) (* Goal: forall _ : not (@eq string (String a s) EmptyString), @eq bool (matches Eps (String a s)) false *) intro Hs. elim Hs. auto. (* Goal: forall r : RegExp, @eq bool (matches (Or Empty r) (String a s)) (matches r (String a s)) *) intro Has. simpl. eapply Empty_false. Qed. (** ** Boolean operations on [RegExp] are morphism. *) (** [Or] corresponds to plus in Kleene algebra. *) Add Parametric Morphism : Or with signature re_eq ==> re_eq ==> re_eq as Or_morphism. Proof. (* Goal: forall (x y : RegExp) (_ : re_eq x y) (x0 y0 : RegExp) (_ : re_eq x0 y0), re_eq (And x x0) (And y y0) *) intros x y H x0 y0 H0. unfold re_eq in *. intro s. (* Goal: @eq bool (matches (Not x) s) (matches (Not y) s) *) generalize dependent x. generalize dependent y. (* Goal: forall (y x : RegExp) (_ : forall s : string, @eq bool (matches x s) (matches y s)), @eq bool (matches (And x x0) s) (matches (And y y0) s) *) generalize dependent x0. generalize dependent y0. (* Goal: forall (s : string) (r : RegExp), @eq bool (matches (Or Empty r) s) (matches r s) *) induction s. (* s = "" *) (* Goal: forall (y0 x0 : RegExp) (_ : forall s : string, @eq bool (matches x0 s) (matches y0 s)) (y x : RegExp) (_ : forall s : string, @eq bool (matches x s) (matches y s)), @eq bool (matches (And (derive a x) (derive a x0)) s) (matches (And (derive a y) (derive a y0)) s) *) intros y0 x0 H0 y x H. specialize (H0 ""%string). specialize (H ""%string). (* Goal: forall r : RegExp, @eq bool (nu r) (nu r) *) (* Goal: forall r : RegExp, @eq bool (matches (Or Empty r) (String a s)) (matches r (String a s)) *) simpl in *. rewrite <- H0. rewrite <- H. reflexivity. (* s = String a s *) (* Goal: forall r : RegExp, @eq bool (matches (Or Empty r) (String a s)) (matches r (String a s)) *) simpl. intros y0 x0 H0 y x H. eapply IHs. (* Goal: forall r : RegExp, re_eq (Or r Empty) r *) intros. repeat rewrite <- derivation. eapply H0. (* Goal: forall r : RegExp, re_eq (Or r Empty) r *) intros. repeat rewrite <- derivation. eapply H. Qed. Add Parametric Morphism : And with signature re_eq ==> re_eq ==> re_eq as And_morphism. Proof. (* Goal: forall (x y : RegExp) (_ : re_eq x y) (x0 y0 : RegExp) (_ : re_eq x0 y0), re_eq (And x x0) (And y y0) *) intros x y H x0 y0 H0. unfold re_eq in *. intros s. (* Goal: @eq bool (matches (Not x) s) (matches (Not y) s) *) generalize dependent x. generalize dependent y. (* Goal: forall (y x : RegExp) (_ : forall s : string, @eq bool (matches x s) (matches y s)), @eq bool (matches (And x x0) s) (matches (And y y0) s) *) generalize dependent x0. generalize dependent y0. (* Goal: forall (s : string) (r : RegExp), @eq bool (matches (Or Empty r) s) (matches r s) *) induction s. (* s = "" *) (* Goal: forall (y0 x0 : RegExp) (_ : forall s : string, @eq bool (matches x0 s) (matches y0 s)) (y x : RegExp) (_ : forall s : string, @eq bool (matches x s) (matches y s)), @eq bool (matches (And (derive a x) (derive a x0)) s) (matches (And (derive a y) (derive a y0)) s) *) intros y0 x0 H0 y x H. specialize (H0 ""%string). specialize (H ""%string). (* Goal: forall r : RegExp, @eq bool (nu r) (nu r) *) (* Goal: forall r : RegExp, @eq bool (matches (Or Empty r) (String a s)) (matches r (String a s)) *) simpl in *. rewrite <- H0. rewrite <- H. reflexivity. (* s = String a s *) (* Goal: forall r : RegExp, @eq bool (matches (Or Empty r) (String a s)) (matches r (String a s)) *) simpl. intros y0 x0 H0 y x H. eapply IHs. (* Goal: @eq bool (matches (derive a x) s0) (matches (derive a y) s0) *) intros s0. repeat rewrite <- derivation. eapply H0. (* Goal: @eq bool (matches (derive a x) s0) (matches (derive a y) s0) *) intros s0. repeat rewrite <- derivation. eapply H. Qed. Add Parametric Morphism : Not with signature re_eq ==> re_eq as Not_morphism. Proof. (* Goal: re_eq (Not x) (Not y) *) intros x y H. unfold re_eq in *. intros s. (* Goal: @eq bool (matches (Not x) s) (matches (Not y) s) *) generalize dependent x. generalize dependent y. (* Goal: forall (s : string) (r : RegExp), @eq bool (matches (Or Empty r) s) (matches r s) *) induction s. (* s = "" *) (* Goal: forall r : RegExp, @eq bool (nu r) (nu r) *) (* Goal: forall r : RegExp, @eq bool (matches (Or Empty r) (String a s)) (matches r (String a s)) *) intros y x H. specialize (H ""%string). simpl in *. rewrite <- H. reflexivity. (* s = String a s *) (* Goal: forall r : RegExp, @eq bool (matches (Or Empty r) (String a s)) (matches r (String a s)) *) simpl. intros y x H. eapply IHs. (* Goal: @eq bool (matches (derive a x) s0) (matches (derive a y) s0) *) intros s0. repeat rewrite <- derivation. eapply H. Qed. (** [matches] is a homomorphism from [RegExp] to bool for [And], [Or], and [Not]. *) Lemma matches_Or : forall s r r', r || r' ~= s = ((r ~= s) || (r' ~= s))%bool. Proof. (* Goal: forall (s : string) (r : RegExp), @eq bool (matches (Or Empty r) s) (matches r s) *) induction s. (* Goal: forall r : RegExp, @eq bool (nu r) (nu r) *) (* Goal: forall r : RegExp, @eq bool (matches (Or Empty r) (String a s)) (matches r (String a s)) *) simpl. reflexivity. (* Goal: forall r : RegExp, @eq bool (matches (Or Empty r) (String a s)) (matches r (String a s)) *) simpl. intros r r'. eapply IHs. Qed. Lemma matches_And : forall s r r', matches (And r r') s = ((r ~= s) && (r' ~= s))%bool. Proof. (* Goal: forall (s : string) (r : RegExp), @eq bool (matches (Or Empty r) s) (matches r s) *) induction s. (* Goal: forall r : RegExp, @eq bool (nu r) (nu r) *) (* Goal: forall r : RegExp, @eq bool (matches (Or Empty r) (String a s)) (matches r (String a s)) *) simpl. reflexivity. (* Goal: forall r : RegExp, @eq bool (matches (Or Empty r) (String a s)) (matches r (String a s)) *) simpl. intros. eapply IHs. Qed. Lemma matches_Not : forall s r, (Not r) ~= s = negb (r ~= s). Proof. (* Goal: forall (s : string) (r : RegExp), @eq bool (matches (Or Empty r) s) (matches r s) *) induction s. (* Goal: forall r : RegExp, @eq bool (nu r) (nu r) *) (* Goal: forall r : RegExp, @eq bool (matches (Or Empty r) (String a s)) (matches r (String a s)) *) simpl. reflexivity. (* Goal: forall r : RegExp, @eq bool (matches (Or Empty r) (String a s)) (matches r (String a s)) *) simpl. intros. eapply IHs. Qed. (** ** Axioms for [Or] *) (** Commutativity and associativity of [Or] and [And]. *) Lemma Or_comm_s : forall s r r', (r || r') ~= s = (r' || r) ~= s. Proof. (* Goal: forall (s : string) (r r' : RegExp), @eq bool (matches (Or r r') s) (matches (Or r' r) s) *) intros s r r'. repeat erewrite matches_Or. (* Goal: forall r : RegExp, @eq bool (nu r) (nu r) *) (* Goal: forall r : RegExp, @eq bool (matches (Or Empty r) (String a s)) (matches r (String a s)) *) destruct (r ~= s); destruct (r' ~= s); reflexivity. Qed. Theorem Or_comm : forall r r', r || r' =R= r' || r. Proof. (* Goal: forall r : RegExp, re_eq (Or r r) r *) unfold re_eq. intros r r' s. eapply Or_comm_s. Qed. Lemma Or_assoc_s : forall s r r' r'', ((r || r') || r'') ~= s = (r || (r' || r'')) ~= s. Proof. (* Goal: forall r : RegExp, re_eq (Or r Empty) r *) intros. repeat erewrite matches_Or. (* Goal: forall r : RegExp, @eq bool (nu r) (nu r) *) (* Goal: forall r : RegExp, @eq bool (matches (Or Empty r) (String a s)) (matches r (String a s)) *) destruct (r ~= s); destruct (r' ~= s); destruct (r'' ~= s); reflexivity. Qed. Theorem Or_assoc : forall r r' r'', (r || r') || r'' =R= r || (r' || r''). Proof. (* Goal: forall r : RegExp, re_eq (Or r r) r *) unfold re_eq. intros r r' r'' s. eapply Or_assoc_s. Qed. Lemma And_comm : forall r r', And r r' =R= And r' r. Proof. (* Goal: forall r : RegExp, re_eq (Or r r) r *) unfold re_eq. intros r r' s. repeat erewrite matches_And. (* Goal: forall r : RegExp, @eq bool (nu r) (nu r) *) (* Goal: forall r : RegExp, @eq bool (matches (Or Empty r) (String a s)) (matches r (String a s)) *) destruct (r ~= s); destruct (r' ~= s); reflexivity. Qed. Lemma And_assoc : forall r r' r'', And (And r r') r'' =R= And r (And r' r''). Proof. (* Goal: forall r : RegExp, re_eq (Or r r) r *) unfold re_eq. intros r r' r'' s. repeat erewrite matches_And. (* Goal: forall r : RegExp, @eq bool (nu r) (nu r) *) (* Goal: forall r : RegExp, @eq bool (matches (Or Empty r) (String a s)) (matches r (String a s)) *) destruct (r ~= s); destruct (r' ~= s); destruct (r'' ~= s); reflexivity. Qed. (** [Empty] is the identity element 0 for [Or]. *) Lemma Or_left_id_s : forall s r, (Empty || r) ~= s = r ~= s. Proof. (* Goal: forall (s : string) (r : RegExp), @eq bool (matches (Or Empty r) s) (matches r s) *) induction s. (* Goal: forall r : RegExp, @eq bool (nu r) (nu r) *) (* Goal: forall r : RegExp, @eq bool (matches (Or Empty r) (String a s)) (matches r (String a s)) *) simpl. reflexivity. (* Goal: forall r : RegExp, @eq bool (matches (Or Empty r) (String a s)) (matches r (String a s)) *) simpl. intros r. eapply IHs. Qed. Theorem Or_left_id : forall r, Empty || r =R= r. Proof. (* Goal: forall r : RegExp, re_eq (Or r r) r *) unfold re_eq. intros r s. eapply Or_left_id_s. Qed. Theorem Or_right_id : forall r, r || Empty =R= r. (* Goal: forall r : RegExp, re_eq (Or r Empty) r *) intros. setoid_rewrite Or_comm. (* Goal: re_eq (Or Empty r) r *) eapply Or_left_id. Qed. Corollary Or_right_id_s : forall s r, (r || Empty) ~= s = r ~= s. Proof. (* Goal: forall (s : string) (r : RegExp), @eq bool (matches (Or r r) s) (matches r s) *) intros s r. specialize Or_right_id. (* Goal: @eq bool (matches (Or r Empty) s) (matches r s) *) intros H. unfold re_eq in H. eapply H. Qed. (** [Or] is idempotent. *) Lemma Or_idem_s : forall s r, (r || r) ~= s = r ~= s. Proof. (* Goal: forall r : RegExp, @eq bool (nu r) (nu r) *) (* Goal: forall r : RegExp, @eq bool (matches (Or Empty r) (String a s)) (matches r (String a s)) *) intros s r. erewrite matches_Or. destruct (r ~= s); reflexivity. Qed. Theorem Or_idem : forall r, r || r =R= r. Proof. (* Goal: forall r : RegExp, re_eq (Or r r) r *) unfold re_eq. intros r s. eapply Or_idem_s. Qed.
(** * Coq codes *) (** ** Dependencies *) Require Export Ascii. Require Export String. Require Export List. Require Export Relation_Definitions. (** ** Equality and equivalence *) Definition bool_eq (a a':bool) : Prop := a = a'. Lemma bool_eq_equiv : equiv bool bool_eq. Proof. (* Goal: equiv string string_eq *) unfold equiv. split. (* Goal: and (transitive string string_eq) (symmetric string string_eq) *) unfold reflexive. intro. unfold bool_eq. auto. split. (* Goal: @eq bool (andb true (andb true true)) true *) unfold transitive. intros. unfold bool_eq in *. transitivity y; auto. (* Goal: @eq bool (andb true (andb true true)) true *) unfold symmetric. intros. unfold bool_eq in *. auto. Qed. Definition ascii_eq (a a':ascii) : Prop := a = a'. Lemma ascii_eq_equiv : equiv ascii ascii_eq. Proof. (* Goal: equiv string string_eq *) unfold equiv. split. (* Goal: and (transitive string string_eq) (symmetric string string_eq) *) unfold reflexive. intros. unfold ascii_eq. auto. split. (* Goal: @eq bool (andb true (andb true true)) true *) unfold transitive. intros. unfold ascii_eq in *. transitivity y; auto. (* Goal: @eq bool (andb true (andb true true)) true *) unfold symmetric. intros. unfold ascii_eq in *. auto. Qed. Definition string_eq (a a':string) : Prop := a = a'. Lemma string_eq_equiv : equiv string string_eq. Proof. (* Goal: equiv string string_eq *) unfold equiv. split. (* Goal: and (transitive string string_eq) (symmetric string string_eq) *) unfold reflexive. intros. unfold string_eq. auto. split. (* Goal: @eq bool (andb true (andb true true)) true *) unfold transitive. intros. unfold string_eq in *. transitivity y; auto. (* Goal: @eq bool (andb true (andb true true)) true *) unfold symmetric. intros. unfold string_eq in *. auto. Qed. (** ** Lemmas for string *) Lemma string_assoc : forall s s' s'':string, ((s ++ s') ++ s'')%string = (s ++ (s' ++ s''))%string. Proof. (* Goal: forall s s' s'' : string, @eq string (append (append s s') s'') (append s (append s' s'')) *) induction s; simpl. (* Goal: @eq bool (andb true (andb true true)) true *) auto. (* Goal: @eq bool (andb true (andb true true)) true *) intros s' s''. erewrite IHs. auto. Qed. Fixpoint str_length (s:string) : nat := match s with | ""%string => O | String _ s' => S (str_length s') end. Lemma str_length_append : forall s s', str_length (s ++ s')%string = str_length s + str_length s'. Proof. (* Goal: forall s : string, @eq string (append s EmptyString) s *) induction s. (* Goal: @eq bool (andb (@forallb A f xs) (@forallb A f (@cons A x (@nil A)))) true *) simpl. reflexivity. (* Goal: forall s' : string, @eq nat (S (str_length (append s s'))) (S (Nat.add (str_length s) (str_length s'))) *) simpl. intros. erewrite IHs. reflexivity. Qed. Lemma string_right_id : forall s, (s ++ "")%string = s. Proof. (* Goal: forall s : string, @eq string (append s EmptyString) s *) induction s. (* Goal: @eq bool (andb true (andb true true)) true *) auto. (* Goal: @eq bool (andb true (andb true true)) true *) simpl. erewrite IHs. auto. Qed. Definition bneq_empty_string(s:string):bool := match (string_dec s ""%string) with | left _ => false | right _ => true end. (** ** Lemmas for list *) Definition concat_list_string(xs:list string) := fold_right (fun s s' : string => (s ++ s')%string) ""%string xs. Lemma concat_list_string_x_xs : forall (x:string)(xs:list string), concat_list_string (x :: xs) = (x ++ (concat_list_string xs))%string. Proof. (* Goal: @eq bool (andb true (andb true true)) true *) induction xs; auto. Qed. Lemma concat_list_string_xs_x : forall (xs:list string)(x:string), concat_list_string (xs ++ x::nil) = ((concat_list_string xs) ++ x)%string. Proof. (* Goal: forall (xs : list string) (x : string), @eq string (concat_list_string (@app string xs (@cons string x (@nil string)))) (append (concat_list_string xs) x) *) induction xs; simpl; intro x. (* Goal: @eq bool (andb true (andb true true)) true *) erewrite string_right_id. auto. (* Goal: @eq bool (andb true (andb true true)) true *) erewrite IHxs. erewrite string_assoc. auto. Qed. Lemma In_list_append_left : forall A (a:A) l l', In a l -> In a (l ++ l')%list. Proof. (* Goal: @eq bool (andb (@forallb A f xs) (@forallb A f (@cons A x (@nil A)))) true *) induction l; simpl. (* Goal: forall (l' : list A) (_ : @In A a l'), or (@eq A a0 a) (@In A a (@app A l l')) *) intros l' H. elim H. (* Goal: forall (l' : list A) (_ : @In A a l'), or (@eq A a0 a) (@In A a (@app A l l')) *) intros l' H. destruct H as [H1 | H2]. (* Goal: @eq bool (andb true (andb true true)) true *) left; auto. (* Goal: @eq bool (andb true (andb true true)) true *) right; eapply IHl; auto. Qed. Lemma In_list_append_right : forall A (a:A) l l', In a l' -> In a (l ++ l')%list. Proof. (* Goal: @eq bool (andb (@forallb A f xs) (@forallb A f (@cons A x (@nil A)))) true *) induction l; simpl. (* Goal: @eq bool (andb true (andb true true)) true *) intros l' H. auto. (* Goal: @eq bool (andb true (andb true true)) true *) intros l' H. right. eapply IHl. auto. Qed. Lemma In_snoc : forall A (a:A) l, In a (l ++ a::nil)%list. Proof. (* Goal: @eq bool (andb (@forallb A f xs) (@forallb A f (@cons A x (@nil A)))) true *) induction l; simpl. (* Goal: @eq bool (andb true (andb true true)) true *) left; auto. (* Goal: @eq bool (andb true (andb true true)) true *) right; auto. Qed. (* Other useful lemmas are: Lemma forallb_forall : forall l, forallb l = true <-> (forall x, In x l -> f x = true). Lemma forallb_app : forall l1 l2, forallb (l1++l2) = forallb l1 && forallb l2. *) Lemma forallb_divide_left : forall (A:Type)(f:A -> bool) (l l':list A), forallb f (l ++ l') = true -> forallb f l = true. Proof. (* Goal: forall (A : Type) (f : forall _ : A, bool) (l l' : list A) (_ : @eq bool (@forallb A f (@app A l l')) true), @eq bool (@forallb A f l') true *) intros A f l l' H. erewrite forallb_app in H. (* Goal: @eq bool (@forallb A f l) true *) destruct(forallb f l). (* Goal: @eq bool (andb true (andb true true)) true *) auto. (* Goal: @eq bool false true *) destruct(forallb f l'); simpl in H; discriminate H. Qed. Lemma forallb_divide_right : forall (A:Type)(f:A -> bool) (l l':list A), forallb f (l ++ l') = true -> forallb f l' = true. Proof. (* Goal: forall (A : Type) (f : forall _ : A, bool) (l l' : list A) (_ : @eq bool (@forallb A f (@app A l l')) true), @eq bool (@forallb A f l') true *) intros A f l l' H. erewrite forallb_app in H. (* Goal: @eq bool (@forallb A f l') true *) destruct(forallb f l'). (* Goal: @eq bool true true *) (* Goal: @eq bool false true *) reflexivity. (* Goal: @eq bool false true *) destruct(forallb f l); simpl in H; discriminate H. Qed. Lemma forallb_list_x_xs : forall A (f:A -> bool)(x:A)(xs:list A), f x = true -> forallb f xs = true -> forallb f (x::xs) = true. Proof. (* Goal: forall (A : Type) (f : forall _ : A, bool) (x : A) (xs : list A) (_ : @eq bool (f x) true) (_ : @eq bool (@forallb A f xs) true), @eq bool (@forallb A f (@cons A x xs)) true *) intros A f x xs Hx Hxs. (* Goal: @eq bool (@forallb A f (@cons A x xs)) true *) replace (x :: xs) with ((x :: nil) ++ xs). (* Goal: @eq bool (andb true (andb true true)) true *) erewrite forallb_app. simpl. rewrite Hx; rewrite Hxs. auto. (* Goal: @eq bool (andb true (andb true true)) true *) simpl. auto. Qed. Lemma forallb_list_xs_x : forall A (f:A -> bool)(xs:list A)(x:A), forallb f xs = true -> f x = true -> forallb f (xs ++ x::nil)%list = true. Proof. (* Goal: forall (A : Type) (f : forall _ : A, bool) (xs : list A) (x : A) (_ : @eq bool (@forallb A f xs) true) (_ : @eq bool (f x) true), @eq bool (@forallb A f (@app A xs (@cons A x (@nil A)))) true *) intros A f xs x Hxs Hx. (* Goal: @eq bool (andb true (andb true true)) true *) erewrite forallb_app. simpl. rewrite Hx; rewrite Hxs. auto. Qed.
(** * Coq codes *) (** ** Dependencies *) Require Export RegExp.Utility. Require Export RegExp.Definitions. Require Export RegExp.Boolean. Require Export RegExp.Concat. Unset Standard Proposition Elimination Names. (** ** [Char] *) Lemma Char_true : forall c, (Char c) ~== (String c ""%string). Proof. (* Goal: forall c : ascii, @eq bool (matches (Char c) (String c EmptyString)) true *) intro c. simpl. (* Goal: @eq bool (matches (string_to_re (String a s)) (String a0 s')) false *) destruct(ascii_dec c c); simpl. (* Goal: @eq bool false false *) auto. (* Goal: @eq bool false false *) elim n. auto. Qed. Lemma Char_false : forall s c, s <> (String c ""%string) -> (Char c) ~!= s. Proof. (* Goal: forall (s s' : string) (_ : not (@eq string s s')), @eq bool (matches (string_to_re s) s') false *) induction s. (* Goal: @eq bool (matches (string_to_re (String a s)) (String a0 s')) false *) intros c Hs. simpl. auto. (* Goal: @eq bool (matches (string_to_re (String a s)) (String a0 s')) false *) induction s; intros c Hs; simpl. (* Goal: @eq bool (matches (string_to_re (String a s)) (String a0 s')) false *) destruct(ascii_dec c a); simpl. (* Goal: @eq bool false false *) rewrite e in Hs. elim Hs. auto. (* Goal: @eq bool false false *) auto. (* Goal: @eq bool (matches (string_to_re (String a s)) (String a0 s')) false *) destruct(ascii_dec c a); simpl. (* Goal: @eq bool (matches Empty s) false *) eapply Empty_false. (* Goal: @eq bool (matches Empty s) false *) eapply Empty_false. Qed. Add Parametric Morphism : Char with signature ascii_eq ==> re_eq as Char_mor. Proof. (* Goal: forall (x y : ascii) (_ : ascii_eq x y), re_eq (Char x) (Char y) *) intros x y Hxy. destruct Hxy. setoid_reflexivity. Qed. Lemma derive_Char_is_id : forall a r, derive a (Char a ++ r) =R= r. Proof. (* Goal: @eq bool (matches (string_to_re (String a s)) (String a0 s')) false *) intros a r. simpl. (* Goal: @eq bool (matches (Cat (if ascii_dec a a then Eps else Empty) (string_to_re s)) s) true *) destruct(ascii_dec a a). (* Goal: re_eq r r *) (* Goal: re_eq (Cat Empty r) r *) setoid_rewrite Cat_left_id. setoid_reflexivity. (* Goal: @eq bool false false *) elim n. auto. Qed. (** ** String *) (** For simplicity, there is no [RegExp] constructor for string; however, the conversion is easy. *) Fixpoint string_to_re (s:string):RegExp := match s with | EmptyString => Eps | String a s' => (Char a) ++ (string_to_re s') end. Lemma string_to_re_true : forall s:string, (string_to_re s) ~== s. Proof. (* Goal: forall (s s' : string) (_ : not (@eq string s s')), @eq bool (matches (string_to_re s) s') false *) induction s. (* Goal: @eq bool (matches (string_to_re (String a s)) (String a0 s')) false *) simpl. auto. (* Goal: @eq bool (matches (string_to_re (String a s)) (String a0 s')) false *) simpl. destruct(ascii_dec a a). (* Goal: @eq bool false false *) erewrite Cat_left_id_s. auto. (* Goal: @eq bool false false *) elim n. auto. Qed. Lemma string_to_re_false : forall s s':string, s <> s' -> (string_to_re s) ~!= s'. Proof. (* Goal: forall (s s' : string) (_ : not (@eq string s s')), @eq bool (matches (string_to_re s) s') false *) induction s. (* Goal: @eq bool (matches (string_to_re (String a s)) (String a0 s')) false *) intros s' Hs. simpl. eapply Eps_false. auto. (* Goal: forall (s' : string) (_ : not (@eq string (String a s) s')), @eq bool (matches (string_to_re (String a s)) s') false *) induction s'. (* Goal: @eq bool (matches (string_to_re (String a s)) (String a0 s')) false *) intros Hs. simpl. auto. (* Goal: @eq bool (matches (string_to_re (String a s)) (String a0 s')) false *) intro Hs. simpl. destruct(ascii_dec a a0). (* Goal: @eq bool (matches (string_to_re s) s') false *) (* Goal: @eq bool (matches (Cat Empty (string_to_re s)) s') false *) erewrite Cat_left_id_s. rewrite e in Hs. eapply IHs. (* Goal: not (@eq string s s') *) (* Goal: @eq bool (matches (Cat Empty (string_to_re s)) s') false *) destruct(string_dec s s'). (* Goal: @eq bool false false *) rewrite e0 in Hs. elim Hs. auto. (* Goal: @eq bool false false *) auto. (* Goal: @eq bool false false *) erewrite Cat_left_zero_s. auto. Qed.
(** * Coq codes *) (** ** Dependencies *) Require Import Recdef. Require Import Arith.Wf_nat. Require Import Omega. Require Export RegExp.Utility. Require Export RegExp.Definitions. Require Export RegExp.Boolean. Require Export RegExp.Concat. Unset Standard Proposition Elimination Names. (** ** Lemmas for Star *) Lemma matches_Star_EmptyString : forall r, (Star r) ~== EmptyString. Proof. (* Goal: forall r : RegExp, @eq bool (matches (Star r) EmptyString) true *) intros r. simpl; auto. Qed. Lemma matches_Star_r : forall s r, r ~== s -> (Star r) ~== s. Proof. (* Goal: @eq bool false (matches Eps s) *) induction s; simpl. (* Goal: forall (r : RegExp) (_ : @eq bool (nu r) true), @eq bool true true *) (* Goal: forall (r : RegExp) (_ : @eq bool (matches (derive a r) s) true), @eq bool (matches (Cat (derive a r) (Star r)) s) true *) intros r nu_r. auto. (* Goal: forall (r : RegExp) (_ : @eq bool (matches (derive a r) s) true), @eq bool (matches (Cat (derive a r) (Star r)) s) true *) intros r Hra. replace s with (s ++ "")%string. (* Goal: @eq string EmptyString EmptyString *) (* Goal: @eq bool false (matches Empty s) *) eapply (matches_Cat s ""%string (r/a) (Star r)); try auto. (* Goal: @eq string (append s EmptyString) s *) eapply string_right_id. Qed. (** ** $ 1 + x x^{\ast} = x $ #1 + x x* = x# *) Lemma matches_Star_right_s : forall s r, (Star r) ~= s = (Eps || (r ++ Star r)) ~= s. Proof. (* Goal: forall (s : string) (r : RegExp), @eq bool (matches (Star r) s) (matches (Or Eps (Cat r (Star r))) s) *) induction s; simpl; intro r. (* Goal: @eq string EmptyString EmptyString *) (* Goal: @eq bool false (matches Empty s) *) auto. (* Goal: @eq bool (matches (Cat (derive a r) (Star r)) s) (matches (Or Empty (if nu r then Or (Cat (derive a r) (Star r)) (Cat (derive a r) (Star r)) else Cat (derive a r) (Star r))) s) *) repeat erewrite matches_Or. erewrite Empty_false. simpl. (* Goal: @eq bool (matches (Cat (derive a r) (Star r)) s) (matches (if nu r then Or (Cat (derive a r) (Star r)) (Cat (derive a r) (Star r)) else Cat (derive a r) (Star r)) s) *) destruct (nu r). (* Goal: @eq string EmptyString EmptyString *) (* Goal: @eq bool false (matches Empty s) *) erewrite Or_idem_s. auto. (* Goal: @eq string EmptyString EmptyString *) (* Goal: @eq bool false (matches Empty s) *) auto. Qed. Lemma matches_Star_right : forall r, Star r =R= Eps || (r ++ Star r). Proof. (* Goal: forall r : RegExp, re_eq (Star r) (Or Eps (Cat (Star r) r)) *) unfold re_eq. intros r s. eapply matches_Star_right_s. Qed. Lemma divide_Star_right : forall s r, (Star r) ~== s -> s <> ""%string -> {s':string & {s'':string | s = (s' ++ s'')%string /\ s' <> ""%string /\ r ~== s' /\ (Star r) ~== s''}}. Proof. (* Goal: forall (s : string) (r : RegExp) (_ : @eq bool (matches (Star r) s) true) (_ : not (@eq string s EmptyString)), @sigT string (fun s' : string => @sig string (fun s'' : string => and (@eq string s (append s' s'')) (and (not (@eq string s' EmptyString)) (and (@eq bool (matches r s') true) (@eq bool (matches (Star r) s'') true))))) *) induction s; intros r Hstar Hs. (* Goal: @eq string EmptyString EmptyString *) (* Goal: @eq bool false (matches Empty s) *) elim Hs. auto. (* Goal: @eq bool false true *) (* Goal: @eq bool false true *) simpl in Hstar. (* Goal: @sigT string (fun s' : string => @sig string (fun s'' : string => and (@eq string (String a s) (append s' s'')) (and (not (@eq string s' EmptyString)) (and (@eq bool (matches r s') true) (@eq bool (matches (Star r) s'') true))))) *) specialize (divide_Cat s (r/a) (Star r) Hstar). intro H0. (* Goal: @sigT string (fun s' : string => @sig string (fun s'' : string => and (@eq string (String a s) (append s' s'')) (and (not (@eq string s' EmptyString)) (and (@eq bool (matches r s') true) (@eq bool (matches (Star r) s'') true))))) *) destruct H0 as [s0' [s0'' [H01 [H02 H03]]]]. (* Goal: @sigT string (fun s' : string => @sig string (fun s'' : string => and (@eq string (String a s) (append s' s'')) (and (not (@eq string s' EmptyString)) (and (@eq bool (matches r s') true) (@eq bool (matches (Star r) s'') true))))) *) rewrite <- derivation in H02. (* Goal: @sigT string (fun s' : string => @sig string (fun s'' : string => and (@eq string (String a s) (append s' s'')) (and (not (@eq string s' EmptyString)) (and (@eq bool (matches r s') true) (@eq bool (matches (Star r) s'') true))))) *) exists (String a s0'). exists s0''. (* Goal: and (@eq bool (matches (Star r) (concat_list_string ss0)) true) (@eq bool (matches r s0) true) *) split. (* Goal: @eq string EmptyString EmptyString *) (* Goal: @eq bool false (matches Empty s) *) simpl. rewrite <- H01. auto. (* Goal: and (@eq bool (matches (Star r) (concat_list_string ss0)) true) (@eq bool (matches r s0) true) *) split. (* Goal: forall _ : iff (@eq bool (@forallb string (fun s : string => matches r s) ss') true) (forall (x : string) (_ : @In string x ss'), @eq bool ((fun s : string => matches r s) x) true), @eq bool (matches r s0) true *) intro H. discriminate H. (* Goal: @eq string EmptyString EmptyString *) (* Goal: @eq bool false (matches Empty s) *) auto. Qed. (** ** Split [Star] to [list string] *) Lemma Star_to_list : forall s r, (Star r) ~== s -> {ss:list string | forallb (fun s => r ~= s) ss = true /\ concat_list_string ss = s /\ forallb (fun s => bneq_empty_string s) ss = true }. Proof. (* Goal: forall (s : string) (r : RegExp) (_ : @eq bool (matches (Star r) s) true), @sig (list string) (fun ss : list string => and (@eq bool (@forallb string (fun s0 : string => matches r s0) ss) true) (and (@eq string (concat_list_string ss) s) (@eq bool (@forallb string (fun s0 : string => bneq_empty_string s0) ss) true))) *) refine (induction_ltof2 string str_length _ _). (* Goal: forall (x : string) (_ : forall (y : string) (_ : ltof string str_length y x) (r : RegExp) (_ : @eq bool (matches (Star r) y) true), @sig (list string) (fun ss : list string => and (@eq bool (@forallb string (fun s : string => matches r s) ss) true) (and (@eq string (concat_list_string ss) y) (@eq bool (@forallb string (fun s : string => bneq_empty_string s) ss) true)))) (r : RegExp) (_ : @eq bool (matches (Star r) x) true), @sig (list string) (fun ss : list string => and (@eq bool (@forallb string (fun s : string => matches r s) ss) true) (and (@eq string (concat_list_string ss) x) (@eq bool (@forallb string (fun s : string => bneq_empty_string s) ss) true))) *) intros s IHs r Hstar. (* Goal: @sig (list string) (fun ss : list string => and (@eq bool (@forallb string (fun s : string => matches r s) ss) true) (and (@eq string (concat_list_string ss) s) (@eq bool (@forallb string (fun s : string => bneq_empty_string s) ss) true))) *) specialize(string_dec s ""%string). intro Hs_dec. destruct Hs_dec. (* s = "" *) (* Goal: @eq string EmptyString EmptyString *) (* Goal: @eq bool false (matches Empty s) *) exists nil. auto. (* s <> "" *) (* Goal: @sig (list string) (fun ss : list string => and (@eq bool (@forallb string (fun s : string => matches r s) ss) true) (and (@eq string (concat_list_string ss) s) (@eq bool (@forallb string (fun s : string => bneq_empty_string s) ss) true))) *) specialize(divide_Star_right s r Hstar n). intro H1. (* Goal: @sig (list string) (fun ss : list string => and (@eq bool (@forallb string (fun s : string => matches r s) ss) true) (and (@eq string (concat_list_string ss) s) (@eq bool (@forallb string (fun s : string => bneq_empty_string s) ss) true))) *) destruct H1 as [s' [s'' [H11 [H12 [H13 H14]]]]]. (* Goal: @sig (list string) (fun ss : list string => and (@eq bool (@forallb string (fun s : string => matches r s) ss) true) (and (@eq string (concat_list_string ss) s) (@eq bool (@forallb string (fun s : string => bneq_empty_string s) ss) true))) *) assert(Hltof: ltof string str_length s'' s). (* Goal: ltof string str_length s'' s *) (* Goal: @sig (list string) (fun ss : list string => and (@eq bool (@forallb string (fun s : string => matches r s) ss) true) (and (@eq string (concat_list_string ss) s) (@eq bool (@forallb string (fun s : string => bneq_empty_string s) ss) true))) *) unfold ltof. rewrite H11. rewrite str_length_append. (* Goal: lt (str_length s'') (Init.Nat.add (str_length s') (str_length s'')) *) (* Goal: @sig (list string) (fun ss : list string => and (@eq bool (@forallb string (fun s : string => matches r s) ss) true) (and (@eq string (concat_list_string ss) s) (@eq bool (@forallb string (fun s : string => bneq_empty_string s) ss) true))) *) assert(Hlen_s: forall s, s <> ""%string -> str_length s <> 0). (* Goal: forall (s : string) (_ : not (@eq string s EmptyString)), not (@eq nat (str_length s) O) *) (* Goal: lt (str_length s'') (Init.Nat.add (str_length s') (str_length s'')) *) (* Goal: @sig (list string) (fun ss : list string => and (@eq bool (@forallb string (fun s : string => matches r s) ss) true) (and (@eq string (concat_list_string ss) s) (@eq bool (@forallb string (fun s : string => bneq_empty_string s) ss) true))) *) induction s0. (* Goal: @eq string EmptyString EmptyString *) (* Goal: @eq bool false (matches Empty s) *) intro H'. elim H'. auto. (* Goal: @eq bool (matches (Star r) (String a s)) (matches (Star r') (String a s)) *) simpl. intro H'. intro H''. discriminate H''. (* Goal: lt (str_length s'') (Init.Nat.add (str_length s') (str_length s'')) *) (* Goal: @sig (list string) (fun ss : list string => and (@eq bool (@forallb string (fun s : string => matches r s) ss) true) (and (@eq string (concat_list_string ss) s) (@eq bool (@forallb string (fun s : string => bneq_empty_string s) ss) true))) *) specialize(Hlen_s s' H12). omega. (* Goal: @sig (list string) (fun ss : list string => and (@eq bool (@forallb string (fun s : string => matches r s) ss) true) (and (@eq string (concat_list_string ss) s) (@eq bool (@forallb string (fun s : string => bneq_empty_string s) ss) true))) *) specialize(IHs s'' Hltof r H14). (* Goal: @sig (list string) (fun ss : list string => and (@eq bool (@forallb string (fun s : string => matches r s) ss) true) (and (@eq string (concat_list_string ss) s) (@eq bool (@forallb string (fun s : string => bneq_empty_string s) ss) true))) *) destruct IHs as [ss' [IH1 [IH2 IH3]]]. (* Goal: and (@eq bool (matches (Star r) (concat_list_string ss0)) true) (@eq bool (matches r s0) true) *) exists (s' :: ss'). split. (* Goal: @eq string EmptyString EmptyString *) (* Goal: @eq bool false (matches Empty s) *) simpl. rewrite H13. rewrite IH1. auto. split. (* Goal: @eq string EmptyString EmptyString *) (* Goal: @eq bool false (matches Empty s) *) simpl. rewrite IH2. rewrite <- H11. auto. (* Goal: @eq bool (matches (Star r) (String a s)) (matches (Star r') (String a s)) *) simpl. rewrite IH3. unfold bneq_empty_string. destruct (string_dec s' ""%string). (* Goal: @eq string EmptyString EmptyString *) (* Goal: @eq bool false (matches Empty s) *) simpl. elim H12. auto. (* Goal: @eq string EmptyString EmptyString *) (* Goal: @eq bool false (matches Empty s) *) auto. Defined. Lemma Star_to_list_not_nil : forall s r, (Star r) ~== s -> s <> ""%string -> {ss:list string | forallb (fun s => r ~= s) ss = true /\ concat_list_string ss = s /\ ss <> nil /\ forallb (fun s => bneq_empty_string s) ss = true }. Proof. (* Goal: forall (s : string) (r : RegExp) (_ : @eq bool (matches (Star r) s) true) (_ : not (@eq string s EmptyString)), @sigT string (fun s' : string => @sig string (fun s'' : string => and (@eq string s (append s' s'')) (and (not (@eq string s'' EmptyString)) (and (@eq bool (matches (Star r) s') true) (@eq bool (matches r s'') true))))) *) intros s r Hstar Hs. (* Goal: forall _ : iff (@eq bool (@forallb string (fun s : string => matches r s) ss') true) (forall (x : string) (_ : @In string x ss'), @eq bool ((fun s : string => matches r s) x) true), @eq bool (matches r s0) true *) specialize(Star_to_list s r Hstar). intro H. (* Goal: @sig (list string) (fun ss : list string => and (@eq bool (@forallb string (fun s : string => matches r s) ss) true) (and (@eq string (concat_list_string ss) s) (and (not (@eq (list string) ss (@nil string))) (@eq bool (@forallb string (fun s : string => bneq_empty_string s) ss) true)))) *) destruct H as [ss' [IH1 [IH2 IH3]]]. (* Goal: @eq string EmptyString EmptyString *) (* Goal: @eq bool false (matches Empty s) *) exists ss'. split; try auto. (* Goal: @eq string EmptyString EmptyString *) (* Goal: @eq bool false (matches Empty s) *) split; try auto. (* Goal: @eq string EmptyString EmptyString *) (* Goal: @eq bool false (matches Empty s) *) split; try auto. (* Goal: @eq string EmptyString EmptyString *) (* Goal: @eq bool false (matches Empty s) *) intro Hss'. rewrite Hss' in IH2. simpl in IH2. elim Hs. auto. Defined. Lemma list_to_Star : forall xs r, forallb (fun s : string => r ~= s) xs = true -> Star r ~== concat_list_string xs. Proof. (* Goal: @eq bool (matches (Star r) (String a s)) (matches (Star r') (String a s)) *) induction xs; intros r0 Hf; simpl. (* Goal: @eq string EmptyString EmptyString *) (* Goal: @eq bool false (matches Empty s) *) auto. (* Goal: @eq bool (matches (Star r0) (append a (concat_list_string xs))) true *) simpl in Hf. (* Goal: @eq bool (matches (Star r0) (append a (concat_list_string xs))) true *) case_eq (r0 ~= a); case_eq (forallb (fun s : string => r0 ~= s) xs); intros H1 H2. (* true true *) (* Goal: @eq bool (matches (Star r0) (append a (concat_list_string xs))) true *) (* Goal: @eq bool (matches (Star r0) (append a (concat_list_string xs))) true *) (* Goal: @eq bool (matches (Star r0) (append a (concat_list_string xs))) true *) (* Goal: @eq bool (matches (Star r0) (append a (concat_list_string xs))) true *) cut(Eps || (r0 ++ (Star r0)) ~== (a ++ concat_list_string xs)). intro H3. (* Goal: @eq string EmptyString EmptyString *) (* Goal: @eq bool false (matches Empty s) *) erewrite matches_Star_right. auto. (* Goal: @eq bool (matches (Or Eps (Cat r0 (Star r0))) (append a (concat_list_string xs))) true *) (* Goal: @eq bool (matches (Star r0) (append a (concat_list_string xs))) true *) (* Goal: @eq bool (matches (Star r0) (append a (concat_list_string xs))) true *) (* Goal: @eq bool (matches (Star r0) (append a (concat_list_string xs))) true *) cut((r0 ++ (Star r0)) ~== (a ++ concat_list_string xs)). intro H4. (* Goal: @eq bool (matches (Or Eps (Cat r0 (Star r0))) (append a (concat_list_string xs))) true *) (* Goal: @eq bool (matches (Cat r0 (Star r0)) (append a (concat_list_string xs))) true *) (* Goal: @eq bool (matches (Star r0) (append a (concat_list_string xs))) true *) (* Goal: @eq bool (matches (Star r0) (append a (concat_list_string xs))) true *) (* Goal: @eq bool (matches (Star r0) (append a (concat_list_string xs))) true *) erewrite matches_Or. rewrite H4. (* Goal: @eq string EmptyString EmptyString *) (* Goal: @eq bool false (matches Empty s) *) destruct (Eps ~= (a ++ concat_list_string xs)); auto. (* Goal: @eq string EmptyString EmptyString *) (* Goal: @eq bool false (matches Empty s) *) erewrite matches_Cat; auto. (* false true *) (* Goal: @eq bool (matches (Star r0) (append a (concat_list_string xs))) true *) rewrite H1 in Hf; rewrite H2 in Hf; simpl in Hf; discriminate Hf. (* true false *) (* Goal: @eq bool (matches (Star r0) (append a (concat_list_string xs))) true *) rewrite H1 in Hf; rewrite H2 in Hf; simpl in Hf; discriminate Hf. (* false false *) (* Goal: @eq bool (matches (Star r0) (append a (concat_list_string xs))) true *) rewrite H1 in Hf; rewrite H2 in Hf; simpl in Hf; discriminate Hf. Qed. Lemma divide_Star_left : forall s r, (Star r) ~== s -> s <> ""%string -> {s':string & {s'':string | s = (s' ++ s'')%string /\ s'' <> ""%string /\ (Star r) ~== s' /\ r ~== s''}}. Proof. (* Goal: forall (s : string) (r : RegExp) (_ : @eq bool (matches (Star r) s) true) (_ : not (@eq string s EmptyString)), @sigT string (fun s' : string => @sig string (fun s'' : string => and (@eq string s (append s' s'')) (and (not (@eq string s'' EmptyString)) (and (@eq bool (matches (Star r) s') true) (@eq bool (matches r s'') true))))) *) intros s r Hstar Hs. (* Goal: forall _ : @eq bool (matches (Cat (Star r) r) (append s' s'')) true, @eq bool true false *) (* Goal: @eq bool false true *) specialize(Star_to_list_not_nil s r Hstar Hs). intro H0. (* Goal: @sigT string (fun s' : string => @sig string (fun s'' : string => and (@eq string s (append s' s'')) (and (not (@eq string s'' EmptyString)) (and (@eq bool (matches (Star r) s') true) (@eq bool (matches r s'') true))))) *) destruct H0 as [ss' [H01 [H02 [H03 H04]]]]. (* Goal: @sigT string (fun s' : string => @sig string (fun s'' : string => and (@eq string s (append s' s'')) (and (not (@eq string s'' EmptyString)) (and (@eq bool (matches (Star r) s') true) (@eq bool (matches r s'') true))))) *) specialize (exists_last H03). intro Hlast. (* Goal: @sigT string (fun s' : string => @sig string (fun s'' : string => and (@eq string s (append s' s'')) (and (not (@eq string s'' EmptyString)) (and (@eq bool (matches (Star r) s') true) (@eq bool (matches r s'') true))))) *) destruct Hlast as [ss0 [s0 Hlast']]. (* Goal: and (@eq bool (matches (Star r) (concat_list_string ss0)) true) (@eq bool (matches r s0) true) *) exists (concat_list_string ss0). exists s0. split. (* Goal: @eq string EmptyString EmptyString *) (* Goal: @eq bool false (matches Empty s) *) erewrite <- concat_list_string_xs_x. rewrite <- Hlast'. auto. split. (* goal: s0 <> ""%string *) (* Goal: not (@eq string s0 EmptyString) *) (* Goal: and (@eq bool (matches (Star r) (concat_list_string ss0)) true) (@eq bool (matches r s0) true) *) assert(H': In s0 ss'). (* Goal: @In string s0 ss' *) (* Goal: not (@eq string s0 EmptyString) *) (* Goal: and (@eq bool (matches (Star r) (concat_list_string ss0)) true) (@eq bool (matches r s0) true) *) rewrite Hlast'. eapply In_list_append_right. eapply in_eq. (* Goal: not (@eq string s0 EmptyString) *) (* Goal: and (@eq bool (matches (Star r) (concat_list_string ss0)) true) (@eq bool (matches r s0) true) *) specialize(forallb_forall (fun s => bneq_empty_string s) ss'). intros H''. (* Goal: not (@eq string s0 EmptyString) *) (* Goal: and (@eq bool (matches (Star r) (concat_list_string ss0)) true) (@eq bool (matches r s0) true) *) destruct H'' as [H'' _]. specialize(H'' H04). specialize(H'' s0 H'). (* Goal: not (@eq string s0 EmptyString) *) (* Goal: and (@eq bool (matches (Star r) (concat_list_string ss0)) true) (@eq bool (matches r s0) true) *) unfold bneq_empty_string in H''. (* Goal: @eq string EmptyString EmptyString *) (* Goal: @eq bool false (matches Empty s) *) destruct (string_dec s0 ""%string). discriminate H''. auto. (* Goal: and (@eq bool (matches (Star r) (concat_list_string ss0)) true) (@eq bool (matches r s0) true) *) split. (* goal: Star r ~== concat_list_string ss0 *) (* Goal: @eq bool (matches (Star r) (concat_list_string ss0)) true *) (* Goal: @eq bool (matches r s0) true *) eapply list_to_Star. rewrite Hlast' in H01. (* Goal: @eq bool (@forallb string (fun s : string => matches r s) ss0) true *) (* Goal: @eq bool (matches r s0) true *) apply(forallb_divide_left string (fun s => r ~= s) ss0 (s0::nil) H01). (* goal: r ~== s0 *) (* Goal: @eq bool (matches r s0) true *) specialize(In_snoc string s0 ss0). (* Goal: forall _ : @In string s0 (@app string ss0 (@cons string s0 (@nil string))), @eq bool (matches r s0) true *) intros HIn. rewrite <- Hlast' in HIn. (* Goal: forall _ : iff (@eq bool (@forallb string (fun s : string => matches r s) ss') true) (forall (x : string) (_ : @In string x ss'), @eq bool ((fun s : string => matches r s) x) true), @eq bool (matches r s0) true *) specialize(forallb_forall (fun s => r ~= s) ss'). intro H. (* Goal: @eq string EmptyString EmptyString *) (* Goal: @eq bool false (matches Empty s) *) destruct H as [H _]. eapply H. auto. (* goal: In s0 ss' *) (* Goal: @eq string EmptyString EmptyString *) (* Goal: @eq bool false (matches Empty s) *) auto. Qed. (** ** [Star] is morphism *) Lemma forallb_matches_morphism_s : forall ss r r', r =R= r' -> forallb (fun s0 => r ~= s0) ss = forallb (fun s0 => r' ~= s0) ss. Proof. (* Goal: forall (ss : list string) (r r' : RegExp) (_ : re_eq r r'), @eq bool (@forallb string (fun s0 : string => matches r s0) ss) (@forallb string (fun s0 : string => matches r' s0) ss) *) induction ss. (* Goal: @eq string EmptyString EmptyString *) (* Goal: @eq bool false (matches Empty s) *) intros r r' H. simpl. auto. (* Goal: @eq bool (matches (Star r) (String a s)) (matches (Star r') (String a s)) *) intros r r' H. simpl. rewrite <- (IHss r r' H). unfold re_eq in H. (* Goal: @eq string EmptyString EmptyString *) (* Goal: @eq bool false (matches Empty s) *) rewrite <- (H a). auto. Qed. Lemma Star_morphism_s : forall s r r', r =R= r' -> (Star r) ~= s = (Star r') ~= s. Proof. (* Goal: forall (s : string) (r r' : RegExp) (_ : re_eq r r'), @eq bool (matches (Star r) s) (matches (Star r') s) *) induction s. (* Goal: @eq string EmptyString EmptyString *) (* Goal: @eq bool false (matches Empty s) *) intros r r' H. simpl. auto. (* Goal: @eq bool (matches (Star r) (String a s)) (matches (Star r') (String a s)) *) intros r r' H. simpl. case_eq ((r / a ++ Star r) ~= s); case_eq ((r' / a ++ Star r') ~= s); (* Goal: @eq string EmptyString EmptyString *) (* Goal: @eq bool false (matches Empty s) *) intros H0 H1; try auto. (* true false *) (* Goal: @eq bool true false *) (* Goal: @eq bool false true *) specialize(divide_Cat s (r/a) (Star r) H1). intros H2. (* Goal: @eq bool false true *) destruct H2 as [s' [s'' [H01 [H02 H03]]]]. (* Goal: @sigT string (fun s' : string => @sig string (fun s'' : string => and (@eq string (String a s) (append s' s'')) (and (not (@eq string s' EmptyString)) (and (@eq bool (matches r s') true) (@eq bool (matches (Star r) s'') true))))) *) erewrite <- derivation in H02. (* Goal: @eq bool false true *) unfold re_eq in H. erewrite H in H02. erewrite derivation in H02. (* Goal: @eq bool true false *) (* Goal: @eq bool false true *) specialize(Star_to_list s'' r H03). intro H2. (* Goal: @eq bool false true *) destruct H2 as [ss [H21 [H22 H23]]]. (* Goal: @eq bool true false *) (* Goal: @eq bool false true *) rewrite (forallb_matches_morphism_s ss r r') in H21. (* Goal: forall _ : @eq bool (matches (Star r) (concat_list_string ss)) true, @eq bool false true *) (* Goal: re_eq r' r *) specialize(list_to_Star ss r' H21). intro H3. rewrite H22 in H3. (* Goal: forall _ : @eq bool (matches (Cat (derive a r) (Star r)) (append s' s'')) true, @eq bool false true *) (* Goal: re_eq r' r *) specialize(matches_Cat s' s'' (r'/a) (Star r') H02 H3). intro H4. (* Goal: @eq string EmptyString EmptyString *) (* Goal: @eq bool false (matches Empty s) *) rewrite <- H01 in H4. rewrite H0 in H4. inversion H4. auto. (* false true *) (* Goal: forall _ : @sigT string (fun s' : string => @sig string (fun s'' : string => and (@eq string s (append s' s'')) (and (@eq bool (matches (derive a r') s') true) (@eq bool (matches (Star r') s'') true)))), @eq bool false true *) specialize(divide_Cat s (r'/a) (Star r') H0). intros H2. (* Goal: @eq bool false true *) destruct H2 as [s' [s'' [H01 [H02 H03]]]]. (* Goal: @sigT string (fun s' : string => @sig string (fun s'' : string => and (@eq string (String a s) (append s' s'')) (and (not (@eq string s' EmptyString)) (and (@eq bool (matches r s') true) (@eq bool (matches (Star r) s'') true))))) *) erewrite <- derivation in H02. (* Goal: @eq bool false true *) unfold re_eq in H. erewrite <- H in H02. erewrite derivation in H02. (* Goal: forall _ : @sig (list string) (fun ss : list string => and (@eq bool (@forallb string (fun s : string => matches r' s) ss) true) (and (@eq string (concat_list_string ss) s'') (@eq bool (@forallb string (fun s : string => bneq_empty_string s) ss) true))), @eq bool false true *) specialize(Star_to_list s'' r' H03). intro H2. (* Goal: @eq bool false true *) destruct H2 as [ss [H21 [H22 H23]]]. (* Goal: @eq bool false true *) rewrite (forallb_matches_morphism_s ss r' r) in H21. (* Goal: forall _ : @eq bool (matches (Star r) (concat_list_string ss)) true, @eq bool false true *) (* Goal: re_eq r' r *) specialize(list_to_Star ss r H21). intro H3. rewrite H22 in H3. (* Goal: forall _ : @eq bool (matches (Cat (derive a r) (Star r)) (append s' s'')) true, @eq bool false true *) (* Goal: re_eq r' r *) specialize(matches_Cat s' s'' (r/a) (Star r) H02 H3). intro H4. (* Goal: @eq bool false true *) (* Goal: re_eq r' r *) rewrite <- H01 in H4. rewrite H1 in H4. inversion H4. (* Goal: @eq string EmptyString EmptyString *) (* Goal: @eq bool false (matches Empty s) *) setoid_symmetry. auto. Qed. Add Parametric Morphism : Star with signature re_eq ==> re_eq as Star_morphism. Proof. (* Goal: forall r : RegExp, re_eq (Star r) (Or Eps (Cat (Star r) r)) *) intros x y H. unfold re_eq. intros s. eapply Star_morphism_s. exact H. Qed. (** ** $ 1 + x^{\ast} x = x $ #1 + x* x = x# *) Lemma matches_Star_left_s : forall s r, (Star r) ~= s = (Eps || (Star r ++ r)) ~= s. Proof. (* Goal: forall (s : string) (r : RegExp), @eq bool (matches (Star r) s) (matches (Or Eps (Cat (Star r) r)) s) *) intros s r. case_eq (Star r ~= s); intro Hstar; (* Goal: @eq string EmptyString EmptyString *) (* Goal: @eq bool false (matches Empty s) *) case_eq ((Eps || (Star r ++ r)) ~= s); intro H; try auto. (* Star r ~== s *) (* Goal: @eq bool false true *) destruct (string_dec s ""%string). (* s = "" *) (* Goal: @eq bool true false *) (* Goal: @eq bool true false *) (* Goal: @eq bool false true *) rewrite e in H. erewrite matches_Or in H. simpl in H. discriminate H. (* s <> "" *) (* Goal: forall _ : @eq bool (matches (Cat (Star r) r) (append s' s'')) true, @eq bool true false *) (* Goal: @eq bool false true *) specialize(divide_Star_left s r Hstar n). intro H0. (* Goal: @eq bool true false *) (* Goal: @eq bool false true *) destruct H0 as [s' [s'' [H01 [H02 [H03 H04]]]]]. (* Goal: forall _ : @eq bool (matches (Cat (Star r) r) (append s' s'')) true, @eq bool true false *) (* Goal: @eq bool false true *) specialize(matches_Cat s' s'' (Star r) r H03 H04). intro H0. (* Goal: @eq bool true false *) (* Goal: @eq bool false true *) rewrite <- H01 in H0. rewrite matches_Or in H. rewrite H0 in H. (* Goal: @eq bool true false *) (* Goal: @eq bool true false *) (* Goal: @eq bool false true *) destruct (Eps ~= s); simpl in H; discriminate H. (* Star r ~!= s *) (* Goal: @eq bool false true *) destruct (string_dec s ""%string). (* s = "" *) (* Goal: @eq bool false true *) (* Goal: @eq bool false true *) rewrite e in Hstar. simpl in Hstar. discriminate Hstar. (* s <> "". Prove (H:Eps || (Star r ++ r) ~== s) -> (~Hstar:Star r ~== s) *) (* Goal: @eq bool false true *) (* Goal: @eq bool false (matches Eps s) *) rewrite matches_Or in H. replace (Eps ~= s) with false in H. simpl in H. (* H: (Star r ++ r) ~== s. Divide s *) (* Goal: forall _ : @sig (list string) (fun ss : list string => and (@eq bool (@forallb string (fun s : string => matches r s) ss) true) (and (@eq string (concat_list_string ss) s') (@eq bool (@forallb string (fun s : string => bneq_empty_string s) ss) true))), @eq bool false true *) (* Goal: @eq bool false (matches Eps s) *) specialize(divide_Cat s (Star r) r H). intro H'. (* Goal: @eq bool false true *) (* Goal: @eq bool false (matches Eps s) *) destruct H' as [s' [s'' [H01 [H02 H03]]]]. (* H02 : Star r ~== s'. Parse s' to ss:list string *) (* Goal: forall _ : @sig (list string) (fun ss : list string => and (@eq bool (@forallb string (fun s : string => matches r s) ss) true) (and (@eq string (concat_list_string ss) s') (@eq bool (@forallb string (fun s : string => bneq_empty_string s) ss) true))), @eq bool false true *) (* Goal: @eq bool false (matches Eps s) *) specialize(Star_to_list s' r H02). intro H'. (* Goal: @eq bool false true *) (* Goal: @eq bool false (matches Eps s) *) destruct H' as [ss [H11 [H12 H13]]]. (* Prove Hf: (Star r) ~== (ss ++ s'::nil) *) (* Goal: @eq bool false true *) (* Goal: @eq bool false (matches Eps s) *) specialize(forallb_list_xs_x string (fun s => r ~= s) ss s'' H11 H03). (* Goal: forall _ : @eq bool (@forallb string (fun s : string => matches r s) (@app string ss (@cons string s'' (@nil string)))) true, @eq bool false true *) (* Goal: @eq bool false (matches Eps s) *) intros Hf. (* Prove Hf': ss ++ s'::nil = s *) (* Goal: @eq bool false true *) (* Goal: @eq bool false (matches Eps s) *) specialize(concat_list_string_xs_x ss s''). intros Hf'. (* Goal: @eq bool false true *) (* Goal: @eq bool false (matches Eps s) *) rewrite H12 in Hf'. rewrite <- H01 in Hf'. (* Prove (Star r ) ~== s *) (* Goal: @eq bool false true *) (* Goal: @eq bool false (matches Eps s) *) specialize(list_to_Star (ss ++ s''::nil) r Hf). intros Hf''. (* Goal: @eq bool false true *) (* Goal: @eq bool false (matches Eps s) *) rewrite Hf' in Hf''. (* Contradiction between Hstar and Hf'' *) (* Goal: @eq bool false true *) (* Goal: @eq bool false (matches Eps s) *) rewrite Hf'' in Hstar. discriminate Hstar. (* Prove false = Eps ~= s *) (* Goal: @eq bool (matches (Star r) (String a s)) (matches (Star r') (String a s)) *) induction s; simpl. (* Goal: @eq string EmptyString EmptyString *) (* Goal: @eq bool false (matches Empty s) *) elim n. auto. (* Goal: @eq bool false (matches Empty s) *) symmetry. eapply Empty_false. Qed. Lemma matches_Star_left : forall r, Star r =R= Eps || (Star r ++ r). Proof. (* Goal: forall r : RegExp, re_eq (Star r) (Or Eps (Cat (Star r) r)) *) unfold re_eq. intros r s. eapply matches_Star_left_s. Qed.
(** * Definitions *) (** [RegExp], a type for regular expressions, consists of following constructors: - [Empty] : matches no strings, - [Eps] : matches an empty string $(\epsilon)$, - [Char c] : matches a single charater [c], - [Cat r1 r2] : [r1 ++ r2] matches [s1 ++ s2] iff [r1, r2] match [s1, s2], respectively, - [Or r1 r2] : [r1 || r2] matches [s1] or [s2] iff [r1, r2] match [s1, s2], respectively, - [Star r] : [Star r] matches a zero-or-more times repetition of [s] iff [r] matches [s]; Kleene star $r^{\ast}$ #r*#, - [Not r] : [Not r] matches [s] iff [r] does not match [s], - [And r1 r2] : [And r1 r2] matches [s] iff both [r1, r2] match [s]. Though [Not] and [And] are not necessary for regular expression, they would be useful in real use. You may add another constructor to [RegExp] because no inductions on [RegExp] are used in the proofs of the library. Just add your constructor to definitions of [RegExp], [nu], and [derive] with consistency. *) (** * Coq codes *) (** ** Dependencies *) Require Export RegExp.Utility. Require Export Setoid. Require Export Relation_Definitions. (** ** Definitions *) Inductive RegExp : Set := | Empty : RegExp | Eps : RegExp | Char : ascii -> RegExp | Cat : RegExp -> RegExp -> RegExp | Or : RegExp -> RegExp -> RegExp | Star : RegExp -> RegExp | Not : RegExp -> RegExp | And : RegExp -> RegExp -> RegExp. Notation "a ++ b" := (Cat a b). Notation "a || b" := (Or a b). (** [nu re = true] iff [re:RegExp] accepts empty string. *) Fixpoint nu(re:RegExp):bool := match re with | Empty => false | Eps => true | Char c => false | Cat r s => (nu r && nu s)%bool | Or r s => (nu r || nu s)%bool | Star r => true | Not r => negb (nu r) | And r s => (nu r && nu s)%bool end. (** Derivation of [re:RegExp] by [a:ascii]. *) Fixpoint derive(a:ascii)(re:RegExp):RegExp := match re with | Empty => Empty | Eps => Empty | Char c => match (ascii_dec c a) with | left _ => Eps | right _ => Empty end | Cat r s => match (nu r) with | true => ((derive a r) ++ s) || (derive a s) | false => (derive a r) ++ s end | Or r s => (derive a r) || (derive a s) | Star r => (derive a r) ++ (Star r) | Not r => Not (derive a r) | And r s => And (derive a r) (derive a s) end. Notation "re / a" := (derive a re). (** [matches re s = true] iff [re:RegExp] matches [s:string]. *) Fixpoint matches (re:RegExp)(s:string) : bool := match s with | EmptyString => nu re | String a w => matches (re / a) w end. Notation "re ~= s" := (matches re s) (at level 60). Notation "re ~== s" := (matches re s = true) (at level 60). Notation "re ~!= s" := (matches re s = false) (at level 60). (** Relation between [matches] and [derive]. *) Theorem derivation : forall (a:ascii)(w:string)(re:RegExp), re ~= (String a w) = (re / a) ~= w. Proof. (* Goal: forall (a : ascii) (w : string) (re : RegExp), @eq bool (matches re (String a w)) (matches (derive a re) w) *) intros a w re. simpl. auto. Qed. (** ** [RegExp] as Setoid. *) (** [re_eq] is an equivalence relation between [RegExp]. *) Definition re_eq (re re':RegExp) : Prop := forall s, re ~= s = re' ~= s. Notation "a =R= b" := (re_eq a b) (at level 70). Lemma re_eq_refl : reflexive RegExp re_eq. Proof. (* Goal: re_eq x0 y0 *) unfold reflexive. intro x. unfold re_eq. intro s. auto. Qed. Lemma re_eq_sym : symmetric RegExp re_eq. Proof. (* Goal: symmetric RegExp re_eq *) unfold symmetric. intros x y H. unfold re_eq in *. (* Goal: re_eq x0 y0 *) intros s. eauto. Qed. Lemma re_eq_trans : transitive RegExp re_eq. Proof. (* Goal: forall (r r' : RegExp) (_ : re_eq r r'), @eq bool (nu r) (nu r') *) unfold transitive. intros x y z. unfold re_eq in *. intros Hxy Hyz s. (* Goal: re_eq x0 y0 *) transitivity (y ~= s); eauto. Qed. Add Parametric Relation : RegExp re_eq reflexivity proved by re_eq_refl symmetry proved by re_eq_sym transitivity proved by re_eq_trans as RegExp_setoid. (** The helper functions are morphisms. *) Lemma nu_equals : forall r r', r =R= r' -> nu r = nu r'. Proof. (* Goal: forall (r r' : RegExp) (_ : re_eq r r'), @eq bool (nu r) (nu r') *) unfold re_eq in *. intros r r' H. (* Goal: re_eq x0 y0 *) specialize (H ""%string); simpl in H. auto. Qed. Add Parametric Morphism : nu with signature re_eq ==> bool_eq as nu_morphism. Proof. (* Goal: re_eq x0 y0 *) intros x y H. eapply nu_equals. auto. Qed. Lemma derive_equals : forall r r', r =R= r' -> (forall a, r / a =R= r' / a). Proof. (* Goal: re_eq r r' *) intros r r' H. unfold re_eq. intros a s. (* Goal: @eq bool (matches (derive a r) s) (matches (derive a r') s) *) repeat rewrite <- derivation. (* Goal: re_eq x0 y0 *) unfold re_eq in H. eauto. Qed. Lemma derive_equals_inv : forall r r', (forall a, (r / a) =R= (r' / a)) -> nu r = nu r' -> r =R= r'. Proof. (* Goal: re_eq r r' *) intros r r' Ha Hnu. unfold re_eq. (* Goal: forall s : string, @eq bool (matches r s) (matches r' s) *) induction s. (* Goal: @eq bool (matches r EmptyString) (matches r' EmptyString) *) (* Goal: @eq bool (matches r (String a s)) (matches r' (String a s)) *) simpl. auto. (* Goal: @eq bool (matches r (String a s)) (matches r' (String a s)) *) repeat erewrite derivation. eapply Ha. Qed. Add Parametric Morphism : derive with signature ascii_eq ==> re_eq ==> re_eq as derive_morphism. Proof. (* Goal: forall (x y : ascii) (_ : ascii_eq x y) (x0 y0 : RegExp) (_ : re_eq x0 y0), re_eq (derive x x0) (derive y y0) *) intros x y H x0 y0 H0. (* Goal: re_eq (derive x x0) (derive y y0) *) inversion H. rewrite <- H1. (* Goal: re_eq x0 y0 *) eapply derive_equals. auto. Qed.
(** * Coq codes *) (** ** Dependencies *) Require Export RegExp.Utility. Require Export RegExp.Definitions. Require Export RegExp.Boolean. (** ** [Cat] is morphism *) Lemma Cat_morphism_s : forall s r0 r1 r0' r1', r0 =R= r1 -> r0' =R= r1' -> (r0 ++ r0') ~= s = (r1 ++ r1') ~= s. Proof. (* Goal: forall (s : string) (r r' r'' : RegExp), @eq bool (matches (Cat (Or r r') r'') s) (matches (Or (Cat r r'') (Cat r' r'')) s) *) induction s. (* ""%string *) (* Goal: forall (r0 r1 r0' r1' : RegExp) (_ : re_eq r0 r1) (_ : re_eq r0' r1'), @eq bool (matches (Cat r0 r0') (String a s)) (matches (Cat r1 r1') (String a s)) *) intros r0 r1 r0' r1' H H'. simpl. rewrite <- (nu_morphism r0 r1 H). (* Goal: @eq bool (andb (nu r0) (nu r0')) (andb (nu r0) (nu r1')) *) (* Goal: forall (r0 r1 r0' r1' : RegExp) (_ : re_eq r0 r1) (_ : re_eq r0' r1'), @eq bool (matches (Cat r0 r0') (String a s)) (matches (Cat r1 r1') (String a s)) *) rewrite <- (nu_morphism r0' r1' H'). auto. (* String a s *) (* Goal: forall (r0 r1 r0' r1' : RegExp) (_ : re_eq r0 r1) (_ : re_eq r0' r1'), @eq bool (matches (Cat r0 r0') (String a s)) (matches (Cat r1 r1') (String a s)) *) intros r0 r1 r0' r1' H H'. simpl. rewrite <- (nu_morphism r0 r1 H). (* Goal: @eq bool (matches (if nu r0 then Or (Cat (derive a r0) r0') (derive a r0') else Cat (derive a r0) r0') s) (matches (if nu r0 then Or (Cat (derive a r1) r1') (derive a r1') else Cat (derive a r1) r1') s) *) destruct (nu r0). (* true *) (* Goal: @eq bool (orb (matches (Or (Cat (derive a r) r'') (Cat (derive a r') r'')) s) (matches (derive a r'') s)) (matches (Or (Cat (derive a r) r'') (Or (Cat (derive a r') r'') (derive a r''))) s) *) (* Goal: @eq bool (matches (Cat (Or (derive a r) (derive a r')) r'') s) (matches (Or (Cat (derive a r) r'') (Cat (derive a r') r'')) s) *) repeat erewrite matches_Or. (* Goal: @eq bool (orb (matches (Cat (derive a r0) r0') s) (matches (derive a r0') s)) (orb (matches (Cat (derive a r1) r1') s) (matches (derive a r1') s)) *) (* Goal: @eq bool (matches (Cat (derive a r0) r0') s) (matches (Cat (derive a r1) r1') s) *) replace (r1' / a ~= s) with (r0' / a ~= s). (* Goal: @eq bool (orb (matches (Cat (derive a r0) r0') s) (matches (derive a r0') s)) (orb (matches (Cat (derive a r1) r1') s) (matches (derive a r0') s)) *) (* Goal: @eq bool (matches (derive a r0') s) (matches (derive a r1') s) *) (* Goal: @eq bool (matches (Cat (derive a r0) r0') s) (matches (Cat (derive a r1) r1') s) *) replace ((r1 / a ++ r1') ~= s) with ((r0 / a ++ r0') ~= s). (* Goal: @eq bool (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) *) auto. (* proof for replace *) (* Goal: @eq bool (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) *) eapply IHs; try auto. eapply derive_morphism; try auto. (* Goal: @eq bool (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) *) unfold ascii_eq; auto. (* proof for replace *) (* Goal: @eq bool (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) *) eapply derive_morphism; try auto. unfold ascii_eq; auto. (* false *) (* Goal: @eq bool (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) *) eapply IHs; try auto. eapply derive_morphism; try auto. (* Goal: @eq bool (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) *) unfold ascii_eq; auto. Qed. Add Parametric Morphism : Cat with signature re_eq ==> re_eq ==> re_eq as Cat_mor. Proof. (* Goal: @eq bool (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) *) intros x y H x0 y0 H0. unfold re_eq. intro s. eapply Cat_morphism_s; auto. Qed. (** ** [Empty] *) (** [Empty] corresponds to 0 in Kleene algebra. *) Lemma Cat_left_zero_s : forall s r, (Empty ++ r) ~= s = false. Proof. (* Goal: @eq bool (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) *) induction s; simpl; auto. Qed. Theorem Cat_left_zero : forall r, Empty ++ r =R= Empty. Proof. (* Goal: forall r r' r'' : RegExp, re_eq (Cat (Or r r') r'') (Or (Cat r r'') (Cat r' r'')) *) unfold re_eq. intros r s. erewrite Empty_false. (* Goal: @eq bool (matches (Cat Empty r) s) false *) eapply Cat_left_zero_s. Qed. Lemma Cat_right_zero_s : forall s r, (r ++ Empty) ~= s = false. Proof. (* Goal: @eq bool (matches (Cat (Or r r') r'') (String a s)) (matches (Or (Cat r r'') (Cat r' r'')) (String a s)) *) induction s; intro r; simpl. (* Goal: @eq bool (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) *) destruct (nu r); simpl; auto. (* Goal: @eq bool (matches (if nu r then Or (Cat (derive a r) Eps) Empty else Cat (derive a r) Eps) s) false *) case_eq (nu r); intro nu_r'. (* Goal: @eq bool (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) *) erewrite matches_Or. erewrite IHs. erewrite Empty_false. simpl; auto. (* Goal: @eq bool (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) *) erewrite IHs. auto. Qed. Theorem Cat_right_zero : forall r, r ++ Empty =R= Empty. Proof. (* Goal: forall r r' r'' : RegExp, re_eq (Cat (Or r r') r'') (Or (Cat r r'') (Cat r' r'')) *) unfold re_eq. intros r s. erewrite Empty_false. (* Goal: @eq bool (matches (Cat r Empty) s) false *) eapply Cat_right_zero_s. Qed. (** ** [Cat] matches concatination of strings. *) Lemma matches_Cat : forall s s' r r', r ~==s -> r' ~== s' -> (r ++ r') ~== (s ++ s')%string. Proof. (* Goal: forall (s : string) (r r' r'' : RegExp), @eq bool (matches (Cat (Or r r') r'') s) (matches (Or (Cat r r'') (Cat r' r'')) s) *) induction s. (* s = ""%string *) (* Goal: forall (s' : string) (r r' : RegExp) (_ : @eq bool (matches r EmptyString) true) (_ : @eq bool (matches r' s') true), @eq bool (matches (Cat r r') (append EmptyString s')) true *) (* Goal: forall (s' : string) (r r' : RegExp) (_ : @eq bool (matches r (String a s)) true) (_ : @eq bool (matches r' s') true), @eq bool (matches (Cat r r') (append (String a s) s')) true *) induction s'. (* s' = ""%string *) (* Goal: @eq bool (matches (Cat (Or r r') r'') (String a s)) (matches (Or (Cat r r'') (Cat r' r'')) (String a s)) *) simpl. intros r r' nu_r nu_r'. rewrite nu_r. rewrite nu_r'. simpl; auto. (* s' = String a s *) (* Goal: @eq bool (matches (Cat (Or r r') r'') (String a s)) (matches (Or (Cat r r'') (Cat r' r'')) (String a s)) *) simpl. intros r r' nu_r Hra. rewrite nu_r. erewrite matches_Or. (* Goal: @eq bool (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) *) rewrite Hra. destruct ((r / a ++ r') ~= s'); simpl; auto. (* s = String a s *) (* Goal: forall (s' : string) (r r' : RegExp) (_ : @eq bool (matches r (String a s)) true) (_ : @eq bool (matches r' s') true), @eq bool (matches (Cat r r') (append (String a s) s')) true *) intros s' r r' Hr Hr'. (* Goal: @eq bool (matches (Cat r r') (append (String a s) s')) true *) replace (String a s ++ s')%string with (String a (s ++ s'))%string. (* Goal: @eq bool (matches (Cat (Or r r') r'') (String a s)) (matches (Or (Cat r r'') (Cat r' r'')) (String a s)) *) rewrite derivation. simpl. case_eq (nu r); intro nu_r'. (* nu r' = true *) (* Goal: @eq bool (matches (Or (Cat (derive a r) r'') (Cat (derive a r') r'')) s) (matches (Or (Cat (derive a r) r'') (Cat (derive a r') r'')) s) *) rewrite derivation in Hr. erewrite matches_Or. (* Goal: @eq bool (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) *) specialize (IHs s' (r/a) r' Hr Hr'). rewrite IHs. simpl; auto. (* nu r' = false *) (* Goal: @eq bool (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) *) rewrite derivation in Hr. specialize (IHs s' (r/a) r' Hr Hr'). auto. (* proof for replace *) (* Goal: @eq bool (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) *) simpl; auto. Qed. (** If [Cat] matches a string, the string can be divided into two strings which match the two [RegExp] respectively. *) Lemma divide_Cat : forall s r' r'', (r' ++ r'') ~== s -> {s':string & {s'':string | s = (s' ++ s'')%string /\ r' ~== s' /\ r'' ~== s'' }}. Proof. (* Goal: forall (s : string) (r r' r'' : RegExp), @eq bool (matches (Cat (Or r r') r'') s) (matches (Or (Cat r r'') (Cat r' r'')) s) *) induction s. (* s = ""%string *) (* Goal: @eq bool (matches (Cat (Or r r') r'') (String a s)) (matches (Or (Cat r r'') (Cat r' r'')) (String a s)) *) intros r' r'' H. exists ""%string. exists ""%string. simpl. (* Goal: @eq bool (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) *) split. auto. simpl in H. (* Goal: and (@eq bool (nu r') true) (@eq bool (nu r'') true) *) (* Goal: forall (r' r'' : RegExp) (_ : @eq bool (matches (Cat r' r'') (String a s)) true), @sigT string (fun s' : string => @sig string (fun s'' : string => and (@eq string (String a s) (append s' s'')) (and (@eq bool (matches r' s') true) (@eq bool (matches r'' s'') true)))) *) destruct (nu r'); destruct (nu r''); split; simpl; auto; inversion H. (* s = String a s *) (* Goal: forall (r' r'' : RegExp) (_ : @eq bool (matches (Cat r' r'') (String a s)) true), @sigT string (fun s' : string => @sig string (fun s'' : string => and (@eq string (String a s) (append s' s'')) (and (@eq bool (matches r' s') true) (@eq bool (matches r'' s'') true)))) *) intros r' r'' H. simpl in H. (* Goal: @sigT string (fun s' : string => @sig string (fun s'' : string => and (@eq string (String a s) (append s' s'')) (and (@eq bool (matches r' s') true) (@eq bool (matches r'' s'') true)))) *) (* Goal: @sigT string (fun s' : string => @sig string (fun s'' : string => and (@eq string (String a s) (append s' s'')) (and (@eq bool (matches r' s') true) (@eq bool (matches r'' s'') true)))) *) case_eq (nu r'); intro nu_r'; rewrite nu_r' in H; simpl in H. (* nu r' = true *) (* Goal: @sigT string (fun s' : string => @sig string (fun s'' : string => and (@eq string (String a s) (append s' s'')) (and (@eq bool (matches r' s') true) (@eq bool (matches r'' s'') true)))) *) (* Goal: @sigT string (fun s' : string => @sig string (fun s'' : string => and (@eq string (String a s) (append s' s'')) (and (@eq bool (matches r' s') true) (@eq bool (matches r'' s'') true)))) *) erewrite matches_Or in H. case_eq ((r' / a ++ r'') ~= s); case_eq (r'' / a ~= s); (* Goal: @sigT string (fun s' : string => @sig string (fun s'' : string => and (@eq string (String a s) (append s' s'')) (and (@eq bool (matches r' s') true) (@eq bool (matches r'' s'') true)))) *) (* Goal: @sigT string (fun s' : string => @sig string (fun s'' : string => and (@eq string (String a s) (append s' s'')) (and (@eq bool (matches r' s') true) (@eq bool (matches r'' s'') true)))) *) intros Hr''_a Hr'_r''_a; simpl in H. (* true true -> (String a s') ++ s'' *) (* Goal: @sigT string (fun s' : string => @sig string (fun s'' : string => and (@eq string (String a s) (append s' s'')) (and (@eq bool (matches r' s') true) (@eq bool (matches r'' s'') true)))) *) (* Goal: @sigT string (fun s' : string => @sig string (fun s'' : string => and (@eq string (String a s) (append s' s'')) (and (@eq bool (matches r' s') true) (@eq bool (matches r'' s'') true)))) *) (* Goal: @sigT string (fun s' : string => @sig string (fun s'' : string => and (@eq string (String a s) (append s' s'')) (and (@eq bool (matches r' s') true) (@eq bool (matches r'' s'') true)))) *) (* Goal: @sigT string (fun s' : string => @sig string (fun s'' : string => and (@eq string (String a s) (append s' s'')) (and (@eq bool (matches r' s') true) (@eq bool (matches r'' s'') true)))) *) specialize (IHs (r'/a) r'' Hr'_r''_a). (* Goal: @sigT string (fun s' : string => @sig string (fun s'' : string => and (@eq string (String a s) (append s' s'')) (and (@eq bool (matches r' s') true) (@eq bool (matches r'' s'') true)))) *) destruct IHs as [s' [s'' [H1 [H2 H3]]]]. (* Goal: @sigT string (fun s' : string => @sig string (fun s'' : string => and (@eq string (String a s) (append s' s'')) (and (@eq bool (matches r' s') true) (@eq bool (matches r'' s'') true)))) *) exists (String a s'). exists s''. (* Goal: @eq bool (matches (Cat (Or r r') r'') (String a s)) (matches (Or (Cat r r'') (Cat r' r'')) (String a s)) *) split. simpl. rewrite <- H1. auto. split; auto. (* (r' / a ++ r'') ~== s *) (* Goal: @sigT string (fun s' : string => @sig string (fun s'' : string => and (@eq string (String a s) (append s' s'')) (and (@eq bool (matches r' s') true) (@eq bool (matches r'' s'') true)))) *) (* Goal: @sigT string (fun s' : string => @sig string (fun s'' : string => and (@eq string (String a s) (append s' s'')) (and (@eq bool (matches r' s') true) (@eq bool (matches r'' s'') true)))) *) (* Goal: @sigT string (fun s' : string => @sig string (fun s'' : string => and (@eq string (String a s) (append s' s'')) (and (@eq bool (matches r' s') true) (@eq bool (matches r'' s'') true)))) *) (* Goal: @sigT string (fun s' : string => @sig string (fun s'' : string => and (@eq string (String a s) (append s' s'')) (and (@eq bool (matches r' s') true) (@eq bool (matches r'' s'') true)))) *) specialize (IHs (r'/a) r'' Hr'_r''_a). (* Goal: @sigT string (fun s' : string => @sig string (fun s'' : string => and (@eq string (String a s) (append s' s'')) (and (@eq bool (matches r' s') true) (@eq bool (matches r'' s'') true)))) *) destruct IHs as [s' [s'' [H1 [H2 H3]]]]. (* Goal: @sigT string (fun s' : string => @sig string (fun s'' : string => and (@eq string (String a s) (append s' s'')) (and (@eq bool (matches r' s') true) (@eq bool (matches r'' s'') true)))) *) exists (String a s'). exists s''. (* Goal: @eq bool (matches (Cat (Or r r') r'') (String a s)) (matches (Or (Cat r r'') (Cat r' r'')) (String a s)) *) split. simpl. rewrite <- H1. auto. split; auto. (* r'' / a ~== s *) (* Goal: @sigT string (fun s' : string => @sig string (fun s'' : string => and (@eq string (String a s) (append s' s'')) (and (@eq bool (matches r' s') true) (@eq bool (matches r'' s'') true)))) *) (* Goal: @sigT string (fun s' : string => @sig string (fun s'' : string => and (@eq string (String a s) (append s' s'')) (and (@eq bool (matches r' s') true) (@eq bool (matches r'' s'') true)))) *) (* Goal: @sigT string (fun s' : string => @sig string (fun s'' : string => and (@eq string (String a s) (append s' s'')) (and (@eq bool (matches r' s') true) (@eq bool (matches r'' s'') true)))) *) exists ""%string. exists (String a s). (* Goal: @eq bool (matches (Cat (Or r r') r'') (String a s)) (matches (Or (Cat r r'') (Cat r' r'')) (String a s)) *) split. simpl. auto. split; simpl; auto. (* false false *) (* Goal: @sigT string (fun s' : string => @sig string (fun s'' : string => and (@eq string (String a s) (append s' s'')) (and (@eq bool (matches r' s') true) (@eq bool (matches r'' s'') true)))) *) (* Goal: @sigT string (fun s' : string => @sig string (fun s'' : string => and (@eq string (String a s) (append s' s'')) (and (@eq bool (matches r' s') true) (@eq bool (matches r'' s'') true)))) *) rewrite Hr''_a in H. rewrite Hr'_r''_a in H. simpl in H. inversion H. (* nu r' = false *) (* Goal: @sigT string (fun s' : string => @sig string (fun s'' : string => and (@eq string (String a s) (append s' s'')) (and (@eq bool (matches r' s') true) (@eq bool (matches r'' s'') true)))) *) specialize (IHs (r'/a) r'' H). (* Goal: @sigT string (fun s' : string => @sig string (fun s'' : string => and (@eq string (String a s) (append s' s'')) (and (@eq bool (matches r' s') true) (@eq bool (matches r'' s'') true)))) *) destruct IHs as [s' [s'' [H1 [H2 H3]]]]. (* Goal: @sigT string (fun s' : string => @sig string (fun s'' : string => and (@eq string (String a s) (append s' s'')) (and (@eq bool (matches r' s') true) (@eq bool (matches r'' s'') true)))) *) exists (String a s'). exists s''. (* Goal: @eq bool (matches (Cat (Or r r') r'') (String a s)) (matches (Or (Cat r r'') (Cat r' r'')) (String a s)) *) split. simpl. rewrite <- H1. auto. split; auto. Defined. Lemma divide_Cat_false : forall s r' r'', (r' ++ r'') ~!= s -> forall s' s'', ((s = s' ++ s'')%string -> r' ~!= s' \/ r'' ~!= s''). Proof. (* Goal: forall (s : string) (r' r'' : RegExp) (_ : @eq bool (matches (Cat r' r'') s) false) (s' s'' : string) (_ : @eq string s (append s' s'')), or (@eq bool (matches r' s') false) (@eq bool (matches r'' s'') false) *) intros s r' r'' H0. (* Goal: forall (s' s'' : string) (_ : @eq string s (append s' s'')), or (@eq bool (matches r' s') false) (@eq bool (matches r'' s'') false) *) intros s' s''. (* Goal: @eq bool (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) *) case_eq (r' ~= s'); case_eq (r'' ~= s''); intros Hr''s'' Hr's' Hs; try auto. (* true true *) (* Goal: or (@eq bool true false) (@eq bool true false) *) specialize(matches_Cat s' s'' r' r'' Hr's' Hr''s''). (* Goal: forall _ : @eq bool (matches (Cat r' r'') (append s' s'')) true, or (@eq bool true false) (@eq bool true false) *) left. rewrite <- Hs in H. rewrite H0 in H. discriminate H. Qed. (** ** [Eps] *) (** [Eps] corresponds to 1 in Kleene algebra. *) Lemma Cat_left_id_s : forall s r, (Eps ++ r) ~= s = r ~= s. Proof. (* Goal: forall (s : string) (r r' r'' : RegExp), @eq bool (matches (Cat (Or r r') r'') s) (matches (Or (Cat r r'') (Cat r' r'')) s) *) induction s. (* Goal: @eq bool (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) *) simpl; auto. (* Goal: @eq bool (matches (Cat (Or r r') r'') (String a s)) (matches (Or (Cat r r'') (Cat r' r'')) (String a s)) *) simpl. intros r. erewrite matches_Or. (* Goal: @eq bool (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) *) erewrite Cat_left_zero_s. simpl; auto. Qed. Theorem Cat_left_id : forall r, Eps ++ r =R= r. Proof. (* Goal: forall r r' r'' : RegExp, re_eq (Cat (Or r r') r'') (Or (Cat r r'') (Cat r' r'')) *) unfold re_eq. intros r s. eapply Cat_left_id_s. Qed. Lemma Cat_right_id_s : forall s r, (r ++ Eps) ~= s = r ~= s. Proof. (* Goal: forall (s : string) (r : RegExp), @eq bool (matches (Cat r Eps) s) (matches r s) *) intros s r. case_eq (r ~= s); intro Hrs. (* r ~== s *) (* Goal: @eq bool (matches (Cat r Eps) s) true *) (* Goal: @eq bool (matches (Cat r Eps) s) false *) replace ((r ++ Eps) ~= s) with ((r ++ Eps) ~= (s ++ EmptyString)). (* Goal: @eq bool (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) *) eapply matches_Cat; auto. (* Goal: @eq bool (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) *) erewrite string_right_id. auto. (* r ~!= s *) (* Goal: @eq bool (matches (Cat r Eps) s) false *) generalize dependent r. (* Goal: forall (s : string) (r r' r'' : RegExp), @eq bool (matches (Cat (Or r r') r'') s) (matches (Or (Cat r r'') (Cat r' r'')) s) *) induction s. (* Goal: @eq bool (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) *) intros r H. simpl in *. rewrite H. auto. (* Goal: @eq bool (matches (if nu r then Or (Cat (derive a r) Eps) Empty else Cat (derive a r) Eps) s) false *) intros r H. simpl in *. case_eq (nu r); intro nu_r'. (* nu r = true *) (* Goal: @eq bool (orb (matches (Cat (derive a r) Eps) s) (matches Empty s)) false *) (* Goal: @eq bool (matches (Cat (derive a r) Eps) s) false *) erewrite matches_Or. erewrite Empty_false. (* Goal: @eq bool (orb (matches (Cat (derive a r) Eps) s) false) false *) (* Goal: @eq bool (matches (Cat (derive a r) Eps) s) false *) replace (((r / a ++ Eps) ~= s) || false)%bool with ((r / a ++ Eps) ~= s). (* Goal: @eq bool (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) *) erewrite IHs; auto. (* Goal: @eq bool (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) *) destruct ((r / a ++ Eps) ~= s); auto. (* nu r = false *) (* Goal: @eq bool (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) *) erewrite IHs; auto. Qed. Theorem Cat_right_id : forall r, r ++ Eps =R= r. Proof. (* Goal: forall r r' r'' : RegExp, re_eq (Cat (Or r r') r'') (Or (Cat r r'') (Cat r' r'')) *) unfold re_eq. intros r s. eapply Cat_right_id_s. Qed. (** ** [Cat] is associative. *) Lemma matches_Cat_Cat_left : forall s s' s'' r r' r'', r ~== s -> r' ~== s' -> r'' ~== s'' -> ((r ++ r') ++ r'') ~== ((s ++ s') ++ s''). Proof. (* Goal: forall (s s' s'' : string) (r r' r'' : RegExp) (_ : @eq bool (matches r s) true) (_ : @eq bool (matches r' s') true) (_ : @eq bool (matches r'' s'') true), @eq bool (matches (Cat r (Cat r' r'')) (append s (append s' s''))) true *) intros s s' s'' r r' r'' H H' H''. (* Goal: @eq bool (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) *) repeat eapply matches_Cat; auto. Qed. Lemma matches_Cat_Cat_right : forall s s' s'' r r' r'', r ~== s -> r' ~== s' -> r'' ~== s'' -> (r ++ (r' ++ r'')) ~== (s ++ (s' ++ s'')). Proof. (* Goal: forall (s s' s'' : string) (r r' r'' : RegExp) (_ : @eq bool (matches r s) true) (_ : @eq bool (matches r' s') true) (_ : @eq bool (matches r'' s'') true), @eq bool (matches (Cat r (Cat r' r'')) (append s (append s' s''))) true *) intros s s' s'' r r' r'' H H' H''. (* Goal: @eq bool (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) *) repeat eapply matches_Cat; auto. Qed. Lemma Cat_assoc_s : forall s r r' r'', ((r ++ r') ++ r'') ~= s = (r ++ (r' ++ r'')) ~= s. Proof. (* Goal: forall (s : string) (r r' r'' : RegExp), @eq bool (matches (Cat (Cat r r') r'') s) (matches (Cat r (Cat r' r'')) s) *) intros s r r' r''. case_eq (((r ++ r') ++ r'') ~= s); intro H; symmetry. (* true *) (* Goal: @eq bool (matches (Cat r (Cat r' r'')) s) true *) (* Goal: @eq bool (matches (Cat r (Cat r' r'')) s) false *) specialize(divide_Cat s (r ++ r') r'' H). intro H0. (* Goal: @eq bool (matches (Cat r (Cat r' r'')) s) true *) (* Goal: @eq bool (matches (Cat r (Cat r' r'')) s) false *) destruct H0 as [srr' [s_'' [H01 [H02 Hs_''r'']]]]. (* Goal: forall _ : @sigT string (fun s' : string => @sig string (fun s'' : string => and (@eq string srr' (append s' s'')) (and (@eq bool (matches r s') true) (@eq bool (matches r' s'') true)))), @eq bool (matches (Cat r (Cat r' r'')) s) true *) (* Goal: @eq bool (matches (Cat r (Cat r' r'')) s) false *) specialize(divide_Cat srr' r r' H02). intro H0. (* Goal: @eq bool (matches (Cat r (Cat r' r'')) s) true *) (* Goal: @eq bool (matches (Cat r (Cat r' r'')) s) false *) destruct H0 as [s_ [s_' [Hs_s_' [Hs_r Hs_'r']]]]. (* Goal: @eq bool (matches (Cat r (Cat r' r'')) s) true *) (* Goal: @eq bool (matches (Cat r (Cat r' r'')) s) false *) replace s with (s_ ++ (s_' ++ s_''))%string. (* Goal: @eq bool (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) *) eapply matches_Cat_Cat_right; auto. (* Goal: @eq bool (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) *) rewrite <- string_assoc. rewrite <- Hs_s_'. rewrite <- H01. auto. (* false *) (* Goal: @eq bool (matches (Cat r (Cat r' r'')) s) false *) specialize(divide_Cat_false s (r ++ r') r'' H). intros H0. (* Goal: @eq bool (matches (Cat r (Cat r' r'')) s) false *) case_eq ((r ++ r' ++ r'') ~= s); intro H1. (* true *) (* Goal: @eq bool true false *) (* Goal: @eq bool false false *) specialize(divide_Cat s r (r' ++ r'') H1). intros H2. (* Goal: @eq bool true false *) (* Goal: @eq bool false false *) destruct H2 as [s0 [s_ [Hs_ [Hrs Hs__]]]]. (* Goal: forall _ : @eq bool (matches (Cat r r') (append s0 s0')) true, @eq bool true false *) (* Goal: @eq bool false false *) specialize (divide_Cat s_ r' r'' Hs__). intros H2. (* Goal: @eq bool true false *) (* Goal: @eq bool false false *) destruct H2 as [s0' [s0'' [Hs [Hrs' Hrs'']]]]. (* Goal: forall _ : @eq bool (matches (Cat r r') (append s0 s0')) true, @eq bool true false *) (* Goal: @eq bool false false *) specialize (matches_Cat s0 s0' r r' Hrs Hrs'). intros H2. (* Goal: @eq bool true false *) (* Goal: @eq bool false false *) specialize (matches_Cat (s0 ++ s0')%string s0'' (r ++ r') r'' H2 Hrs''). (* Goal: forall _ : @eq bool (matches (Cat (Cat r r') r'') (append (append s0 s0') s0'')) true, @eq bool true false *) (* Goal: @eq bool false false *) intros H3. (* Goal: @eq bool true false *) (* Goal: @eq bool false false *) replace (((s0 ++ s0') ++ s0'')%string) with s in H3. (* Goal: @eq bool true false *) (* Goal: @eq string s (append (append s0 s0') s0'') *) (* Goal: @eq bool false false *) rewrite H in H3. discriminate H3. (* proof for replace *) (* Goal: @eq bool (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) *) erewrite string_assoc. rewrite <- Hs. rewrite <- Hs_. auto. (* false *) (* Goal: @eq bool (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) *) auto. Qed. Theorem Cat_assoc : forall r r' r'', (r ++ r') ++ r'' =R= r ++ (r' ++ r''). Proof. (* Goal: forall r r' r'' : RegExp, re_eq (Cat (Or r r') r'') (Or (Cat r r'') (Cat r' r'')) *) intros r r' r''. unfold re_eq. intro s. (* Goal: @eq bool (matches (Cat (Cat r r') r'') s) (matches (Cat r (Cat r' r'')) s) *) eapply Cat_assoc_s. Qed. (** ** [Cat] distributes to [Or]. *) Lemma Cat_left_distr_s : forall s r r' r'', (r ++ (r' || r'')) ~= s = ((r ++ r') || (r ++ r'')) ~= s. Proof. (* Goal: forall (s : string) (r r' r'' : RegExp), @eq bool (matches (Cat (Or r r') r'') s) (matches (Or (Cat r r'') (Cat r' r'')) s) *) induction s. (* s = "" *) (* Goal: @eq bool (matches (Cat (Or r r') r'') (String a s)) (matches (Or (Cat r r'') (Cat r' r'')) (String a s)) *) intros r r' r''. simpl. (* Goal: @eq bool (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) *) destruct(nu r); destruct(nu r'); destruct(nu r''); auto. (* s = String a s *) (* Goal: @eq bool (matches (Cat (Or r r') r'') (String a s)) (matches (Or (Cat r r'') (Cat r' r'')) (String a s)) *) intros r r' r''. simpl. case_eq (nu r); intro nu_r. (* nu r = true *) (* Goal: @eq bool (matches (Or (Cat (derive a r) (Or r' r'')) (Or (derive a r') (derive a r''))) s) (matches (Or (Or (Cat (derive a r) r') (derive a r')) (Or (Cat (derive a r) r'') (derive a r''))) s) *) (* Goal: @eq bool (matches (Cat (derive a r) (Or r' r'')) s) (matches (Or (Cat (derive a r) r') (Cat (derive a r) r'')) s) *) rewrite (matches_Or s (r / a ++ r' || r'') (r' / a || r'' / a)). (* Goal: @eq bool (orb (matches (Cat (derive a r) (Or r' r'')) s) (matches (Or (derive a r') (derive a r'')) s)) (matches (Or (Or (Cat (derive a r) r') (derive a r')) (Or (Cat (derive a r) r'') (derive a r''))) s) *) (* Goal: @eq bool (matches (Cat (derive a r) (Or r' r'')) s) (matches (Or (Cat (derive a r) r') (Cat (derive a r) r'')) s) *) rewrite (IHs (r / a) r' r''). (* Goal: @eq bool (orb (matches (Or (Cat (derive a r) r'') (Cat (derive a r') r'')) s) (matches (derive a r'') s)) (matches (Or (Cat (derive a r) r'') (Or (Cat (derive a r') r'') (derive a r''))) s) *) (* Goal: @eq bool (matches (Cat (Or (derive a r) (derive a r')) r'') s) (matches (Or (Cat (derive a r) r'') (Cat (derive a r') r'')) s) *) repeat erewrite matches_Or. destruct ((r / a ++ r') ~= s); destruct ((r / a ++ r'') ~= s); (* Goal: @eq bool (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) *) destruct (r' / a ~= s); destruct (r'' / a ~= s); auto. (* nu r = false *) (* Goal: @eq bool (matches (Cat (derive a r) (Or r' r'')) s) (matches (Or (Cat (derive a r) r') (Cat (derive a r) r'')) s) *) eapply IHs. Qed. Lemma Cat_left_distr : forall r r' r'', (r ++ (r' || r'')) =R= ((r ++ r') || (r ++ r'')). Proof. (* Goal: forall r r' r'' : RegExp, re_eq (Cat (Or r r') r'') (Or (Cat r r'') (Cat r' r'')) *) unfold re_eq. intros r r' r'' s. eapply Cat_left_distr_s. Qed. Lemma Cat_right_distr_s : forall s r r' r'', ((r || r') ++ r'') ~= s = ((r ++ r'') || (r' ++ r'')) ~= s. Proof. (* Goal: forall (s : string) (r r' r'' : RegExp), @eq bool (matches (Cat (Or r r') r'') s) (matches (Or (Cat r r'') (Cat r' r'')) s) *) induction s. (* s = "" *) (* Goal: @eq bool (matches (Cat (Or r r') r'') (String a s)) (matches (Or (Cat r r'') (Cat r' r'')) (String a s)) *) intros r r' r''. simpl. (* Goal: @eq bool (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) *) destruct (nu r); destruct (nu r'); destruct (nu r''); auto. (* s = String a s *) (* Goal: @eq bool (matches (Cat (Or r r') r'') (String a s)) (matches (Or (Cat r r'') (Cat r' r'')) (String a s)) *) intros r r' r''. simpl. (* Goal: @eq bool (matches (Cat (Or r r') r'') (String a s)) (matches (Or (Cat r r'') (Cat r' r'')) (String a s)) *) case_eq (nu r); intro nu_r; case_eq (nu r'); intro nu_r'; simpl. (* true true *) (* Goal: @eq bool (matches (Or (Cat (Or (derive a r) (derive a r')) r'') (derive a r'')) s) (matches (Or (Cat (derive a r) r'') (Or (Cat (derive a r') r'') (derive a r''))) s) *) (* Goal: @eq bool (matches (Cat (Or (derive a r) (derive a r')) r'') s) (matches (Or (Cat (derive a r) r'') (Cat (derive a r') r'')) s) *) rewrite (matches_Or s (r / a || r' / a ++ r'') (r'' / a)). (* Goal: @eq bool (matches (Cat (Or (derive a r) (derive a r')) r'') s) (matches (Or (Cat (derive a r) r'') (Cat (derive a r') r'')) s) *) rewrite (IHs (r / a) (r' / a) r''). (* Goal: @eq bool (orb (matches (Or (Cat (derive a r) r'') (Cat (derive a r') r'')) s) (matches (derive a r'') s)) (matches (Or (Cat (derive a r) r'') (Or (Cat (derive a r') r'') (derive a r''))) s) *) (* Goal: @eq bool (matches (Cat (Or (derive a r) (derive a r')) r'') s) (matches (Or (Cat (derive a r) r'') (Cat (derive a r') r'')) s) *) repeat erewrite matches_Or. destruct ((r / a ++ r'') ~= s); destruct ((r' / a ++ r'') ~= s); (* Goal: @eq bool (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) *) destruct (r'' / a ~= s); auto. (* true false *) (* Goal: @eq bool (matches (Or (Cat (Or (derive a r) (derive a r')) r'') (derive a r'')) s) (matches (Or (Cat (derive a r) r'') (Or (Cat (derive a r') r'') (derive a r''))) s) *) (* Goal: @eq bool (matches (Cat (Or (derive a r) (derive a r')) r'') s) (matches (Or (Cat (derive a r) r'') (Cat (derive a r') r'')) s) *) rewrite (matches_Or s (r / a || r' / a ++ r'') (r''/a)). (* Goal: @eq bool (matches (Cat (Or (derive a r) (derive a r')) r'') s) (matches (Or (Cat (derive a r) r'') (Cat (derive a r') r'')) s) *) rewrite (IHs (r/a) (r'/a) r''). (* Goal: @eq bool (orb (matches (Or (Cat (derive a r) r'') (Cat (derive a r') r'')) s) (matches (derive a r'') s)) (matches (Or (Cat (derive a r) r'') (Or (Cat (derive a r') r'') (derive a r''))) s) *) (* Goal: @eq bool (matches (Cat (Or (derive a r) (derive a r')) r'') s) (matches (Or (Cat (derive a r) r'') (Cat (derive a r') r'')) s) *) repeat erewrite matches_Or. destruct ((r / a ++ r'') ~= s); destruct ((r' / a ++ r'') ~= s); (* Goal: @eq bool (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) *) destruct (r'' / a ~= s); auto. (* false true *) (* Goal: @eq bool (matches (Or (Cat (Or (derive a r) (derive a r')) r'') (derive a r'')) s) (matches (Or (Cat (derive a r) r'') (Or (Cat (derive a r') r'') (derive a r''))) s) *) (* Goal: @eq bool (matches (Cat (Or (derive a r) (derive a r')) r'') s) (matches (Or (Cat (derive a r) r'') (Cat (derive a r') r'')) s) *) rewrite (matches_Or s (r / a || r' / a ++ r'') (r''/a)). (* Goal: @eq bool (matches (Cat (Or (derive a r) (derive a r')) r'') s) (matches (Or (Cat (derive a r) r'') (Cat (derive a r') r'')) s) *) rewrite (IHs (r/a) (r'/a) r''). (* Goal: @eq bool (orb (matches (Or (Cat (derive a r) r'') (Cat (derive a r') r'')) s) (matches (derive a r'') s)) (matches (Or (Cat (derive a r) r'') (Or (Cat (derive a r') r'') (derive a r''))) s) *) (* Goal: @eq bool (matches (Cat (Or (derive a r) (derive a r')) r'') s) (matches (Or (Cat (derive a r) r'') (Cat (derive a r') r'')) s) *) repeat erewrite matches_Or. destruct ((r / a ++ r'') ~= s); destruct ((r' / a ++ r'') ~= s); (* Goal: @eq bool (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) *) destruct (r'' / a ~= s); auto. (* false false *) (* Goal: @eq bool (matches (Cat (Or (derive a r) (derive a r')) r'') s) (matches (Or (Cat (derive a r) r'') (Cat (derive a r') r'')) s) *) rewrite (IHs (r/a) (r'/a) r''). (* Goal: @eq bool (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) (orb (matches (Cat (derive a r) r'') s) (matches (Cat (derive a r') r'') s)) *) erewrite matches_Or. auto. Qed. Lemma Cat_right_distr : forall r r' r'', ((r || r') ++ r'') =R= ((r ++ r'') || (r' ++ r'')). Proof. (* Goal: forall r r' r'' : RegExp, re_eq (Cat (Or r r') r'') (Or (Cat r r'') (Cat r' r'')) *) unfold re_eq. intros r r' r'' s. eapply Cat_right_distr_s. Qed.
(** * Coq codes *) (** ** Dependencies *) Require Import Recdef. Require Import Arith.Wf_nat. Require Import Omega. Require Export RegExp.Utility. Require Export RegExp.Definitions. Require Export RegExp.Boolean. Require Export RegExp.Concat. Require Export RegExp.Star. (** ** Define [includes] *) Definition includes (x y:RegExp) : Prop := (x || y) =R= y. Notation "x <= y" := (includes x y) (at level 70). Definition prop_eq (p q:Prop) : Prop := (p <-> q). Lemma prop_eq_equiv : equiv Prop prop_eq. Proof. (* Goal: equiv Prop prop_eq *) unfold equiv. split. (* Goal: and (includes y (Or x y)) (forall (z : RegExp) (_ : includes x z) (_ : includes y z), includes (Or x y) z) *) unfold reflexive. intros. unfold prop_eq. tauto. split. (* Goal: forall (x y : Prop) (_ : prop_eq x y), prop_eq y x *) unfold transitive. intros. unfold prop_eq in *. tauto. (* Goal: forall (x y : Prop) (_ : prop_eq x y), prop_eq y x *) unfold symmetric. intros. unfold prop_eq in *. tauto. Qed. Add Parametric Morphism : includes with signature re_eq ==> re_eq ==> prop_eq as includes_morphism. Proof. (* Goal: and (includes y (Or x y)) (forall (z : RegExp) (_ : includes x z) (_ : includes y z), includes (Or x y) z) *) intros x y H x0 y0 H0. unfold prop_eq. split. (* Goal: includes (Cat b (Star a)) x *) unfold includes. intros H1. setoid_rewrite <- H. setoid_rewrite <- H0. auto. (* Goal: includes (Cat b (Star a)) x *) unfold includes. intros H1. setoid_rewrite H. setoid_rewrite H0. auto. Qed. Lemma includes_reflexive : reflexive RegExp includes. Proof. (* Goal: reflexive RegExp includes *) unfold reflexive. intro x. unfold includes. eapply Or_idem. Qed. Lemma includes_antisymmetric : forall x y, x <= y -> y <= x -> x =R= y. Proof. (* Goal: forall (x y : RegExp) (_ : includes x y) (_ : includes y x), re_eq x y *) intros x y Hxy Hyx. unfold includes in *. (* Goal: re_eq x y *) setoid_rewrite Or_comm in Hyx. setoid_symmetry in Hyx. (* Goal: @eq bool (matches a s''0) true *) setoid_transitivity (x || y); auto. Qed. Lemma includes_transitive : transitive RegExp includes. Proof. (* Goal: transitive RegExp includes *) unfold transitive. intros x y z Hxy Hyz. unfold includes in *. (* Goal: re_eq (Or x z) z *) setoid_replace (x || z) with (x || (y || z)). (* Goal: re_eq (Or z (Or z x)) (Or z x) *) (* Goal: re_eq (Or x z) (Or z x) *) setoid_rewrite <- Or_assoc. (* Goal: @eq bool (matches a s''0) true *) setoid_rewrite Hxy. auto. (* Goal: re_eq (Or x z) (Or x (Or y z)) *) setoid_rewrite Hyz. setoid_reflexivity. Qed. Lemma implies_to_includes : forall x y, (forall s, x ~== s -> y ~== s) -> x <= y. Proof. (* Goal: forall (x y : RegExp) (_ : forall (s : string) (_ : @eq bool (matches x s) true), @eq bool (matches y s) true), includes x y *) intros x y Hsxy. (* Goal: includes x y *) unfold includes; unfold re_eq. intros s. (* Goal: @eq bool (matches (Or (Star x) (Star y)) s) (matches (Star y) s) *) erewrite matches_Or. (* Goal: @eq bool (matches a s''0) true *) case_eq(x ~= s); case_eq(y ~= s); try auto. (* Goal: forall (_ : @eq bool (matches y s) false) (_ : @eq bool (matches x s) true), @eq bool (orb true false) false *) intros Hys Hxs. rewrite (Hsxy s Hxs) in Hys. discriminate Hys. Qed. Lemma includes_to_implies : forall x y, x <= y -> (forall s, x ~== s -> y ~== s). Proof. (* Goal: forall (x y : RegExp) (_ : includes x y), includes (Star x) (Star y) *) intros x y Hxy. unfold includes in Hxy. unfold re_eq in Hxy. (* Goal: forall (s : string) (_ : @eq bool (matches x s) true), @eq bool (matches y s) true *) intros s Hx. specialize(Hxy s). erewrite matches_Or in Hxy. (* Goal: @eq bool (matches a s''0) true *) destruct(x ~= s); destruct(y ~= s); try discriminate Hx; try discriminate Hxy; auto. Qed. (** [x || y] is the least upper bound of [x] and [y] *) Lemma Cat_least_upper_bound : forall x y, x <= (x || y) /\ y <= (x || y) /\ (forall z, x <= z -> y <= z -> (x || y) <= z). Proof. (* Goal: and (includes y (Or x y)) (forall (z : RegExp) (_ : includes x z) (_ : includes y z), includes (Or x y) z) *) intros x y. split. (* x <= x || y *) (* Goal: includes (Cat b (Star a)) x *) unfold includes. setoid_rewrite <- Or_assoc. setoid_rewrite Or_idem. (* Goal: re_eq (Star r) (Star r) *) setoid_reflexivity. (* Goal: and (includes y (Or x y)) (forall (z : RegExp) (_ : includes x z) (_ : includes y z), includes (Or x y) z) *) split. (* y <= x || y *) (* Goal: includes (Cat b (Star a)) x *) unfold includes. setoid_replace (y || (x || y)) with (y || (y || x)). (* Goal: re_eq (Or z (Or z x)) (Or z x) *) (* Goal: re_eq (Or x z) (Or z x) *) setoid_rewrite <- Or_assoc. setoid_rewrite Or_idem. (* Goal: re_eq (Or x z) (Or z x) *) eapply Or_comm. (* Goal: re_eq (Star r) (Star r) *) setoid_replace (x || y) with (y || x). setoid_reflexivity. (* Goal: re_eq (Or x z) (Or z x) *) eapply Or_comm. (* forall z : RegExp, x <= z -> y <= z -> x || y <= z *) (* Goal: includes (Cat z x) (Cat z y) *) intros z Hxz Hyz. unfold includes in *. (* Goal: re_eq (Or (Or z x) z) (Or z x) *) setoid_rewrite Or_assoc. setoid_replace (y || z) with z. (* Goal: @eq bool (matches a s''0) true *) auto. auto. Qed. (** ** Monotonicity of [includes] *) Lemma includes_right_Or_monotone : forall x y z, x <= y -> (x || z) <= (y || z). Proof. (* Goal: includes (Cat z x) (Cat z y) *) intros x y z Hxy. unfold includes in *. (* Goal: re_eq (Or z (Or z x)) (Or z x) *) (* Goal: re_eq (Or x z) (Or z x) *) setoid_rewrite <- Or_assoc. setoid_replace (y || z) with ((x || y) || z). (* Goal: re_eq (Or (Or (Or x z) y) z) (Or (Or x y) z) *) (* Goal: re_eq (Or y z) (Or (Or x y) z) *) setoid_replace (x || z || y) with (x || y || z). (* Goal: re_eq (Or (Or (Or x y) z) z) (Or (Or x y) z) *) (* Goal: re_eq (Or (Or x z) y) (Or (Or x y) z) *) (* Goal: re_eq (Or y z) (Or (Or x y) z) *) setoid_replace (x || y || z || z) with (x || y || (z || z)). (* Goal: re_eq (Star r) (Star r) *) setoid_rewrite Or_idem. setoid_reflexivity. (* Goal: re_eq (Or z (Or z x)) (Or z x) *) (* Goal: re_eq (Or x z) (Or z x) *) repeat setoid_rewrite <- Or_assoc. setoid_reflexivity. (* Goal: re_eq (Or (Or z x) z) (Or z x) *) setoid_rewrite Or_assoc. setoid_replace (z || y) with (y || z). (* Goal: re_eq (Star r) (Star r) *) setoid_rewrite Or_comm. setoid_reflexivity. (* Goal: re_eq (Or x z) (Or z x) *) eapply Or_comm. (* Goal: @eq bool (matches a s''0) true *) setoid_replace (x || y) with y. setoid_reflexivity. auto. Qed. Lemma includes_left_Or_monotone : forall x y z, x <= y -> (z || x) <= (z || y). Proof. (* Goal: includes (Cat z x) (Cat z y) *) intros x y z Hxy. unfold includes in *. (* Goal: re_eq (Or z (Or z x)) (Or z x) *) (* Goal: re_eq (Or x z) (Or z x) *) repeat setoid_rewrite <- Or_assoc. (* Goal: re_eq (Or (Or (Or z x) z) y) (Or z y) *) setoid_replace (z || x || z) with (z || x). (* Goal: re_eq (Cat z (Or x y)) (Cat z y) *) setoid_rewrite Or_assoc. setoid_rewrite Hxy. setoid_reflexivity. (* Goal: re_eq (Or (Or z x) z) (Or z x) *) setoid_rewrite Or_assoc. setoid_replace (x || z) with (z || x). (* Goal: re_eq (Or z (Or z x)) (Or z x) *) (* Goal: re_eq (Or x z) (Or z x) *) setoid_rewrite <- Or_assoc. setoid_rewrite Or_idem. setoid_reflexivity. (* Goal: re_eq (Or x z) (Or z x) *) eapply Or_comm. Qed. Lemma includes_right_Cat_monotone : forall x y z, x <= y -> (x ++ z) <= (y ++ z). Proof. (* Goal: includes (Cat z x) (Cat z y) *) intros x y z Hxy. unfold includes in *. (* Goal: re_eq (Cat z (Or x y)) (Cat z y) *) erewrite <- Cat_right_distr. setoid_rewrite Hxy. setoid_reflexivity. Qed. Lemma includes_left_Cat_monotone : forall x y z, x <= y -> (z ++ x) <= (z ++ y). Proof. (* Goal: includes (Cat z x) (Cat z y) *) intros x y z Hxy. unfold includes in *. (* Goal: re_eq (Cat z (Or x y)) (Cat z y) *) erewrite <- Cat_left_distr. setoid_rewrite Hxy. setoid_reflexivity. Qed. Lemma includes_Star_monotone : forall x y, x <= y -> (Star x) <= (Star y). Proof. (* Goal: forall (x y : RegExp) (_ : includes x y), includes (Star x) (Star y) *) intros x y Hxy. specialize(includes_to_implies x y Hxy). intro H01. (* Goal: includes (Star x) (Star y) *) assert(H1: forall s, Star x ~== s -> Star y ~== s). (* Goal: forall (s : string) (_ : @eq bool (matches (Star x) s) true), @eq bool (matches (Star y) s) true *) (* Goal: includes (Star x) (Star y) *) intros s HSx. specialize(Star_to_list s x HSx). intros H. (* Goal: @eq bool (matches (Star y) s) true *) (* Goal: includes (Star x) (Star y) *) destruct H as [ss [Ha [Hb Hc]]]. assert(H1': forall zs, forallb (fun s : string => x ~= s) zs = true -> forallb (fun s : string => y ~= s) zs = true). (* Goal: @eq bool (matches a s''0) true *) induction zs. simpl. intro H. auto. (* Goal: gt (str_length (String a0 s''0)) O *) (* Goal: @eq bool (matches x s) true *) simpl. intro H. case_eq(x ~= a); case_eq(forallb (fun s : string => x ~= s) zs); intros H' H''; rewrite H' in H; rewrite H'' in H; simpl in H; try discriminate H. (* Goal: @eq bool (matches a s''0) true *) replace (y ~= a) with true. erewrite (IHzs H'). auto. (* Goal: @eq bool (matches a s''0) true *) symmetry. eapply H01. auto. (* Goal: forall _ : @eq bool (matches (Or (Or b (Cat x a)) x) s) true, @eq bool (matches x s) true *) (* Goal: @eq bool (matches (Or (Or b (Cat x a)) x) s) true *) (* Goal: @eq bool (matches x s) true *) specialize(H1' ss Ha). specialize(list_to_Star ss y H1'). intros H. (* Goal: @eq bool (matches a s''0) true *) erewrite Hb in H. auto. (* Goal: includes (Star x) (Star y) *) assert(H02: forall s, y ~!= s -> x ~!= s). (* Goal: @eq bool (matches x s) false *) (* Goal: includes (Star x) (Star y) *) intros s Hy. specialize(Hxy s). erewrite matches_Or in Hxy. (* Goal: @eq bool (matches x s) false *) (* Goal: includes (Star x) (Star y) *) rewrite Hy in Hxy. (* Goal: @eq bool (matches x s) false *) (* Goal: includes (Star x) (Star y) *) destruct(x ~= s). (* Goal: @eq bool true false *) (* Goal: @eq bool false false *) (* Goal: includes (Star x) (Star y) *) simpl in Hxy. discriminate Hxy. (* Goal: @eq bool (matches a s''0) true *) auto. (* Goal: includes (Cat b (Star a)) x *) unfold includes. unfold re_eq. intro s. erewrite matches_Or. case_eq (Star x ~= s); case_eq (Star y ~= s); simpl; intros H' H''; try reflexivity. (* Goal: @eq bool true false *) specialize(H1 s H''). rewrite H' in H1. discriminate H1. Qed. (** ** Axioms for [includes] *) (** See also lemma [matches_Star_right] which is stronger lemma. *) Theorem Star_right : forall r, (Eps || (r ++ Star r)) <= Star r. Proof. (* Goal: forall r : RegExp, includes (Or Eps (Cat (Star r) r)) (Star r) *) intros r. (* Goal: includes (Cat b (Star a)) x *) unfold includes. setoid_rewrite <- matches_Star_right. (* Goal: re_eq (Star r) (Star r) *) setoid_rewrite Or_idem. setoid_reflexivity. Qed. (** See also lemma [matches_Star_left] which is stronger lemma. *) Theorem Star_left : forall r, (Eps || (Star r ++ r)) <= Star r. Proof. (* Goal: forall r : RegExp, includes (Or Eps (Cat (Star r) r)) (Star r) *) intros r. (* Goal: includes (Cat b (Star a)) x *) unfold includes. setoid_rewrite <- matches_Star_left. (* Goal: re_eq (Star r) (Star r) *) setoid_rewrite Or_idem. setoid_reflexivity. Qed. Lemma Star_eq_left_s : forall s a b x, (b || (a ++ x)) <= x -> ((Star a) ++ b) ~== s -> x ~== s. Proof. (* Goal: forall (s : string) (a b x : RegExp) (_ : includes (Or b (Cat x a)) x) (_ : @eq bool (matches (Cat b (Star a)) s) true), @eq bool (matches x s) true *) refine (induction_ltof2 string str_length _ _). (* Goal: forall (x : string) (_ : forall (y : string) (_ : ltof string str_length y x) (a b x0 : RegExp) (_ : includes (Or b (Cat a x0)) x0) (_ : @eq bool (matches (Cat (Star a) b) y) true), @eq bool (matches x0 y) true) (a b x0 : RegExp) (_ : includes (Or b (Cat a x0)) x0) (_ : @eq bool (matches (Cat (Star a) b) x) true), @eq bool (matches x0 x) true *) intros s IH a b x Hbax HSab. (* Goal: @eq bool (matches x s) true *) specialize(divide_Cat s (Star a) b HSab). intro H'. (* Goal: @eq bool (matches x s) true *) destruct H' as [s' [s'' [H01 [H02 H03]]]]. (* Goal: @eq bool (matches x s) true *) case_eq (string_dec s' ""%string); intros Hs _. (* s = "" *) (* Goal: @eq bool (matches x s) true *) (* Goal: @eq bool (matches x s) true *) rewrite Hs in *. simpl in H01. (* Goal: forall _ : @eq bool (matches (Or (Or b (Cat x a)) x) s) true, @eq bool (matches x s) true *) (* Goal: @eq bool (matches (Or (Or b (Cat x a)) x) s) true *) (* Goal: @eq bool (matches x s) true *) unfold includes in Hbax. cut ((b || (a ++ x) || x) ~== s). intros H. (* Goal: @eq bool (matches a s''0) true *) unfold re_eq in Hbax. specialize(Hbax s). rewrite <- Hbax. auto. (* Goal: @eq bool (matches a s''0) true *) repeat rewrite matches_Or. rewrite H01. rewrite H03. simpl. auto. (* s <> "" *) (* Goal: @eq bool (matches x s) true *) specialize(divide_Star_right s' a H02 Hs). intro H0. (* Goal: @eq bool (matches x s) true *) destruct H0 as [s'0 [s''0 [H11 [H12 [H13 H14]]]]]. (* y = s''0 ++ s'' *) (* Goal: @eq bool (matches x s) true *) assert(Hltof: ltof string str_length (s''0 ++ s'')%string s). (* Goal: @eq bool (matches (Cat x a) s) true *) unfold ltof. rewrite H01. rewrite H11. (* Goal: lt (str_length (append s' s'0)) (str_length (append s' (append s'0 s''0))) *) (* Goal: @eq bool (matches x s) true *) repeat rewrite str_length_append. (* Goal: lt (Init.Nat.add (str_length s''0) (str_length s'')) (Init.Nat.add (Init.Nat.add (str_length s'0) (str_length s''0)) (str_length s'')) *) (* Goal: @eq bool (matches x s) true *) cut(str_length s'0 > 0). intro Hs'0. omega. (* Goal: gt (str_length s'0) O *) (* Goal: @eq bool (matches x s) true *) induction s'0. (* Goal: @eq bool (matches a s''0) true *) elim H12. auto. (* Goal: gt (str_length (String a0 s''0)) O *) (* Goal: @eq bool (matches x s) true *) simpl. omega. (* Goal: @eq bool (matches x s) true *) assert(Hy: (Star a ++ b) ~== (s''0 ++ s'')). (* Goal: @eq bool (matches a s''0) true *) eapply matches_Cat. auto. auto. (* Goal: @eq bool (matches x s) true *) assert(Hy': x ~== (s''0 ++ s'')%string). (* Goal: @eq bool (matches x (append s''0 s'')) true *) (* Goal: @eq bool (matches x s) true *) apply (IH (s''0 ++ s'')%string Hltof a b x Hbax Hy). (* Goal: @eq bool (matches x s) true *) unfold includes in Hbax. unfold re_eq in Hbax. (* Goal: @eq bool (matches a s''0) true *) cut(b || (a ++ x) || x ~== s). intro H. rewrite <- (Hbax s). auto. (* Goal: forall _ : includes (Or b (Cat x a)) x, includes (Cat b (Star a)) x *) repeat rewrite matches_Or. cut((a ++ x) ~== s). intro H. rewrite H. (* Goal: @eq bool (orb (orb (matches b s) true) (matches x s)) true *) (* Goal: @eq bool (matches (Cat x a) s) true *) destruct(b ~= s); destruct(x ~= s); reflexivity. (* Goal: @eq bool (matches (Cat x a) s) true *) rewrite H01. rewrite H11. rewrite string_assoc. (* Goal: @eq bool (matches a s''0) true *) eapply matches_Cat. auto. auto. Qed. Theorem Star_eq_left : forall a b x, (b || (a ++ x)) <= x -> ((Star a) ++ b) <= x. Proof. (* Goal: includes (Cat b (Star a)) x *) intros a b x. intro H. unfold includes. unfold re_eq. intro s. case_eq((Star a ++ b) ~= s); case_eq(x ~= s); intros H1 H2; rewrite matches_Or; rewrite H1; rewrite H2; try reflexivity. (* Goal: @eq bool (orb true false) false *) specialize(Star_eq_left_s s a b x H H2). intro H'. rewrite H' in H1. (* Goal: @eq bool (orb true false) false *) discriminate H1. Qed. Theorem Star_eq_right_s : forall s a b x, (b || (x ++ a)) <= x -> (b ++ (Star a)) ~== s -> x ~== s. Proof. (* Goal: forall (s : string) (a b x : RegExp) (_ : includes (Or b (Cat x a)) x) (_ : @eq bool (matches (Cat b (Star a)) s) true), @eq bool (matches x s) true *) refine (induction_ltof2 string str_length _ _). (* Goal: forall (x : string) (_ : forall (y : string) (_ : ltof string str_length y x) (a b x0 : RegExp) (_ : includes (Or b (Cat x0 a)) x0) (_ : @eq bool (matches (Cat b (Star a)) y) true), @eq bool (matches x0 y) true) (a b x0 : RegExp) (_ : includes (Or b (Cat x0 a)) x0) (_ : @eq bool (matches (Cat b (Star a)) x) true), @eq bool (matches x0 x) true *) intros s IH a b x Hbxa HbSa. (* Goal: forall _ : @eq bool (matches x s) true, @eq bool (orb true false) false *) specialize(divide_Cat s b (Star a) HbSa). intro H'. (* Goal: @eq bool (matches x s) true *) destruct H' as [s' [s'' [H01 [H02 H03]]]]. (* Goal: @eq bool (matches x s) true *) case_eq (string_dec s'' ""%string); intros Hs _. (* s'' = "" *) (* Goal: @eq bool (matches x s) true *) (* Goal: @eq bool (matches x s) true *) rewrite Hs in *. rewrite string_right_id in H01. (* Goal: forall _ : @eq bool (matches (Or (Or b (Cat x a)) x) s) true, @eq bool (matches x s) true *) (* Goal: @eq bool (matches (Or (Or b (Cat x a)) x) s) true *) (* Goal: @eq bool (matches x s) true *) unfold includes in Hbxa. cut ((b || (x ++ a) || x) ~== s). intros H. (* Goal: @eq bool (matches a s''0) true *) unfold re_eq in Hbxa. specialize(Hbxa s). rewrite <- Hbxa. auto. (* Goal: @eq bool (matches a s''0) true *) repeat rewrite matches_Or. rewrite H01. rewrite H02. simpl. auto. (* s'' <> "" *) (* Goal: forall _ : @sigT string (fun s' : string => @sig string (fun s''0 : string => and (@eq string s'' (append s' s''0)) (and (not (@eq string s''0 EmptyString)) (and (@eq bool (matches (Star a) s') true) (@eq bool (matches a s''0) true))))), @eq bool (matches x s) true *) specialize(divide_Star_left s'' a H03 Hs). intro H0. (* Goal: @eq bool (matches x s) true *) destruct H0 as [s'0 [s''0 [H11 [H12 [H13 H14]]]]]. (* y = s' ++ s'0 *) (* Goal: @eq bool (matches x s) true *) assert(Hltof: ltof string str_length (s' ++ s'0)%string s). (* Goal: @eq bool (matches (Cat x a) s) true *) unfold ltof. rewrite H01. rewrite H11. (* Goal: lt (str_length (append s' s'0)) (str_length (append s' (append s'0 s''0))) *) (* Goal: @eq bool (matches x s) true *) repeat rewrite str_length_append. (* Goal: gt (S (str_length s''0)) O *) (* Goal: @eq bool (matches x s) true *) cut(str_length s''0 > 0). intro Hs''0. omega. (* Goal: gt (str_length s''0) O *) (* Goal: @eq bool (matches x s) true *) induction s''0. (* Goal: @eq bool (matches a s''0) true *) elim H12. auto. (* Goal: gt (str_length (String a0 s''0)) O *) (* Goal: @eq bool (matches x s) true *) simpl. omega. (* Goal: @eq bool (matches x s) true *) assert(Hy: (b ++ Star a) ~== (s' ++ s'0)). (* Goal: @eq bool (matches a s''0) true *) eapply matches_Cat. auto. auto. (* Goal: @eq bool (matches x s) true *) assert(Hy': x ~== (s' ++ s'0)%string). (* Goal: @eq bool (matches x (append s' s'0)) true *) (* Goal: @eq bool (matches x s) true *) apply (IH (s' ++ s'0)%string Hltof a b x Hbxa Hy). (* Goal: @eq bool (matches x s) true *) unfold includes in Hbxa. unfold re_eq in Hbxa. (* Goal: @eq bool (matches a s''0) true *) cut(b || (x ++ a) || x ~== s). intro H. rewrite <- (Hbxa s). auto. (* Goal: forall _ : includes (Or b (Cat x a)) x, includes (Cat b (Star a)) x *) repeat rewrite matches_Or. cut((x ++ a) ~== s). intro H. rewrite H. (* Goal: @eq bool (orb (orb (matches b s) true) (matches x s)) true *) (* Goal: @eq bool (matches (Cat x a) s) true *) destruct(b ~= s); destruct(x ~= s); reflexivity. (* Goal: @eq bool (matches (Cat x a) s) true *) rewrite H01. rewrite H11. rewrite <- string_assoc. (* Goal: @eq bool (matches a s''0) true *) eapply matches_Cat. auto. auto. Qed. Theorem Star_eq_right : forall a b x, (b || (x ++ a)) <= x -> (b ++ (Star a)) <= x. Proof. (* Goal: includes (Cat b (Star a)) x *) intros a b x. intro H. unfold includes. unfold re_eq. intro s. case_eq((b ++ Star a) ~= s); case_eq(x ~= s); intros H1 H2; rewrite matches_Or; rewrite H1; rewrite H2; try reflexivity. (* Goal: @eq bool (orb true false) false *) specialize(Star_eq_right_s s a b x H H2). intro H'. rewrite H' in H1. (* Goal: @eq bool (orb true false) false *) discriminate H1. Qed.
(* This program is free software; you can redistribute it and/or *) (* modify it under the terms of the GNU Lesser General Public License *) (* as published by the Free Software Foundation; either version 2.1 *) (* of the License, or (at your option) any later version. *) (* *) (* This program is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* GNU General Public License for more details. *) (* *) (* You should have received a copy of the GNU Lesser General Public *) (* License along with this program; if not, write to the Free *) (* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *) (* 02110-1301 USA *) (********************************************************) (* Une axiomatisation en coq de la norme IEEE 754 *) (* Module IEEE754_properties.v *) (* un plan d'ensemble se trouve dans le fichier README *) (* Patrick Loiseleur, avril 1997 *) (********************************************************) Require Import Omega. Require Import Zcomplements. Require Import Zpower. Require Import Zlogarithm. Require Import Diadic. Require Import IEEE754_def. Section basic_verifs. Lemma max_abstract_wf : forall (b : bool) (t : float_type), abstract_wf t (max_abstract t b). simple induction b; simple induction t; compute in |- *; split; split; trivial || discriminate. Qed. (**** Lemma abstract_of_diadic_wf : (t:float_type)(m:rounding_mode)(d:diadic) (abstract_wf t (abstract_of_diadic t m d)). Intro t; Destruct m; Intro d; Red. Unfold abstract_of_diadic; Trivial. ****) End basic_verifs.
(* This program is free software; you can redistribute it and/or *) (* modify it under the terms of the GNU Lesser General Public License *) (* as published by the Free Software Foundation; either version 2.1 *) (* of the License, or (at your option) any later version. *) (* *) (* This program is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* GNU General Public License for more details. *) (* *) (* You should have received a copy of the GNU Lesser General Public *) (* License along with this program; if not, write to the Free *) (* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *) (* 02110-1301 USA *) (********************************************************) (* Une axiomatisation en coq de la norme IEEE 754 *) (* Module Diadic.v *) (* un plan d'ensemble se trouve dans le fichier README *) (* Patrick Loiseleur, avril 1997 *) (********************************************************) Require Import Omega. Require Import Zcomplements. Require Import Zpower. Require Import Zlogarithm. Require Import ZArithRing. Section definitions. (* The type diadic represents the set of numbers who can be written: *) (* x = n*2^p with n and p in Z. (diadic numbers) *) (* n = Dnum and p = Dexp *) Record diadic : Set := Diadic {Dnum : Z; Dexp : Z}. Definition Dshift (n : Z) (x : diadic) := Diadic (Dnum x) (Dexp x + n). Definition Dzero (x : Z) := Diadic 0 x. Definition is_Dzero (x : diadic) := Dnum x = 0%Z. (** Fixpoint Dnormalize[x:diadic] : diadic := Cases (Dnum x) of (POS (xO y)) => (Dnormalize (Diadic (POS y) `(Dexp x)+1`)) | (NEG (xO y)) => (Dnormalize (Diadic (NEG y) `(Dexp x)+1`)) | _ => x end. **) Inductive rounding_mode : Set := | Rounding_sup : rounding_mode | Rounding_inf : rounding_mode | Rounding_nearest : rounding_mode | Rounding_zero : rounding_mode. Definition Rounding_mode_opp (m : rounding_mode) := match m with | Rounding_sup => Rounding_inf | Rounding_inf => Rounding_sup | Rounding_nearest => Rounding_nearest | Rounding_zero => Rounding_zero end. (* This inductive set, equal to {-infty}+Z+Z (disjoint union) is the set of results of function DLog. *) (**** Inductive DLog_result : Set := M_infty : DLog_result | Log_of_pos : Z -> DLog_result | Log_of_neg : Z -> DLog_result. ****) End definitions. Section comparisons. (* Fist a function Qcompare is defined, who takes two diadic numbers *) (* and answers SUPERIEUR, EGAL or INFERIEUR. *) (* Qcompare is similary to Zcompare from the omega library *) (* Then the usual predicates "less or equal", "less than", "greater *) (* or equal" and "greater than" are defined. Since these predicates *) (* are deterministic, the boolean equivalents are also defined *) (* Be careful ! Two diadic numbers x, y are equal iff the predicate *) (* (Deq x y) is true, that is (Dcompare x y)=EGAL *) (* That's not equivalent to : (eq D x y) *) Definition Dcompare (x y : diadic) : Datatypes.comparison := let nx := Dnum x in let ny := Dnum y in let ex := Dexp x in let ey := Dexp y in (two_p (ex - Zmin ex ey) * nx ?= two_p (ey - Zmin ex ey) * ny)%Z. (* Inductive relation := EGAL | INFERIEUR | SUPERIEUR *) Definition Deq (x y : diadic) := match Dcompare x y with | Datatypes.Eq => True | Datatypes.Lt => False | Datatypes.Gt => False end. Definition Dneq (x y : diadic) := match Dcompare x y with | Datatypes.Eq => False | Datatypes.Lt => True | Datatypes.Gt => True end. Definition Dle (x y : diadic) := match Dcompare x y with | Datatypes.Eq => True | Datatypes.Lt => True | Datatypes.Gt => False end. Definition Dlt (x y : diadic) := match Dcompare x y with | Datatypes.Eq => False | Datatypes.Lt => True | Datatypes.Gt => False end. Definition Dge (x y : diadic) := match Dcompare x y with | Datatypes.Eq => True | Datatypes.Lt => False | Datatypes.Gt => True end. Definition Dgt (x y : diadic) := match Dcompare x y with | Datatypes.Eq => False | Datatypes.Lt => False | Datatypes.Gt => True end. Definition Deq_bool (x y : diadic) := match Dcompare x y with | Datatypes.Eq => true | Datatypes.Lt => false | Datatypes.Gt => false end. Definition Dneq_bool (x y : diadic) := match Dcompare x y with | Datatypes.Eq => false | Datatypes.Lt => true | Datatypes.Gt => true end. Definition Dle_bool (x y : diadic) := match Dcompare x y with | Datatypes.Eq => true | Datatypes.Lt => true | Datatypes.Gt => false end. Definition Dlt_bool (x y : diadic) := match Dcompare x y with | Datatypes.Eq => false | Datatypes.Lt => true | Datatypes.Gt => false end. Definition Dge_bool (x y : diadic) := match Dcompare x y with | Datatypes.Eq => true | Datatypes.Lt => false | Datatypes.Gt => true end. Definition Dgt_bool (x y : diadic) := match Dcompare x y with | Datatypes.Eq => false | Datatypes.Lt => false | Datatypes.Gt => true end. Lemma Dcompare_shift : forall (x y : diadic) (n : Z), Dcompare (Dshift n x) (Dshift n y) = Dcompare x y. unfold Dcompare in |- *; simpl in |- *; intros; rewrite (Zmin.Zmin_plus (Dexp x) (Dexp y) n). (* Goal: @eq comparison (Z.compare (Z.mul (two_p (Z.sub (Z.add (Dexp x) n) (Z.add (Z.min (Dexp x) (Dexp y)) n))) (Dnum x)) (Z.mul (two_p (Z.sub (Z.add (Dexp y) n) (Z.add (Z.min (Dexp x) (Dexp y)) n))) (Dnum y))) (Z.compare (Z.mul (two_p (Z.sub (Dexp x) (Z.min (Dexp x) (Dexp y)))) (Dnum x)) (Z.mul (two_p (Z.sub (Dexp y) (Z.min (Dexp x) (Dexp y)))) (Dnum y))) *) do 2 rewrite BinInt.Zminus_plus_simpl_r. (* Goal: @eq Z (Z.mul (two_p (Z.sub ex (Z.min ex (Z.sub ex n)))) nx) (Z.mul (two_p (Z.sub ex (Z.min ex (Z.sub ex n)))) nx) *) (* Goal: Z.le Z0 (Z.sub (Z.sub ex n) (Z.min ex (Z.sub ex n))) *) (* Goal: Z.le Z0 n *) reflexivity. Qed. Lemma eq_Deq : forall x y : diadic, x = y -> Deq x y. intros; rewrite H; unfold Deq in |- *; unfold Dcompare in |- *; apply Zcompare.Zcompare_eq_case; trivial. Qed. (* Links between Zcompare and Dcompare, Zle and Dle *) Lemma Dcompare_zero : forall (x : diadic) (n : Z), Dcompare x (Dzero n) = (Dnum x ?= 0)%Z. (* Goal: forall (x : diadic) (n : Z), @eq comparison (Dcompare x (Dzero n)) (Z.compare (Dnum x) Z0) *) intros (nx, ex) n. (* Goal: @eq comparison (Dcompare (Diadic nx ex) (Dzero n)) (Z.compare (Dnum (Diadic nx ex)) Z0) *) unfold Dcompare in |- *; simpl in |- *. symmetry in |- *. (* Goal: @eq comparison (Z.compare nx Z0) (Z.compare (Z.mul (two_p (Z.sub ex (Z.min ex n))) nx) (Z.mul (two_p (Z.sub n (Z.min ex n))) Z0)) *) replace (two_p (n - Zmin ex n) * 0)%Z with (two_p (ex - Zmin ex n) * 0)%Z. (* Goal: @eq comparison (Z.compare nx Z0) (Z.compare (Z.mul (two_p (Z.sub ex (Z.min ex n))) nx) (Z.mul (two_p (Z.sub ex (Z.min ex n))) Z0)) *) (* Goal: @eq Z (Z.mul (two_p (Z.sub ex (Z.min ex n))) Z0) (Z.mul (two_p (Z.sub n (Z.min ex n))) Z0) *) apply Zmult_compare_compat_l. (* Goal: Z.gt (two_p (Z.sub ex (Z.min ex n))) Z0 *) (* Goal: @eq Z (Z.mul (two_p (Z.sub ex (Z.min ex n))) Z0) (Z.mul (two_p (Z.sub n (Z.min ex n))) Z0) *) apply two_p_gt_ZERO. (* Goal: Z.le Z0 (Z.sub ex (Z.min ex n)) *) (* Goal: @eq Z (Z.mul (two_p (Z.sub ex (Z.min ex n))) Z0) (Z.mul (two_p (Z.sub n (Z.min ex n))) Z0) *) generalize (Zle_min_l ex n); generalize (Zmin ex n); intro; omega. (* Goal: @eq Z (Z.mul (two_p (Z.sub ex (Z.min ex (Z.sub ex n)))) nx) (Z.mul (two_p (Z.sub ex (Z.min ex (Z.sub ex n)))) nx) *) (* Goal: Z.le Z0 (Z.sub (Z.sub ex n) (Z.min ex (Z.sub ex n))) *) (* Goal: Z.le Z0 n *) do 2 rewrite Zmult_0_r; reflexivity. Qed. Lemma Deq_shift : forall (x y : diadic) (n : Z), Deq x y -> Deq (Dshift n x) (Dshift n y). (* Goal: forall (x y : diadic) (n : Z) (_ : Deq x y), Deq (Dshift n x) (Dshift n y) *) unfold Deq in |- *; intros; rewrite (Dcompare_shift x y n); trivial. Qed. Lemma Deq_x_shift_x : forall (x : diadic) (n : Z), (0 <= n)%Z -> Deq x (Diadic (Dnum x * two_p n) (Dexp x - n)). intros (nx, ex) n Hn; unfold Deq in |- *; unfold Dcompare in |- *; simpl in |- *. cut ((two_p (ex - Zmin ex (ex - n)) * nx)%Z = (two_p (ex - n - Zmin ex (ex - n)) * (nx * two_p n))%Z). (* Goal: forall _ : @eq Z (Z.mul (two_p (Z.sub ex (Z.min ex (Z.sub ex n)))) nx) (Z.mul (two_p (Z.sub (Z.sub ex n) (Z.min ex (Z.sub ex n)))) (Z.mul nx (two_p n))), match Z.compare (Z.mul (two_p (Z.sub ex (Z.min ex (Z.sub ex n)))) nx) (Z.mul (two_p (Z.sub (Z.sub ex n) (Z.min ex (Z.sub ex n)))) (Z.mul nx (two_p n))) with | Eq => True | Lt => False | Gt => False end *) (* Goal: @eq Z (Z.mul (two_p (Z.sub ex (Z.min ex (Z.sub ex n)))) nx) (Z.mul (two_p (Z.sub (Z.sub ex n) (Z.min ex (Z.sub ex n)))) (Z.mul nx (two_p n))) *) intro H; rewrite H. (* Goal: match Z.compare (Z.mul (two_p (Z.sub (Z.sub ex n) (Z.min ex (Z.sub ex n)))) (Z.mul nx (two_p n))) (Z.mul (two_p (Z.sub (Z.sub ex n) (Z.min ex (Z.sub ex n)))) (Z.mul nx (two_p n))) with | Eq => True | Lt => False | Gt => False end *) (* Goal: @eq Z (Z.mul (two_p (Z.sub ex (Z.min ex (Z.sub ex n)))) nx) (Z.mul (two_p (Z.sub (Z.sub ex n) (Z.min ex (Z.sub ex n)))) (Z.mul nx (two_p n))) *) generalize (two_p (ex - n - Zmin ex (ex - n)) * (nx * two_p n))%Z. (* Goal: forall z : Z, match Z.compare z z with | Eq => True | Lt => False | Gt => False end *) (* Goal: @eq Z (Z.mul (two_p (Z.sub ex (Z.min ex (Z.sub ex n)))) nx) (Z.mul (two_p (Z.sub (Z.sub ex n) (Z.min ex (Z.sub ex n)))) (Z.mul nx (two_p n))) *) intros. generalize (Zcompare.Zcompare_refl z). (* Goal: forall _ : @eq comparison (Z.compare z z) Eq, match Z.compare z z with | Eq => True | Lt => False | Gt => False end *) (* Goal: @eq Z (Z.mul (two_p (Z.sub ex (Z.min ex (Z.sub ex n)))) nx) (Z.mul (two_p (Z.sub (Z.sub ex n) (Z.min ex (Z.sub ex n)))) (Z.mul nx (two_p n))) *) elim (z ?= z)%Z; discriminate || trivial. (* Goal: @eq Z (Z.mul (two_p (Z.sub ex (Z.min ex (Z.sub ex n)))) nx) (Z.mul (two_p (Z.sub (Z.sub ex n) (Z.min ex (Z.sub ex n)))) (Z.mul nx (two_p n))) *) rewrite (Zmult_comm nx (two_p n)). (* Goal: @eq Z (Z.mul (two_p (Z.sub ex (Z.min ex (Z.sub ex n)))) nx) (Z.mul (two_p (Z.sub (Z.sub ex n) (Z.min ex (Z.sub ex n)))) (Z.mul (two_p n) nx)) *) rewrite <- Zmult_assoc_reverse. (* Goal: @eq Z (Z.mul (two_p (Z.sub ex (Z.min ex (Z.sub ex n)))) nx) (Z.mul (Z.mul (two_p (Z.sub (Z.sub ex n) (Z.min ex (Z.sub ex n)))) (two_p n)) nx) *) rewrite <- two_p_is_exp. (* Goal: @eq Z (Z.mul (two_p (Z.sub ex (Z.min ex (Z.sub ex n)))) nx) (Z.mul (two_p (Z.add (Z.sub (Z.sub ex n) (Z.min ex (Z.sub ex n))) n)) nx) *) (* Goal: Z.le Z0 (Z.sub (Z.sub ex n) (Z.min ex (Z.sub ex n))) *) (* Goal: Z.le Z0 n *) ring_simplify (ex - n - Zmin ex (ex - n) + n)%Z (ex - Zmin ex (ex - n))%Z. (* Goal: @eq Z (Z.mul (two_p (Z.sub ex (Z.min ex (Z.sub ex n)))) nx) (Z.mul (two_p (Z.sub ex (Z.min ex (Z.sub ex n)))) nx) *) (* Goal: Z.le Z0 (Z.sub (Z.sub ex n) (Z.min ex (Z.sub ex n))) *) (* Goal: Z.le Z0 n *) reflexivity. (* Goal: Z.le Z0 (Z.sub (Z.sub ex n) (Z.min ex (Z.sub ex n))) *) (* Goal: Z.le Z0 n *) generalize (Zle_min_l ex (ex - n)) (Zle_min_r ex (ex - n)). (* Goal: forall (_ : Z.le (Z.min ex (Z.sub ex n)) ex) (_ : Z.le (Z.min ex (Z.sub ex n)) (Z.sub ex n)), Z.le Z0 (Z.sub (Z.sub ex n) (Z.min ex (Z.sub ex n))) *) (* Goal: Z.le Z0 n *) omega. (* Goal: Z.le Z0 n *) assumption. Qed. Lemma Dle_Zle : forall n1 n2 d : Z, (n1 <= n2)%Z -> Dle (Diadic n1 d) (Diadic n2 d). (* Goal: @eq comparison (Dcompare (Diadic nx ex) (Dzero n)) (Z.compare (Dnum (Diadic nx ex)) Z0) *) intros; unfold Dle in |- *; unfold Dcompare in |- *; simpl in |- *. (* Goal: match Z.compare (Z.mul (two_p (Z.sub d (Z.min d d))) n1) (Z.mul (two_p (Z.sub d (Z.min d d))) n2) with | Eq => False | Lt => False | Gt => True end *) rewrite (Zmin_n_n d). (* Goal: match Z.compare (Z.mul (two_p (Z.sub d d)) n1) (Z.mul (two_p (Z.sub d d)) n2) with | Eq => False | Lt => False | Gt => True end *) rewrite <- (Zminus_diag_reverse d). (* Goal: match Z.compare (Z.mul (two_p Z0) n1) (Z.mul (two_p Z0) n2) with | Eq => False | Lt => False | Gt => True end *) unfold two_p in |- *. (* Goal: match Z.compare (Z.mul (Zpos xH) n1) (Z.mul (Zpos xH) n2) with | Eq => False | Lt => False | Gt => True end *) rewrite (Zcompare_mult_compat 1 n1 n2). (* Goal: Z.le Z0 n *) apply Zcompare.Zle_compare; assumption. Qed. Lemma Dlt_Zlt : forall n1 n2 d : Z, (n1 < n2)%Z -> Dlt (Diadic n1 d) (Diadic n2 d). (* Goal: @eq comparison (Dcompare (Diadic nx ex) (Dzero n)) (Z.compare (Dnum (Diadic nx ex)) Z0) *) intros; unfold Dlt in |- *; unfold Dcompare in |- *; simpl in |- *. (* Goal: match Z.compare (Z.mul (two_p (Z.sub d (Z.min d d))) n1) (Z.mul (two_p (Z.sub d (Z.min d d))) n2) with | Eq => False | Lt => False | Gt => True end *) rewrite (Zmin_n_n d). (* Goal: match Z.compare (Z.mul (two_p (Z.sub d d)) n1) (Z.mul (two_p (Z.sub d d)) n2) with | Eq => False | Lt => False | Gt => True end *) rewrite <- (Zminus_diag_reverse d). (* Goal: match Z.compare (Z.mul (two_p Z0) n1) (Z.mul (two_p Z0) n2) with | Eq => False | Lt => False | Gt => True end *) unfold two_p in |- *. (* Goal: match Z.compare (Z.mul (Zpos xH) n1) (Z.mul (Zpos xH) n2) with | Eq => False | Lt => False | Gt => True end *) rewrite (Zcompare_mult_compat 1 n1 n2). (* Goal: Z.le Z0 n *) apply Zcompare.Zlt_compare; assumption. Qed. Lemma Dge_Zge : forall n1 n2 d : Z, (n1 >= n2)%Z -> Dge (Diadic n1 d) (Diadic n2 d). (* Goal: @eq comparison (Dcompare (Diadic nx ex) (Dzero n)) (Z.compare (Dnum (Diadic nx ex)) Z0) *) intros; unfold Dge in |- *; unfold Dcompare in |- *; simpl in |- *. (* Goal: match Z.compare (Z.mul (two_p (Z.sub d (Z.min d d))) n1) (Z.mul (two_p (Z.sub d (Z.min d d))) n2) with | Eq => False | Lt => False | Gt => True end *) rewrite (Zmin_n_n d). (* Goal: match Z.compare (Z.mul (two_p (Z.sub d d)) n1) (Z.mul (two_p (Z.sub d d)) n2) with | Eq => False | Lt => False | Gt => True end *) rewrite <- (Zminus_diag_reverse d). (* Goal: match Z.compare (Z.mul (two_p Z0) n1) (Z.mul (two_p Z0) n2) with | Eq => False | Lt => False | Gt => True end *) unfold two_p in |- *. (* Goal: match Z.compare (Z.mul (Zpos xH) n1) (Z.mul (Zpos xH) n2) with | Eq => False | Lt => False | Gt => True end *) rewrite (Zcompare_mult_compat 1 n1 n2). (* Goal: Z.le Z0 n *) apply Zcompare.Zge_compare; assumption. Qed. Lemma Dgt_Zgt : forall n1 n2 d : Z, (n1 > n2)%Z -> Dgt (Diadic n1 d) (Diadic n2 d). (* Goal: @eq comparison (Dcompare (Diadic nx ex) (Dzero n)) (Z.compare (Dnum (Diadic nx ex)) Z0) *) intros; unfold Dgt in |- *; unfold Dcompare in |- *; simpl in |- *. (* Goal: match Z.compare (Z.mul (two_p (Z.sub d (Z.min d d))) n1) (Z.mul (two_p (Z.sub d (Z.min d d))) n2) with | Eq => False | Lt => False | Gt => True end *) rewrite (Zmin_n_n d). (* Goal: match Z.compare (Z.mul (two_p (Z.sub d d)) n1) (Z.mul (two_p (Z.sub d d)) n2) with | Eq => False | Lt => False | Gt => True end *) rewrite <- (Zminus_diag_reverse d). (* Goal: match Z.compare (Z.mul (two_p Z0) n1) (Z.mul (two_p Z0) n2) with | Eq => False | Lt => False | Gt => True end *) unfold two_p in |- *. (* Goal: match Z.compare (Z.mul (Zpos xH) n1) (Z.mul (Zpos xH) n2) with | Eq => False | Lt => False | Gt => True end *) rewrite (Zcompare_mult_compat 1 n1 n2). (* Goal: Z.le Z0 n *) apply Zcompare.Zgt_compare; assumption. Qed. (* Arithmetic properties on D : Dle is reflexive, transitive, antisymmetric *) Lemma Dle_refl : forall x y : diadic, Deq x y -> Dle x y. unfold Deq in |- *; unfold Dle in |- *; intros x y; elim (Dcompare x y); trivial. Qed. (*** Lemma Dle_trans : (x,y,z:diadic) (Dle x y)->(Dle y z)->(Dle x z). Intros x y z; Unfold Dle; Lemma Dle_antisym : Lemma Dle_lt_or_eq : (Dle x y) -> (Dlt x y)\/(Deq x y) Lemma Dlt_not_refl : Lemma Dlt_trans : Lemma Dle_lt_trans : x<=y -> y<z -> x < z Lemma Dlt_le_trans : Lemma Dgt_lt : Lemma Dge_le : ***) End comparisons. Section operations. (* Now the 4 arithmetic operations and the square root *) (* can be defined on D. *) (* Addition, negation, difference and multiplication are exact. *) (* Since D is non closed by inverse and square root, these operations *) (* are defined with a precision 2^p for a given p > 0. *) (* So, there is at this step of the work no function Dinv, but a *) (* predicates Dinv who takes 4 arguments : rounding mode, x, y, p. *) (* (Dinv MODE x y p) says that y is an approximation of 1/x with *) (* p digits, according to the rounding mode MODE *) (* That means (in the field R of real numbers): *) (* (Dnum y) has p digits and : *) (* *) (* -For MODE=Roundig_sup : y <= 1/x < Dsucc y *) (* -For MODE=Roundig_inf : Dpred y < 1/x <= y *) (* -For MODE=Rounding_nearest : *) (* as Rounding_sup if nearer than Rounding_inf *) (* as Rounding_inf in the other case *) (* -For MODE=Roundig_zero : as Rounding_sup if x>0, *) (* as Rounding_inf if x<=0. *) (* __ *) (* (Dsqr MODE x y p) says that y is an approximation of \/ x *) (* with p digits, according to the rounding mode MODE. *) (* That means : *) (* -For MODE=Roundig_sup : y^2 <= x < (Dsucc y)^2 *) (* -For MODE=Roundig_inf : (Dpred y)^2 < x <= y^2 *) (* -For MODE=Rounding_nearest : *) (* as Rounding_sup if nearer than Rounding_inf *) (* as Rounding_inf in the other case *) (* -For MODE=Roundig_zero : as Rounding_sup since x>0 *) (* *) (* The square root of a negative number does not exist : *) (* (Dsrq MODE x y p) is alwas false when x <= 0 *) Definition Dsucc (x : diadic) := Diadic (Dnum x + 1) (Dexp x). Definition Dpred (x : diadic) := Diadic (Dnum x - 1) (Dexp x). Definition Dadd (x y : diadic) := let nx := Dnum x in let ny := Dnum y in let ex := Dexp x in let ey := Dexp y in Diadic (two_p (ex - Zmin ex ey) * nx + two_p (ey - Zmin ex ey) * ny) (Zmin ex ey). Definition Dopp (x : diadic) := Diadic (- Dnum x) (Dexp x). Definition Dabs (x : diadic) := Diadic (Zabs (Dnum x)) (Dexp x). Definition Dminus (x y : diadic) := Dadd x (Dopp y). Definition Dmult (x y : diadic) := Diadic (Dnum x * Dnum y) (Dexp x + Dexp y). (* DLog 0 is -infty. When n<>0, (DLog n)= (Log_of_pos m) iff +2^m is the nearest power of two of n, according to the choosen rounding mode. (DLog n) = (Log_of_neg m) iff -2^m is the nearest power of two of n, according to the choosen rounding mode. *) (*** ON S'en FOUT Definition DLog := [m:rounding_mode][x:diadic]Cases (Dnum x) of (POS n) => (Log_of_pos (Cases m of Rounding_sup => `(Log_sup_pos n)-(Dexp x)` | Rounding_inf => `(Log_inf_pos n)-(Dexp x)` | Rounding_nearest => `(Log_nearest n)-(Dexp x)` | Rounding_zero => `(Log_inf n)-(Dexp x)) end)` | (NEG n) => (Log_of_neg (Cases m of Rounding_sup => `(Log_inf n)-(Dexp x)` | Rounding_inf => `(Log_sup n)-(Dexp x)` | Rounding_nearest => `(Log_nearest n)-(Dexp x)` | Rounding_zero => `(Log_inf n)-(Dexp x)) end)` | ZERO => M_infty end. *****************) (* (Dproj m x P y) is true when y is the projection of x onto the subset of integers who satisfy P, acording to the rounding mode m *) Definition Dproj (m : rounding_mode) (x : diadic) (P : diadic -> Prop) (y : diadic) := P y /\ match m with | Rounding_sup => forall z : diadic, P z -> Dle x z -> Dle y z | Rounding_inf => forall z : diadic, P z -> Dle z x -> Dle z y | Rounding_nearest => forall z : diadic, P z -> Dle (Dabs (Dminus x y)) (Dabs (Dminus x z)) | Rounding_zero => forall z : diadic, P z -> IF Dle (Dzero 0) x then Dle z x -> Dle z y else Dle z x -> Dle z y end. (* ZROUND "forgets" p digits of n, but with respect to the rounding mode m. In few cases, ZROUND may have one digit more than (N_digits n)-p. Examples : (ZROUND inf 4 #1111111) = #111 but (ZROUND sup 4 #1111111) = #1000 (ZROUND inf 4 #-1111111) = #-1000 but (ZROUND sup 4 #-1111111) = #-111 *) Lemma ZROUND_inf_spec : forall (p : positive) (x : Z), {y : Z | (y * two_power_pos p <= x < Zsucc y * two_power_pos p)%Z}. intros; elim (Zdiv_rest_correct x p); intros q r Hx Hr1 Hr2; exists q; rewrite (Zplus_0_r_reverse (q * two_power_pos p)); rewrite Hx; split; [ apply Zplus_le_compat_l; assumption | unfold Zsucc in |- *; rewrite Zmult_plus_distr_l; apply Zplus_lt_compat_l; rewrite Zmult_1_l; assumption ]. Qed. Definition ZROUND_inf (p : positive) (x : Z) := let (x', p) := ZROUND_inf_spec p x in x'. Lemma ZROUND_sup_spec : forall (p : positive) (x : Z), {y : Z | (Zpred y * two_power_pos p < x <= y * two_power_pos p)%Z}. intros; elim (Zdiv_rest_correct x p); intros q r; elim r; [ intros Hx Hr; exists q; rewrite Hx; rewrite <- Zplus_0_r_reverse; split; [ apply Zmult_gt_0_lt_compat_r; [ compute in |- *; reflexivity | apply Zlt_pred ] | apply Zle_refl ] | intros p0 Hx Hr1 Hr2; exists (Zsucc q); rewrite Hx; split; [ replace (Zpred (Zsucc q) * two_power_pos p)%Z with (q * two_power_pos p + 0)%Z; [ apply Zplus_lt_compat_l; compute in |- *; reflexivity | rewrite <- Zpred_succ; rewrite <- Zplus_0_r_reverse; reflexivity ] | unfold Zsucc in |- *; rewrite Zmult_plus_distr_l; apply Zplus_le_compat_l; rewrite Zmult_1_l; apply Zlt_le_weak; assumption ] | intros p0 Hx Hr1 Hr2; absurd (Datatypes.Gt = Datatypes.Gt); [ exact Hr1 | reflexivity ] ]. Qed. Definition ZROUND_sup (p : positive) (x : Z) := let (x', p) := ZROUND_sup_spec p x in x'. Lemma ZROUND_correct : forall (m : rounding_mode) (p : positive) (x : Z), {y : Z | match m with | Rounding_inf => (y * two_power_pos p <= x < Zsucc y * two_power_pos p)%Z | Rounding_sup => (Zpred y * two_power_pos p < x <= y * two_power_pos p)%Z | Rounding_nearest => match (x - ZROUND_inf p x ?= ZROUND_sup p x - x)%Z with | Datatypes.Eq => if Zeven.Zeven_bool (ZROUND_inf p x) then (y * two_power_pos p <= x < Zsucc y * two_power_pos p)%Z else (Zpred y * two_power_pos p < x <= y * two_power_pos p)%Z | Datatypes.Gt => (Zpred y * two_power_pos p < x <= y * two_power_pos p)%Z | Datatypes.Lt => (y * two_power_pos p <= x < Zsucc y * two_power_pos p)%Z end | Rounding_zero => match x with | Zpos _ => (y * two_power_pos p <= x < Zsucc y * two_power_pos p)%Z | Z0 => y = 0%Z | Zneg _ => (Zpred y * two_power_pos p < x <= y * two_power_pos p)%Z end end}. simple destruct m; [ exact ZROUND_sup_spec | exact ZROUND_inf_spec | intros p x; elim (x - ZROUND_inf p x ?= ZROUND_sup p x - x)%Z; [ elim (Zeven.Zeven_bool (ZROUND_inf p x)); [ apply ZROUND_inf_spec | apply ZROUND_sup_spec ] | apply ZROUND_inf_spec | apply ZROUND_sup_spec ] | simple induction x; [ (* ZERO *) exists 0%Z; reflexivity | (* POS *) intro; apply ZROUND_inf_spec | (* NEG *) intro; apply ZROUND_sup_spec ] ]. Qed. Definition ZROUND (m : rounding_mode) (p : positive) (x : Z) := let (x', p) := ZROUND_correct m p x in x'. Definition POS_ROUND (m : rounding_mode) (p n : positive) := BinInt.Zabs_N (ZROUND m p (Zpos n)). Definition NEG_ROUND (m : rounding_mode) (p n : positive) := BinInt.Zabs_N (- ZROUND m p (Zneg n)). (* (ROUND m p x) does verify : (Dproj m x {y:Z | (N_digits (Dexp x))=p \/ (Dexp x)=`0`} (ROUND m p x)) (At least, I hope so). *) (* If p < 0 then (ROUND m p x)=(ROUND m -p x) *) (* p is choosen of type Z (and not positive) only to avoid some further conversions *) (* The case when (ZROUND m q nx) has p+1 digits occurs only when (ZROUND m q nx) = 1000...000. It is correctly matched *) Definition Ddouble (d : diadic) := Dshift 1 d. Axiom ROUND_spec : forall (m : rounding_mode) (p : Z) (x : diadic), {y : diadic | N_digits (Dexp y) = p /\ match m with | Rounding_inf => Dle y x /\ Dlt x (Dsucc y) | Rounding_sup => Dlt (Dpred y) x /\ Dle x y | Rounding_nearest => Dle (Dpred (Ddouble y)) (Ddouble x) /\ Dle (Ddouble x) (Dsucc (Ddouble y)) | Rounding_zero => IF Dlt (Dzero 0) x then Dle y x /\ Dlt x (Dsucc y) else Dlt (Dpred y) x /\ Dle x y end}. Definition ROUND (m : rounding_mode) (p : Z) (d : diadic) := let (x, _) := ROUND_spec m p d in x. (* Le jeu inverse : on fixe l'exposant, et on ajuste la mantisse *) (* (ANTIROUND m p x) rend l'entier k tel que la projection de x (selon le mode m) sur l'ensemble des diadiques dont l'exposant vaut p (cad l'ensemble des multiples entiers de 2^p) est k.2^p *) Definition ANTIROUND (m : rounding_mode) (p : Z) (x : diadic) := let nx := Dnum x in let ex := Dexp x in match (p - ex)%Z with | Zpos q => ZROUND m q nx | Zneg q => (nx * two_power_pos q)%Z | Z0 => nx end. (******** Definition Dinv := [x,y:diadic m:rounding_mode; p:positive] [nx=(POS px)][ny=(POS py)][ex=(Dexp x)][ey=(Dexp y)] Cases nx ny m of (POS px) (POS py) Rounding_sup => `(Log_inf nx) - ex = -(Log_sup ny) + ey` /\`(Log_inf ny) >= p` /\` nx*ny <= (two_power_Z (ex+ey)) < nx*(ny+1)` (POS px) (POS py) Rounding_inf => `(Log_sup nx) - ex = -(Log_inf ny) + ey` /\`(Log_inf ny) >= p` /\` nx*(ny-1) <= (two_power_Z (ex+ey)) <= nx*ny` (POS px) (POS py) Rounding_nearest => `(Log_nearest nx) - ex = -(Log_nearest ny) + ey` /\`(Log_inf ny) >= p` /\` nx*ny <= (two_power_Z (ex+ey)) < (nx+1)*ny` | Rounding_sup (Log_of_neg e) => | Rounding_inf => | Rounding_nearest => | Rounding_zero => end. ************) (* (Ddiv m p x y) is the correct approximation with p digits of the division (in the field R of real numebers) x/y Unspecified if p <= 0 *) Parameter Ddiv : rounding_mode -> Z -> diadic -> diadic -> diadic. (* Dsqrt m p n e) is the correct approximation with p digits of the division (in the field R of real numebers) sqrt(n*2^e) *) Parameter Dsqrt : rounding_mode -> Z -> positive -> Z -> diadic. End operations.
(* This program is free software; you can redistribute it and/or *) (* modify it under the terms of the GNU Lesser General Public License *) (* as published by the Free Software Foundation; either version 2.1 *) (* of the License, or (at your option) any later version. *) (* *) (* This program is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* GNU General Public License for more details. *) (* *) (* You should have received a copy of the GNU Lesser General Public *) (* License along with this program; if not, write to the Free *) (* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *) (* 02110-1301 USA *) (********************************************************) (* Une axiomatisation en coq de la norme IEEE 754 *) (* Module Registersv : *) (* registres machines (vecteurs de bits) *) (* un plan d'ensemble se trouve dans le fichier README *) (* Patrick Loiseleur, avril 1997 *) (********************************************************) Require Import Bool. Require Import Omega. Section registers. (* The type (register n) represents integers who can write with n binary digits, i.e integers beetween 0 and 2^n - 1. The least significative digit is on top : (regS true (regS true (regS false regO))) is 011 (binary) or 3 (regS false (regS false (regS true regO))) is 100 (binary) or 4 *) Inductive register : nat -> Set := | regO : register 0 | regS : forall m : nat, bool -> register m -> register (S m). (* 0 and max number represented by a register number *) Definition register_zero := nat_rec register regO (fun m : nat => regS m false). Definition register_max := nat_rec register regO (fun m : nat => regS m true). Fixpoint is_register_zero (n : nat) (x : register n) {struct x} : bool := match x with | regO => true | regS m b y => if b then false else is_register_zero m y end. Definition is_register_max (n : nat) (x : register n) := match x with | regO => true | regS m b y => if b then is_register_zero m y else false end. (******* (* Decidable equality on registers *) Fixpoint eq_register[n:nat; x:(register n); m:nat; y:(register m)] : bool := Cases x y of regO regO => true | (regS n' bx x') (regS m' by y') => (andb (eqb bx by) (eq_register n' x' m' y')) | _ _ => false end. (* Egality of registers of same lenght *) Definition eq_reg := [n:nat][x,y:(register n)](eq_register n x n y). (* Alphabetic order on registers *) Fixpoint lt_register[n:nat; x:(register n); m:nat; y:(register m)] : bool := Cases x y of regO regO => false | (regS n' bx x') (regS m' by y') => (orb (ifb bx false by) (lt_register n' x' m' y')) | regO (regS m' by y') => true | (regS n' bx x') regO => false end. (* Order on registers of same lenght *) Definition lt_reg := [n:nat][x,y:(register n)](lt_register n x n y). ********) Fixpoint entier_of_register (n : nat) (x : register n) {struct x} : N := match x with | regO => 0%N | regS m b y => if b then Ndouble_plus_one (entier_of_register m y) else Ndouble (entier_of_register m y) end. Definition Z_of_register (n : nat) (x : register n) := BinInt.Z_of_N (entier_of_register n x). (******** Lemma eq_register_correct : (n:nat)(x:(register n))(m:nat)(y:(register m)) (eq_register n x m y)=(Case (%(Z_of_register n x) ?= (Z_of_register m y)) of true false false end). Lemma lt_register_correct : (n:nat)(x:(register n))(m:nat)(y:(register m)) (lt_register n x m y)=(Case (%(Z_of_register n x) ?= (Z_of_register m y)) of false true false end). *********) Definition sign_of (b : bool) := if b then 1%Z else (-1)%Z. (* This function only reads the n less significative bits of x, or all bits of x if x has less than n digits. *) (* In normal use of this function, we've always x < 2^n or x = 2^n + y when y<2^n *) Fixpoint register_of_pos (n : nat) (x : positive) {struct x} : register n := match n as x return (register x) with | O => regO | S m => match x with | xH => regS m true (register_zero m) | xI y => regS m true (register_of_pos m y) | xO y => regS m false (register_of_pos m y) end end. Definition register_of_entier (n : nat) (x : N) := match x return (register n) with | N0 => register_zero n | Npos p => register_of_pos n p end. Definition register_of_Z (n : nat) (z : Z) : register n := register_of_entier n (BinInt.Zabs_N z). (****************************************************** *** Need the power of two Lemma register_of_entier_bij1 : (n:nat)(x:entier) (% x < (two_puiss_nat n)) -> (entier_of_register n (register_of_entier n x))=x. ################################################################### Induction n; [ Destruct x; Normalize; Intros; Discriminate H | Intros n0 HR; Destruct x; Intros; Simpl; [ Cut (% (POS p) < (two_puiss_nat n0)); [ Intro Hp; Rewrite (HR p Hp); Reflexivity | Rewrite (POS_xI p) in H; Rewrite (two_puiss_nat_S n0) in H; Omega] | Cut (% (POS p) < (two_puiss_nat n0)); [ Intro Hp; Rewrite (HR p Hp); Reflexivity | Rewrite (POS_xO p) in H; Rewrite (two_puiss_nat_S n0) in H; Omega] | Replace (Z_of_register n0 (register_zero n0)) with `0`; [ Reflexivity | Elim n0; [ Trivial | Simpl; Intros n1 HZ; Rewrite <- HZ; Trivial ]]] ]. Save. *********************************************) Lemma register_of_entier_bij2 : forall (n : nat) (x : register n), register_of_entier n (entier_of_register n x) = x. simple induction x; [ reflexivity | intros m b r; elim b; [ simpl in |- *; unfold Ndouble_plus_one in |- *; elim (entier_of_register m r); intros; rewrite <- H; reflexivity | simpl in |- *; unfold Ndouble in |- *; elim (entier_of_register m r); intros; rewrite <- H; reflexivity ] ]. Qed. Fixpoint register_compare (n : nat) (x : register n) (m : nat) (y : register m) {struct y} : Datatypes.comparison := match x with | regO => if is_register_zero m y then Datatypes.Eq else Datatypes.Lt | regS n' b_x x' => match y with | regO => if is_register_zero n x then Datatypes.Eq else Datatypes.Gt | regS m' b_y y' => match register_compare n' x' m' y' with | Datatypes.Eq => if b_x then if b_y then Datatypes.Eq else Datatypes.Gt else if b_y then Datatypes.Lt else Datatypes.Eq | Datatypes.Gt => Datatypes.Gt | Datatypes.Lt => Datatypes.Lt end end end. Definition reg_compare (n : nat) (x y : register n) := register_compare n x n y. (***** Theorem register_compare_correct : (n:nat)(x:(register n))(m:nat)(y:(register m)) (Zcompare (Z_of_register n x) (Z_of_register m y))= (register_compare n x m y). Induction x; Induction y; Simpl; Auto. *******) End registers.
(* This program is free software; you can redistribute it and/or *) (* modify it under the terms of the GNU Lesser General Public License *) (* as published by the Free Software Foundation; either version 2.1 *) (* of the License, or (at your option) any later version. *) (* *) (* This program is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* GNU General Public License for more details. *) (* *) (* You should have received a copy of the GNU Lesser General Public *) (* License along with this program; if not, write to the Free *) (* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *) (* 02110-1301 USA *) Set Implicit Arguments. Unset Strict Implicit. Require Export Streams. Require Import time_clocks. (* Temporal notions for discrete time *) Infix "^" := Cons. Section TemporalOperators_CTL. (*** operators CTL with co-inductives types: definitions and properties ***) Variable Label : Set. (* labels: dicrete transitions *) Variable S : Set. (* states *) Variable tr : S -> Label -> S -> Prop. (* transitions *) Variable inv : S -> Prop. (* location invariants *) Variable inc : S -> Instant -> S. (* increase clocks of states *) Notation SPath := (Stream S) (only parsing). CoInductive ForAllS (P : Stream S -> Prop) : Stream S -> Prop := forallS : forall (x : Stream S) (s : S), P (s ^ x) -> ForAllS P x -> ForAllS P (s ^ x). Inductive ExistsS (P : Stream S -> Prop) : Stream S -> Prop := | Here : forall x : Stream S, P x -> ExistsS P x | Further : forall (x : Stream S) (s : S), ExistsS P x -> ExistsS P (s ^ x). (* Ejecution traces *) CoInductive isTrace : Stream S -> Prop := | isTraceTick : forall (x : Stream S) (s : S), inv (inc s tick) -> isTrace (inc s tick ^ x) -> isTrace (s ^ inc s tick ^ x) | isTraceDisc : forall (x : Stream S) (s1 s2 : S) (l : Label), tr s1 l s2 -> inv s2 -> isTrace (s2 ^ x) -> isTrace (s1 ^ s2 ^ x). Definition isTraceFrom (Sini : S) (x : Stream S) := Sini = hd x /\ isTrace x. (* operator Until *) Inductive Until (P Q : Stream S -> Prop) : Stream S -> Prop := | UntilFurther : forall (s : S) (x : Stream S), P (s ^ x) -> Until P Q x -> Until P Q (s ^ x) | UntilHere : forall x : Stream S, Q x -> Until P Q x. Inductive EX_Until (Sini : S) (P Q : Stream S -> Prop) : Prop := ExUntil : forall x : Stream S, isTraceFrom Sini x -> Until P Q x -> EX_Until Sini P Q. Definition FA_Until (Sini : S) (P Q : Stream S -> Prop) := forall x : Stream S, isTraceFrom Sini x -> Until P Q x. (* Init => FA[] P *) Definition Always (Sini : S) (P : Stream S -> Prop) := forall x : Stream S, isTraceFrom Sini x -> ForAllS P x. (* Init => FA<> P *) Definition Inevitable (Sini : S) (P : Stream S -> Prop) := forall x : Stream S, isTraceFrom Sini x -> ExistsS P x. (* Init => EX<> P *) Inductive Posible (Sini : S) (P : Stream S -> Prop) : Prop := posible : forall x : Stream S, isTraceFrom Sini x -> ExistsS P x -> Posible Sini P. (* Init => EX[] P *) Inductive SafePath (Sini : S) (P : Stream S -> Prop) : Prop := safePath : forall x : Stream S, isTraceFrom Sini x -> ForAllS P x -> SafePath Sini P. (**************************************************************************) (* Some Properties *) (**************************************************************************) Theorem Equiv1 : forall (Sini : S) (P : Stream S -> Prop), Posible Sini P <-> EX_Until Sini (fun _ : Stream S => True) P. Proof. (* Goal: forall (Sini : S) (P : forall _ : Stream S, Prop), iff (Posible Sini P) (EX_Until Sini (fun _ : Stream S => True) P) *) unfold iff in |- *; intros; split; intro. (* Goal: Posible Sini P *) inversion_clear H. (* Goal: EX_Until Sini (fun _ : Stream S => True) P *) (* Goal: Posible Sini P *) apply ExUntil with (P := fun _ : Stream S => True) (1 := H0). (* Goal: False *) elim H1; intros. (* Goal: ExistsS P (@Cons S s x0) *) (* Goal: ExistsS P x0 *) constructor 2; assumption. (* Goal: Until (fun _ : Stream S => True) P (@Cons S s x0) *) (* Goal: ExistsS P x *) constructor 1; trivial. (* Goal: Posible Sini P *) inversion_clear H. (* Goal: Posible Sini0 (fun s : Stream S => not (P s)) *) (* Goal: ForAllS P s0 *) apply posible with (1 := H0). (* Goal: False *) elim H1; intros. (* Goal: ExistsS P (@Cons S s x0) *) (* Goal: ExistsS P x0 *) constructor 2; assumption. (* Goal: ExistsS (fun s : Stream S => not (P s)) (@Cons S s s0) *) (* Goal: ForAllS P s0 *) constructor 1; assumption. Qed. Theorem Equiv2 : forall (Sini : S) (P : Stream S -> Prop), Inevitable Sini P <-> FA_Until Sini (fun _ : Stream S => True) P. Proof. (* Goal: forall (Sini : S) (P : forall _ : Stream S, Prop), iff (Inevitable Sini P) (FA_Until Sini (fun _ : Stream S => True) P) *) unfold iff, Inevitable, FA_Until in |- *; intros; split; intros. (* Goal: ExistsS P x *) elim (H x H0); intros. (* Goal: ExistsS P (@Cons S s x0) *) (* Goal: ExistsS P x0 *) constructor 2; assumption. (* Goal: Until (fun _ : Stream S => True) P (@Cons S s x0) *) (* Goal: ExistsS P x *) constructor 1; trivial. (* Goal: ExistsS P x *) elim (H x H0); intros. (* Goal: ExistsS P (@Cons S s x0) *) (* Goal: ExistsS P x0 *) constructor 2; assumption. (* Goal: ExistsS (fun s : Stream S => not (P s)) (@Cons S s s0) *) (* Goal: ForAllS P s0 *) constructor 1; assumption. Qed. Lemma ConsTrace : forall (s1 s2 : S) (x z : Stream S), isTraceFrom s2 z -> isTraceFrom s1 (s1 ^ s2 ^ x) -> isTraceFrom s1 (s1 ^ z). Proof. (* Goal: forall (s1 s2 : S) (x z : Stream S) (_ : isTraceFrom s2 z) (_ : isTraceFrom s1 (@Cons S s1 (@Cons S s2 x))), isTraceFrom s1 (@Cons S s1 z) *) unfold isTraceFrom in |- *; simpl in |- *. simple destruct z; simple destruct 1; simple destruct 3; simpl in |- *; (* Goal: forall (x : Stream S) (_ : not (forall _ : isTraceFrom Sini x, ExistsS (fun s : Stream S => forall _ : P s, False) x)), SafePath Sini P *) intros. (* Goal: and (@eq S s1 s1) (isTrace (@Cons S s1 (@Cons S s s0))) *) compute in H0; rewrite H0 in H4. (* Goal: and (@eq S s1 s1) (isTrace (@Cons S s1 (@Cons S s s0))) *) inversion_clear H4 in H1. (* Goal: and (@eq S s1 s1) (isTrace (@Cons S s1 (@Cons S (inc s1 tick) s0))) *) (* Goal: and (@eq S s1 s1) (isTrace (@Cons S s1 (@Cons S s s0))) *) split; [ trivial | apply (isTraceTick H5 H1) ]. (* Goal: and (@eq S s1 s1) (isTrace (@Cons S s1 (@Cons S s s0))) *) split; [ trivial | apply (isTraceDisc H5 H6 H1) ]. Qed. Lemma notPosible : forall (P : Stream S -> Prop) (s1 : S), ~ Posible s1 P -> forall (z : Stream S) (s2 : S), isTraceFrom s1 (s1 ^ s2 ^ z) -> ~ Posible s2 P. Proof. (* Goal: forall (P : forall _ : Stream S, Prop) (s1 : S) (_ : not (Posible s1 P)) (z : Stream S) (s2 : S) (_ : isTraceFrom s1 (@Cons S s1 (@Cons S s2 z))), not (Posible s2 P) *) unfold not at 2 in |- *; intros. (* Goal: False *) elim H1; intros. (* Goal: False *) apply H; cut (isTraceFrom s1 (s1 ^ x)). (* Goal: forall _ : isTraceFrom s1 (@Cons S s1 x), Posible s1 P *) (* Goal: isTraceFrom s1 (@Cons S s1 x) *) intro H4; apply (posible (P:=P) H4). (* Goal: ExistsS P (@Cons S s1 x) *) (* Goal: isTraceFrom s1 (@Cons S s1 x) *) apply Further; assumption. (* Goal: isTraceFrom s1 (@Cons S s1 x) *) apply ConsTrace with (1 := H2) (2 := H0); assumption. Qed. Require Import Classical. Theorem Equiv3 : forall (Sini : S) (P : Stream S -> Prop), Always Sini P <-> ~ Posible Sini (fun s : Stream S => ~ P s). Proof. (* Goal: forall (Sini : S) (P : forall _ : Stream S, Prop), iff (Always Sini P) (not (Posible Sini (fun s : Stream S => not (P s)))) *) unfold iff, Always, not in |- *; intros; split. (* Goal: forall (_ : forall (x : Stream S) (_ : isTraceFrom Sini x), ForAllS P x) (_ : Posible Sini (fun s : Stream S => forall _ : P s, False)), False *) (* Goal: forall (_ : forall _ : Posible Sini (fun s : Stream S => forall _ : P s, False), False) (x : Stream S) (_ : isTraceFrom Sini x), ForAllS P x *) intros H H0; inversion_clear H0. (* Goal: False *) (* Goal: forall (_ : forall _ : Posible Sini (fun s : Stream S => forall _ : P s, False), False) (x : Stream S) (_ : isTraceFrom Sini x), ForAllS P x *) generalize (H x H1); elim H2; intros. (* Goal: False *) (* Goal: False *) (* Goal: forall (_ : forall _ : Posible Sini (fun s : Stream S => forall _ : P s, False), False) (x : Stream S) (_ : isTraceFrom Sini x), ForAllS P x *) inversion_clear H3 in H0. (* Goal: False *) (* Goal: False *) (* Goal: forall (_ : forall _ : Posible Sini (fun s : Stream S => forall _ : P s, False), False) (x : Stream S) (_ : isTraceFrom Sini x), ForAllS P x *) apply (H0 H4). (* Goal: False *) (* Goal: forall (_ : forall _ : Posible Sini (fun s : Stream S => forall _ : P s, False), False) (x : Stream S) (_ : isTraceFrom Sini x), ForAllS P x *) inversion_clear H4. (* Goal: False *) (* Goal: forall (_ : forall _ : Posible Sini (fun s : Stream S => forall _ : P s, False), False) (x : Stream S) (_ : isTraceFrom Sini x), ForAllS P x *) apply (H3 H6). (* Goal: forall (_ : forall _ : Posible Sini (fun s : Stream S => forall _ : P s, False), False) (x : Stream S) (_ : isTraceFrom Sini x), ForAllS P x *) generalize Sini; cofix u. (* Goal: forall (Sini : S) (_ : forall _ : Posible Sini (fun s : Stream S => forall _ : P s, False), False) (x : Stream S) (_ : isTraceFrom Sini x), ForAllS P x *) simple destruct x; intros; constructor. (* Goal: P (@Cons S s s0) *) (* Goal: ForAllS P s0 *) elim (classic (P (s ^ s0))); [ trivial | intros ]. (* Goal: P (@Cons S s s0) *) (* Goal: ForAllS P s0 *) absurd (Posible Sini0 (fun s : Stream S => ~ P s)). (* Goal: not (Posible Sini0 (fun s : Stream S => not (P s))) *) (* Goal: Posible Sini0 (fun s : Stream S => not (P s)) *) (* Goal: ForAllS P s0 *) assumption. (* Goal: Posible Sini0 (fun s : Stream S => not (P s)) *) (* Goal: ForAllS P s0 *) apply posible with (1 := H0). (* Goal: ExistsS (fun s : Stream S => not (P s)) (@Cons S s s0) *) (* Goal: ForAllS P s0 *) constructor 1; assumption. (* Goal: ForAllS P s0 *) elim H0; simpl in |- *; intros. (* Goal: ForAllS P s0 *) apply (u (hd s0)); intros. (* Goal: False *) (* Goal: isTraceFrom (@hd S s0) s0 *) generalize H0; clear H0; generalize H3; clear H3. (* Goal: forall (_ : Posible (@hd S s0) (fun s : Stream S => forall _ : P s, False)) (_ : isTraceFrom Sini0 (@Cons S s s0)), False *) (* Goal: isTraceFrom (@hd S s0) s0 *) rewrite <- H1; case s0; simpl in |- *; intros. (* Goal: not (Posible Sini0 (fun s : Stream S => not (P s))) *) (* Goal: Posible Sini0 (fun s : Stream S => not (P s)) *) (* Goal: ForAllS P s0 *) apply (notPosible (P:=fun s : Stream S => ~ P s) H H0); assumption. (* Goal: isTraceFrom (@hd S s0) s0 *) inversion_clear H2; simpl in |- *. (* Goal: isTraceFrom (@hd S (@Cons S s2 x1)) (@Cons S s2 x1) *) unfold isTraceFrom in |- *; split; trivial. (* Goal: isTraceFrom (@hd S (@Cons S s2 x1)) (@Cons S s2 x1) *) unfold isTraceFrom in |- *; split; trivial. Qed. Lemma not_EX : forall (P : Stream S -> Prop) (x : Stream S) (s : S), ~ ExistsS P (s ^ x) -> ~ ExistsS P x. Proof. (* Goal: forall (P : forall _ : Stream S, Prop) (x : Stream S) (s : S) (_ : not (ExistsS P (@Cons S s x))), not (ExistsS P x) *) unfold not in |- *; intros. (* Goal: False *) apply (H (Further s H0)). Qed. Theorem Equiv4 : forall (Sini : S) (P : Stream S -> Prop), SafePath Sini P <-> ~ Inevitable Sini (fun s : Stream S => ~ P s). Proof. (* Goal: forall (Sini : S) (P : forall _ : Stream S, Prop), iff (SafePath Sini P) (not (Inevitable Sini (fun s : Stream S => not (P s)))) *) unfold iff, Inevitable, not in |- *; intros; split. (* Goal: forall (_ : SafePath Sini P) (_ : forall (x : Stream S) (_ : isTraceFrom Sini x), ExistsS (fun s : Stream S => forall _ : P s, False) x), False *) (* Goal: forall _ : forall _ : forall (x : Stream S) (_ : isTraceFrom Sini x), ExistsS (fun s : Stream S => forall _ : P s, False) x, False, SafePath Sini P *) intro sp; inversion sp; intros. (* Goal: False *) (* Goal: forall _ : forall _ : forall (x : Stream S) (_ : isTraceFrom Sini x), ExistsS (fun s : Stream S => forall _ : P s, False) x, False, SafePath Sini P *) generalize H0; elim (H1 x H); intros. (* Goal: False *) (* Goal: False *) (* Goal: forall _ : forall _ : forall (x : Stream S) (_ : isTraceFrom Sini x), ExistsS (fun s : Stream S => forall _ : P s, False) x, False, SafePath Sini P *) inversion_clear H3 in H2. (* Goal: False *) (* Goal: False *) (* Goal: forall _ : forall _ : forall (x : Stream S) (_ : isTraceFrom Sini x), ExistsS (fun s : Stream S => forall _ : P s, False) x, False, SafePath Sini P *) apply (H2 H4). (* Goal: not (Posible Sini0 (fun s : Stream S => not (P s))) *) (* Goal: Posible Sini0 (fun s : Stream S => not (P s)) *) (* Goal: ForAllS P s0 *) apply H3; inversion_clear H4; assumption. intro H; elim (not_all_ex_not (Stream S) (fun x : Stream S => isTraceFrom Sini x -> ExistsS (fun s : Stream S => P s -> False) x) H). (* Goal: forall (x : Stream S) (_ : not (forall _ : isTraceFrom Sini x, ExistsS (fun s : Stream S => forall _ : P s, False) x)), SafePath Sini P *) intros. generalize (not_imply_elim2 (isTraceFrom Sini x) (ExistsS (fun s : Stream S => ~ P s) x) H0). generalize (not_imply_elim (isTraceFrom Sini x) (ExistsS (fun s : Stream S => ~ P s) x) H0); (* Goal: forall (x : Stream S) (_ : not (forall _ : isTraceFrom Sini x, ExistsS (fun s : Stream S => forall _ : P s, False) x)), SafePath Sini P *) intros. (* Goal: SafePath Sini P *) apply safePath with (1 := H1). (* Goal: ForAllS P x *) generalize H1; clear H1; generalize H2; clear H2. (* Goal: forall (_ : forall _ : Posible Sini (fun s : Stream S => forall _ : P s, False), False) (x : Stream S) (_ : isTraceFrom Sini x), ForAllS P x *) generalize x; generalize Sini; cofix u. (* Goal: forall (Sini : S) (x : Stream S) (_ : not (ExistsS (fun s : Stream S => not (P s)) x)) (_ : isTraceFrom Sini x), ForAllS P x *) simple destruct x0; intros; constructor. (* Goal: P (@Cons S s s0) *) (* Goal: ForAllS P s0 *) elim (classic (P (s ^ s0))); [ trivial | intro ]. (* Goal: P (@Cons S s s0) *) (* Goal: ForAllS P s0 *) elim (H2 (Here (P:=fun s : Stream S => ~ P s) H3)). (* Goal: ForAllS P s0 *) apply u with (Sini := hd s0). (* Goal: forall (P : forall _ : Stream S, Prop) (x : Stream S) (s : S) (_ : not (ExistsS P (@Cons S s x))), not (ExistsS P x) *) generalize H2; clear H2; case s0; unfold not in |- *; intros. (* Goal: False *) (* Goal: isTraceFrom (@hd S s0) s0 *) apply (not_EX H2 H3). (* Goal: isTraceFrom (@hd S s0) s0 *) elim H1; intros ig trace; inversion_clear trace. (* Goal: isTraceFrom (@hd S (@Cons S s2 x1)) (@Cons S s2 x1) *) unfold isTraceFrom in |- *; split; trivial. (* Goal: isTraceFrom (@hd S (@Cons S s2 x1)) (@Cons S s2 x1) *) unfold isTraceFrom in |- *; split; trivial. Qed. Theorem Mon_I_S : forall (x : Stream S) (Pg Pp : Stream S -> Prop), ForAllS Pg x -> (forall s : Stream S, Pg s -> Pp s) -> ForAllS Pp x. Proof. (* Goal: forall (x : Stream S) (_ : not (forall _ : isTraceFrom Sini x, ExistsS (fun s : Stream S => forall _ : P s, False) x)), SafePath Sini P *) cofix u; intro x; case x; intros. (* Goal: ForAllS Pp (@Cons S s s0) *) case H; constructor. (* Goal: Pp (@Cons S s1 x0) *) (* Goal: ForAllS Pp x0 *) apply (H0 (s1 ^ x0) H1). (* Goal: ForAllS Pp x0 *) apply (u x0 Pg Pp H2 H0). Qed. Theorem Conj_S : forall (x : Stream S) (P1 P2 : Stream S -> Prop), ForAllS P1 x -> ForAllS P2 x -> ForAllS (fun s : Stream S => P1 s /\ P2 s) x. Proof. (* Goal: forall (x : Stream S) (_ : not (forall _ : isTraceFrom Sini x, ExistsS (fun s : Stream S => forall _ : P s, False) x)), SafePath Sini P *) cofix u; intro x; case x; intros. (* Goal: ForAllS (fun s : Stream S => and (P1 s) (P2 s)) (@Cons S s s0) *) inversion_clear H; inversion_clear H0. (* Goal: not (Posible Sini0 (fun s : Stream S => not (P s))) *) (* Goal: Posible Sini0 (fun s : Stream S => not (P s)) *) (* Goal: ForAllS P s0 *) constructor; [ split | apply (u s0) ]; assumption. Qed. Theorem Mon_I_EX_S : forall (x : Stream S) (Pg Pp : Stream S -> Prop), ExistsS Pg x -> (forall s : Stream S, Pg s -> Pp s) -> ExistsS Pp x. Proof. (* Goal: forall (x : Stream S) (_ : not (forall _ : isTraceFrom Sini x, ExistsS (fun s : Stream S => forall _ : P s, False) x)), SafePath Sini P *) simple induction 1; intros. (* Goal: ExistsS Pp x0 *) (* Goal: ExistsS Pp (@Cons S s x0) *) constructor 1; apply (H1 x0 H0). (* Goal: ExistsS Pp (@Cons S s x0) *) constructor 2; apply (H1 H2). Qed. Theorem OneStep_EX : forall (x : Stream S) (P : Stream S -> Prop), ExistsS P x -> forall s : S, ExistsS P (s ^ x). Proof. (* Goal: ExistsS P (@Cons S s x0) *) (* Goal: ExistsS P x0 *) intros; constructor 2; assumption. Qed. End TemporalOperators_CTL.
(* This program is free software; you can redistribute it and/or *) (* modify it under the terms of the GNU Lesser General Public License *) (* as published by the Free Software Foundation; either version 2.1 *) (* of the License, or (at your option) any later version. *) (* *) (* This program is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* GNU General Public License for more details. *) (* *) (* You should have received a copy of the GNU Lesser General Public *) (* License along with this program; if not, write to the Free *) (* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *) (* 02110-1301 USA *) Set Implicit Arguments. Unset Strict Implicit. Require Import time_clocks. (* Temporal notions for discrete time *) Require Import ctl. Infix "^" := Cons. Section TemporalOperators_TCTL. (*** operators TCTL with co-inductives types: definitions and properties ***) Variable Label : Set. (* labels: dicrete transitions *) Variable S : Set. (* states *) Variable tr : S -> Label -> S -> Prop. (* transitions *) Variable inv : S -> Prop. (* location invariants *) Variable inc : S -> Instant -> S. (* increase clocks of states *) Variable bound : Instant -> Prop. (* Belonging to temporal intervals *) Notation State_T := (S * Instant)%type (only parsing). Notation SPath_T := (Stream (S * Instant)) (only parsing). (* Ejecution traces *) CoInductive isTrace_T : Stream (S * Instant) -> Prop := | isTraceTick_T : forall (x : Stream (S * Instant)) (s : S) (t : Instant), inv (inc s tick) -> isTrace_T ((inc s tick, Inc t) ^ x) -> isTrace_T ((s, t) ^ (inc s tick, Inc t) ^ x) | isTraceDisc_T : forall (x : Stream (S * Instant)) (s1 s2 : S) (t : Instant) (l : Label), tr s1 l s2 -> inv s2 -> isTrace_T ((s2, t) ^ x) -> isTrace_T ((s1, t) ^ (s2, t) ^ x). Definition isTraceFrom_T (Sini : S * Instant) (x : Stream (S * Instant)) := Sini = hd x /\ isTrace_T x. (* operator Until *) Inductive Until_bound (P Q : Stream (S * Instant) -> Prop) : Stream (S * Instant) -> Prop := | UntilFurther_bound : forall (s : S * Instant) (x : Stream (S * Instant)), P (s ^ x) -> Until_bound P Q x -> Until_bound P Q (s ^ x) | UntilHere_bound : forall (s : S) (t : Instant) (x : Stream (S * Instant)), bound t -> Q ((s, t) ^ x) -> Until_bound P Q ((s, t) ^ x). Inductive EX_Until_bound (Sini : S * Instant) (P Q : Stream (S * Instant) -> Prop) : Prop := ExUntil_bound : forall x : Stream (S * Instant), isTraceFrom_T Sini x -> Until_bound P Q x -> EX_Until_bound Sini P Q. Definition FA_Until_bound (Sini : S * Instant) (P Q : Stream (S * Instant) -> Prop) := forall x : Stream (S * Instant), isTraceFrom_T Sini x -> Until_bound P Q x. (* Init => FA[](bound t) P *) Definition Always_T (Sini : S * Instant) (P : Stream (S * Instant) -> Prop) := forall x : Stream (S * Instant), isTraceFrom_T Sini x -> ForAllS (fun s : Stream (S * Instant) => bound (snd (hd s)) -> P s) x. (* Init => FA<>(bound t) P *) Definition Inevitable_T (Sini : S * Instant) (P : Stream (S * Instant) -> Prop) := forall x : Stream (S * Instant), isTraceFrom_T Sini x -> ExistsS (fun s : Stream (S * Instant) => bound (snd (hd s)) /\ P s) x. (* Init => EX<>(bound t) P *) Inductive Posible_T (Sini : S * Instant) (P : Stream (S * Instant) -> Prop) : Prop := posible_T : forall x : Stream (S * Instant), isTraceFrom_T Sini x -> ExistsS (fun s : Stream (S * Instant) => bound (snd (hd s)) /\ P s) x -> Posible_T Sini P. (* Init => EX[](bound t) P *) Inductive SafePath_T (Sini : S * Instant) (P : Stream (S * Instant) -> Prop) : Prop := safePath_T : forall x : Stream (S * Instant), isTraceFrom_T Sini x -> ForAllS (fun s : Stream (S * Instant) => bound (snd (hd s)) -> P s) x -> SafePath_T Sini P. (**************************************************************************) (* Some Properties *) (**************************************************************************) Theorem Equiv1_T : forall (Sini : S * Instant) (P : Stream (S * Instant) -> Prop), Posible_T Sini P <-> EX_Until_bound Sini (fun _ : Stream (S * Instant) => True) P. Proof. (* Goal: forall (Sini : prod S Instant) (P : forall _ : Stream (prod S Instant), Prop), iff (Posible_T Sini P) (EX_Until_bound Sini (fun _ : Stream (prod S Instant) => True) P) *) unfold iff in |- *; intros; split; intro. (* Goal: Posible_T Sini P *) inversion_clear H. apply ExUntil_bound with (P := fun _ : Stream (S * Instant) => True) (1 := H0). (* Goal: @ExistsS (prod S Instant) (fun s : Stream (prod S Instant) => and (bound (@snd S Instant (@hd (prod S Instant) s))) (P s)) x *) elim H1. (* Goal: forall (x : Stream (prod S Instant)) (_ : and (bound (@snd S Instant (@hd (prod S Instant) x))) (P x)), Until_bound (fun _ : Stream (prod S Instant) => True) P x *) (* Goal: forall (x : Stream (prod S Instant)) (s : prod S Instant) (_ : @ExistsS (prod S Instant) (fun s0 : Stream (prod S Instant) => and (bound (@snd S Instant (@hd (prod S Instant) s0))) (P s0)) x) (_ : Until_bound (fun _ : Stream (prod S Instant) => True) P x), Until_bound (fun _ : Stream (prod S Instant) => True) P (@Cons (prod S Instant) s x) *) (* Goal: Posible_T Sini P *) simple destruct x0; simpl in |- *. (* Goal: forall (p : prod S Instant) (s : Stream (prod S Instant)) (_ : and (bound (@snd S Instant p)) (P (@Cons (prod S Instant) p s))), Until_bound (fun _ : Stream (prod S Instant) => True) P (@Cons (prod S Instant) p s) *) (* Goal: forall (x : Stream (prod S Instant)) (s : prod S Instant) (_ : @ExistsS (prod S Instant) (fun s0 : Stream (prod S Instant) => and (bound (@snd S Instant (@hd (prod S Instant) s0))) (P s0)) x) (_ : Until_bound (fun _ : Stream (prod S Instant) => True) P x), Until_bound (fun _ : Stream (prod S Instant) => True) P (@Cons (prod S Instant) s x) *) (* Goal: Posible_T Sini P *) simple destruct p; simple destruct 1; simpl in |- *; intros. (* Goal: @ExistsS (prod S Instant) (fun s : Stream (prod S Instant) => and (bound (@snd S Instant (@hd (prod S Instant) s))) (P s)) (@Cons (prod S Instant) s x0) *) (* Goal: @ExistsS (prod S Instant) (fun s : Stream (prod S Instant) => and (bound (@snd S Instant (@hd (prod S Instant) s))) (P s)) (@Cons (prod S Instant) (@pair S Instant s t) x0) *) constructor 2; assumption. (* Goal: forall (s : prod S Instant) (x : Stream (prod S Instant)) (_ : True) (_ : Until_bound (fun _ : Stream (prod S Instant) => True) P x) (_ : @ExistsS (prod S Instant) (fun s0 : Stream (prod S Instant) => and (bound (@snd S Instant (@hd (prod S Instant) s0))) (P s0)) x), @ExistsS (prod S Instant) (fun s0 : Stream (prod S Instant) => and (bound (@snd S Instant (@hd (prod S Instant) s0))) (P s0)) (@Cons (prod S Instant) s x) *) (* Goal: forall (s : S) (t : Instant) (x : Stream (prod S Instant)) (_ : bound t) (_ : P (@Cons (prod S Instant) (@pair S Instant s t) x)), @ExistsS (prod S Instant) (fun s0 : Stream (prod S Instant) => and (bound (@snd S Instant (@hd (prod S Instant) s0))) (P s0)) (@Cons (prod S Instant) (@pair S Instant s t) x) *) simple destruct s; intros. (* Goal: forall (p : prod S Instant) (s : Stream (prod S Instant)) (s0 : prod S Instant) (_ : @ExistsS (prod S Instant) (fun s1 : Stream (prod S Instant) => and (bound (@snd S Instant (@hd (prod S Instant) s1))) (P s1)) (@Cons (prod S Instant) p s)) (_ : Until_bound (fun _ : Stream (prod S Instant) => True) P (@Cons (prod S Instant) p s)), Until_bound (fun _ : Stream (prod S Instant) => True) P (@Cons (prod S Instant) s0 (@Cons (prod S Instant) p s)) *) (* Goal: @ExistsS (prod S Instant) (fun s : Stream (prod S Instant) => and (bound (@snd S Instant (@hd (prod S Instant) s))) (P s)) x *) constructor 1; trivial. (* Goal: Posible_T Sini P *) inversion_clear H. (* Goal: Posible_T Sini0 (fun s : Stream (prod S Instant) => not (P s)) *) (* Goal: @ForAllS (prod S Instant) (fun s : Stream (prod S Instant) => forall _ : bound (@snd S Instant (@hd (prod S Instant) s)), P s) s *) apply posible_T with (1 := H0). (* Goal: @ExistsS (prod S Instant) (fun s : Stream (prod S Instant) => and (bound (@snd S Instant (@hd (prod S Instant) s))) (P s)) x *) elim H1. (* Goal: forall (s : prod S Instant) (x : Stream (prod S Instant)) (_ : True) (_ : Until_bound (fun _ : Stream (prod S Instant) => True) P x) (_ : @ExistsS (prod S Instant) (fun s0 : Stream (prod S Instant) => and (bound (@snd S Instant (@hd (prod S Instant) s0))) (P s0)) x), @ExistsS (prod S Instant) (fun s0 : Stream (prod S Instant) => and (bound (@snd S Instant (@hd (prod S Instant) s0))) (P s0)) (@Cons (prod S Instant) s x) *) (* Goal: forall (s : S) (t : Instant) (x : Stream (prod S Instant)) (_ : bound t) (_ : P (@Cons (prod S Instant) (@pair S Instant s t) x)), @ExistsS (prod S Instant) (fun s0 : Stream (prod S Instant) => and (bound (@snd S Instant (@hd (prod S Instant) s0))) (P s0)) (@Cons (prod S Instant) (@pair S Instant s t) x) *) simple destruct s; intros. (* Goal: @ExistsS (prod S Instant) (fun s : Stream (prod S Instant) => and (bound (@snd S Instant (@hd (prod S Instant) s))) (P s)) (@Cons (prod S Instant) s x0) *) (* Goal: @ExistsS (prod S Instant) (fun s : Stream (prod S Instant) => and (bound (@snd S Instant (@hd (prod S Instant) s))) (P s)) (@Cons (prod S Instant) (@pair S Instant s t) x0) *) constructor 2; assumption. (* Goal: forall (s : S) (t : Instant) (x : Stream (prod S Instant)) (_ : bound t) (_ : P (@Cons (prod S Instant) (@pair S Instant s t) x)), @ExistsS (prod S Instant) (fun s0 : Stream (prod S Instant) => and (bound (@snd S Instant (@hd (prod S Instant) s0))) (P s0)) (@Cons (prod S Instant) (@pair S Instant s t) x) *) intros; constructor 1; simpl in |- *; split; assumption. Qed. Theorem Equiv2_T : forall (Sini : S * Instant) (P : Stream (S * Instant) -> Prop), Inevitable_T Sini P <-> FA_Until_bound Sini (fun _ : Stream (S * Instant) => True) P. Proof. (* Goal: forall (Sini : prod S Instant) (P : forall _ : Stream (prod S Instant), Prop), iff (Inevitable_T Sini P) (FA_Until_bound Sini (fun _ : Stream (prod S Instant) => True) P) *) unfold iff, Inevitable_T, FA_Until_bound in |- *; intros; split; intros. (* Goal: Until_bound (fun _ : Stream (prod S Instant) => True) P x *) (* Goal: @ExistsS (prod S Instant) (fun s : Stream (prod S Instant) => and (bound (@snd S Instant (@hd (prod S Instant) s))) (P s)) x *) elim (H x H0); simple destruct x0. (* Goal: forall (p : prod S Instant) (s : Stream (prod S Instant)) (_ : and (bound (@snd S Instant (@hd (prod S Instant) (@Cons (prod S Instant) p s)))) (P (@Cons (prod S Instant) p s))), Until_bound (fun _ : Stream (prod S Instant) => True) P (@Cons (prod S Instant) p s) *) (* Goal: forall (p : prod S Instant) (s : Stream (prod S Instant)) (s0 : prod S Instant) (_ : @ExistsS (prod S Instant) (fun s1 : Stream (prod S Instant) => and (bound (@snd S Instant (@hd (prod S Instant) s1))) (P s1)) (@Cons (prod S Instant) p s)) (_ : Until_bound (fun _ : Stream (prod S Instant) => True) P (@Cons (prod S Instant) p s)), Until_bound (fun _ : Stream (prod S Instant) => True) P (@Cons (prod S Instant) s0 (@Cons (prod S Instant) p s)) *) (* Goal: @ExistsS (prod S Instant) (fun s : Stream (prod S Instant) => and (bound (@snd S Instant (@hd (prod S Instant) s))) (P s)) x *) simple destruct p; intros. (* Goal: False *) elim H1; intros. (* Goal: @ExistsS (prod S Instant) (fun s : Stream (prod S Instant) => and (bound (@snd S Instant (@hd (prod S Instant) s))) (P s)) (@Cons (prod S Instant) s x0) *) (* Goal: @ExistsS (prod S Instant) (fun s : Stream (prod S Instant) => and (bound (@snd S Instant (@hd (prod S Instant) s))) (P s)) (@Cons (prod S Instant) (@pair S Instant s t) x0) *) constructor 2; assumption. (* Goal: forall (p : prod S Instant) (s : Stream (prod S Instant)) (s0 : prod S Instant) (_ : @ExistsS (prod S Instant) (fun s1 : Stream (prod S Instant) => and (bound (@snd S Instant (@hd (prod S Instant) s1))) (P s1)) (@Cons (prod S Instant) p s)) (_ : Until_bound (fun _ : Stream (prod S Instant) => True) P (@Cons (prod S Instant) p s)), Until_bound (fun _ : Stream (prod S Instant) => True) P (@Cons (prod S Instant) s0 (@Cons (prod S Instant) p s)) *) (* Goal: @ExistsS (prod S Instant) (fun s : Stream (prod S Instant) => and (bound (@snd S Instant (@hd (prod S Instant) s))) (P s)) x *) constructor 1; trivial. (* Goal: @ExistsS (prod S Instant) (fun s : Stream (prod S Instant) => and (bound (@snd S Instant (@hd (prod S Instant) s))) (P s)) x *) elim (H x H0); intros. (* Goal: @ExistsS (prod S Instant) (fun s : Stream (prod S Instant) => and (bound (@snd S Instant (@hd (prod S Instant) s))) (P s)) (@Cons (prod S Instant) s x0) *) (* Goal: @ExistsS (prod S Instant) (fun s : Stream (prod S Instant) => and (bound (@snd S Instant (@hd (prod S Instant) s))) (P s)) (@Cons (prod S Instant) (@pair S Instant s t) x0) *) constructor 2; assumption. (* Goal: @ExistsS (prod S Instant) (fun s : Stream (prod S Instant) => and (bound (@snd S Instant (@hd (prod S Instant) s))) (not (P s))) (@Cons (prod S Instant) p s) *) (* Goal: @ForAllS (prod S Instant) (fun s : Stream (prod S Instant) => forall _ : bound (@snd S Instant (@hd (prod S Instant) s)), P s) s *) constructor 1; split; assumption. Qed. Lemma ConsTrace_T : forall (s1 s2 : S * Instant) (x z : Stream (S * Instant)), isTraceFrom_T s2 z -> isTraceFrom_T s1 (s1 ^ s2 ^ x) -> isTraceFrom_T s1 (s1 ^ z). Proof. (* Goal: forall (s1 s2 : prod S Instant) (x z : Stream (prod S Instant)) (_ : isTraceFrom_T s2 z) (_ : isTraceFrom_T s1 (@Cons (prod S Instant) s1 (@Cons (prod S Instant) s2 x))), isTraceFrom_T s1 (@Cons (prod S Instant) s1 z) *) unfold isTraceFrom_T in |- *; simpl in |- *. simple destruct z; simple destruct 1; simple destruct 3; simpl in |- *; (* Goal: forall (x : Stream (prod S Instant)) (_ : not (forall _ : isTraceFrom_T Sini x, @ExistsS (prod S Instant) (fun s : Stream (prod S Instant) => and (bound (@snd S Instant (@hd (prod S Instant) s))) (forall _ : P s, False)) x)), SafePath_T Sini P *) intros. (* Goal: and (@eq (prod S Instant) s1 s1) (isTrace_T (@Cons (prod S Instant) s1 (@Cons (prod S Instant) p s))) *) compute in H0; rewrite H0 in H4. (* Goal: and (@eq (prod S Instant) s1 s1) (isTrace_T (@Cons (prod S Instant) s1 (@Cons (prod S Instant) p s))) *) inversion_clear H4 in H1. (* Goal: and (@eq (prod S Instant) (@pair S Instant s0 t) (@pair S Instant s0 t)) (isTrace_T (@Cons (prod S Instant) (@pair S Instant s0 t) (@Cons (prod S Instant) (@pair S nat (inc s0 tick) (Inc t)) s))) *) (* Goal: and (@eq (prod S Instant) (@pair S Instant s0 t) (@pair S Instant s0 t)) (isTrace_T (@Cons (prod S Instant) (@pair S Instant s0 t) (@Cons (prod S Instant) (@pair S Instant s3 t) s))) *) split; [ trivial | apply (isTraceTick_T H5 H1) ]. (* Goal: and (@eq (prod S Instant) (@pair S Instant s0 t) (@pair S Instant s0 t)) (isTrace_T (@Cons (prod S Instant) (@pair S Instant s0 t) (@Cons (prod S Instant) (@pair S Instant s3 t) s))) *) split; [ trivial | apply (isTraceDisc_T H5 H6 H1) ]. Qed. Lemma notPosible_T : forall (P : Stream (S * Instant) -> Prop) (s1 : S * Instant), ~ Posible_T s1 P -> forall (z : Stream (S * Instant)) (s2 : S * Instant), isTraceFrom_T s1 (s1 ^ s2 ^ z) -> ~ Posible_T s2 P. Proof. (* Goal: forall (P : forall _ : Stream (prod S Instant), Prop) (s1 : prod S Instant) (_ : not (Posible_T s1 P)) (z : Stream (prod S Instant)) (s2 : prod S Instant) (_ : isTraceFrom_T s1 (@Cons (prod S Instant) s1 (@Cons (prod S Instant) s2 z))), not (Posible_T s2 P) *) unfold not at 2 in |- *; intros. (* Goal: False *) elim H1; intros. (* Goal: False *) apply H; cut (isTraceFrom_T s1 (s1 ^ x)). (* Goal: forall _ : isTraceFrom_T s1 (@Cons (prod S Instant) s1 x), Posible_T s1 P *) (* Goal: isTraceFrom_T s1 (@Cons (prod S Instant) s1 x) *) intro H4; apply (posible_T (P:=P) H4). (* Goal: @ExistsS (prod S Instant) (fun s : Stream (prod S Instant) => and (bound (@snd S Instant (@hd (prod S Instant) s))) (P s)) (@Cons (prod S Instant) s1 x) *) (* Goal: isTraceFrom_T s1 (@Cons (prod S Instant) s1 x) *) apply Further; assumption. (* Goal: isTraceFrom_T s1 (@Cons (prod S Instant) s1 x) *) apply ConsTrace_T with (1 := H2) (2 := H0); assumption. Qed. Require Import Classical. Theorem Equiv3_T : forall (Sini : S * Instant) (P : Stream (S * Instant) -> Prop), Always_T Sini P <-> ~ Posible_T Sini (fun s : Stream (S * Instant) => ~ P s). Proof. (* Goal: forall (Sini : prod S Instant) (P : forall _ : Stream (prod S Instant), Prop), iff (Always_T Sini P) (not (Posible_T Sini (fun s : Stream (prod S Instant) => not (P s)))) *) unfold iff, Always_T, not in |- *; intros; split. (* Goal: forall (_ : forall (x : Stream (prod S Instant)) (_ : isTraceFrom_T Sini x), @ForAllS (prod S Instant) (fun s : Stream (prod S Instant) => forall _ : bound (@snd S Instant (@hd (prod S Instant) s)), P s) x) (_ : Posible_T Sini (fun s : Stream (prod S Instant) => forall _ : P s, False)), False *) (* Goal: forall (_ : forall _ : Posible_T Sini (fun s : Stream (prod S Instant) => forall _ : P s, False), False) (x : Stream (prod S Instant)) (_ : isTraceFrom_T Sini x), @ForAllS (prod S Instant) (fun s : Stream (prod S Instant) => forall _ : bound (@snd S Instant (@hd (prod S Instant) s)), P s) x *) intros H H0; inversion_clear H0. (* Goal: False *) (* Goal: forall (_ : forall _ : Posible_T Sini (fun s : Stream (prod S Instant) => forall _ : P s, False), False) (x : Stream (prod S Instant)) (_ : isTraceFrom_T Sini x), @ForAllS (prod S Instant) (fun s : Stream (prod S Instant) => forall _ : bound (@snd S Instant (@hd (prod S Instant) s)), P s) x *) generalize (H x H1); elim H2; intros. (* Goal: False *) (* Goal: False *) (* Goal: forall (_ : forall _ : Posible_T Sini (fun s : Stream (prod S Instant) => forall _ : P s, False), False) (x : Stream (prod S Instant)) (_ : isTraceFrom_T Sini x), @ForAllS (prod S Instant) (fun s : Stream (prod S Instant) => forall _ : bound (@snd S Instant (@hd (prod S Instant) s)), P s) x *) inversion_clear H3 in H0. (* Goal: False *) (* Goal: False *) (* Goal: forall (_ : forall _ : Posible_T Sini (fun s : Stream (prod S Instant) => forall _ : P s, False), False) (x : Stream (prod S Instant)) (_ : isTraceFrom_T Sini x), @ForAllS (prod S Instant) (fun s : Stream (prod S Instant) => forall _ : bound (@snd S Instant (@hd (prod S Instant) s)), P s) x *) elim H0; intros. (* Goal: False *) (* Goal: False *) (* Goal: forall (_ : forall _ : Posible_T Sini (fun s : Stream (prod S Instant) => forall _ : P s, False), False) (x : Stream (prod S Instant)) (_ : isTraceFrom_T Sini x), @ForAllS (prod S Instant) (fun s : Stream (prod S Instant) => forall _ : bound (@snd S Instant (@hd (prod S Instant) s)), P s) x *) elim (H6 (H4 H3)). (* Goal: False *) (* Goal: forall (_ : forall _ : Posible_T Sini (fun s : Stream (prod S Instant) => forall _ : P s, False), False) (x : Stream (prod S Instant)) (_ : isTraceFrom_T Sini x), @ForAllS (prod S Instant) (fun s : Stream (prod S Instant) => forall _ : bound (@snd S Instant (@hd (prod S Instant) s)), P s) x *) inversion_clear H4. (* Goal: False *) (* Goal: forall (_ : forall _ : Posible_T Sini (fun s : Stream (prod S Instant) => forall _ : P s, False), False) (x : Stream (prod S Instant)) (_ : isTraceFrom_T Sini x), @ForAllS (prod S Instant) (fun s : Stream (prod S Instant) => forall _ : bound (@snd S Instant (@hd (prod S Instant) s)), P s) x *) apply (H3 H6). (* Goal: forall (_ : forall _ : Posible_T Sini (fun s : Stream (prod S Instant) => forall _ : P s, False), False) (x : Stream (prod S Instant)) (_ : isTraceFrom_T Sini x), @ForAllS (prod S Instant) (fun s : Stream (prod S Instant) => forall _ : bound (@snd S Instant (@hd (prod S Instant) s)), P s) x *) generalize Sini; cofix u. (* Goal: forall (Sini : prod S Instant) (_ : forall _ : Posible_T Sini (fun s : Stream (prod S Instant) => forall _ : P s, False), False) (x : Stream (prod S Instant)) (_ : isTraceFrom_T Sini x), @ForAllS (prod S Instant) (fun s : Stream (prod S Instant) => forall _ : bound (@snd S Instant (@hd (prod S Instant) s)), P s) x *) simple destruct x; intros; constructor. (* Goal: forall _ : bound (@snd S Instant (@hd (prod S Instant) (@Cons (prod S Instant) p s))), P (@Cons (prod S Instant) p s) *) (* Goal: @ForAllS (prod S Instant) (fun s : Stream (prod S Instant) => forall _ : bound (@snd S Instant (@hd (prod S Instant) s)), P s) s *) intro; elim (classic (P (p ^ s))); [ trivial | intros ]. (* Goal: P (@Cons (prod S Instant) p s) *) (* Goal: @ForAllS (prod S Instant) (fun s : Stream (prod S Instant) => forall _ : bound (@snd S Instant (@hd (prod S Instant) s)), P s) s *) absurd (Posible_T Sini0 (fun s : Stream (S * Instant) => ~ P s)). (* Goal: not (Posible_T Sini0 (fun s : Stream (prod S Instant) => not (P s))) *) (* Goal: Posible_T Sini0 (fun s : Stream (prod S Instant) => not (P s)) *) (* Goal: @ForAllS (prod S Instant) (fun s : Stream (prod S Instant) => forall _ : bound (@snd S Instant (@hd (prod S Instant) s)), P s) s *) assumption. (* Goal: Posible_T Sini0 (fun s : Stream (prod S Instant) => not (P s)) *) (* Goal: @ForAllS (prod S Instant) (fun s : Stream (prod S Instant) => forall _ : bound (@snd S Instant (@hd (prod S Instant) s)), P s) s *) apply posible_T with (1 := H0). (* Goal: @ExistsS (prod S Instant) (fun s : Stream (prod S Instant) => and (bound (@snd S Instant (@hd (prod S Instant) s))) (not (P s))) (@Cons (prod S Instant) p s) *) (* Goal: @ForAllS (prod S Instant) (fun s : Stream (prod S Instant) => forall _ : bound (@snd S Instant (@hd (prod S Instant) s)), P s) s *) constructor 1; split; assumption. (* Goal: @ForAllS (prod S Instant) (fun s : Stream (prod S Instant) => forall _ : bound (@snd S Instant (@hd (prod S Instant) s)), P s) s *) elim H0; simpl in |- *; intros. (* Goal: @ForAllS (prod S Instant) (fun s : Stream (prod S Instant) => forall _ : bound (@snd S Instant (@hd (prod S Instant) s)), P s) s *) apply (u (hd s)); intros. (* Goal: False *) (* Goal: isTraceFrom_T (@hd (prod S Instant) s) s *) generalize H0; clear H0; generalize H3; clear H3. (* Goal: forall (_ : Posible_T (@hd (prod S Instant) s) (fun s : Stream (prod S Instant) => forall _ : P s, False)) (_ : isTraceFrom_T Sini0 (@Cons (prod S Instant) p s)), False *) (* Goal: isTraceFrom_T (@hd (prod S Instant) s) s *) rewrite <- H1; case s; simpl in |- *; intros. apply (notPosible_T (P:=fun s : Stream (S * Instant) => ~ P s) H H0); (* Goal: not (Posible_T Sini0 (fun s : Stream (prod S Instant) => not (P s))) *) (* Goal: Posible_T Sini0 (fun s : Stream (prod S Instant) => not (P s)) *) (* Goal: @ForAllS (prod S Instant) (fun s : Stream (prod S Instant) => forall _ : bound (@snd S Instant (@hd (prod S Instant) s)), P s) s *) assumption. (* Goal: isTraceFrom_T (@hd (prod S Instant) s) s *) unfold isTraceFrom_T in |- *; inversion_clear H2; simpl in |- *. (* Goal: and (@eq (prod S Instant) (@hd (prod S Instant) (@Cons (prod S Instant) (@pair S Instant s2 t) x1)) (@hd (prod S Instant) (@Cons (prod S Instant) (@pair S Instant s2 t) x1))) (isTrace_T (@Cons (prod S Instant) (@pair S Instant s2 t) x1)) *) split; trivial. (* Goal: and (@eq (prod S Instant) (@hd (prod S Instant) (@Cons (prod S Instant) (@pair S Instant s2 t) x1)) (@hd (prod S Instant) (@Cons (prod S Instant) (@pair S Instant s2 t) x1))) (isTrace_T (@Cons (prod S Instant) (@pair S Instant s2 t) x1)) *) split; trivial. Qed. Theorem Equiv4_T : forall (Sini : S * Instant) (P : Stream (S * Instant) -> Prop), SafePath_T Sini P <-> ~ Inevitable_T Sini (fun s : Stream (S * Instant) => ~ P s). Proof. (* Goal: forall (Sini : prod S Instant) (P : forall _ : Stream (prod S Instant), Prop), iff (SafePath_T Sini P) (not (Inevitable_T Sini (fun s : Stream (prod S Instant) => not (P s)))) *) unfold iff, Inevitable_T, not in |- *; intros; split. (* Goal: forall (_ : SafePath_T Sini P) (_ : forall (x : Stream (prod S Instant)) (_ : isTraceFrom_T Sini x), @ExistsS (prod S Instant) (fun s : Stream (prod S Instant) => and (bound (@snd S Instant (@hd (prod S Instant) s))) (forall _ : P s, False)) x), False *) (* Goal: forall _ : forall _ : forall (x : Stream (prod S Instant)) (_ : isTraceFrom_T Sini x), @ExistsS (prod S Instant) (fun s : Stream (prod S Instant) => and (bound (@snd S Instant (@hd (prod S Instant) s))) (forall _ : P s, False)) x, False, SafePath_T Sini P *) intro sp; inversion sp; intros. (* Goal: False *) (* Goal: forall _ : forall _ : forall (x : Stream (prod S Instant)) (_ : isTraceFrom_T Sini x), @ExistsS (prod S Instant) (fun s : Stream (prod S Instant) => and (bound (@snd S Instant (@hd (prod S Instant) s))) (forall _ : P s, False)) x, False, SafePath_T Sini P *) generalize H0; elim (H1 x H); intros. (* Goal: False *) (* Goal: False *) (* Goal: forall _ : forall _ : forall (x : Stream (prod S Instant)) (_ : isTraceFrom_T Sini x), @ExistsS (prod S Instant) (fun s : Stream (prod S Instant) => and (bound (@snd S Instant (@hd (prod S Instant) s))) (forall _ : P s, False)) x, False, SafePath_T Sini P *) inversion_clear H3 in H2. (* Goal: False *) (* Goal: False *) (* Goal: forall _ : forall _ : forall (x : Stream (prod S Instant)) (_ : isTraceFrom_T Sini x), @ExistsS (prod S Instant) (fun s : Stream (prod S Instant) => and (bound (@snd S Instant (@hd (prod S Instant) s))) (forall _ : P s, False)) x, False, SafePath_T Sini P *) elim H2; intros. (* Goal: False *) (* Goal: False *) (* Goal: forall _ : forall _ : forall (x : Stream (prod S Instant)) (_ : isTraceFrom_T Sini x), @ExistsS (prod S Instant) (fun s : Stream (prod S Instant) => and (bound (@snd S Instant (@hd (prod S Instant) s))) (forall _ : P s, False)) x, False, SafePath_T Sini P *) apply (H6 (H4 H3)). (* Goal: not (Posible_T Sini0 (fun s : Stream (prod S Instant) => not (P s))) *) (* Goal: Posible_T Sini0 (fun s : Stream (prod S Instant) => not (P s)) *) (* Goal: @ForAllS (prod S Instant) (fun s : Stream (prod S Instant) => forall _ : bound (@snd S Instant (@hd (prod S Instant) s)), P s) s *) apply H3; inversion_clear H4; assumption. intro H; elim (not_all_ex_not (Stream (S * Instant)) (fun x : Stream (S * Instant) => isTraceFrom_T Sini x -> ExistsS (fun s : Stream (S * Instant) => bound (snd (hd s)) /\ (P s -> False)) x) H). (* Goal: forall (x : Stream (prod S Instant)) (_ : not (forall _ : isTraceFrom_T Sini x, @ExistsS (prod S Instant) (fun s : Stream (prod S Instant) => and (bound (@snd S Instant (@hd (prod S Instant) s))) (forall _ : P s, False)) x)), SafePath_T Sini P *) intros. generalize (not_imply_elim2 (isTraceFrom_T Sini x) (ExistsS (fun s : Stream (S * Instant) => bound (snd (hd s)) /\ (P s -> False)) x) H0). generalize (not_imply_elim (isTraceFrom_T Sini x) (ExistsS (fun s : Stream (S * Instant) => bound (snd (hd s)) /\ (P s -> False)) x) H0); (* Goal: forall (x : Stream (prod S Instant)) (_ : not (forall _ : isTraceFrom_T Sini x, @ExistsS (prod S Instant) (fun s : Stream (prod S Instant) => and (bound (@snd S Instant (@hd (prod S Instant) s))) (forall _ : P s, False)) x)), SafePath_T Sini P *) intros. (* Goal: SafePath_T Sini P *) apply safePath_T with (1 := H1). (* Goal: @ForAllS (prod S Instant) (fun s : Stream (prod S Instant) => forall _ : bound (@snd S Instant (@hd (prod S Instant) s)), P s) x *) generalize H1; clear H1; generalize H2; clear H2. (* Goal: forall (_ : forall _ : Posible_T Sini (fun s : Stream (prod S Instant) => forall _ : P s, False), False) (x : Stream (prod S Instant)) (_ : isTraceFrom_T Sini x), @ForAllS (prod S Instant) (fun s : Stream (prod S Instant) => forall _ : bound (@snd S Instant (@hd (prod S Instant) s)), P s) x *) generalize x; generalize Sini; cofix u. (* Goal: forall (Sini : prod S Instant) (x : Stream (prod S Instant)) (_ : not (@ExistsS (prod S Instant) (fun s : Stream (prod S Instant) => and (bound (@snd S Instant (@hd (prod S Instant) s))) (forall _ : P s, False)) x)) (_ : isTraceFrom_T Sini x), @ForAllS (prod S Instant) (fun s : Stream (prod S Instant) => forall _ : bound (@snd S Instant (@hd (prod S Instant) s)), P s) x *) simple destruct x0; intros; constructor. (* Goal: forall _ : bound (@snd S Instant (@hd (prod S Instant) (@Cons (prod S Instant) p s))), P (@Cons (prod S Instant) p s) *) (* Goal: @ForAllS (prod S Instant) (fun s : Stream (prod S Instant) => forall _ : bound (@snd S Instant (@hd (prod S Instant) s)), P s) s *) elim (classic (P (p ^ s))); [ trivial | intros ]. cut (ExistsS (fun s0 : Stream (S * Instant) => bound (snd (hd s0)) /\ (P s0 -> False)) (p ^ s)). (* Goal: forall _ : @ExistsS (prod S Instant) (fun s0 : Stream (prod S Instant) => and (bound (@snd S Instant (@hd (prod S Instant) s0))) (forall _ : P s0, False)) (@Cons (prod S Instant) p s), P (@Cons (prod S Instant) p s) *) (* Goal: @ExistsS (prod S Instant) (fun s0 : Stream (prod S Instant) => and (bound (@snd S Instant (@hd (prod S Instant) s0))) (forall _ : P s0, False)) (@Cons (prod S Instant) p s) *) (* Goal: @ForAllS (prod S Instant) (fun s : Stream (prod S Instant) => forall _ : bound (@snd S Instant (@hd (prod S Instant) s)), P s) s *) intro ex; elim (H2 ex). apply Here with (P := fun s : Stream (S * Instant) => bound (snd (hd s)) /\ (P s -> False)). (* Goal: not (Posible_T Sini0 (fun s : Stream (prod S Instant) => not (P s))) *) (* Goal: Posible_T Sini0 (fun s : Stream (prod S Instant) => not (P s)) *) (* Goal: @ForAllS (prod S Instant) (fun s : Stream (prod S Instant) => forall _ : bound (@snd S Instant (@hd (prod S Instant) s)), P s) s *) split; assumption. (* Goal: @ForAllS (prod S Instant) (fun s : Stream (prod S Instant) => forall _ : bound (@snd S Instant (@hd (prod S Instant) s)), P s) s *) apply u with (Sini := hd s). (* Goal: forall (x : Stream (prod S Instant)) (_ : not (forall _ : isTraceFrom_T Sini x, @ExistsS (prod S Instant) (fun s : Stream (prod S Instant) => and (bound (@snd S Instant (@hd (prod S Instant) s))) (forall _ : P s, False)) x)), SafePath_T Sini P *) generalize H2; clear H2; case s; unfold not in |- *; intros. (* Goal: False *) (* Goal: isTraceFrom_T (@hd (prod S Instant) s) s *) apply (not_EX H2 H3). unfold isTraceFrom_T in |- *; elim H1; intros ig trace; inversion_clear trace. (* Goal: and (@eq (prod S Instant) (@hd (prod S Instant) (@Cons (prod S Instant) (@pair S Instant s2 t) x1)) (@hd (prod S Instant) (@Cons (prod S Instant) (@pair S Instant s2 t) x1))) (isTrace_T (@Cons (prod S Instant) (@pair S Instant s2 t) x1)) *) split; trivial. (* Goal: and (@eq (prod S Instant) (@hd (prod S Instant) (@Cons (prod S Instant) (@pair S Instant s2 t) x1)) (@hd (prod S Instant) (@Cons (prod S Instant) (@pair S Instant s2 t) x1))) (isTrace_T (@Cons (prod S Instant) (@pair S Instant s2 t) x1)) *) split; trivial. Qed. End TemporalOperators_TCTL.
(* This program is free software; you can redistribute it and/or *) (* modify it under the terms of the GNU Lesser General Public License *) (* as published by the Free Software Foundation; either version 2.1 *) (* of the License, or (at your option) any later version. *) (* *) (* This program is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* GNU General Public License for more details. *) (* *) (* You should have received a copy of the GNU Lesser General Public *) (* License along with this program; if not, write to the Free *) (* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *) (* 02110-1301 USA *) Set Implicit Arguments. Unset Strict Implicit. Require Import time_clocks. (* Temporal notions for discrete time *) Section TemporalOperators_Ind. (*** Temporal operators with inductive types: definition and properties ***) Variable Label : Set. (* labels: dicrete transitions *) Variable S : Set. (* states *) Variable tr : S -> Label -> S -> Prop. (* transitions *) Variable inv : S -> Prop. (* location invariants *) Variable inc : S -> Instant -> S. (* increase clocks of states *) (* Reachable states from "Sini" with transitions "tr" *) Inductive RState (Sini : S) : S -> Prop := | rsIni : RState Sini Sini | rsNextTick : forall s : S, RState Sini s -> inv (inc s tick) -> RState Sini (inc s tick) | rsNextDisc : forall (s1 s2 : S) (l : Label), RState Sini s1 -> tr s1 l s2 -> inv s2 -> RState Sini s2. (* Reachable states from "Sini" with transitions "tr" in time units *) Inductive RState_T (Sini : S) : S -> Instant -> Prop := | rsIni_T : RState_T Sini Sini time0 | rsNextTick_T : forall (s : S) (t : Instant), RState_T Sini s t -> inv (inc s tick) -> RState_T Sini (inc s tick) (Inc t) | rsNextDisc_T : forall (s1 s2 : S) (l : Label) (t : Instant), RState_T Sini s1 t -> tr s1 l s2 -> inv s2 -> RState_T Sini s2 t. (**************************************************************************) (* Invariants and Reachability *) (**************************************************************************) (* Init => FA[] P *) Definition ForAll (Sini : S) (P : S -> Prop) := forall s : S, RState Sini s -> P s. (* Init => FA[](bound t) P *) Definition ForAll_T (Sini : S) (P : S -> Prop) (bound : Instant -> Prop) := forall (s : S) (t : Instant), bound t -> RState_T Sini s t -> P s. (* Init => EX<> P *) Inductive Exists (Sini : S) (P : S -> Prop) : Prop := exists_ : forall s : S, RState Sini s -> P s -> Exists Sini P. (* Init => EX<>(bound t) P *) Inductive Exists_T (Sini : S) (P : S -> Prop) (bound : Instant -> Prop) : Prop := exists_T : forall (s : S) (t : Instant), bound t -> RState_T Sini s t -> P s -> Exists_T Sini P bound. (**************************************************************************) (* Some Properties *) (**************************************************************************) Theorem Mon_I : forall (Sini : S) (Pg Pp : S -> Prop), ForAll Sini Pg -> (forall s : S, Pg s -> Pp s) -> ForAll Sini Pp. Proof. (* Goal: forall (Sini : S) (P1 P2 : forall _ : S, Prop) (_ : ForAll Sini P1) (_ : ForAll Sini P2), ForAll Sini (fun s : S => and (P1 s) (P2 s)) *) unfold ForAll in |- *; intros. (* Goal: Pp s *) apply H0. (* Goal: Pg s *) apply H; assumption. Qed. Theorem Mon_I_T : forall (Sini : S) (Pg Pp : S -> Prop) (bound : Instant -> Prop), ForAll_T Sini Pg bound -> (forall s : S, Pg s -> Pp s) -> ForAll_T Sini Pp bound. Proof. (* Goal: forall (Sini : S) (P1 P2 : forall _ : S, Prop) (bound : forall _ : Instant, Prop) (_ : ForAll_T Sini P1 bound) (_ : ForAll_T Sini P2 bound), ForAll_T Sini (fun s : S => and (P1 s) (P2 s)) bound *) unfold ForAll_T in |- *; intros. (* Goal: Pp s *) apply H0. (* Goal: Pg s *) apply (H s t); assumption. Qed. Theorem Conj : forall (Sini : S) (P1 P2 : S -> Prop), ForAll Sini P1 -> ForAll Sini P2 -> ForAll Sini (fun s : S => P1 s /\ P2 s). Proof. (* Goal: forall (Sini : S) (P1 P2 : forall _ : S, Prop) (_ : ForAll Sini P1) (_ : ForAll Sini P2), ForAll Sini (fun s : S => and (P1 s) (P2 s)) *) unfold ForAll in |- *; intros. (* Goal: and (P1 s) (P2 s) *) split; [ apply H | apply H0 ]; assumption. Qed. Theorem Conj_T : forall (Sini : S) (P1 P2 : S -> Prop) (bound : Instant -> Prop), ForAll_T Sini P1 bound -> ForAll_T Sini P2 bound -> ForAll_T Sini (fun s : S => P1 s /\ P2 s) bound. Proof. (* Goal: forall (Sini : S) (P1 P2 : forall _ : S, Prop) (bound : forall _ : Instant, Prop) (_ : ForAll_T Sini P1 bound) (_ : ForAll_T Sini P2 bound), ForAll_T Sini (fun s : S => and (P1 s) (P2 s)) bound *) unfold ForAll_T in |- *; intros. (* Goal: and (P1 s) (P2 s) *) split; [ apply (H s t) | apply (H0 s t) ]; assumption. Qed. Theorem Mon_I_EX : forall (Sini : S) (Pg Pp : S -> Prop), Exists Sini Pg -> (forall s : S, Pg s -> Pp s) -> Exists Sini Pp. Proof. (* Goal: forall (s1 s2 : S) (P : forall _ : S, Prop) (_ : RState s1 s2) (_ : Exists s2 P), Exists s1 P *) intros. (* Goal: Exists_T Sini Pp bound *) inversion_clear H. (* Goal: Exists Sini Pp *) apply (exists_ H1 (H0 s H2)). Qed. Theorem Mon_I_EX_T : forall (Sini : S) (Pg Pp : S -> Prop) (bound : Instant -> Prop), Exists_T Sini Pg bound -> (forall s : S, Pg s -> Pp s) -> Exists_T Sini Pp bound. Proof. (* Goal: forall (s1 s2 : S) (P : forall _ : S, Prop) (_ : RState s1 s2) (_ : Exists s2 P), Exists s1 P *) intros. (* Goal: Exists_T Sini Pp bound *) inversion_clear H. (* Goal: Exists_T Sini Pp bound *) apply (exists_T H1 H2 (H0 s H3)). Qed. Lemma RState_Trans : forall s1 s2 s3 : S, RState s1 s2 -> RState s2 s3 -> RState s1 s3. Proof. (* Goal: forall (s1 s2 : S) (P : forall _ : S, Prop) (_ : RState s1 s2) (_ : Exists s2 P), Exists s1 P *) simple induction 2; intros. (* Goal: not (Exists_T Sini (fun s : S => forall _ : P s, False) bound) *) (* Goal: Exists_T Sini (fun s : S => forall _ : P s, False) bound *) assumption. (* Goal: RState s1 (inc s tick) *) (* Goal: RState s1 s4 *) apply rsNextTick; trivial. (* Goal: RState s1 s4 *) apply (rsNextDisc H2 H3 H4). Qed. Lemma RState_Trans_T : forall (s1 s2 s3 : S) (t1 t2 : Instant), RState_T s1 s2 t1 -> RState_T s2 s3 t2 -> RState_T s1 s3 (plus_Ck t1 t2). Proof. (* Goal: forall (s1 s2 : S) (P : forall _ : S, Prop) (_ : RState s1 s2) (_ : Exists s2 P), Exists s1 P *) simple induction 2; unfold plus_Ck in |- *; intros. rewrite (plus_comm t1 time0); unfold time0 in |- *; simpl in |- *; (* Goal: not (Exists_T Sini (fun s : S => forall _ : P s, False) bound) *) (* Goal: Exists_T Sini (fun s : S => forall _ : P s, False) bound *) assumption. unfold Inc in |- *; unfold plus_Ck in |- *; rewrite (plus_assoc t1 t tick). (* Goal: RState_T s1 (inc s tick) (Nat.add (Nat.add t1 t) tick) *) (* Goal: RState_T s1 s4 (Init.Nat.add t1 t) *) apply (rsNextTick_T H2 H3). (* Goal: RState_T s1 s4 (Init.Nat.add t1 t) *) apply (rsNextDisc_T H2 H3 H4). Qed. Theorem StepsEX : forall (s1 s2 : S) (P : S -> Prop), RState s1 s2 -> Exists s2 P -> Exists s1 P. Proof. (* Goal: forall (s1 s2 : S) (P : forall _ : S, Prop) (_ : RState s1 s2) (_ : Exists s2 P), Exists s1 P *) intros. (* Goal: False *) (* Goal: P s *) inversion H0. (* Goal: Exists s1 P *) apply (exists_ (RState_Trans H H1) H2). Qed. Require Import Classical. Theorem ForAll_EX : forall (Sini : S) (P : S -> Prop), ForAll Sini P <-> ~ Exists Sini (fun s : S => ~ P s). Proof. unfold not in |- *; unfold ForAll in |- *; red in |- *; intros; split; (* Goal: forall (s1 s2 : S) (P : forall _ : S, Prop) (_ : RState s1 s2) (_ : Exists s2 P), Exists s1 P *) intros. (* Goal: False *) (* Goal: P s *) inversion H0. (* Goal: False *) (* Goal: P s *) apply (H2 (H s H1)). elim (classic (P s)); [ trivial | intro; absurd (Exists Sini (fun s : S => P s -> False)) ]. (* Goal: not (Exists_T Sini (fun s : S => forall _ : P s, False) bound) *) (* Goal: Exists_T Sini (fun s : S => forall _ : P s, False) bound *) assumption. (* Goal: not (Exists_T Sini (fun s : S => forall _ : P s, False) bound) *) (* Goal: Exists_T Sini (fun s : S => forall _ : P s, False) bound *) apply exists_ with (1 := H0); assumption. Qed. Theorem ForAll_EX_T : forall (Sini : S) (P : S -> Prop) (bound : Instant -> Prop), ForAll_T Sini P bound <-> ~ Exists_T Sini (fun s : S => ~ P s) bound. Proof. unfold not in |- *; unfold ForAll_T in |- *; red in |- *; intros; split; (* Goal: forall (s1 s2 : S) (P : forall _ : S, Prop) (_ : RState s1 s2) (_ : Exists s2 P), Exists s1 P *) intros. (* Goal: False *) (* Goal: P s *) inversion H0. (* Goal: False *) (* Goal: P s *) apply (H3 (H s t H1 H2)). elim (classic (P s)); [ trivial | intro; absurd (Exists_T Sini (fun s : S => P s -> False) bound) ]. (* Goal: not (Exists_T Sini (fun s : S => forall _ : P s, False) bound) *) (* Goal: Exists_T Sini (fun s : S => forall _ : P s, False) bound *) assumption. (* Goal: not (Exists_T Sini (fun s : S => forall _ : P s, False) bound) *) (* Goal: Exists_T Sini (fun s : S => forall _ : P s, False) bound *) apply exists_T with (2 := H1); assumption. Qed. (**************************************************************************) (* Other definitions *) (**************************************************************************) (* FA[] (Q => FA[] P) *) Definition ForAll_from (Sini : S) (Q P : S -> Prop) := ForAll Sini (fun s : S => Q s -> ForAll s P). (* (s:S) (RState Sini s) -> (Q s) -> (ForAll s P). *) (* FA[] (Q => FA[](bound t) P) *) Definition ForAll_from_T (Sini : S) (Q P : S -> Prop) (bound : Instant -> Prop) := ForAll Sini (fun s : S => Q s -> ForAll_T s P bound). (* (s:S) (RState Sini s) -> (Q s) -> (ForAll_T s P bound). *) (* FA[] (Q => EX<> P) *) Definition Exists_from (Sini : S) (Q P : S -> Prop) := ForAll Sini (fun s : S => Q s -> Exists s P). (* (s:S) (RState Sini s) -> (Q s) -> (Exists s P). *) (* FA[] (Q => EX<>(bound t) P) *) Definition Exists_from_T (Sini : S) (Q P : S -> Prop) (bound : Instant -> Prop) := ForAll Sini (fun s : S => Q s -> Exists_T s P bound). (* (s:S) (RState Sini s) -> (Q s) -> (Exists_T s P bound). *) End TemporalOperators_Ind.
(* (c) Copyright 2006-2016 Microsoft Corporation and Inria. *) (* Distributed under the terms of CeCILL-B. *) Require Import mathcomp.ssreflect.ssreflect. From mathcomp Require Import ssrfun ssrbool eqtype ssrnat seq choice fintype. (****************************************************************************) (* This is a small library to do epsilon - N reasonning. *) (* In order to use it, one only has to know the following tactics: *) (* *) (* pose_big_enough i == pose a big enough natural number i *) (* pose_big_modulus m F == pose a function m : F -> nat which should *) (* provide a big enough return value *) (* exists_big_modulus m F := pose_big_modulus m F; exists m *) (* big_enough == replaces a big enough constraint x <= i *) (* by true and implicity remembers that i should *) (* be bigger than x. *) (* close == all "pose" tactics create a dummy subgoal to *) (* force the user to explictely indicate that all *) (* constraints have been found *) (****************************************************************************) Set Implicit Arguments. Unset Strict Implicit. Unset Printing Implicit Defensive. Module BigEnough. Record big_rel_class_of T (leq : rel T) := BigRelClass { leq_big_internal_op : rel T; bigger_than_op : seq T -> T; _ : leq_big_internal_op = leq; _ : forall i s, leq_big_internal_op i (bigger_than_op (i :: s)); _ : forall i j s, leq_big_internal_op i (bigger_than_op s) -> leq_big_internal_op i (bigger_than_op (j :: s)) }. Record big_rel_of T := BigRelOf { leq_big :> rel T; big_rel_class : big_rel_class_of leq_big }. Definition bigger_than_of T (b : big_rel_of T) (phb : phantom (rel T) b) := bigger_than_op (big_rel_class b). Notation bigger_than leq := (@bigger_than_of _ _ (Phantom (rel _) leq)). Definition leq_big_internal_of T (b : big_rel_of T) (phb : phantom (rel T) b) := leq_big_internal_op (big_rel_class b). Notation leq_big_internal leq := (@leq_big_internal_of _ _ (Phantom (rel _) leq)). Lemma next_bigger_than T (b : big_rel_of T) i j s : leq_big_internal b i (bigger_than b s) -> leq_big_internal b i (bigger_than b (j :: s)). (* Goal: forall (_ : is_true (@leq_big_internal_of T b (Phantom (rel T) (@leq_big T b)) i (@bigger_than_of T b (Phantom (rel T) (@leq_big T b)) s))) (_ : P true), P (@leq_big T b i (@bigger_than_of T b (Phantom (rel T) (@leq_big T b)) s)) *) Proof. by case: b i j s => [? []]. Qed. Lemma instantiate_bigger_than T (b : big_rel_of T) i s : leq_big_internal b i (bigger_than b (i :: s)). Proof. by case: b i s => [? []]. Qed. Lemma leq_big_internalE T (b : big_rel_of T) : leq_big_internal b = leq_big b. Proof. by case: b => [? []]. Qed. (* Lemma big_enough T (b : big_rel_of T) i s : *) (* leq_big_internal b i (bigger_than b s) -> *) (* leq_big b i (bigger_than b s). *) (* Proof. by rewrite leq_big_internalE. Qed. *) Lemma context_big_enough P T (b : big_rel_of T) i s : leq_big_internal b i (bigger_than b s) -> P true -> P (leq_big b i (bigger_than b s)). Proof. by rewrite leq_big_internalE => ->. Qed. Definition big_rel_leq_class : big_rel_class_of leq. Proof. exists leq (foldr maxn 0%N) => [|i s|i j s /leq_trans->] //; by rewrite (leq_maxl, leq_maxr). Qed. Canonical big_enough_nat := BigRelOf big_rel_leq_class. Definition closed T (i : T) := {j : T | j = i}. Ltac close := match goal with | |- context [closed ?i] => instantiate (1 := [::]) in (Value of i); exists i end. Ltac pose_big_enough i := evar (i : nat); suff : closed i; first do [move=> _; instantiate (1 := bigger_than leq _) in (Value of i)]. Ltac pose_big_modulus m F := evar (m : F -> nat); suff : closed m; first do [move=> _; instantiate (1 := (fun e => bigger_than leq _)) in (Value of m)]. Ltac exists_big_modulus m F := pose_big_modulus m F; first exists m. Ltac olddone := trivial; hnf; intros; solve [ do ![solve [trivial | apply: sym_equal; trivial] | discriminate | contradiction | split] | case not_locked_false_eq_true; assumption | match goal with H : ~ _ |- _ => solve [case H; trivial] end]. Ltac big_enough := do ?[ apply context_big_enough; first do [do ?[ now apply instantiate_bigger_than | apply next_bigger_than]]]. Ltac big_enough_trans := match goal with | [leq_nm : is_true (?n <= ?m)%N |- is_true (?x <= ?m)] => apply: leq_trans leq_nm; big_enough; olddone | _ => big_enough; olddone end. Ltac done := do [olddone|big_enough_trans]. End BigEnough.
(* Contribution to the Coq Library V6.3 (July 1999) *) (****************************************************************************) (* The Calculus of Inductive Constructions *) (* *) (* Projet Coq *) (* *) (* INRIA ENS-CNRS *) (* Rocquencourt Lyon *) (* *) (* Coq V5.10 *) (* Nov 25th 1994 *) (* *) (****************************************************************************) (* Pol1.v *) (****************************************************************************) (*****************************************************************************) (* Projet Coq - Calculus of Inductive Constructions V5.8 *) (*****************************************************************************) (* *) (* Meta-theory of the explicit substitution calculus lambda-env *) (* Amokrane Saibi *) (* *) (* September 1993 *) (* *) (*****************************************************************************) (* Preuve de terminaison: Polynome P1 *) Require Import Le. Require Import Lt. Require Import Plus. Require Import Gt. Require Import Minus. Require Import Mult. Require Import TS. Require Import sigma_lift. Require Import comparith. Definition e_P1 (b : wsort) (U : TS b) : nat := (fix F (w : wsort) (t : TS w) {struct t} : nat := match t with | var n => power2 (S n) | app t0 t1 => F wt t0 + F wt t1 | lambda t0 => F wt t0 + 2 | env t0 t1 => F wt t0 * F ws t1 | id => 2 | shift => 2 | cons t0 t1 => F wt t0 + F ws t1 | comp t0 t1 => F ws t0 * F ws t1 | lift t0 => F ws t0 | meta_X _ => 2 | meta_x _ => 2 end) b U. (* var *) (* app *) (* lam *) (* env *) (* id *) (* | *) (* . *) (* o *) (* || *) (* X *) (* x *) Notation P1 := (e_P1 _) (only parsing). (* <Warning> : Syntax is discontinued *) Theorem gt_P1_1 : forall (b : wsort) (M : TS b), e_P1 _ M > 1. Proof. (* Goal: forall (b : wsort) (M : TS b), gt (e_P1 b M) (S O) *) simple induction M; intros; simpl in |- *; auto with arith. (* var *) (* Goal: gt (Nat.add (power2 n) (Nat.add (power2 n) O)) (S O) *) elim plus_n_O; elim n; simpl in |- *. (* Goal: @eq nat (Nat.mul (power2 (S n)) (Nat.mul (S (S O)) (e_P1 ws s))) (Nat.mul (power2 (S n)) (Nat.mul (e_P1 ws s) (S (S O)))) *) auto with arith. (* Goal: @eq nat (Nat.mul (power2 (S n)) (Nat.mul (S (S O)) (e_P1 ws s))) (Nat.mul (power2 (S n)) (Nat.mul (e_P1 ws s) (S (S O)))) *) intros; elim plus_n_O; auto with arith. Qed. Hint Resolve gt_P1_1. Theorem P1_app : forall M N : terms, reg_app M N -> e_P1 _ M = e_P1 _ N. Proof. (* Goal: @eq nat (Nat.mul (power2 (S n)) (Nat.mul (S (S O)) (e_P1 ws s))) (Nat.mul (power2 (S n)) (Nat.mul (e_P1 ws s) (S (S O)))) *) simple induction 1; intros; simpl in |- *; auto with arith. Qed. Hint Resolve P1_app. Theorem P1_lambda : forall M N : terms, reg_lambda M N -> e_P1 _ M > e_P1 _ N. Proof. simple induction 1; intros; simpl in |- *; rewrite Mult.mult_plus_distr_r; (* Goal: @eq nat (Nat.mul (power2 (S n)) (Nat.mul (S (S O)) (e_P1 ws s))) (Nat.mul (power2 (S n)) (Nat.mul (e_P1 ws s) (S (S O)))) *) auto with arith. Qed. Hint Resolve P1_lambda. Theorem P1_clos : forall M N : terms, reg_clos M N -> e_P1 _ M = e_P1 _ N. Proof. (* Goal: @eq nat (Nat.mul (power2 (S n)) (Nat.mul (S (S O)) (e_P1 ws s))) (Nat.mul (power2 (S n)) (Nat.mul (e_P1 ws s) (S (S O)))) *) simple induction 1; intros; simpl in |- *; auto with arith. Qed. Hint Resolve P1_clos. Theorem P1_varshift1 : forall M N : terms, reg_varshift1 M N -> e_P1 _ M = e_P1 _ N. Proof. (* Goal: forall (M N : terms) (_ : reg_rvarlift2 M N), @eq nat (e_P1 wt M) (e_P1 wt N) *) simple induction 1; intros. (* Goal: @eq nat (e_P1 wt (env (var n) shift)) (e_P1 wt (var (S n))) *) change (power2 (S n) * 2 = 2 * power2 (S n)) in |- *. (* Goal: @eq nat (Nat.mul (power2 (S n)) (Nat.mul (S (S O)) (e_P1 ws s))) (Nat.mul (power2 (S n)) (Nat.mul (e_P1 ws s) (S (S O)))) *) auto with arith. Qed. Hint Resolve P1_varshift1. Theorem P1_varshift2 : forall M N : terms, reg_varshift2 M N -> e_P1 _ M = e_P1 _ N. Proof. (* Goal: forall (M N : terms) (_ : reg_rvarlift2 M N), @eq nat (e_P1 wt M) (e_P1 wt N) *) simple induction 1; intros. (* Goal: @eq nat (e_P1 wt (env (var n) (comp shift s))) (e_P1 wt (env (var (S n)) s)) *) change (power2 (S n) * (2 * e_P1 _ s) = 2 * power2 (S n) * e_P1 _ s) in |- *. (* Goal: @eq nat (Nat.mul (power2 (S n)) (Nat.mul (S (S O)) (e_P1 ws s))) (Nat.mul (power2 (S n)) (Nat.mul (e_P1 ws s) (S (S O)))) *) elim mult_permut; auto with arith. Qed. Hint Resolve P1_varshift2. Theorem P1_fvarcons : forall M N : terms, reg_fvarcons M N -> e_P1 _ M > e_P1 _ N. Proof. (* Goal: @eq nat (Nat.mul (power2 (S n)) (Nat.mul (S (S O)) (e_P1 ws s))) (Nat.mul (power2 (S n)) (Nat.mul (e_P1 ws s) (S (S O)))) *) simple induction 1; intros; simpl in |- *; elim plus_n_O; auto with arith. Qed. Hint Resolve P1_fvarcons. Theorem P1_fvarlift1 : forall M N : terms, reg_fvarlift1 M N -> e_P1 _ M > e_P1 _ N. Proof. (* Goal: forall (M N : terms) (_ : reg_rvarlift2 M N), @eq nat (e_P1 wt M) (e_P1 wt N) *) simple induction 1; intros. (* Goal: gt (e_P1 wt (env (var O) (lift s))) (e_P1 wt (var O)) *) change (2 * e_P1 _ s > 2) in |- *. (* Goal: @eq nat (Nat.mul (power2 (S n)) (Nat.mul (S (S O)) (e_P1 ws s))) (Nat.mul (power2 (S n)) (Nat.mul (e_P1 ws s) (S (S O)))) *) auto with arith. Qed. Hint Resolve P1_fvarlift1. Theorem P1_fvarlift2 : forall M N : terms, reg_fvarlift2 M N -> e_P1 _ M > e_P1 _ N. Proof. (* Goal: forall (M N : terms) (_ : reg_rvarlift2 M N), @eq nat (e_P1 wt M) (e_P1 wt N) *) simple induction 1; intros. (* Goal: gt (e_P1 wt (env (var O) (comp (lift s) t))) (e_P1 wt (env (var O) t)) *) change (2 * (e_P1 _ s * e_P1 _ t) > 2 * e_P1 _ t) in |- *. (* Goal: @eq nat (Nat.mul (power2 (S n)) (Nat.mul (S (S O)) (e_P1 ws s))) (Nat.mul (power2 (S n)) (Nat.mul (e_P1 ws s) (S (S O)))) *) auto with arith. Qed. Hint Resolve P1_fvarlift2. Theorem P1_rvarcons : forall M N : terms, reg_rvarcons M N -> e_P1 _ M > e_P1 _ N. Proof. (* Goal: forall (M N : terms) (_ : reg_rvarlift2 M N), @eq nat (e_P1 wt M) (e_P1 wt N) *) simple induction 1; intros. change (2 * power2 (S n) * (e_P1 _ a + e_P1 _ s) > power2 (S n) * e_P1 _ s) in |- *. (* Goal: @eq nat (Nat.mul (power2 (S n)) (Nat.mul (S (S O)) (e_P1 ws s))) (Nat.mul (power2 (S n)) (Nat.mul (e_P1 ws s) (S (S O)))) *) rewrite comparith.mult_plus_distr_r; auto with arith. Qed. Hint Resolve P1_rvarcons. Theorem P1_rvarlift1 : forall M N : terms, reg_rvarlift1 M N -> e_P1 _ M = e_P1 _ N. Proof. (* Goal: forall (M N : terms) (_ : reg_rvarlift2 M N), @eq nat (e_P1 wt M) (e_P1 wt N) *) simple induction 1; intros. (* Goal: @eq nat (e_P1 wt (env (var (S n)) (lift s))) (e_P1 wt (env (var n) (comp s shift))) *) change (2 * power2 (S n) * e_P1 _ s = power2 (S n) * (e_P1 _ s * 2)) in |- *. (* Goal: @eq nat (Nat.mul (Nat.mul (S (S O)) (power2 (S n))) (e_P1 ws s)) (Nat.mul (power2 (S n)) (Nat.mul (e_P1 ws s) (S (S O)))) *) elim mult_assoc_l; elim (mult_permut (power2 (S n)) 2 (e_P1 _ s)). (* Goal: @eq nat (Nat.mul (power2 (S n)) (Nat.mul (S (S O)) (e_P1 ws s))) (Nat.mul (power2 (S n)) (Nat.mul (e_P1 ws s) (S (S O)))) *) auto with arith. Qed. Hint Resolve P1_rvarlift1. Theorem P1_rvarlift2 : forall M N : terms, reg_rvarlift2 M N -> e_P1 _ M = e_P1 _ N. Proof. (* Goal: forall (M N : terms) (_ : reg_rvarlift2 M N), @eq nat (e_P1 wt M) (e_P1 wt N) *) simple induction 1; intros. change (2 * power2 (S n) * (e_P1 _ s * e_P1 _ t) = power2 (S n) * (e_P1 _ s * (2 * e_P1 _ t))) in |- *. (* Goal: @eq nat (Nat.mul (power2 (S n)) (Nat.mul (S (S O)) (e_P1 ws s))) (Nat.mul (power2 (S n)) (Nat.mul (e_P1 ws s) (S (S O)))) *) elim (mult_sym (power2 (S n)) 2); elim mult_assoc_l; auto with arith. Qed. Hint Resolve P1_rvarlift2. Theorem P1_assenv : forall M N : sub_explicits, reg_assenv M N -> e_P1 _ M = e_P1 _ N. Proof. (* Goal: @eq nat (Nat.mul (power2 (S n)) (Nat.mul (S (S O)) (e_P1 ws s))) (Nat.mul (power2 (S n)) (Nat.mul (e_P1 ws s) (S (S O)))) *) simple induction 1; intros; simpl in |- *; auto with arith. Qed. Hint Resolve P1_assenv. Theorem P1_mapenv : forall M N : sub_explicits, reg_mapenv M N -> e_P1 _ M = e_P1 _ N. Proof. (* Goal: @eq nat (Nat.mul (power2 (S n)) (Nat.mul (S (S O)) (e_P1 ws s))) (Nat.mul (power2 (S n)) (Nat.mul (e_P1 ws s) (S (S O)))) *) simple induction 1; intros; simpl in |- *; auto with arith. Qed. Hint Resolve P1_mapenv. Theorem P1_shiftcons : forall M N : sub_explicits, reg_shiftcons M N -> e_P1 _ M > e_P1 _ N. Proof. (* Goal: @eq nat (Nat.mul (power2 (S n)) (Nat.mul (S (S O)) (e_P1 ws s))) (Nat.mul (power2 (S n)) (Nat.mul (e_P1 ws s) (S (S O)))) *) simple induction 1; intros; simpl in |- *; elim plus_n_O; auto with arith. Qed. Hint Resolve P1_shiftcons. Theorem P1_shiftlift1 : forall M N : sub_explicits, reg_shiftlift1 M N -> e_P1 _ M = e_P1 _ N. Proof. (* Goal: @eq nat (Nat.mul (power2 (S n)) (Nat.mul (S (S O)) (e_P1 ws s))) (Nat.mul (power2 (S n)) (Nat.mul (e_P1 ws s) (S (S O)))) *) simple induction 1; intros; simpl in |- *; elim plus_n_O; auto with arith. Qed. Hint Resolve P1_shiftlift1. Theorem P1_shiftlift2 : forall M N : sub_explicits, reg_shiftlift2 M N -> e_P1 _ M = e_P1 _ N. Proof. simple induction 1; intros; simpl in |- *; do 2 elim plus_n_O; (* Goal: @eq nat (Nat.mul (power2 (S n)) (Nat.mul (S (S O)) (e_P1 ws s))) (Nat.mul (power2 (S n)) (Nat.mul (e_P1 ws s) (S (S O)))) *) auto with arith. Qed. Hint Resolve P1_shiftlift2. Theorem P1_lift1 : forall M N : sub_explicits, reg_lift1 M N -> e_P1 _ M = e_P1 _ N. Proof. (* Goal: @eq nat (Nat.mul (power2 (S n)) (Nat.mul (S (S O)) (e_P1 ws s))) (Nat.mul (power2 (S n)) (Nat.mul (e_P1 ws s) (S (S O)))) *) simple induction 1; intros; simpl in |- *; auto with arith. Qed. Hint Resolve P1_lift1. Theorem P1_lift2 : forall M N : sub_explicits, reg_lift2 M N -> e_P1 _ M = e_P1 _ N. Proof. (* Goal: @eq nat (Nat.mul (power2 (S n)) (Nat.mul (S (S O)) (e_P1 ws s))) (Nat.mul (power2 (S n)) (Nat.mul (e_P1 ws s) (S (S O)))) *) simple induction 1; intros; simpl in |- *; auto with arith. Qed. Hint Resolve P1_lift2. Theorem P1_liftenv : forall M N : sub_explicits, reg_liftenv M N -> e_P1 _ M > e_P1 _ N. Proof. simple induction 1; intros; simpl in |- *; (* Goal: @eq nat (Nat.mul (power2 (S n)) (Nat.mul (S (S O)) (e_P1 ws s))) (Nat.mul (power2 (S n)) (Nat.mul (e_P1 ws s) (S (S O)))) *) rewrite comparith.mult_plus_distr_r; auto with arith. Qed. Hint Resolve P1_liftenv. Theorem P1_idl : forall M N : sub_explicits, reg_idl M N -> e_P1 _ M > e_P1 _ N. Proof. (* Goal: @eq nat (Nat.mul (power2 (S n)) (Nat.mul (S (S O)) (e_P1 ws s))) (Nat.mul (power2 (S n)) (Nat.mul (e_P1 ws s) (S (S O)))) *) simple induction 1; intros; simpl in |- *; elim plus_n_O; auto with arith. Qed. Hint Resolve P1_idl. Theorem P1_idr : forall M N : sub_explicits, reg_idr M N -> e_P1 _ M > e_P1 _ N. Proof. (* Goal: @eq nat (Nat.mul (power2 (S n)) (Nat.mul (S (S O)) (e_P1 ws s))) (Nat.mul (power2 (S n)) (Nat.mul (e_P1 ws s) (S (S O)))) *) simple induction 1; intros; simpl in |- *; auto with arith. Qed. Hint Resolve P1_idr. Theorem P1_liftid : forall M N : sub_explicits, reg_liftid M N -> e_P1 _ M = e_P1 _ N. Proof. (* Goal: @eq nat (Nat.mul (power2 (S n)) (Nat.mul (S (S O)) (e_P1 ws s))) (Nat.mul (power2 (S n)) (Nat.mul (e_P1 ws s) (S (S O)))) *) simple induction 1; intros; simpl in |- *; auto with arith. Qed. Hint Resolve P1_liftid. Theorem P1_id : forall M N : terms, reg_id M N -> e_P1 _ M > e_P1 _ N. Proof. (* Goal: @eq nat (Nat.mul (power2 (S n)) (Nat.mul (S (S O)) (e_P1 ws s))) (Nat.mul (power2 (S n)) (Nat.mul (e_P1 ws s) (S (S O)))) *) simple induction 1; intros; simpl in |- *; auto with arith. Qed. Hint Resolve P1_id.
(* Contribution to the Coq Library V6.3 (July 1999) *) (****************************************************************************) (* The Calculus of Inductive Constructions *) (* *) (* Projet Coq *) (* *) (* INRIA ENS-CNRS *) (* Rocquencourt Lyon *) (* *) (* Coq V5.10 *) (* Nov 25th 1994 *) (* *) (****************************************************************************) (* Yokouchi.v *) (****************************************************************************) (*****************************************************************************) (* Projet Coq - Calculus of Inductive Constructions V5.8 *) (*****************************************************************************) (* *) (* Meta-theory of the explicit substitution calculus lambda-env *) (* Amokrane Saibi *) (* *) (* September 1993 *) (* *) (*****************************************************************************) (* Theoreme utilise pour la preuve de confluence du lambda-sigma-lift-calcul *) Require Import sur_les_relations. Section YokouchiS. Variable A : Set. Variable R S : A -> A -> Prop. Hypothesis C : explicit_confluence _ R. Hypothesis N : explicit_noetherian _ R. Hypothesis SC : explicit_strong_confluence _ S. Definition Rstar_S_Rstar := explicit_comp_rel _ (explicit_star _ R) (explicit_comp_rel _ S (explicit_star _ R)). Hypothesis commut1 : forall f g h : A, R f h -> S f g -> exists k : A, explicit_star _ R g k /\ Rstar_S_Rstar h k. Goal forall f g h : A, explicit_star _ R f g -> Rstar_S_Rstar g h -> Rstar_S_Rstar f h. (* Goal: forall (f g h : A) (_ : Rstar_S_Rstar f g) (_ : explicit_star A R g h), Rstar_S_Rstar f h *) intros f g h H1 H2. elim (comp_case A (explicit_star _ R) (explicit_comp_rel _ S (explicit_star _ R)) g h H2). (* Goal: forall (x : A) (_ : and (explicit_star A R f x) (explicit_comp_rel A S (explicit_star A R) x g)), Rstar_S_Rstar f h *) intros f' H3; elim H3; intros H4 H5. (* Goal: Rstar_S_Rstar f h *) red in |- *; apply comp_2rel with f'. (* Goal: explicit_star A R f'' h *) apply star_trans with g; assumption. (* Goal: S f' f'' *) (* Goal: explicit_star A R f'' h *) assumption. Save comp_l. Goal forall f g h : A, Rstar_S_Rstar f g -> explicit_star _ R g h -> Rstar_S_Rstar f h. (* Goal: forall (f g h : A) (_ : Rstar_S_Rstar f g) (_ : explicit_star A R g h), Rstar_S_Rstar f h *) intros f g h H1 H2. elim (comp_case A (explicit_star _ R) (explicit_comp_rel _ S (explicit_star _ R)) f g H1). (* Goal: forall (x : A) (_ : and (explicit_star A R f x) (explicit_comp_rel A S (explicit_star A R) x g)), Rstar_S_Rstar f h *) intros f' H3; elim H3; intros H4 H5. (* Goal: Rstar_S_Rstar f h *) elim (comp_case A S (explicit_star _ R) f' g H5). (* Goal: forall (x : A) (_ : and (S f' x) (explicit_star A R x g)), Rstar_S_Rstar f h *) intros f'' H6; elim H6; intros H7 H8. (* Goal: Rstar_S_Rstar f h *) red in |- *; apply comp_2rel with f'. (* Goal: S f' f'' *) (* Goal: explicit_star A R f'' h *) assumption. (* Goal: explicit_comp_rel A S (explicit_star A R) f' h *) apply comp_2rel with f''. (* Goal: S f' f'' *) (* Goal: explicit_star A R f'' h *) assumption. (* Goal: explicit_star A R f'' h *) apply star_trans with g; assumption. Save comp_r. Goal forall f g h : A, explicit_star _ R f h -> S f g -> exists k : A, explicit_star _ R g k /\ Rstar_S_Rstar h k. intro f; pattern f in |- *; apply (noetherian_induction A R N); intros f0 H g h H1 H2. elim (star_case A R f0 h H1); intro H3. (* cas f0=h *) exists g; split. apply star_refl. elim H3; red in |- *; apply comp_2rel with f0. apply star_refl. apply comp_2rel with g; [ assumption | apply star_refl ]. (* cas f0 R f1 R* h *) elim H3; intros f1 H4; elim H4; intros H5 H6. cut (exists k : A, explicit_star _ R g k /\ Rstar_S_Rstar f1 k). intro H7; elim H7; intros g1 H8; elim H8; intros H9 H10. (* Goal: S f' f'' *) (* Goal: explicit_star A R f'' h *) 2: apply commut1 with f0; assumption. cut (exists f2 : A, explicit_star _ R f1 f2 /\ explicit_comp_rel _ S (explicit_star _ R) f2 g1). (* Goal: S f' f'' *) (* Goal: explicit_star A R f'' h *) 2: apply comp_case; assumption. intro H11; elim H11; intros f2 H12; elim H12; intros H13 H14. cut (exists f3 : A, S f2 f3 /\ explicit_star _ R f3 g1). (* Goal: S f' f'' *) (* Goal: explicit_star A R f'' h *) 2: apply comp_case; assumption. intro H15; elim H15; intros f3 H16; elim H16; intros H17 H18. elim (C f1 h f2 H6 H13); intros h1 H19; elim H19; intros H20 H21. elim (H f2) with f3 h1. (* Goal: S f' f'' *) (* Goal: explicit_star A R f'' h *) 2: apply comp_relplus; apply comp_2rel with f1; assumption. (* Goal: S f' f'' *) (* Goal: explicit_star A R f'' h *) 2: assumption. (* Goal: S f' f'' *) (* Goal: explicit_star A R f'' h *) 2: assumption. intros h2 H22; elim H22; intros H23 H24. elim (C f3 h2 g1 H23 H18); intros k H25; elim H25; intros H26 H27. exists k; split. (* Goal: S f' f'' *) (* Goal: explicit_star A R f'' h *) apply star_trans with g1; assumption. apply comp_l with h1. (* Goal: S f' f'' *) (* Goal: explicit_star A R f'' h *) assumption. (* Goal: S f' f'' *) (* Goal: explicit_star A R f'' h *) apply comp_r with h2; assumption. Save commut2. Theorem Yokouchi : explicit_strong_confluence _ Rstar_S_Rstar. unfold explicit_strong_confluence in |- *; intro f; pattern f in |- *; apply (noetherian_induction1 A R N). intros f0 H; unfold strong_confluence_en in |- *; intros g h H1 H2. cut (exists u : A, explicit_star _ R f0 u /\ explicit_comp_rel _ S (explicit_star _ R) u h). (* Goal: S f' f'' *) (* Goal: explicit_star A R f'' h *) 2: apply comp_case; assumption. intro H3; elim H3; intros f1 H4; elim H4; intros H5 H6. cut (exists u : A, explicit_star _ R f0 u /\ explicit_comp_rel _ S (explicit_star _ R) u g). (* Goal: S f' f'' *) (* Goal: explicit_star A R f'' h *) 2: apply comp_case; assumption. intro H7; elim H7; intros g1 H8; elim H8; intros H9 H10. elim (star_case A R f0 f1 H5); intro H11. elim (star_case A R f0 g1 H9); intro H12. (* cas f0 SR* h et f0 SR* h *) generalize H6; elim H11; intro H6'. generalize H10; elim H12; intro H10'. elim (comp_case A S (explicit_star _ R) f0 h H6'); intros f2 H13. elim H13; intros H14 H15. elim (comp_case A S (explicit_star _ R) f0 g H10'); intros g2 H16. elim H16; intros H17 H18. elim (SC f0 f2 g2 H14 H17); intros k1 H19; elim H19; intros H20 H21. elim (commut2 g2 k1 g H18 H21); intros k2 H22; elim H22; intros H23 H24. elim (commut2 f2 k1 h H15 H20); intros h1 H25; elim H25; intros H26 H27. elim (C k1 h1 k2 H26 H23); intros k H28; elim H28; intros H29 H30. exists k; split. (* Goal: S f' f'' *) (* Goal: explicit_star A R f'' h *) apply comp_r with k2; assumption. (* Goal: S f' f'' *) (* Goal: explicit_star A R f'' h *) apply comp_r with h1; assumption. (* cas f0 R* g1 SR* g et f0 SR* h *) elim H12; intros g2 H13; elim H13; intros H14 H15. generalize H6; elim H11; intro H6'. elim (comp_case A S (explicit_star _ R) f0 h H6'); intros f2 H16. elim H16; intros H17 H18. elim (commut1 f0 f2 g2 H14 H17); intros k1 H19; elim H19; intros H20 H21. elim (C f2 h k1 H18 H20); intros h1 H22; elim H22; intros H23 H24. elim (H g2 H14 g h1). (* Goal: S f' f'' *) (* Goal: explicit_star A R f'' h *) 2: red in |- *; apply comp_2rel with g1; assumption. (* Goal: S f' f'' *) (* Goal: explicit_star A R f'' h *) 2: apply comp_r with k1; assumption. intros k H25; elim H25; intros H26 H27. exists k; split. (* Goal: S f' f'' *) (* Goal: explicit_star A R f'' h *) assumption. (* Goal: S f' f'' *) (* Goal: explicit_star A R f'' h *) apply comp_l with h1; assumption. (* cas f0 RR* f1 SR* h et f0 R*SR* g *) elim H11; intros f2 H12; elim H12; intros H13 H14. elim (C f0 f2 g1). 2: apply star_trans1 with f2. (* Goal: S f' f'' *) (* Goal: explicit_star A R f'' h *) 2: assumption. 2: apply star_refl. (* Goal: S f' f'' *) (* Goal: explicit_star A R f'' h *) 2: assumption. intros k1 H15; elim H15; intros H16 H17. elim (comp_case A S (explicit_star _ R) g1 g H10); intros g2 H18. elim H18; intros H19 H20. elim (commut2 g1 g2 k1 H17 H19); intros k2 H21; elim H21; intros H22 H23. elim (C g2 k2 g H22 H20); intros k3 H24; elim H24; intros H25 H26. elim (H f2 H13 h k3). (* Goal: S f' f'' *) (* Goal: explicit_star A R f'' h *) 2: red in |- *; apply comp_2rel with f1; assumption. 2: apply comp_l with k1. (* Goal: S f' f'' *) (* Goal: explicit_star A R f'' h *) 2: assumption. (* Goal: S f' f'' *) (* Goal: explicit_star A R f'' h *) 2: apply comp_r with k2; assumption. intros k H27; elim H27; intros H28 H29. exists k; split. (* Goal: S f' f'' *) (* Goal: explicit_star A R f'' h *) apply comp_l with k3; assumption. (* Goal: S f' f'' *) (* Goal: explicit_star A R f'' h *) assumption. Qed. End YokouchiS.
(* Contribution to the Coq Library V6.3 (July 1999) *) (****************************************************************************) (* The Calculus of Inductive Constructions *) (* *) (* Projet Coq *) (* *) (* INRIA ENS-CNRS *) (* Rocquencourt Lyon *) (* *) (* Coq V5.10 *) (* Nov 25th 1994 *) (* *) (****************************************************************************) (* Pol2.v *) (****************************************************************************) (*****************************************************************************) (* Projet Coq - Calculus of Inductive Constructions V5.8 *) (*****************************************************************************) (* *) (* Meta-theory of the explicit substitution calculus lambda-env *) (* Amokrane Saibi *) (* *) (* September 1993 *) (* *) (*****************************************************************************) (* Preuve de terminaison: polynome P2 *) Require Import Le. Require Import Lt. Require Import Plus. Require Import Gt. Require Import Minus. Require Import Mult. Require Import TS. Require Import sigma_lift. Require Import comparith. Definition e_P2 (b : wsort) (U : TS b) : nat := (fix F (w : wsort) (t : TS w) {struct t} : nat := match t with | var _ => 1 | app t0 t1 => S (F wt t0 + F wt t1) | lambda t0 => 2 * F wt t0 | env t0 t1 => F wt t0 * S (F ws t1) | id => 1 | shift => 1 | cons t0 t1 => S (F wt t0 + F ws t1) | comp t0 t1 => F ws t0 * S (F ws t1) | lift t0 => 4 * F ws t0 | meta_X _ => 1 | meta_x _ => 1 end) b U. (* var *) (* app *) (* lam *) (* env *) (* id *) (* | *) (* . *) (* o *) (* || *) (* X *) (* x *) Notation P2 := (e_P2 _) (only parsing). (* <Warning> : Syntax is discontinued *) Theorem P2_pos : forall (b : wsort) (M : TS b), e_P2 _ M > 0. Proof. (* Goal: forall (b : wsort) (M : TS b), gt (e_P2 b M) O *) simple induction M; simpl in |- *; intros; auto with arith. Qed. Hint Resolve P2_pos. Theorem P2_app : forall M N : terms, reg_app M N -> e_P2 _ M > e_P2 _ N. Proof. simple induction 1; intros; simpl in |- *; elim Mult.mult_plus_distr_r; (* Goal: gt (e_P2 wt a) O *) (* Goal: gt (Nat.mul (Nat.mul (S (S (S (S O)))) (e_P2 ws s)) (Nat.add (e_P2 ws t) (S (S O)))) (PeanoNat.Nat.add (Nat.mul (e_P2 ws s) (S (e_P2 ws t))) (S O)) *) (* Goal: @eq nat (S (S (Nat.add (e_P2 wt a) (e_P2 ws t)))) (Nat.add (e_P2 wt a) (Nat.add (e_P2 ws t) (S (S O)))) *) auto with arith. Qed. Hint Resolve P2_app. Theorem P2_lambda : forall M N : terms, reg_lambda M N -> e_P2 _ M < e_P2 _ N. Proof. (* Goal: forall (M N : sub_explicits) (_ : reg_liftenv M N), gt (e_P2 ws M) (e_P2 ws N) *) simple induction 1; intros. change (2 * (e_P2 _ a * S (4 * e_P2 _ s)) > 2 * e_P2 _ a * S (e_P2 _ s)) in |- *. (* Goal: gt (Nat.mul (Nat.mul (S (S (S (S O)))) (e_P2 ws s)) (S (Nat.mul (S (S (S (S O)))) (e_P2 ws t)))) (Nat.mul (S (S (S (S O)))) (Nat.mul (e_P2 ws s) (S (e_P2 ws t)))) *) elim mult_assoc_reverse; auto with arith. Qed. Hint Resolve P2_lambda. Theorem P2_clos : forall M N : terms, reg_clos M N -> e_P2 _ M > e_P2 _ N. Proof. (* Goal: forall (M N : sub_explicits) (_ : reg_assenv M N), gt (e_P2 ws M) (e_P2 ws N) *) simple induction 1; intros; simpl in |- *. (* Goal: gt (Nat.mul (Nat.mul (e_P2 wt a) (S (e_P2 ws s))) (S (e_P2 ws t))) (Nat.mul (e_P2 wt a) (S (Nat.mul (e_P2 ws s) (S (e_P2 ws t))))) *) elim mult_assoc_l; apply gt_mult_reg_l. (* Goal: gt (e_P2 wt a) O *) (* Goal: gt (Nat.mul (Nat.mul (S (S (S (S O)))) (e_P2 ws s)) (Nat.add (e_P2 ws t) (S (S O)))) (PeanoNat.Nat.add (Nat.mul (e_P2 ws s) (S (e_P2 ws t))) (S O)) *) (* Goal: @eq nat (S (S (Nat.add (e_P2 wt a) (e_P2 ws t)))) (Nat.add (e_P2 wt a) (Nat.add (e_P2 ws t) (S (S O)))) *) auto with arith. (* Goal: gt (e_P2 wt a) O *) (* Goal: gt (Nat.mul (Nat.mul (S (S (S (S O)))) (e_P2 ws s)) (Nat.add (e_P2 ws t) (S (S O)))) (PeanoNat.Nat.add (Nat.mul (e_P2 ws s) (S (e_P2 ws t))) (S O)) *) (* Goal: @eq nat (S (S (Nat.add (e_P2 wt a) (e_P2 ws t)))) (Nat.add (e_P2 wt a) (Nat.add (e_P2 ws t) (S (S O)))) *) simpl in |- *; auto with arith. Qed. Hint Resolve P2_clos. Theorem P2_varshift1 : forall M N : terms, reg_varshift1 M N -> e_P2 _ M > e_P2 _ N. Proof. (* Goal: gt (e_P2 wt a) O *) (* Goal: gt (Nat.mul (Nat.mul (S (S (S (S O)))) (e_P2 ws s)) (Nat.add (e_P2 ws t) (S (S O)))) (PeanoNat.Nat.add (Nat.mul (e_P2 ws s) (S (e_P2 ws t))) (S O)) *) (* Goal: @eq nat (S (S (Nat.add (e_P2 wt a) (e_P2 ws t)))) (Nat.add (e_P2 wt a) (Nat.add (e_P2 ws t) (S (S O)))) *) simple induction 1; simpl in |- *; auto with arith. Qed. Hint Resolve P2_varshift1. Theorem P2_varshift2 : forall M N : terms, reg_varshift2 M N -> e_P2 _ M > e_P2 _ N. Proof. simple induction 1; intros; simpl in |- *; repeat elim plus_n_O; (* Goal: gt (e_P2 wt a) O *) (* Goal: gt (Nat.mul (Nat.mul (S (S (S (S O)))) (e_P2 ws s)) (Nat.add (e_P2 ws t) (S (S O)))) (PeanoNat.Nat.add (Nat.mul (e_P2 ws s) (S (e_P2 ws t))) (S O)) *) (* Goal: @eq nat (S (S (Nat.add (e_P2 wt a) (e_P2 ws t)))) (Nat.add (e_P2 wt a) (Nat.add (e_P2 ws t) (S (S O)))) *) auto with arith. Qed. Hint Resolve P2_varshift2. Theorem P2_fvarcons : forall M N : terms, reg_fvarcons M N -> e_P2 _ M > e_P2 _ N. Proof. (* Goal: gt (e_P2 wt a) O *) (* Goal: gt (Nat.mul (Nat.mul (S (S (S (S O)))) (e_P2 ws s)) (Nat.add (e_P2 ws t) (S (S O)))) (PeanoNat.Nat.add (Nat.mul (e_P2 ws s) (S (e_P2 ws t))) (S O)) *) (* Goal: @eq nat (S (S (Nat.add (e_P2 wt a) (e_P2 ws t)))) (Nat.add (e_P2 wt a) (Nat.add (e_P2 ws t) (S (S O)))) *) simple induction 1; intros; simpl in |- *; elim plus_n_O; auto with arith. Qed. Hint Resolve P2_fvarcons. Theorem P2_fvarlift1 : forall M N : terms, reg_fvarlift1 M N -> e_P2 _ M > e_P2 _ N. Proof. (* Goal: forall (M N : sub_explicits) (_ : reg_liftenv M N), gt (e_P2 ws M) (e_P2 ws N) *) simple induction 1; intros. (* Goal: gt (e_P2 wt (env (var O) (lift s))) (e_P2 wt (var O)) *) change (1 * S (4 * e_P2 _ s) > 1) in |- *. (* Goal: gt (e_P2 wt a) O *) (* Goal: gt (Nat.mul (Nat.mul (S (S (S (S O)))) (e_P2 ws s)) (Nat.add (e_P2 ws t) (S (S O)))) (PeanoNat.Nat.add (Nat.mul (e_P2 ws s) (S (e_P2 ws t))) (S O)) *) (* Goal: @eq nat (S (S (Nat.add (e_P2 wt a) (e_P2 ws t)))) (Nat.add (e_P2 wt a) (Nat.add (e_P2 ws t) (S (S O)))) *) auto with arith. Qed. Hint Resolve P2_fvarlift1. Theorem P2_fvarlift2 : forall M N : terms, reg_fvarlift2 M N -> e_P2 _ M > e_P2 _ N. Proof. simple induction 1; intros; simpl in |- *; repeat elim plus_n_O; (* Goal: gt (e_P2 wt a) O *) (* Goal: gt (Nat.mul (Nat.mul (S (S (S (S O)))) (e_P2 ws s)) (Nat.add (e_P2 ws t) (S (S O)))) (PeanoNat.Nat.add (Nat.mul (e_P2 ws s) (S (e_P2 ws t))) (S O)) *) (* Goal: @eq nat (S (S (Nat.add (e_P2 wt a) (e_P2 ws t)))) (Nat.add (e_P2 wt a) (Nat.add (e_P2 ws t) (S (S O)))) *) auto with arith. Qed. Hint Resolve P2_fvarlift2. Theorem P2_rvarcons : forall M N : terms, reg_rvarcons M N -> e_P2 _ M > e_P2 _ N. Proof. simple induction 1; intros; simpl in |- *; repeat elim plus_n_O; (* Goal: gt (e_P2 wt a) O *) (* Goal: gt (Nat.mul (Nat.mul (S (S (S (S O)))) (e_P2 ws s)) (Nat.add (e_P2 ws t) (S (S O)))) (PeanoNat.Nat.add (Nat.mul (e_P2 ws s) (S (e_P2 ws t))) (S O)) *) (* Goal: @eq nat (S (S (Nat.add (e_P2 wt a) (e_P2 ws t)))) (Nat.add (e_P2 wt a) (Nat.add (e_P2 ws t) (S (S O)))) *) auto with arith. Qed. Hint Resolve P2_rvarcons. Theorem P2_rvarlift1 : forall M N : terms, reg_rvarlift1 M N -> e_P2 _ M > e_P2 _ N. Proof. (* Goal: forall (M N : terms) (_ : reg_rvarlift1 M N), gt (e_P2 wt M) (e_P2 wt N) *) simple induction 1; intros; simpl in |- *; repeat elim plus_n_O. (* Goal: gt (e_P2 wt a) O *) (* Goal: gt (Nat.mul (Nat.mul (S (S (S (S O)))) (e_P2 ws s)) (Nat.add (e_P2 ws t) (S (S O)))) (PeanoNat.Nat.add (Nat.mul (e_P2 ws s) (S (e_P2 ws t))) (S O)) *) (* Goal: @eq nat (S (S (Nat.add (e_P2 wt a) (e_P2 ws t)))) (Nat.add (e_P2 wt a) (Nat.add (e_P2 ws t) (S (S O)))) *) elim mult_n_2; auto with arith. Qed. Hint Resolve P2_rvarlift1. Theorem P2_rvarlift2 : forall M N : terms, reg_rvarlift2 M N -> e_P2 _ M > e_P2 _ N. Proof. (* Goal: forall (M N : sub_explicits) (_ : reg_liftenv M N), gt (e_P2 ws M) (e_P2 ws N) *) simple induction 1; intros. change (1 * S (4 * e_P2 _ s * S (e_P2 _ t)) > 1 * S (e_P2 _ s * S (1 * S (e_P2 _ t)))) in |- *. unfold mult at 1 in |- *; unfold mult at 3 in |- *; unfold mult at 4 in |- *; repeat elim plus_n_O. (* Goal: gt (S (Nat.mul (Nat.mul (S (S (S (S O)))) (e_P2 ws s)) (S (e_P2 ws t)))) (S (Nat.mul (e_P2 ws s) (S (S (e_P2 ws t))))) *) apply gt_n_S; repeat elim mult_n_Sm; elim plus_assoc. (* Goal: gt (Nat.add (Nat.mul (Nat.mul (S (S (S (S O)))) (e_P2 ws s)) (e_P2 ws t)) (Nat.mul (S (S (S (S O)))) (e_P2 ws s))) (PeanoNat.Nat.add (Nat.mul (e_P2 ws s) (e_P2 ws t)) (PeanoNat.Nat.add (e_P2 ws s) (e_P2 ws s))) *) apply gt_plus_plus. (* Goal: gt (e_P2 wt a) O *) (* Goal: gt (Nat.mul (Nat.mul (S (S (S (S O)))) (e_P2 ws s)) (Nat.add (e_P2 ws t) (S (S O)))) (PeanoNat.Nat.add (Nat.mul (e_P2 ws s) (S (e_P2 ws t))) (S O)) *) (* Goal: @eq nat (S (S (Nat.add (e_P2 wt a) (e_P2 ws t)))) (Nat.add (e_P2 wt a) (Nat.add (e_P2 ws t) (S (S O)))) *) elim mult_assoc_l; auto with arith. (* Goal: gt (e_P2 wt a) O *) (* Goal: gt (Nat.mul (Nat.mul (S (S (S (S O)))) (e_P2 ws s)) (Nat.add (e_P2 ws t) (S (S O)))) (PeanoNat.Nat.add (Nat.mul (e_P2 ws s) (S (e_P2 ws t))) (S O)) *) (* Goal: @eq nat (S (S (Nat.add (e_P2 wt a) (e_P2 ws t)))) (Nat.add (e_P2 wt a) (Nat.add (e_P2 ws t) (S (S O)))) *) elim mult_n_2; elim mult_sym; auto with arith. Qed. Hint Resolve P2_rvarlift2. Theorem P2_assenv : forall M N : sub_explicits, reg_assenv M N -> e_P2 _ M > e_P2 _ N. Proof. (* Goal: forall (M N : sub_explicits) (_ : reg_assenv M N), gt (e_P2 ws M) (e_P2 ws N) *) simple induction 1; intros; simpl in |- *. (* Goal: gt (e_P2 wt a) O *) (* Goal: gt (Nat.mul (Nat.mul (S (S (S (S O)))) (e_P2 ws s)) (Nat.add (e_P2 ws t) (S (S O)))) (PeanoNat.Nat.add (Nat.mul (e_P2 ws s) (S (e_P2 ws t))) (S O)) *) (* Goal: @eq nat (S (S (Nat.add (e_P2 wt a) (e_P2 ws t)))) (Nat.add (e_P2 wt a) (Nat.add (e_P2 ws t) (S (S O)))) *) rewrite mult_assoc_reverse; simpl in |- *; auto with arith. Qed. Hint Resolve P2_assenv. Theorem P2_mapenv : forall M N : sub_explicits, reg_mapenv M N -> e_P2 _ M > e_P2 _ N. Proof. simple induction 1; intros; simpl in |- *; elim Mult.mult_plus_distr_r; (* Goal: gt (e_P2 wt a) O *) (* Goal: gt (Nat.mul (Nat.mul (S (S (S (S O)))) (e_P2 ws s)) (Nat.add (e_P2 ws t) (S (S O)))) (PeanoNat.Nat.add (Nat.mul (e_P2 ws s) (S (e_P2 ws t))) (S O)) *) (* Goal: @eq nat (S (S (Nat.add (e_P2 wt a) (e_P2 ws t)))) (Nat.add (e_P2 wt a) (Nat.add (e_P2 ws t) (S (S O)))) *) auto with arith. Qed. Hint Resolve P2_mapenv. Theorem P2_shiftcons : forall M N : sub_explicits, reg_shiftcons M N -> e_P2 _ M > e_P2 _ N. Proof. (* Goal: gt (e_P2 wt a) O *) (* Goal: gt (Nat.mul (Nat.mul (S (S (S (S O)))) (e_P2 ws s)) (Nat.add (e_P2 ws t) (S (S O)))) (PeanoNat.Nat.add (Nat.mul (e_P2 ws s) (S (e_P2 ws t))) (S O)) *) (* Goal: @eq nat (S (S (Nat.add (e_P2 wt a) (e_P2 ws t)))) (Nat.add (e_P2 wt a) (Nat.add (e_P2 ws t) (S (S O)))) *) simple induction 1; intros; simpl in |- *; elim plus_n_O; auto with arith. Qed. Hint Resolve P2_shiftcons. Theorem P2_shiftlift1 : forall M N : sub_explicits, reg_shiftlift1 M N -> e_P2 _ M > e_P2 _ N. Proof. (* Goal: forall (M N : sub_explicits) (_ : reg_liftenv M N), gt (e_P2 ws M) (e_P2 ws N) *) simple induction 1; intros. (* Goal: gt (e_P2 ws (comp shift (lift s))) (e_P2 ws (comp s shift)) *) change (1 * S (4 * e_P2 _ s) > e_P2 _ s * 2) in |- *. (* Goal: gt (Nat.mul (S O) (S (Nat.mul (S (S (S (S O)))) (e_P2 ws s)))) (Nat.mul (e_P2 ws s) (S (S O))) *) unfold mult at 1 in |- *; elim plus_n_O. (* Goal: gt (e_P2 wt a) O *) (* Goal: gt (Nat.mul (Nat.mul (S (S (S (S O)))) (e_P2 ws s)) (Nat.add (e_P2 ws t) (S (S O)))) (PeanoNat.Nat.add (Nat.mul (e_P2 ws s) (S (e_P2 ws t))) (S O)) *) (* Goal: @eq nat (S (S (Nat.add (e_P2 wt a) (e_P2 ws t)))) (Nat.add (e_P2 wt a) (Nat.add (e_P2 ws t) (S (S O)))) *) apply gt_S_l; elim mult_sym; auto with arith. Qed. Hint Resolve P2_shiftlift1. Theorem P2_shiftlift2 : forall M N : sub_explicits, reg_shiftlift2 M N -> e_P2 _ M > e_P2 _ N. Proof. (* Goal: forall (M N : sub_explicits) (_ : reg_liftenv M N), gt (e_P2 ws M) (e_P2 ws N) *) simple induction 1; intros. change (1 * S (4 * e_P2 _ s * S (e_P2 _ t)) > e_P2 _ s * S (1 * S (e_P2 _ t))) in |- *. unfold mult at 1 in |- *; elim plus_n_O; unfold mult at 4 in |- *; elim plus_n_O. (* Goal: gt (S (Nat.mul (Nat.mul (S (S (S (S O)))) (e_P2 ws s)) (S (e_P2 ws t)))) (Nat.mul (e_P2 ws s) (S (S (e_P2 ws t)))) *) apply gt_S_l; repeat elim mult_n_Sm; elim plus_assoc. (* Goal: gt (Nat.add (Nat.mul (Nat.mul (S (S (S (S O)))) (e_P2 ws s)) (e_P2 ws t)) (Nat.mul (S (S (S (S O)))) (e_P2 ws s))) (PeanoNat.Nat.add (Nat.mul (e_P2 ws s) (e_P2 ws t)) (PeanoNat.Nat.add (e_P2 ws s) (e_P2 ws s))) *) apply gt_plus_plus. (* Goal: gt (e_P2 wt a) O *) (* Goal: gt (Nat.mul (Nat.mul (S (S (S (S O)))) (e_P2 ws s)) (Nat.add (e_P2 ws t) (S (S O)))) (PeanoNat.Nat.add (Nat.mul (e_P2 ws s) (S (e_P2 ws t))) (S O)) *) (* Goal: @eq nat (S (S (Nat.add (e_P2 wt a) (e_P2 ws t)))) (Nat.add (e_P2 wt a) (Nat.add (e_P2 ws t) (S (S O)))) *) elim mult_assoc_l; auto with arith. (* Goal: gt (e_P2 wt a) O *) (* Goal: gt (Nat.mul (Nat.mul (S (S (S (S O)))) (e_P2 ws s)) (Nat.add (e_P2 ws t) (S (S O)))) (PeanoNat.Nat.add (Nat.mul (e_P2 ws s) (S (e_P2 ws t))) (S O)) *) (* Goal: @eq nat (S (S (Nat.add (e_P2 wt a) (e_P2 ws t)))) (Nat.add (e_P2 wt a) (Nat.add (e_P2 ws t) (S (S O)))) *) elim mult_n_2; elim mult_sym; auto with arith. Qed. Hint Resolve P2_shiftlift2. Theorem P2_lift1 : forall M N : sub_explicits, reg_lift1 M N -> e_P2 _ M > e_P2 _ N. Proof. (* Goal: forall (M N : sub_explicits) (_ : reg_liftenv M N), gt (e_P2 ws M) (e_P2 ws N) *) simple induction 1; intros. change (4 * e_P2 _ s * S (4 * e_P2 _ t) > 4 * (e_P2 _ s * S (e_P2 _ t))) in |- *. (* Goal: gt (Nat.mul (Nat.mul (S (S (S (S O)))) (e_P2 ws s)) (S (Nat.mul (S (S (S (S O)))) (e_P2 ws t)))) (Nat.mul (S (S (S (S O)))) (Nat.mul (e_P2 ws s) (S (e_P2 ws t)))) *) elim mult_assoc_reverse; auto with arith. Qed. Hint Resolve P2_lift1. Theorem P2_lift2 : forall M N : sub_explicits, reg_lift2 M N -> e_P2 _ M > e_P2 _ N. Proof. (* Goal: forall (M N : sub_explicits) (_ : reg_liftenv M N), gt (e_P2 ws M) (e_P2 ws N) *) simple induction 1; intros. change (4 * e_P2 _ s * S (4 * e_P2 _ t * S (e_P2 _ u)) > 4 * (e_P2 _ s * S (e_P2 _ t)) * S (e_P2 _ u)) in |- *. elim mult_assoc_reverse; elim (mult_assoc_l (4 * e_P2 _ s) (S (e_P2 _ t)) (S (e_P2 _ u))); apply gt_mult_reg_l. (* Goal: gt (e_P2 wt a) O *) (* Goal: gt (Nat.mul (Nat.mul (S (S (S (S O)))) (e_P2 ws s)) (Nat.add (e_P2 ws t) (S (S O)))) (PeanoNat.Nat.add (Nat.mul (e_P2 ws s) (S (e_P2 ws t))) (S O)) *) (* Goal: @eq nat (S (S (Nat.add (e_P2 wt a) (e_P2 ws t)))) (Nat.add (e_P2 wt a) (Nat.add (e_P2 ws t) (S (S O)))) *) auto with arith. (* Goal: gt (S (Nat.mul (Nat.mul (S (S (S (S O)))) (e_P2 ws t)) (S (e_P2 ws u)))) (Nat.mul (S (e_P2 ws t)) (S (e_P2 ws u))) *) apply gt_S_l; apply gt_mult_reg_r. (* Goal: gt (e_P2 wt a) O *) (* Goal: gt (Nat.mul (Nat.mul (S (S (S (S O)))) (e_P2 ws s)) (Nat.add (e_P2 ws t) (S (S O)))) (PeanoNat.Nat.add (Nat.mul (e_P2 ws s) (S (e_P2 ws t))) (S O)) *) (* Goal: @eq nat (S (S (Nat.add (e_P2 wt a) (e_P2 ws t)))) (Nat.add (e_P2 wt a) (Nat.add (e_P2 ws t) (S (S O)))) *) auto with arith. (* Goal: gt (Nat.mul (S (S (S (S O)))) (e_P2 ws t)) (S (e_P2 ws t)) *) apply gt_trans with (3 * e_P2 _ t). (* Goal: gt (e_P2 wt a) O *) (* Goal: gt (Nat.mul (Nat.mul (S (S (S (S O)))) (e_P2 ws s)) (Nat.add (e_P2 ws t) (S (S O)))) (PeanoNat.Nat.add (Nat.mul (e_P2 ws s) (S (e_P2 ws t))) (S O)) *) (* Goal: @eq nat (S (S (Nat.add (e_P2 wt a) (e_P2 ws t)))) (Nat.add (e_P2 wt a) (Nat.add (e_P2 ws t) (S (S O)))) *) auto with arith. (* Goal: gt (Nat.mul (S (S (S O))) (e_P2 ws t)) (S (e_P2 ws t)) *) simpl in |- *; elim plus_n_O; rewrite S_plus; apply plus_gt_compat_l. (* Goal: gt (e_P2 wt a) O *) (* Goal: gt (Nat.mul (Nat.mul (S (S (S (S O)))) (e_P2 ws s)) (Nat.add (e_P2 ws t) (S (S O)))) (PeanoNat.Nat.add (Nat.mul (e_P2 ws s) (S (e_P2 ws t))) (S O)) *) (* Goal: @eq nat (S (S (Nat.add (e_P2 wt a) (e_P2 ws t)))) (Nat.add (e_P2 wt a) (Nat.add (e_P2 ws t) (S (S O)))) *) elim mult_n_2; auto with arith. Qed. Hint Resolve P2_lift2. Theorem P2_liftenv : forall M N : sub_explicits, reg_liftenv M N -> e_P2 _ M > e_P2 _ N. Proof. (* Goal: forall (M N : sub_explicits) (_ : reg_liftenv M N), gt (e_P2 ws M) (e_P2 ws N) *) simple induction 1; intros. change (4 * e_P2 _ s * S (S (e_P2 _ a + e_P2 _ t)) > S (e_P2 _ a + e_P2 _ s * S (e_P2 _ t))) in |- *. (* Goal: gt (Nat.mul (Nat.mul (S (S (S (S O)))) (e_P2 ws s)) (S (S (Nat.add (e_P2 wt a) (e_P2 ws t))))) (S (Nat.add (e_P2 wt a) (Nat.mul (e_P2 ws s) (S (e_P2 ws t))))) *) cut (S (S (e_P2 _ a + e_P2 _ t)) = e_P2 _ a + (e_P2 _ t + 2)). (* Goal: forall _ : @eq nat (S (S (Nat.add (e_P2 wt a) (e_P2 ws t)))) (Nat.add (e_P2 wt a) (Nat.add (e_P2 ws t) (S (S O)))), gt (Nat.mul (Nat.mul (S (S (S (S O)))) (e_P2 ws s)) (S (S (Nat.add (e_P2 wt a) (e_P2 ws t))))) (S (Nat.add (e_P2 wt a) (Nat.mul (e_P2 ws s) (S (e_P2 ws t))))) *) (* Goal: @eq nat (S (S (Nat.add (e_P2 wt a) (e_P2 ws t)))) (Nat.add (e_P2 wt a) (Nat.add (e_P2 ws t) (S (S O)))) *) intro H1; rewrite H1. rewrite (S_plus (e_P2 _ a + e_P2 _ s * S (e_P2 _ t))); rewrite comparith.mult_plus_distr_r. (* Goal: gt (Nat.add (Nat.mul (Nat.mul (S (S (S (S O)))) (e_P2 ws s)) (e_P2 ws t)) (Nat.mul (S (S (S (S O)))) (e_P2 ws s))) (PeanoNat.Nat.add (Nat.mul (e_P2 ws s) (e_P2 ws t)) (PeanoNat.Nat.add (e_P2 ws s) (e_P2 ws s))) *) elim plus_assoc; apply gt_plus_plus. (* Goal: gt (Nat.mul (Nat.mul (S (S (S (S O)))) (e_P2 ws s)) (e_P2 wt a)) (e_P2 wt a) *) (* Goal: gt (Nat.mul (Nat.mul (S (S (S (S O)))) (e_P2 ws s)) (Nat.add (e_P2 ws t) (S (S O)))) (PeanoNat.Nat.add (Nat.mul (e_P2 ws s) (S (e_P2 ws t))) (S O)) *) (* Goal: @eq nat (S (S (Nat.add (e_P2 wt a) (e_P2 ws t)))) (Nat.add (e_P2 wt a) (Nat.add (e_P2 ws t) (S (S O)))) *) apply gt_mult_l. (* Goal: gt (e_P2 wt a) O *) (* Goal: gt (Nat.mul (Nat.mul (S (S (S (S O)))) (e_P2 ws s)) (Nat.add (e_P2 ws t) (S (S O)))) (PeanoNat.Nat.add (Nat.mul (e_P2 ws s) (S (e_P2 ws t))) (S O)) *) (* Goal: @eq nat (S (S (Nat.add (e_P2 wt a) (e_P2 ws t)))) (Nat.add (e_P2 wt a) (Nat.add (e_P2 ws t) (S (S O)))) *) auto with arith. (* Goal: gt (e_P2 wt a) O *) (* Goal: gt (Nat.mul (Nat.mul (S (S (S (S O)))) (e_P2 ws s)) (Nat.add (e_P2 ws t) (S (S O)))) (PeanoNat.Nat.add (Nat.mul (e_P2 ws s) (S (e_P2 ws t))) (S O)) *) (* Goal: @eq nat (S (S (Nat.add (e_P2 wt a) (e_P2 ws t)))) (Nat.add (e_P2 wt a) (Nat.add (e_P2 ws t) (S (S O)))) *) auto with arith. (* Goal: gt (Nat.mul (Nat.mul (S (S (S (S O)))) (e_P2 ws s)) (Nat.add (e_P2 ws t) (S (S O)))) (PeanoNat.Nat.add (Nat.mul (e_P2 ws s) (S (e_P2 ws t))) (S O)) *) (* Goal: @eq nat (S (S (Nat.add (e_P2 wt a) (e_P2 ws t)))) (Nat.add (e_P2 wt a) (Nat.add (e_P2 ws t) (S (S O)))) *) replace (e_P2 _ t + 2) with (e_P2 _ t + 1 + 1). (* Goal: gt (Nat.add (Nat.mul (Nat.mul (S (S (S (S O)))) (e_P2 ws s)) (e_P2 ws t)) (Nat.mul (S (S (S (S O)))) (e_P2 ws s))) (PeanoNat.Nat.add (Nat.mul (e_P2 ws s) (e_P2 ws t)) (PeanoNat.Nat.add (e_P2 ws s) (e_P2 ws s))) *) rewrite comparith.mult_plus_distr_r; apply gt_plus_plus. (* Goal: gt (Nat.mul (Nat.mul (S (S (S (S O)))) (e_P2 ws s)) (Nat.add (e_P2 ws t) (S O))) (Nat.mul (e_P2 ws s) (S (e_P2 ws t))) *) (* Goal: gt (Nat.mul (Nat.mul (S (S (S (S O)))) (e_P2 ws s)) (S O)) (S O) *) (* Goal: @eq nat (Nat.add (Nat.add (e_P2 ws t) (S O)) (S O)) (Nat.add (e_P2 ws t) (S (S O))) *) (* Goal: @eq nat (S (S (Nat.add (e_P2 wt a) (e_P2 ws t)))) (Nat.add (e_P2 wt a) (Nat.add (e_P2 ws t) (S (S O)))) *) elim S_plus; elim mult_assoc_l. (* Goal: gt (e_P2 wt a) O *) (* Goal: gt (Nat.mul (Nat.mul (S (S (S (S O)))) (e_P2 ws s)) (Nat.add (e_P2 ws t) (S (S O)))) (PeanoNat.Nat.add (Nat.mul (e_P2 ws s) (S (e_P2 ws t))) (S O)) *) (* Goal: @eq nat (S (S (Nat.add (e_P2 wt a) (e_P2 ws t)))) (Nat.add (e_P2 wt a) (Nat.add (e_P2 ws t) (S (S O)))) *) apply gt_mult_l; auto with arith. (* Goal: gt (e_P2 wt a) O *) (* Goal: gt (Nat.mul (Nat.mul (S (S (S (S O)))) (e_P2 ws s)) (Nat.add (e_P2 ws t) (S (S O)))) (PeanoNat.Nat.add (Nat.mul (e_P2 ws s) (S (e_P2 ws t))) (S O)) *) (* Goal: @eq nat (S (S (Nat.add (e_P2 wt a) (e_P2 ws t)))) (Nat.add (e_P2 wt a) (Nat.add (e_P2 ws t) (S (S O)))) *) apply gt_mult_l; auto with arith. (* Goal: gt (e_P2 wt a) O *) (* Goal: gt (Nat.mul (Nat.mul (S (S (S (S O)))) (e_P2 ws s)) (Nat.add (e_P2 ws t) (S (S O)))) (PeanoNat.Nat.add (Nat.mul (e_P2 ws s) (S (e_P2 ws t))) (S O)) *) (* Goal: @eq nat (S (S (Nat.add (e_P2 wt a) (e_P2 ws t)))) (Nat.add (e_P2 wt a) (Nat.add (e_P2 ws t) (S (S O)))) *) elim (plus_n_Sm (e_P2 _ t) 1); auto with arith. rewrite plus_assoc; elim plus_n_Sm; elim plus_n_Sm; elim plus_n_O; (* Goal: gt (e_P2 wt a) O *) (* Goal: gt (Nat.mul (Nat.mul (S (S (S (S O)))) (e_P2 ws s)) (Nat.add (e_P2 ws t) (S (S O)))) (PeanoNat.Nat.add (Nat.mul (e_P2 ws s) (S (e_P2 ws t))) (S O)) *) (* Goal: @eq nat (S (S (Nat.add (e_P2 wt a) (e_P2 ws t)))) (Nat.add (e_P2 wt a) (Nat.add (e_P2 ws t) (S (S O)))) *) auto with arith. Qed. Hint Resolve P2_liftenv. Theorem P2_idl : forall M N : sub_explicits, reg_idl M N -> e_P2 _ M > e_P2 _ N. Proof. (* Goal: gt (e_P2 wt a) O *) (* Goal: gt (Nat.mul (Nat.mul (S (S (S (S O)))) (e_P2 ws s)) (Nat.add (e_P2 ws t) (S (S O)))) (PeanoNat.Nat.add (Nat.mul (e_P2 ws s) (S (e_P2 ws t))) (S O)) *) (* Goal: @eq nat (S (S (Nat.add (e_P2 wt a) (e_P2 ws t)))) (Nat.add (e_P2 wt a) (Nat.add (e_P2 ws t) (S (S O)))) *) simple induction 1; simpl in |- *; intros; elim plus_n_O; auto with arith. Qed. Hint Resolve P2_idl. Theorem P2_idr : forall M N : sub_explicits, reg_idr M N -> e_P2 _ M > e_P2 _ N. Proof. (* Goal: gt (e_P2 wt a) O *) (* Goal: gt (Nat.mul (Nat.mul (S (S (S (S O)))) (e_P2 ws s)) (Nat.add (e_P2 ws t) (S (S O)))) (PeanoNat.Nat.add (Nat.mul (e_P2 ws s) (S (e_P2 ws t))) (S O)) *) (* Goal: @eq nat (S (S (Nat.add (e_P2 wt a) (e_P2 ws t)))) (Nat.add (e_P2 wt a) (Nat.add (e_P2 ws t) (S (S O)))) *) simple induction 1; intros; simpl in |- *; auto with arith. Qed. Hint Resolve P2_idr. Theorem P2_liftid : forall M N : sub_explicits, reg_liftid M N -> e_P2 _ M > e_P2 _ N. Proof. (* Goal: gt (e_P2 wt a) O *) (* Goal: gt (Nat.mul (Nat.mul (S (S (S (S O)))) (e_P2 ws s)) (Nat.add (e_P2 ws t) (S (S O)))) (PeanoNat.Nat.add (Nat.mul (e_P2 ws s) (S (e_P2 ws t))) (S O)) *) (* Goal: @eq nat (S (S (Nat.add (e_P2 wt a) (e_P2 ws t)))) (Nat.add (e_P2 wt a) (Nat.add (e_P2 ws t) (S (S O)))) *) simple induction 1; intros; simpl in |- *; auto with arith. Qed. Hint Resolve P2_liftid. Theorem P2_id : forall M N : terms, reg_id M N -> e_P2 _ M > e_P2 _ N. Proof. (* Goal: gt (e_P2 wt a) O *) (* Goal: gt (Nat.mul (Nat.mul (S (S (S (S O)))) (e_P2 ws s)) (Nat.add (e_P2 ws t) (S (S O)))) (PeanoNat.Nat.add (Nat.mul (e_P2 ws s) (S (e_P2 ws t))) (S O)) *) (* Goal: @eq nat (S (S (Nat.add (e_P2 wt a) (e_P2 ws t)))) (Nat.add (e_P2 wt a) (Nat.add (e_P2 ws t) (S (S O)))) *) simple induction 1; intros; simpl in |- *; auto with arith. Qed. Hint Resolve P2_id.
(* Contribution to the Coq Library V6.3 (July 1999) *) (****************************************************************************) (* The Calculus of Inductive Constructions *) (* *) (* Projet Coq *) (* *) (* INRIA ENS-CNRS *) (* Rocquencourt Lyon *) (* *) (* Coq V5.10 *) (* Nov 25th 1994 *) (* *) (****************************************************************************) (* SLstar_bpar_SLstar.v *) (****************************************************************************) (*****************************************************************************) (* Projet Coq - Calculus of Inductive Constructions V5.8 *) (*****************************************************************************) (* *) (* Meta-theory of the explicit substitution calculus lambda-env *) (* Amokrane Saibi *) (* *) (* September 1993 *) (* *) (*****************************************************************************) (* relation SL* o B|| o SL* *) Require Import TS. Require Import sur_les_relations. Require Import sigma_lift. Require Import lambda_sigma_lift. Require Import betapar. Definition e_slstar_bp_slstar (b : wsort) := explicit_comp_rel _ (e_relSLstar b) (explicit_comp_rel _ (e_beta_par b) (e_relSLstar b)). Notation slstar_bp_slstar := (e_slstar_bp_slstar _) (only parsing). (* <Warning> : Syntax is discontinued *) Hint Unfold e_slstar_bp_slstar. Goal forall a a' b b' : terms, e_beta_par _ b b' -> e_slstar_bp_slstar _ a a' -> e_slstar_bp_slstar _ (app a b) (app a' b'). (* Goal: forall (s s' t t' : sub_explicits) (_ : e_beta_par ws s s') (_ : e_slstar_bp_slstar ws t t'), e_slstar_bp_slstar ws (comp s t) (comp s' t') *) simple induction 2; intros. (* Goal: e_slstar_bp_slstar wt (app x b) (app z b') *) red in |- *; apply comp_2rel with (app y b). (* Goal: explicit_inclus (TS b) (e_beta_par b) (e_relLSLstar b) *) (* Goal: explicit_inclus (TS b) (e_relSLstar b) (e_relLSLstar b) *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) auto. (* Goal: explicit_comp_rel (TS ws) (e_beta_par ws) (e_relSLstar ws) (comp s y) (comp s' z) *) elim H2; intros. (* Goal: explicit_inclus (TS b) (e_beta_par b) (e_relLSLstar b) *) (* Goal: explicit_inclus (TS b) (e_relSLstar b) (e_relLSLstar b) *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) apply comp_2rel with (app y0 b'); auto. Save slbpsl_context_app_l. Hint Resolve slbpsl_context_app_l. Goal forall a a' b b' : terms, e_beta_par _ a a' -> e_slstar_bp_slstar _ b b' -> e_slstar_bp_slstar _ (app a b) (app a' b'). (* Goal: forall (s s' t t' : sub_explicits) (_ : e_beta_par ws s s') (_ : e_slstar_bp_slstar ws t t'), e_slstar_bp_slstar ws (comp s t) (comp s' t') *) simple induction 2; intros. (* Goal: e_slstar_bp_slstar wt (app a x) (app a' z) *) red in |- *; apply comp_2rel with (app a y). (* Goal: explicit_inclus (TS b) (e_beta_par b) (e_relLSLstar b) *) (* Goal: explicit_inclus (TS b) (e_relSLstar b) (e_relLSLstar b) *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) auto. (* Goal: explicit_comp_rel (TS ws) (e_beta_par ws) (e_relSLstar ws) (comp s y) (comp s' z) *) elim H2; intros. (* Goal: explicit_inclus (TS b) (e_beta_par b) (e_relLSLstar b) *) (* Goal: explicit_inclus (TS b) (e_relSLstar b) (e_relLSLstar b) *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) apply comp_2rel with (app a' y0); auto. Save slbpsl_context_app_r. Hint Resolve slbpsl_context_app_r. Goal forall a b a' b' : terms, e_beta_par _ b b' -> e_slstar_bp_slstar _ a a' -> e_slstar_bp_slstar _ (app (lambda a) b) (env a' (cons b' id)). (* Goal: forall (s s' t t' : sub_explicits) (_ : e_beta_par ws s s') (_ : e_slstar_bp_slstar ws t t'), e_slstar_bp_slstar ws (comp s t) (comp s' t') *) simple induction 2; intros. (* Goal: e_slstar_bp_slstar wt (app (lambda x) b) (env z (cons b' id)) *) red in |- *; apply comp_2rel with (app (lambda y) b). (* Goal: explicit_inclus (TS b) (e_beta_par b) (e_relLSLstar b) *) (* Goal: explicit_inclus (TS b) (e_relSLstar b) (e_relLSLstar b) *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) auto. (* Goal: explicit_comp_rel (TS ws) (e_beta_par ws) (e_relSLstar ws) (comp s y) (comp s' z) *) elim H2; intros. (* Goal: explicit_inclus (TS b) (e_beta_par b) (e_relLSLstar b) *) (* Goal: explicit_inclus (TS b) (e_relSLstar b) (e_relLSLstar b) *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) apply comp_2rel with (env y0 (cons b' id)); auto. Save slbpsl_context_beta_l. Hint Resolve slbpsl_context_beta_l. Goal forall a b a' b' : terms, e_beta_par _ a a' -> e_slstar_bp_slstar _ b b' -> e_slstar_bp_slstar _ (app (lambda a) b) (env a' (cons b' id)). (* Goal: forall (s s' t t' : sub_explicits) (_ : e_beta_par ws s s') (_ : e_slstar_bp_slstar ws t t'), e_slstar_bp_slstar ws (comp s t) (comp s' t') *) simple induction 2; intros. (* Goal: e_slstar_bp_slstar wt (app (lambda a) x) (env a' (cons z id)) *) red in |- *; apply comp_2rel with (app (lambda a) y). (* Goal: explicit_inclus (TS b) (e_beta_par b) (e_relLSLstar b) *) (* Goal: explicit_inclus (TS b) (e_relSLstar b) (e_relLSLstar b) *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) auto. (* Goal: explicit_comp_rel (TS ws) (e_beta_par ws) (e_relSLstar ws) (comp s y) (comp s' z) *) elim H2; intros. (* Goal: explicit_inclus (TS b) (e_beta_par b) (e_relLSLstar b) *) (* Goal: explicit_inclus (TS b) (e_relSLstar b) (e_relLSLstar b) *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) apply comp_2rel with (env a' (cons y0 id)); auto. Save slbpsl_context_beta_r. Hint Resolve slbpsl_context_beta_r. Goal forall a a' : terms, e_slstar_bp_slstar _ a a' -> e_slstar_bp_slstar _ (lambda a) (lambda a'). (* Goal: forall (s s' : sub_explicits) (_ : e_slstar_bp_slstar ws s s'), e_slstar_bp_slstar ws (lift s) (lift s') *) simple induction 1; intros. (* Goal: e_slstar_bp_slstar wt (lambda x) (lambda z) *) red in |- *; apply comp_2rel with (lambda y). (* Goal: explicit_inclus (TS b) (e_beta_par b) (e_relLSLstar b) *) (* Goal: explicit_inclus (TS b) (e_relSLstar b) (e_relLSLstar b) *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) auto. (* Goal: explicit_comp_rel (TS ws) (e_beta_par ws) (e_relSLstar ws) (lift y) (lift z) *) elim H1; intros. (* Goal: explicit_inclus (TS b) (e_beta_par b) (e_relLSLstar b) *) (* Goal: explicit_inclus (TS b) (e_relSLstar b) (e_relLSLstar b) *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) apply comp_2rel with (lambda y0); auto. Save slbpsl_context_lambda. Hint Resolve slbpsl_context_lambda. Goal forall (a a' : terms) (s s' : sub_explicits), e_beta_par _ s s' -> e_slstar_bp_slstar _ a a' -> e_slstar_bp_slstar _ (env a s) (env a' s'). (* Goal: forall (s s' t t' : sub_explicits) (_ : e_beta_par ws s s') (_ : e_slstar_bp_slstar ws t t'), e_slstar_bp_slstar ws (comp s t) (comp s' t') *) simple induction 2; intros. (* Goal: e_slstar_bp_slstar wt (env x s) (env z s') *) red in |- *; apply comp_2rel with (env y s). (* Goal: explicit_inclus (TS b) (e_beta_par b) (e_relLSLstar b) *) (* Goal: explicit_inclus (TS b) (e_relSLstar b) (e_relLSLstar b) *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) auto. (* Goal: explicit_comp_rel (TS ws) (e_beta_par ws) (e_relSLstar ws) (comp s y) (comp s' z) *) elim H2; intros. (* Goal: explicit_inclus (TS b) (e_beta_par b) (e_relLSLstar b) *) (* Goal: explicit_inclus (TS b) (e_relSLstar b) (e_relLSLstar b) *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) apply comp_2rel with (env y0 s'); auto. Save slbpsl_context_env_t. Hint Resolve slbpsl_context_env_t. Goal forall (a a' : terms) (s s' : sub_explicits), e_beta_par _ a a' -> e_slstar_bp_slstar _ s s' -> e_slstar_bp_slstar _ (env a s) (env a' s'). (* Goal: forall (s s' t t' : sub_explicits) (_ : e_beta_par ws s s') (_ : e_slstar_bp_slstar ws t t'), e_slstar_bp_slstar ws (comp s t) (comp s' t') *) simple induction 2; intros. (* Goal: e_slstar_bp_slstar wt (env a x) (env a' z) *) red in |- *; apply comp_2rel with (env a y). (* Goal: explicit_inclus (TS b) (e_beta_par b) (e_relLSLstar b) *) (* Goal: explicit_inclus (TS b) (e_relSLstar b) (e_relLSLstar b) *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) auto. (* Goal: explicit_comp_rel (TS ws) (e_beta_par ws) (e_relSLstar ws) (comp s y) (comp s' z) *) elim H2; intros. (* Goal: explicit_inclus (TS b) (e_beta_par b) (e_relLSLstar b) *) (* Goal: explicit_inclus (TS b) (e_relSLstar b) (e_relLSLstar b) *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) apply comp_2rel with (env a' y0); auto. Save slbpsl_context_env_s. Hint Resolve slbpsl_context_env_s. Goal forall (a a' : terms) (s s' : sub_explicits), e_beta_par _ s s' -> e_slstar_bp_slstar _ a a' -> e_slstar_bp_slstar _ (cons a s) (cons a' s'). (* Goal: forall (s s' t t' : sub_explicits) (_ : e_beta_par ws s s') (_ : e_slstar_bp_slstar ws t t'), e_slstar_bp_slstar ws (comp s t) (comp s' t') *) simple induction 2; intros. (* Goal: e_slstar_bp_slstar ws (cons x s) (cons z s') *) red in |- *; apply comp_2rel with (cons y s). (* Goal: explicit_inclus (TS b) (e_beta_par b) (e_relLSLstar b) *) (* Goal: explicit_inclus (TS b) (e_relSLstar b) (e_relLSLstar b) *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) auto. (* Goal: explicit_comp_rel (TS ws) (e_beta_par ws) (e_relSLstar ws) (comp s y) (comp s' z) *) elim H2; intros. (* Goal: explicit_inclus (TS b) (e_beta_par b) (e_relLSLstar b) *) (* Goal: explicit_inclus (TS b) (e_relSLstar b) (e_relLSLstar b) *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) apply comp_2rel with (cons y0 s'); auto. Save slbpsl_context_cons_t. Hint Resolve slbpsl_context_cons_t. Goal forall (a a' : terms) (s s' : sub_explicits), e_beta_par _ a a' -> e_slstar_bp_slstar _ s s' -> e_slstar_bp_slstar _ (cons a s) (cons a' s'). (* Goal: forall (s s' t t' : sub_explicits) (_ : e_beta_par ws s s') (_ : e_slstar_bp_slstar ws t t'), e_slstar_bp_slstar ws (comp s t) (comp s' t') *) simple induction 2; intros. (* Goal: e_slstar_bp_slstar ws (cons a x) (cons a' z) *) red in |- *; apply comp_2rel with (cons a y). (* Goal: explicit_inclus (TS b) (e_beta_par b) (e_relLSLstar b) *) (* Goal: explicit_inclus (TS b) (e_relSLstar b) (e_relLSLstar b) *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) auto. (* Goal: explicit_comp_rel (TS ws) (e_beta_par ws) (e_relSLstar ws) (comp s y) (comp s' z) *) elim H2; intros. (* Goal: explicit_inclus (TS b) (e_beta_par b) (e_relLSLstar b) *) (* Goal: explicit_inclus (TS b) (e_relSLstar b) (e_relLSLstar b) *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) apply comp_2rel with (cons a' y0); auto. Save slbpsl_context_cons_s. Hint Resolve slbpsl_context_cons_s. Goal forall s s' t t' : sub_explicits, e_beta_par _ t t' -> e_slstar_bp_slstar _ s s' -> e_slstar_bp_slstar _ (comp s t) (comp s' t'). (* Goal: forall (s s' t t' : sub_explicits) (_ : e_beta_par ws s s') (_ : e_slstar_bp_slstar ws t t'), e_slstar_bp_slstar ws (comp s t) (comp s' t') *) simple induction 2; intros. (* Goal: e_slstar_bp_slstar ws (comp x t) (comp z t') *) red in |- *; apply comp_2rel with (comp y t). (* Goal: explicit_inclus (TS b) (e_beta_par b) (e_relLSLstar b) *) (* Goal: explicit_inclus (TS b) (e_relSLstar b) (e_relLSLstar b) *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) auto. (* Goal: explicit_comp_rel (TS ws) (e_beta_par ws) (e_relSLstar ws) (comp s y) (comp s' z) *) elim H2; intros. (* Goal: explicit_inclus (TS b) (e_beta_par b) (e_relLSLstar b) *) (* Goal: explicit_inclus (TS b) (e_relSLstar b) (e_relLSLstar b) *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) apply comp_2rel with (comp y0 t'); auto. Save slbpsl_context_comp_l. Hint Resolve slbpsl_context_comp_l. Goal forall s s' t t' : sub_explicits, e_beta_par _ s s' -> e_slstar_bp_slstar _ t t' -> e_slstar_bp_slstar _ (comp s t) (comp s' t'). (* Goal: forall (s s' t t' : sub_explicits) (_ : e_beta_par ws s s') (_ : e_slstar_bp_slstar ws t t'), e_slstar_bp_slstar ws (comp s t) (comp s' t') *) simple induction 2; intros. (* Goal: e_slstar_bp_slstar ws (comp s x) (comp s' z) *) red in |- *; apply comp_2rel with (comp s y). (* Goal: explicit_inclus (TS b) (e_beta_par b) (e_relLSLstar b) *) (* Goal: explicit_inclus (TS b) (e_relSLstar b) (e_relLSLstar b) *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) auto. (* Goal: explicit_comp_rel (TS ws) (e_beta_par ws) (e_relSLstar ws) (comp s y) (comp s' z) *) elim H2; intros. (* Goal: explicit_inclus (TS b) (e_beta_par b) (e_relLSLstar b) *) (* Goal: explicit_inclus (TS b) (e_relSLstar b) (e_relLSLstar b) *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) apply comp_2rel with (comp s' y0); auto. Save slbpsl_context_comp_r. Hint Resolve slbpsl_context_comp_r. Goal forall s s' : sub_explicits, e_slstar_bp_slstar _ s s' -> e_slstar_bp_slstar _ (lift s) (lift s'). (* Goal: forall (s s' : sub_explicits) (_ : e_slstar_bp_slstar ws s s'), e_slstar_bp_slstar ws (lift s) (lift s') *) simple induction 1; intros. (* Goal: e_slstar_bp_slstar ws (lift x) (lift z) *) red in |- *; apply comp_2rel with (lift y). (* Goal: explicit_inclus (TS b) (e_beta_par b) (e_relLSLstar b) *) (* Goal: explicit_inclus (TS b) (e_relSLstar b) (e_relLSLstar b) *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) auto. (* Goal: explicit_comp_rel (TS ws) (e_beta_par ws) (e_relSLstar ws) (lift y) (lift z) *) elim H1; intros. (* Goal: explicit_inclus (TS b) (e_beta_par b) (e_relLSLstar b) *) (* Goal: explicit_inclus (TS b) (e_relSLstar b) (e_relLSLstar b) *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) apply comp_2rel with (lift y0); auto. Save slbpsl_context_lift. Hint Resolve slbpsl_context_lift. Goal forall (b : wsort) (M N : TS b), e_beta_par _ M N -> e_slstar_bp_slstar _ M N. (* Goal: forall (b : wsort) (M N : TS b) (_ : e_beta_par b M N), e_slstar_bp_slstar b M N *) intros; red in |- *; apply comp_2rel with M. (* Goal: explicit_inclus (TS b) (e_beta_par b) (e_relLSLstar b) *) (* Goal: explicit_inclus (TS b) (e_relSLstar b) (e_relLSLstar b) *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) red in |- *; auto. (* Goal: explicit_inclus (TS b) (e_beta_par b) (e_relLSLstar b) *) (* Goal: explicit_inclus (TS b) (e_relSLstar b) (e_relLSLstar b) *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) apply comp_2rel with N; auto. Save betapar_slbpsl. Hint Resolve betapar_slbpsl. Goal forall (b : wsort) (M : TS b), e_slstar_bp_slstar _ M M. (* Goal: explicit_inclus (TS b) (e_beta_par b) (e_relLSLstar b) *) (* Goal: explicit_inclus (TS b) (e_relSLstar b) (e_relLSLstar b) *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) auto. Save refl_slbpsl. Hint Resolve refl_slbpsl. (* LSL inclus dans SL*B||SL* *) Goal forall b : wsort, explicit_inclus _ (e_relLSL b) (e_slstar_bp_slstar b). (* Goal: explicit_inclus (TS b) (e_beta_par b) (e_relLSLstar b) *) (* Goal: explicit_inclus (TS b) (e_relSLstar b) (e_relLSLstar b) *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) red in |- *; simple induction 1; auto. (* Goal: explicit_inclus (TS b) (e_beta_par b) (e_relLSLstar b) *) (* Goal: explicit_inclus (TS b) (e_relSLstar b) (e_relLSLstar b) *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) simple induction 1; auto. (* regle beta *) (* Goal: explicit_inclus (TS b) (e_beta_par b) (e_relLSLstar b) *) (* Goal: explicit_inclus (TS b) (e_relSLstar b) (e_relLSLstar b) *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) simple induction 1; auto. (* Goal: forall (b : wsort) (M N : TS b) (_ : e_systemSL b M N), e_slstar_bp_slstar b M N *) intros b1 M0 N0 H1; red in |- *; apply comp_2rel with N0. (* Goal: explicit_inclus (TS b) (e_beta_par b) (e_relLSLstar b) *) (* Goal: explicit_inclus (TS b) (e_relSLstar b) (e_relLSLstar b) *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) auto. (* Goal: explicit_inclus (TS b) (e_beta_par b) (e_relLSLstar b) *) (* Goal: explicit_inclus (TS b) (e_relSLstar b) (e_relLSLstar b) *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) apply comp_2rel with N0; auto. Save relLSL_inclus_slbpsl. Hint Resolve relLSL_inclus_slbpsl. (* SL*B||SL* inclus dans LSL* *) Goal forall b : wsort, explicit_inclus _ (e_beta_par b) (e_relLSLstar b). (* Goal: explicit_inclus (TS b) (e_beta_par b) (e_relLSLstar b) *) (* Goal: explicit_inclus (TS b) (e_relSLstar b) (e_relLSLstar b) *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) red in |- *; simple induction 1; intros; auto. (* beta_bpar *) (* Goal: e_relLSLstar wt (app (lambda M) N) (env M' (cons N' id)) *) red in |- *; apply star_trans1 with (env M (cons N id)). (* Goal: explicit_inclus (TS b) (e_beta_par b) (e_relLSLstar b) *) (* Goal: explicit_inclus (TS b) (e_relSLstar b) (e_relLSLstar b) *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) auto. change (e_relLSLstar _ (env M (cons N id)) (env M' (cons N' id))) in |- *; (* Goal: explicit_inclus (TS b) (e_beta_par b) (e_relLSLstar b) *) (* Goal: explicit_inclus (TS b) (e_relSLstar b) (e_relLSLstar b) *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) auto. Save betapar_inclus_relSLstar. Hint Resolve betapar_inclus_relSLstar. Goal forall b : wsort, explicit_inclus _ (e_relSL b) (e_relLSL b). (* Goal: explicit_inclus (TS b) (e_beta_par b) (e_relLSLstar b) *) (* Goal: explicit_inclus (TS b) (e_relSLstar b) (e_relLSLstar b) *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) red in |- *; simple induction 1; auto. Save relSL_inclus_relLSL. Hint Resolve relSL_inclus_relLSL. Goal forall b : wsort, explicit_inclus _ (e_slstar_bp_slstar b) (e_relLSLstar b). (* Goal: forall b : wsort, explicit_inclus (TS b) (e_slstar_bp_slstar b) (e_relLSLstar b) *) unfold e_slstar_bp_slstar in |- *; intro b. (* Goal: explicit_inclus (TS b) (explicit_comp_rel (TS b) (e_beta_par b) (e_relSLstar b)) (e_relLSLstar b) *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) apply inclus_comp. (* SL* incl LSL* *) change (explicit_inclus _ (explicit_star _ (e_relSL b)) (* Goal: explicit_inclus (TS b) (e_beta_par b) (e_relLSLstar b) *) (* Goal: explicit_inclus (TS b) (e_relSLstar b) (e_relLSLstar b) *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) (explicit_star _ (e_relLSL b))) in |- *; auto. (* Goal: explicit_inclus (TS b) (explicit_comp_rel (TS b) (e_beta_par b) (e_relSLstar b)) (e_relLSLstar b) *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) apply inclus_comp. (* B|| incl LSL* *) (* Goal: explicit_inclus (TS b) (e_beta_par b) (e_relLSLstar b) *) (* Goal: explicit_inclus (TS b) (e_relSLstar b) (e_relLSLstar b) *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) auto. (* SL* incl LSL* *) change (explicit_inclus _ (explicit_star _ (e_relSL b)) (* Goal: explicit_inclus (TS b) (e_beta_par b) (e_relLSLstar b) *) (* Goal: explicit_inclus (TS b) (e_relSLstar b) (e_relLSLstar b) *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) (explicit_star _ (e_relLSL b))) in |- *; auto. (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) intros; red in |- *; apply star_trans with y; assumption. (* Goal: forall (x y z : TS b) (_ : e_relLSLstar b x y) (_ : e_relLSLstar b y z), e_relLSLstar b x z *) intros; red in |- *; apply star_trans with y; assumption. Save slbpsl_inclus_relLSLstar. Hint Resolve slbpsl_inclus_relLSLstar.