Declare ML Module "autocontra". Grammar tactic simple_tactic := [ "Auto_Contra" identarg($id)] -> [(TRY (auto_contra $id))]. Syntax tactic pp_auto_contra (TRY (auto_contra $id)) 0 "Auto_Contra " <$id:"namehyp":*>. Grammar tactic simple_tactic := [ "Auto_Contra"] -> [(TRY (auto_contran))]. Syntax tactic pp_auto_contran (TRY (autocontran)) 0 "Auto_Contra". Section boolean_decidability. Require Bool. Lemma bool_dec1 : (b:bool)~(Is_true b)->(Is_true (negb b)). Induction b. Simpl. Intro. Unfold not in H. Apply H. Try Trivial. Simpl. Intro. Try Trivial. Save. Lemma bool_dec2 : (b:bool)~b=true->(Is_true (negb b)). Induction b. Intros. Apply bool_dec1. Unfold not in H. Unfold not . Intro. Apply H. Try Trivial. Simpl. Try Trivial. Save. Lemma bool_dec3 : (b:bool)(Is_true b)->(b=true). Induction b. Intro. Try Trivial. Intros H. Inversion H. Save. Lemma bool_dec4 : (b:bool)~b=false->b=true. Induction b. Intro. Try Trivial. Cut (false = (negb true)). Intro. Rewrite -> H. Intros. Apply bool_dec3. Apply bool_dec2. Unfold not in H0. Unfold not . Intro. Apply H0. Try Trivial. Simpl. Try Trivial. Save. Lemma bool_dec5 : (b:bool)~b=true->b=false. Induction b. Intro. Cut (Is_true (negb true)). Simpl. (Intro;Contradiction). Apply bool_dec2. Try Trivial. Intro. Try Trivial. Save. Lemma bool_dec6 : (b:bool)b=false->~b=true. Induction b. (Intros d;Discriminate d). Intro. Discriminate. Save. Lemma bool_dec7 : (b:bool)b=true->~b=false. Induction b. Intros. Discriminate. (Intros d;Discriminate d). Save. End boolean_decidability. Section boolean_extension. (* Giving if constructor over bool for general sets.*) Hypothesis genset:Set. Recursive Definition Setifb : bool->genset->genset->genset := true x y => x | false x y => y. Lemma orbor : (b1,b2:bool) (orb b1 b2)=true->b1=true\/b2=true. Intros b1 b2. Case b1. Auto. Case b2. Auto. Auto. Save. Lemma ororb : (b1,b2:bool) (b1=true\/b2=true)->(orb b1 b2)=true. Intros. Case H. Intros. Rewrite -> H0. Auto. Intros. Rewrite -> H0. Case b1. Auto. Auto. Save. Lemma orbor1 : (b1,b2:bool) (orb b1 b2)=false->b1=false/\b2=false. Intros b1 b2. Case b1. Simpl. (Intros d;Discriminate d). Simpl. Auto. Save. Lemma ororb1 : (b1,b2:bool) (b1=false/\b2=false)->(orb b1 b2)=false. Intros. Case H. Intros. Rewrite -> H0. Rewrite -> H1. Auto. Save. Lemma sym_andb : (b1,b2:bool) (andb b1 b2)=(andb b2 b1). Intros. (Case b1; Case b2; Auto). Save. Lemma andbf : (b:bool) (andb b false)=false. Intros. Rewrite sym_andb; Auto. Save. End boolean_extension. Inductive lt : nat->nat->Prop := lt_O : (i:nat)(lt O (S i)) | lt_S : (i,j:nat)(lt i j)->(lt (S i) (S j)). Hint lt_O. Hint lt_S. Require MinMJ_booleans. Require MinMJ_lt. Section natural_number_decidability. Lemma S1 : (i,j:nat)(i=j)->~i=(S j). Intros. Rewrite -> H. (Generalize j ;Clear H i j). Induction j. Discriminate. Unfold not . Intros. Injection H0. Auto. Save. Hint S1. Lemma S2 : (i,j:nat)(i=j)->~i=(S (S j)). Intros. Rewrite -> H. Clear H i. Elim j. Discriminate. Intros. Injection. Auto. Save. Hint S2. Lemma Splus : (i,j:nat)(plus i (S j))=(S (plus i j)). Induction i. Auto. Intros. Simpl. Rewrite -> (H j). Auto. Save. Lemma Not_Splus : (i,j:nat)~(S (plus i j))=j. Induction j. Auto. Unfold not . Intros. Apply H. Rewrite <- (Splus i n). Injection H0. Auto. Save. Hint Not_Splus. Recursive Definition nateqb : nat->nat->bool := O O => true | (S i) O => false | O (S j) => false | (S i) (S j) => (nateqb i j). Lemma nateqb_sym : (i,j:nat)(nateqb i j)=(nateqb j i). Induction i. Induction j. Simpl. Try Trivial. Intros. Simpl. Try Trivial. Induction j. Simpl. Try Trivial. Intros. Simpl. Apply H. Save. Lemma nateqb_is_eq1 : (i,j:nat)i=j->(nateqb i j)=true. Intros. Rewrite -> H. (Generalize j ;Clear H j i). Induction j. Auto. Intros. Auto. Save. Lemma nateqb_is_eq2 : (i,j:nat)(nateqb i j)=true->i=j. Induction i. Induction j. Auto. Simpl. Intros. Discriminate H0. Induction j. Simpl. (Intros d;Discriminate d). Intros. Simpl in H1. Rewrite -> (H n0 H1). Auto. Save. Lemma nateqb_is_eq3 : (i,j:nat)(~i=j)->(nateqb i j)=false. Unfold not. Intros. Apply bool_dec5. Unfold not. Intros. Apply H. Apply (nateqb_is_eq2 i j H0). Save. Lemma nateqb_is_eq4 : (i,j:nat)((nateqb i j)=false)->~i=j. Intros. Cut (not (eq ? (nateqb i j) true)). Unfold not. Intros. Apply H0. Apply (nateqb_is_eq1 i j H1). Apply bool_dec6. Auto. Save. Definition nat_compare1 : nat->nat->Prop := [i,j:nat]((nateqb i j)=true)\/(nateqb i j)=false. Lemma nateqb_dec : (i,j:nat)(nat_compare1 i j). Unfold nat_compare1. Intros. Case (nateqb i j). Left. Try Trivial. Right. Try Trivial. Save. Definition nat_compare : nat->nat->Prop := [i,j:nat]i=j\/~i=j. Lemma nateq_dec : (i,j:nat)(nat_compare i j). Unfold nat_compare. Intros. Cut (nat_compare1 i j). Unfold nat_compare1. (Intros c;Elim c;[Clear c;Intros c|Clear c;Intros c]). Left. Apply (nateqb_is_eq2 i j c). Right. Apply nateqb_is_eq4. Auto. Exact (nateqb_dec i j). Save. Lemma nateq_dec1 : (i,j:nat)(P:Prop) i=j-> ~i=j-> P. Intros. Cut (eq ? (nateqb i j) true). Rewrite -> (nateqb_is_eq3 i j H0). (Intros d;Discriminate d). Exact (nateqb_is_eq1 i j H). Save. Recursive Definition ltb : nat->nat->bool := O O => false | O (S j) => true | (S i) O => false | (S i) (S j) => (ltb i j). Lemma ltb_is_lt1 : (i,j:nat) (lt i j)->(ltb i j)=true. Induction i. Intros. Inversion H. Auto. Intros. Inversion H0. Simpl. Auto. Save. Lemma ltb_is_lt2 : (i,j:nat) (ltb i j)=true->(lt i j). Induction i. Induction j. Simpl. (Intros d;Discriminate d). Auto. Induction j. Simpl. (Intros d;Discriminate d). Intros. Apply lt_S. Auto. Save. Lemma ltb_is_lt3 : (i,j:nat) ~(lt i j)->(ltb i j)=false. Unfold not. Intros. Apply bool_dec5. Unfold not. Intros. Apply H. Apply (ltb_is_lt2 i j H0). Save. Lemma ltb_is_lt4 : (i,j:nat) (ltb i j)=false->~(lt i j). Intros. Cut (not (eq ? (ltb i j) true)). Unfold not. Intros. Apply H0. Apply (ltb_is_lt1 i j H1). Apply bool_dec6. Auto. Save. Lemma lt_not_eq1 : (i,j:nat) (lt i j)->~i=j. Induction i. Induction j. Intros. Cut (eq ? (ltb O O) true). Simpl. (Intros d;Discriminate d). Apply (ltb_is_lt1 O O H). Auto. Intros. Inversion H0. Unfold not in H. Injection. Intros. Apply (H j0 H2 H5). Save. Definition nat_compare2 : nat->nat->Prop := [i,j:nat](lt i j)\/i=j\/(lt j i). Lemma natlt_dec : (i,j:nat)(nat_compare2 i j). Intros. Apply nat_double_ind. Induction n. Unfold nat_compare2. Auto. Unfold nat_compare2. Intros. Auto. Unfold nat_compare2. Auto. Unfold nat_compare2. Intros. (Elim H;[Clear H;Intros H|Clear H;Intros H;Elim H;[Clear H;Intros H|Clear H;Intros H]]). Left. Apply lt_S. Auto. Auto. (Right;Right). (Apply lt_S;Auto). Save. Lemma ltS : (i,j:nat) (lt i j)->(lt i (S j)). Induction i. Auto. Intros. Apply lt_S. Inversion H0. Apply H. Auto. Save. Hint nateq_dec. Hint natlt_dec. Lemma ltSplus1 : (i,j:nat) (lt i (S (plus i j))). Induction i. Auto. Intros. Simpl. Apply lt_S. Auto. Save. Hint ltSplus1. Lemma ltSplus2 : (i,j:nat) (lt i (S (plus j i))). Induction j. Simpl. Elim i. Auto. Intros. Apply lt_S. Auto. Intros. Simpl. Apply ltS. Auto. Save. Hint ltSplus2. Lemma ltSplus3 : (i,j,k:nat) (lt i j)-> (lt i (S (plus k j))). Induction k. Simpl. Intros. Apply ltS. Auto. Intros. Simpl. Apply ltS. Apply H. Auto. Save. Lemma ltplus1 : (i,j,k:nat) (lt i k)-> (lt O j)-> (lt i (plus j k)). Induction j. Intros. Inversion H0. Induction k. Intros. Inversion H0. Intros. Simpl. Apply ltSplus3. Auto. Save. Lemma plus_bridge : (i,j:nat) (plus i (S j))=(S (plus i j)). Induction i. Auto. Intros. Simpl. Rewrite -> H. Auto. Save. Lemma Slt : (i,j:nat) (lt (S i) j)-> (lt i j). Induction j. Intros. Inversion H. Intros. Inversion H0. Apply ltS. Auto. Save. Lemma notltbii : (i,j:nat) i=j-> (ltb i j)=false. Intros. Rewrite -> H. (Generalize j ;Clear H j i). Induction j. Auto. Intros. Auto. Save. Lemma ltplus2 : (j,h,i:nat) (lt i h)-> (lt i (plus j h)). Induction h. Intros. Inversion H. Intros. Inversion H0. Rewrite -> plus_bridge. Auto. Rewrite -> plus_bridge. Apply lt_S. Apply (H i0). Auto. Save. Lemma lt_trans : (k,i,j:nat) (lt i j)-> (lt j k)-> (lt i k). Induction k. (Intros;Inversion H0). Induction i. Auto. Induction j. (Intros d;Inversion d). Intros. (Inversion_clear H2;Inversion_clear H3). Apply lt_S. Apply H with j:=n1 . Auto. Auto. Save. Lemma lt_trans1 : (i,k,j:nat) (lt i j)-> (lt j k)-> (lt (S i) k). Induction i. Intros k j H. Inversion_clear H. Intros. Inversion_clear H. Inversion_clear H0. Apply lt_S. Apply lt_O. Apply lt_S. Apply lt_O. Intros. (Generalize H1 ; Clear H1; Inversion_clear H0). Intros. Inversion_clear H0. Apply lt_S. Apply (H j1 j0). Auto. Auto. Save. Lemma ltnotlt : (i,j:nat) (lt i j)->~(lt j i). Intros. Apply ltb_is_lt4. (Generalize i j H ;Clear H i j). Induction i. Intros. Simpl. Apply ltb_is_lt3. Unfold not . Intros. Inversion H0. Intros. Inversion_clear H0. Simpl. Apply H. Auto. Save. Lemma ltnot0 : (i,j:nat) (lt i j)->~j=O. Intros. Inversion_clear H. Discriminate. Discriminate. Save. Lemma not_eq_notO_not_pred_eq : (i,j:nat) ~i=O-> ~j=O-> ~i=j-> ~(pred i)=(pred j). Induction i. Unfold not . Intros. Apply H. Auto. Induction j. Unfold not . Intros. Apply H1. Auto. Intros. Simpl. Unfold not in H3. Unfold not . Intros. Apply H3. Auto. Save. Lemma ltiSi : (i,j:nat) i=j-> (lt i (S j)). Intros. Apply ltb_is_lt2. Rewrite -> H. Elim j. Auto. Intros. Auto. Save. Lemma notltii : (i,j:nat) i=j-> ~(lt i j). Induction i. Intros. Rewrite <- H. Apply ltb_is_lt4. Auto. Intros. Rewrite <- H0. Apply ltb_is_lt4. Simpl. Apply ltb_is_lt3. Apply H. Auto. Save. Lemma ltS_ltpred : (i,j:nat) (lt (S i) j)-> (lt i (pred j)). Induction j. Intros. Inversion H. Intros. Simpl. Inversion_clear H0. Auto. Save. Lemma ltpred_ltS : (i,j:nat) (lt i (pred j))-> (lt (S i) j). Induction j. Intros. Inversion H. Intros. Simpl in H0. Auto. Save. Lemma lt_S_le : (j,i:nat) (lt i j)-> (S i)=j\/(lt (S i) j). Induction j. Intros. Inversion H. Intros. Cut (nat_compare2 i n). Unfold nat_compare2 . (Intros d; Case d; Clear d; Intros d). Right. Apply lt_S. Auto. (Case d; Clear d; Intros d). Left. Auto. (Generalize d ; Clear d). Inversion_clear H0. Intros. Inversion d. Intros. Cut (or (eq ? (S i0) n) (lt (S i0) n)). Intros. Case H0. Clear H0. Intros. Rewrite -> H0. Left. Auto. Clear H0. Intros. Right. Apply lt_S. Auto. Apply H. Auto. Exact (natlt_dec i n). Save. Lemma lt_S_le2 : (i,j:nat) (lt i (S j))-> (lt i j)\/i=j. (Intros; Cut (or (eq ? (S i) (S j)) (lt (S i) (S j)))). (Intros c; Case c; Clear c; Intros). (Injection H0; Auto). (Inversion_clear H0; Auto). (Apply lt_S_le; Auto). Save. Lemma lt_trans2 : (i,j,k:nat) (lt i (S j))-> (lt j k)-> (lt i k). Induction i. Intros. Inversion H0. Auto. Auto. Intros. Apply lt_trans1 with j:=j. Inversion_clear H0. Auto. Auto. Save. Lemma lt_trans3 : (i,j,k:nat) (lt i j)-> (lt j (S k))-> (lt i k). (Induction j; Clear j; Intros). Inversion H. Inversion_clear H1. (Apply lt_trans2 with j:=n; Auto). Save. Lemma not_lt_eq_lt : (i,j:nat) ~(lt i j)-> i=j\/(lt j i). Intros. Cut (nat_compare2 i j). Unfold nat_compare2 . Intros. (Case H0; Clear H0; Intros). Left. Apply nateqb_is_eq2. Apply bool_dec4. (Unfold not in H; Unfold not ; Intros). Apply H. Auto. Auto. Exact (natlt_dec i j). Save. Lemma ltS_neq_lt : (j,i:nat) (lt i (S j))-> ~i=j-> (lt i j). Induction j. Intros. Generalize H0 . Clear H0. Inversion_clear H. Intros. Apply nateq_dec1 with i:=O j:=O. Auto. Auto. Inversion_clear H0. Intros. (Generalize H1 ; Clear H1; Inversion_clear H0). Auto. Intros. Apply lt_S. Apply H. Auto. (Unfold not in H0; Unfold not ; Intros). Auto. Save. Lemma lt_not_ltpred : (i,j:nat) (lt i j)-> ~(lt (pred j) i). Induction j. Intros. Inversion H. Intros. Simpl. Cut (or (eq ? (S i) (S n)) (lt (S i) (S n))). (Intros c; Case c; Clear c; Intros). (Injection H1; Intros). Apply notltii. Auto. Inversion_clear H1. Apply ltnotlt. Auto. Apply lt_S_le. Auto. Save. Lemma lt_not_ltS : (i,j:nat) (lt i j)-> ~(lt j (S i)). (Intros; Cut (eq ? j (pred (S j))); Auto; Intros; Rewrite -> H0; Apply lt_not_ltpred; Auto). Save. Lemma plus_eq2 : (i,j:nat) (plus (S i) j)= (S (plus i j)). Auto. Save. Lemma plus_right_id : (i:nat) (plus i O)=i. (Induction i; Clear i; Auto). Save. Lemma sym_plus : (i,j:nat) (plus i j)=(plus j i). (Induction i; Clear i; Intros; Simpl). (Rewrite -> plus_right_id; Auto). (Rewrite -> H; Auto). Save. Lemma ltS_not_lt : (i,j:nat) (lt i (S j))-> ~(lt j i). Intros. Cut (or (eq ? (S i) (S j)) (lt (S i) (S j))). (Intros c; Case c; Clear c; Intros). (Injection H0; Intros; Apply notltii; Auto). (Apply ltnotlt; Inversion H0; Auto). (Apply lt_S_le; Auto). Save. Lemma ltplus3 : (i,j:nat) (lt O j)-> (lt i (plus j i)). Induction j. (Intros H; Inversion H). Intros. Simpl. Apply ltSplus2. Save. Lemma ltplus4 : (i,j,k:nat) (lt (plus i j) k)-> (lt i k). (Induction i; Clear i; Simpl; Intros). (Inversion_clear H; Auto). Inversion_clear H0. Apply lt_S. (Apply (H j); Auto). Save. Lemma ltplus6: (i,j,k,n:nat) (lt k i)-> (lt n j)-> (lt (plus k n) (plus i j)). (Induction i; Clear i; Simpl). Intros. Inversion H. Intros. Cut (or (eq ? (S k) (S n)) (lt (S k) (S n))). (Intros c; Case c; Clear c H0; Intros). (Injection H0; Clear H0; Intros). Rewrite -> H0. (Elim n; Simpl; Intros). (Apply ltS; Auto). Auto. (Inversion_clear H0; Apply ltS; Apply H; Auto). (Apply lt_S_le; Auto). Save. Lemma ltplus5: (k,j,i,n:nat) (lt (plus i j) (plus k n))-> (lt i k)\/(lt j k)\/(lt i n)\/(lt j n). Intros. (Cut (nat_compare2 i k); Auto; Unfold nat_compare2 ; Intros c; Case c; Clear c; Intros c; Auto; Case c; Clear c; Intros). (Generalize H ; Rewrite -> H0; Clear H H0 i; Intros). (Right; Right; Right). (Generalize H ; Clear H; Elim k; Simpl; Auto; Intros). (Inversion_clear H0; Apply H; Auto). (Cut (nat_compare2 j n); Auto; Unfold nat_compare2 ; Intros c; Case c; Clear c; Intros c; Auto; Case c; Clear c; Intros). (Generalize H ; Rewrite -> H1; Clear H H1 j; Intros). Left. (Generalize H ; Clear H; Elim n). (Rewrite -> plus_right_id; Rewrite -> plus_right_id; Auto). Intros n0 H. (Rewrite -> sym_plus; Rewrite -> plus_eq2; Rewrite -> (sym_plus k); Rewrite -> plus_eq2; Rewrite -> sym_plus; Rewrite -> (sym_plus n0); Intros). (Inversion_clear H1; Apply H; Auto). Cut False. Contradiction. Cut (not (lt (plus i j) (plus k n))). (Intros H2; Apply H2; Auto). Apply ltnotlt; Apply ltplus6; Auto. Save. Recursive Definition max_nat : nat->nat->nat := i j => (Setifb nat (ltb i j) j i). Lemma max_nat0 : (i:nat) (max_nat i O)=i. (Induction i; Clear i; Simpl; Auto). Save. Lemma sym_max_nat : (i,j:nat) (max_nat i j)=(max_nat j i). (Intros; Cut (nat_compare2 i j); Auto; Unfold nat_compare2 ; Intros c; Case c; Clear c; Intros; Unfold max_nat ). (Rewrite -> ltb_is_lt1; Auto; Rewrite -> ltb_is_lt3; Auto). (Apply ltnotlt; Auto). (Case H; Clear H; Intros). Rewrite -> ltb_is_lt3. (Rewrite -> ltb_is_lt3; Auto). (Apply notltii; Auto). (Apply notltii; Auto). Rewrite -> ltb_is_lt3. (Rewrite -> ltb_is_lt1; Auto). (Apply ltnotlt; Auto). Save. Lemma lt_max_nat : (i,j,k:nat) (lt i (S (max_nat j k)))-> ((lt i (S j)) /\ (lt k (S j)))\/ ((lt i (S k)) /\ (lt j (S k))). (Unfold max_nat ; Intros; Generalize H ; Clear H; Cut (nat_compare2 j k); Auto; Unfold nat_compare2 ; Intros c; Case c; Clear c; Intros c). (Rewrite -> ltb_is_lt1; Auto; Simpl; Intros; Right; Split; Auto). (Apply ltS; Auto). (Case c; Clear c; Intros c; Rewrite -> ltb_is_lt3). (Simpl; Intros; Left; Split; Auto). (Apply ltiSi; Auto). (Apply notltii; Auto). (Simpl; Intros; Left; Split; Auto; Apply ltS; Auto). (Apply ltnotlt; Auto). Save. Lemma eq_max_nat : (i,j,k:nat) i=(S (max_nat j k))-> (i=(S j)/\ (lt k (S j)))\/ (i=(S k)/\ (lt j (S k))). (Unfold max_nat ; Intros; Generalize H ; Clear H; Cut (nat_compare2 j k); Auto; Unfold nat_compare2 ; Intros c; Case c; Clear c; Intros c). (Rewrite -> ltb_is_lt1; Auto; Simpl; Intros; Right; Split; Auto). (Apply ltS; Auto). (Case c; Clear c; Intros c). Rewrite -> ltb_is_lt3. (Unfold Setifb ; Intros; Left; Split; Auto). (Apply ltiSi; Auto). (Apply notltii; Auto). Rewrite -> ltb_is_lt3. (Simpl; Intros). (Left; Split; Auto; Apply ltS; Auto). (Apply ltnotlt; Auto). Save. Lemma lt_max_nat1 : (i,j,k:nat) i=j-> (lt i (S (max_nat j k))). (Unfold max_nat ; Intros; Generalize H ; Clear H; Cut (nat_compare2 j k); Auto; Unfold nat_compare2 ; Intros c; Case c; Clear c; Intros c). (Rewrite -> ltb_is_lt1; Auto). Simpl. Intros. (Rewrite -> H; Apply ltS; Auto). (Case c; Clear c; Intros; Rewrite -> ltb_is_lt3). (Simpl; Apply ltiSi; Rewrite -> H0; Auto). (Apply notltii; Auto). (Simpl; Apply ltiSi; Auto). (Apply ltnotlt; Auto). Save. Lemma lt_max_nat2 : (i,j,k:nat) (lt i j)-> (lt i (max_nat j k)). (Intros; Cut (nat_compare2 j k); Auto; Unfold nat_compare2 ; Intros c; Case c; Clear c; Intros; Unfold max_nat ). (Rewrite -> ltb_is_lt1; Auto; Apply lt_trans with j:=j; Auto). (Case H0; Clear H0; Intros; Rewrite -> ltb_is_lt3; Auto). (Apply notltii; Auto). (Apply ltnotlt; Auto). Save. Lemma S_max_nat_bridge0 : (i,j:nat) (S (max_nat i j))=(max_nat (S i) (S j)). (Intros; Unfold max_nat ; Cut (nat_compare2 i j); Auto; Unfold nat_compare2 ; Intros c; Case c; Clear c; Intros). (Rewrite -> ltb_is_lt1; Auto; Rewrite -> ltb_is_lt1; Auto). (Case H; Clear H; Intros; Rewrite -> ltb_is_lt3). (Rewrite -> ltb_is_lt3; Auto). (Apply notltii; Auto). (Apply notltii; Auto). (Rewrite -> ltb_is_lt3; Auto). (Apply ltnotlt; Auto). (Apply ltnotlt; Auto). Save. End natural_number_decidability. Hint ltSplus1. Hint ltSplus2. Hint ltiSi. Hint S1. Hint S2. Hint Splus. Hint Not_Splus. Hint nateq_dec. Hint natlt_dec. (* Tactic syntax *) Grammar tactic simple_tactic := [ "NComp2" command:command($i) command:command($j)] -> [let $1 = <<(nat_compare2 $i $j)>> in <:tactic:< Cut $1 ; [Destruct 1; [Intro | Destruct 1; Intro] | Auto]>>]. Grammar tactic simple_tactic := [ "NComp" command:command($i) command:command($j)] -> [let $1 = <<(nat_compare $i $j)>> in <:tactic:< Cut $1 ; [Destruct 1; Intro | Auto]>>]. Grammar tactic simple_tactic := [ "Induction_clear" identarg($i)] -> [ <:tactic:>]. Grammar tactic simple_tactic := [ "Injection_clear" identarg($i)] -> [ <:tactic:>]. Require autocontra. Require MinMJ_nat. Inductive F:Set := form: nat->F | (* Giving an infinite supply of decidably separate atomic Formulae.*) Impl : F->F->F. (* So far, we are only dealing with implicational fragments.*) Section F_decidability. Recursive Definition Feqb : F->F->bool := (form x) (form y) => (nateqb x y) | (form x) (Impl P' Q') => false | (Impl P Q) (form y) => false | (Impl P Q) (Impl P' Q') => (andb (Feqb P P') (Feqb Q Q')). Lemma Feqb_sym : (P,Q:F)(Feqb P Q)=(Feqb Q P). Induction P. Induction n. Induction Q. Induction n. Simpl. Try Trivial. Intros. Simpl. Try Trivial. Intros. Simpl. Try Trivial. Induction Q. Induction n. Simpl. Try Trivial. Intros. Simpl. Apply nateqb_sym. Intros. Simpl. Try Trivial. Induction Q. Simpl. Try Trivial. Intros. Simpl. Rewrite -> (H f1). Rewrite -> (H0 f2). Try Trivial. Save. Lemma Feqb_is_eq1 : (P,Q:F)(P=Q)->(Feqb P Q)=true. Intros. Rewrite <- H. Generalize P. Clear H P Q. Induction P. Induction n. Simpl. Try Trivial. Simpl. Try Trivial. Simpl. Intros. Rewrite -> H. Rewrite -> H0. Simpl. Try Trivial. Save. Lemma Feqb_is_eq2 : (P,Q:F)(Feqb P Q)=true->P=Q. Induction P. Induction Q. Simpl. Intros. Cut (eq ? n n0). (Intros c;Rewrite -> c). Try Trivial. Apply (nateqb_is_eq2 n n0 H). Intros. Simpl in H1. Discriminate H1. Induction Q. Intros. Simpl in H1. Discriminate H1. Intros. Cut (eq ? f f1). Cut (eq ? f0 f2). Intros. Rewrite -> H4. Rewrite -> H5. Try Trivial. Simpl in H3. Apply H0. (Generalize H3 ;Clear H3). Case (Feqb f0 f2). Auto. Case (Feqb f f1). Auto. Auto. Apply H. (Generalize H3 ;Clear H3;Simpl). Case (Feqb f f1). Auto. Auto. Save. Lemma Feqb_is_eq3 : (P,Q:F)(~P=Q)->(Feqb P Q)=false. Unfold not . Intros. Apply bool_dec5. Unfold not . Intros. Apply H. Apply (Feqb_is_eq2 P Q H0). Save. Lemma Feqb_is_eq4 : (P,Q:F)(Feqb P Q)=false->~P=Q. Intros. Cut (not (eq ? (Feqb P Q) true)). Unfold not . Intros. Apply H0. Apply (Feqb_is_eq1 P Q H1). Apply bool_dec6. Auto. Save. Definition F_compare1 : F->F->Prop := [P,Q:F]((Feqb P Q)=true)\/(Feqb P Q)=false. Lemma Feqb_dec : (P,Q:F)(F_compare1 P Q). Unfold F_compare1. Intros. Case (Feqb P Q). Left. Try Trivial. Right. Try Trivial. Save. Definition F_compare : F->F->Prop := [P,Q:F]P=Q\/~P=Q. Lemma Feq_dec : (P,Q:F)(F_compare P Q). Unfold F_compare . Intros. Cut (F_compare1 P Q). Unfold F_compare1 . Intros c;Elim c;[Clear c;Intros c|Clear c;Intros c]. Left. Apply (Feqb_is_eq2 P Q c). Right. Apply Feqb_is_eq4. Auto. Exact (Feqb_dec P Q). Save. Lemma Feq_dec1 : (i,j:F)(P:Prop) i=j-> ~i=j-> P. Intros. Cut (eq ? (Feqb i j) true). Rewrite -> (Feqb_is_eq3 i j H0). (Intros d;Discriminate d). Exact (Feqb_is_eq1 i j H). Save. Lemma Feq_dec2 : (i,j:F)(P:Prop) i=j-> ~i=j-> ~P. Intros. Unfold not . Intros. Exact (Feq_dec1 i j False H H0). Save. End F_decidability. Require MinMJ_F. Require PolyList. Require MinMJ_Syntax. (* Syntactic Definition Hyps := (list F). *) Grammar command command3 := ["Hyps"] -> [$0=<<(list F)>>]. Syntax constr HYPS <<(list F)>> 3 "Hyps". (* Syntactic Definition MT := (nil F). *) Grammar command command3 := ["MT"] -> [$0=<<(nil F)>>]. Syntax constr NH <<(nil F)>> 3 "MT". (* Syntactic Definition Add_Hyp := (cons F). *) Grammar command command3 := ["Add_Hyp" command:command($f) command:command($h)] -> [$0 = <<(cons F $f $h)>>]. Syntax constr AH <<(cons F $f $h)>> 3 "Add_Hyp " <$f:"term":L> " " <$h:"term":E>. Grammar command command3 := ["Len_Hyps" command:command($h)] -> [$0 = <<(length F $h)>>]. Syntax contr LH <<(length F $h)>> 3 "Len_Hyps " <$h:"term":E>. Lemma Add_Hyp1 : (i:Hyps)(P:F)~(Add_Hyp P i)=i. (Induction i; Clear i; Intros). Discriminate. (Unfold not; Intros; Apply (H a)). (Injection H0; Auto). Save. Hint Add_Hyp1. Recursive Definition Hypseqb : Hyps->Hyps->bool := MT MT => true | MT (Add_Hyp P' h') => false | (Add_Hyp P h) MT => false | (Add_Hyp P h) (Add_Hyp P' h') => (andb (Feqb P P') (Hypseqb h h')). Lemma Hypseqb_sym : (i,j:Hyps)(Hypseqb i j)=(Hypseqb j i). (Induction i; Clear i; Induction j; Clear j; Intros; Simpl; Try Trivial). (Rewrite -> Feqb_sym; Rewrite -> (H l0); Auto). Save. Lemma Hypseqb_is_eq1 : (i,j:Hyps)i=j->(Hypseqb i j)=true. (Intros; Rewrite -> H; Elim j; Clear H j; Intros; Auto). (Simpl; Rewrite -> Feqb_is_eq1; Auto; Rewrite -> H; Auto). Save. Lemma Hypseqb_is_eq2 : (i,j:Hyps)(Hypseqb i j)=true->i=j. (Induction i; Clear i; Induction j; Clear j; Intros; Auto). Discriminate H0. Discriminate H0. Simpl in H1. Clear H0. Cut (Feqb a a0)=true. Intros. Cut (Hypseqb l l0)=true. Intros. (Rewrite -> (Feqb_is_eq2 a a0); Auto). (Rewrite -> (H l0); Auto). (Generalize H1 ; Clear H1; Case (Hypseqb l l0); Rewrite -> H0; Auto). (Generalize H1 ; Clear H1; Case (Feqb a a0); Auto). Save. Lemma Hypseqb_is_eq3 : (i,j:Hyps)(~i=j)->(Hypseqb i j)=false. (Unfold not; Intros; Apply bool_dec5; Unfold not; Intros; Apply H; Apply Hypseqb_is_eq2; Auto). Save. Lemma Hypseqb_is_eq4 : (i,j:Hyps)(Hypseqb i j)=false->~i=j. Intros; Cut ~(Hypseqb i j)=true. Unfold not; Intros; Apply H0; Apply (Hypseqb_is_eq1 i j H1). Apply bool_dec6; Auto. Save. Definition Hyps_compare1 : Hyps->Hyps->Prop := [i,j:Hyps]((Hypseqb i j)=true)\/(Hypseqb i j)=false. Lemma Hypseqb_dec : (i,j:Hyps)(Hyps_compare1 i j). Unfold Hyps_compare1. Intros; Case (Hypseqb i j); Auto. Save. Definition Hyps_compare :Hyps->Hyps->Prop := [i,j:Hyps]i=j\/~i=j. Lemma Hypseq_dec : (i,j:Hyps)(Hyps_compare i j). Unfold Hyps_compare. Intros. Cut (Hyps_compare1 i j). Unfold Hyps_compare1. Intros c;Elim c;[Clear c;Intros c|Clear c;Intros c]. Left. Apply (Hypseqb_is_eq2 i j c). Right. Apply Hypseqb_is_eq4. Auto. Exact (Hypseqb_dec i j). Save. Require MinMJ_Hyps. Inductive In_Hyps : nat->F->Hyps->Prop := inhyps_base : (P:F)(h:Hyps) (In_Hyps O P (Add_Hyp P h)) | inhyps_rec : (n:nat)(P,Q:F)(h:Hyps) (In_Hyps n P h)-> (In_Hyps (S n) P (Add_Hyp Q h)). Definition V :Set := nat. Lemma In_lt : (h:Hyps)(x:V)(P:F) (In_Hyps x P h)-> (lt x (Len_Hyps h)). (Induction h; Clear h; Intros). Inversion H. Inversion_clear H0. (Simpl; Auto). (Simpl; Apply lt_S; Apply (H n P); Auto). Save. Hint inhyps_base. Hint inhyps_rec.Require MinMJ_In. Inductive L:Set := vr : V->L | app : V->L->L->L | lm : L->L. Require MinMJ_In. Mutual Inductive M:Set := sc : V->Ms->M | lambda : M->M with Ms:Set := mnil : Ms | mcons : M->Ms->Ms. Section MJ_syntax. Scheme M_Ms_ind1 := Induction for M Sort Prop with Ms_M_ind1 := Induction for Ms Sort Prop. (* We now join these two schemes together into the simultaneous induction scheme we actually want. *) Lemma M_Ms_ind : (P:M->Prop) (P0:Ms->Prop) ((v:V)(m:Ms)(P0 m)->(P (sc v m))) ->((m:M)(P m)->(P (lambda m))) ->(P0 mnil) ->((m:M)(P m)->(m0:Ms)(P0 m0)->(P0 (mcons m m0))) ->(((m:M)(P m)) /\ ((ms:Ms)(P0 ms))). Intros; Split; Intros. Exact (M_Ms_ind1 P P0 H H0 H1 H2 m). Exact (Ms_M_ind1 P P0 H H0 H1 H2 ms). Save. End MJ_syntax.Require MinMJ_In. Mutual Inductive N:Set := lam : N->N | an : A->N with A:Set := ap : A->N->A | var : V->A. Section NJ_syntax. Scheme N_A_ind1 := Induction for N Sort Prop with A_N_ind1 := Induction for A Sort Prop. Lemma N_A_ind : (P:N->Prop) (P0:A->Prop) ((n:N)(P n)->(P (lam n))) ->((a:A)(P0 a)->(P (an a))) ->((a:A)(P0 a)->(n:N)(P n)->(P0 (ap a n))) ->((v:V)(P0 (var v))) ->(((n:N)(P n)) /\ ((a:A)(P0 a))). Intro. Intro. Intro. Intro. Intro. Intro. Split. Intro. Exact (N_A_ind1 P P0 H H0 H1 H2 n). Intro. Exact (A_N_ind1 P P0 H H0 H1 H2 a). Save. End NJ_syntax.Require MinMJ_M. Require MinMJ_N. Fixpoint theta [m:M]:N := Case m of (* v;ms *)[x:V][ms:Ms] (theta1' ms (var x)) (* lambda m *)[m:M] (lam (theta m)) end with theta1' [ms:Ms]:A->N := [a:A]Case ms of (* mnil *) (an a) (* m::ms *)[m:M][ms:Ms] (theta1' ms (ap a (theta m))) end. (* Theta1' has its arguments in the wrong order so define theta' in the same order as psi' later for ease of human parsing and consistency. *) Recursive Definition theta' : A -> Ms -> N := a ms => (theta1' ms a). Section Theta. Lemma th1 : (x:V)(ms:Ms)((theta (sc x ms)) = (theta' (var x) ms)). Trivial. Save. Lemma th2 : (m:M)((theta (lambda m)) = (lam (theta m))). Trivial. Save. Lemma th3 : (a:A)((theta' a mnil) = (an a)). Trivial. Save. Lemma th4 : (m:M)(ms:Ms)(a:A)((theta' a (mcons m ms)) = (theta' (ap a (theta m)) ms)). Trivial. Save. End Theta.Require MinMJ_M. Require MinMJ_N. Fixpoint psi [n:N]:M := Case n of (* lam n *)[n:N] (lambda (psi n)) (* an a *)[a:A] (psi' a mnil) end with psi' [a:A]:Ms->M := [ms:Ms]Case a of (* ap a n *)[a':A][n:N] (psi' a' (mcons (psi n) ms)) (* var v *)[x:V] (sc x ms) end. Section Psi. Lemma ps1 : (n:N)((psi (lam n)) = (lambda (psi n))). Trivial. Save. Lemma ps2 : (a:A)((psi (an a)) = (psi' a mnil)). Trivial. Save. Lemma ps3 : (a:A)(n:N)(ms:Ms)((psi' (ap a n) ms) = (psi' a (mcons (psi n) ms))). Trivial. Save. Lemma ps4 : (x:V)(ms:Ms)((psi' (var x) ms) = (sc x ms)). Trivial. Save. End Psi. Require MinMJ_theta. Require MinMJ_psi. Section Theta_Psi. Definition thpsids :N->Prop := [n:N]((theta (psi n)) = n). Definition thps'th's :A->Prop := [a:A](ms:Ms)((theta (psi' a ms)) = (theta' a ms)). (*Now the actual proof *) Lemma thpsid : ((n:N)(thpsids n))/\((a:A)(thps'th's a)). (Apply N_A_ind; Unfold thpsids ; Unfold thps'th's thpsids ; Intros). (Rewrite -> ps1; Rewrite -> th2; Rewrite -> H; Auto). (Rewrite -> ps2; Exact (H mnil)). (Rewrite -> ps3; Rewrite -> (H (mcons (psi n) ms)); Rewrite -> th4; Rewrite -> H0; Auto). (Rewrite -> ps4; Rewrite -> th1; Auto). Save. End Theta_Psi. Lemma thetapsi: (n:N)((theta(psi n)) = n). Cut ((n:N)(thpsids n))/\((a:A)(thps'th's a)). Unfold thpsids; Intros; Case H; Auto. Apply thpsid. Save. Lemma thetapsi'theta': (a:A)(ms:Ms)((theta (psi' a ms)) = (theta' a ms)). Cut ((n:N)(thpsids n))/\((a:A)(thps'th's a)). Unfold thps'th's; Intros; Case H; Auto. Apply thpsid. Save. Require MinMJ_theta. Require MinMJ_psi. (* Because the bald statement of the proof has the wrong type inferred, we define the lemmas individually and unfold them after applying induction. *) Definition psthids :M->Prop := [m:M]((psi (theta m)) = m). Definition psth'ps's :Ms->Prop := [ms:Ms](a:A)((psi (theta' a ms)) = (psi' a ms)). (* Now we actually state the lemma. *) Lemma psthid : ((m:M)(psthids m))/\((ms:Ms)(psth'ps's ms)). (Apply M_Ms_ind; Unfold psthids ; Unfold psth'ps's ; Intros). (Rewrite -> th1; Exact (H (var v))). (Rewrite -> th2; Rewrite -> ps1; Rewrite -> H; Auto). (Rewrite -> th3; Rewrite -> ps2; Auto). (Rewrite -> th4; Rewrite -> (H0 (ap a (theta m))); Rewrite -> ps3; Rewrite -> H; Auto). Save. Lemma psitheta: (m:M)((psi(theta m))=m). Cut ((m:M)(psthids m))/\((ms:Ms)(psth'ps's ms)). Unfold psthids; Intros; Case H; Auto. Apply psthid. Save. Lemma psitheta'psi': (ms:Ms)(a:A)((psi (theta' a ms)) = (psi' a ms)). Cut ((m:M)(psthids m))/\((ms:Ms)(psth'ps's ms)). Unfold psth'ps's; Intros; Case H; Auto. Apply psthid. Save. Require MinMJ_LMN. Recursive Definition lift_V : nat->V->V := i j => (Setifb V (ltb j i) j (S j)). Recursive Definition lift_L : nat->L->L := i (vr x) => (vr (lift_V i x)) | i (app x l1 l2) => (app (lift_V i x) (lift_L i l1) (lift_L (S i) l2)) | i (lm l) => (lm (lift_L (S i) l)). Fixpoint lift_M1 [m:M] : nat->M := [i:nat]Case m of (* x;ms *)[x:V][ms:Ms] (sc (lift_V i x) (lift_Ms1 ms i)) (* lam m *)[m':M] (lambda (lift_M1 m' (S i))) end with lift_Ms1 [ms:Ms] : nat->Ms := [i:nat]Case ms of (* mnil *) mnil (* m::ms *)[m:M][ms':Ms] (mcons (lift_M1 m i) (lift_Ms1 ms' i)) end. Recursive Definition lift_M : nat->M->M := i m => (lift_M1 m i). Recursive Definition lift_Ms : nat->Ms->Ms := i ms => (lift_Ms1 ms i). Fixpoint lift_N1 [n:N] : nat->N := [i:nat]Case n of (* lam n *)[n':N] (lam (lift_N1 n' (S i))) (* an a *)[a:A] (an (lift_A1 a i)) end with lift_A1 [a:A] : nat->A := [i:nat]Case a of (* ap a n *)[a':A][n:N] (ap (lift_A1 a' i) (lift_N1 n i)) (* var x *)[x:V] (var (lift_V i x)) end. Recursive Definition lift_N : nat->N->N := i n => (lift_N1 n i). Recursive Definition lift_A : nat->A->A := i a => (lift_A1 a i). Section Lifting. Lemma LIFTM1 : (i:nat)(x:V)(ms:Ms) ((lift_M i (sc x ms)) = (sc (lift_V i x) (lift_Ms i ms))). Simpl. Intuition. Save. Lemma LIFTM2 : (i:nat)(m:M)((lift_M i (lambda m)) = (lambda (lift_M (S i) m))). Simpl. Intuition. Save. Lemma LIFTM3 : (i:nat)(lift_Ms i mnil)=mnil. Simpl. Trivial. Save. Lemma LIFTM4 : (i:nat)(m:M)(ms:Ms)((lift_Ms i (mcons m ms)) = (mcons (lift_M i m) (lift_Ms i ms))). Simpl. Intuition. Save. Lemma LIFTN1 : (i:nat)(n:N)((lift_N i (lam n)) = (lam (lift_N (S i) n))). Simpl. Intuition. Save. Lemma LIFTN2 : (i:nat)(a:A)((lift_N i (an a)) = (an (lift_A i a))). Simpl. Intuition. Save. Lemma LIFTN3 : (i:nat)(a:A)(n:N) ((lift_A i (ap a n)) = (ap (lift_A i a) (lift_N i n))). Simpl. Intuition. Save. Lemma LIFTN4 : (i:nat)(x:V)((lift_A i (var x)) = (var (lift_V i x))). Simpl. Trivial. Save. Lemma Lift_Lift_V_Bridge : (x:V)(i,j:nat) (lt i j)-> (lift_V i (lift_V j x))= (lift_V (S j) (lift_V i x)). (Unfold V ; Intros k i j H; Unfold 2 4 lift_V ). (Cut (nat_compare2 k j); Auto; Unfold nat_compare2 ; Intros c; Case c; Clear c; Intros). (Rewrite -> (ltb_is_lt1 k j H0); Simpl). (Cut (nat_compare2 k i); Auto; Unfold nat_compare2 ; Intros c; Case c; Clear c; Intros). (Rewrite -> (ltb_is_lt1 k i H1); Simpl). (Rewrite -> (ltb_is_lt1 k (S j)); Auto). Unfold lift_V . (Rewrite -> (ltb_is_lt1 k i H1); Rewrite -> ltb_is_lt1; Auto). (Apply ltS; Auto). (Apply ltS; Auto). (Case H1; Clear H1; Intros). Rewrite -> ltb_is_lt3. (Simpl; Unfold lift_V ). Rewrite -> ltb_is_lt3. (Rewrite -> ltb_is_lt1; Auto). (Apply notltii; Auto). (Apply notltii; Auto). (Rewrite -> ltb_is_lt3; Simpl; Unfold lift_V ). (Rewrite -> ltb_is_lt3; Simpl). (Rewrite -> ltb_is_lt1; Auto). (Apply ltnotlt; Auto). (Apply ltnotlt; Auto). (Case H0; Clear H0; Intros). (Rewrite -> ltb_is_lt3; Simpl). (Rewrite -> ltb_is_lt3; Simpl). Unfold lift_V . (Rewrite -> ltb_is_lt3; Simpl). (Rewrite -> ltb_is_lt3; Auto). (Apply notltii; Auto). (Apply ltnotlt; Apply ltS; Rewrite -> H0; Auto). (Apply ltnotlt; Rewrite -> H0; Auto). (Apply notltii; Auto). (Rewrite -> ltb_is_lt3; Simpl). (Rewrite -> ltb_is_lt3; Simpl). Unfold lift_V . (Rewrite -> ltb_is_lt3; Simpl). (Rewrite -> ltb_is_lt3; Auto). (Apply ltnotlt; Auto). (Apply ltnotlt; Apply ltS; Apply lt_trans with j:=j; Auto). (Apply ltnotlt; Apply lt_trans with j:=j; Auto). (Apply ltnotlt; Auto). Save. Lemma Lift_Lift_L_Bridge : (l:L)(i,j:nat) (lt i j)-> (lift_L i (lift_L j l))= (lift_L (S j) (lift_L i l)). (Induction l; Auto; Clear l; Intros). (Simpl; Rewrite -> Lift_Lift_V_Bridge; Auto). (Simpl; Rewrite -> H; Auto; Rewrite -> H0; Auto). (Rewrite -> Lift_Lift_V_Bridge; Auto). (Simpl; Rewrite -> H; Auto). Save. Definition lift_lift_n_bridge : N->Prop := [n:N](i,j:nat) (lt i j)-> (lift_N i (lift_N j n))= (lift_N (S j) (lift_N i n)). Definition lift_lift_a_bridge : A->Prop := [a:A](i,j:nat) (lt i j)-> (lift_A i (lift_A j a))= (lift_A (S j) (lift_A i a)). Lemma lift_lift_n_Bridge : ((n:N)(lift_lift_n_bridge n))/\ ((a:A)(lift_lift_a_bridge a)). (Apply N_A_ind; Unfold lift_lift_n_bridge ; Unfold lift_lift_a_bridge ; Intros). Simpl. Rewrite -> H. Auto. Auto. Rewrite -> LIFTN2. Rewrite -> LIFTN2. Rewrite -> LIFTN2. Rewrite -> LIFTN2. Rewrite -> H. Auto. Auto. Rewrite -> LIFTN3. Rewrite -> LIFTN3. Rewrite -> LIFTN3. Rewrite -> LIFTN3. Rewrite -> H. Rewrite -> H0. Auto. Auto. Auto. Rewrite -> LIFTN4. Rewrite -> LIFTN4. Rewrite -> LIFTN4. Rewrite -> LIFTN4. Rewrite -> Lift_Lift_V_Bridge. Auto. Auto. Save. Lemma Lift_Lift_N_Bridge : (n:N)(i,j:nat) (lt i j)-> (lift_N i (lift_N j n))= (lift_N (S j) (lift_N i n)). Cut ((n:N)(lift_lift_n_bridge n))/\((a:A)(lift_lift_a_bridge a)). Unfold lift_lift_n_bridge. Intros H. Case H. Auto. Exact lift_lift_n_Bridge. Save. Lemma Lift_Lift_A_Bridge : (a:A)(i,j:nat) (lt i j)-> (lift_A i (lift_A j a))= (lift_A (S j) (lift_A i a)). Cut ((n:N)(lift_lift_n_bridge n))/\((a:A)(lift_lift_a_bridge a)). Unfold lift_lift_a_bridge. Intros H. Case H. Auto. Exact lift_lift_n_Bridge. Save. Lemma Lift_Lift_V_Bridge0 : (x:V)(i,j:nat) (lt j i)-> (lift_V i (lift_V j x))= (lift_V j (lift_V (pred i) x)). (Unfold V ; Intros n i j H; Unfold 4 lift_V ; Inversion_clear H; Clear i j; Unfold pred ). (Cut (nat_compare2 n i0); Auto; Unfold nat_compare ; Intros c; Case c; Clear c; Intros). (Rewrite -> ltb_is_lt1; Auto; Unfold Setifb ; Unfold 2 3 lift_V ). Rewrite -> ltb_is_lt3. (Unfold Setifb ; Unfold lift_V ; Rewrite -> ltb_is_lt1; Auto). (Unfold not ; Intros; Inversion H0). (Case H; Clear H; Intros). Rewrite -> ltb_is_lt3. (Unfold Setifb ; Unfold 2 3 lift_V ; Rewrite -> ltb_is_lt3). Rewrite -> ltb_is_lt3. (Unfold Setifb ; Unfold lift_V ; Rewrite -> ltb_is_lt3; Auto). (Apply notltii; Auto). (Unfold not ; Intros; Inversion H0). (Unfold not ; Intros; Inversion H0). (Apply notltii; Auto). Rewrite -> ltb_is_lt3. (Unfold Setifb ; Unfold 2 3 lift_V ). Rewrite -> ltb_is_lt3. Rewrite -> ltb_is_lt3. (Unfold Setifb ; Unfold lift_V ; Rewrite -> ltb_is_lt3; Auto). (Apply ltnotlt; Auto). (Unfold not ; Intros; Inversion H0). (Unfold not ; Intros; Inversion H0). (Apply ltnotlt; Auto). (Cut (nat_compare2 n j0); Auto; Unfold nat_compare2 ; Intros c; Case c; Clear c; Intros). (Rewrite -> ltb_is_lt1; Auto; Unfold Setifb ; Unfold 2 3 lift_V ; Cut (nat_compare2 n (S i0)); Auto; Unfold nat_compare2 ; Intros c; Case c; Clear c; Intros). (Rewrite -> ltb_is_lt1; Auto; Unfold Setifb ; Unfold lift_V ; Rewrite -> ltb_is_lt1; Auto). (Apply ltS; Auto). (Case H1; Clear H1; Intros). Rewrite -> ltb_is_lt3. (Unfold Setifb ; Unfold lift_V ; Rewrite -> ltb_is_lt1; Auto). (Apply notltii; Auto). Rewrite -> ltb_is_lt3. (Unfold Setifb ; Unfold lift_V ; Rewrite -> ltb_is_lt1; Auto). (Apply ltnotlt; Auto). Rewrite -> ltb_is_lt3. (Unfold Setifb ; Unfold 2 3 lift_V ; Case H; Clear H; Intros). Rewrite -> ltb_is_lt3. Rewrite -> ltb_is_lt3. (Unfold Setifb ; Unfold lift_V ). (Rewrite -> ltb_is_lt3; Auto). (Apply notltii; Auto). (Rewrite -> H; Apply ltnotlt; Auto). (Rewrite -> H; Clear H n). (Apply lt_not_ltS; Auto). Rewrite -> ltb_is_lt3. Rewrite -> ltb_is_lt3. (Unfold Setifb ; Unfold lift_V ; Rewrite -> ltb_is_lt3; Auto). (Apply ltnotlt; Auto). (Apply ltnotlt; Apply lt_S; Apply lt_trans with j:=j0; Auto). (Apply ltnotlt; Apply lt_trans1 with j:=j0; Auto). (Case H; Clear H; Intros). (Apply notltii; Auto). (Apply ltnotlt; Auto). Save. Lemma Lift_Lift_L_Bridge0 : (l:L)(i,j:nat) (lt j i)-> (lift_L i (lift_L j l))= (lift_L j (lift_L (pred i) l)). (Induction l; Auto; Clear l; Intros). (Simpl; Rewrite -> Lift_Lift_V_Bridge0; Auto). (Simpl; Rewrite -> H; Auto; Rewrite -> H0; Auto). (Rewrite -> Lift_Lift_V_Bridge0; Auto; Inversion_clear H1; Auto). (Simpl; Rewrite -> H; Auto; Inversion_clear H0; Auto). Save. Definition lift_lift_n_bridge0 : N->Prop := [n:N](i,j:nat) (lt j i)-> (lift_N i (lift_N j n))= (lift_N j (lift_N (pred i) n)). Definition lift_lift_a_bridge0 : A->Prop := [a:A](i,j:nat) (lt j i)-> (lift_A i (lift_A j a))= (lift_A j (lift_A (pred i) a)). Lemma lift_lift_n_Bridge0 : ((n:N)(lift_lift_n_bridge0 n))/\ ((a:A)(lift_lift_a_bridge0 a)). (Apply N_A_ind; Unfold lift_lift_n_bridge0; Unfold lift_lift_a_bridge0; Intros). (Rewrite -> LIFTN1; Rewrite -> LIFTN1; Rewrite -> H; Auto; Inversion_clear H0; Auto). (Rewrite -> LIFTN2; Rewrite -> LIFTN2; Rewrite -> H; Auto). (Rewrite -> LIFTN3; Rewrite -> LIFTN3; Rewrite -> H; Auto; Rewrite -> H0; Auto). (Rewrite -> LIFTN4; Rewrite -> LIFTN4; Rewrite -> Lift_Lift_V_Bridge0; Auto). Save. Lemma Lift_Lift_N_Bridge0 : (n:N)(i,j:nat) (lt j i)-> (lift_N i (lift_N j n))= (lift_N j (lift_N (pred i) n)). Cut ((n:N)(lift_lift_n_bridge0 n))/\((a:A)(lift_lift_a_bridge0 a)). Unfold lift_lift_n_bridge0; Intros H; Case H; Auto. Exact lift_lift_n_Bridge0. Save. Lemma Lift_Lift_A_Bridge0 : (a:A)(i,j:nat) (lt j i)-> (lift_A i (lift_A j a))= (lift_A j (lift_A (pred i) a)). Cut ((n:N)(lift_lift_n_bridge0 n))/\((a:A)(lift_lift_a_bridge0 a)). Unfold lift_lift_a_bridge0; Intros H; Case H; Auto. Exact lift_lift_n_Bridge0. Save. Lemma Lift_Lift_V_Bridge1 : (x:V)(i,j:nat) i=j-> (lift_V i (lift_V j x))=(lift_V (S j) (lift_V i x)). (Unfold V ; Intros k i j H; Rewrite -> H; Cut (nat_compare2 j k); Auto; Unfold nat_compare2 ; Intros c; Case c; Clear c; Intros; Unfold 2 4 lift_V ). Rewrite -> ltb_is_lt3. (Simpl; Unfold lift_V ). (Rewrite -> ltb_is_lt3; Auto). (Rewrite -> ltb_is_lt3; Auto). (Apply ltnotlt; Auto). (Apply ltnotlt; Apply ltS; Auto). (Apply ltnotlt; Auto). (Case H0; Clear H0; Intros). (Rewrite -> ltb_is_lt3; Simpl; Unfold lift_V ). Rewrite -> ltb_is_lt3. (Rewrite -> ltb_is_lt3; Auto). (Rewrite -> H0; Apply notltii; Auto). (Apply ltnotlt; Rewrite -> H0; Apply ltiSi; Auto). (Apply notltii; Auto). (Rewrite -> ltb_is_lt1; Auto; Simpl; Unfold lift_V ). (Rewrite -> ltb_is_lt1; Auto; Rewrite -> ltb_is_lt1; Auto). (Apply ltS; Auto). Save. Definition lift_lift_n_bridge1 : N->Prop := [n:N](i,j:nat) i=j-> (lift_N i (lift_N j n))=(lift_N (S j) (lift_N i n)). Definition lift_lift_a_bridge1 : A->Prop := [a:A](i,j:nat) i=j-> (lift_A i (lift_A j a))=(lift_A (S j) (lift_A i a)). Lemma lift_lift_n_Bridge1 : ((n:N)(lift_lift_n_bridge1 n))/\((a:A)(lift_lift_a_bridge1 a)). (Apply N_A_ind; Unfold lift_lift_n_bridge1 ; Unfold lift_lift_a_bridge1 ; Intros). (Rewrite -> LIFTN1; Rewrite -> LIFTN1; Rewrite -> LIFTN1; Rewrite -> LIFTN1; Rewrite -> H). Auto. Auto. (Rewrite -> LIFTN2; Rewrite -> LIFTN2; Rewrite -> LIFTN2; Rewrite -> LIFTN2; Rewrite -> H; Auto). (Rewrite -> LIFTN3; Rewrite -> LIFTN3; Rewrite -> LIFTN3; Rewrite -> LIFTN3; Rewrite -> H). Rewrite -> H0. Auto. Auto. Auto. (Rewrite -> LIFTN4; Rewrite -> LIFTN4; Rewrite -> Lift_Lift_V_Bridge1; Auto). Save. Lemma Lift_Lift_N_Bridge1 : (n:N)(i,j:nat) i=j-> (lift_N i (lift_N j n))=(lift_N (S j) (lift_N i n)). Cut ((n:N)(lift_lift_n_bridge1 n))/\((a:A)(lift_lift_a_bridge1 a)). Unfold lift_lift_n_bridge1. Intros c. Case c. Intros. Auto. Exact lift_lift_n_Bridge1. Save. Lemma Lift_Lift_A_Bridge1 : (a:A)(i,j:nat) i=j-> (lift_A i (lift_A j a))=(lift_A (S j) (lift_A i a)). Cut ((n:N)(lift_lift_n_bridge1 n))/\((a:A)(lift_lift_a_bridge1 a)). Unfold lift_lift_a_bridge1. Intros c. Case c. Intros. Auto. Exact lift_lift_n_Bridge1. Save. Lemma Lift_Lift_L_Bridge1 :(l:L)(i,j:nat) i=j-> (lift_L i (lift_L j l))=(lift_L (S j) (lift_L i l)). Induction l; Clear l; Intros. (Simpl; Rewrite -> Lift_Lift_V_Bridge1; Auto). (Simpl; Rewrite -> H; Auto; Rewrite -> H0; Auto; Rewrite -> Lift_Lift_V_Bridge1; Auto). (Simpl; Rewrite -> H; Auto). Save. End Lifting.Require MinMJ_LMN. Recursive Definition drop_V : nat->V->V := j i => (Setifb V (ltb i j) i (pred i)). Recursive Definition drop_L : nat->L->L := i (vr x) => (vr (drop_V i x)) | i (app x l1 l2) => (app (drop_V i x) (drop_L i l1) (drop_L (S i) l2)) | i (lm l) => (lm (drop_L (S i) l)). Fixpoint drop_M1 [m:M] : nat->M := [i:nat]Case m of (* x;ms *)[x:V][ms:Ms] (sc (drop_V i x) (drop_Ms1 ms i)) (* lambda m *)[m':M] (lambda (drop_M1 m' (S i))) end with drop_Ms1 [ms:Ms] : nat->Ms := [i:nat]Case ms of (* mnil *) mnil (* m::ms *)[m:M][ms':Ms] (mcons (drop_M1 m i) (drop_Ms1 ms' i)) end. Recursive Definition drop_M : nat->M->M := i m => (drop_M1 m i). Recursive Definition drop_Ms : nat->Ms->Ms := i ms => (drop_Ms1 ms i). Fixpoint drop_N1 [n:N] : nat->N := [i:nat]Case n of (* lam n *)[n':N] (lam (drop_N1 n' (S i))) (* an a *)[a:A] (an (drop_A1 a i)) end with drop_A1 [a:A] : nat->A := [i:nat]Case a of (* ap a n *)[a':A][n:N] (ap (drop_A1 a' i) (drop_N1 n i)) (* var x *)[x:V] (var (drop_V i x)) end. Recursive Definition drop_N : nat->N->N := i n => (drop_N1 n i). Recursive Definition drop_A : nat->A->A := i a => (drop_A1 a i). Section Dropping. Lemma DROPM1 : (i:nat)(x:V)(ms:Ms)((drop_M i (sc x ms)) = (sc (drop_V i x) (drop_Ms i ms))). Simpl. Intuition. Save. Lemma DROPM2 : (i:nat)(m:M) ((drop_M i (lambda m)) = (lambda (drop_M (S i) m))). Simpl. Intuition. Save. Lemma DROPM3 : (i:nat)(drop_Ms i mnil)=mnil. Simpl. Trivial. Save. Lemma DROPM4 : (i:nat)(m:M)(ms:Ms)((drop_Ms i (mcons m ms)) = (mcons (drop_M i m) (drop_Ms i ms))). Simpl. Intuition. Save. Lemma DROPN1 : (i:nat)(n:N)((drop_N i (lam n)) = (lam (drop_N (S i) n))). Simpl. Intuition. Save. Lemma DROPN2 : (i:nat)(a:A)((drop_N i (an a)) = (an (drop_A i a))). Simpl. Intuition. Save. Lemma DROPN3 : (i:nat)(a:A)(n:N) ((drop_A i (ap a n)) = (ap (drop_A i a) (drop_N i n))). Simpl. Intuition. Save. Lemma DROPN4 : (i:nat)(x:V)((drop_A i (var x)) = (var (drop_V i x))). Simpl. Trivial. Save. End Dropping.Require MinMJ_Lift. Require MinMJ_Drop. Inductive Occurs_In_V : nat->V->Prop := Occurs_in_v : (i,j:nat)i=j-> (Occurs_In_V i j). Inductive Occurs_In_L : nat->L->Prop := Occurs_in_vr : (i:nat)(x:V) (Occurs_In_V i x)-> (Occurs_In_L i (vr x)) | Occurs_in_app1 : (i:nat)(x:V)(l1,l2:L) (Occurs_In_V i x)-> (Occurs_In_L i (app x l1 l2)) | Occurs_in_app2 : (i:nat)(x:V)(l1,l2:L) (Occurs_In_L i l1)-> (Occurs_In_L i (app x l1 l2)) | Occurs_in_app3 : (i:nat)(x:V)(l1,l2:L) (Occurs_In_L (S i) l2)-> (Occurs_In_L i (app x l1 l2)) | Occurs_in_lm : (i:nat)(l:L) (Occurs_In_L (S i) l)-> (Occurs_In_L i (lm l)). Mutual Inductive Occurs_In_M : nat->M->Prop := Occurs_in_sc1 : (i:nat)(x:V)(ms:Ms) (Occurs_In_V i x)-> (Occurs_In_M i (sc x ms)) | Occurs_in_sc2 : (i:nat)(x:V)(ms:Ms) (Occurs_In_Ms i ms)-> (Occurs_In_M i (sc x ms)) | Occurs_in_lambda : (i:nat)(m:M) (Occurs_In_M (S i) m)-> (Occurs_In_M i (lambda m)) with Occurs_In_Ms : nat->Ms->Prop := Occurs_in_mcons1 : (i:nat)(m:M)(ms:Ms) (Occurs_In_M i m)-> (Occurs_In_Ms i (mcons m ms)) | Occurs_in_mcons2 : (i:nat)(m:M)(ms:Ms) (Occurs_In_Ms i ms)-> (Occurs_In_Ms i (mcons m ms)). Mutual Inductive Occurs_In_N : nat->N->Prop := Occurs_in_lam : (i:nat)(n:N) (Occurs_In_N (S i) n)-> (Occurs_In_N i (lam n)) | Occurs_in_an : (i:nat)(a:A) (Occurs_In_A i a)-> (Occurs_In_N i (an a)) with Occurs_In_A : nat->A->Prop := Occurs_in_ap1 : (i:nat)(a:A)(n:N) (Occurs_In_A i a)-> (Occurs_In_A i (ap a n)) | Occurs_in_ap2 : (i:nat)(a:A)(n:N) (Occurs_In_N i n)-> (Occurs_In_A i (ap a n)) | Occurs_in_var : (i:nat)(x:V) (Occurs_In_V i x)-> (Occurs_In_A i (var x)). Hint Occurs_in_v. Hint Occurs_in_var. Hint Occurs_in_vr. Hint Occurs_in_sc1. Hint Occurs_in_sc2. Hint Occurs_in_lam. Hint Occurs_in_lambda. Hint Occurs_in_lm. Hint Occurs_in_app1. Hint Occurs_in_app2. Hint Occurs_in_app3. Hint Occurs_in_mcons1. Hint Occurs_in_mcons2. Hint Occurs_in_ap1. Hint Occurs_in_ap2. Hint Occurs_in_an. Section occurs. Recursive Definition Occurs_In_V1 : V->V->bool := i j => (nateqb i j). Lemma OIV1_is_OIV1 : (i,x:V) (Occurs_In_V i x)-> (Occurs_In_V1 i x)=true. (Intros; Inversion_clear H; Exact (nateqb_is_eq1 i x H0)). Save. Lemma OIV1_is_OIV2 : (i:V)(x:V) (Occurs_In_V1 i x)=true-> (Occurs_In_V i x). (Unfold Occurs_In_V1 ; Intros; Apply Occurs_in_v; Exact (nateqb_is_eq2 i x H)). Save. Lemma OIV1_is_OIV3 : (i:V)(x:V) ~(Occurs_In_V i x)-> (Occurs_In_V1 i x)=false. Unfold not. Intros. Apply bool_dec5. (Unfold not ;Intros;Apply H). Exact (OIV1_is_OIV2 i x H0). Save. Lemma OIV1_is_OIV4 : (i:V)(x:V) (Occurs_In_V1 i x)=false-> ~(Occurs_In_V i x). Intros. Cut (not (eq ? (Occurs_In_V1 i x) true)). (Unfold not ;Intros;Apply H0). Apply OIV1_is_OIV1. Auto. Apply bool_dec6. Auto. Save. Definition OIV_compare : V->V->Prop := [i:V][x:V](Occurs_In_V i x)\/~(Occurs_In_V i x). Lemma OIV_dec : (i:V)(x:V) (OIV_compare i x). Unfold OIV_compare. Intros. (Cut (nat_compare i x); Auto; Intros c; Case c; Clear c; Intros; Auto). (Right; Unfold not ; Intros; Apply H; Inversion_clear H0; Auto). Save. Recursive Definition Occurs_In_L1 : V->L->bool := i (vr x) => (Occurs_In_V1 i x) | i (app x l1 l2) => (orb (Occurs_In_V1 i x) (orb (Occurs_In_L1 i l1) (Occurs_In_L1 (S i) l2))) | i (lm l) => (Occurs_In_L1 (S i) l). Lemma OIL1_is_OIL1 : (l:L)(i:V) (Occurs_In_L i l)-> (Occurs_In_L1 i l)=true. (Induction l; Intros). Inversion_clear H. Exact (OIV1_is_OIV1 i v H0). (Generalize H H0 ; Clear H H0). Inversion_clear H1. Simpl. Intros. Rewrite -> (OIV1_is_OIV1 i v H). Auto. (Intros; Auto). Simpl. (Rewrite -> H0; Auto). Simpl. (Case (Occurs_In_V1 i v); Auto). (Simpl; Intros). (Rewrite -> H1; Auto). (Case (Occurs_In_L1 i l0); Case (Occurs_In_V1 i v); Auto). (Simpl; Inversion_clear H0; Rewrite -> H; Auto). Save. Lemma OIL1_is_OIL2 : (l:L)(i:V) (Occurs_In_L1 i l)=true-> (Occurs_In_L i l). (Induction l; Simpl; Intros). (Apply Occurs_in_vr; Apply OIV1_is_OIV2; Auto). Cut (or (eq ? (Occurs_In_V1 i v) true) (or (eq ? (Occurs_In_L1 i l0) true) (eq ? (Occurs_In_L1 (S i) l1) true))). (Intros c; Case c; Clear c; Intros). (Apply Occurs_in_app1; Apply OIV1_is_OIV2; Auto). (Case H2; Clear H2; Intros). (Apply Occurs_in_app2; Apply H; Auto). (Apply Occurs_in_app3; Apply H0; Auto). (Generalize H1 ; Clear H1; Case (Occurs_In_V1 i v); Auto). (Case (Occurs_In_L1 i l0); Auto). (Apply Occurs_in_lm; Apply H; Auto). Save. Lemma OIL1_is_OIL3 : (l:L)(i:V) ~(Occurs_In_L i l)-> (Occurs_In_L1 i l)=false. Unfold not. Intros. Apply bool_dec5. Unfold not ;Intros;Apply H. Exact (OIL1_is_OIL2 l i H0). Save. Lemma OIL1_is_OIL4 : (l:L)(i:V) (Occurs_In_L1 i l)=false-> ~(Occurs_In_L i l). Intros. Cut (not (eq ? (Occurs_In_L1 i l) true)). Unfold not ;Intros;Apply H0. Apply OIL1_is_OIL1. Auto. Apply bool_dec6. Auto. Save. Definition OIL_compare : V->L->Prop := [i:V][l:L](Occurs_In_L i l)\/~(Occurs_In_L i l). Lemma OIL_dec : (l:L)(i:V) (OIL_compare i l). Unfold OIL_compare . Intros. Cut (or (eq ? (Occurs_In_L1 i l) true) (eq ? (Occurs_In_L1 i l) false)). (Intros c; Case c; Clear c; Intros). (Left; Apply OIL1_is_OIL2; Auto). (Right; Apply OIL1_is_OIL4; Auto). (Case (Occurs_In_L1 i l); Auto). Save. Fixpoint Occurs_In_M2 [m:M] : V->bool := [i:V]Case m of (* x;ms *)[x:V][ms:Ms] (orb (Occurs_In_V1 i x) (Occurs_In_Ms2 ms i)) (* lambda m *)[m':M] (Occurs_In_M2 m' (S i)) end with Occurs_In_Ms2 [ms:Ms] : V->bool := [i:V]Case ms of (* mnil *) false (* m::ms *)[m:M][ms':Ms] (orb (Occurs_In_M2 m i) (Occurs_In_Ms2 ms' i)) end. Recursive Definition Occurs_In_M1 : V->M->bool := x m => (Occurs_In_M2 m x). Recursive Definition Occurs_In_Ms1 : V->Ms->bool := x ms => (Occurs_In_Ms2 ms x). Lemma OIM1 : (i,x:V)(ms:Ms) (Occurs_In_M1 i (sc x ms)) =(orb (Occurs_In_V1 i x) (Occurs_In_Ms1 i ms)). Auto. Save. Lemma OIM2 : (i:V)(m:M) (Occurs_In_M1 i (lambda m))= (Occurs_In_M1 (S i) m). Auto. Save. Lemma OIM3 : (i:V) (Occurs_In_Ms1 i mnil)=false. Auto. Save. Lemma OIM4 : (i:V)(m:M)(ms:Ms) (Occurs_In_Ms1 i (mcons m ms))= (orb (Occurs_In_M1 i m) (Occurs_In_Ms1 i ms)). Auto. Save. Definition oim1_is_oim1 : M->Prop := [m:M](i:V)(Occurs_In_M i m)-> (Occurs_In_M1 i m)=true. Definition oims1_is_oims1 : Ms->Prop := [ms:Ms](i:V)(Occurs_In_Ms i ms)-> (Occurs_In_Ms1 i ms)=true. Lemma oiM1_is_oiM1 : ((m:M)(oim1_is_oim1 m))/\ ((ms:Ms)(oims1_is_oims1 ms)). (Apply M_Ms_ind; Unfold oims1_is_oims1 ; Unfold oim1_is_oim1 ; Intros). Rewrite -> OIM1. Inversion_clear H0. Rewrite -> (OIV1_is_OIV1 i v H1). Auto. Rewrite -> (H i H1). (Case (Occurs_In_V1 i v); Auto). (Simpl; Apply H; Inversion_clear H0; Auto). Inversion H. (Rewrite -> OIM4; Apply ororb; Inversion_clear H1). (Left; Apply H; Auto). (Right; Apply H0; Auto). Save. Lemma OIM1_is_OIM1 : (i:V)(m:M) (Occurs_In_M i m)-> (Occurs_In_M1 i m)=true. Cut ((m:M)(oim1_is_oim1 m))/\ ((ms:Ms)(oims1_is_oims1 ms)). Unfold oim1_is_oim1; Intros H; Case H; Auto. Exact oiM1_is_oiM1. Save. Lemma OIMs1_is_OIMs1 : (i:V)(ms:Ms) (Occurs_In_Ms i ms)-> (Occurs_In_Ms1 i ms)=true. Cut ((m:M)(oim1_is_oim1 m))/\ ((ms:Ms)(oims1_is_oims1 ms)). Unfold oims1_is_oims1; Intros H; Case H; Auto. Exact oiM1_is_oiM1. Save. Definition oim1_is_oim2 : M->Prop := [m:M](i:V)(Occurs_In_M1 i m)=true-> (Occurs_In_M i m). Definition oims1_is_oims2 : Ms->Prop := [ms:Ms](i:V)(Occurs_In_Ms1 i ms)=true-> (Occurs_In_Ms i ms). Lemma oiM1_is_oiM2 : ((m:M)(oim1_is_oim2 m))/\ ((ms:Ms)(oims1_is_oims2 ms)). (Apply M_Ms_ind; Unfold oims1_is_oims2 ; Unfold oim1_is_oim2 ). (Intros v m H i; Rewrite -> OIM1; Intros; Cut (or (eq ? (Occurs_In_V1 i v) true) (eq ? (Occurs_In_Ms1 i m) true))). (Intros c; Case c; Clear c; Intros). (Apply Occurs_in_sc1; Apply OIV1_is_OIV2; Auto). (Apply Occurs_in_sc2; Apply H; Auto). (Generalize H0 ; Clear H0; Case (Occurs_In_V1 i v); Auto; Case (Occurs_In_Ms1 i m); Auto). (Intros m H i; Rewrite -> OIM2; Intros; Apply Occurs_in_lambda; Apply H; Auto). (Simpl; Intros; Discriminate H). (Intros m H m0 H0 i; Rewrite -> OIM4; Intros). Cut (or (eq ? (Occurs_In_M1 i m) true) (eq ? (Occurs_In_Ms1 i m0) true)). (Intros c; Case c; Clear c; Intros). (Apply Occurs_in_mcons1; Apply H; Auto). (Apply Occurs_in_mcons2; Apply H0; Auto). (Generalize H1 ; Clear H1; Case (Occurs_In_M1 i m); Auto; Case (Occurs_In_Ms1 i m0); Auto). Save. Lemma OIM1_is_OIM2 : (i:V)(m:M) (Occurs_In_M1 i m)=true-> (Occurs_In_M i m). Cut ((m:M)(oim1_is_oim2 m))/\ ((ms:Ms)(oims1_is_oims2 ms)). Unfold oim1_is_oim2. Intros H. Case H. Auto. Exact oiM1_is_oiM2. Save. Lemma OIMs1_is_OIMs2 : (i:V)(ms:Ms) (Occurs_In_Ms1 i ms)=true-> (Occurs_In_Ms i ms). Cut ((m:M)(oim1_is_oim2 m))/\ ((ms:Ms)(oims1_is_oims2 ms)). Unfold oims1_is_oims2. Intros H. Case H. Auto. Exact oiM1_is_oiM2. Save. Lemma OIM1_is_OIM3 : (i:V)(m:M) ~(Occurs_In_M i m)-> (Occurs_In_M1 i m)=false. Unfold not. Intros. Apply bool_dec5. Unfold not ;Intros;Apply H. Exact (OIM1_is_OIM2 i m H0). Save. Lemma OIMs1_is_OIMs3 : (i:V)(ms:Ms) ~(Occurs_In_Ms i ms)-> (Occurs_In_Ms1 i ms)=false. Unfold not. Intros. Apply bool_dec5. (Unfold not ;Intros;Apply H). Exact (OIMs1_is_OIMs2 i ms H0). Save. Lemma OIM1_is_OIM4 : (i:V)(m:M) (Occurs_In_M1 i m)=false-> ~(Occurs_In_M i m). Intros. Cut (not (eq ? (Occurs_In_M1 i m) true)). Unfold not ;Intros;Apply H0. Apply OIM1_is_OIM1. Auto. Apply bool_dec6. Auto. Save. Lemma OIMs1_is_OIMs4 : (i:V)(ms:Ms) (Occurs_In_Ms1 i ms)=false-> ~(Occurs_In_Ms i ms). Intros. Cut (not (eq ? (Occurs_In_Ms1 i ms) true)). Unfold not ;Intros;Apply H0. Apply OIMs1_is_OIMs1. Auto. Apply bool_dec6. Auto. Save. Definition OIM_compare : V->M->Prop := [i:V][m:M](Occurs_In_M i m)\/~(Occurs_In_M i m). Lemma OIM_dec : (i:V)(m:M) (OIM_compare i m). (Intros; Unfold OIM_compare ; Cut (or (eq ? (Occurs_In_M1 i m) true) (eq ? (Occurs_In_M1 i m) false))). (Intros c; Case c; Clear c; Intros). (Left; Apply OIM1_is_OIM2; Auto). (Right; Apply OIM1_is_OIM4; Auto). (Case (Occurs_In_M1 i m); Auto). Save. Definition OIMs_compare : V->Ms->Prop := [i:V][ms:Ms](Occurs_In_Ms i ms)\/~(Occurs_In_Ms i ms). Lemma OIMs_dec : (i:V)(ms:Ms) (OIMs_compare i ms). (Intros; Unfold OIMs_compare ; Cut (or (eq ? (Occurs_In_Ms1 i ms) true) (eq ? (Occurs_In_Ms1 i ms) false))). (Intros c; Case c; Clear c; Intros). (Left; Apply OIMs1_is_OIMs2; Auto). (Right; Apply OIMs1_is_OIMs4; Auto). (Case (Occurs_In_Ms1 i ms); Auto). Save. Fixpoint Occurs_In_N2 [n:N] : V->bool := [i:V]Case n of (* lam n *)[n':N] (Occurs_In_N2 n' (S i)) (* an a *)[a:A] (Occurs_In_A2 a i) end with Occurs_In_A2 [a:A] : V->bool := [i:V]Case a of (* ap a n *)[a':A][n:N] (orb (Occurs_In_A2 a' i) (Occurs_In_N2 n i)) (* var x *)[x:V] (Occurs_In_V1 i x) end. Definition Occurs_In_N1 : V->N->bool := [i:V][n:N](Occurs_In_N2 n i). Definition Occurs_In_A1 : V->A->bool := [i:V][a:A](Occurs_In_A2 a i). Lemma OIN1 : (i:V)(n:N) (Occurs_In_N1 i (lam n))= (Occurs_In_N1 (S i) n). Auto. Save. Lemma OIN2 : (i:V)(a:A) (Occurs_In_N1 i (an a))= (Occurs_In_A1 i a). Auto. Save. Lemma OIN3 : (i:V)(a:A)(n:N) (Occurs_In_A1 i (ap a n))= (orb (Occurs_In_A1 i a) (Occurs_In_N1 i n)). Auto. Save. Lemma OIN4 : (i,x:V) (Occurs_In_A1 i (var x))= (Occurs_In_V1 i x). Auto. Save. Definition oin1_is_oin1 : N->Prop := [n:N](i:V) (Occurs_In_N i n)-> (Occurs_In_N1 i n)=true. Definition oia1_is_oia1 : A->Prop := [a:A](i:V) (Occurs_In_A i a)-> (Occurs_In_A1 i a)=true. Lemma oiN1_is_oiN1 : ((n:N)(oin1_is_oin1 n))/\ ((a:A)(oia1_is_oia1 a)). (Apply N_A_ind; Unfold oin1_is_oin1 ; Unfold oia1_is_oia1 ; Intros). Simpl. (Apply H; Inversion_clear H0; Auto). (Rewrite -> OIN2; Apply H; Inversion_clear H0; Auto). (Rewrite -> OIN3; Apply ororb; Inversion_clear H1). (Left; Apply H; Auto). (Right; Apply H0; Auto). (Simpl; Inversion_clear H; Apply OIV1_is_OIV1; Auto). Save. Lemma OIN1_is_OIN1 : (n:N)(i:V) (Occurs_In_N i n)-> (Occurs_In_N1 i n)=true. Cut ((n:N)(oin1_is_oin1 n))/\ ((a:A)(oia1_is_oia1 a)). Intros H; Case H; Auto. Exact oiN1_is_oiN1. Save. Lemma OIA1_is_OIA1 : (a:A)(i:V) (Occurs_In_A i a)-> (Occurs_In_A1 i a)=true. Cut ((n:N)(oin1_is_oin1 n))/\ ((a:A)(oia1_is_oia1 a)). Intros H; Case H; Auto. Exact oiN1_is_oiN1. Save. Definition oin1_is_oin2 : N->Prop := [n:N](i:V)(Occurs_In_N1 i n)=true-> (Occurs_In_N i n). Definition oia1_is_oia2 : A->Prop := [a:A](i:V)(Occurs_In_A1 i a)=true-> (Occurs_In_A i a). Lemma oiN1_is_oiN2 : ((n:N)(oin1_is_oin2 n))/\ ((a:A)(oia1_is_oia2 a)). (Apply N_A_ind; Unfold oin1_is_oin2 ; Unfold oia1_is_oia2 ). (Intros n H i; Rewrite -> OIN1; Intros; Apply Occurs_in_lam; Apply H; Auto). (Intros a H i; Rewrite -> OIN2; Intros; Apply Occurs_in_an; Apply H; Auto). (Intros a H n H0 i; Rewrite -> OIN3; Intros; Cut (or (eq ? (Occurs_In_A1 i a) true) (eq ? (Occurs_In_N1 i n) true))). (Intros c; Case c; Clear c; Intros). (Apply Occurs_in_ap1; Apply H; Auto). (Apply Occurs_in_ap2; Apply H0; Auto). (Generalize H1 ; Clear H1; Case (Occurs_In_A1 i a); Auto; Case (Occurs_In_N1 i n); Auto). (Intros v i; Rewrite -> OIN4; Intros; Apply Occurs_in_var; Apply OIV1_is_OIV2; Auto). Save. Lemma OIN1_is_OIN2 : (n:N)(i:V) (Occurs_In_N1 i n)=true-> (Occurs_In_N i n). Cut ((n:N)(oin1_is_oin2 n))/\ ((a:A)(oia1_is_oia2 a)). Intros H; Case H; Auto. Exact oiN1_is_oiN2. Save. Lemma OIA1_is_OIA2 : (a:A)(i:V) (Occurs_In_A1 i a)=true-> (Occurs_In_A i a). Cut ((n:N)(oin1_is_oin2 n))/\ ((a:A)(oia1_is_oia2 a)). Intros H; Case H; Auto. Exact oiN1_is_oiN2. Save. Lemma OIN1_is_OIN3 : (i:V)(n:N) ~(Occurs_In_N i n)-> (Occurs_In_N1 i n)=false. Unfold not; Intros. Apply bool_dec5. Unfold not ;Intros;Apply H. Exact (OIN1_is_OIN2 n i H0). Save. Lemma OIA1_is_OIA3 : (i:V)(a:A) ~(Occurs_In_A i a)-> (Occurs_In_A1 i a)=false. Unfold not; Intros. Apply bool_dec5. Unfold not ;Intros;Apply H. Exact (OIA1_is_OIA2 a i H0). Save. Lemma OIN1_is_OIN4 : (i:V)(n:N) (Occurs_In_N1 i n)=false-> ~(Occurs_In_N i n). Intros; Cut (not (eq ? (Occurs_In_N1 i n) true)). Unfold not ;Intros;Apply H0. Apply OIN1_is_OIN1. Auto. Apply bool_dec6. Auto. Save. Lemma OIA1_is_OIA4 : (i:V)(a:A) (Occurs_In_A1 i a)=false-> ~(Occurs_In_A i a). Intros; Cut (not (eq ? (Occurs_In_A1 i a) true)). Unfold not ;Intros;Apply H0. Apply OIA1_is_OIA1. Auto. Apply bool_dec6. Auto. Save. Definition OIN_compare : V->N->Prop := [i:V][n:N](Occurs_In_N i n)\/~(Occurs_In_N i n). Lemma OIN_dec : (i:V)(n:N) (Occurs_In_N i n)\/~(Occurs_In_N i n). (Intros; Unfold OIN_compare ; Cut (or (eq ? (Occurs_In_N1 i n) true) (eq ? (Occurs_In_N1 i n) false))). (Intros c; Case c; Clear c; Intros). (Left; Apply OIN1_is_OIN2; Auto). (Right; Apply OIN1_is_OIN4; Auto). (Case (Occurs_In_N1 i n); Auto). Save. Definition OIA_compare : V->A->Prop := [i:V][a:A](Occurs_In_A i a)\/~(Occurs_In_A i a). Lemma OIA_dec : (i:V)(a:A) (Occurs_In_A i a)\/~(Occurs_In_A i a). (Intros; Unfold OIA_compare ; Cut (or (eq ? (Occurs_In_A1 i a) true) (eq ? (Occurs_In_A1 i a) false))). (Intros c; Case c; Clear c; Intros). (Left; Apply OIA1_is_OIA2; Auto). (Right; Apply OIA1_is_OIA4; Auto). (Case (Occurs_In_A1 i a); Auto). Save. Lemma NOI_Lift_V_Bridge0 : (x,i:V) ~(Occurs_In_V i x)-> (lift_V i x)= (lift_V (S i) x). (Intros j i H; Cut (nat_compare2 i j); Auto; Unfold nat_compare2 ; Intros c; Case c; Clear c; Intros; Unfold lift_V). Rewrite -> ltb_is_lt3. (Rewrite -> ltb_is_lt3; Auto). Cut (or (eq ? (S i) j) (lt (S i) j)). (Intros c; Case c; Clear c; Intros). (Apply notltii; Auto). (Apply ltnotlt; Auto). (Apply lt_S_le; Auto). (Apply ltnotlt; Auto). (Case H0; Clear H0; Intros; Simpl). (Cut False; Intros). Contradiction. (Unfold not in H; Apply H; Auto). Rewrite -> (ltb_is_lt1 j i H0). Rewrite -> ltb_is_lt1. Auto. (Apply ltS; Auto). Save. Definition NOI_lift_n_bridge0 : N->Prop := [n:N](i:V) ~(Occurs_In_N i n)-> (lift_N i n)= (lift_N (S i) n). Definition NOI_lift_a_bridge0 : A->Prop := [a:A](i:V) ~(Occurs_In_A i a)-> (lift_A i a)= (lift_A (S i) a). Lemma NOI_lift_n_Bridge0 : ((n:N)(NOI_lift_n_bridge0 n))/\ ((a:A)(NOI_lift_a_bridge0 a)). (Apply N_A_ind; Unfold NOI_lift_n_bridge0 ; Unfold NOI_lift_a_bridge0 ; Intros). (Simpl; Rewrite -> H; Auto). (Unfold not in H0; Unfold not ; Intros; Apply H0; Auto). (Rewrite -> LIFTN2; Rewrite -> H; Auto). (Unfold not in H0; Unfold not ; Intros; Apply H0; Auto). (Rewrite -> LIFTN3; Rewrite -> H). (Rewrite -> H0; Auto). (Unfold not in H1; Unfold not ; Intros; Apply H1; Apply Occurs_in_ap2; Auto). (Unfold not in H1; Unfold not ; Intros; Apply H1; Apply Occurs_in_ap1; Auto). (Simpl; Rewrite -> NOI_Lift_V_Bridge0; Auto). (Unfold not in H; Unfold not ; Intros; Apply H; Auto). Save. Lemma NOI_Lift_N_Bridge0 : (n:N)(i:V) ~(Occurs_In_N i n)-> (lift_N i n)= (lift_N (S i) n). Cut ((n:N)(NOI_lift_n_bridge0 n))/\ ((a:A)(NOI_lift_a_bridge0 a)). Unfold NOI_lift_n_bridge0. Intros c; Case c; Clear c; Intros; Auto. Exact NOI_lift_n_Bridge0. Save. Lemma NOI_Lift_A_Bridge0 : (a:A)(i:V) ~(Occurs_In_A i a)-> (lift_A i a)= (lift_A (S i) a). Cut ((n:N)(NOI_lift_n_bridge0 n))/\ ((a:A)(NOI_lift_a_bridge0 a)). Unfold NOI_lift_a_bridge0. Intros c; Case c; Clear c; Intros; Auto. Exact NOI_lift_n_Bridge0. Save. Lemma NOI_Lift_L_Bridge0 : (l:L)(i:V) ~(Occurs_In_L i l)-> (lift_L i l)= (lift_L (S i) l). (Induction l; Clear l; Intros; Simpl). Rewrite -> NOI_Lift_V_Bridge0. Auto. (Unfold not ; Intros; Apply H; Auto). Rewrite -> NOI_Lift_V_Bridge0. Rewrite -> H. (Rewrite -> H0; Auto). (Unfold not ; Intros; Apply H1; Apply Occurs_in_app3; Auto). (Unfold not ; Intros; Apply H1; Apply Occurs_in_app2; Auto). (Unfold not ; Intros; Apply H1; Apply Occurs_in_app1; Auto). (Rewrite -> H; Auto; Unfold not ; Intros; Apply H0; Auto). Save. Lemma NOI_Drop_V_Bridge0 : (x:V)(i,j:V) (lt i j)-> ~(Occurs_In_V (S j) x)-> ~(Occurs_In_V j (drop_V i x)). (Intros n i j H; Unfold drop_V ; Cut (nat_compare2 n i); Auto; Unfold nat_compare2 ; Intros c; Case c; Clear c; Intros c). (Rewrite -> ltb_is_lt1; Auto; Unfold Setifb ). Intros. (Apply OIV1_is_OIV4; Unfold Occurs_In_V1 ). (Apply nateqb_is_eq3; Apply sym_not_equal; Apply lt_not_eq1; Apply lt_trans with j:=i; Auto). (Case c; Clear c; Intros). Rewrite -> ltb_is_lt3. Unfold Setifb . (Generalize H ; Clear H; Rewrite -> H0; Clear H0; Elim i; Clear i; Intros). Simpl. (Inversion_clear H; Auto). (Apply OIV1_is_OIV4; Unfold Occurs_In_V1 ; Apply nateqb_is_eq3; Auto). Simpl. (Apply OIV1_is_OIV4; Unfold Occurs_In_V1 ; Apply nateqb_is_eq3; Apply sym_not_equal; Apply lt_not_eq1; Apply Slt; Auto). (Apply notltii; Auto). Rewrite -> ltb_is_lt3. Unfold Setifb . (Generalize H1 H ; Clear H1 H; Inversion_clear H0; Intros). (Simpl; Unfold not ; Intros; Apply H1; Inversion_clear H0; Auto). (Simpl; Unfold not ; Intros; Apply H1; Inversion_clear H2; Auto). (Apply ltnotlt; Auto). Save. Definition noi_drop_m_bridge0 : M->Prop := [m:M](i,j:V) (lt i j) ->~(Occurs_In_M (S j) m) ->~(Occurs_In_M j (drop_M i m)). Definition noi_drop_ms_bridge0 : Ms->Prop := [ms:Ms](i,j:V) (lt i j) ->~(Occurs_In_Ms (S j) ms) ->~(Occurs_In_Ms j (drop_Ms i ms)). Lemma noi_drop_m_Bridge0 : ((m:M)(noi_drop_m_bridge0 m))/\ ((ms:Ms)(noi_drop_ms_bridge0 ms)). (Apply M_Ms_ind; Unfold noi_drop_m_bridge0 ; Unfold noi_drop_ms_bridge0 ; Intros; Auto). (Apply OIM1_is_OIM4; Rewrite -> DROPM1; Rewrite -> OIM1; Apply ororb1; Split). (Apply OIV1_is_OIV3; Apply NOI_Drop_V_Bridge0; Auto). (Unfold not ; Intros; Apply H1; Apply Occurs_in_sc1; Auto). (Apply OIMs1_is_OIMs3; Apply H; Auto). (Unfold not ; Intros; Apply H1; Apply Occurs_in_sc2; Auto). (Apply OIM1_is_OIM4; Rewrite -> DROPM2; Rewrite -> OIM2; Apply OIM1_is_OIM3; Apply H; Auto; Unfold not ; Intros; Apply H1; Auto). (Simpl; Unfold not ; Intros; Inversion H1). (Apply OIMs1_is_OIMs4; Rewrite -> DROPM4; Rewrite -> OIM4; Apply ororb1; Split). (Apply OIM1_is_OIM3; Apply H; Auto; Unfold not ; Intros; Apply H2; Apply Occurs_in_mcons1; Auto). (Apply OIMs1_is_OIMs3; Apply H0; Auto; Unfold not ; Intros; Apply H2; Apply Occurs_in_mcons2; Auto). Save. Lemma NOI_Drop_M_Bridge0 : (m:M)(i,j:V) (lt i j) ->~(Occurs_In_M (S j) m) ->~(Occurs_In_M j (drop_M i m)). Cut ((m:M)(noi_drop_m_bridge0 m))/\ ((ms:Ms)(noi_drop_ms_bridge0 ms)). Unfold noi_drop_m_bridge0; Intros c; Case c; Clear c; Auto. Exact noi_drop_m_Bridge0. Save. Lemma NOI_Drop_Ms_Bridge0 : (ms:Ms)(i,j:V) (lt i j) ->~(Occurs_In_Ms (S j) ms) ->~(Occurs_In_Ms j (drop_Ms i ms)). Cut ((m:M)(noi_drop_m_bridge0 m))/\ ((ms:Ms)(noi_drop_ms_bridge0 ms)). Unfold noi_drop_ms_bridge0; Intros c; Case c; Clear c; Auto. Exact noi_drop_m_Bridge0. Save. Lemma NOI_Lift_V : (x:V)(i:nat) ~(Occurs_In_V i (lift_V i x)). (Intros n i; Unfold lift_V ; Cut (nat_compare2 n i); Auto; Unfold nat_compare2 ). (Intros d; Case d; [ Clear d; Intros d | Clear d; Intros d; Case d; [ Clear d; Intros d | Clear d; Intros d ] ]). (Rewrite -> (ltb_is_lt1 n i d); Unfold Setifb ). (Apply OIV1_is_OIV4; Unfold Occurs_In_V1 ; Apply nateqb_is_eq3; Apply sym_not_equal; Apply lt_not_eq1; Auto). Rewrite -> ltb_is_lt3. (Unfold Setifb ; Apply OIV1_is_OIV4; Unfold Occurs_In_V1 ; Apply nateqb_is_eq3; Apply lt_not_eq1; Apply ltiSi; Auto). (Apply notltii; Auto). Rewrite -> ltb_is_lt3. (Unfold Setifb ; Apply OIV1_is_OIV4; Unfold Occurs_In_V1 ; Apply nateqb_is_eq3; Apply lt_not_eq1; Auto). (Apply ltS; Auto). (Apply ltnotlt; Auto). Save. Lemma NOI_Lift_V2 :(x:V)(i,j:nat) ~(Occurs_In_V (S i) x)-> ~(Occurs_In_V i x)-> ~(Occurs_In_V (S i) (lift_V j x)). (Intros n i j H H0; Unfold lift_V ; Cut (nat_compare2 n j); Auto; Intros d; Case d; [ Clear d; Intros d | Clear d; Intros d; Case d; [ Clear d; Intros d | Clear d; Intros d ] ]). (Rewrite -> (ltb_is_lt1 n j d); Simpl; Auto). Rewrite -> ltb_is_lt3. (Simpl; Unfold not ; Intros; Apply H0; Inversion_clear H1; Auto). (Apply notltii; Auto). Rewrite -> ltb_is_lt3. (Simpl; Unfold not ; Intros; Inversion_clear H1; Apply H0; Auto). (Apply ltnotlt; Auto). Save. Definition noi_lift_m : M->Prop := [m:M](i:nat) ~(Occurs_In_M i (lift_M i m)). Definition noi_lift_ms : Ms->Prop := [ms:Ms](i:nat) ~(Occurs_In_Ms i (lift_Ms i ms)). Lemma NOI_lift_m : ((m:M)(noi_lift_m m))/\ ((ms:Ms)(noi_lift_ms ms)). (Apply M_Ms_ind; Unfold noi_lift_ms ; Unfold noi_lift_m ; Intros). (Rewrite -> LIFTM1; Apply OIM1_is_OIM4; Rewrite -> OIM1; Apply ororb1; Split). (Apply OIV1_is_OIV3; Apply NOI_Lift_V). (Apply OIMs1_is_OIMs3; Apply H). (Apply OIM1_is_OIM4; Rewrite -> LIFTM2; Rewrite -> OIM2; Apply OIM1_is_OIM3; Apply H). (Apply OIMs1_is_OIMs4; Auto). (Apply OIMs1_is_OIMs4; Rewrite -> LIFTM4; Rewrite -> OIM4; Apply ororb1; Split). (Apply OIM1_is_OIM3; Auto). (Apply OIMs1_is_OIMs3; Auto). Save. Lemma NOI_Lift_M : (m:M)(i:nat) ~(Occurs_In_M i (lift_M i m)). Cut ((m:M)(noi_lift_m m))/\ ((ms:Ms)(noi_lift_ms ms)). Intros c; Case c; Auto. Exact NOI_lift_m. Save. Lemma NOI_Lift_Ms : (ms:Ms)(i:nat) ~(Occurs_In_Ms i (lift_Ms i ms)). Cut ((m:M)(noi_lift_m m))/\ ((ms:Ms)(noi_lift_ms ms)). Intros c; Case c; Auto. Exact NOI_lift_m. Save. Definition noi_lift_m1 : M->Prop := [m:M](i:nat)(j:nat) ~(Occurs_In_M (S i) m)-> ~(Occurs_In_M i m)-> ~(Occurs_In_M (S i) (lift_M j m)). Definition noi_lift_ms1 : Ms->Prop := [ms:Ms](i:nat)(j:nat) ~(Occurs_In_Ms (S i) ms)-> ~(Occurs_In_Ms i ms)-> ~(Occurs_In_Ms (S i) (lift_Ms j ms)). Lemma NOI_lift_m1 : ((m:M)(noi_lift_m1 m))/\ ((ms:Ms)(noi_lift_ms1 ms)). (Apply M_Ms_ind; Unfold noi_lift_ms1 ; Unfold noi_lift_m1 ; Intros). (Apply OIM1_is_OIM4; Rewrite -> LIFTM1; Rewrite -> OIM1; Apply ororb1; Split). Cut (not (Occurs_In_V i v)). Cut (not (Occurs_In_V (S i) v)). (Intros; Apply OIV1_is_OIV3; Apply NOI_Lift_V2; Auto). (Unfold not ; Intros; Apply H0; Auto). (Unfold not ; Intros; Apply H1; Auto). (Apply OIMs1_is_OIMs3; Apply H). (Unfold not ; Intros; Apply H0; Auto). (Unfold not ; Intros; Apply H1; Auto). (Apply OIM1_is_OIM4; Rewrite -> LIFTM2; Rewrite -> OIM2; Apply OIM1_is_OIM3; Apply H). (Unfold not ; Intros; Apply H0; Auto). (Unfold not ; Intros; Apply H1; Auto). (Apply OIMs1_is_OIMs4; Auto). (Apply OIMs1_is_OIMs4; Rewrite -> LIFTM4; Rewrite -> OIM4; Apply ororb1; Split). (Apply OIM1_is_OIM3; Apply H). (Unfold not ; Intros; Apply H1; Auto). (Unfold not ; Intros; Apply H2; Auto). (Apply OIMs1_is_OIMs3; Apply H0). (Unfold not ; Intros; Apply H1; Auto). (Unfold not ; Intros; Apply H2; Auto). Save. Lemma NOI_Lift_M1 : (m:M)(i,j:nat) ~(Occurs_In_M (S i) m)-> ~(Occurs_In_M i m)-> ~(Occurs_In_M (S i) (lift_M j m)). Cut ((m:M)(noi_lift_m1 m))/\ ((ms:Ms)(noi_lift_ms1 ms)). Intros c; Case c; Auto. Exact NOI_lift_m1. Save. Lemma NOI_Lift_Ms1 : (ms:Ms)(i,j:nat) ~(Occurs_In_Ms (S i) ms)-> ~(Occurs_In_Ms i ms)-> ~(Occurs_In_Ms (S i) (lift_Ms j ms)). Cut ((m:M)(noi_lift_m1 m))/\ ((ms:Ms)(noi_lift_ms1 ms)). Intros c; Case c; Auto. Exact NOI_lift_m1. Save. Lemma NOI_Lift_L : (l:L)(i:nat) ~(Occurs_In_L i (lift_L i l)). (Induction l; Clear l; Intros; Apply OIL1_is_OIL4; Simpl; Auto). (Apply OIV1_is_OIV3; Apply NOI_Lift_V; Auto). (Apply ororb1; Split). (Apply OIV1_is_OIV3; Apply NOI_Lift_V). (Apply ororb1; Split; Apply OIL1_is_OIL3). Apply H. Apply H0. (Apply OIL1_is_OIL3; Apply H). Save. Lemma NOI_Lift_V3 : (x:V)(i,j:nat) (lt j i)-> ~(Occurs_In_V i x)-> ~(Occurs_In_V (S i) (lift_V j x)). Intros n i j H H0; Unfold lift_V . (Cut (nat_compare2 n j); Auto; Unfold nat_compare2 ; Intros c; Case c; Clear c; Intros). (Rewrite -> ltb_is_lt1; Auto; Simpl). (Apply OIV1_is_OIV4; Unfold Occurs_In_V1 ). (Apply nateqb_is_eq3; Apply sym_not_equal; Apply lt_not_eq1). Apply ltS. (Apply lt_trans with j:=j; Auto). (Case H1; Clear H1; Intros). Rewrite -> ltb_is_lt3. Simpl. (Apply OIV1_is_OIV4; Unfold Occurs_In_V1 ; Apply nateqb_is_eq3). Rewrite -> H1. (Apply sym_not_equal; Apply lt_not_eq1; Auto). (Apply notltii; Auto). Rewrite -> ltb_is_lt3. (Apply OIV1_is_OIV4; Unfold Setifb ; Unfold Occurs_In_V1 ; Apply nateqb_is_eq3). (Unfold not ; Intros c; Injection c; Clear c; Intros; Apply H0; Auto). (Apply ltnotlt; Auto). Save. Lemma NOI_Lift_V4 : (x:V)(i,j:nat) j=i-> ~(Occurs_In_V i x)-> ~(Occurs_In_V (S i) (lift_V j x)). Intros. Rewrite <- H. Rewrite -> NOI_Lift_V_Bridge0. Apply NOI_Lift_V. (Rewrite -> H; Auto). Save. End occurs. Hint OIL_dec. Hint OIM_dec. Hint OIMs_dec. Hint OIN_dec. Hint OIA_dec. Hint Occurs_in_v. Hint Occurs_in_var. Hint Occurs_in_vr. Hint Occurs_in_sc1. Hint Occurs_in_sc2. Hint Occurs_in_lam. Hint Occurs_in_lambda. Hint Occurs_in_lm. Hint Occurs_in_app1. Hint Occurs_in_app2. Hint Occurs_in_app3. Hint Occurs_in_mcons1. Hint Occurs_in_mcons2. Hint Occurs_in_ap1. Hint Occurs_in_ap2. Hint Occurs_in_an. Require MinMJ_Occurs. (* Support functions for phibar. *) (* Recursive Definition MssubstVMV2 : V->M->V->V->Ms->M := x m i j ms => (Setifb M (nateqb i j) (sc x (mcons m ms)) (sc (drop_V i j) ms)). Fixpoint MsubstVMV1 [m:M] : V->M->V->M := [x:V][m':M][i:nat]Case m of (* x;ms *)[z:V][ms:Ms] (MssubstVMV2 x m' i z (MssubstVMV1 ms x m' i)) (* lambda m *)[m'':M] (lambda (MsubstVMV1 m'' (lift_V O x) (lift_M O m') (S i))) end with MssubstVMV1 [ms:Ms] : V->M->V->Ms := [x:V][m:M][i:nat]Case ms of (* mnil *) mnil (* m::ms *)[m':M][ms':Ms] (mcons (MsubstVMV1 m' x m i) (MssubstVMV1 ms' x m i)) end. *) Fixpoint MsubstVMV1 [m:M] : V->M->V->M := [x:V][m':M][i:V]Case m of [z:V][ms:Ms] (Setifb M (nateqb i z) (sc x (mcons m' (MssubstVMV1 ms x m' z))) (sc (drop_V i z) (MssubstVMV1 ms x m' i))) [m'':M] (lambda (MsubstVMV1 m'' (lift_V O x) (lift_M O m') (S i))) end with MssubstVMV1 [ms:Ms] : V->M->V->Ms := [x:V][m':M][i:V]Case ms of mnil [m'':M][ms':Ms] (mcons (MsubstVMV1 m'' x m' i) (MssubstVMV1 ms' x m' i)) end. Recursive Definition MsubstVMV : V->M->V->M->M := x m i m' => (MsubstVMV1 m' x m i). Recursive Definition MssubstVMV : V->M->V->Ms->Ms := x m i ms => (MssubstVMV1 ms x m i). Section Msub_B. Lemma Drop_Lift_V : (x:V)(i:nat) (drop_V i (lift_V i x))=x. (Unfold V ; Intros n i; Cut (nat_compare2 i n); Auto; Unfold lift_V ; Unfold nat_compare2 ; Intros c; Case c; Clear c; Intros). (Rewrite -> ltb_is_lt3; Simpl; Unfold drop_V ). (Rewrite -> ltb_is_lt3; Auto). (Apply ltnotlt; Apply ltS; Auto). (Apply ltnotlt; Auto). (Case H; Clear H; Intros). (Rewrite -> ltb_is_lt3; Simpl; Unfold drop_V ). (Rewrite -> ltb_is_lt3; Auto). (Apply ltnotlt; Apply ltiSi; Auto). (Apply notltii; Auto). (Rewrite -> ltb_is_lt1; Auto; Simpl; Unfold drop_V ; Rewrite -> ltb_is_lt1; Auto). Save. Definition drop_lift_m : M->Prop := [m:M](i:nat)(drop_M i (lift_M i m))=m. Definition drop_lift_ms : Ms->Prop := [ms:Ms](i:nat)(drop_Ms i (lift_Ms i ms))=ms. Lemma drop_lift_M : ((m:M)(drop_lift_m m))/\((ms:Ms)(drop_lift_ms ms)). Apply M_Ms_ind. (Unfold drop_lift_ms;Unfold drop_lift_m ). Intros. Rewrite -> LIFTM1. Rewrite -> DROPM1. Rewrite -> H. Auto. Rewrite -> Drop_Lift_V. Auto. Unfold drop_lift_m . Intros. Simpl. Rewrite -> H. Auto. Unfold drop_lift_ms . Auto. Unfold drop_lift_m . Unfold drop_lift_ms . Intros. Rewrite -> LIFTM4. Rewrite -> DROPM4. (Rewrite -> H;Rewrite -> H0). Auto. Save. Lemma Drop_Lift_M : (i:nat)(m:M)(drop_M i (lift_M i m))=m. Cut ((m:M)(drop_lift_m m))/\((ms:Ms)(drop_lift_ms ms)). Unfold drop_lift_m. Intros H. Case H. Auto. Exact drop_lift_M. Save. Lemma Drop_Lift_Ms : (i:nat)(ms:Ms)(drop_Ms i (lift_Ms i ms))=ms. Cut ((m:M)(drop_lift_m m))/\((ms:Ms)(drop_lift_ms ms)). Unfold drop_lift_ms. Intros H. Case H. Auto. Exact drop_lift_M. Save. Lemma MSVMV1 : (x:V)(m:M)(y,z:V)(ms:Ms) (MsubstVMV x m y (sc z ms)) = (Setifb M (nateqb y z) (sc x (mcons m (MssubstVMV x m z ms))) (sc (drop_V y z) (MssubstVMV x m y ms))). Auto. Save. Lemma MSVMV2 : (x:V)(m:M)(m':M)(y:V) (MsubstVMV x m y (lambda m')) = (lambda (MsubstVMV (lift_V O x) (lift_M O m) (S y) m')). Auto. Save. Lemma MSVMV3 : (x:V)(m:M)(y:V)((MssubstVMV x m y mnil) = mnil). Auto. Save. Lemma MSVMV4 : (x:V)(m:M)(y:V)(m':M)(ms:Ms) ((MssubstVMV x m y (mcons m' ms)) = (mcons (MsubstVMV x m y m') (MssubstVMV x m y ms))). Auto. Save. Lemma Lift_Drop_V : (x:V)(i:nat) ~(Occurs_In_V i x)-> (lift_V i (drop_V i x))=x. Intros. (Cut (nat_compare2 i x); [ Destruct 1; [ Intro | Destruct 1; Intro ] | Auto ]). Unfold drop_V. (Rewrite -> ltb_is_lt3; Unfold Setifb). Unfold lift_V. (Rewrite -> ltb_is_lt3; Unfold Setifb). (Inversion_clear H1; Auto). (Apply lt_not_ltpred; Auto). (Apply ltnotlt; Auto). Auto_Contra H. Unfold drop_V. (Rewrite -> ltb_is_lt1; Auto; Unfold Setifb; Unfold lift_V). (Rewrite -> ltb_is_lt1; Auto). Save. Definition lift_drop_m : M->Prop := [m:M](i:nat) ~(Occurs_In_M i m)-> (lift_M i (drop_M i m))=m. Definition lift_drop_ms : Ms->Prop := [ms:Ms](i:nat) ~(Occurs_In_Ms i ms)-> (lift_Ms i (drop_Ms i ms))=ms. Lemma lift_drop_M : ((m:M)(lift_drop_m m))/\((ms:Ms)(lift_drop_ms ms)). (Apply M_Ms_ind; Unfold lift_drop_m; Unfold lift_drop_ms; Auto; Intros). (Rewrite -> DROPM1; Rewrite -> LIFTM1; Rewrite -> H; Auto). (Rewrite -> Lift_Drop_V; Auto). (Unfold not; Intros; Apply H0; Auto). (Unfold not; Intros; Apply H0; Auto). (Rewrite -> DROPM2; Rewrite -> LIFTM2; Rewrite -> H; Auto). (Unfold not; Intros; Apply H0; Auto). (Rewrite -> DROPM4; Rewrite -> LIFTM4; Rewrite -> H; Auto). (Rewrite -> H0; Auto). (Unfold not; Intros; Apply H1; Auto). (Unfold not; Intros; Apply H1; Auto). Save. Lemma Lift_Drop_M : (i:nat)(m:M) ~(Occurs_In_M i m)-> (lift_M i (drop_M i m))=m. Cut ((m:M)(lift_drop_m m))/\((ms:Ms)(lift_drop_ms ms)). (Unfold lift_drop_m; Intros c; Case c; Auto). Exact lift_drop_M. Save. Lemma Lift_Drop_Ms : (i:nat)(ms:Ms) ~(Occurs_In_Ms i ms)-> (lift_Ms i (drop_Ms i ms))=ms. Cut ((m:M)(lift_drop_m m))/\((ms:Ms)(lift_drop_ms ms)). (Unfold lift_drop_ms; Intros c; Case c; Auto). Exact lift_drop_M. Save. End Msub_B. Require MinMJ_Lift. Require MinMJ_Drop. (* Support functions for Phi. *) (* subst a for i in (var j). *) Recursive Definition VsubstAV : A->V->V->A := a i j => (Setifb A (nateqb i j) a (var (drop_V i j))). Fixpoint NsubstAV1 [n:N]: A->nat->N := [a:A][i:nat]Case n of (* lam n *)[n':N] (lam (NsubstAV1 n' (lift_A O a) (S i))) (* an a *)[a':A] (an (AsubstAV1 a' a i)) end with AsubstAV1 [a:A] : A->nat->A := [a':A][i:nat]Case a of (* ap a n *)[a'':A][n:N] (ap (AsubstAV1 a'' a' i) (NsubstAV1 n a' i)) (* var x *)[x:V] (VsubstAV a' i x) end. Recursive Definition NsubstAV : A->V->N->N := a i n => (NsubstAV1 n a i). Recursive Definition AsubstAV : A->V->A->A := a i a' => (AsubstAV1 a' a i). Section Nsub_B. Lemma NSAV1 : (a:A)(i:nat)(n:N) ((NsubstAV a i (lam n)) = (lam (NsubstAV (lift_A O a) (S i) n))). Auto. Save. Lemma NSAV2 : (a:A)(i:nat)(a':A) ((NsubstAV a i (an a')) = (an (AsubstAV a i a'))). Auto. Save. Lemma NSAV3 : (a:A)(i:nat)(a':A)(n:N) ((AsubstAV a i (ap a' n)) = (ap (AsubstAV a i a') (NsubstAV a i n))). Auto. Save. Lemma NSAV4 : (a:A)(i:nat)(x:V) ((AsubstAV a i (var x)) = (VsubstAV a i x)). Auto. Save. End Nsub_B. Require MinMJ_Nsub. (* The Mapping Phi from LJ to NJ. *) Recursive Definition phi : L -> N := (vr x) => (an (var x)) | (app x l1 l2) => (NsubstAV (ap (var x) (phi l1)) O (phi l2)) | (lm l) => (lam (phi l)). Require MinMJ_Msub. (* The Mapping PhiBar from LJ to MJ. *) Recursive Definition phibar : L->M := (vr x) => (sc x mnil) | (app x l1 l2) => (MsubstVMV x (phibar l1) O (phibar l2)) | (lm l) => (lambda (phibar l)). Require MinMJ_phibar. Require MinMJ_phi. Require MinMJ_psitheta. Require MinMJ_thetapsi. Section Bridge. Definition lift_psi_bridge : N->Prop := [n:N](i:nat)(lift_M i (psi n)) = (psi (lift_N i n)). Definition lift_psi'_bridge : A->Prop := [a:A](ms:Ms)(i:nat)(lift_M i (psi' a ms))=(psi' (lift_A i a) (lift_Ms i ms)). Lemma Lift_psi_Bridge : ((n:N)(lift_psi_bridge n))/\ ((a:A)(lift_psi'_bridge a)). Apply N_A_ind. Unfold lift_psi_bridge . Intros. Simpl. Rewrite -> H. Auto. Unfold lift_psi'_bridge . Unfold lift_psi_bridge . Intros. Rewrite -> ps2. Rewrite -> LIFTN2. Rewrite -> ps2. Rewrite -> H. Rewrite -> LIFTM3. Auto. Unfold lift_psi'_bridge . Unfold lift_psi_bridge . Intros. Rewrite -> ps3. Rewrite -> LIFTN3. Rewrite -> H. Rewrite -> LIFTM4. Rewrite -> H0. Auto. Unfold lift_psi'_bridge . Intros. Rewrite -> ps4. Rewrite -> LIFTM1. Rewrite -> LIFTN4. Rewrite -> ps4. Auto. Save. Lemma Lift_Psi_Bridge : (n:N)(i:nat)(lift_M i (psi n)) = (psi (lift_N i n)). Cut (and (n:N)(lift_psi_bridge n) (a:A)(lift_psi'_bridge a)). Unfold lift_psi_bridge . Intros H. Case H. Auto. Apply Lift_psi_Bridge. Save. Lemma Lift_Psi'_Bridge : (a:A)(ms:Ms)(i:nat) (lift_M i (psi' a ms))=(psi' (lift_A i a) (lift_Ms i ms)). Cut (and (n:N)(lift_psi_bridge n) (a:A)(lift_psi'_bridge a)). Unfold lift_psi'_bridge . Intros H. Case H. Auto. Apply Lift_psi_Bridge. Save. Lemma Lift_Theta_Bridge : (m:M)(i:nat)(lift_N i (theta m)) = (theta (lift_M i m)). Intros. Rewrite <- (psitheta m). Rewrite -> Lift_Psi_Bridge. Rewrite -> thetapsi. Rewrite -> thetapsi. Auto. Save. Lemma Lift_Theta'_Bridge : (a:A)(ms:Ms)(i:nat) (lift_N i (theta' a ms))=(theta' (lift_A i a) (lift_Ms i ms)). Intros. Rewrite <- (thetapsi'theta' a ms). Rewrite -> Lift_Theta_Bridge. Rewrite -> Lift_Psi'_Bridge. Rewrite -> thetapsi'theta'. Auto. Save. Lemma Lift_Lift_M_Bridge : (m:M)(i,j:nat) (lt i j)-> (lift_M i (lift_M j m))= (lift_M (S j) (lift_M i m)). (Intros; Rewrite <- (psitheta m); Rewrite -> Lift_Psi_Bridge; Rewrite -> Lift_Psi_Bridge; Rewrite -> Lift_Lift_N_Bridge; Auto; Rewrite <- Lift_Psi_Bridge; Rewrite <- Lift_Psi_Bridge; Auto). Save. Lemma Lift_Lift_Ms_Bridge : (ms:Ms)(i,j:nat) (lt i j)-> (lift_Ms i (lift_Ms j ms))= (lift_Ms (S j) (lift_Ms i ms)). (Induction ms; Clear ms; Auto; Intros; Rewrite -> LIFTM4; Rewrite -> LIFTM4; Rewrite -> Lift_Lift_M_Bridge; Auto; Rewrite -> H; Auto). Save. Lemma Lift_Lift_M_Bridge0 : (m:M)(i,j:nat) (lt j i)-> (lift_M i (lift_M j m))= (lift_M j (lift_M (pred i) m)). (Intros; Rewrite <- (psitheta m); Rewrite -> Lift_Psi_Bridge; Rewrite -> Lift_Psi_Bridge; Rewrite -> Lift_Lift_N_Bridge0; Auto; Rewrite <- Lift_Psi_Bridge; Rewrite <- Lift_Psi_Bridge; Auto). Save. Lemma Lift_Lift_Ms_Bridge0 : (ms:Ms)(i,j:nat) (lt j i)-> (lift_Ms i (lift_Ms j ms))= (lift_Ms j (lift_Ms (pred i) ms)). (Induction ms; Clear ms; Auto; Intros; Rewrite -> LIFTM4; Rewrite -> LIFTM4; Rewrite -> Lift_Lift_M_Bridge0; Auto; Rewrite -> H; Auto). Save. Lemma Lift_Lift_M_Bridge1 : (m:M)(i,j:nat) i=j-> (lift_M i (lift_M j m))= (lift_M (S j) (lift_M i m)). (Intros; Rewrite <- (psitheta m); Rewrite -> Lift_Psi_Bridge; Rewrite -> Lift_Psi_Bridge; Rewrite -> Lift_Lift_N_Bridge1; Auto; Rewrite <- Lift_Psi_Bridge; Rewrite <- Lift_Psi_Bridge; Auto). Save. Lemma Lift_Lift_Ms_Bridge1 : (ms:Ms)(i,j:nat) i=j-> (lift_Ms i (lift_Ms j ms))= (lift_Ms (S j) (lift_Ms i ms)). (Induction ms; Clear ms; Auto; Intros; Rewrite -> LIFTM4; Rewrite -> LIFTM4; Rewrite -> Lift_Lift_M_Bridge1; Auto; Rewrite -> H; Auto). Save. Definition msub_psi_bridge : N->Prop := [n2:N](n1:N)(x,y:V) (MsubstVMV x (psi n1) y (psi n2))= (psi (NsubstAV (ap (var x) n1) y n2)). Definition msub_psi'_bridge : A->Prop := [a:A](x:V)(n:N)(y:V)(ms:Ms) (MsubstVMV x (psi n) y (psi' a ms))= (psi' (AsubstAV (ap (var x) n) y a) (MssubstVMV x (psi n) y ms)). Lemma Msub_psi_bridge : ((n:N)(msub_psi_bridge n))/\((a:A)(msub_psi'_bridge a)). (Apply N_A_ind; Unfold msub_psi_bridge ; Unfold msub_psi'_bridge ; Intros). (Rewrite -> ps1; Rewrite -> MSVMV2; Rewrite -> NSAV1; Rewrite -> ps1; Rewrite -> Lift_Psi_Bridge; Rewrite -> H; Auto). (Rewrite -> ps2; Rewrite -> NSAV2; Rewrite -> ps2; Rewrite -> H; Rewrite -> MSVMV3; Auto). (Rewrite -> ps3; Rewrite -> NSAV3; Rewrite -> ps3; Rewrite -> H; Rewrite -> MSVMV4; Rewrite -> H0; Auto). (Rewrite -> NSAV4; Rewrite -> ps4; Rewrite -> MSVMV1; Unfold VsubstAV; Cut (nat_compare y v); [ Destruct 1; Intro | Auto ]). (Rewrite -> nateqb_is_eq1; Auto; Rewrite -> H0; Auto). (Rewrite -> nateqb_is_eq3; Auto). Save. Lemma Msub_Psi_Bridge : (n2:N)(n1:N)(x,y:V) (MsubstVMV x (psi n1) y (psi n2))= (psi (NsubstAV (ap (var x) n1) y n2)). Cut (and (n:N)(msub_psi_bridge n) (a:A)(msub_psi'_bridge a)). Unfold msub_psi_bridge; Intros c; Case c; Auto. Exact Msub_psi_bridge. Save. Lemma Msub_Psi'_Bridge : (a:A)(x:V)(n:N)(y:V)(ms:Ms) (MsubstVMV x (psi n) y (psi' a ms))= (psi' (AsubstAV (ap (var x) n) y a) (MssubstVMV x (psi n) y ms)). Cut (and (n:N)(msub_psi_bridge n) (a:A)(msub_psi'_bridge a)). Unfold msub_psi'_bridge; Intros c; Case c; Auto. Exact Msub_psi_bridge. Save. Lemma Nsub_Theta_Bridge : (x:V)(m1:M)(y:V)(m2:M) (NsubstAV (ap (var x) (theta m1)) y (theta m2)) =(theta (MsubstVMV x m1 y m2)). Intros. Rewrite <- (psitheta m1). Rewrite <- (psitheta m2). Rewrite -> Msub_Psi_Bridge. Rewrite -> psitheta. Rewrite -> psitheta. Rewrite -> thetapsi. Auto. Save. Definition theta_drop_m_bridge : M->Prop := [m:M](i:nat)(theta (drop_M i m))=(drop_N i (theta m)). Definition theta'_drop_ms_bridge : Ms->Prop := [ms:Ms](a:A)(i:nat) (theta' (drop_A i a) (drop_Ms i ms))=(drop_N i (theta' a ms)). Lemma theta_drop_M_bridge : ((m:M)(theta_drop_m_bridge m))/\ ((ms:Ms)(theta'_drop_ms_bridge ms)). Apply M_Ms_ind. Unfold theta'_drop_ms_bridge . Unfold theta_drop_m_bridge . Intros. Rewrite -> DROPM1. Rewrite -> th1. Rewrite <- DROPN4. Rewrite -> H. Rewrite -> th1. Auto. Unfold theta_drop_m_bridge . Intros. Rewrite -> DROPM2. Rewrite -> th2. Rewrite -> H. Rewrite -> th2. Rewrite -> DROPN1. Auto. Unfold theta'_drop_ms_bridge . Auto. Unfold theta'_drop_ms_bridge . Unfold theta_drop_m_bridge . Intros. Rewrite -> DROPM4. Rewrite -> th4. Rewrite -> H. Rewrite -> th4. Rewrite <- H0. Rewrite -> DROPN3. Auto. Save. Lemma Theta_Drop_M_Bridge : (m:M)(i:nat)(theta (drop_M i m))=(drop_N i (theta m)). Cut ((m:M)(theta_drop_m_bridge m))/\ ((ms:Ms)(theta'_drop_ms_bridge ms)). Unfold theta_drop_m_bridge. Intros H. Case H. Auto. Exact theta_drop_M_bridge. Save. Lemma Theta'_Drop_Ms_Bridge : (ms:Ms)(a:A)(i:nat) (theta' (drop_A i a) (drop_Ms i ms))=(drop_N i (theta' a ms)). Cut ((m:M)(theta_drop_m_bridge m))/\ ((ms:Ms)(theta'_drop_ms_bridge ms)). Unfold theta'_drop_ms_bridge. Intros H. Case H. Auto. Exact theta_drop_M_bridge. Save. Lemma Psi_Drop_N_Bridge : (n:N)(i:nat) (psi (drop_N i n))=(drop_M i (psi n)). Intros. Rewrite <- (thetapsi n). Rewrite <- Theta_Drop_M_Bridge. Rewrite -> psitheta. Rewrite -> thetapsi. Auto. Save. Lemma Psi'_Drop_A_Bridge : (a:A)(ms:Ms)(i:nat) (psi' (drop_A i a) (drop_Ms i ms))=(drop_M i (psi' a ms)). Intros. Rewrite <- (psitheta'psi' ms a). Rewrite <- Psi_Drop_N_Bridge. Rewrite <- Theta'_Drop_Ms_Bridge. Rewrite -> psitheta'psi'. Auto. Save. Lemma thetaphibarphi : (l:L)(theta (phibar l))=(phi l). (Induction l; Clear l; Intros; Auto). (Rewrite -> phibar_eq2; Rewrite -> phi_eq2). Rewrite <- Nsub_Theta_Bridge. (Rewrite -> H; Rewrite -> H0; Auto). (Rewrite -> phibar_eq3; Rewrite -> phi_eq3; Rewrite -> th2; Rewrite -> H; Auto). Save. Lemma psiphiphibar : (l:L)(psi (phi l))=(phibar l). Intros. Rewrite <- (psitheta (phibar l)). Rewrite -> thetaphibarphi. Auto. Save. End Bridge.Require MinMJ_Bridge. Lemma OI_Lift_V1_1: (x:V)(i,j:nat) (lt i j)-> (Occurs_In_V1 i (lift_V j x))=(Occurs_In_V1 i x). (Intros n i j H; Cut (nat_compare2 j n); Auto; Unfold nat_compare2; Intros c; Case c; [ Clear c; Intros c | Clear c; Intros c; Case c; [ Clear c; Intros c | Clear c; Intros c ] ]). (Unfold lift_V; Rewrite -> ltb_is_lt3). (Unfold Setifb; Unfold Occurs_In_V1; Rewrite -> nateqb_is_eq3). (Rewrite -> nateqb_is_eq3; Auto). (Apply lt_not_eq1; Apply lt_trans with j:=j; Auto). (Apply lt_not_eq1; Apply ltS; Apply lt_trans with j:=j; Auto). (Apply ltnotlt; Auto). (Unfold lift_V; Rewrite -> ltb_is_lt3). (Unfold Setifb; Unfold Occurs_In_V1; Rewrite -> nateqb_is_eq3). (Rewrite -> nateqb_is_eq3; Auto). (Apply lt_not_eq1; Rewrite <- c; Auto). (Rewrite <- c; Apply lt_not_eq1; Apply ltS; Auto). (Apply notltii; Auto). (Unfold lift_V; Rewrite -> ltb_is_lt1; Auto). Save. Lemma OI_Lift_V1_2: (x:V)(i,j:nat) i=j-> (Occurs_In_V1 i (lift_V j x))=false. (Intros n i j H; Rewrite <- H; Clear H). (Unfold lift_V; Cut (nat_compare2 n i); Auto; Unfold nat_compare2; Auto; Intros d; Case d; [ Clear d; Intros d | Clear d; Intros d; Case d; [ Clear d; Intros d | Clear d; Intros d ] ]). (Rewrite -> ltb_is_lt1; Auto; Simpl; Unfold Occurs_In_V1; Apply nateqb_is_eq3; Apply sym_not_equal). (Apply lt_not_eq1; Auto). Rewrite -> ltb_is_lt3. (Simpl; Unfold Occurs_In_V1; Rewrite -> d; Apply nateqb_is_eq3; Auto). (Apply notltii; Auto). Rewrite -> ltb_is_lt3. (Simpl; Unfold Occurs_In_V1; Apply nateqb_is_eq3; Apply lt_not_eq1; Apply ltS; Auto). (Apply ltnotlt; Auto). Save. Lemma OI_Lift_V1_3 : (x:V)(i,j:nat) (lt j i)-> (Occurs_In_V1 (S i) (lift_V j x))= (Occurs_In_V1 i x). (Intros n i j H; Cut (nat_compare2 j n); Auto; Intros c; Case c; [ Clear c; Intros c | Clear c; Intros c; Case c; [ Clear c; Intros c | Clear c; Intros c ] ]). (Unfold lift_V; Rewrite -> ltb_is_lt3). (Unfold Setifb; Auto; Unfold Occurs_In_V1; Auto). (Apply ltnotlt; Auto). (Rewrite <- c; Clear c n; Unfold lift_V; Rewrite -> ltb_is_lt3). (Unfold Setifb; Auto). (Apply notltii; Auto). (Unfold lift_V; Rewrite -> ltb_is_lt1; Auto; Unfold Occurs_In_V1; Unfold Setifb; Rewrite -> nateqb_is_eq3). (Rewrite -> nateqb_is_eq3; Auto). (Apply sym_not_equal; Apply lt_not_eq1; Apply lt_trans with j:=j; Auto). (Apply sym_not_equal; Apply lt_not_eq1; Apply ltS; Apply lt_trans with j:=j; Auto). Save. Lemma OI_Lift_V1_4 : (x:V)(i,j:nat) (lt j i)-> (Occurs_In_V1 i (lift_V j x))= (Occurs_In_V1 (pred i) x). Intros. Cut (or (eq ? (S j) i) (lt (S j) i)). (Intros c; Case c; Clear c; Intros). (Generalize H; Clear H; Rewrite <- H0; Clear H0 i; Intros). Clear H. Unfold pred. (Cut (nat_compare2 j x); Auto; Unfold lift_V; Unfold nat_compare2; Intros c; Case c; Clear c; Intros). Rewrite -> ltb_is_lt3. Unfold Setifb. (Unfold Occurs_In_V1; Auto). (Apply ltnotlt; Auto). (Case H; Clear H; Intros). (Rewrite <- H; Clear H x; Rewrite -> ltb_is_lt3). Auto. (Apply notltii; Auto). (Rewrite -> ltb_is_lt1; Auto; Unfold Occurs_In_V1; Unfold Setifb ). Rewrite -> nateqb_is_eq3. (Rewrite -> nateqb_is_eq3; Auto). (Apply sym_not_equal; Apply lt_not_eq1; Auto). (Apply sym_not_equal; Apply lt_not_eq1; Apply ltS; Auto). (Clear H; Inversion_clear H0). (Unfold pred; Apply OI_Lift_V1_3; Auto). (Apply lt_S_le; Auto). Save. Definition oi_lift_m1_1: M->Prop := [m:M](i,j:nat) (lt i j)->(Occurs_In_M1 i (lift_M j m))=(Occurs_In_M1 i m). Definition oi_lift_ms1_1: Ms->Prop := [ms:Ms](i,j:nat) (lt i j)-> (Occurs_In_Ms1 i (lift_Ms j ms))=(Occurs_In_Ms1 i ms). Lemma oi_lift_M1_1 : ((m:M)(oi_lift_m1_1 m))/\ ((ms:Ms)(oi_lift_ms1_1 ms)). (Apply M_Ms_ind; Unfold oi_lift_ms1_1; Unfold oi_lift_m1_1; Intros; Auto). (Rewrite -> LIFTM1; Rewrite -> OIM1; Rewrite -> OIM1). (Rewrite -> OI_Lift_V1_1; Auto; Rewrite -> H; Auto). (Rewrite -> LIFTM2; Rewrite -> OIM2; Rewrite -> H; Auto). (Rewrite -> LIFTM4; Rewrite -> OIM4; Rewrite -> H; Auto; Rewrite -> H0; Auto). Save. Lemma OI_Lift_M1_1: (m:M)(i,j:nat) (lt i j)-> (Occurs_In_M1 i (lift_M j m))=(Occurs_In_M1 i m). Cut ((m:M)(oi_lift_m1_1 m))/\ ((ms:Ms)(oi_lift_ms1_1 ms)). Intros c; Case c; Auto. Exact oi_lift_M1_1. Save. Lemma OI_Lift_Ms1_1: (ms:Ms)(i,j:nat) (lt i j)-> (Occurs_In_Ms1 i (lift_Ms j ms))=(Occurs_In_Ms1 i ms). Cut ((m:M)(oi_lift_m1_1 m))/\ ((ms:Ms)(oi_lift_ms1_1 ms)). Intros c; Case c; Auto. Exact oi_lift_M1_1. Save. Definition oi_lift_m1_2: M->Prop := [m:M](i,j:nat) i=j->(Occurs_In_M1 i (lift_M j m))=false. Definition oi_lift_ms1_2: Ms->Prop := [ms:Ms](i,j:nat) i=j->(Occurs_In_Ms1 i (lift_Ms j ms))=false. Lemma oi_lift_M1_2 : ((m:M)(oi_lift_m1_2 m))/\ ((ms:Ms)(oi_lift_ms1_2 ms)). (Apply M_Ms_ind; Unfold oi_lift_ms1_2; Unfold oi_lift_m1_2; Intros; Auto). (Rewrite -> LIFTM1; Rewrite -> OIM1; Rewrite -> H; Auto; Rewrite -> OI_Lift_V1_2; Auto). (Rewrite -> LIFTM2; Rewrite -> OIM2; Rewrite -> H; Auto). (Rewrite -> LIFTM4; Rewrite -> OIM4; Rewrite -> H; Auto; Rewrite -> H0; Auto). Save. Lemma OI_Lift_M1_2: (m:M)(i,j:nat) i=j-> (Occurs_In_M1 i (lift_M j m))=false. Cut ((m:M)(oi_lift_m1_2 m))/\ ((ms:Ms)(oi_lift_ms1_2 ms)). Intros c; Case c; Auto. Exact oi_lift_M1_2. Save. Lemma OI_Lift_Ms1_2: (ms:Ms)(i,j:nat) i=j-> (Occurs_In_Ms1 i (lift_Ms j ms))=false. Cut ((m:M)(oi_lift_m1_2 m))/\ ((ms:Ms)(oi_lift_ms1_2 ms)). Intros c; Case c; Auto. Exact oi_lift_M1_2. Save. Definition oi_lift_m1_3: M->Prop := [m:M](i,j:nat) (lt j i)-> (Occurs_In_M1 (S i) (lift_M j m))=(Occurs_In_M1 i m). Definition oi_lift_ms1_3: Ms->Prop := [ms:Ms](i,j:nat) (lt j i)-> (Occurs_In_Ms1 (S i) (lift_Ms j ms))=(Occurs_In_Ms1 i ms). Lemma oi_lift_M1_3 : ((m:M)(oi_lift_m1_3 m))/\ ((ms:Ms)(oi_lift_ms1_3 ms)). (Apply M_Ms_ind; Unfold oi_lift_m1_3; Unfold oi_lift_ms1_3; Intros; Auto). (Rewrite -> LIFTM1; Rewrite -> OIM1; Rewrite -> H; Auto; Rewrite -> OI_Lift_V1_3; Auto). (Rewrite -> LIFTM2; Rewrite -> OIM2; Rewrite -> H; Auto). (Rewrite -> LIFTM4; Rewrite -> OIM4; Rewrite -> H; Auto; Rewrite -> H0; Auto). Save. Lemma OI_Lift_M1_3: (m:M)(i,j:nat) (lt j i)-> (Occurs_In_M1 (S i) (lift_M j m))=(Occurs_In_M1 i m). Cut ((m:M)(oi_lift_m1_3 m))/\ ((ms:Ms)(oi_lift_ms1_3 ms)). Intros c; Case c; Auto. Exact oi_lift_M1_3. Save. Lemma OI_Lift_Ms1_3: (ms:Ms)(i,j:nat) (lt j i)-> (Occurs_In_Ms1 (S i) (lift_Ms j ms))=(Occurs_In_Ms1 i ms). Cut ((m:M)(oi_lift_m1_3 m))/\ ((ms:Ms)(oi_lift_ms1_3 ms)). Intros c; Case c; Auto. Exact oi_lift_M1_3. Save. Definition oi_lift_m1_4: M->Prop := [m:M](i,j:nat) (lt j i)-> (Occurs_In_M1 i (lift_M j m))=(Occurs_In_M1 (pred i) m). Definition oi_lift_ms1_4: Ms->Prop := [ms:Ms](i,j:nat) (lt j i)-> (Occurs_In_Ms1 i (lift_Ms j ms))= (Occurs_In_Ms1 (pred i) ms). Lemma oi_lift_M1_4 : ((m:M)(oi_lift_m1_4 m))/\ ((ms:Ms)(oi_lift_ms1_4 ms)). (Apply M_Ms_ind; Unfold oi_lift_ms1_4; Unfold oi_lift_m1_4; Intros; Auto). (Rewrite -> LIFTM1; Rewrite -> OIM1; Rewrite -> H; Auto; Rewrite -> OI_Lift_V1_4; Auto). (Rewrite -> LIFTM2; Rewrite -> OIM2; Rewrite -> H; Auto; Inversion_clear H0; Auto). (Rewrite -> LIFTM4; Rewrite -> OIM4; Rewrite -> H; Auto; Rewrite -> H0; Auto). Save. Lemma OI_Lift_M1_4 : (m:M)(i,j:nat) (lt j i)-> (Occurs_In_M1 i (lift_M j m))=(Occurs_In_M1 (pred i) m). Cut ((m:M)(oi_lift_m1_4 m))/\ ((ms:Ms)(oi_lift_ms1_4 ms)). Intros c; Case c; Auto. Exact oi_lift_M1_4. Save. Lemma OI_Lift_Ms1_4 : (ms:Ms)(i,j:nat) (lt j i)-> (Occurs_In_Ms1 i (lift_Ms j ms))= (Occurs_In_Ms1 (pred i) ms). Cut ((m:M)(oi_lift_m1_4 m))/\ ((ms:Ms)(oi_lift_ms1_4 ms)). Intros c; Case c; Auto. Exact oi_lift_M1_4. Save. Definition oi_lift_n1_1: N->Prop := [n:N](i,j:nat) (lt i j)->(Occurs_In_N1 i (lift_N j n))=(Occurs_In_N1 i n). Definition oi_lift_a1_1: A->Prop := [a:A](i,j:nat) (lt i j)->(Occurs_In_A1 i (lift_A j a))=(Occurs_In_A1 i a). Lemma oi_lift_N1_1 : ((n:N)(oi_lift_n1_1 n))/\ ((a:A)(oi_lift_a1_1 a)). (Apply N_A_ind; Unfold oi_lift_n1_1; Unfold oi_lift_a1_1; Intros). (Rewrite -> LIFTN1; Rewrite -> OIN1; Rewrite -> H; Auto). (Rewrite -> LIFTN2; Rewrite -> OIN2; Rewrite -> H; Auto). (Rewrite -> LIFTN3; Rewrite -> OIN3; Rewrite -> H; Auto; Rewrite -> H0; Auto). (Rewrite -> LIFTN4; Rewrite -> OIN4; Rewrite -> OI_Lift_V1_1; Auto). Save. Lemma OI_Lift_N1_1: (n:N)(i,j:nat) (lt i j)-> (Occurs_In_N1 i (lift_N j n))=(Occurs_In_N1 i n). Cut ((n:N)(oi_lift_n1_1 n))/\ ((a:A)(oi_lift_a1_1 a)). Intros c; Case c; Auto. Exact oi_lift_N1_1. Save. Lemma OI_Lift_A1_1: (a:A)(i,j:nat) (lt i j)-> (Occurs_In_A1 i (lift_A j a))=(Occurs_In_A1 i a). Cut ((n:N)(oi_lift_n1_1 n))/\ ((a:A)(oi_lift_a1_1 a)). Intros c; Case c; Auto. Exact oi_lift_N1_1. Save. Definition oi_lift_n1_2 : N->Prop := [n:N](i,j:nat) i=j->(Occurs_In_N1 i (lift_N j n))=false. Definition oi_lift_a1_2 : A->Prop := [a:A](i,j:nat) i=j->(Occurs_In_A1 i (lift_A j a))=false. Lemma oi_lift_N1_2 : ((n:N)(oi_lift_n1_2 n))/\ ((a:A)(oi_lift_a1_2 a)). (Apply N_A_ind; Unfold oi_lift_n1_2; Unfold oi_lift_a1_2; Intros). (Rewrite -> LIFTN1; Rewrite -> OIN1; Rewrite -> H; Auto). (Rewrite -> LIFTN2; Rewrite -> OIN2; Rewrite -> H; Auto). (Rewrite -> LIFTN3; Rewrite -> OIN3; Rewrite -> H; Auto; Rewrite -> H0; Auto). (Rewrite -> LIFTN4; Rewrite -> OIN4; Rewrite -> OI_Lift_V1_2; Auto). Save. Lemma OI_Lift_N1_2: (n:N)(i,j:nat) i=j-> (Occurs_In_N1 i (lift_N j n))=false. Cut ((n:N)(oi_lift_n1_2 n))/\ ((a:A)(oi_lift_a1_2 a)). Intros c; Case c; Auto. Exact oi_lift_N1_2. Save. Lemma OI_Lift_A1_2: (a:A)(i,j:nat) i=j-> (Occurs_In_A1 i (lift_A j a))=false. Cut ((n:N)(oi_lift_n1_2 n))/\ ((a:A)(oi_lift_a1_2 a)). Intros c; Case c; Auto. Exact oi_lift_N1_2. Save. Definition oi_lift_n1_3: N->Prop := [n:N](i,j:nat) (lt j i)-> (Occurs_In_N1 (S i) (lift_N j n))=(Occurs_In_N1 i n). Definition oi_lift_a1_3: A->Prop := [a:A](i,j:nat) (lt j i)-> (Occurs_In_A1 (S i) (lift_A j a))=(Occurs_In_A1 i a). Lemma oi_lift_N1_3 : ((n:N)(oi_lift_n1_3 n))/\ ((a:A)(oi_lift_a1_3 a)). (Apply N_A_ind; Unfold oi_lift_n1_3; Unfold oi_lift_a1_3; Intros). (Rewrite -> LIFTN1; Rewrite -> OIN1; Rewrite -> H; Auto). (Rewrite -> LIFTN2; Rewrite -> OIN2; Rewrite -> H; Auto). (Rewrite -> LIFTN3; Rewrite -> OIN3; Rewrite -> H; Auto; Rewrite -> H0; Auto). (Rewrite -> LIFTN4; Rewrite -> OIN4; Rewrite -> OI_Lift_V1_3; Auto). Save. Lemma OI_Lift_N1_3 : (n:N)(i,j:nat) (lt j i)-> (Occurs_In_N1 (S i) (lift_N j n))=(Occurs_In_N1 i n). Cut ((n:N)(oi_lift_n1_3 n))/\ ((a:A)(oi_lift_a1_3 a)). Intros c; Case c; Auto. Exact oi_lift_N1_3. Save. Lemma OI_Lift_A1_3 : (a:A)(i,j:nat) (lt j i)-> (Occurs_In_A1 (S i) (lift_A j a))=(Occurs_In_A1 i a). Cut ((n:N)(oi_lift_n1_3 n))/\ ((a:A)(oi_lift_a1_3 a)). Intros c; Case c; Auto. Exact oi_lift_N1_3. Save. Definition oi_lift_n1_4: N->Prop := [n:N](i,j:nat) (lt j i)-> (Occurs_In_N1 i (lift_N j n))=(Occurs_In_N1 (pred i) n). Definition oi_lift_a1_4: A->Prop := [a:A](i,j:nat) (lt j i)-> (Occurs_In_A1 i (lift_A j a))=(Occurs_In_A1 (pred i) a). Lemma oi_lift_N1_4 : ((n:N)(oi_lift_n1_4 n))/\ ((a:A)(oi_lift_a1_4 a)). (Apply N_A_ind; Unfold oi_lift_n1_4; Unfold oi_lift_a1_4; Intros). (Rewrite -> LIFTN1; Rewrite -> OIN1; Rewrite -> H; Auto; Inversion_clear H0; Auto). (Rewrite -> LIFTN2; Rewrite -> OIN2; Rewrite -> H; Auto). (Rewrite -> LIFTN3; Rewrite -> OIN3; Rewrite -> H; Auto; Rewrite -> H0; Auto). (Rewrite -> LIFTN4; Rewrite -> OIN4; Rewrite -> OI_Lift_V1_4; Auto). Save. Lemma OI_Lift_N1_4 : (n:N)(i,j:nat) (lt j i)-> (Occurs_In_N1 i (lift_N j n))=(Occurs_In_N1 (pred i) n). Cut ((n:N)(oi_lift_n1_4 n))/\ ((a:A)(oi_lift_a1_4 a)). Intros c; Case c; Auto. Exact oi_lift_N1_4. Save. Lemma OI_Lift_A1_4 : (a:A)(i,j:nat) (lt j i)-> (Occurs_In_A1 i (lift_A j a))=(Occurs_In_A1 (pred i) a). Cut ((n:N)(oi_lift_n1_4 n))/\ ((a:A)(oi_lift_a1_4 a)). Intros c; Case c; Auto. Exact oi_lift_N1_4. Save. Lemma OI_Lift_L1_4 : (l:L)(i,j:nat) (lt j i)-> (Occurs_In_L1 i (lift_L j l))= (Occurs_In_L1 (pred i) l). (Induction l; Clear l; Intros; Simpl). (Rewrite -> OI_Lift_V1_4; Auto). (Rewrite -> H; Auto; Rewrite -> H0; Auto). (Rewrite -> OI_Lift_V1_4; Auto). (Inversion_clear H1; Auto). (Rewrite -> H; Inversion_clear H0; Auto). Save. Definition noi_msub_b_bridge : M->Prop := [m:M](x:V)(m1:M)(i:nat) ~(Occurs_In_M i m)-> (MsubstVMV x m1 i m)=(drop_M i m). Definition noi_mssub_b_bridge : Ms->Prop := [ms:Ms](x:V)(m1:M)(i:nat) ~(Occurs_In_Ms i ms)-> (MssubstVMV x m1 i ms)=(drop_Ms i ms). Lemma noi_msub_b_Bridge : ((m:M)(noi_msub_b_bridge m))/\ ((ms:Ms)(noi_mssub_b_bridge ms)). (Apply M_Ms_ind; Unfold noi_msub_b_bridge; Unfold noi_mssub_b_bridge; Intros; Auto). (Rewrite -> MSVMV1; Rewrite -> nateqb_is_eq3). (Unfold Setifb; Rewrite -> H; Auto). (Unfold not; Intros; Apply H0; Auto). (Unfold not; Intros; Apply H0; Auto). (Rewrite -> MSVMV2; Rewrite -> H; Auto). (Unfold not; Intros; Apply H0; Auto). (Rewrite -> MSVMV4; Rewrite -> H; Auto). (Rewrite -> H0; Auto). (Unfold not; Intros; Apply H1; Auto). (Unfold not; Intros; Apply H1; Auto). Save. Lemma NOI_Msub_Bridge : (m:M)(x:V)(m1:M)(i:nat) ~(Occurs_In_M i m)-> (MsubstVMV x m1 i m)=(drop_M i m). Cut ((m:M)(noi_msub_b_bridge m))/\ ((ms:Ms)(noi_mssub_b_bridge ms)). Intros c; Case c; Auto. Exact noi_msub_b_Bridge. Save. Lemma NOI_Mssub_Bridge : (ms:Ms)(x:V)(m1:M)(i:nat) ~(Occurs_In_Ms i ms)-> (MssubstVMV x m1 i ms)=(drop_Ms i ms). Cut ((m:M)(noi_msub_b_bridge m))/\ ((ms:Ms)(noi_mssub_b_bridge ms)). Intros c; Case c; Auto. Exact noi_msub_b_Bridge. Save. Lemma Lift_Drop_V_Bridge1 : (x:V)(i,j:nat) (lt j i)-> ~(Occurs_In_V j x)-> (lift_V i (drop_V j x))= (drop_V j (lift_V (S i) x)). (Intros k i j H H0; Unfold 1 drop_V; Unfold 2 lift_V; Cut (nat_compare2 k (S i)); Auto; Unfold nat_compare2; Intros c; Case c; Clear c; Intros). (Cut (nat_compare2 k j); Auto; Unfold nat_compare2; Intros c; Case c; Clear c; Intros). (Rewrite -> ltb_is_lt1; Auto; Rewrite -> ltb_is_lt1; Auto). (Unfold Setifb; Unfold lift_V; Unfold drop_V ). Cut (or (eq ? (S k) (S i)) (lt (S k) (S i))). (Intros c; Case c; Clear c; Intros). (Injection H3; Clear H3; Intros). Cut False. Contradiction. (Cut (not (lt k j)); Intros). (Apply H4; Auto). (Rewrite -> H3; Apply ltnotlt; Auto). (Inversion_clear H3; Rewrite -> ltb_is_lt1; Auto; Rewrite -> ltb_is_lt1; Auto). (Apply lt_S_le; Auto). (Case H2; Clear H2; Intros). Cut False. Contradiction. (Apply H0; Auto). Rewrite -> ltb_is_lt3. (Rewrite -> ltb_is_lt1; Auto; Unfold Setifb; Unfold lift_V; Unfold drop_V ). Rewrite -> ltb_is_lt1. Rewrite -> ltb_is_lt3. Auto. (Apply ltnotlt; Auto). (Generalize H1; Clear H1; Inversion_clear H2; Simpl; Intros). (Inversion_clear H1; Auto). (Inversion_clear H2; Auto). (Apply ltnotlt; Auto). (Case H1; Clear H1; Intros). Rewrite -> ltb_is_lt3. Rewrite -> ltb_is_lt3. (Rewrite -> H1; Unfold pred; Unfold Setifb; Unfold lift_V; Unfold drop_V ). Rewrite -> ltb_is_lt3. (Rewrite -> ltb_is_lt3; Auto). (Apply ltnotlt; Apply ltS; Apply ltS; Auto). (Apply notltii; Auto). (Apply notltii; Auto). (Rewrite -> H1; Apply ltnotlt; Apply ltS; Auto). Rewrite -> ltb_is_lt3. Rewrite -> ltb_is_lt3. (Unfold Setifb; Unfold lift_V; Unfold drop_V ). Rewrite -> ltb_is_lt3. Rewrite -> ltb_is_lt3. (Inversion_clear H1; Auto). (Apply ltnotlt; Apply lt_trans with j:=(S i); Auto). (Apply ltS; Auto). (Apply Slt; Auto). (Apply lt_not_ltpred; Apply Slt; Auto). (Apply ltnotlt; Auto). (Apply ltnotlt; Apply lt_trans with j:=(S i); Auto; Apply ltS; Auto). Save. Definition lift_drop_n_bridge1 : N->Prop := [n:N](i,j:nat) (lt j i)-> ~(Occurs_In_N j n)-> (lift_N i (drop_N j n))= (drop_N j (lift_N (S i) n)). Definition lift_drop_a_bridge1 : A->Prop := [a:A](i,j:nat) (lt j i)-> ~(Occurs_In_A j a)-> (lift_A i (drop_A j a))= (drop_A j (lift_A (S i) a)). Lemma lift_drop_n_Bridge1 : ((n:N)(lift_drop_n_bridge1 n))/\((a:A)(lift_drop_a_bridge1 a)). (Apply N_A_ind; Unfold lift_drop_n_bridge1; Unfold lift_drop_a_bridge1; Intros). (Rewrite -> DROPN1; Rewrite -> LIFTN1; Rewrite -> LIFTN1; Rewrite -> DROPN1; Rewrite -> H; Auto; Unfold not in H1; Unfold not; Intros; Apply H1; Auto). (Rewrite -> DROPN2; Rewrite -> LIFTN2; Rewrite -> LIFTN2; Rewrite -> DROPN2; Rewrite -> H; Auto; Unfold not in H1; Unfold not; Intros; Apply H1; Auto). (Rewrite -> DROPN3; Rewrite -> LIFTN3; Rewrite -> LIFTN3; Rewrite -> DROPN3). (Rewrite -> H; Auto). (Rewrite -> H0; Auto; Unfold not in H2; Unfold not; Intros; Apply H2; Auto). (Unfold not in H2; Unfold not; Intros; Apply H2; Auto). (Rewrite -> DROPN4; Rewrite -> LIFTN4; Rewrite -> LIFTN4; Rewrite -> DROPN4; Rewrite -> Lift_Drop_V_Bridge1; Auto). (Unfold not in H0; Unfold not; Intros; Apply H0; Auto). Save. Lemma Lift_Drop_N_Bridge1 : (n:N)(i,j:nat) (lt j i)-> ~(Occurs_In_N j n)-> (lift_N i (drop_N j n))= (drop_N j (lift_N (S i) n)). Cut ((n:N)(lift_drop_n_bridge1 n))/\((a:A)(lift_drop_a_bridge1 a)). Unfold lift_drop_n_bridge1; Intros c; Case c; Intros; Auto. Exact lift_drop_n_Bridge1. Save. Lemma Lift_Drop_A_Bridge1 : (a:A)(i,j:nat) (lt j i)-> ~(Occurs_In_A j a)-> (lift_A i (drop_A j a))= (drop_A j (lift_A (S i) a)). Cut ((n:N)(lift_drop_n_bridge1 n))/\((a:A)(lift_drop_a_bridge1 a)). Unfold lift_drop_a_bridge1; Intros c; Case c; Intros; Auto. Exact lift_drop_n_Bridge1. Save. Lemma Drop_Lift_V_Bridge1 : (x:V)(i,j:nat) ~(Occurs_In_V i x)-> (lt j (S i))-> (drop_V (S i) (lift_V j x))= (lift_V j (drop_V i x)). Intros. Cut ~i=x. (Clear H; Intros). Unfold 1 lift_V. (Cut (nat_compare2 x j); Auto; Unfold nat_compare2; Intros c; Case c; Clear c; Intros). (Rewrite -> ltb_is_lt1; Auto; Unfold Setifb; Unfold drop_V). Rewrite -> ltb_is_lt1. Rewrite -> ltb_is_lt1. (Simpl; Unfold lift_V). (Rewrite -> ltb_is_lt1; Auto). (Apply lt_trans3 with j:=j; Auto). (Apply lt_trans with j:=j; Auto). Rewrite -> ltb_is_lt3. (Simpl; Unfold drop_V; Simpl). (Case H1; Clear H1; Intros). Rewrite -> ltb_is_lt1. (Simpl; Unfold lift_V). (Rewrite -> ltb_is_lt3; Auto). (Apply notltii; Auto). (Apply ltS_neq_lt; Auto; Rewrite -> H1; Auto). (Cut (nat_compare2 x i); Auto; Unfold nat_compare2; Intros c; Case c; Clear c; Intros). (Rewrite -> ltb_is_lt1; Auto; Simpl; Unfold lift_V). (Rewrite -> ltb_is_lt3; Auto; Apply ltnotlt; Auto). Rewrite -> ltb_is_lt3. (Simpl; Unfold lift_V). Rewrite -> ltb_is_lt3. (Inversion_clear H1; Auto). (Apply lt_not_ltpred; Auto). (Case H2; Clear H2; Intros). (Apply notltii; Auto). (Apply ltnotlt; Auto). (Case H1; Clear H1; Intros). (Apply notltii; Auto). (Apply ltnotlt; Auto). (Unfold not; Intros; Apply H; Auto). Save. Definition drop_lift_n_bridge1 : N->Prop := [n:N](i,j:nat) ~(Occurs_In_N i n)-> (lt j (S i))-> (drop_N (S i) (lift_N j n))= (lift_N j (drop_N i n)). Definition drop_lift_a_bridge1 : A->Prop := [a:A](i,j:nat) ~(Occurs_In_A i a)-> (lt j (S i))-> (drop_A (S i) (lift_A j a))= (lift_A j (drop_A i a)). Lemma drop_lift_n_Bridge1 : ((n:N)(drop_lift_n_bridge1 n))/\ ((a:A)(drop_lift_a_bridge1 a)). (Apply N_A_ind; Unfold drop_lift_n_bridge1; Unfold drop_lift_a_bridge1; Intros; Auto). (Simpl; Rewrite -> H; Auto). (Unfold not; Intros; Apply H0; Auto). (Rewrite -> LIFTN2; Rewrite -> DROPN2; Rewrite -> H; Auto). (Unfold not; Intros; Apply H0; Auto). (Rewrite -> LIFTN3; Rewrite -> DROPN3; Rewrite -> H; Auto). (Rewrite -> H0; Auto). (Unfold not; Intros; Apply H1; Auto). (Unfold not; Intros; Apply H1; Auto). (Simpl; Rewrite -> Drop_Lift_V_Bridge1; Auto). (Unfold not; Intros; Apply H; Auto). Save. Lemma Drop_Lift_N_Bridge1 : (n:N)(i,j:nat) ~(Occurs_In_N i n)-> (lt j (S i))-> (drop_N (S i) (lift_N j n))= (lift_N j (drop_N i n)). Cut ((n:N)(drop_lift_n_bridge1 n))/\ ((a:A)(drop_lift_a_bridge1 a)). Intros c; Case c; Auto. Exact drop_lift_n_Bridge1. Save. Lemma Drop_Lift_A_Bridge1 : (a:A)(i,j:nat) ~(Occurs_In_A i a)-> (lt j (S i))-> (drop_A (S i) (lift_A j a))= (lift_A j (drop_A i a)). Cut ((n:N)(drop_lift_n_bridge1 n))/\ ((a:A)(drop_lift_a_bridge1 a)). Intros c; Case c; Auto. Exact drop_lift_n_Bridge1. Save. Lemma Lift_Vsub_Bridge0 : (x:V)(i,j:nat)(a:A) (lt i j)-> (lift_A j (VsubstAV a i x))= (VsubstAV (lift_A j a) i (lift_V (S j) x)). (Intros n i j a H; Unfold 1 VsubstAV; Cut (nat_compare2 i n); Auto; Unfold nat_compare2; Intros c; Case c; Clear c; Intros). Rewrite -> nateqb_is_eq3. Unfold Setifb. Unfold drop_V. Rewrite -> ltb_is_lt3. Unfold Setifb. (Rewrite -> LIFTN4; Unfold lift_V ). (Cut (nat_compare2 n (S j)); Auto; Unfold nat_compare2; Intros c; Case c; Clear c; Intros). (Rewrite -> ltb_is_lt1; Auto). (Rewrite -> ltb_is_lt1; Auto). Unfold Setifb. Unfold VsubstAV. Rewrite -> nateqb_is_eq3. (Unfold Setifb; Unfold drop_V ). (Rewrite -> ltb_is_lt3; Auto). (Apply ltnotlt; Auto). (Apply lt_not_eq1; Auto). (Generalize H1; Clear H1; Inversion_clear H0; Auto). Simpl. Intros. (Inversion_clear H1; Auto). Simpl. Intros. (Inversion_clear H0; Auto). (Case H1; Clear H1; Intros). Rewrite -> H1. Unfold pred. Rewrite -> ltb_is_lt3. Rewrite -> ltb_is_lt3. Unfold Setifb. Unfold VsubstAV. Rewrite -> nateqb_is_eq3. (Unfold Setifb; Unfold drop_V ). Rewrite -> ltb_is_lt3. (Unfold Setifb; Auto). (Apply ltnotlt; Apply ltS; Apply ltS; Auto). (Apply lt_not_eq1; Apply ltS; Apply ltS; Auto). (Apply notltii; Auto). (Apply notltii; Auto). Rewrite -> ltb_is_lt3. Rewrite -> ltb_is_lt3. Unfold Setifb. Unfold VsubstAV. Rewrite -> nateqb_is_eq3. (Unfold Setifb; Unfold drop_V ). Rewrite -> ltb_is_lt3. (Unfold Setifb; Inversion_clear H1; Auto). (Apply ltnotlt; Apply ltS; Auto). (Apply lt_not_eq1; Apply ltS; Auto). (Apply ltnotlt; Auto). (Apply lt_not_ltpred; Auto). (Apply Slt; Auto). (Apply ltnotlt; Auto). (Apply lt_not_eq1; Auto). (Case H0; Clear H0; Intros). (Rewrite -> nateqb_is_eq1; Auto). Unfold Setifb. Unfold lift_V. (Rewrite -> ltb_is_lt1; Auto). (Unfold Setifb; Unfold VsubstAV ). (Rewrite -> nateqb_is_eq1; Auto). (Rewrite <- H0; Apply ltS; Auto). Rewrite -> nateqb_is_eq3. (Unfold Setifb; Unfold drop_V ). Unfold lift_V. (Rewrite -> ltb_is_lt1; Auto). Rewrite -> ltb_is_lt1. Unfold Setifb. Unfold VsubstAV. Rewrite -> nateqb_is_eq3. Unfold Setifb. Unfold drop_V. (Rewrite -> ltb_is_lt1; Auto). Unfold Setifb. Rewrite -> LIFTN4. Unfold lift_V. (Rewrite -> ltb_is_lt1; Auto). (Apply lt_trans with j:=i; Auto). (Apply sym_not_equal; Apply lt_not_eq1; Auto). (Apply lt_trans with j:=i; Auto; Apply ltS; Auto). (Apply sym_not_equal; Apply lt_not_eq1; Auto). Save. Definition lift_nsub_b_bridge0 : N->Prop := [n:N](i,j:nat)(a:A) (lt i j)-> (lift_N j (NsubstAV a i n))= (NsubstAV (lift_A j a) i (lift_N (S j) n)). Definition lift_asub_b_bridge0 : A->Prop := [a:A](i,j:nat)(a1:A) (lt i j)-> (lift_A j (AsubstAV a1 i a))= (AsubstAV (lift_A j a1) i (lift_A (S j) a)). Lemma lift_nsub_b_Bridge0 : ((n:N)(lift_nsub_b_bridge0 n))/\ ((a:A)(lift_asub_b_bridge0 a)). (Apply N_A_ind; Unfold lift_nsub_b_bridge0; Unfold lift_asub_b_bridge0; Intros). (Rewrite -> NSAV1; Rewrite -> LIFTN1; Rewrite -> H; Auto; Rewrite <- Lift_Lift_A_Bridge; Auto; Inversion_clear H0; Auto). (Rewrite -> NSAV2; Rewrite -> LIFTN2; Rewrite -> H; Auto). (Rewrite -> NSAV3; Rewrite -> LIFTN3; Rewrite -> H; Auto; Rewrite -> H0; Auto). (Rewrite -> NSAV4; Rewrite -> LIFTN4; Rewrite -> Lift_Vsub_Bridge0; Auto). Save. Lemma Lift_Nsub_Bridge0 : (n:N)(i,j:nat)(a:A) (lt i j)-> (lift_N j (NsubstAV a i n))= (NsubstAV (lift_A j a) i (lift_N (S j) n)). Cut ((n:N)(lift_nsub_b_bridge0 n))/\ ((a:A)(lift_asub_b_bridge0 a)). Unfold lift_nsub_b_bridge0. Intros c; Case c; Intros; Auto. Exact lift_nsub_b_Bridge0. Save. Lemma Lift_Asub_Bridge0 : (a:A)(i,j:nat)(a1:A) (lt i j)-> (lift_A j (AsubstAV a1 i a))= (AsubstAV (lift_A j a1) i (lift_A (S j) a)). Cut ((n:N)(lift_nsub_b_bridge0 n))/\ ((a:A)(lift_asub_b_bridge0 a)). Unfold lift_asub_b_bridge0. Intros c; Case c; Intros; Auto. Exact lift_nsub_b_Bridge0. Save. Lemma Lift_Msub_Bridge0 : (x:V)(m,m0:M)(i,j:nat) (lt i j)-> (lift_M j (MsubstVMV x m i m0))= (MsubstVMV (lift_V j x) (lift_M j m) i (lift_M (S j) m0)). (Intros; Rewrite <- (psitheta m0); Rewrite <- (psitheta m); Rewrite -> Msub_Psi_Bridge; Rewrite -> Lift_Psi_Bridge; Rewrite -> Lift_Nsub_Bridge0; Auto; Rewrite -> LIFTN3; Rewrite -> (Lift_Theta_Bridge m0); Rewrite -> Lift_Theta_Bridge; Rewrite -> LIFTN4; Rewrite <- Msub_Psi_Bridge; Rewrite -> psitheta; Rewrite -> psitheta; Rewrite -> psitheta; Rewrite -> psitheta; Auto). Save. Lemma Lift_Mssub_Bridge0 : (x:V)(m:M)(ms:Ms)(i,j:nat) (lt i j)-> (lift_Ms j (MssubstVMV x m i ms))= (MssubstVMV (lift_V j x) (lift_M j m) i (lift_Ms (S j) ms)). (Induction ms; Intros; Auto; Clear ms; Rewrite -> MSVMV4; Rewrite -> LIFTM4; Rewrite -> Lift_Msub_Bridge0; Auto; Rewrite -> H; Auto). Save. Definition lift_msub_bridge2 : M->Prop := [m:M](x,y:V)(m1:M) (MsubstVMV x m1 (S y) (lift_M y (lift_M (S y) m)))= (MsubstVMV x m1 y (lift_M (S (S y)) (lift_M (S y) m))). Definition lift_mssub_bridge2 : Ms->Prop := [ms:Ms](x,y:V)(m1:M) (MssubstVMV x m1 (S y) (lift_Ms y (lift_Ms (S y) ms)))= (MssubstVMV x m1 y (lift_Ms (S (S y)) (lift_Ms (S y) ms))). Lemma Lift_msub_bridge2 : ((m:M)(lift_msub_bridge2 m))/\ ((ms:Ms)(lift_mssub_bridge2 ms)). (Apply M_Ms_ind; Unfold lift_msub_bridge2; Unfold lift_mssub_bridge2; Auto; Intros). (Repeat Rewrite -> LIFTM1; Unfold 2 4 lift_V; Cut (nat_compare2 (S y) v); [ Destruct 1; [ Intro | Destruct 1; Intro ] | Auto ]). (Rewrite -> ltb_is_lt3; Unfold Setifb; Unfold lift_V). (Repeat Rewrite -> ltb_is_lt3; Unfold Setifb). Repeat Rewrite -> MSVMV1. (Repeat Rewrite -> nateqb_is_eq3; Unfold Setifb; Unfold drop_V). (Repeat Rewrite -> ltb_is_lt3; Unfold Setifb; Unfold pred). (Rewrite -> H; Auto). (Apply ltnotlt; Apply ltS; Apply ltS; Apply Slt; Auto). (Apply ltnotlt; Apply ltS; Apply ltS; Auto). (Apply lt_not_eq1; Apply ltS; Apply ltS; Apply Slt; Auto). (Apply lt_not_eq1; Apply ltS; Apply ltS; Auto). (Apply ltnotlt; Auto). (Apply ltnotlt; Apply ltS; Apply Slt; Auto). (Apply ltnotlt; Auto). (Rewrite <- H2; Clear H0 H1 H2 v). (Rewrite -> ltb_is_lt3; Unfold Setifb; Unfold lift_V). (Repeat Rewrite -> ltb_is_lt3; Unfold Setifb). (Repeat Rewrite -> MSVMV1; Repeat Rewrite -> nateqb_is_eq3; Unfold Setifb). Unfold drop_V. (Repeat Rewrite -> ltb_is_lt3; Unfold Setifb). (Rewrite -> H; Auto). (Apply ltnotlt; Apply ltS; Apply ltS; Apply ltiSi; Auto). (Apply ltnotlt; Apply ltS; Apply ltiSi; Auto). (Apply lt_not_eq1; Apply ltS; Apply ltS; Apply ltiSi; Auto). (Apply lt_not_eq1; Apply ltS; Apply ltiSi; Auto). (Apply notltii; Auto). (Apply ltnotlt; Apply ltS; Apply ltiSi; Auto). (Apply notltii; Auto). Clear H0 H1. (Rewrite -> ltb_is_lt1; Auto; Unfold Setifb; Unfold lift_V). (Cut (nat_compare v y); [ Destruct 1; Intro | Auto ]). Rewrite -> ltb_is_lt3. (Rewrite -> ltb_is_lt1; Unfold Setifb). Repeat Rewrite -> MSVMV1. (Repeat Rewrite -> nateqb_is_eq1; Auto). Unfold Setifb. (Rewrite -> H1; Rewrite -> H; Auto). (Rewrite -> H1; Apply ltS; Auto). (Apply notltii; Auto). (Repeat Rewrite -> ltb_is_lt1; Unfold Setifb). Repeat Rewrite -> MSVMV1. (Repeat Rewrite -> nateqb_is_eq3; Auto; Unfold Setifb; Unfold drop_V). (Repeat Rewrite -> ltb_is_lt1; Auto; Unfold Setifb). (Rewrite -> H; Auto). (Apply ltS_neq_lt; Auto). (Apply sym_not_equal; Apply lt_not_eq1; Auto). (Apply ltS; Auto). (Apply ltS_neq_lt; Auto). (Repeat Rewrite -> LIFTM2; Repeat Rewrite -> MSVMV2; Rewrite -> H; Auto). (Repeat Rewrite -> LIFTM4; Repeat Rewrite -> MSVMV4; Rewrite -> H; Rewrite -> H0; Auto). Save. Lemma Lift_Msub_Bridge2 : (x:V)(m1:M)(y:V)(m:M) (MsubstVMV x m1 (S y) (lift_M y (lift_M (S y) m)))= (MsubstVMV x m1 y (lift_M (S (S y)) (lift_M (S y) m))). Cut ((m:M)(lift_msub_bridge2 m))/\ ((ms:Ms)(lift_mssub_bridge2 ms)). Intros c; Case c; Unfold lift_msub_bridge2; Auto. Exact Lift_msub_bridge2. Save. Lemma Lift_Mssub_Bridge2 : (x:V)(m1:M)(y:V)(ms:Ms) (MssubstVMV x m1 (S y) (lift_Ms y (lift_Ms (S y) ms)))= (MssubstVMV x m1 y (lift_Ms (S (S y)) (lift_Ms (S y) ms))). Cut ((m:M)(lift_msub_bridge2 m))/\ ((ms:Ms)(lift_mssub_bridge2 ms)). Intros c; Case c; Unfold lift_mssub_bridge2; Auto. Exact Lift_msub_bridge2. Save. Lemma Lift_Vsub_Bridge1 : (x:V)(i,j:nat)(a:A) i=j-> (lift_A j (VsubstAV a i x))= (VsubstAV (lift_A j a) i (lift_V (S j) x)). (Intros n i j a H; Rewrite -> H; Clear H i). (Unfold lift_V; Unfold 1 VsubstAV; Unfold drop_V; Cut (nat_compare2 n j); Auto; Unfold nat_compare2; Intros c; Case c; Clear c; Intros). (Rewrite -> ltb_is_lt1; Auto; Rewrite -> nateqb_is_eq3). Rewrite -> ltb_is_lt1. (Unfold Setifb; Rewrite -> LIFTN4; Unfold VsubstAV; Unfold drop_V; Unfold lift_V; Rewrite -> nateqb_is_eq3). (Rewrite -> ltb_is_lt1; Auto). (Apply sym_not_equal; Apply lt_not_eq1; Auto). (Apply ltS; Auto). (Apply sym_not_equal; Apply lt_not_eq1; Auto). (Case H; Clear H; Intros). (Rewrite -> nateqb_is_eq1; Auto; Rewrite -> ltb_is_lt3). Rewrite -> ltb_is_lt1. (Unfold Setifb; Unfold VsubstAV ). (Rewrite -> nateqb_is_eq1; Auto). (Apply ltiSi; Auto). (Apply notltii; Auto). Rewrite -> nateqb_is_eq3. Rewrite -> ltb_is_lt3. Rewrite -> ltb_is_lt3. (Unfold Setifb; Unfold VsubstAV; Auto). (Rewrite -> nateqb_is_eq3; Auto). (Unfold Setifb; Unfold drop_V ). (Rewrite -> ltb_is_lt3; Auto). (Rewrite -> LIFTN4; Unfold lift_V ). (Rewrite -> ltb_is_lt3; Auto). (Inversion_clear H; Auto). (Apply lt_not_ltpred; Auto). (Apply ltnotlt; Apply ltS; Auto). (Apply lt_not_eq1; Apply ltS; Auto). (Apply lt_not_ltS; Auto). (Apply ltnotlt; Auto). (Apply lt_not_eq1; Auto). Save. Lemma Lift_Vsub_Bridge2 : (x:V)(i,j:nat)(a:A) (lt j i)-> (lift_A j (VsubstAV a i x))= (VsubstAV (lift_A j a) (S i) (lift_V j x)). (Intros n i j a H; Unfold lift_V; Cut (nat_compare2 n j); Auto; Unfold nat_compare2; Intros c; Case c; Clear c; Intros). (Rewrite -> ltb_is_lt1; Auto; Unfold Setifb; Unfold VsubstAV ). Rewrite -> nateqb_is_eq3. Rewrite -> nateqb_is_eq3. Unfold Setifb. Unfold drop_V. Rewrite -> ltb_is_lt1. Rewrite -> ltb_is_lt1. Unfold Setifb. (Rewrite -> LIFTN4; Unfold lift_V ). (Rewrite -> ltb_is_lt1; Auto). (Apply lt_trans with j:=j; Auto; Apply ltS; Auto). (Apply lt_trans with j:=j; Auto). (Apply sym_not_equal; Apply lt_not_eq1; Apply lt_trans with j:=j; Auto; Apply ltS; Auto). (Apply sym_not_equal; Apply lt_not_eq1; Apply lt_trans with j:=j; Auto). (Case H0; Clear H0; Intros). (Rewrite -> H0; Clear H0 n). Rewrite -> ltb_is_lt3. Unfold Setifb. Unfold VsubstAV. Rewrite -> nateqb_is_eq3. Rewrite -> nateqb_is_eq3. Unfold Setifb. Unfold drop_V. (Rewrite -> ltb_is_lt1; Auto; Rewrite -> ltb_is_lt1; Auto). (Unfold Setifb; Rewrite -> LIFTN4; Unfold lift_V ). (Rewrite -> ltb_is_lt3; Auto; Apply notltii; Auto). (Apply sym_not_equal; Apply lt_not_eq1; Auto). (Apply sym_not_equal; Apply lt_not_eq1; Auto). (Apply notltii; Auto). Rewrite -> ltb_is_lt3. (Unfold Setifb; Unfold VsubstAV ). (Cut (nat_compare2 i n); Auto; Unfold nat_compare2; Intros c; Case c; Clear c; Intros). Rewrite -> nateqb_is_eq3. Rewrite -> nateqb_is_eq3. (Unfold Setifb; Unfold drop_V ). Rewrite -> ltb_is_lt3. Rewrite -> ltb_is_lt3. (Unfold Setifb; Rewrite -> LIFTN4; Unfold lift_V ). Rewrite -> ltb_is_lt3. (Inversion_clear H1; Auto). (Apply lt_not_ltpred; Auto). (Apply ltnotlt; Auto). (Apply ltnotlt; Auto). (Apply lt_not_eq1; Auto). (Apply lt_not_eq1; Auto). (Case H1; Clear H1; Intros). (Rewrite -> nateqb_is_eq1; Auto; Rewrite -> nateqb_is_eq1; Auto). Rewrite -> nateqb_is_eq3. Rewrite -> nateqb_is_eq3. (Unfold Setifb; Unfold drop_V ). (Rewrite -> ltb_is_lt1; Auto; Rewrite -> ltb_is_lt1; Auto). (Unfold Setifb; Rewrite -> LIFTN4; Unfold lift_V ). (Rewrite -> ltb_is_lt3; Auto). (Apply ltnotlt; Auto). (Apply sym_not_equal; Apply lt_not_eq1; Auto). (Apply sym_not_equal; Apply lt_not_eq1; Auto). (Apply ltnotlt; Auto). Save. Definition lift_nsub_b_bridge1 : N->Prop := [n:N](i,j:nat)(a:A) i=j-> (lift_N j (NsubstAV a i n))= (NsubstAV (lift_A j a) i (lift_N (S j) n)). Definition lift_asub_b_bridge1 : A->Prop := [a:A](i,j:nat)(a1:A) i=j-> (lift_A j (AsubstAV a1 i a))= (AsubstAV (lift_A j a1) i (lift_A (S j) a)). Lemma lift_nsub_b_Bridge1 : ((n:N)(lift_nsub_b_bridge1 n))/\ ((a:A)(lift_asub_b_bridge1 a)). (Apply N_A_ind; Unfold lift_nsub_b_bridge1; Unfold lift_asub_b_bridge1; Intros). (Rewrite -> H0; Clear H0 i; Rewrite -> NSAV1; Rewrite -> LIFTN1; Rewrite -> H; Auto; Elim j). (Rewrite <- Lift_Lift_A_Bridge1; Auto). (Intros; Rewrite <- Lift_Lift_A_Bridge; Auto). (Rewrite -> NSAV2; Rewrite -> LIFTN2; Rewrite -> H; Auto). (Rewrite -> NSAV3; Rewrite -> LIFTN3; Rewrite -> H; Auto; Rewrite -> H0; Auto). (Rewrite -> NSAV4; Rewrite -> LIFTN4; Rewrite -> Lift_Vsub_Bridge1; Auto). Save. Lemma Lift_Nsub_Bridge1 : (n:N)(i,j:nat)(a:A) i=j-> (lift_N j (NsubstAV a i n))= (NsubstAV (lift_A j a) i (lift_N (S j) n)). Cut ((n:N)(lift_nsub_b_bridge1 n))/\ ((a:A)(lift_asub_b_bridge1 a)). Unfold lift_nsub_b_bridge1. Intros c; Case c; Intros; Auto. Exact lift_nsub_b_Bridge1. Save. Lemma Lift_Asub_Bridge1 : (a:A)(i,j:nat)(a1:A) i=j-> (lift_A j (AsubstAV a1 i a))= (AsubstAV (lift_A j a1) i (lift_A (S j) a)). Cut ((n:N)(lift_nsub_b_bridge1 n))/\ ((a:A)(lift_asub_b_bridge1 a)). Unfold lift_asub_b_bridge1. Intros c; Case c; Intros; Auto. Exact lift_nsub_b_Bridge1. Save. Definition lift_nsub_b_bridge2 : N->Prop := [n:N](i,j:nat)(a:A) (lt j i)-> (lift_N j (NsubstAV a i n))= (NsubstAV (lift_A j a) (S i) (lift_N j n)). Definition lift_asub_b_bridge2 : A->Prop := [a:A](i,j:nat)(a1:A) (lt j i)-> (lift_A j (AsubstAV a1 i a))= (AsubstAV (lift_A j a1) (S i) (lift_A j a)). Lemma lift_nsub_b_Bridge2 : ((n:N)(lift_nsub_b_bridge2 n))/\ ((a:A)(lift_asub_b_bridge2 a)). (Apply N_A_ind; Unfold lift_nsub_b_bridge2; Unfold lift_asub_b_bridge2; Intros; Auto). (Rewrite -> NSAV1; Rewrite -> LIFTN1; Rewrite -> H; Auto; Rewrite -> LIFTN1; Rewrite -> NSAV1). Elim j. (Rewrite <- Lift_Lift_A_Bridge1; Auto). (Intros; Rewrite <- Lift_Lift_A_Bridge; Auto). (Rewrite -> NSAV2; Rewrite -> LIFTN2; Rewrite -> H; Auto). (Rewrite -> NSAV3; Rewrite -> LIFTN3; Rewrite -> H; Auto; Rewrite -> H0; Auto). (Rewrite -> NSAV4; Rewrite -> LIFTN4; Rewrite -> Lift_Vsub_Bridge2; Auto). Save. Lemma Lift_Nsub_Bridge2 : (n:N)(i,j:nat)(a:A) (lt j i)-> (lift_N j (NsubstAV a i n))= (NsubstAV (lift_A j a) (S i) (lift_N j n)). Cut ((n:N)(lift_nsub_b_bridge2 n))/\ ((a:A)(lift_asub_b_bridge2 a)). Intros c; Case c; Auto. Exact lift_nsub_b_Bridge2. Save. Lemma Lift_Asub_Bridge2 : (a:A)(i,j:nat)(a1:A) (lt j i)-> (lift_A j (AsubstAV a1 i a))= (AsubstAV (lift_A j a1) (S i) (lift_A j a)). Cut ((n:N)(lift_nsub_b_bridge2 n))/\ ((a:A)(lift_asub_b_bridge2 a)). Intros c; Case c; Auto. Exact lift_nsub_b_Bridge2. Save. Lemma Lift_Vsub_Bridge3 : (x:V)(i,j:nat)(a:A) i=j-> (lift_A j (VsubstAV a i x))= (VsubstAV (lift_A j a) (S i) (lift_V j x)). (Intros n i j a H; Rewrite -> H; Clear H i; Cut (nat_compare2 n j); Auto; Unfold nat_compare2; Intros c; Case c; Clear c; Intros). (Unfold lift_V; Rewrite -> ltb_is_lt1; Auto; Unfold Setifb; Unfold VsubstAV ). Rewrite -> nateqb_is_eq3. Rewrite -> nateqb_is_eq3. (Unfold Setifb; Rewrite -> LIFTN4; Unfold drop_V ). (Rewrite -> ltb_is_lt1; Auto; Rewrite -> ltb_is_lt1). (Unfold Setifb; Unfold lift_V ). (Rewrite -> ltb_is_lt1; Auto). (Apply ltS; Auto). (Apply sym_not_equal; Apply lt_not_eq1; Apply ltS; Auto). (Apply sym_not_equal; Apply lt_not_eq1; Auto). (Case H; Clear H; Intros). Unfold lift_V. Rewrite -> ltb_is_lt3. (Unfold Setifb; Unfold VsubstAV ). (Rewrite -> nateqb_is_eq1; Auto; Rewrite -> nateqb_is_eq1; Auto). (Apply notltii; Auto). (Unfold lift_V; Rewrite -> ltb_is_lt3). (Unfold Setifb; Unfold VsubstAV; Rewrite -> nateqb_is_eq3). Rewrite -> nateqb_is_eq3. (Unfold Setifb; Unfold drop_V ). Rewrite -> ltb_is_lt3. Rewrite -> ltb_is_lt3. (Unfold Setifb; Rewrite -> LIFTN4; Unfold lift_V ). Rewrite -> ltb_is_lt3. (Inversion_clear H; Auto). (Apply lt_not_ltpred; Auto). (Apply ltnotlt; Auto). (Apply ltnotlt; Auto). (Apply lt_not_eq1; Auto). (Apply lt_not_eq1; Auto). (Apply ltnotlt; Auto). Save. Definition lift_nsub_b_bridge3 : N->Prop := [n:N](i,j:nat)(a:A) i=j-> (lift_N j (NsubstAV a i n))= (NsubstAV (lift_A j a) (S i) (lift_N j n)). Definition lift_asub_b_bridge3 : A->Prop := [a:A](i,j:nat)(a1:A) i=j-> (lift_A j (AsubstAV a1 i a))= (AsubstAV (lift_A j a1) (S i) (lift_A j a)). Lemma lift_nsub_b_Bridge3 : ((n:N)(lift_nsub_b_bridge3 n))/\ ((a:A)(lift_asub_b_bridge3 a)). (Apply N_A_ind; Unfold lift_nsub_b_bridge3; Unfold lift_asub_b_bridge3; Intros). (Rewrite -> H0; Clear H0 i; Rewrite -> NSAV1; Rewrite -> LIFTN1; Rewrite -> H; Auto; Elim j). (Rewrite <- Lift_Lift_A_Bridge1; Auto). (Intros; Rewrite <- Lift_Lift_A_Bridge; Auto). (Rewrite -> NSAV2; Rewrite -> LIFTN2; Rewrite -> H; Auto). (Rewrite -> NSAV3; Rewrite -> LIFTN3; Rewrite -> H; Auto; Rewrite -> H0; Auto). (Rewrite -> NSAV4; Rewrite -> LIFTN4; Rewrite -> Lift_Vsub_Bridge3; Auto). Save. Lemma Lift_Nsub_Bridge3 : (n:N)(i,j:nat)(a:A) i=j-> (lift_N j (NsubstAV a i n))= (NsubstAV (lift_A j a) (S i) (lift_N j n)). Cut ((n:N)(lift_nsub_b_bridge3 n))/\ ((a:A)(lift_asub_b_bridge3 a)). Unfold lift_nsub_b_bridge3. Intros c; Case c; Intros; Auto. Exact lift_nsub_b_Bridge3. Save. Lemma Lift_Asub_Bridge3 : (a:A)(i,j:nat)(a1:A) i=j-> (lift_A j (AsubstAV a1 i a))= (AsubstAV (lift_A j a1) (S i) (lift_A j a)). Cut ((n:N)(lift_nsub_b_bridge3 n))/\ ((a:A)(lift_asub_b_bridge3 a)). Unfold lift_asub_b_bridge3. Intros c; Case c; Intros; Auto. Exact lift_nsub_b_Bridge3. Save. Lemma Lift_Msub_Bridge1 : (x:V)(m,m0:M)(i,j:nat) i=j-> (lift_M j (MsubstVMV x m i m0))= (MsubstVMV (lift_V j x) (lift_M j m) i (lift_M (S j) m0)). (Intros; Rewrite <- (psitheta m0); Rewrite <- (psitheta m); Rewrite -> Msub_Psi_Bridge; Rewrite -> Lift_Psi_Bridge; Rewrite -> Lift_Nsub_Bridge1; Auto; Rewrite -> LIFTN3; Rewrite -> (Lift_Theta_Bridge m0); Rewrite -> Lift_Theta_Bridge; Rewrite -> LIFTN4; Rewrite <- Msub_Psi_Bridge; Rewrite -> psitheta; Rewrite -> psitheta; Rewrite -> psitheta; Rewrite -> psitheta; Auto). Save. Lemma Lift_Mssub_Bridge1 : (x:V)(m:M)(ms:Ms)(i,j:nat) i=j-> (lift_Ms j (MssubstVMV x m i ms))= (MssubstVMV (lift_V j x) (lift_M j m) i (lift_Ms (S j) ms)). (Induction ms; Intros; Auto; Clear ms; Rewrite -> MSVMV4; Rewrite -> LIFTM4; Rewrite -> Lift_Msub_Bridge1; Auto; Rewrite -> H; Auto). Save. Lemma NOI_Vsub_B : (x:V)(i:nat)(a:A) ~(Occurs_In_A i a)-> ~(Occurs_In_V (S i) x)-> ~(Occurs_In_A i (VsubstAV a i x)). (Intros n i a H H0; Unfold VsubstAV; Unfold drop_V; Cut (nat_compare2 n i); Auto; Unfold nat_compare2; Intros c; Case c; Clear c; Intros). (Rewrite -> ltb_is_lt1; Auto; Rewrite -> nateqb_is_eq3). (Unfold Setifb; Apply OIA1_is_OIA4; Rewrite -> OIN4; Unfold Occurs_In_V1; Apply nateqb_is_eq3; Apply sym_not_equal; Apply lt_not_eq1; Auto). (Apply sym_not_equal; Apply lt_not_eq1; Auto). (Case H1; Clear H1; Intros). (Rewrite -> nateqb_is_eq1; Auto). Rewrite -> nateqb_is_eq3. Rewrite -> ltb_is_lt3. (Unfold Setifb; Apply OIA1_is_OIA4; Rewrite -> OIN4; Unfold Occurs_In_V1; Apply nateqb_is_eq3; Generalize H0; Clear H0; Inversion_clear H1; Intros; Simpl). (Unfold not; Intros; Apply H0; Auto). (Unfold not; Intros; Apply H1; Auto). (Apply ltnotlt; Auto). (Apply lt_not_eq1; Auto). Save. Definition noi_nsub_b : N->Prop := [n:N](i:nat)(a:A) ~(Occurs_In_A i a)-> ~(Occurs_In_N (S i) n)-> ~(Occurs_In_N i (NsubstAV a i n)). Definition noi_asub_b : A->Prop := [a:A](i:nat)(a1:A) ~(Occurs_In_A i a1)-> ~(Occurs_In_A (S i) a)-> ~(Occurs_In_A i (AsubstAV a1 i a)). Lemma NOI_nsub_b : ((n:N)(noi_nsub_b n))/\ ((a:A)(noi_asub_b a)). (Apply N_A_ind; Unfold noi_nsub_b; Unfold noi_asub_b; Intros). (Rewrite -> NSAV1; Apply OIN1_is_OIN4; Simpl; Apply OIN1_is_OIN3; Apply H). (Apply OIA1_is_OIA4; Rewrite -> OI_Lift_A1_4; Auto; Simpl; Apply OIA1_is_OIA3; Auto). (Unfold not; Unfold not in H1; Intros; Apply H1; Auto). (Rewrite -> NSAV2; Apply OIN1_is_OIN4; Rewrite -> OIN2; Apply OIA1_is_OIA3; Apply H; Auto). (Unfold not; Unfold not in H1; Intros; Apply H1; Auto). (Rewrite -> NSAV3; Apply OIA1_is_OIA4; Rewrite -> OIN3; Apply ororb1; Split). (Apply OIA1_is_OIA3; Apply H; Auto). (Unfold not; Intros; Unfold not in H2; Apply H2; Apply Occurs_in_ap1; Auto). (Apply OIN1_is_OIN3; Apply H0; Auto). (Unfold not; Intros; Unfold not in H2; Apply H2; Apply Occurs_in_ap2; Auto). (Rewrite -> NSAV4; Apply NOI_Vsub_B; Auto; Unfold not in H0; Unfold not; Intros; Apply H0; Auto). Save. Lemma NOI_Nsub_B : (n:N)(i:nat)(a:A) ~(Occurs_In_A i a)-> ~(Occurs_In_N (S i) n)-> ~(Occurs_In_N i (NsubstAV a i n)). Cut ((n:N)(noi_nsub_b n))/\ ((a:A)(noi_asub_b a)). Unfold noi_nsub_b. Intros c; Case c; Clear c; Auto. Exact NOI_nsub_b. Save. Lemma NOI_Asub_B : (a:A)(i:nat)(a1:A) ~(Occurs_In_A i a1)-> ~(Occurs_In_A (S i) a)-> ~(Occurs_In_A i (AsubstAV a1 i a)). Cut ((n:N)(noi_nsub_b n))/\ ((a:A)(noi_asub_b a)). Unfold noi_asub_b. Intros c; Case c; Clear c; Auto. Exact NOI_nsub_b. Save. Lemma Lift_Phi_Bridge : (l:L)(i:nat) (lift_N i (phi l))= (phi (lift_L i l)). (Induction l; Clear l; Auto; Intros). (Rewrite -> lift_L_eq2; Rewrite -> phi_eq2; Rewrite -> phi_eq2). (Elim i; Intros). (Rewrite <- H; Rewrite <- H0). (Rewrite <- LIFTN4; Rewrite <- LIFTN3). (Rewrite -> Lift_Nsub_Bridge1; Auto). (Rewrite -> Lift_Nsub_Bridge0; Auto; Rewrite -> LIFTN3; Rewrite -> LIFTN4; Rewrite -> H0; Rewrite -> H; Auto). (Simpl; Rewrite -> H; Auto). Save. Lemma Lift_PhiBar_Bridge : (l:L)(i:nat) (lift_M i (phibar l))= (phibar (lift_L i l)). (Intros; Rewrite <- psiphiphibar; Rewrite -> Lift_Psi_Bridge; Rewrite -> Lift_Phi_Bridge; Rewrite -> psiphiphibar; Auto). Save. Lemma Drop_Lift_L : (l:L)(x:V) (drop_L x (lift_L x l))=l. (Induction l; Clear l; Intros; Simpl). (Rewrite -> Drop_Lift_V; Auto). (Rewrite -> H; Rewrite -> H0; Rewrite -> Drop_Lift_V; Auto). (Rewrite -> H; Auto). Save. Definition oi_theta : M->Prop := [m:M](x:V) (Occurs_In_M x m)-> (Occurs_In_N x (theta m)). Definition oi_theta' : Ms->Prop := [ms:Ms](a:A)(x:V) ((Occurs_In_Ms x ms)\/(Occurs_In_A x a))-> (Occurs_In_N x (theta' a ms)). Lemma OI_theta : ((m:M)(oi_theta m))/\ ((ms:Ms)(oi_theta' ms)). (Apply M_Ms_ind; Unfold oi_theta; Unfold oi_theta'; Intros). (Rewrite -> th1; Apply H; Inversion_clear H0; Auto). (Rewrite -> th2; Apply Occurs_in_lam; Apply H; Inversion_clear H0; Auto). (Simpl; Inversion_clear H; Auto; Inversion H0). (Rewrite -> th4; Inversion_clear H1). (Inversion_clear H2; Apply H0; Auto). (Apply H0; Auto). Save. Lemma OI_Theta : (m:M)(x:V) (Occurs_In_M x m)-> (Occurs_In_N x (theta m)). Cut ((m:M)(oi_theta m))/\ ((ms:Ms)(oi_theta' ms)). Intros c; Case c; Clear c; Auto. Exact OI_theta. Save. Lemma OI_Theta' : (ms:Ms)(a:A)(x:V) ((Occurs_In_Ms x ms)\/(Occurs_In_A x a))-> (Occurs_In_N x (theta' a ms)). Cut ((m:M)(oi_theta m))/\ ((ms:Ms)(oi_theta' ms)). Intros c; Case c; Clear c; Auto. Exact OI_theta. Save. Definition oi_psi : N->Prop := [n:N](x:V) (Occurs_In_N x n)-> (Occurs_In_M x (psi n)). Definition oi_psi' : A->Prop := [a:A](ms:Ms)(x:V) ((Occurs_In_A x a)\/(Occurs_In_Ms x ms))-> (Occurs_In_M x (psi' a ms)). Lemma OI_psi : ((n:N)(oi_psi n))/\ ((a:A)(oi_psi' a)). (Apply N_A_ind; Unfold oi_psi; Unfold oi_psi'; Intros). (Simpl; Inversion_clear H0; Apply Occurs_in_lambda; Apply H; Auto). (Rewrite -> ps2; Inversion_clear H0; Apply H; Auto). (Rewrite -> ps3; Inversion_clear H1; Auto). (Apply H; Auto). (Inversion_clear H2; Auto). (Inversion_clear H; Simpl; Auto). (Inversion_clear H0; Auto). Save. Lemma OI_Psi : (n:N)(x:V) (Occurs_In_N x n)-> (Occurs_In_M x (psi n)). Cut ((n:N)(oi_psi n))/\((a:A)(oi_psi' a)). (Intros c; Case c; Auto). Exact OI_psi. Save. Lemma OI_Psi' : (a:A)(ms:Ms)(x:V) ((Occurs_In_A x a)\/(Occurs_In_Ms x ms))-> (Occurs_In_M x (psi' a ms)). Cut ((n:N)(oi_psi n))/\((a:A)(oi_psi' a)). (Intros c; Case c; Auto). Exact OI_psi. Save. Definition noi_theta : M->Prop := [m:M](x:V) ~(Occurs_In_M x m)-> ~(Occurs_In_N x (theta m)). Definition noi_theta' : Ms->Prop := [ms:Ms](x:V)(a:A) ~(Occurs_In_Ms x ms)-> ~(Occurs_In_A x a)-> ~(Occurs_In_N x (theta' a ms)). Lemma noi_Theta : ((m:M)(noi_theta m))/\ ((ms:Ms)(noi_theta' ms)). (Apply M_Ms_ind; Unfold noi_theta; Unfold noi_theta'; Intros; Auto). Rewrite -> th1. (Apply H; Unfold not; Intros; Apply H0; Auto). (Inversion_clear H1; Auto). (Rewrite -> th2; Apply OIN1_is_OIN4; Rewrite -> OIN1; Apply OIN1_is_OIN3; Apply H; Unfold not; Intros; Apply H0; Auto). (Rewrite -> th3; Unfold not; Intros; Apply H0; Inversion_clear H1; Auto). (Rewrite -> th4; Apply H0; Auto). (Unfold not; Intros; Apply H1; Auto). (Apply OIA1_is_OIA4; Rewrite -> OIN3; Apply ororb1; Split). (Apply OIA1_is_OIA3; Auto). (Apply OIN1_is_OIN3; Apply H; Auto). (Unfold not; Intros; Apply H1; Auto). Save. Lemma NOI_Theta : (x:V)(m:M) ~(Occurs_In_M x m)-> ~(Occurs_In_N x (theta m)). Cut ((m:M)(noi_theta m))/\ ((ms:Ms)(noi_theta' ms)). Intros c; Case c; Unfold noi_theta; Auto. Exact noi_Theta. Save. Lemma NOI_Theta' : (x:V)(a:A)(ms:Ms) ~(Occurs_In_A x a)-> ~(Occurs_In_Ms x ms)-> ~(Occurs_In_N x (theta' a ms)). Cut ((m:M)(noi_theta m))/\ ((ms:Ms)(noi_theta' ms)). Intros c; Case c; Unfold noi_theta'; Auto. Exact noi_Theta. Save. Require MinMJ_Lift. Section HeightL. Recursive Definition Height_L : L->nat := (vr x) => O | (app x l1 l2) => (S (max_nat (Height_L l1) (Height_L l2))) | (lm l) => (S (Height_L l)). Definition lt_Height_L : L->L->Prop := [l1,l2:L](lt (Height_L l1) (Height_L l2)). Lemma WF_Height_L : (well_founded L lt_Height_L). Unfold well_founded . (Induction a; Clear a; Intros). Apply Acc_intro. Unfold lt_Height_L . Simpl. Intros. Inversion H. Apply Acc_intro. Unfold lt_Height_L . Rewrite -> Height_L_eq2. Intros. Cut (or (and (lt (Height_L y) (S (Height_L l))) (lt (Height_L l0) (S (Height_L l)))) (and (lt (Height_L y) (S (Height_L l0))) (lt (Height_L l) (S (Height_L l0))))). (Intros c; Case c; Clear c H1; Intros c; Case c; Clear c; Intros). Cut (or (lt (Height_L y) (Height_L l)) (eq ? (Height_L y) (Height_L l))). (Intros c; Case c; Clear c H1; Intros). Apply Acc_inv with x:=l. Unfold lt_Height_L in H. Auto. Auto. Apply Acc_intro. Intros. (Generalize H3 ; Clear H3; Rewrite -> H1; Intros). (Apply Acc_inv with x:=l; Auto). (Apply lt_S_le2; Auto). Cut (or (lt (Height_L y) (Height_L l0)) (eq ? (Height_L y) (Height_L l0))). (Intros c; Case c; Clear c H1; Intros). (Apply Acc_inv with x:=l0; Auto). (Apply Acc_intro; Rewrite -> H1; Intros). (Apply Acc_inv with x:=l0; Auto). (Apply lt_S_le2; Auto). (Apply lt_max_nat; Auto). (Apply Acc_intro; Unfold 1 lt_Height_L ; Simpl; Intros). Cut (or (lt (Height_L y) (Height_L l)) (eq ? (Height_L y) (Height_L l))). (Intros c; Case c; Clear c H0; Intros). (Apply Acc_inv with x:=l; Auto). (Apply Acc_intro; Unfold lt_Height_L ; Rewrite -> H0; Intros). (Apply Acc_inv with x:=l; Auto). (Apply lt_S_le2; Auto). Save. Lemma L_Height_ind1 : (P:L->Prop) ((l0:L)((l1:L)(lt_Height_L l1 l0)->(P l1))->(P l0))-> (l:L)(P l). (Intros; Apply (well_founded_ind L lt_Height_L WF_Height_L); Auto). Save. Lemma L_Height_ind : (P:L->Prop) ((l0:L)((l1:L)(lt (Height_L l1) (Height_L l0))->(P l1))->(P l0))-> (l:L)(P l). (Intros; Apply L_Height_ind1; Auto). Save. Lemma Height_Lift_L : (l:L)(i:nat) (Height_L (lift_L i l))= (Height_L l). (Induction l; Clear l; Intros; Auto; Simpl). (Rewrite -> H; Rewrite -> H0; Auto). (Rewrite -> H; Auto). Save. End HeightL. Require MinMJ_Lift. Fixpoint Height_M [m:M] : nat := Case m of (* sc x ms *)[x:V][ms:Ms](S (Height_Ms ms)) (* lambda m *)[m:M](S (Height_M m)) end with Height_Ms [ms:Ms] : nat := Case ms of (* mnil *)O (* mcons m ms *)[m:M][ms:Ms](S (max_nat (Height_M m) (Height_Ms ms))) end. Lemma HTM1 : (x:V)(ms:Ms) (Height_M (sc x ms))=(S (Height_Ms ms)). Auto. Save. Lemma HTM2 : (m:M) (Height_M (lambda m))=(S (Height_M m)). Auto. Save. Lemma HTM3 : (Height_Ms mnil)=O. Auto. Save. Lemma HTM4 : (m:M)(ms:Ms) (Height_Ms (mcons m ms))=(S (max_nat (Height_M m) (Height_Ms ms))). Auto. Save. Lemma Height_Ms_Zero_Nil1 : (ms:Ms) ~ms=mnil-> (lt O (Height_Ms ms)). (Induction ms; Auto; Clear ms). (Intros; Cut False; Auto; Contradiction). Intros. Rewrite -> HTM4. Auto. Save. Lemma Height_Ms_Zero_Nil : (ms:Ms) (Height_Ms ms)=O-> ms=mnil. (Induction ms; Clear ms; Auto; Intros m ms). Rewrite -> HTM4. Intros. Discriminate H0. Save. Lemma Height_M_not_eq_not_eq : (m:M)(m0:M) ~(Height_M m)=(Height_M m0)-> ~m=m0. Unfold not; Intros; Apply H; Rewrite <- H0; Auto. Save. Lemma Height_Ms_not_eq_not_eq : (ms:Ms)(ms0:Ms) ~(Height_Ms ms)=(Height_Ms ms0)-> ~ms=ms0. Unfold not; Intros; Apply H; Rewrite <- H0; Auto. Save. Definition height_lift_m : M->Prop := [m:M](i:nat) (Height_M (lift_M i m))= (Height_M m). Definition height_lift_ms : Ms->Prop := [ms:Ms](i:nat) (Height_Ms (lift_Ms i ms))= (Height_Ms ms). Lemma height_lift_M : ((m:M)(height_lift_m m))/\ ((ms:Ms)(height_lift_ms ms)). (Apply M_Ms_ind; Unfold height_lift_m ; Unfold height_lift_ms ; Intros; Auto). (Rewrite -> LIFTM1; Rewrite -> HTM1; Rewrite -> H; Auto). (Rewrite -> LIFTM2; Rewrite -> HTM2; Rewrite -> H; Auto). (Rewrite -> LIFTM4; Rewrite -> HTM4; Rewrite -> H; Rewrite -> H0; Auto). Save. Lemma Height_Lift_M : (m:M)(i:nat) (Height_M (lift_M i m))= (Height_M m). Cut ((m:M)(height_lift_m m))/\ ((ms:Ms)(height_lift_ms ms)). Intros c; Case c; Auto. Exact height_lift_M. Save. Lemma Height_Lift_Ms : (ms:Ms)(i:nat) (Height_Ms (lift_Ms i ms))= (Height_Ms ms). Cut ((m:M)(height_lift_m m))/\ ((ms:Ms)(height_lift_ms ms)). Intros c; Case c; Auto. Exact height_lift_M. Save. Section HeightMind. Variable P:M->Prop. Variable P0:Ms->Prop. Definition QSM : M->Prop := [m:M] ((m1:M) ((lt (Height_M m1) (Height_M m)) \/ (Height_M m1)=(Height_M m))-> (P m1))/\ ((ms1:Ms) ((lt (Height_Ms ms1) (Height_M m)) \/ (Height_Ms ms1)=(Height_M m))-> (P0 ms1)). Definition QSMs : Ms->Prop := [ms:Ms] ((m1:M) ((lt (Height_M m1) (Height_Ms ms)) \/ (Height_M m1)=(Height_Ms ms))-> (P m1))/\ ((ms1:Ms) ((lt (Height_Ms ms1) (Height_Ms ms)) \/ (Height_Ms ms1)=(Height_Ms ms))-> (P0 ms1)). Lemma M_Ms_szind1 : (((m:M)(QSM m))/\((ms:Ms)(QSMs ms)))-> ((m:M)(P m))/\((ms:Ms)(P0 ms)). (Intros H; Case H; Clear H; Unfold QSM ; Unfold QSMs ; Intros; Apply M_Ms_ind; Intros). Case (H0 (mcons (sc v m) mnil)). (Intros; Apply H2; Rewrite -> HTM1; Rewrite -> HTM4). Rewrite -> HTM3. Rewrite -> max_nat0. (Rewrite -> HTM1; Left; Apply ltiSi; Auto). (Case (H (lambda (lambda m))); Intros). Apply H2. Left. Simpl. (Apply ltiSi; Auto). (Case (H0 mnil); Auto). (Case (H0 (mcons m m0)); Auto). Save. Lemma M_Ms_Height_ind : ((m:M) (((m1:M)(lt (Height_M m1) (Height_M m))->(P m1)) /\ ((ms1:Ms)(lt (Height_Ms ms1) (Height_M m))->(P0 ms1)))->(P m))-> ((ms:Ms) (((ms1:Ms)(lt (Height_Ms ms1) (Height_Ms ms))->(P0 ms1))/\ ((m1:M)(lt (Height_M m1) (Height_Ms ms))->(P m1)))->(P0 ms))-> ((m:M)(P m))/\((ms:Ms)(P0 ms)). (Intros; Apply M_Ms_szind1). (Apply M_Ms_ind; Unfold QSM; Unfold QSMs; Intros; Auto). (Split; Intros). (Case H1; Clear H1; Intros; Case H2; Clear H2; Intros). (Generalize H2 ; Clear H2; Rewrite -> HTM1; Intros). Cut (S (Height_M m1))=(S (Height_Ms m)) \/(lt (S (Height_M m1)) (S (Height_Ms m))). (Intros c; Case c; Clear c H2; Intros). (Injection H2; Clear H2; Intros). (Apply H1; Auto). (Inversion_clear H2; Apply H1; Auto). (Apply lt_S_le; Auto). (Generalize H2 ; Clear H2; Rewrite -> HTM1; Intros). (Apply H; Split; Intros). (Generalize H4 ; Clear H4; Rewrite -> H2; Intros). Cut (S (Height_M m0))=(S (Height_Ms m)) \/(lt (S (Height_M m0)) (S (Height_Ms m))). (Intros c; Case c; Clear c H4; Intros). (Injection H4; Clear H4; Intros). (Apply H1; Auto). (Inversion_clear H4; Apply H1; Auto). (Apply lt_S_le; Auto). (Generalize H4 ; Clear H4; Rewrite -> H2; Intros). Cut (S (Height_Ms ms1))=(S (Height_Ms m)) \/(lt (S (Height_Ms ms1)) (S (Height_Ms m))). (Intros c; Case c; Clear c H4; Intros). (Injection H4; Clear H4; Intros). (Apply H3; Auto). (Inversion_clear H4; Apply H3; Auto). (Apply lt_S_le; Auto). (Case H1; Clear H1; Intros; Case H2; Clear H2; Rewrite -> HTM1; Intros). Cut (S (Height_Ms ms1))=(S (Height_Ms m)) \/(lt (S (Height_Ms ms1)) (S (Height_Ms m))). (Intros c; Case c; Clear c H2; Intros; Apply H3). (Injection H2; Auto). (Inversion_clear H2; Auto). (Apply lt_S_le; Auto). (Apply H0; Split; Rewrite -> H2; Intros). Cut (S (Height_Ms ms0))=(S (Height_Ms m)) \/(lt (S (Height_Ms ms0)) (S (Height_Ms m))). (Intros c; Case c; Clear c H4; Intros; Apply H3). (Injection H4; Auto). (Inversion_clear H4; Auto). (Apply lt_S_le; Auto). Cut (S (Height_M m1))=(S (Height_Ms m)) \/(lt (S (Height_M m1)) (S (Height_Ms m))). (Intros c; Case c; Clear c H4; Intros; Apply H1). (Injection H4; Auto). (Inversion_clear H4; Auto). (Apply lt_S_le; Auto). (Split; Intros). (Case H1; Clear H1; Intros; Case H2; Clear H2; Intros). (Generalize H2 ; Clear H2; Rewrite -> HTM2; Intros). Cut (S (Height_M m1))=(S (Height_M m))\/(lt (S (Height_M m1)) (S (Height_M m))). (Intros c; Case c; Clear c H2; Intros). (Injection H2; Clear H2; Intros). (Apply H1; Auto). (Inversion_clear H2; Apply H1; Auto). (Apply lt_S_le; Auto). (Generalize H2 ; Clear H2; Rewrite -> HTM2; Intros). (Apply H; Split; Intros). (Generalize H4 ; Clear H4; Rewrite -> H2; Intros). Cut (S (Height_M m0))=(S (Height_M m))\/(lt (S (Height_M m0)) (S (Height_M m))). (Intros c; Case c; Clear c H4; Intros). (Injection H4; Clear H4; Intros). (Apply H1; Auto). (Inversion_clear H4; Apply H1; Auto). (Apply lt_S_le; Auto). (Generalize H4 ; Clear H4; Rewrite -> H2; Intros). Cut (S (Height_Ms ms1))=(S (Height_M m)) \/(lt (S (Height_Ms ms1)) (S (Height_M m))). (Intros c; Case c; Clear c H4; Intros). (Injection H4; Clear H4; Intros). (Apply H3; Auto). (Inversion_clear H4; Apply H3; Auto). (Apply lt_S_le; Auto). (Case H1; Clear H1; Intros; Case H2; Clear H2; Rewrite -> HTM2; Intros). Cut (S (Height_Ms ms1))=(S (Height_M m)) \/(lt (S (Height_Ms ms1)) (S (Height_M m))). (Intros c; Case c; Clear c H2; Intros; Apply H3). (Injection H2; Auto). (Inversion_clear H2; Auto). (Apply lt_S_le; Auto). (Apply H0; Split; Rewrite -> H2; Intros). Cut (S (Height_Ms ms0))=(S (Height_M m)) \/(lt (S (Height_Ms ms0)) (S (Height_M m))). (Intros c; Case c; Clear c H4; Intros; Apply H3). (Injection H4; Auto). (Inversion_clear H4; Auto). (Apply lt_S_le; Auto). Cut (S (Height_M m1))=(S (Height_M m))\/(lt (S (Height_M m1)) (S (Height_M m))). (Intros c; Case c; Clear c H4; Intros; Apply H1). (Injection H4; Auto). (Inversion_clear H4; Auto). (Apply lt_S_le; Auto). (Split; Rewrite -> HTM3; Intros; Case H1; Clear H1; Intros). Inversion H1. (Generalize H1 ; Elim m1; Clear H1 m1). (Intros x ms; Rewrite -> HTM1). Intros. (Rewrite -> (Height_Ms_Zero_Nil ms); Auto). Discriminate H1. Discriminate H1. (Intros m; Rewrite -> HTM2). Intros. Discriminate H2. Inversion H1. (Rewrite -> (Height_Ms_Zero_Nil ms1); Auto). (Apply H0; Rewrite -> HTM3; Split; Intros; Inversion H2). (Rewrite -> HTM4; Case H1; Clear H1; Intros; Case H2; Clear H2; Intros; Split; Intros; Case H5; Clear H5; Intros). Cut (lt (Height_M m1) (S (Height_M m)))/\(lt (Height_Ms m0) (S (Height_M m))) \/(lt (Height_M m1) (S (Height_Ms m0))) /\(lt (Height_M m) (S (Height_Ms m0))). (Intros c; Case c; Clear c H5; Intros c; Case c; Clear c; Intros). (Apply H1; Apply lt_S_le2; Auto). (Apply H2; Apply lt_S_le2; Auto). (Apply lt_max_nat; Auto). Cut (Height_M m1)=(S (Height_M m))/\(lt (Height_Ms m0) (S (Height_M m))) \/(Height_M m1)=(S (Height_Ms m0))/\(lt (Height_M m) (S (Height_Ms m0))). (Intros c; Case c; Clear c H5; Intros c; Case c; Clear c; Intros). (Apply H; Split; Intros). Apply H1. Apply lt_S_le2. (Rewrite <- H5; Auto). (Apply H3; Apply lt_S_le2). (Rewrite <- H5; Auto). (Apply H; Split; Intros). (Apply H2; Apply lt_S_le2; Rewrite <- H5; Auto). (Apply H4; Apply lt_S_le2; Rewrite <- H5; Auto). (Apply eq_max_nat; Auto). Cut (lt (Height_Ms ms1) (S (Height_M m)))/\(lt (Height_Ms m0) (S (Height_M m))) \/(lt (Height_Ms ms1) (S (Height_Ms m0))) /\(lt (Height_M m) (S (Height_Ms m0))). (Intros c; Case c; Clear c H5; Intros c; Case c; Clear c; Intros). (Apply H3; Apply lt_S_le2; Auto). (Apply H4; Apply lt_S_le2; Auto). (Apply lt_max_nat; Auto). Cut (Height_Ms ms1)=(S (Height_M m))/\(lt (Height_Ms m0) (S (Height_M m))) \/(Height_Ms ms1)=(S (Height_Ms m0))/\(lt (Height_M m) (S (Height_Ms m0))). (Intros c; Case c; Clear c H5; Intros c; Case c; Clear c; Intros). (Apply H0; Split; Intros). (Apply H3; Apply lt_S_le2; Rewrite <- H5; Auto). (Apply H1; Apply lt_S_le2; Rewrite <- H5; Auto). (Apply H0; Split; Intros). (Apply H4; Apply lt_S_le2; Rewrite <- H5; Auto). (Apply H2; Apply lt_S_le2; Rewrite <- H5; Auto). (Apply eq_max_nat; Auto). Save. End HeightMind.Require MinMJ_Occurs_Lift. Section Lifts. Recursive Definition lifts_V : nat->nat->V->V := O j x => x | (S i) j x => (lift_V j (lifts_V i j x)). Recursive Definition lifts_L : nat->nat->L->L := i j (vr x) => (vr (lifts_V i j x)) | i j (app x l l0) => (app (lifts_V i j x) (lifts_L i j l) (lifts_L i (S j) l0)) | i j (lm l) => (lm (lifts_L i (S j) l)). Fixpoint lifts_M1 [m:M] : nat->nat->M := [i,j:nat] Case m of (* x;ms *)[x:V][ms:Ms] (sc (lifts_V i j x) (lifts_Ms1 ms i j)) (* \m *)[m:M] (lambda (lifts_M1 m i (S j))) end with lifts_Ms1 [ms:Ms] : nat->nat->Ms := [i,j:nat] Case ms of (* mnil *)mnil (* m::ms *)[m:M][ms:Ms] (mcons (lifts_M1 m i j) (lifts_Ms1 ms i j)) end. Recursive Definition lifts_M : nat->nat->M->M := i j m => (lifts_M1 m i j). Recursive Definition lifts_Ms : nat->nat->Ms->Ms := i j ms => (lifts_Ms1 ms i j). Lemma LIFTSM1 : (i,j:nat)(x:V)(ms:Ms) (lifts_M i j (sc x ms))= (sc (lifts_V i j x) (lifts_Ms i j ms)). Auto. Save. Lemma LIFTSM2 : (i,j:nat)(m:M) (lifts_M i j (lambda m))= (lambda (lifts_M i (S j) m)). Auto. Save. Lemma LIFTSM3 : (i,j:nat) (lifts_Ms i j mnil)=mnil. Auto. Save. Lemma LIFTSM4 : (i,j:nat)(m:M)(ms:Ms) (lifts_Ms i j (mcons m ms))= (mcons (lifts_M i j m) (lifts_Ms i j ms)). Auto. Save. Lemma Lifts_L0 : (l:L)(j:nat) (lifts_L O j l)=l. Induction l; Clear l; Intros; Auto. Rewrite lifts_L_eq2; Unfold lifts_V; Rewrite H; Rewrite H0; Auto. Rewrite lifts_L_eq3; Rewrite H; Auto. Save. Definition lifts_m0 : M->Prop := [m:M](j:nat) (lifts_M O j m)=m. Definition lifts_ms0 : Ms->Prop := [ms:Ms](j:nat) (lifts_Ms O j ms)=ms. Lemma Lifts_m0 : ((m:M)(lifts_m0 m))/\ ((ms:Ms)(lifts_ms0 ms)). Apply M_Ms_ind; Unfold lifts_m0; Unfold lifts_ms0; Intros; Auto. Rewrite LIFTSM1; Unfold lifts_V; Rewrite H; Auto. Rewrite LIFTSM2; Rewrite H; Auto. Rewrite LIFTSM4; Rewrite H; Rewrite H0; Auto. Save. Lemma Lifts_M0 : (m:M)(j:nat) (lifts_M O j m)=m. Cut ((m:M)(lifts_m0 m))/\ ((ms:Ms)(lifts_ms0 ms)). Intros c; Case c; Auto. Exact Lifts_m0. Save. Lemma Lifts_Ms0 : (ms:Ms)(j:nat) (lifts_Ms O j ms)=ms. Cut ((m:M)(lifts_m0 m))/\ ((ms:Ms)(lifts_ms0 ms)). Intros c; Case c; Auto. Exact Lifts_m0. Save. Lemma Lifts_L_rec1 : (l:L)(i,j:nat) (lifts_L (S i) j l)=(lift_L j (lifts_L i j l)). Induction l; Clear l; Intros; Auto. Rewrite lifts_L_eq2; Unfold lifts_V; Rewrite H; Rewrite H0; Auto. Rewrite lifts_L_eq3; Rewrite H; Auto. Save. Definition lifts_m_rec1 : M->Prop := [m:M](i,j:nat) (lifts_M (S i) j m)=(lift_M j (lifts_M i j m)). Definition lifts_ms_rec1 : Ms->Prop := [ms:Ms](i,j:nat) (lifts_Ms (S i) j ms)=(lift_Ms j (lifts_Ms i j ms)). Lemma Lifts_m_rec1 : ((m:M)(lifts_m_rec1 m))/\ ((ms:Ms)(lifts_ms_rec1 ms)). Apply M_Ms_ind; Unfold lifts_m_rec1; Unfold lifts_ms_rec1; Intros; Auto. Rewrite LIFTSM1; Unfold lifts_V; Rewrite H; Auto. Rewrite LIFTSM2; Rewrite H; Auto. Rewrite LIFTSM4; Rewrite H; Rewrite H0; Auto. Save. Lemma Lifts_M_rec1 : (m:M)(i,j:nat) (lifts_M (S i) j m)=(lift_M j (lifts_M i j m)). Cut ((m:M)(lifts_m_rec1 m))/\ ((ms:Ms)(lifts_ms_rec1 ms)). Intros c; Case c; Auto. Exact Lifts_m_rec1. Save. Lemma Lifts_Ms_rec1 : (ms:Ms)(i,j:nat) (lifts_Ms (S i) j ms)=(lift_Ms j (lifts_Ms i j ms)). Cut ((m:M)(lifts_m_rec1 m))/\ ((ms:Ms)(lifts_ms_rec1 ms)). Intros c; Case c; Auto. Exact Lifts_m_rec1. Save. Lemma Lifts_V_rec2 : (x:V)(i,j:nat) (lifts_V (S i) j x)= (lifts_V i j (lift_V j x)). (Induction i; Clear i; Intros; Auto; Rewrite -> lifts_V_eq2; Rewrite -> H; Auto). Save. Lemma Lifts_L_rec2 : (l:L)(i,j:nat) (lifts_L (S i) j l)= (lifts_L i j (lift_L j l)). (Induction l; Clear l; Intros; Auto). (Rewrite -> lifts_L_eq1; Rewrite -> lift_L_eq1; Rewrite -> lifts_L_eq1; Rewrite -> Lifts_V_rec2; Auto). (Rewrite -> lifts_L_eq2; Rewrite -> lift_L_eq2; Rewrite -> lifts_L_eq2; Rewrite -> Lifts_V_rec2; Rewrite -> H; Rewrite -> H0; Auto). (Rewrite -> lifts_L_eq3; Rewrite -> lift_L_eq3; Rewrite -> lifts_L_eq3; Rewrite -> H; Auto). Save. Definition lifts_m_rec2 : M->Prop := [m:M](i,j:nat) (lifts_M (S i) j m)=(lifts_M i j (lift_M j m)). Definition lifts_ms_rec2 : Ms->Prop := [ms:Ms](i,j:nat) (lifts_Ms (S i) j ms)=(lifts_Ms i j (lift_Ms j ms)). Lemma Lifts_m_rec2 : ((m:M)(lifts_m_rec2 m))/\ ((ms:Ms)(lifts_ms_rec2 ms)). Apply M_Ms_ind; Unfold lifts_m_rec2; Unfold lifts_ms_rec2; Intros; Auto. Rewrite LIFTSM1; Rewrite Lifts_V_rec2; Rewrite H; Auto. Rewrite LIFTSM2; Rewrite H; Auto. Rewrite LIFTSM4; Rewrite H; Rewrite H0; Auto. Save. Lemma Lifts_M_rec2 : (m:M)(i,j:nat) (lifts_M (S i) j m)=(lifts_M i j (lift_M j m)). Cut ((m:M)(lifts_m_rec2 m))/\ ((ms:Ms)(lifts_ms_rec2 ms)). Intros c; Case c; Auto. Exact Lifts_m_rec2. Save. Lemma Lifts_Ms_rec2 : (ms:Ms)(i,j:nat) (lifts_Ms (S i) j ms)=(lifts_Ms i j (lift_Ms j ms)). Cut ((m:M)(lifts_m_rec2 m))/\ ((ms:Ms)(lifts_ms_rec2 ms)). Intros c; Case c; Auto. Exact Lifts_m_rec2. Save. Lemma Lifts_Msub_Bridge0 : (k:nat)(x:V)(m,m0:M)(i,j:nat) (lt i j)-> (lifts_M k j (MsubstVMV x m0 i m))= (MsubstVMV (lifts_V k j x) (lifts_M k j m0) i (lifts_M k (S j) m)). (Induction k; Clear k; Intros). (Rewrite -> Lifts_M0; Unfold lifts_V ; Rewrite -> Lifts_M0; Rewrite -> Lifts_M0; Auto). (Rewrite -> Lifts_M_rec2; Rewrite -> Lift_Msub_Bridge0; Auto; Rewrite -> H; Auto; Rewrite -> Lifts_V_rec2; Rewrite -> Lifts_M_rec2; Rewrite -> Lifts_M_rec2; Auto). Save. Lemma Lifts_Mssub_Bridge0 : (k:nat)(x:V)(ms:Ms)(m0:M)(i,j:nat) (lt i j)-> (lifts_Ms k j (MssubstVMV x m0 i ms))= (MssubstVMV (lifts_V k j x) (lifts_M k j m0) i (lifts_Ms k (S j) ms)). (Induction ms; Clear ms; Intros; Auto; Rewrite -> MSVMV4; Rewrite -> LIFTSM4; Rewrite -> H; Auto; Rewrite -> Lifts_Msub_Bridge0; Auto). Save. Lemma Lifts_Msub_Bridge1 : (k:nat)(x:V)(m,m0:M)(i,j:nat) i=j-> (lifts_M k j (MsubstVMV x m0 i m))= (MsubstVMV (lifts_V k j x) (lifts_M k j m0) i (lifts_M k (S j) m)). (Induction k; Clear k; Intros). (Rewrite -> Lifts_M0; Unfold lifts_V ; Rewrite -> Lifts_M0; Rewrite -> Lifts_M0; Auto). (Rewrite -> Lifts_M_rec2; Rewrite -> Lift_Msub_Bridge1; Auto; Rewrite -> H; Auto; Rewrite -> Lifts_V_rec2; Rewrite -> Lifts_M_rec2; Rewrite -> Lifts_M_rec2; Auto). Save. Lemma Lifts_Mssub_Bridge1 : (k:nat)(x:V)(ms:Ms)(m0:M)(i,j:nat) i=j-> (lifts_Ms k j (MssubstVMV x m0 i ms))= (MssubstVMV (lifts_V k j x) (lifts_M k j m0) i (lifts_Ms k (S j) ms)). (Induction ms; Clear ms; Intros; Auto; Rewrite -> MSVMV4; Rewrite -> LIFTSM4; Rewrite -> H; Auto; Rewrite -> Lifts_Msub_Bridge1; Auto). Save. Lemma Lifts_PhiBar_Bridge : (l:L)(i,j:nat) (lifts_M i j (phibar l))= (phibar (lifts_L i j l)). (Induction l; Clear l; Intros; Auto). Rewrite -> phibar_eq2. (Elim j; Clear j; Intros). Rewrite -> Lifts_Msub_Bridge1; Auto. Rewrite -> lifts_L_eq2. Rewrite -> phibar_eq2. (Rewrite -> H; Auto; Rewrite -> H0; Auto). (Rewrite -> Lifts_Msub_Bridge0; Auto). (Rewrite -> lifts_L_eq2; Rewrite -> phibar_eq2; Rewrite -> H; Auto). (Rewrite -> H0; Auto). (Rewrite -> phibar_eq3; Rewrite -> LIFTSM2; Rewrite -> H; Auto). Save. Lemma Lifts_Lift_V_Bridge3 : (x:V)(i,j,k:nat) ~(lt k j)-> (lifts_V i j (lift_V k x))= (lift_V (plus i k) (lifts_V i j x)). (Intros n i; Generalize n ; Elim i; Clear n i; Intros). (Unfold lifts_V ; Unfold plus ; Auto). (Rewrite -> lifts_V_eq2; Rewrite -> lifts_V_eq2). (Rewrite -> plus_eq2; Rewrite -> H). Cut (or (eq ? k j) (lt j k)). (Clear H0; Intros H0; Case H0; Clear H0; Intros). (Rewrite -> H0; Clear H0 k). Rewrite -> (Lift_Lift_V_Bridge0 (lifts_V n j n0) (S (plus n j))). (Unfold pred ; Auto). (Apply ltSplus2; Auto). Rewrite -> (Lift_Lift_V_Bridge0 (lifts_V n j n0) (S (plus n k))). (Unfold pred ; Auto). (Apply ltSplus3; Auto). (Apply not_lt_eq_lt; Auto). Auto. Save. Lemma Lifts_Lift_L_Bridge3 : (l:L)(i,j,k:nat) ~(lt k j)-> (lifts_L i j (lift_L k l))= (lift_L (plus i k) (lifts_L i j l)). (Induction l; Clear l; Intros; Auto). (Rewrite -> lift_L_eq1; Rewrite -> lifts_L_eq1; Rewrite -> Lifts_Lift_V_Bridge3; Auto). (Rewrite -> lift_L_eq2; Rewrite -> lifts_L_eq2; Rewrite -> Lifts_Lift_V_Bridge3; Auto; Rewrite -> H; Auto; Rewrite -> H0; Auto). (Rewrite -> (sym_plus i (S k)); Rewrite -> plus_eq2; Rewrite -> (sym_plus k i); Auto). (Unfold not ; Intros; Apply H1; Inversion_clear H2; Auto). (Rewrite -> lift_L_eq3; Rewrite -> lifts_L_eq3; Rewrite -> H; Auto). (Rewrite -> sym_plus; Rewrite -> plus_eq2; Rewrite -> sym_plus; Auto). (Unfold not ; Intros; Apply H0; Inversion_clear H1; Auto). Save. Lemma Lifts_Lifts_L_Bridge0 : (i,j,k,n:nat)(l:L) k=n-> (lifts_L i k (lifts_L j n l))= (lifts_L (plus i j) n l). (Induction i; Clear i; Intros; Auto). (Rewrite -> Lifts_L0; Auto). (Rewrite -> Lifts_L_rec1; Rewrite -> H; Auto; Rewrite -> H0; Rewrite -> plus_eq2; Rewrite -> Lifts_L_rec1; Auto). Save. End Lifts.Require MinMJ_Lifts. Require MinMJ_HeightM. (* The Mapping RhoBar from MJ to LJ. *) Fixpoint rhobar [m:M] : L := Case m of (* x;ms *)[x:V][ms:Ms] Case ms of (* mnil *) (vr x) (* m::ms *)[m:M][ms:Ms] (app x (rhobar m) (rhobar' ms (S O))) end (* \m *)[m:M] (lm (rhobar m)) end with rhobar' [ms:Ms] : nat->L := [i:nat] Case ms of (* mnil *) (vr O) (* m::ms *)[m:M][ms:Ms] (app O (lifts_L i O (rhobar m)) (rhobar' ms (S i))) end. Recursive Definition rhobar1 : nat->Ms->L := i ms => (rhobar' ms i). Recursive Definition rho : N->L := n => (rhobar (psi n)). Section Rhobar. Lemma rhothetarhobar : (m:M) (rho (theta m))=(rhobar m). (Intros; Rewrite -> rho_eq1; Rewrite -> psitheta; Auto). Save. Lemma Rhobar1 : (x:V) (rhobar (sc x mnil))=(vr x). Auto. Save. Lemma Rhobar2 : (x:V)(m:M) (rhobar (sc x (mcons m mnil)))= (app x (rhobar m) (vr O)). Auto. Save. Lemma Rhobar3 : (x:V)(m:M)(ms:Ms) (rhobar (sc x (mcons m ms)))= (app x (rhobar m) (rhobar1 (S O) ms)). Auto. Save. Lemma Rhobar4 : (m:M) (rhobar (lambda m))=(lm (rhobar m)). Auto. Save. Lemma Rhobar5 : (i:nat) (rhobar1 i mnil)=(vr O). Auto. Save. Lemma Rhobar6 : (m:M)(ms:Ms)(i:nat) (rhobar1 i (mcons m ms))= (app O (lifts_L i O (rhobar m)) (rhobar1 (S i) ms)). Auto. Save. Definition phibarrhobar1 : M->Prop := [m:M] (phibar (rhobar m))=m. Definition phibarrhobar2 : Ms->Prop := [ms:Ms] (m:M)(i:nat) ((m1:M) (lt (Height_M m1) (Height_Ms (mcons m ms)))-> (phibar (rhobar m1))=m1)-> (phibar (rhobar1 i (mcons m ms)))= (sc O (lifts_Ms i O (mcons m ms))). Lemma Phibarrhobar : ((m:M)(phibarrhobar1 m))/\ ((ms:Ms)(phibarrhobar2 ms)). (Apply M_Ms_Height_ind; Unfold phibarrhobar1; Unfold phibarrhobar2; Intros). (Case H; Clear H; Elim m; Clear m). (Intros x ms; Generalize x ; Elim ms; Clear ms; Intros; Auto). (Rewrite -> Rhobar3; Rewrite -> phibar_eq2). (Clear H; Rewrite -> H0; Auto; Clear x). (Generalize x0 m H0 H1 ; Elim m0; Clear H0 H1 x0 m m0; Intros). (Rewrite -> Rhobar5; Rewrite -> phibar_eq1; Rewrite -> MSVMV1). (Rewrite -> nateqb_is_eq1; Auto; Unfold Setifb; Rewrite -> MSVMV3; Auto). (Clear H; Rewrite -> H1; Auto). (Rewrite -> MSVMV1; Rewrite -> nateqb_is_eq1; Auto; Unfold Setifb). (Rewrite -> Lifts_Ms_rec1; Rewrite -> NOI_Mssub_Bridge). (Rewrite -> Drop_Lift_Ms; Auto). (Rewrite -> Lifts_Ms0; Auto). Apply NOI_Lift_Ms. (Rewrite -> HTM1; Apply ltS; Rewrite -> HTM4; Rewrite -> sym_max_nat; Apply ltS; Apply lt_max_nat2; Rewrite -> HTM4; Rewrite -> sym_max_nat; Apply lt_max_nat1; Auto). (Intros; Apply H0; Auto). (Rewrite -> HTM1; Apply ltS; Rewrite -> HTM4; Rewrite -> sym_max_nat; Apply ltS; Apply lt_max_nat2; Auto). (Rewrite -> HTM1; Apply ltS; Rewrite -> HTM4; Apply lt_max_nat1; Auto). (Intros; Rewrite -> Rhobar4; Rewrite -> phibar_eq3; Rewrite -> H0; Auto). (Rewrite -> HTM2; Apply ltiSi; Auto). (Case H; Generalize m i H0 ; Elim ms; Clear H H0 m i ms; Intros). (Rewrite -> Rhobar6; Rewrite -> Rhobar5; Rewrite -> phibar_eq2; Rewrite -> phibar_eq1). (Rewrite -> MSVMV1; Rewrite -> nateqb_is_eq1; Auto; Unfold Setifb). (Rewrite -> MSVMV3; Rewrite <- Lifts_PhiBar_Bridge; Rewrite -> LIFTSM4; Auto; Rewrite -> H0; Auto). (Rewrite -> HTM4; Rewrite -> max_nat0; Apply ltiSi; Auto). (Clear H; Rewrite -> Rhobar6; Rewrite -> phibar_eq2; Rewrite -> H1; Auto). (Rewrite -> Lifts_Ms_rec1; Rewrite -> MSVMV1; Rewrite -> nateqb_is_eq1; Auto; Unfold Setifb). Rewrite -> NOI_Mssub_Bridge. (Rewrite -> Drop_Lift_Ms; Auto). (Rewrite <- Lifts_PhiBar_Bridge; Rewrite -> H0; Auto). (Rewrite -> HTM4; Apply lt_max_nat1; Auto). (Apply NOI_Lift_Ms; Auto). (Rewrite -> HTM4; Rewrite -> sym_max_nat; Apply lt_max_nat1; Auto). Save. Lemma phibarrhobar : (m:M)(phibar (rhobar m))=m. Cut ((m:M)(phibarrhobar1 m))/\ ((ms:Ms)(phibarrhobar2 ms)). Intros c; Case c; Auto. Exact Phibarrhobar. Save. Lemma phibarrhobar_ms : (i:nat)(m:M)(ms:Ms) (phibar (rhobar1 i (mcons m ms)))= (sc O (lifts_Ms i O (mcons m ms))). Cut (and (m:M)(phibarrhobar1 m) (ms:Ms)(phibarrhobar2 ms)). (Intros c; Case c; Unfold phibarrhobar2 ; Intros). Apply H0. Intros. Apply phibarrhobar. Exact Phibarrhobar. Save. Lemma phirho : (n:N)(phi (rho n))=n. (Intros; Unfold rho; Rewrite <- (thetapsi (phi (rhobar (psi n)))); Rewrite -> psiphiphibar; Rewrite -> phibarrhobar; Rewrite -> thetapsi; Auto). Save. End Rhobar. Require MinMJ_L. Inductive L_Deriv : Hyps -> L -> F -> Prop := L_Axiom : (h:Hyps)(i:V)(P:F) (In_Hyps i P h)-> (L_Deriv h (vr i) P) | Implies_L : (h:Hyps)(i:V)(P:F)(Q:F)(l1:L)(l2:L)(R:F) (In_Hyps i (Impl P Q) h)-> (L_Deriv h l1 P)-> (L_Deriv (Add_Hyp Q h) l2 R)-> (L_Deriv h (app i l1 l2) R) | Implies_R : (h:Hyps)(P:F)(l:L)(Q:F) (L_Deriv (Add_Hyp P h) l Q)-> (L_Deriv h (lm l) (Impl P Q)). Scheme L_Deriv_ind1 := Induction for L_Deriv Sort Prop. (* New Induction scheme for inductive Proposition.*) Require MinMJ_M. Mutual Inductive M_Deriv : Hyps -> M -> F -> Prop := Choose : (h:Hyps)(i:V)(P:F)(ms:Ms)(R:F) (In_Hyps i P h)-> (Ms_Deriv h P ms R)-> (M_Deriv h (sc i ms) R) | Abstract : (h:Hyps)(P:F)(m:M)(Q:F) (M_Deriv (Add_Hyp P h) m Q)-> (M_Deriv h (lambda m) (Impl P Q)) with Ms_Deriv : Hyps -> F -> Ms -> F -> Prop := Meet : (h:Hyps)(P:F) (Ms_Deriv h P mnil P) | Implies_S : (h:Hyps)(m:M)(P:F)(Q:F)(ms:Ms)(R:F) (M_Deriv h m P)-> (Ms_Deriv h Q ms R)-> (Ms_Deriv h (Impl P Q) (mcons m ms) R). Scheme M_Ms_Deriv_ind1 := Induction for M_Deriv Sort Prop with Ms_M_Deriv_ind1 := Induction for Ms_Deriv Sort Prop. Lemma M_Ms_Deriv_ind : (P:(h:Hyps)(m:M)(f:F)(M_Deriv h m f)->Prop) (P0:(h:Hyps)(f:F)(m:Ms)(f0:F)(Ms_Deriv h f m f0)->Prop) ((h:Hyps)(i:V)(P1:F)(ms:Ms)(R:F) (i0:(In_Hyps i P1 h)) (m:(Ms_Deriv h P1 ms R)) (P0 h P1 ms R m)-> (P h (sc i ms) R (Choose h i P1 ms R i0 m)))-> ((h:Hyps)(P1:F)(m:M)(Q:F) (m0:(M_Deriv (Add_Hyp P1 h) m Q)) (P (Add_Hyp P1 h) m Q m0)-> (P h (lambda m) (Impl P1 Q) (Abstract h P1 m Q m0)))-> ((h:Hyps)(P1:F)(P0 h P1 mnil P1 (Meet h P1)))-> ((h:Hyps)(m:M)(P1,Q:F)(ms:Ms)(R:F) (m0:(M_Deriv h m P1)) (P h m P1 m0)-> (m1:(Ms_Deriv h Q ms R)) (P0 h Q ms R m1)-> (P0 h (Impl P1 Q) (mcons m ms) R (Implies_S h m P1 Q ms R m0 m1)))-> ((h:Hyps)(m:M)(f:F)(m0:(M_Deriv h m f))(P h m f m0))/\ ((h:Hyps)(f:F)(m:Ms)(f0:F)(m0:(Ms_Deriv h f m f0))(P0 h f m f0 m0)). Intros. Split. Exact (M_Ms_Deriv_ind1 P P0 H H0 H1 H2). Exact (Ms_M_Deriv_ind1 P P0 H H0 H1 H2). Save. Require MinMJ_N. Mutual Inductive N_Deduc : Hyps -> N -> F -> Prop := Implies_I : (h:Hyps)(P:F)(n:N)(Q:F) (N_Deduc (Add_Hyp P h) n Q)-> (N_Deduc h (lam n) (Impl P Q)) | AN_Axiom : (h:Hyps)(a:A)(P:F) (A_Deduc h a P)-> (N_Deduc h (an a) P) with A_Deduc : Hyps -> A -> F -> Prop := Implies_E : (h:Hyps)(a:A)(P:F)(Q:F)(n:N) (A_Deduc h a (Impl P Q))-> (N_Deduc h n P)-> (A_Deduc h (ap a n) Q) | A_Axiom : (h:Hyps)(i:V)(P:F) (In_Hyps i P h)-> (A_Deduc h (var i) P). Scheme N_A_Deduc_ind1 := Induction for N_Deduc Sort Prop with A_N_Deduc_ind1 := Induction for A_Deduc Sort Prop. Lemma N_A_Deduc_ind : (P:(h:Hyps)(n:N)(f:F)(N_Deduc h n f)->Prop) (P0:(h:Hyps)(a:A)(f:F)(A_Deduc h a f)->Prop) ((h:Hyps) (P1:F) (n:N) (Q:F) (n0:(N_Deduc (Add_Hyp P1 h) n Q)) (P (Add_Hyp P1 h) n Q n0) ->(P h (lam n) (Impl P1 Q) (Implies_I h P1 n Q n0))) ->((h:Hyps) (a:A) (P1:F) (a0:(A_Deduc h a P1)) (P0 h a P1 a0)->(P h (an a) P1 (AN_Axiom h a P1 a0))) ->((h:Hyps) (a:A) (P1,Q:F) (n:N) (a0:(A_Deduc h a (Impl P1 Q))) (P0 h a (Impl P1 Q) a0) ->(n0:(N_Deduc h n P1)) (P h n P1 n0) ->(P0 h (ap a n) Q (Implies_E h a P1 Q n a0 n0))) ->((h:Hyps) (i:V) (P1:F) (i0:(In_Hyps i P1 h)) (P0 h (var i) P1 (A_Axiom h i P1 i0))) ->((h:Hyps)(n:N)(f:F)(n0:(N_Deduc h n f))(P h n f n0))/\ ((h:Hyps)(a:A)(f:F)(a0:(A_Deduc h a f))(P0 h a f a0)). Intros. Split. Exact (N_A_Deduc_ind1 P P0 H H0 H1 H2). Exact (A_N_Deduc_ind1 P P0 H H0 H1 H2). Save. Require MinMJ_psi. Require MinMJ_MJ. Require MinMJ_NJ. Definition m_admis_psi : (h:Hyps)(n:N)(R:F)(N_Deduc h n R)-> Prop := [h:Hyps][n:N][R:F][prf:(N_Deduc h n R)](M_Deriv h (psi n) R). Definition m_admis_psi' : (h:Hyps)(a:A)(P:F)(A_Deduc h a P)->Prop := [h:Hyps][a:A][P:F][prf:(A_Deduc h a P)] (R:F)(ms:Ms)((Ms_Deriv h P ms R) -> (M_Deriv h (psi' a ms) R)). Lemma M_admis_psi : ((h:Hyps)(n:N)(R:F)(prf:(N_Deduc h n R))(m_admis_psi h n R prf))/\ ((h:Hyps)(a:A)(R:F)(prf:(A_Deduc h a R))(m_admis_psi' h a R prf)). (Apply N_A_Deduc_ind; Unfold m_admis_psi; Unfold m_admis_psi'; Intros). (Rewrite -> ps1; Apply Abstract; Auto). (Rewrite -> ps2; Apply H; Apply Meet; Auto; Rewrite -> ps4; Apply Choose with P:=P1; Auto). (Rewrite -> ps3; Apply H; Apply Implies_S; Auto). (Rewrite -> ps4; Apply Choose with P:=P1; Auto). Save. Lemma M_Admis_Psi : (h:Hyps)(n:N)(R:F) (N_Deduc h n R)-> (M_Deriv h (psi n) R). Cut (and (h:Hyps)(n:N)(R:F)(prf:(N_Deduc h n R))(m_admis_psi h n R prf) (h:Hyps)(a:A)(R:F)(prf:(A_Deduc h a R))(m_admis_psi' h a R prf)). (Unfold m_admis_psi; Intros c; Case c; Auto). Exact M_admis_psi. Save. Lemma M_Admis_Psi' : (h:Hyps)(a:A)(ms:Ms)(R:F)(P:F) (A_Deduc h a P)-> (Ms_Deriv h P ms R)-> (M_Deriv h (psi' a ms) R). Cut ((h:Hyps)(n:N)(R:F)(prf:(N_Deduc h n R))(m_admis_psi h n R prf)) /\((h:Hyps)(a:A)(R:F)(prf:(A_Deduc h a R))(m_admis_psi' h a R prf)). (Unfold m_admis_psi'; Intros c; Case c; Clear c; Intros). (Apply H0 with R:=P; Auto). Exact M_admis_psi. Save. Require MinMJ_theta. Require MinMJ_MJ. Require MinMJ_NJ. Definition n_admis_theta : (h:Hyps)(m:M)(P:F)(M_Deriv h m P)->Prop := [h:Hyps][m:M][R:F][prf:(M_Deriv h m R)](N_Deduc h (theta m) R). Definition n_admis_theta' : (h:Hyps)(P:F)(ms:Ms)(R:F)(Ms_Deriv h P ms R)->Prop := [h:Hyps][P:F][ms:Ms][R:F][prf:(Ms_Deriv h P ms R)] (a:A)((A_Deduc h a P) -> (N_Deduc h (theta' a ms) R)). Lemma N_admis_theta : ((h:Hyps)(m:M)(P:F)(prf:(M_Deriv h m P))(n_admis_theta h m P prf)) /\ ((h:Hyps)(P:F)(ms:Ms)(R:F)(prf:(Ms_Deriv h P ms R)) (n_admis_theta' h P ms R prf)). (Apply M_Ms_Deriv_ind; Unfold n_admis_theta; Unfold n_admis_theta'; Intros). (Rewrite -> th1; Apply H; Apply A_Axiom; Auto). (Rewrite -> th2; Apply Implies_I; Auto). (Simpl; Apply AN_Axiom; Auto). (Rewrite -> th4; Apply H0; Apply Implies_E with P:=P1; Auto). Save. Lemma N_Admis_Theta : (h:Hyps)(m:M)(R:F) (M_Deriv h m R)-> (N_Deduc h (theta m) R). Cut ((h:Hyps)(m:M)(P:F)(prf:(M_Deriv h m P))(n_admis_theta h m P prf)) /\((h:Hyps) (P:F)(ms:Ms)(R:F)(prf:(Ms_Deriv h P ms R))(n_admis_theta' h P ms R prf)). (Unfold n_admis_theta; Intros c; Case c; Clear c; Auto). Exact N_admis_theta. Save. Lemma N_Admis_Theta' : (h:Hyps)(P:F)(ms:Ms)(R:F) (Ms_Deriv h P ms R)-> ((a:A)((A_Deduc h a P)-> (N_Deduc h (theta' a ms) R))). Cut ((h:Hyps)(m:M)(P:F)(prf:(M_Deriv h m P))(n_admis_theta h m P prf)) /\((h:Hyps) (P:F)(ms:Ms)(R:F)(prf:(Ms_Deriv h P ms R))(n_admis_theta' h P ms R prf)). (Unfold n_admis_theta'; Intros c; Case c; Clear c; Intros). (Apply H0 with R:=R P:=P; Auto). Exact N_admis_theta. Save. Require MinMJ_LJ. Require MinMJ_MJ. Require MinMJ_NJ. Require MinMJ_Occurs_Lift. Recursive Definition Weaken_Hyps : nat->F->Hyps->Hyps := O P h => (Add_Hyp P h) | (S n) P MT => MT | (S n) P (Add_Hyp Q h) => (Add_Hyp Q (Weaken_Hyps n P h)). Section Weakening. Section Hyps_Weaken. Lemma In_Weaken_Hyps : (i,j:nat)(h:Hyps)(P,Q:F) (lt j (S (Len_Hyps h)))-> (In_Hyps i P h)-> (In_Hyps (lift_V j i) P (Weaken_Hyps j Q h)). (Unfold lift_V; Intros i j; Cut (nat_compare2 i j); Auto; Unfold nat_compare2; Intros c; Case c; Clear c; Intros c). (Rewrite -> ltb_is_lt1; Auto; Unfold Setifb; Intros h; Generalize i j c ; Elim h; Clear c j i; Intros). Inversion H0. Simpl in H0. (Generalize H0 H1 ; Clear H0 H1; Inversion_clear c; Intros). (Simpl; Inversion_clear H1; Auto; Simpl). Simpl. (Inversion_clear H1; Inversion_clear H2). (Apply inhyps_rec; Apply H; Auto). Rewrite -> ltb_is_lt3. (Unfold Setifb; Case c; Clear c; Intros c h; Generalize i j c ; Elim h; Clear c i j; Intros). Inversion H0. (Generalize H0 H1 ; Rewrite -> c; Clear H0 H1 c i; Intros). Simpl in H0. (Generalize H0 ; Clear H0; Inversion_clear H1; Simpl; Auto; Intros). (Apply inhyps_rec; Inversion_clear H1; Apply H; Auto). Inversion H0. (Generalize H0 H1 ; Clear H0 H1; Inversion_clear c). (Intros; Simpl; Auto). (Simpl; Intros). (Apply inhyps_rec; Inversion_clear H1; Inversion_clear H2; Apply H; Auto). (Case c; Clear c; Intros). (Apply notltii; Auto). (Apply ltnotlt; Auto). Save. End Hyps_Weaken. Section N_Weaken. Definition n_admis_weaken : (h:Hyps)(n:N)(P:F)(N_Deduc h n P)->Prop := [h:Hyps][n:N][P:F][D:(N_Deduc h n P)] (j:nat)(Q:F) (lt j (S (Len_Hyps h)))-> (N_Deduc (Weaken_Hyps j Q h) (lift_N j n) P). Definition a_admis_weaken : (h:Hyps)(a:A)(P:F)(A_Deduc h a P)->Prop := [h:Hyps][a:A][P:F][D:(A_Deduc h a P)] (j:nat)(Q:F) (lt j (S (Len_Hyps h)))-> (A_Deduc (Weaken_Hyps j Q h) (lift_A j a) P). Lemma N_admis_weaken : ((h:Hyps)(n:N)(R:F)(n0:(N_Deduc h n R))(n_admis_weaken h n R n0))/\ ((h:Hyps)(a:A)(R:F)(a0:(A_Deduc h a R))(a_admis_weaken h a R a0)). (Apply N_A_Deduc_ind; Unfold n_admis_weaken; Unfold a_admis_weaken; Intros). Simpl. (Apply Implies_I; Auto). (Rewrite <- Weaken_Hyps_eq3; Apply H; Auto). Rewrite -> LIFTN2. (Apply AN_Axiom; Apply H; Auto). (Rewrite -> LIFTN3; Apply Implies_E with P:=P1 Q:=Q). (Apply H; Auto). (Apply H0; Auto). Simpl. (Apply A_Axiom; Auto). (Apply In_Weaken_Hyps; Auto). Save. Lemma N_Admis_Weaken : (h:Hyps)(n:N)(P:F)(j:nat)(Q:F) (N_Deduc h n P)-> (lt j (S (Len_Hyps h)))-> (N_Deduc (Weaken_Hyps j Q h) (lift_N j n) P). Cut ((h:Hyps)(n:N)(R:F)(n0:(N_Deduc h n R))(n_admis_weaken h n R n0))/\ ((h:Hyps)(a:A)(R:F)(a0:(A_Deduc h a R))(a_admis_weaken h a R a0)). Unfold n_admis_weaken. Intros c; Case c; Clear c; Intros. Apply H; Auto. Exact N_admis_weaken. Save. Lemma A_Admis_Weaken : (h:Hyps)(a:A)(P:F)(j:nat)(Q:F) (A_Deduc h a P)-> (lt j (S (Len_Hyps h)))-> (A_Deduc (Weaken_Hyps j Q h) (lift_A j a) P). Cut ((h:Hyps)(n:N)(R:F)(n0:(N_Deduc h n R))(n_admis_weaken h n R n0))/\ ((h:Hyps)(a:A)(R:F)(a0:(A_Deduc h a R))(a_admis_weaken h a R a0)). Unfold a_admis_weaken. Intros c; Case c; Clear c; Intros. Apply H0; Auto. Exact N_admis_weaken. Save. End N_Weaken. Section L_Weaken. Definition l_admis_weaken : (h:Hyps)(l:L)(P:F)(L_Deriv h l P)->Prop := [h:Hyps][l:L][P:F][D:(L_Deriv h l P)] (j:nat)(Q:F) (lt j (S (Len_Hyps h)))-> (L_Deriv (Weaken_Hyps j Q h) (lift_L j l) P). Lemma L_admis_weaken : (h:Hyps)(l:L)(P:F)(D:(L_Deriv h l P)) (l_admis_weaken h l P D). (Intros; Apply L_Deriv_ind1; Clear D h l P; Unfold l_admis_weaken; Intros; Auto). Simpl. (Apply L_Axiom; Apply In_Weaken_Hyps; Auto). Simpl. (Apply Implies_L with P:=P Q:=Q; Auto). (Apply In_Weaken_Hyps; Auto). Rewrite <- Weaken_Hyps_eq3. (Apply H0; Auto). Simpl. (Apply Implies_R; Auto). (Rewrite <- Weaken_Hyps_eq3; Apply H; Auto). Save. Lemma L_Admis_Weaken : (h:Hyps)(l:L)(P,Q:F)(j:nat) (L_Deriv h l P)-> (lt j (S (Len_Hyps h)))-> (L_Deriv (Weaken_Hyps j Q h) (lift_L j l) P). Intros. Cut (h:Hyps)(l:L)(P:F)(D:(L_Deriv h l P))(l_admis_weaken h l P D). (Unfold l_admis_weaken; Intros; Auto). Exact L_admis_weaken. Save. End L_Weaken. End Weakening. Require MinMJ_LJ. Require MinMJ_MJ. Require MinMJ_NJ. Require MinMJ_Occurs_Lift. Recursive Definition Strengthen_Hyps : nat->Hyps->Hyps := n MT => MT | O (Add_Hyp Q h) => h | (S i) (Add_Hyp Q h) => (Add_Hyp Q (Strengthen_Hyps i h)). Section Strength1. Lemma Drop_S_Bridge_nat : (i,j:nat) ~i=j-> (drop_V (S i) (S j))= (S (drop_V i j)). (Intros i j; Unfold drop_V ; Simpl). (Elim j; Clear j; Intros). (Rewrite -> ltb_is_lt1; Auto). (Generalize H ; Clear H; Elim i; Auto). Intros. Cut False. Contradiction. (Apply H; Auto). (Case (ltb (S n) i); Auto). Save. Lemma In_Strength : (h:Hyps)(i,j:nat)(P:F) (In_Hyps i P h)-> ~i=j-> (In_Hyps (drop_V j i) P (Strengthen_Hyps j h)). (Induction h; Clear h; Intros). Inversion H. (Generalize H H1 ; Clear H H1; Inversion_clear H0; Intros). (Unfold drop_V; Generalize H1 ; Clear H1; Elim j; Clear j; Intros). (Cut False; Intros). Contradiction. (Apply H1; Auto). (Rewrite -> ltb_is_lt1; Auto; Unfold Setifb ; Simpl; Auto). (Generalize H1 ; Clear H1; Elim j; Clear j; Intros). Clear H1. Simpl. Unfold drop_V . Rewrite -> ltb_is_lt3. Auto. (Unfold not ; Intros c; Inversion c). (Simpl; Rewrite -> Drop_S_Bridge_nat; Auto). (Apply inhyps_rec; Apply H0; Auto). (Unfold not ; Intros; Apply H2; Auto). (Unfold not ; Intros; Apply H2; Auto). Save. End Strength1. Definition n_admis_strengthen : (h:Hyps)(n:N)(Q:F)(N_Deduc h n Q)->Prop := [h:Hyps][n:N][Q:F][D:(N_Deduc h n Q)] (i:nat) ~(Occurs_In_N i n)-> (N_Deduc (Strengthen_Hyps i h) (drop_N i n) Q). Definition a_admis_strengthen : (h:Hyps)(a:A)(Q:F)(A_Deduc h a Q)->Prop := [h:Hyps][a:A][Q:F][D:(A_Deduc h a Q)] (i:nat) ~(Occurs_In_A i a)-> (A_Deduc (Strengthen_Hyps i h) (drop_A i a) Q). Lemma N_admis_strengthen : ((h:Hyps)(n:N)(Q:F)(n0:(N_Deduc h n Q)) (n_admis_strengthen h n Q n0))/\ ((h:Hyps)(a:A)(Q:F)(a0:(A_Deduc h a Q)) (a_admis_strengthen h a Q a0)). (Apply N_A_Deduc_ind; Unfold n_admis_strengthen ; Unfold a_admis_strengthen ; Intros). (Rewrite -> DROPN1; Apply Implies_I). Rewrite <- Strengthen_Hyps_eq3. (Apply H; Auto). (Unfold not ; Intros; Apply H0; Auto). (Rewrite -> DROPN2; Apply AN_Axiom; Apply H; Auto). (Unfold not ; Intros; Apply H0; Auto). (Rewrite -> DROPN3; Apply Implies_E with P:=P1 Q:=Q; Auto). (Apply H; Auto). (Unfold not ; Intros; Apply H1; Auto). (Apply H0; Unfold not ; Intros; Apply H1; Auto). (Rewrite -> DROPN4; Apply A_Axiom; Auto). (Apply In_Strength; Auto). (Unfold not ; Intros; Apply H; Auto). Save. Lemma N_Admis_Strengthen : (h:Hyps)(n:N)(Q:F)(i:nat) (N_Deduc h n Q)-> ~(Occurs_In_N i n)-> (N_Deduc (Strengthen_Hyps i h) (drop_N i n) Q). Cut (and (h:Hyps)(n:N)(Q:F)(n0:(N_Deduc h n Q))(n_admis_strengthen h n Q n0) (h:Hyps)(a:A)(Q:F)(a0:(A_Deduc h a Q))(a_admis_strengthen h a Q a0)). Unfold n_admis_strengthen . (Intros c; Case c; Clear c; Intros). Apply H; Auto. Exact N_admis_strengthen. Save. Lemma A_Admis_Strengthen : (h:Hyps)(a:A)(Q:F)(i:nat) (A_Deduc h a Q)-> ~(Occurs_In_A i a)-> (A_Deduc (Strengthen_Hyps i h) (drop_A i a) Q). Cut (and (h:Hyps)(n:N)(Q:F)(n0:(N_Deduc h n Q))(n_admis_strengthen h n Q n0) (h:Hyps)(a:A)(Q:F)(a0:(A_Deduc h a Q))(a_admis_strengthen h a Q a0)). Unfold a_admis_strengthen . (Intros c; Case c; Clear c; Intros). (Apply H0; Auto). Exact N_admis_strengthen. Save. Definition l_admis_strengthen : (h:Hyps)(l:L)(Q:F)(L_Deriv h l Q)->Prop := [h:Hyps][l:L][Q:F][l0:(L_Deriv h l Q)] (i:nat) ~(Occurs_In_L i l)-> (L_Deriv (Strengthen_Hyps i h) (drop_L i l) Q). Lemma L_admis_strengthen : (h:Hyps)(l:L)(Q:F)(l0:(L_Deriv h l Q)) (l_admis_strengthen h l Q l0). (Intros; Apply L_Deriv_ind1; Clear l0 h l Q; Unfold l_admis_strengthen ; Intros). (Simpl; Apply L_Axiom). (Apply In_Strength; Auto). (Unfold not ; Intros; Apply H; Auto). Rewrite -> drop_L_eq2. (Apply Implies_L with P:=P Q:=Q; Auto). (Apply In_Strength; Auto). (Unfold not ; Intros; Apply H1; Auto). (Apply H; Auto). (Unfold not ; Intros; Apply H1; Auto). (Rewrite <- Strengthen_Hyps_eq3; Apply H0; Auto). (Unfold not ; Intros; Apply H1; Auto). (Rewrite -> drop_L_eq3; Apply Implies_R; Rewrite <- Strengthen_Hyps_eq3; Apply H; Auto; Unfold not ; Intros; Apply H0; Auto). Save. Lemma L_Admis_Strengthen : (h:Hyps)(l:L)(Q:F)(i:nat) (L_Deriv h l Q)-> ~(Occurs_In_L i l)-> (L_Deriv (Strengthen_Hyps i h) (drop_L i l) Q). Cut (h:Hyps)(l:L)(Q:F)(l0:(L_Deriv h l Q))(l_admis_strengthen h l Q l0). Unfold l_admis_strengthen . Intros. (Apply H; Auto). Exact L_admis_strengthen. Save. Require MinMJ_LJ. Require MinMJ_MJ. Require MinMJ_NJ. Require MinMJ_Occurs_Lift. Recursive Definition Hyps_Exchange : nat->Hyps->Hyps := i MT => MT | i (Add_Hyp P MT) => (Add_Hyp P MT) | O (Add_Hyp P (Add_Hyp Q h)) => (Add_Hyp Q (Add_Hyp P h)) | (S i) (Add_Hyp P (Add_Hyp Q h)) => (Add_Hyp P (Hyps_Exchange i (Add_Hyp Q h))). Recursive Definition V_Exchange : nat->V->V := i j => (Setifb V (nateqb i j) (S i) (Setifb V (nateqb (S i) j) i j)). Recursive Definition L_Exchange : nat->L->L := i (vr x) => (vr (V_Exchange i x)) | i (app x l1 l2) => (app (V_Exchange i x) (L_Exchange i l1) (L_Exchange (S i) l2)) | i (lm l) => (lm (L_Exchange (S i) l)). Fixpoint M_Exchange1 [m:M] : nat->M := [i:nat]Case m of (* x;ms *)[x:V][ms:Ms] (sc (V_Exchange i x) (Ms_Exchange1 ms i)) (* lam m *)[m':M] (lambda (M_Exchange1 m' (S i))) end with Ms_Exchange1 [ms:Ms] : nat->Ms := [i:nat]Case ms of (* mnil *) mnil (* m::ms *)[m:M][ms':Ms] (mcons (M_Exchange1 m i) (Ms_Exchange1 ms' i)) end. Recursive Definition M_Exchange : nat->M->M := i m => (M_Exchange1 m i). Recursive Definition Ms_Exchange : nat->Ms->Ms := i ms => (Ms_Exchange1 ms i). Fixpoint N_Exchange1 [n:N] : nat->N := [i:nat]Case n of (* lam n *)[n':N] (lam (N_Exchange1 n' (S i))) (* an a *)[a:A] (an (A_Exchange1 a i)) end with A_Exchange1 [a:A] : nat->A := [i:nat]Case a of (* ap a n *)[a':A][n:N] (ap (A_Exchange1 a' i) (N_Exchange1 n i)) (* var x *)[x:V] (var (V_Exchange i x)) end. Recursive Definition N_Exchange : nat->N->N := i n => (N_Exchange1 n i). Recursive Definition A_Exchange : nat->A->A := i a => (A_Exchange1 a i). Section Exchange. Lemma MExch1 : (i:nat)(x:V)(ms:Ms) ((M_Exchange i (sc x ms)) = (sc (V_Exchange i x) (Ms_Exchange i ms))). Auto. Save. Lemma MExch2 : (i:nat)(m:M)((M_Exchange i (lambda m)) = (lambda (M_Exchange (S i) m))). Auto. Save. Lemma MExch3 : (i:nat)(Ms_Exchange i mnil)=mnil. Auto. Save. Lemma MExch4 : (i:nat)(m:M)(ms:Ms)((Ms_Exchange i (mcons m ms)) = (mcons (M_Exchange i m) (Ms_Exchange i ms))). Auto. Save. Lemma NExch1 : (i:nat)(n:N)((N_Exchange i (lam n)) = (lam (N_Exchange (S i) n))). Auto. Save. Lemma NExch2 : (i:nat)(a:A)((N_Exchange i (an a)) = (an (A_Exchange i a))). Auto. Save. Lemma NExch3 : (i:nat)(a:A)(n:N) ((A_Exchange i (ap a n)) = (ap (A_Exchange i a) (N_Exchange i n))). Auto. Save. Lemma NExch4 : (i:nat)(x:V)((A_Exchange i (var x)) = (var (V_Exchange i x))). Auto. Save. End Exchange.Require MinMJ_Exchange. Lemma Hyps_ref_eq : (i,j:V)(P,Q:F)(h:Hyps) i=j-> (In_Hyps i P h)-> (In_Hyps j Q h)-> P=Q. (Induction i; Clear i; Intros). (Generalize H1 ; Clear H1; Rewrite <- H; Clear H j; Inversion_clear H0; Intros). (Inversion_clear H1; Auto). (Generalize H2 ; Clear H2; Rewrite <- H0; Clear H0 j; Inversion_clear H1; Intros). Inversion_clear H2. (Apply (H n P Q h0); Auto). Save. Lemma V_Exch_S_Bridge : (i,j:nat) (V_Exchange (S i) (S j))= (S (V_Exchange i j)). (Intros; Unfold V_Exchange ). (Rewrite -> nateqb_eq4; Rewrite -> nateqb_eq4). (Case (nateqb i j); Auto; Case (nateqb (S i) j); Auto). Save. Lemma V_Exch_id : (i:nat) (V_Exchange i i)=(S i). (Intros; Simpl; Unfold V_Exchange ; Rewrite -> nateqb_is_eq1; Auto). Save. Lemma In_Exch1 : (h:Hyps)(i,j:nat)(P:F) (lt i j)-> (In_Hyps i P h)-> (In_Hyps i P (Hyps_Exchange j h)). (Induction h; Clear h; Intros). Inversion H0. (Generalize H0 ; Clear H0; Inversion_clear H1). Intros. (Generalize H ; Clear H; Case l; Intros). (Generalize H H0 ; Clear H H0; Case j; Intros). Inversion H0. (Simpl; Auto). (Generalize H0 ; Clear H0; Case j; Intros). Inversion H0. (Rewrite -> Hyps_Exchange_eq4; Auto). (Case j; Intros). Inversion H1. (Clear j; Generalize H1 ; Clear H1; Case n0; Intros). (Inversion_clear H1; Inversion H2). (Inversion_clear H1; Generalize H H0 ; Clear H H0; Case l; Intros). Inversion H0. Rewrite -> Hyps_Exchange_eq4. (Apply inhyps_rec; Apply H; Auto). Save. Lemma In_Exch2 : (h:Hyps)(i,j:nat)(P:F) (lt (S j) i)-> (In_Hyps i P h)-> (In_Hyps i P (Hyps_Exchange j h)). (Intros h; Case h; Clear h). Intros. Inversion H0. (Intros f h; Case h; Clear h). Intros. (Generalize H ; Clear H; Inversion_clear H0). Intros. Inversion_clear H. Inversion H. (Intros f0 h i j; Generalize f f0 h i ; Elim j; Clear f f0 h i j). (Intros f f0 h i P H; Inversion_clear H; Inversion_clear H0). Simpl. (Intros; Inversion_clear H; Inversion_clear H0; Auto). Intros. (Generalize H1 ; Case h; Clear H1 h). (Inversion_clear H0; Inversion_clear H1; Inversion_clear H0). Simpl. Intros. (Inversion_clear H1; Inversion_clear H0; Inversion_clear H1). Intros. (Inversion_clear H0; Inversion_clear H2; Inversion_clear H0). Inversion_clear H0. Intros. Inversion_clear H0. (Rewrite -> Hyps_Exchange_eq4; Apply inhyps_rec). (Apply H; Auto). Save. Lemma In_Exch : (i,j:nat)(h:Hyps)(P,Q,R:F) (In_Hyps i P h)-> (In_Hyps j Q h)-> (In_Hyps (S j) R h)-> (In_Hyps (V_Exchange j i) P (Hyps_Exchange j h)). (Intros i j; Unfold V_Exchange; Cut (nat_compare j i); Auto; Unfold nat_compare; Intros c; Case c; Clear c; Intros H). (Rewrite -> nateqb_is_eq1; Auto; Unfold Setifb). (Rewrite -> H; Clear H j; Intros h; Generalize i ; Elim h; Clear i h). Intros. Inversion H. (Intros f h H; Generalize f ; Elim h; Clear H f h). Intros. (Inversion_clear H1; Inversion H2). (Induction i; Clear i; Intros). Simpl. (Inversion_clear H0; Auto). Rewrite -> Hyps_Exchange_eq4. Apply inhyps_rec. (Apply (H a n P Q R); Auto). (Inversion_clear H1; Auto). (Inversion_clear H2; Auto). (Inversion_clear H3; Auto). (Rewrite -> nateqb_is_eq3; Auto; Unfold 1 Setifb; Cut (nat_compare (S j) i); Auto; Unfold nat_compare; Intros c; Case c; Clear c; Intros H0). (Rewrite -> nateqb_is_eq1; Auto; Unfold Setifb). (Rewrite <- H0; Intros h; Generalize j ; Clear H H0 i j; Elim h; Clear h). (Intros; Inversion H). (Intros f h H; Generalize f ; Elim h; Clear H h f). Intros. (Inversion_clear H1; Inversion H2). (Induction j; Clear j; Intros). Simpl. (Inversion_clear H0; Inversion_clear H3; Auto). Rewrite -> Hyps_Exchange_eq4. (Inversion_clear H1; Inversion_clear H2; Inversion_clear H3; Apply inhyps_rec; Apply (H a n P Q R); Auto). (Rewrite -> nateqb_is_eq3; Auto; Unfold Setifb). (Cut (nat_compare2 i j); Auto; Unfold nat_compare2; Intros c; Case c; Clear c; Intros H1). Intros. (Apply In_Exch1; Auto). (Case H1; Clear H1). Intros. Auto_Contra H. Intros. Cut (lt (S j) i). Intros. (Apply In_Exch2; Auto). Clear H2 H3 H4. Clear h P Q R. Cut (S j)=i\/(lt (S j) i). (Intros c; Case c; Clear c; Intros). Auto_Contra H0. Auto. (Apply lt_S_le; Auto). Save. Definition l_admis_exch1 : (h:Hyps)(l:L)(R:F)(L_Deriv h l R)->Prop := [h:Hyps][l:L][R:F][l0:(L_Deriv h l R)](j:nat)(P,Q:F) (In_Hyps j P h)-> (In_Hyps (S j) Q h)-> (L_Deriv (Hyps_Exchange j h) (L_Exchange j l) R). Lemma L_admis_exch : (h:Hyps)(l:L)(R:F)(D:(L_Deriv h l R)) (l_admis_exch1 h l R D). (Intros; Apply L_Deriv_ind1; Clear D h l R; Unfold l_admis_exch1; Intros). Simpl. Apply L_Axiom. (Apply In_Exch with Q:=P0 R:=Q; Auto). (Simpl; Apply Implies_L with P:=P Q:=Q; Auto). (Apply In_Exch with Q:=P0 R:=Q0; Auto). (Apply (H j P0 Q0); Auto). (Generalize i0 H H0 H1 H2 l l0 ; Case h; Clear i0 H H0 H1 H2 l l0 h; Intros). Inversion i0. (Rewrite <- Hyps_Exchange_eq4; Apply H0 with P:=P0 Q0:=Q0; Auto). (Simpl; Apply Implies_R; Auto). (Generalize l0 H H0 H1 ; Case h; Clear l0 H H0 H1 h; Intros). Inversion H0. (Rewrite <- Hyps_Exchange_eq4; Apply (H (S j) P0 Q0); Auto). Save. Lemma L_Admis_Exch : (h:Hyps)(l:L)(R:F)(j:nat)(P,Q:F) (L_Deriv h l R)-> (In_Hyps j P h)-> (In_Hyps (S j) Q h)-> (L_Deriv (Hyps_Exchange j h) (L_Exchange j l) R). Cut (h:Hyps)(l:L)(R:F)(D:(L_Deriv h l R))(l_admis_exch1 h l R D). (Unfold l_admis_exch1; Intros). Exact (H h l R H0 j P Q H1 H2). Exact L_admis_exch. Save. Lemma Hyps_Exchange_Top : (P,Q:F)(h:Hyps) (Hyps_Exchange O (Add_Hyp P (Add_Hyp Q h)))= (Add_Hyp Q (Add_Hyp P h)). Auto. Save. Lemma L_Admis_Exch_Top : (P,Q,R:F)(h:Hyps)(l:L) (L_Deriv (Add_Hyp P (Add_Hyp Q h)) l R)-> (L_Deriv (Add_Hyp Q (Add_Hyp P h)) (L_Exchange O l) R). Intros. Rewrite <- Hyps_Exchange_Top. (Apply L_Admis_Exch with P:=P Q:=Q; Auto). Save. Definition n_admis_exch : (h:Hyps)(n:N)(R:F)(N_Deduc h n R)->Prop := [h:Hyps][n:N][R:F][n0:(N_Deduc h n R)](j:nat)(P,Q:F) (In_Hyps j P h)-> (In_Hyps (S j) Q h)-> (N_Deduc (Hyps_Exchange j h) (N_Exchange j n) R). Definition a_admis_exch : (h:Hyps)(a:A)(R:F)(A_Deduc h a R)->Prop := [h:Hyps][a:A][R:F][a0:(A_Deduc h a R)](j:nat)(P,Q:F) (In_Hyps j P h)-> (In_Hyps (S j) Q h)-> (A_Deduc (Hyps_Exchange j h) (A_Exchange j a) R). Lemma N_admis_exch : ((h:Hyps)(n:N)(R:F)(n0:(N_Deduc h n R))(n_admis_exch h n R n0))/\ ((h:Hyps)(a:A)(R:F)(a0:(A_Deduc h a R))(a_admis_exch h a R a0)). (Apply N_A_Deduc_ind; Unfold n_admis_exch ; Unfold a_admis_exch ; Intros). Simpl. (Apply Implies_I; Auto). (Generalize H H0 H1 n0 ; Case h; Clear H H0 H1 n0 h; Intros). Inversion H0. Rewrite <- Hyps_Exchange_eq4. (Apply H with P:=P Q0:=Q0; Auto). Rewrite -> NExch2. (Apply AN_Axiom; Auto). (Apply (H j P Q); Auto). (Rewrite -> NExch3; Apply Implies_E with P:=P1 Q:=Q; Auto). (Apply (H j P Q0); Auto). (Apply (H0 j P Q0); Auto). (Rewrite -> NExch4; Apply A_Axiom). (Apply In_Exch with Q:=P R:=Q; Auto). Save. Lemma N_Admis_Exch : (h:Hyps)(n:N)(R:F)(j:nat)(P,Q:F) (N_Deduc h n R)-> (In_Hyps j P h)-> (In_Hyps (S j) Q h)-> (N_Deduc (Hyps_Exchange j h) (N_Exchange j n) R). Cut (and (h:Hyps)(n:N)(R:F)(n0:(N_Deduc h n R))(n_admis_exch h n R n0) (h:Hyps)(a:A)(R:F)(a0:(A_Deduc h a R))(a_admis_exch h a R a0)). Unfold n_admis_exch . (Intros c; Case c; Clear c; Intros). (Apply H with P:=P Q:=Q; Auto). Exact N_admis_exch. Save. Lemma A_Admis_Exch : (h:Hyps)(a:A)(R:F)(j:nat)(P,Q:F) (A_Deduc h a R)-> (In_Hyps j P h)-> (In_Hyps (S j) Q h)-> (A_Deduc (Hyps_Exchange j h) (A_Exchange j a) R). Cut ((h:Hyps)(n:N)(R:F)(n0:(N_Deduc h n R))(n_admis_exch h n R n0))/\ ((h:Hyps)(a:A)(R:F)(a0:(A_Deduc h a R))(a_admis_exch h a R a0)). Unfold a_admis_exch. Intros c; Case c; Clear c; Intros; Apply H0 with P:=P Q:=Q; Auto. Exact N_admis_exch. Save. Require MinMJ_Exchange. Lemma V_Exchange_inv : (x:V)(i,j:nat) i=j-> (V_Exchange i (V_Exchange j x))=x. (Intros; Rewrite -> H; Clear H i; Cut (nat_compare j x); [ Destruct 1; Intro | Auto ]; Unfold 2 V_Exchange). (Rewrite -> nateqb_is_eq1; Auto; Simpl; Unfold V_Exchange). (Rewrite -> nateqb_is_eq3; Auto; Rewrite -> nateqb_is_eq1; Auto). (Rewrite -> nateqb_is_eq3; Auto; Cut (nat_compare (S j) x); [ Destruct 1; Intro | Auto ]). (Rewrite -> nateqb_is_eq1; Auto; Simpl; Unfold V_Exchange). (Rewrite -> nateqb_is_eq1; Auto). (Rewrite -> nateqb_is_eq3; Auto; Simpl; Unfold V_Exchange). (Rewrite -> nateqb_is_eq3; Auto; Rewrite -> nateqb_is_eq3; Auto). Save. Lemma L_Exchange_inv : (l:L)(i,j:nat) i=j-> (L_Exchange i (L_Exchange j l))=l. (Induction l; Clear l; Intros; Auto). (Rewrite -> L_Exchange_eq1; Rewrite -> L_Exchange_eq1; Rewrite -> V_Exchange_inv; Auto). (Simpl; Rewrite -> V_Exchange_inv; Auto; Rewrite -> H; Auto; Rewrite -> H0; Auto). (Simpl; Rewrite -> H; Auto). Save. Require MinMJ_Weak. Require MinMJ_N_Admis_Theta. Require MinMJ_M_Admis_Psi. Section Bridge5. Lemma M_Admis_Weaken : (h:Hyps)(m:M)(P:F)(j:nat)(Q:F) (M_Deriv h m P)-> (lt j (S (Len_Hyps h)))-> (M_Deriv (Weaken_Hyps j Q h) (lift_M j m) P). (Intros; Rewrite <- (psitheta m); Rewrite -> Lift_Psi_Bridge; Apply M_Admis_Psi; Apply N_Admis_Weaken; Auto). (Apply N_Admis_Theta; Auto). Save. Lemma Ms_Admis_Weaken : (ms:Ms)(h:Hyps)(R:F)(P:F)(j:nat)(Q:F) (Ms_Deriv h R ms P)-> (lt j (S (Len_Hyps h)))-> (Ms_Deriv (Weaken_Hyps j Q h) R (lift_Ms j ms) P). (Induction ms; Clear ms; Intros). Inversion_clear H. (Apply Meet; Auto). Inversion_clear H0. Rewrite -> LIFTM4. (Apply Implies_S; Auto). (Apply M_Admis_Weaken; Auto). Save. Lemma M_Admis_Weaken_Top : (h:Hyps)(m:M)(P:F) (M_Deriv h m P)-> (Q:F)(M_Deriv (Add_Hyp Q h) (lift_M O m) P). Intros. Rewrite <- Weaken_Hyps_eq1. (Apply M_Admis_Weaken; Auto). Save. Lemma Ms_Admis_Weaken_Top : (ms:Ms)(h:Hyps)(R,P:F) (Ms_Deriv h R ms P)-> (Q:F)(Ms_Deriv (Add_Hyp Q h) R (lift_Ms O ms) P). (Induction ms; Clear ms; Intros; Auto). (Inversion_clear H; Apply Meet; Auto). (Inversion_clear H0; Rewrite LIFTM4; Apply Implies_S; Auto). (Apply M_Admis_Weaken_Top; Auto). Save. Lemma N_Admis_Weaken_Top : (h:Hyps)(n:N)(P:F) (N_Deduc h n P)-> (Q:F)(N_Deduc (Add_Hyp Q h) (lift_N O n) P). Intros. Rewrite <- Weaken_Hyps_eq1. (Apply N_Admis_Weaken; Auto). Save. Lemma A_Admis_Weaken_Top : (h:Hyps)(a:A)(P:F) (A_Deduc h a P)-> (Q:F)(A_Deduc (Add_Hyp Q h) (lift_A O a) P). Intros. Rewrite <- Weaken_Hyps_eq1. (Apply A_Admis_Weaken; Auto). Save. Lemma L_Admis_Weaken_Top : (h:Hyps)(l:L)(P:F) (L_Deriv h l P)-> (Q:F)(L_Deriv (Add_Hyp Q h) (lift_L O l) P). Intros. Rewrite <- Weaken_Hyps_eq1. (Apply L_Admis_Weaken; Auto). Save. End Bridge5.Require MinMJ_rhobar. Require MinMJ_Bridge2. Definition lift_rhobar_bridge : M->Prop := [m:M](i:nat) (lift_L i (rhobar m))= (rhobar (lift_M i m)). Definition lift_rhobar1_bridge : Ms->Prop := [ms:Ms](i,j:nat)(m:M) (lt O i)-> ((m1:M)(k:nat) (lt (Height_M m1) (Height_Ms (mcons m ms)))-> (lift_L k (rhobar m1))= (rhobar (lift_M k m1)))-> (rhobar1 i (lift_Ms j (mcons m ms)))= (lift_L (plus i j) (rhobar1 i (mcons m ms))). Lemma lift_rhobar_Bridge : ((m:M)(lift_rhobar_bridge m))/\ ((ms:Ms)(lift_rhobar1_bridge ms)). Apply M_Ms_Height_ind. (Induction m; Clear m). (Intros x ms; Generalize x ; Elim ms; Clear ms x). (Unfold lift_rhobar_bridge; Auto). (Intros m ms H; Generalize m ; Elim ms; Clear H m ms; Unfold lift_rhobar_bridge; Unfold lift_rhobar1_bridge; Intros). (Rewrite -> Rhobar2; Rewrite -> lift_L_eq2). (Case H; Clear H; Intros). (Rewrite -> H; Auto). (Rewrite -> HTM1; Rewrite -> HTM4; Rewrite -> HTM3; Rewrite -> max_nat0; Apply ltS; Apply ltiSi; Auto). (Rewrite -> Rhobar3; Rewrite -> lift_L_eq2; Case H0; Clear H H0; Intros). (Pattern 3 i ; Rewrite <- (plus_right_id i); Rewrite -> sym_plus; Rewrite <- plus_eq2). (Rewrite <- H0; Auto). (Rewrite -> LIFTM1; Rewrite -> LIFTM4). Rewrite -> LIFTM4. Rewrite -> Rhobar3. (Rewrite -> H; Auto). (Rewrite -> HTM1; Apply ltS; Rewrite -> HTM4; Apply lt_max_nat1; Auto). (Rewrite -> HTM1; Apply ltS; Rewrite -> HTM4; Rewrite -> sym_max_nat; Apply ltS; Apply lt_max_nat2; Rewrite -> HTM4; Rewrite -> sym_max_nat; Apply lt_max_nat1; Auto). Intros. Apply H. (Rewrite -> HTM1; Apply ltS; Rewrite -> HTM4; Apply ltS; Rewrite -> sym_max_nat; Apply lt_max_nat2; Auto). (Unfold lift_rhobar_bridge; Intros). (Case H0; Clear H H0; Intros). (Rewrite -> Rhobar4; Rewrite -> lift_L_eq3; Rewrite -> H; Auto). (Rewrite -> HTM2; Apply ltiSi; Auto). (Induction ms; Clear ms). (Unfold lift_rhobar_bridge; Unfold lift_rhobar1_bridge; Intros). (Rewrite -> LIFTM4; Rewrite -> LIFTM3; Rewrite -> Rhobar6; Rewrite -> Rhobar5). (Case H; Clear H; Intros). (Rewrite <- H1; Auto). (Rewrite -> Rhobar6; Rewrite -> Rhobar5). (Rewrite -> lift_L_eq2; Rewrite -> lift_L_eq1). Unfold lift_V. Rewrite -> ltb_is_lt1. (Rewrite -> ltb_is_lt1; Auto). Unfold Setifb. Rewrite -> Lifts_Lift_L_Bridge3. Auto. (Unfold not; Intros c; Inversion c). (Inversion_clear H0; Simpl; Auto). (Rewrite -> HTM4; Rewrite -> HTM3; Rewrite -> max_nat0; Apply ltiSi; Auto). (Unfold lift_rhobar_bridge; Unfold lift_rhobar1_bridge; Intros). (Case H0; Clear H H0; Intros). Clear H0. (Rewrite -> LIFTM4; Rewrite -> Rhobar6). (Rewrite <- H2; Auto). Rewrite -> Lifts_Lift_L_Bridge3. (Rewrite -> H; Auto). Rewrite -> plus_eq2. Rewrite -> (Rhobar6 m1). Rewrite -> lift_L_eq2. Unfold lift_V. (Rewrite -> ltb_is_lt1; Unfold Setifb). Auto. (Inversion_clear H1; Simpl; Auto). (Rewrite -> HTM4; Rewrite -> sym_max_nat; Apply lt_max_nat1; Auto). (Intros; Apply H2). (Rewrite -> HTM4; Apply ltS; Rewrite -> sym_max_nat; Apply lt_max_nat2; Auto). (Unfold not; Intros c; Inversion c). (Rewrite -> HTM4; Apply lt_max_nat1; Auto). Save. Lemma Lift_RhoBar_Bridge : (m:M)(i:nat) (lift_L i (rhobar m))= (rhobar (lift_M i m)). Cut ((m:M)(lift_rhobar_bridge m))/\ ((ms:Ms)(lift_rhobar1_bridge ms)). Intros c; Case c; Auto. Exact lift_rhobar_Bridge. Save. Lemma Lift_RhoBar1_Bridge : (ms:Ms)(i,j:nat)(m:M) (lt O i)-> (rhobar1 i (lift_Ms j (mcons m ms)))= (lift_L (plus i j) (rhobar1 i (mcons m ms))). Cut (and (m:M)(lift_rhobar_bridge m) (ms:Ms)(lift_rhobar1_bridge ms)). (Intros c; Case c; Clear c; Unfold lift_rhobar_bridge ; Unfold lift_rhobar1_bridge ; Intros). (Rewrite -> H0; Auto). Exact lift_rhobar_Bridge. Save. Lemma Lifts_RhoBar_Bridge : (i,j:nat)(m:M) (lifts_L i j (rhobar m))= (rhobar (lifts_M i j m)). (Induction i; Clear i; Intros). (Rewrite -> Lifts_L0; Rewrite -> Lifts_M0; Auto). (Rewrite -> Lifts_L_rec1; Rewrite -> Lifts_M_rec1; Rewrite -> H; Rewrite -> Lift_RhoBar_Bridge; Auto). Save. Lemma Lift_RhoBar1_Bridge1 : (ms:Ms)(i,j:nat) (lt O i)-> (rhobar1 i (lift_Ms j ms))= (lift_L (plus i j) (rhobar1 i ms)). (Induction ms; Clear ms; Intros). (Rewrite -> LIFTM3; Rewrite -> Rhobar5; Rewrite -> lift_L_eq1; Unfold lift_V). (Rewrite -> ltb_is_lt1; Auto). (Inversion_clear H; Simpl; Auto). (Rewrite -> LIFTM4; Rewrite -> Rhobar6; Rewrite -> Rhobar6; Rewrite -> lift_L_eq2; Unfold lift_V). Rewrite -> ltb_is_lt1. (Unfold Setifb ; Rewrite <- Lift_RhoBar_Bridge; Rewrite -> Lifts_Lift_L_Bridge3). (Rewrite <- plus_eq2; Rewrite <- H; Auto). (Unfold not ; Intros c; Inversion c). (Inversion_clear H0; Simpl; Auto). Save. Lemma RhoBar1_Lifts_Ms1 : (ms:Ms)(i,j:nat) (rhobar1 j (lifts_Ms (S i) O ms))= (rhobar1 (S j) (lifts_Ms i O ms)). (Induction ms; Clear ms; Intros; Auto). (Rewrite -> LIFTSM4; Rewrite -> Rhobar6; Rewrite <- Lifts_RhoBar_Bridge; Rewrite -> Lifts_Lifts_L_Bridge0; Auto; Rewrite -> LIFTSM4; Rewrite -> Rhobar6; Rewrite <- Lifts_RhoBar_Bridge; Rewrite -> Lifts_Lifts_L_Bridge0; Auto; Rewrite -> sym_plus; Rewrite -> plus_eq2; Rewrite -> sym_plus; Rewrite -> plus_eq2; Rewrite -> H; Auto). Save. Lemma RhoBar1_Lifts_Ms : (i,j:nat)(ms:Ms) (rhobar1 j (lifts_Ms i O ms))= (rhobar1 (plus j i) ms). (Induction i; Clear i; Intros). (Rewrite -> Lifts_Ms0; Rewrite -> plus_right_id; Auto). (Rewrite -> RhoBar1_Lifts_Ms1; Rewrite -> H; Rewrite -> plus_eq2; Rewrite -> sym_plus; Rewrite <- plus_eq2; Rewrite -> sym_plus; Auto). Save. Definition rhobar21 : M->Prop := [m:M](x:V)(ms:Ms) ((ms1:Ms)(i:nat) (lt (Height_Ms ms1) (Height_Ms (mcons m ms)))-> (rhobar1 (S i) ms1)= (rhobar (sc O (lifts_Ms (S i) O ms1))))-> (rhobar (sc x (mcons m ms)))= (app x (rhobar m) (rhobar (sc O (lift_Ms O ms)))). Definition rhobar22 : Ms->Prop := [ms:Ms](i:nat) (rhobar1 (S i) ms)= (rhobar (sc O (lifts_Ms (S i) O ms))). Lemma Rhobar21 : ((m:M)(rhobar21 m))/\ ((ms:Ms)(rhobar22 ms)). Apply M_Ms_Height_ind. (Induction m; Clear m). (Intros x ms; Generalize x ; Elim ms; Clear x ms). (Unfold rhobar21; Unfold rhobar22; Intros). (Case H; Clear H; Intros). Clear H1. Rewrite -> Rhobar3. Rewrite -> Rhobar1. (Rewrite -> H0; Auto). (Rewrite -> Lifts_Ms_rec1; Rewrite -> Lifts_Ms0; Auto). (Rewrite -> HTM4; Rewrite -> sym_max_nat; Apply lt_max_nat1; Auto). (Unfold rhobar21; Unfold rhobar22; Intros). (Case H0; Clear H H0; Intros). (Rewrite -> Rhobar3; Rewrite -> Rhobar3). (Rewrite -> H1; Auto). (Rewrite -> Lifts_Ms_rec1; Rewrite -> Lifts_Ms0; Auto). (Rewrite -> H1; Auto). (Rewrite -> Lifts_Ms_rec1; Rewrite -> Lifts_Ms0; Auto). (Rewrite -> HTM4; Rewrite -> sym_max_nat; Apply lt_max_nat1; Auto). (Rewrite -> HTM4; Apply ltS; Apply lt_max_nat2; Rewrite -> HTM1; Apply ltS; Rewrite -> HTM4; Rewrite -> sym_max_nat; Apply lt_max_nat1; Auto). (Unfold rhobar21; Unfold rhobar22; Intros). Rewrite -> Rhobar3. Rewrite -> Rhobar4. (Case H0; Clear H H0; Intros). (Rewrite -> H1; Auto). (Rewrite -> Lifts_Ms_rec1; Rewrite -> Lifts_Ms0; Auto). (Rewrite -> HTM4; Rewrite -> sym_max_nat; Apply lt_max_nat1; Auto). (Induction ms; Clear ms). (Unfold rhobar22; Auto). (Intros m ms; Generalize m ; Elim ms; Clear m ms; Unfold rhobar21; Unfold rhobar22; Intros). (Case H0; Clear H H0; Intros). (Rewrite -> Rhobar6; Rewrite -> Rhobar5). (Rewrite -> LIFTSM4; Rewrite -> LIFTSM3; Rewrite -> Rhobar2). Rewrite -> Lifts_RhoBar_Bridge. Auto. (Case H1; Clear H0 H1; Intros; Clear H). (Rewrite -> Rhobar6; Rewrite -> LIFTSM4; Rewrite -> Rhobar3). Rewrite -> Lifts_RhoBar_Bridge. (Rewrite -> H0; Auto). (Rewrite -> LIFTSM4; Rewrite -> LIFTSM4; Rewrite -> Rhobar6; Rewrite -> Rhobar3; Rewrite -> Lifts_RhoBar_Bridge). (Rewrite -> (Lifts_M_rec1 m); Rewrite -> (Lifts_M_rec1 (lifts_M (S i) O m)); Rewrite -> Lifts_M0). (Rewrite -> RhoBar1_Lifts_Ms; Rewrite -> RhoBar1_Lifts_Ms; Auto). (Rewrite -> (HTM4 m1); Rewrite -> sym_max_nat; Apply lt_max_nat1; Auto). Save. Lemma RhoBar1 : (x:V) (rhobar (sc x mnil))=(vr x). Auto. Save. Lemma RhoBar2 : (ms:Ms)(x:V)(m:M) (rhobar (sc x (mcons m ms)))= (app x (rhobar m) (rhobar (sc O (lift_Ms O ms)))). Cut ((m:M)(rhobar21 m))/\ ((ms:Ms)(rhobar22 ms)). Intros c; Case c; Clear c; Unfold rhobar21; Unfold rhobar22; Intros. Rewrite H; Auto. Exact Rhobar21. Save. Lemma RhoBar3 : (m:M) (rhobar (lambda m))=(lm (rhobar m)). Auto. Save. Definition l_admis_rhobar_m : M->Prop := [m:M](h:Hyps)(P:F) (M_Deriv h m P)-> (L_Deriv h (rhobar m) P). Definition l_admis_rhobar_ms : Ms->Prop := [ms:Ms](h:Hyps)(P,Q:F) ((m1:M)(h1:Hyps)(P1:F) (lt (Height_M m1) (Height_Ms ms))-> (M_Deriv h1 m1 P1)-> (L_Deriv h1 (rhobar m1) P1))-> (Ms_Deriv (Add_Hyp Q h) Q ms P)-> (L_Deriv (Add_Hyp Q h) (rhobar (sc O ms)) P). Lemma L_Admis_RhoBar1 : ((m:M)(l_admis_rhobar_m m))/\ ((ms:Ms)(l_admis_rhobar_ms ms)). Apply M_Ms_Height_ind. (Induction m; Clear m). (Intros x ms; Generalize x ; Elim ms; Clear x ms; Unfold l_admis_rhobar_m; Unfold l_admis_rhobar_ms; Intros). Rewrite -> RhoBar1. Inversion_clear H0. (Generalize H1 ; Clear H; Inversion_clear H2; Intros; Apply L_Axiom; Auto). Rewrite -> RhoBar2. (Case H0; Clear H H0; Intros). (Generalize H H0 ; Clear H H0; Inversion_clear H1). (Generalize H ; Clear H; Inversion_clear H0; Intros). (Apply Implies_L with P:=P1 Q:=Q; Auto). (Apply H2; Auto). (Rewrite -> HTM1; Rewrite -> HTM4; Apply ltS; Apply lt_max_nat1; Auto). Apply H3. (Rewrite -> Height_Lift_Ms; Rewrite -> HTM1; Rewrite -> HTM4; Rewrite -> sym_max_nat; Apply ltS; Apply lt_max_nat1; Auto). Intros. (Apply H2; Auto). (Generalize H4 ; Clear H4; Rewrite -> Height_Lift_Ms; Intros). (Rewrite -> HTM1; Rewrite -> HTM4). (Apply ltS; Apply ltS; Rewrite -> sym_max_nat; Apply lt_max_nat2; Auto). (Apply Ms_Admis_Weaken_Top; Auto). (Unfold l_admis_rhobar_m; Unfold l_admis_rhobar_ms; Intros). Simpl. (Case H0; Clear H H0; Inversion_clear H1; Intros). (Apply Implies_R; Apply H0; Auto). Simpl. (Apply ltiSi; Auto). (Induction ms; Clear ms; Unfold l_admis_rhobar_m; Unfold l_admis_rhobar_ms; Intros). Clear H. Simpl. (Inversion_clear H1; Apply L_Axiom; Auto). Rewrite -> RhoBar2. (Case H0; Clear H H0; Inversion_clear H2; Intros). (Apply Implies_L with P:=P0 Q:=Q0; Auto). (Apply H1; Auto). Rewrite -> HTM4. (Apply lt_max_nat1; Auto). (Apply H2; Auto). (Rewrite -> Height_Lift_Ms; Rewrite -> HTM4; Rewrite -> sym_max_nat; Apply lt_max_nat1; Auto). Intros. (Apply H3; Auto). (Generalize H4 ; Clear H4; Rewrite -> Height_Lift_Ms; Intros; Rewrite -> HTM4; Apply ltS; Rewrite -> sym_max_nat; Apply lt_max_nat2; Auto). (Apply Ms_Admis_Weaken_Top; Auto). Save. Lemma L_Admis_RhoBar : (h:Hyps)(m:M)(P:F) (M_Deriv h m P)-> (L_Deriv h (rhobar m) P). Cut (and (m:M)(l_admis_rhobar_m m) (ms:Ms)(l_admis_rhobar_ms ms)). (Intros c; Case c; Unfold l_admis_rhobar_m; Auto). Exact L_Admis_RhoBar1. Save. Lemma L_Admis_Rho : (h:Hyps)(n:N)(P:F) (N_Deduc h n P)-> (L_Deriv h (rho n) P). (Intros; Unfold rho ; Apply L_Admis_RhoBar; Apply M_Admis_Psi; Auto). Save. Require MinMJ_Strength. Require MinMJ_Exchange2. Require MinMJ_Bridge2. Definition n_admis_sub_b : (h:Hyps)(n:N)(P:F)(N_Deduc h n P)->Prop := [h:Hyps][n:N][P:F][D:(N_Deduc h n P)] (g:nat)(Q:F)(a0:A) (In_Hyps g Q h)-> (A_Deduc (Strengthen_Hyps g h) a0 Q)-> (N_Deduc (Strengthen_Hyps g h) (NsubstAV a0 g n) P). Definition a_admis_sub_b : (h:Hyps)(a:A)(P:F)(A_Deduc h a P)->Prop := [h:Hyps][a:A][P:F][D:(A_Deduc h a P)] (g:nat)(Q:F)(a0:A) (In_Hyps g Q h)-> (A_Deduc (Strengthen_Hyps g h) a0 Q)-> (A_Deduc (Strengthen_Hyps g h) (AsubstAV a0 g a) P). Lemma n_admis_sub_B : ((h:Hyps)(n:N)(P:F)(D:(N_Deduc h n P))(n_admis_sub_b h n P D))/\ ((h:Hyps)(a:A)(P:F)(D:(A_Deduc h a P))(a_admis_sub_b h a P D)). (Apply N_A_Deduc_ind; Unfold n_admis_sub_b; Unfold a_admis_sub_b; Intros). (Rewrite -> NSAV1; Apply Implies_I; Auto). (Rewrite <- Strengthen_Hyps_eq3; Apply H with Q0:=Q0; Auto). (Simpl; Apply A_Admis_Weaken_Top; Auto). (Rewrite -> NSAV2; Apply AN_Axiom; Auto). (Apply H with Q:=Q; Auto). (Rewrite -> NSAV3; Apply Implies_E with P:=P1 Q:=Q; Auto). (Apply H with Q0:=Q0; Auto). (Apply H0 with Q:=Q0; Auto). (Rewrite -> NSAV4; Unfold VsubstAV). (Cut (nat_compare g i); [ Destruct 1; Intro | Auto ]). Replace P1 with Q. (Rewrite -> nateqb_is_eq1; Auto). (Apply Hyps_ref_eq with i:=g j:=i h:=h; Auto). (Rewrite -> nateqb_is_eq3; Auto; Simpl; Rewrite <- DROPN4; Apply A_Admis_Strengthen). (Apply A_Axiom; Auto). (Unfold not; Intros; Apply H2; Inversion_clear H3; Inversion_clear H4; Auto). Save. Lemma N_Admis_Sub_B : (h:Hyps)(n:N)(P:F)(Q:F)(a0:A)(g:nat) (N_Deduc h n P)-> (In_Hyps g Q h)-> (A_Deduc (Strengthen_Hyps g h) a0 Q)-> (N_Deduc (Strengthen_Hyps g h) (NsubstAV a0 g n) P). Cut ((h:Hyps)(n:N)(P:F)(D:(N_Deduc h n P))(n_admis_sub_b h n P D)) /\((h:Hyps)(a:A)(P:F)(D:(A_Deduc h a P))(a_admis_sub_b h a P D)). (Unfold n_admis_sub_b; Intros c; Case c; Intros). Exact (H h n P H1 g Q a0 H2 H3). Exact n_admis_sub_B. Save. Lemma A_Admis_Sub_B : (h:Hyps)(a:A)(P:F)(Q:F)(a0:A)(g:nat) (A_Deduc h a P)-> (In_Hyps g Q h)-> (A_Deduc (Strengthen_Hyps g h) a0 Q)-> (A_Deduc (Strengthen_Hyps g h) (AsubstAV a0 g a) P). Cut ((h:Hyps)(n:N)(P:F)(D:(N_Deduc h n P))(n_admis_sub_b h n P D)) /\((h:Hyps)(a:A)(P:F)(D:(A_Deduc h a P))(a_admis_sub_b h a P D)). (Unfold a_admis_sub_b; Intros c; Case c; Clear c; Intros). Exact (H0 h a P H1 g Q a0 H2 H3). Exact n_admis_sub_B. Save. Lemma SW_Id : (h:Hyps)(i:nat)(P:F) (Strengthen_Hyps i (Weaken_Hyps i P h))= h. (Induction h; Clear h; Intros). Simpl. (Elim i; Clear i; Auto). (Elim i; Auto). Intros. Simpl. (Rewrite -> H; Auto). Save. Definition n_admis_phi : (h:Hyps)(l:L)(P:F)(L_Deriv h l P)->Prop := [h:Hyps][l:L][P:F][l0:(L_Deriv h l P)](N_Deduc h (phi l) P). Lemma N_Admis_Phi_1 : (h:Hyps)(l:L)(P:F)(l0:(L_Deriv h l P)) (n_admis_phi h l P l0). (Intros; Apply L_Deriv_ind1; Clear l0 h l P; Unfold n_admis_phi; Intros). (Simpl; Apply AN_Axiom; Apply A_Axiom; Auto). Simpl. Rewrite <- (SW_Id h O Q). Rewrite -> Weaken_Hyps_eq1. (Apply N_Admis_Sub_B with Q:=Q; Auto). Simpl. (Apply Implies_E with P:=P Q:=Q; Auto). (Apply A_Axiom; Auto). Simpl. (Apply Implies_I; Auto). Save. Lemma N_Admis_Phi : (h:Hyps)(l:L)(P:F) (L_Deriv h l P)-> (N_Deduc h (phi l) P). Cut (h:Hyps)(l:L)(P:F)(l0:(L_Deriv h l P)) (n_admis_phi h l P l0). Unfold n_admis_phi; Auto. Exact N_Admis_Phi_1. Save. Lemma M_Admis_PhiBar : (h:Hyps)(l:L)(P:F) (L_Deriv h l P)-> (M_Deriv h (phibar l) P). (Intros; Rewrite <- psiphiphibar; Apply M_Admis_Psi; Apply N_Admis_Phi; Auto). Save. Require MinMJ_Exchange2. Require MinMJ_Exchange3. Require MinMJ_L_Admis_RhoBar. Lemma Exchange_Lift_V : (v,x,y:V) (x=y)-> (V_Exchange x (lift_V y v))= (lift_V (S y) v). Intros. (Rewrite -> H; Clear H x; Unfold lift_V). (Cut (nat_compare2 v (S y)); [ Destruct 1; [ Intro | Destruct 1; Intro ] | Auto ]). (Cut (nat_compare v y); [ Destruct 1; Intro | Auto ]). Rewrite -> ltb_is_lt3. (Rewrite -> ltb_is_lt1; Auto; Unfold Setifb; Unfold V_Exchange). Rewrite -> nateqb_is_eq3. (Rewrite -> nateqb_is_eq1; Auto). (Apply lt_not_eq1; Apply ltiSi; Auto). (Apply notltii; Auto). (Repeat Rewrite -> ltb_is_lt1; Unfold Setifb). (Unfold V_Exchange; Repeat Rewrite -> nateqb_is_eq3; Auto). (Apply sym_not_equal; Apply lt_not_eq1; Auto). Auto. (Apply ltS_neq_lt; Auto). (Rewrite -> H1; Clear H H0 H1 v). (Repeat Rewrite -> ltb_is_lt3; Unfold Setifb; Unfold V_Exchange). (Repeat Rewrite -> nateqb_is_eq3; Auto). (Apply notltii; Auto). (Apply ltnotlt; Apply ltiSi; Auto). (Repeat Rewrite -> ltb_is_lt3; Unfold Setifb; Unfold V_Exchange). (Repeat Rewrite -> nateqb_is_eq3; Auto). (Apply lt_not_eq1; Apply ltS; Auto). (Apply lt_not_eq1; Apply ltS; Apply Slt; Auto). (Apply ltnotlt; Auto). (Apply ltnotlt; Apply Slt; Auto). Save. Definition exchange_lift_m : M->Prop := [m:M](x,y:V) x=y-> (M_Exchange x (lift_M y m))= (lift_M (S y) m). Definition exchange_lift_ms : Ms->Prop := [ms:Ms](x,y:V) x=y-> (Ms_Exchange x (lift_Ms y ms))= (lift_Ms (S y) ms). Lemma Exchange_lift_m : ((m:M)(exchange_lift_m m))/\ ((ms:Ms)(exchange_lift_ms ms)). (Apply M_Ms_ind; Unfold exchange_lift_m; Unfold exchange_lift_ms; Intros; Auto). (Rewrite -> LIFTM1; Rewrite -> MExch1; Rewrite -> H; Auto; Rewrite -> Exchange_Lift_V; Auto). (Rewrite -> LIFTM2; Rewrite -> MExch2; Rewrite -> H; Auto). (Rewrite -> LIFTM4; Rewrite -> MExch4; Rewrite -> H; Auto; Rewrite -> H0; Auto). Save. Lemma Exchange_Lift_M : (x,y:V)(m:M) x=y-> (M_Exchange x (lift_M y m))= (lift_M (S y) m). Cut ((m:M)(exchange_lift_m m))/\ ((ms:Ms)(exchange_lift_ms ms)). Intros c; Case c; Unfold exchange_lift_m; Auto. Exact Exchange_lift_m. Save. Lemma Exchange_Lift_Ms : (x,y:V)(ms:Ms) x=y-> (Ms_Exchange x (lift_Ms y ms))= (lift_Ms (S y) ms). Cut ((m:M)(exchange_lift_m m))/\ ((ms:Ms)(exchange_lift_ms ms)). Intros c; Case c; Unfold exchange_lift_ms; Auto. Exact Exchange_lift_m. Save. Lemma Lift_Exchange_V1 : (v,x,y:V) (lt x (S y))-> (lift_V x (V_Exchange y v))= (V_Exchange (S y) (lift_V x v)). Intros. Unfold 2 lift_V. (Cut (nat_compare2 v x); [ Destruct 1; [ Intro | Destruct 1; Intro ] | Auto ]). (Rewrite -> ltb_is_lt1; Auto; Unfold Setifb; Unfold V_Exchange). Rewrite -> nateqb_is_eq3. Rewrite -> nateqb_is_eq3. Rewrite -> nateqb_is_eq3. Simpl. Unfold lift_V. (Rewrite -> ltb_is_lt1; Auto). Apply sym_not_equal. (Apply lt_not_eq1; Apply lt_trans with j:=x; Auto). (Apply ltS; Auto). (Apply sym_not_equal; Apply lt_not_eq1; Apply lt_trans with j:=x; Auto). (Apply sym_not_equal; Apply lt_not_eq1; Apply lt_trans3 with j:=x; Auto). Clear H0 H1. Rewrite -> ltb_is_lt3. (Unfold Setifb; Unfold V_Exchange). (Rewrite -> nateqb_eq4; Rewrite -> nateqb_eq4). Cut (S x)=(S y)\/(lt (S x) (S y)). (Intros c; Case c; Clear c; Intros). (Injection H0; Clear H0; Intros). (Rewrite -> H2; Rewrite -> nateqb_is_eq1; Auto). Unfold Setifb. Unfold lift_V. (Rewrite -> ltb_is_lt3; Auto). (Apply ltnotlt; Auto). Inversion_clear H0. (Rewrite -> H2; Rewrite -> nateqb_is_eq3). (Rewrite -> nateqb_is_eq3; Unfold Setifb; Unfold lift_V). (Rewrite -> ltb_is_lt3; Auto). (Apply notltii; Auto). (Apply sym_not_equal; Apply lt_not_eq1; Auto). (Apply sym_not_equal; Apply lt_not_eq1; Auto). (Apply lt_S_le; Auto). (Apply notltii; Auto). Clear H0 H1. Rewrite -> ltb_is_lt3. (Unfold Setifb; Unfold V_Exchange). (Rewrite -> nateqb_eq4; Rewrite -> nateqb_eq4). (Cut (nat_compare y v); [ Destruct 1; Intro | Auto ]). (Rewrite -> nateqb_is_eq1; Auto; Unfold Setifb; Unfold lift_V). (Rewrite -> ltb_is_lt3; Auto). (Apply ltnotlt; Auto). (Rewrite -> nateqb_is_eq3; Auto; Cut (nat_compare (S y) v); [ Destruct 1; Intro | Auto ]). (Rewrite -> nateqb_is_eq1; Auto; Unfold Setifb; Unfold lift_V). (Rewrite -> ltb_is_lt3; Auto). (Apply ltS_not_lt; Auto). (Rewrite -> nateqb_is_eq3; Auto; Unfold Setifb; Unfold lift_V). (Rewrite -> ltb_is_lt3; Auto). (Apply ltnotlt; Auto). (Apply ltnotlt; Auto). Save. Definition lift_exchange_m1 : M->Prop := [m:M](x,y:nat) (lt x (S y))-> (lift_M x (M_Exchange y m))= (M_Exchange (S y) (lift_M x m)). Definition lift_exchange_ms1 : Ms->Prop := [ms:Ms](x,y:nat) (lt x (S y))-> (lift_Ms x (Ms_Exchange y ms))= (Ms_Exchange (S y) (lift_Ms x ms)). Lemma lift_exchange_M1 : ((m:M)(lift_exchange_m1 m))/\ ((ms:Ms)(lift_exchange_ms1 ms)). (Apply M_Ms_ind; Unfold lift_exchange_m1; Unfold lift_exchange_ms1; Auto; Intros). (Rewrite -> LIFTM1; Rewrite -> MExch1; Rewrite -> MExch1; Rewrite -> LIFTM1). (Rewrite -> H; Auto). (Rewrite -> Lift_Exchange_V1; Auto). (Rewrite -> MExch2; Rewrite -> LIFTM2; Rewrite -> H; Auto). (Rewrite -> MExch4; Rewrite -> LIFTM4; Rewrite -> H; Auto; Rewrite -> H0; Auto). Save. Lemma Lift_Exchange_M1 : (m:M)(x,y:nat) (lt x (S y))-> (lift_M x (M_Exchange y m))= (M_Exchange (S y) (lift_M x m)). Cut ((m:M)(lift_exchange_m1 m))/\ ((ms:Ms)(lift_exchange_ms1 ms)). Intros c; Case c; Auto. Exact lift_exchange_M1. Save. Lemma Lift_Exchange_Ms1 : (ms:Ms)(x,y:nat) (lt x (S y))-> (lift_Ms x (Ms_Exchange y ms))= (Ms_Exchange (S y) (lift_Ms x ms)). Cut ((m:M)(lift_exchange_m1 m))/\ ((ms:Ms)(lift_exchange_ms1 ms)). Intros c; Case c; Auto. Exact lift_exchange_M1. Save. Definition exchange_rhobar_bridge : M->Prop := [m:M](x:V) (L_Exchange x (rhobar m))= (rhobar (M_Exchange x m)). Definition exchange_rhobar1_bridge : Ms->Prop := [ms:Ms](x,y:V) (L_Exchange x (rhobar (sc y ms)))= (rhobar (M_Exchange x (sc y ms))). Lemma Exchange_rhobar_bridge : ((m:M)(exchange_rhobar_bridge m))/\ ((ms:Ms)(exchange_rhobar1_bridge ms)). Apply M_Ms_Height_ind. (Destruct m; Clear m). (Intros x ms; Generalize x ; Clear x; Case ms; Unfold exchange_rhobar_bridge; Unfold exchange_rhobar1_bridge; Intros; Auto). Rewrite -> RhoBar2. Rewrite -> L_Exchange_eq2. Rewrite -> MExch1. Rewrite -> MExch4. Rewrite -> RhoBar2. (Case H; Clear H; Intros). (Rewrite -> H0; Auto). (Rewrite -> H; Auto). Rewrite -> MExch1. Unfold 2 V_Exchange. (Rewrite -> nateqb_is_eq3; Auto; Rewrite -> nateqb_is_eq3; Auto; Unfold Setifb). (Rewrite -> Lift_Exchange_Ms1; Auto). (Rewrite -> HTM1; Rewrite -> HTM4; Apply ltS; Apply lt_max_nat1; Auto). (Rewrite -> Height_Lift_Ms; Rewrite -> HTM1; Rewrite -> HTM4; Rewrite -> sym_max_nat; Apply ltS; Apply lt_max_nat1; Auto). (Unfold exchange_rhobar_bridge; Intros). (Case H; Clear H; Intros). Rewrite -> RhoBar3. (Rewrite -> L_Exchange_eq3; Rewrite -> H; Auto). (Rewrite -> HTM2; Apply ltiSi; Auto). (Destruct ms; Unfold exchange_rhobar_bridge; Unfold exchange_rhobar1_bridge; Intros; Auto). (Rewrite -> RhoBar2; Rewrite -> L_Exchange_eq2; Case H; Clear H; Intros). (Rewrite -> H; Auto). Rewrite -> MExch1. (Rewrite -> MExch1; Rewrite -> MExch4). Rewrite -> RhoBar2. (Rewrite -> H0; Auto). (Rewrite -> Lift_Exchange_Ms1; Auto). (Rewrite -> HTM4; Apply lt_max_nat1; Auto). (Rewrite -> Height_Lift_Ms; Rewrite -> HTM4; Rewrite -> sym_max_nat; Apply lt_max_nat1; Auto). Save. Lemma Exchange_RhoBar_Bridge : (x:nat)(m:M) (L_Exchange x (rhobar m))= (rhobar (M_Exchange x m)). Cut ((m:M)(exchange_rhobar_bridge m))/\ ((ms:Ms)(exchange_rhobar1_bridge ms)). Intros c; Case c; Unfold exchange_rhobar_bridge; Auto. Exact Exchange_rhobar_bridge. Save. Definition height_m_exchange : M->Prop := [m:M](x:nat) (Height_M (M_Exchange x m))= (Height_M m). Definition height_ms_exchange : Ms->Prop := [ms:Ms](x:nat) (Height_Ms (Ms_Exchange x ms))= (Height_Ms ms). Lemma Height_m_exchange : ((m:M)(height_m_exchange m))/\ ((ms:Ms)(height_ms_exchange ms)). (Apply M_Ms_ind; Unfold height_m_exchange; Unfold height_ms_exchange; Intros; Auto). (Rewrite -> MExch1; Rewrite -> HTM1; Rewrite -> H; Auto). (Rewrite -> MExch2; Rewrite -> HTM2; Rewrite -> H; Auto). (Rewrite -> MExch4; Rewrite -> HTM4; Rewrite -> H; Rewrite -> H0; Auto). Save. Lemma Height_M_Exchange : (m:M)(x:nat) (Height_M (M_Exchange x m))= (Height_M m). Cut ((m:M)(height_m_exchange m))/\ ((ms:Ms)(height_ms_exchange ms)). Intros c; Case c; Unfold height_m_exchange; Auto. Exact Height_m_exchange. Save. Lemma Height_Ms_Exchange : (ms:Ms)(x:nat) (Height_Ms (Ms_Exchange x ms))= (Height_Ms ms). Cut ((m:M)(height_m_exchange m))/\ ((ms:Ms)(height_ms_exchange ms)). Intros c; Case c; Unfold height_ms_exchange; Auto. Exact Height_m_exchange. Save. Definition msub_exch_bridge1 : M->Prop := [m:M](x,y:V)(m1:M) (MsubstVMV x m1 y (M_Exchange y m))= (MsubstVMV x m1 (S y) m). Definition mssub_exch_bridge1 : Ms->Prop := [ms:Ms](x,y:V)(m1:M) (MssubstVMV x m1 y (Ms_Exchange y ms))= (MssubstVMV x m1 (S y) ms). Lemma Msub_exch_bridge1 : ((m:M)(msub_exch_bridge1 m))/\ ((ms:Ms)(mssub_exch_bridge1 ms)). (Apply M_Ms_ind; Unfold msub_exch_bridge1; Unfold mssub_exch_bridge1; Intros; Auto). (Rewrite -> MExch1; Rewrite -> MSVMV1). Rewrite -> MSVMV1. Unfold V_Exchange. (Cut (nat_compare2 y v); [ Destruct 1; [ Intro | Destruct 1; Intro ] | Auto ]). Rewrite -> (nateqb_is_eq3 y v). Unfold 2 4 6 Setifb. (Cut (nat_compare (S y) v); [ Destruct 1; Intro | Auto ]). (Rewrite -> (nateqb_is_eq1 (S y) v); Auto). Unfold 2 3 4 5 Setifb. (Rewrite -> nateqb_is_eq1; Auto). Unfold Setifb. (Rewrite <- H3; Rewrite -> H; Auto). (Rewrite -> (nateqb_is_eq3 (S y) v); Auto). Unfold 2 3 4 5 Setifb. (Rewrite -> nateqb_is_eq3; Auto). Unfold Setifb. (Rewrite -> H; Auto). Unfold drop_V. Rewrite -> ltb_is_lt3. (Rewrite -> ltb_is_lt3; Auto). (Apply lt_not_ltS; Auto). (Apply ltnotlt; Auto). (Apply lt_not_eq1; Auto). (Apply lt_not_eq1; Auto). (Clear H0 H1; Rewrite -> (nateqb_is_eq1 y v H2)). Unfold 2 4 6 Setifb. Rewrite -> (nateqb_is_eq3 y (S y)). Unfold drop_V. Unfold 1 Setifb. Rewrite -> ltb_is_lt3. Unfold 1 Setifb. Unfold 1 pred. Rewrite -> nateqb_is_eq3. Unfold 1 Setifb. Rewrite -> ltb_is_lt1. Unfold Setifb. (Rewrite -> H; Rewrite -> H2; Auto). (Apply ltiSi; Auto). (Rewrite -> H2; Apply sym_not_equal; Apply n_Sn). (Apply ltnotlt; Apply ltiSi; Auto). (Apply n_Sn; Auto). Clear H1 H0. Rewrite -> (nateqb_is_eq3 y v). Unfold 2 4 6 Setifb. Rewrite -> (nateqb_is_eq3 (S y) v). Unfold 2 3 4 5 Setifb. Rewrite -> nateqb_is_eq3. Unfold Setifb. (Rewrite -> H; Auto). Unfold drop_V. (Rewrite -> ltb_is_lt1; Auto). (Rewrite -> ltb_is_lt1; Auto). (Apply ltS; Auto). (Apply sym_not_equal; Apply lt_not_eq1; Auto). (Apply sym_not_equal; Apply lt_not_eq1; Apply ltS; Auto). (Apply sym_not_equal; Apply lt_not_eq1; Auto). (Simpl; Rewrite -> H; Auto). (Rewrite -> MExch4; Repeat Rewrite -> MSVMV4; Rewrite -> H; Rewrite -> H0; Auto). Save. Lemma Msub_Exch_Bridge1 : (m:M)(x,y:V)(m1:M) (MsubstVMV x m1 y (M_Exchange y m))= (MsubstVMV x m1 (S y) m). Cut ((m:M)(msub_exch_bridge1 m))/\ ((ms:Ms)(mssub_exch_bridge1 ms)). Intros c; Case c; Unfold msub_exch_bridge1; Auto. Exact Msub_exch_bridge1. Save. Lemma Mssub_Exch_Bridge1 : (ms:Ms)(x,y:V)(m1:M) (MssubstVMV x m1 y (Ms_Exchange y ms))= (MssubstVMV x m1 (S y) ms). Cut ((m:M)(msub_exch_bridge1 m))/\ ((ms:Ms)(mssub_exch_bridge1 ms)). Intros c; Case c; Unfold mssub_exch_bridge1; Auto. Exact Msub_exch_bridge1. Save. Require MinMJ_Occurs. Mutual Inductive Norm_L : L->Prop := norm_vr : (x:V)(Norm_L (vr x)) | norm_app : (x:V)(l1,l2:L) (Norm_L l1)-> (Norm'_L l2)-> (Norm_L (app x l1 l2)) | norm_lm : (l:L) (Norm_L l)-> (Norm_L (lm l)) with Norm'_L : L->Prop := norm'_vr : (Norm'_L (vr O)) | norm'_app : (l1,l2:L) (Norm_L l1)-> (Norm'_L l2)-> ~(Occurs_In_L O l1)-> ~(Occurs_In_L (S O) l2)-> (Norm'_L (app O l1 l2)). Hint norm_vr. Hint norm_app. Hint norm_lm. Hint norm'_vr. Hint norm'_app. Scheme Norm_Norm'_L_ind1 := Induction for Norm_L Sort Prop with Norm'_Norm_L_ind1 := Induction for Norm'_L Sort Prop. Lemma Norm_Norm'_L_ind : (P:(l:L)(Norm_L l)->Prop) (P0:(l:L)(Norm'_L l)->Prop) ((x:V)(P (vr x) (norm_vr x))) ->((x:V) (l1,l2:L) (n:(Norm_L l1)) (P l1 n) ->(n0:(Norm'_L l2)) (P0 l2 n0) ->(P (app x l1 l2) (norm_app x l1 l2 n n0))) ->((l:L)(n:(Norm_L l))(P l n)->(P (lm l) (norm_lm l n))) ->(P0 (vr O) norm'_vr) ->((l1,l2:L) (n:(Norm_L l1)) (P l1 n) ->(n0:(Norm'_L l2)) (P0 l2 n0) ->(n1:~(Occurs_In_L O l1)) (n2:~(Occurs_In_L (S O) l2)) (P0 (app O l1 l2) (norm'_app l1 l2 n n0 n1 n2))) ->((l:L)(n:(Norm_L l))(P l n))/\ ((l:L)(n:(Norm'_L l))(P0 l n)). (Intros; Split). Exact (Norm_Norm'_L_ind1 P P0 H H0 H1 H2 H3). Exact (Norm'_Norm_L_ind1 P P0 H H0 H1 H2 H3). Save. Fixpoint Norm_Lb [l:L] : bool := Case l of (* vr x *)[x:V] true (* app x l0 l1 *)[x:V][l0,l1:L] (andb (Norm_Lb l0) (Norm'_Lb l1)) (* .\ l *)[l:L] (Norm_Lb l) end with Norm'_Lb [l:L] : bool := Case l of (* vr x *)[x:V] (nateqb x O) (* app x l0 l1 *)[x:V][l0,l1:L] (andb (nateqb x O) (andb (negb (Occurs_In_L1 O l0)) (andb (negb (Occurs_In_L1 (S O) l1)) (andb (Norm_Lb l0) (Norm'_Lb l1))))) (* .\ l *)[l:L] false end. Lemma NMLB1 : (x:V) (Norm_Lb (vr x))=true. Auto. Save. Lemma NMLB2 : (x:V)(l0,l1:L) (Norm_Lb (app x l0 l1))= (andb (Norm_Lb l0) (Norm'_Lb l1)). Auto. Save. Lemma NMLB3 : (l:L) (Norm_Lb (lm l))= (Norm_Lb l). Auto. Save. Lemma NMLB4 : (x:V) (Norm'_Lb (vr x))= (nateqb x O). Auto. Save. Lemma NMLB5 : (x:V)(l0,l1:L) (Norm'_Lb (app x l0 l1))= (andb (nateqb x O) (andb (negb (Occurs_In_L1 O l0)) (andb (negb (Occurs_In_L1 (S O) l1)) (andb (Norm_Lb l0) (Norm'_Lb l1))))). Auto. Save. Lemma NMLB6 : (l:L) (Norm'_Lb (lm l))= false. Auto. Save. Lemma nmlb1_is_nmlb1 : (l:L) ((Norm_L l)-> (Norm_Lb l)=true)/\ ((Norm'_L l)-> (Norm'_Lb l)=true). (Induction l; Clear l; Intros; Auto). (Split; Intros; Auto). (Inversion_clear H; Auto). (Case H0; Clear H0; Intros). (Case H; Clear H; Intros). (Split; Intros). Inversion_clear H3. Rewrite -> NMLB2. (Rewrite -> H; Auto). (Inversion_clear H3; Rewrite -> NMLB5). (Rewrite -> H; Auto). (Rewrite -> nateqb_is_eq1; Auto). (Rewrite -> OIL1_is_OIL3; Auto). (Rewrite -> OIL1_is_OIL3; Auto). (Split; Intros). (Inversion_clear H0; Case H; Clear H; Intros; Rewrite -> NMLB3). (Apply H; Auto). Inversion_clear H0. Save. Lemma NMLB1_is_NMLB1 : (l:L) ((Norm_L l)-> (Norm_Lb l)=true). (Intros; Cut (l:L) (and (Norm_L l)->(eq ? (Norm_Lb l) true) (Norm'_L l)->(eq ? (Norm'_Lb l) true))). (Intros c; Case (c l); Auto). Exact nmlb1_is_nmlb1. Save. Lemma NM'LB1_is_NM'LB1 : (l:L) ((Norm'_L l)-> (Norm'_Lb l)=true). (Intros; Cut (l:L) (and (Norm_L l)->(eq ? (Norm_Lb l) true) (Norm'_L l)->(eq ? (Norm'_Lb l) true))). (Intros c; Case (c l); Auto). Exact nmlb1_is_nmlb1. Save. Lemma nmlb1_is_nmlb2 : (l:L) ((Norm_Lb l)=true-> (Norm_L l))/\ ((Norm'_Lb l)=true-> (Norm'_L l)). (Induction l; Clear l; Intros; Split; Intros; Auto). Simpl in H. (Rewrite -> (nateqb_is_eq2 v O); Auto). (Case H; Clear H; Intros; Case H0; Clear H0; Intros). (Generalize H1 ; Clear H1; Rewrite -> NMLB2; Intros). Apply norm_app. Apply H. (Generalize H1 ; Clear H1; Case (Norm_Lb l); Auto). (Apply H3; Generalize H1 ; Case (Norm'_Lb l0); Auto). (Rewrite -> sym_andb; Auto). (Case H; Clear H; Intros; Case H0; Clear H0; Intros). (Generalize H1 ; Clear H1; Rewrite -> NMLB5; Intros). Rewrite -> (nateqb_is_eq2 v O). Apply norm'_app. (Apply H; Generalize H1 ; Clear H1; Case (Norm_Lb l); Auto). Simpl. (Rewrite -> andbf; Rewrite -> andbf; Rewrite -> andbf; Auto). (Apply H3; Generalize H1 ; Clear H1; Case (Norm'_Lb l0); Auto). (Rewrite -> andbf; Rewrite -> andbf; Rewrite -> andbf; Rewrite -> andbf; Auto). (Apply OIL1_is_OIL4; Generalize H1 ; Clear H1). (Case (Occurs_In_L1 O l); Auto). (Simpl; Rewrite -> andbf; Auto). (Apply OIL1_is_OIL4; Generalize H1 ; Clear H1; Case (Occurs_In_L1 (S O) l0); Auto; Simpl; Rewrite -> andbf; Rewrite -> andbf; Auto). (Generalize H1 ; Clear H1; Case (nateqb v O); Auto). (Case H; Clear H; Intros; Simpl in H0). (Apply norm_lm; Apply H; Auto). (Simpl in H0; Discriminate H0). Save. Lemma NMLB1_is_NMLB2 : (l:L) ((Norm_Lb l)=true-> (Norm_L l)). (Intros; Cut (l:L) ((Norm_Lb l)=true-> (Norm_L l))/\ ((Norm'_Lb l)=true-> (Norm'_L l))). (Intros c; Case (c l); Auto). Exact nmlb1_is_nmlb2. Save. Lemma NM'LB1_is_NM'LB2 : (l:L) ((Norm'_Lb l)=true-> (Norm'_L l)). (Intros; Cut (l:L) ((Norm_Lb l)=true-> (Norm_L l))/\ ((Norm'_Lb l)=true-> (Norm'_L l))). (Intros c; Case (c l); Auto). Exact nmlb1_is_nmlb2. Save. Lemma NMLB1_is_NMLB3 : (l:L) (~(Norm_L l)-> (Norm_Lb l)=false). Unfold not . Intros. Apply bool_dec5. Unfold not . Intros. Apply H. (Apply NMLB1_is_NMLB2; Auto). Save. Lemma NM'LB1_is_NM'LB3 : (l:L) (~(Norm'_L l)-> (Norm'_Lb l)=false). Unfold not . Intros. Apply bool_dec5. Unfold not . Intros. Apply H. (Apply NM'LB1_is_NM'LB2; Auto). Save. Lemma NMLB1_is_NMLB4 : (l:L) ((Norm_Lb l)=false-> ~(Norm_L l)). Intros. Cut (not (eq ? (Norm_Lb l) true)). (Unfold not ; Intros; Apply H0; Apply NMLB1_is_NMLB1; Auto). (Apply bool_dec6; Auto). Save. Lemma NM'LB1_is_NM'LB4 : (l:L) ((Norm'_Lb l)=false-> ~(Norm'_L l)). Intros. Cut (not (eq ? (Norm'_Lb l) true)). (Unfold not ; Intros; Apply H0; Apply NM'LB1_is_NM'LB1; Auto). (Apply bool_dec6; Auto). Save. Definition NML_compare : L->Prop := [l:L] ((Norm_L l)\/~(Norm_L l)). Lemma NML_dec : (l:L)(NML_compare l). (Unfold NML_compare ; Intros). Cut (or (eq ? (Norm_Lb l) true) (eq ? (Norm_Lb l) false)). (Intros c; Case c; Clear c; Intros). (Left; Apply NMLB1_is_NMLB2; Auto). (Right; Apply NMLB1_is_NMLB4; Auto). (Case (Norm_Lb l); Auto). Save. Definition NM'L_compare : L->Prop := [l:L] ((Norm'_L l)\/~(Norm'_L l)). Lemma NM'L_dec : (l:L)(NM'L_compare l). (Unfold NM'L_compare ; Intros). Cut (or (eq ? (Norm'_Lb l) true) (eq ? (Norm'_Lb l) false)). (Intros c; Case c; Clear c; Intros). (Left; Apply NM'LB1_is_NM'LB2; Auto). (Right; Apply NM'LB1_is_NM'LB4; Auto). (Case (Norm'_Lb l); Auto). Save. Hint NML_dec. Hint NM'L_dec. Hint norm_vr. Hint norm_app. Hint norm_lm. Hint norm'_vr. Hint norm'_app. Require MinMJ_L_Admis_RhoBar. Require MinMJ_NormL. Definition noi_rhobar1 : M->Prop := [m:M](i:nat) ~(Occurs_In_L (S i) (rhobar (lift_M i (lift_M i m)))). Definition noi_rhobar2 : Ms->Prop := [ms:Ms](i:nat) ~(Occurs_In_L (S i) (rhobar (sc O (lift_Ms i (lift_Ms i ms))))). Lemma noi_rhobar : ((m:M)(noi_rhobar1 m))/\ ((ms:Ms)(noi_rhobar2 ms)). Apply M_Ms_Height_ind. (Induction m; Clear m). (Intros x ms; Generalize x ; Elim ms; Clear x ms; Unfold noi_rhobar1; Unfold noi_rhobar2; Intros). (Simpl; Apply OIL1_is_OIL4; Rewrite -> Occurs_In_L1_eq1; Apply OIV1_is_OIV3; Apply NOI_Lift_V4; Auto). Apply NOI_Lift_V. (Rewrite -> LIFTM1; Rewrite -> LIFTM1; Case H0; Clear H0; Intros; Rewrite -> LIFTM4; Rewrite -> LIFTM4). (Rewrite -> RhoBar2; Apply OIL1_is_OIL4; Rewrite -> Occurs_In_L1_eq2; Apply ororb1; Split). (Apply OIV1_is_OIV3; Apply NOI_Lift_V4; Auto; Apply NOI_Lift_V). (Apply ororb1; Split; Apply OIL1_is_OIL3). (Clear H; Apply H0; Auto). (Rewrite -> HTM1; Rewrite -> HTM4; Rewrite -> S_max_nat_bridge0; Apply ltS; Apply lt_max_nat2; Apply ltiSi; Auto). Case i. (Rewrite -> Lift_Lift_Ms_Bridge1; Auto). (Rewrite -> (Lift_Lift_Ms_Bridge1 m0); Auto). (Apply H1; Auto). (Rewrite -> Height_Lift_Ms; Rewrite -> HTM1; Rewrite -> HTM4; Rewrite -> sym_max_nat; Rewrite -> S_max_nat_bridge0; Apply ltS; Apply lt_max_nat2; Apply ltiSi; Auto). Intros. (Rewrite -> Lift_Lift_Ms_Bridge; Auto; Rewrite -> (Lift_Lift_Ms_Bridge m0); Auto; Apply H1; Auto). (Rewrite -> Height_Lift_Ms; Rewrite -> HTM1; Rewrite -> HTM4; Rewrite -> sym_max_nat; Rewrite -> S_max_nat_bridge0; Apply ltS; Apply lt_max_nat2; Apply ltiSi; Auto). (Unfold noi_rhobar1; Unfold noi_rhobar2; Intros). (Case H0; Clear H H0; Intros). (Rewrite -> LIFTM2; Rewrite -> LIFTM2; Rewrite -> RhoBar3; Apply OIL1_is_OIL4; Rewrite -> Occurs_In_L1_eq3; Apply OIL1_is_OIL3; Apply H; Auto). (Rewrite -> HTM2; Apply ltiSi; Auto). (Intros ms; Case ms; Clear ms; Unfold noi_rhobar1; Unfold noi_rhobar2; Intros). (Simpl; Apply OIL1_is_OIL4; Auto). (Case H; Clear H; Intros). (Rewrite -> LIFTM4; Rewrite -> LIFTM4; Rewrite -> RhoBar2; Apply OIL1_is_OIL4; Rewrite -> Occurs_In_L1_eq2; Apply ororb1; Split; Auto; Apply ororb1; Split; Apply OIL1_is_OIL3). (Apply H0; Auto). (Rewrite -> HTM4; Rewrite -> S_max_nat_bridge0; Apply lt_max_nat2; Apply ltiSi; Auto). Case i. (Rewrite -> Lift_Lift_Ms_Bridge1; Auto; Rewrite -> (Lift_Lift_Ms_Bridge1 m0); Auto; Apply H; Rewrite -> Height_Lift_Ms; Rewrite -> HTM4; Rewrite -> S_max_nat_bridge0; Rewrite -> sym_max_nat; Apply lt_max_nat2; Apply ltiSi; Auto). Intros. (Rewrite -> Lift_Lift_Ms_Bridge; Auto; Rewrite -> (Lift_Lift_Ms_Bridge m0); Auto; Apply H; Auto; Rewrite -> Height_Lift_Ms; Rewrite -> HTM4; Rewrite -> S_max_nat_bridge0; Rewrite -> sym_max_nat; Apply lt_max_nat2; Apply ltiSi; Auto). Save. Lemma NOI_RhoBar1 : (m:M)(i:nat) ~(Occurs_In_L (S i) (rhobar (lift_M i (lift_M i m)))). Cut ((m:M)(noi_rhobar1 m))/\ ((ms:Ms)(noi_rhobar2 ms)). Intros c; Case c; Auto. Exact noi_rhobar. Save. Lemma NOI_RhoBar2 : (ms:Ms)(i:nat) ~(Occurs_In_L (S i) (rhobar (sc O (lift_Ms i (lift_Ms i ms))))). Cut ((m:M)(noi_rhobar1 m))/\ ((ms:Ms)(noi_rhobar2 ms)). Intros c; Case c; Auto. Exact noi_rhobar. Save. Definition norm_l_rhobar_m : M->Prop := [m:M](Norm_L (rhobar m)). Definition norm_l_rhobar_ms : Ms->Prop := [ms:Ms] (Norm'_L (rhobar (sc O (lift_Ms O ms)))). Lemma norm_l_rhobar : ((m:M)(norm_l_rhobar_m m))/\ ((ms:Ms)(norm_l_rhobar_ms ms)). Apply M_Ms_Height_ind. (Induction m; Clear m). (Intros x ms; Generalize x ; Elim ms; Clear x ms; Unfold norm_l_rhobar_m; Unfold norm_l_rhobar_ms; Intros; Auto). (Simpl; Auto). (Case H0; Clear H0 H; Intros). (Rewrite -> RhoBar2; Apply norm_app). (Apply H; Auto). (Rewrite -> HTM1; Rewrite -> HTM4; Rewrite -> S_max_nat_bridge0; Apply ltS; Apply lt_max_nat2; Apply ltiSi; Auto). (Apply H0; Auto). (Rewrite -> HTM1; Rewrite -> HTM4; Rewrite -> sym_max_nat; Rewrite -> S_max_nat_bridge0; Apply ltS; Apply lt_max_nat2; Apply ltiSi; Auto). (Unfold norm_l_rhobar_m; Unfold norm_l_rhobar_ms; Intros). Rewrite -> RhoBar3. (Case H0; Clear H H0; Intros). (Apply norm_lm; Apply H; Rewrite -> HTM2; Apply ltiSi; Auto). (Intros ms; Case ms; Clear ms; Unfold norm_l_rhobar_m; Unfold norm_l_rhobar_ms; Intros). (Simpl; Auto). (Rewrite -> LIFTM4; Rewrite -> RhoBar2; Apply norm'_app; Case H; Clear H; Intros). (Apply H0; Rewrite -> Height_Lift_M; Rewrite -> HTM4; Rewrite -> S_max_nat_bridge0; Apply lt_max_nat2; Apply ltiSi; Auto). (Apply H; Auto). (Rewrite -> Height_Lift_Ms; Rewrite -> HTM4; Rewrite -> sym_max_nat; Rewrite -> S_max_nat_bridge0; Apply lt_max_nat2; Apply ltiSi; Auto). (Rewrite <- Lift_RhoBar_Bridge; Apply NOI_Lift_L). Apply NOI_RhoBar2. Save. Lemma Norm_L_RhoBar : (m:M) (Norm_L (rhobar m)). Cut ((m:M)(norm_l_rhobar_m m))/\ ((ms:Ms)(norm_l_rhobar_ms ms)). Intros c; Case c; Auto. Exact norm_l_rhobar. Save. Lemma Norm'_L_RhoBar : (ms:Ms) (Norm'_L (rhobar (sc O (lift_Ms O ms)))). Cut ((m:M)(norm_l_rhobar_m m))/\ ((ms:Ms)(norm_l_rhobar_ms ms)). Intros c; Case c; Auto. Exact norm_l_rhobar. Save. Require MinMJ_Lifts. Require MinMJ_LJ. Require MinMJ_Exchange3. (* Recursive Definition HV_L : L->V := (vr x) => x | (app x l1 l2) => (Setifb V (nateqb O (HV_L l2)) x (HV_L l2)) | (lm l) => (HV_L l). *) Inductive L_Perm1 : L->L->Prop := l_perm1_lm : (l1,l2:L) (L_Perm1 l1 l2)-> (L_Perm1 (lm l1) (lm l2)) | l_perm1_app1 : (i:V)(l11,l12,l2:L) (L_Perm1 l11 l12)-> (L_Perm1 (app i l11 l2) (app i l12 l2)) | l_perm1_app2 : (i:V)(l1,l21,l22:L) (L_Perm1 l21 l22)-> (L_Perm1 (app i l1 l21) (app i l1 l22)) | l_perm1_app_wkn : (x:V)(l1,l2:L) ~(Occurs_In_L O l2)-> (L_Perm1 (app x l1 l2) (drop_L O l2)) | l_perm1_app_app1 : (x,y:V)(l1,l2,l3:L) ((Occurs_In_L O l2)\/(Occurs_In_L (S O) l3))-> (L_Perm1 (app x l1 (app (S y) l2 l3)) (app y (app x l1 l2) (app (lift_V O x) (lift_L O l1) (L_Exchange O l3)))) | l_perm1_app_app2 : (x:V)(l1,l2,l3:L) ((Occurs_In_L O l2)\/(Occurs_In_L (S O) l3))-> (L_Perm1 (app x l1 (app O l2 l3)) (app x l1 (app O (app (lift_V O x) (lift_L O l1) (lift_L (S O) l2)) (app (lifts_V (S (S O)) O x) (lifts_L (S (S O)) O l1) (L_Exchange O (lift_L (S (S O)) l3)))))) | l_perm1_app_lm : (x:V)(l1,l2:L) (L_Perm1 (app x l1 (lm l2)) (lm (app (lift_V O x) (lift_L O l1) (L_Exchange O l2)))). Scheme L_Perm1_ind1 := Induction for L_Perm1 Sort Prop. Require MinMJ_NormL. Require MinMJ_PermDef. Require MinMJ_HeightL. Lemma perm_not_norm_l1 : (l0,l1,l2:L)(x:V) (Occurs_In_L O l1)-> ~(Norm_L (app x l0 (app O l1 l2))). (Unfold not ; Intros; Inversion_clear H0; Inversion_clear H2; Apply H4; Auto). Save. Lemma perm_not_norm_l2 : (l0,l1,l2:L)(x:V) (Occurs_In_L (S O) l2)-> ~(Norm_L (app x l0 (app O l1 l2))). (Unfold not ; Intros; Inversion_clear H0; Inversion_clear H2; Apply H5; Auto). Save. Lemma Norm'_Norm_L : (l:L) (Norm'_L l)-> (Norm_L l). (Induction l; Clear l; Intros; Auto). Inversion_clear H1. (Apply norm_app; Auto). Inversion H0. Save. Hint Norm'_Norm_L. Lemma Perm_not_norm_l : (l0,l1:L) (L_Perm1 l0 l1)-> ~(Norm_L l0). (Intro; Apply L_Height_ind with P:=[l0:L](l1:L)(L_Perm1 l0 l1)->~(Norm_L l0); Clear l0; Induction l0; Clear l0; Intros). Inversion_clear H0. Inversion_clear H2. (Unfold not; Intros; Inversion_clear H2). Cut (lt (Height_L l) (Height_L (app v l l0))). Intros. Apply (H1 l H2 l12 H3 H4). (Simpl; Apply lt_max_nat1; Auto). (Unfold not; Intros; Inversion_clear H2). (Cut (Norm_L l0); Auto; Intros). Cut (lt (Height_L l0) (Height_L (app v l l0))). Intros. Apply (H1 l0 H6 l22 H3 H2). (Simpl; Rewrite -> sym_max_nat; Apply lt_max_nat1; Auto). (Unfold not; Intros; Apply H3). Inversion_clear H2. (Inversion_clear H5; Auto). (Unfold not; Intros; Inversion_clear H2). Inversion_clear H5. (Case H3; Clear H3; Intros). (Apply perm_not_norm_l1; Auto). (Apply perm_not_norm_l2; Auto). (Unfold not; Intros; Inversion_clear H2). Inversion_clear H4. Inversion_clear H1. (Unfold not; Intros). (Cut (lt (Height_L l) (Height_L (lm l))); Auto; Intros). Inversion_clear H1. Apply (H0 l H3 l2 H2 H4). (Simpl; Auto). Save. Lemma Perm_Not_Norm_L : (l0,l1:L) (L_Perm1 l0 l1)-> ~(Norm_L l0). (Intros; Exact (Perm_not_norm_l l0 l1 H)). Save. Lemma Norm_Imperm_L : (l0,l1:L) (Norm_L l0)-> ~(L_Perm1 l0 l1). (Unfold not; Intros; Apply (Perm_not_norm_l l0 l1 H0 H)). Save. Require MinMJ_PermDef. Require MinMJ_Normal_RhoBar. Require MinMJ_Strength. Require MinMJ_Bridge3. Inductive L_Permn : L->L->Prop := l_permn_base : (l0,l1:L) l0=l1-> (L_Permn l0 l1) | l_permn_rec : (l0,l1,l2:L) (L_Perm1 l0 l1)-> (L_Permn l1 l2)-> (L_Permn l0 l2). Scheme L_Permn_ind1 := Induction for L_Permn Sort Prop. Hint l_permn_base. Definition l_admis_perm1 : (l,l0:L)(L_Perm1 l l0)->Prop := [l,l0:L][d:(L_Perm1 l l0)] (h:Hyps)(P:F)(L_Deriv h l P)-> (L_Deriv h l0 P). Lemma L_admis_perm1 : (l,l0:L)(D:(L_Perm1 l l0)) (l_admis_perm1 l l0 D). (Intros; Apply L_Perm1_ind1; Clear D l l0; Unfold l_admis_perm1; Intros; Auto). (Inversion_clear H0; Apply Implies_R; Apply H; Auto). (Inversion_clear H0; Apply Implies_L with P:=P0 Q:=Q; Auto). (Inversion_clear H0; Apply Implies_L with P:=P0 Q:=Q; Auto). (Inversion_clear H; Rewrite <- (Strengthen_Hyps_eq2 Q h); Apply L_Admis_Strengthen; Auto). (Inversion_clear H; Inversion_clear H2; Inversion_clear H). (Apply Implies_L with P:=P1 Q:=Q0; Auto). (Apply Implies_L with P:=P0 Q:=Q; Auto). (Apply Implies_L with P:=P0 Q:=Q; Auto). (Rewrite <- Weaken_Hyps_eq1; Apply In_Weaken_Hyps; Auto). (Apply L_Admis_Weaken_Top; Auto). (Apply L_Admis_Exch_Top; Auto). (Inversion_clear H; Inversion_clear H2). (Generalize H0 H3 H4 ; Clear H0 H3 H4; Inversion_clear H; Intros). (Apply Implies_L with P:=P0 Q:=(Impl P1 Q0); Auto). (Apply Implies_L with P:=P1 Q:=Q0; Auto). (Apply Implies_L with P:=P0 Q:=(Impl P1 Q0); Auto). (Rewrite <- Weaken_Hyps_eq1; Apply In_Weaken_Hyps; Auto). (Apply L_Admis_Weaken_Top; Auto). (Rewrite <- (Weaken_Hyps_eq1 (Impl P1 Q0) h); Rewrite <- Weaken_Hyps_eq3). (Apply L_Admis_Weaken; Simpl; Auto). (Apply Implies_L with P:=P0 Q:=(Impl P1 Q0); Auto). Simpl. (Rewrite <- Weaken_Hyps_eq1; Apply In_Weaken_Hyps; Auto; Rewrite <- Weaken_Hyps_eq1; Apply In_Weaken_Hyps; Auto). (Rewrite -> Lifts_L_rec1; Rewrite -> Lifts_L_rec1; Rewrite -> Lifts_L0; Apply L_Admis_Weaken_Top; Apply L_Admis_Weaken_Top; Auto). Apply L_Admis_Exch_Top. (Rewrite <- (Weaken_Hyps_eq1 (Impl P1 Q0) h); Rewrite <- Weaken_Hyps_eq3; Rewrite <- Weaken_Hyps_eq3; Apply L_Admis_Weaken; Simpl; Auto). Inversion_clear H. (Generalize H0 H1 ; Clear H0 H1; Inversion_clear H2; Intros). (Apply Implies_R; Auto). (Apply Implies_L with P:=P0 Q:=Q; Auto). (Rewrite <- Weaken_Hyps_eq1; Apply In_Weaken_Hyps; Auto). (Apply L_Admis_Weaken_Top; Auto). (Apply L_Admis_Exch_Top; Auto). Save. Lemma L_Admis_Perm1 : (l,l0:L)(h:Hyps)(P:F) (L_Perm1 l l0)-> (L_Deriv h l P)-> (L_Deriv h l0 P). Cut (l,l0:L)(D:(L_Perm1 l l0))(l_admis_perm1 l l0 D). (Unfold l_admis_perm1; Intros). Exact (H l l0 H0 h P H1). Exact L_admis_perm1. Save. Lemma L_Perm1n : (l,l0:L) (L_Perm1 l l0)-> (L_Permn l l0). (Intros; Apply l_permn_rec with l1:=l0; Auto). Save. Definition l_permnn : (l,l0:L)(L_Permn l l0)->Prop := [l,l0:L][d:(L_Permn l l0)] (l1:L) (L_Permn l0 l1)-> (L_Permn l l1). Lemma L_permnn : (l,l0:L)(d:(L_Permn l l0)) (l_permnn l l0 d). (Intros; Apply L_Permn_ind1; Unfold l_permnn; Clear d l l0; Intros; Auto). (Rewrite -> e; Auto). (Apply l_permn_rec with l1:=l1; Auto). Save. Lemma L_Permnn : (l,l0,l1:L) (L_Permn l l0)-> (L_Permn l0 l1)-> (L_Permn l l1). Cut (l,l0:L)(d:(L_Permn l l0))(l_permnn l l0 d). (Unfold l_permnn; Intros). (Apply (H l l0); Auto). Exact L_permnn. Save. Definition l_permn_app1 : (l,l0:L)(L_Permn l l0)->Prop := [l,l0:L][D:(L_Permn l l0)] (x:V)(l1:L) (L_Permn (app x l l1) (app x l0 l1)). Lemma L_permn_app1 : (l,l0:L)(D:(L_Permn l l0)) (l_permn_app1 l l0 D). (Intros; Apply L_Permn_ind1; Clear D l l0; Unfold l_permn_app1; Intros; Auto). (Rewrite -> e; Auto). Apply l_permn_rec with l1:=(app x l1 l4). (Apply l_perm1_app1; Auto). (Apply H; Auto). Save. Lemma L_Permn_app1 : (l,l0,l1:L)(x:V) (L_Permn l l0)-> (L_Permn (app x l l1) (app x l0 l1)). Cut (l,l0:L)(d:(L_Permn l l0))(l_permn_app1 l l0 d). (Unfold l_permn_app1; Intros). Exact (H l l0 H0 x l1). Exact L_permn_app1. Save. Definition l_permn_app2 : (l0,l1:L)(L_Permn l0 l1)->Prop := [l0,l1:L][D:(L_Permn l0 l1)] (x:V)(l:L) (L_Permn (app x l l0) (app x l l1)). Lemma L_permn_app2 : (l0,l1:L)(D:(L_Permn l0 l1)) (l_permn_app2 l0 l1 D). (Intros; Apply L_Permn_ind1; Clear D l0 l1; Unfold l_permn_app2; Intros; Auto). (Rewrite -> e; Auto). Apply l_permn_rec with l1:=(app x l4 l1). (Apply l_perm1_app2; Auto). (Apply H; Auto). Save. Lemma L_Permn_app2 : (l,l0,l1:L)(x:V) (L_Permn l0 l1)-> (L_Permn (app x l l0) (app x l l1)). Cut (l0,l1:L)(D:(L_Permn l0 l1))(l_permn_app2 l0 l1 D). (Unfold l_permn_app2; Intros). Exact (H l0 l1 H0 x l). Exact L_permn_app2. Save. Lemma L_Permn_app : (x:V)(l0,l1,l2,l3:L) (L_Permn l0 l1)-> (L_Permn l2 l3)-> (L_Permn (app x l0 l2) (app x l1 l3)). Intros. Apply L_Permnn with l0:=(app x l1 l2). (Apply L_Permn_app1; Auto). (Apply L_Permn_app2; Auto). Save. Definition l_permn_lm : (l0,l1:L)(L_Permn l0 l1)->Prop := [l0,l1:L][d:(L_Permn l0 l1)] (L_Permn (lm l0) (lm l1)). Lemma L_permn_lm : (l0,l1:L)(d:(L_Permn l0 l1)) (l_permn_lm l0 l1 d). (Intros; Apply L_Permn_ind1; Unfold l_permn_lm; Clear d l0 l1; Intros; Auto). (Rewrite -> e; Auto). (Apply l_permn_rec with l1:=(lm l1); Auto). (Apply l_perm1_lm; Auto). Save. Lemma L_Permn_lm : (l,l0:L) (L_Permn l l0)-> (L_Permn (lm l) (lm l0)). Cut (l0,l1:L)(d:(L_Permn l0 l1))(l_permn_lm l0 l1 d). (Unfold l_permn_lm; Intros). Exact (H l l0 H0). Exact L_permn_lm. Save. Definition l_admis_permn : (l,l0:L)(L_Permn l l0)->Prop := [l,l0:L][d:(L_Permn l l0)] (h:Hyps)(P:F) (L_Deriv h l P)-> (L_Deriv h l0 P). Lemma L_admis_permn : (l,l0:L)(d:(L_Permn l l0)) (l_admis_permn l l0 d). (Intros; Apply L_Permn_ind1; Unfold l_admis_permn; Clear d l l0; Intros; Auto). (Rewrite <- e; Auto). Apply H. (Apply L_Admis_Perm1 with l:=l0; Auto). Save. Lemma L_Admis_Permn : (h:Hyps)(l0,l1:L)(P:F) (L_Permn l0 l1)-> (L_Deriv h l0 P)-> (L_Deriv h l1 P). Cut (l0,l1:L)(d:(L_Permn l0 l1))(l_admis_permn l0 l1 d). (Unfold l_admis_permn; Intros). Exact (H l0 l1 H0 h P H1). Exact L_admis_permn. Save. (* Definition hv_rhobar_m : M->Prop := [m:M](x:V)(l1,l2:L) (rhobar m)=(app x l1 l2)-> (HV_L l2)=O. Definition hv_rhobar_ms : Ms->Prop := [ms:Ms] (HV_L (rhobar (sc O ms)))=O. Lemma HV_rhobar_m : ((m:M)(hv_rhobar_m m))/\ ((ms:Ms)(hv_rhobar_ms ms)). Apply M_Ms_Height_ind. (Destruct m; Clear m). (Intros x ms; Generalize x ; Case ms; Clear x ms; Unfold hv_rhobar_m; Unfold hv_rhobar_ms; Intros). (Case H; Clear H; Intros). (Simpl in H0; Discriminate H0). (Generalize H0 ; Clear H0; Rewrite -> RhoBar2; Intros; Injection H0; Clear H0; Intros). Rewrite <- H0. (Case H; Clear H; Intros). (Apply H3; Auto). (Rewrite -> Height_Lift_Ms; Rewrite -> HTM1; Rewrite -> HTM4; Rewrite -> sym_max_nat; Apply ltS; Apply lt_max_nat1; Auto). (Unfold hv_rhobar_m; Unfold hv_rhobar_ms; Intros). (Simpl in H0; Discriminate H0). (Destruct ms; Clear ms; Unfold hv_rhobar_ms; Unfold hv_rhobar_m; Intros). Auto. Rewrite -> RhoBar2. Rewrite -> HV_L_eq2. (Case H; Clear H; Intros). (Rewrite -> H; Auto). (Rewrite -> Height_Lift_Ms; Rewrite -> HTM4; Rewrite -> sym_max_nat; Apply lt_max_nat1; Auto). Save. Lemma HV_rhobar1 : (ms:Ms) (HV_L (rhobar (sc O ms)))=O. Cut ((m:M)(hv_rhobar_m m))/\((ms:Ms)(hv_rhobar_ms ms)). (Intros c; Case c; Auto). Exact HV_rhobar_m. Save. Lemma HV_rhobar : (m:M)(x:V)(l1,l2:L) (rhobar m)=(app x l1 l2)-> (HV_L l2)=O. Cut ((m:M)(hv_rhobar_m m))/\((ms:Ms)(hv_rhobar_ms ms)). (Intros c; Case c; Auto). Exact HV_rhobar_m. Save. *) Definition oi_rhobar_m : M->Prop := [m:M](x:V) (Occurs_In_M x m)-> (Occurs_In_L x (rhobar m)). Definition oi_rhobar_ms : Ms->Prop := [ms:Ms](x,y:V) (Occurs_In_Ms x ms)-> (Occurs_In_L (S x) (rhobar (sc y (lift_Ms O ms)))). Lemma oi_rhobar_M : ((m:M)(oi_rhobar_m m))/\ ((ms:Ms)(oi_rhobar_ms ms)). Apply M_Ms_Height_ind. (Intro; Case m; Clear m). (Intros x ms; Generalize x ; Clear x; Case ms; Clear ms). (Unfold oi_rhobar_ms; Unfold oi_rhobar_m; Intros). Inversion_clear H0. Inversion_clear H1. (Case H; Rewrite -> H0; Clear H H0 x0; Intros). (Simpl; Auto). Inversion H1. (Unfold oi_rhobar_m; Unfold oi_rhobar_ms; Intros). (Case H; Clear H; Inversion_clear H0). (Inversion_clear H; Rewrite -> H0; Clear H0 x0; Intros). Rewrite -> RhoBar2. Auto. (Inversion_clear H; Intros). Rewrite -> RhoBar2. Apply Occurs_in_app2. (Apply H; Auto). (Rewrite -> HTM1; Apply ltS; Rewrite -> HTM4; Apply lt_max_nat1; Auto). Rewrite -> RhoBar2. (Apply Occurs_in_app3; Apply H1; Auto). (Rewrite -> HTM1; Apply ltS; Rewrite -> HTM4; Rewrite -> sym_max_nat; Apply lt_max_nat1; Auto). (Unfold oi_rhobar_m; Unfold oi_rhobar_ms; Intros). (Inversion_clear H0; Rewrite -> RhoBar3; Case H; Clear H; Intros). (Apply Occurs_in_lm; Apply H; Auto). (Rewrite -> HTM2; Apply ltiSi; Auto). (Intros ms; Case ms; Clear ms; Unfold oi_rhobar_m; Unfold oi_rhobar_ms; Intros). Inversion H0. Inversion_clear H0. (Case H; Clear H; Intros). (Rewrite -> LIFTM4; Rewrite -> RhoBar2). Apply Occurs_in_app2. (Apply H0; Auto). Rewrite -> Height_Lift_M. (Rewrite -> HTM4; Apply lt_max_nat1; Auto). Apply OIM1_is_OIM2. Rewrite -> OI_Lift_M1_4. Unfold pred. (Apply OIM1_is_OIM1; Auto). Auto. (Case H; Clear H; Intros). (Rewrite -> LIFTM4; Rewrite -> RhoBar2). Apply Occurs_in_app3. (Apply H; Auto). (Rewrite -> Height_Lift_Ms; Rewrite -> HTM4; Rewrite -> sym_max_nat; Apply lt_max_nat1; Auto). (Apply OIMs1_is_OIMs2; Rewrite -> OI_Lift_Ms1_4; Auto; Apply OIMs1_is_OIMs1; Unfold pred; Auto). Save. Lemma OI_RhoBar_M : (m:M)(x:V) (Occurs_In_M x m)-> (Occurs_In_L x (rhobar m)). Cut ((m:M)(oi_rhobar_m m))/\ ((ms:Ms)(oi_rhobar_ms ms)). Intros c; Case c; Unfold oi_rhobar_m; Auto. Exact oi_rhobar_M. Save. Lemma OI_RhoBar_Ms : (ms:Ms)(x,y:V) (Occurs_In_Ms x ms)-> (Occurs_In_L (S x) (rhobar (sc y (lift_Ms O ms)))). Cut ((m:M)(oi_rhobar_m m))/\ ((ms:Ms)(oi_rhobar_ms ms)). Intros c; Case c; Unfold oi_rhobar_ms; Auto. Exact oi_rhobar_M. Save. Lemma NOI_RhoBar_M : (m:M)(x:V) ~(Occurs_In_L x (rhobar m))-> ~(Occurs_In_M x m). (Unfold not; Intros; Apply H; Apply OI_RhoBar_M; Auto). Save. Lemma NOI_RhoBar_Ms : (ms:Ms)(x:V) ~(Occurs_In_L (S x) (rhobar (sc O (lift_Ms O ms))))-> ~(Occurs_In_Ms x ms). (Unfold not; Intros; Apply H; Apply OI_RhoBar_Ms; Auto). Save. Definition oi_rhobar_m1 : M->Prop := [m:M](x:V) (Occurs_In_L x (rhobar m))-> (Occurs_In_M x m). Definition oi_rhobar_ms1 : Ms->Prop := [ms:Ms](x:V) (Occurs_In_L (S x) (rhobar (sc O (lift_Ms O ms))))-> (Occurs_In_Ms x ms). Lemma oi_rhobar_M1 : ((m:M)(oi_rhobar_m1 m))/\ ((ms:Ms)(oi_rhobar_ms1 ms)). Apply M_Ms_Height_ind. (Intro; Case m; Clear m). (Intros x ms; Generalize x ; Clear x; Case ms; Clear ms). (Unfold oi_rhobar_m1; Unfold oi_rhobar_ms1; Intros). (Simpl in H0; Inversion_clear H0; Auto). (Unfold oi_rhobar_m1; Unfold oi_rhobar_ms1; Intros). (Case H; Clear H; Intros). (Generalize H0 ; Clear H0; Rewrite -> RhoBar2; Intros). (Inversion_clear H0; Auto). (Apply Occurs_in_sc2; Apply Occurs_in_mcons1; Apply H; Auto). (Rewrite -> HTM1; Apply ltS; Rewrite -> HTM4; Apply lt_max_nat1; Auto). (Apply Occurs_in_sc2; Apply Occurs_in_mcons2; Apply H1; Auto). (Rewrite -> HTM1; Apply ltS; Rewrite -> HTM4; Rewrite -> sym_max_nat; Apply lt_max_nat1; Auto). (Unfold oi_rhobar_m1; Unfold oi_rhobar_ms1; Intros). Simpl in H0. Inversion_clear H0. (Apply Occurs_in_lambda; Case H; Clear H; Intros; Apply H; Auto). (Rewrite -> HTM2; Apply ltiSi; Auto). (Induction ms; Clear ms; Unfold oi_rhobar_ms1; Unfold oi_rhobar_m1; Intros). (Simpl in H0; Inversion_clear H0; Inversion_clear H1; Discriminate H0). (Generalize H1 ; Rewrite -> LIFTM4; Rewrite -> RhoBar2; Case H0; Clear H H0 H1; Intros). Inversion_clear H1. (Inversion_clear H2; Discriminate H1). (Apply Occurs_in_mcons1; Cut x=(pred (S x)); Auto; Intros). (Rewrite -> H1; Apply OIM1_is_OIM2; Rewrite <- (OI_Lift_M1_4 m (S x) O); Auto). (Apply OIM1_is_OIM1; Apply H0; Auto). (Rewrite -> Height_Lift_M; Rewrite -> HTM4; Apply lt_max_nat1; Auto). (Apply Occurs_in_mcons2; Cut x=(pred (S x)); Auto). (Intros; Rewrite -> H1). (Apply OIMs1_is_OIMs2; Rewrite <- (OI_Lift_Ms1_4 m0 (S x) O); Auto). Apply OIMs1_is_OIMs1. (Apply H; Auto). (Rewrite -> Height_Lift_Ms; Rewrite -> HTM4; Rewrite -> sym_max_nat; Apply lt_max_nat1; Auto). Save. Lemma OI_RhoBar_M1 : (x:V)(m:M) (Occurs_In_L x (rhobar m))-> (Occurs_In_M x m). Cut ((m:M)(oi_rhobar_m1 m))/\ ((ms:Ms)(oi_rhobar_ms1 ms)). Intros c; Case c; Unfold oi_rhobar_m1; Auto. Exact oi_rhobar_M1. Save. Lemma OI_RhoBar_Ms1 : (x:V)(ms:Ms) (Occurs_In_L (S x) (rhobar (sc O (lift_Ms O ms))))-> (Occurs_In_Ms x ms). Cut ((m:M)(oi_rhobar_m1 m))/\ ((ms:Ms)(oi_rhobar_ms1 ms)). Intros c; Case c; Unfold oi_rhobar_ms1; Auto. Exact oi_rhobar_M1. Save. Lemma NOI_RhoBar_M1 : (x:V)(m:M) ~(Occurs_In_M x m)-> ~(Occurs_In_L x (rhobar m)). (Unfold not; Intros; Apply H; Apply OI_RhoBar_M1; Auto). Save. Lemma NOI_RhoBar_Ms1 : (x:V)(ms:Ms) ~(Occurs_In_Ms x ms)-> ~(Occurs_In_L (S x) (rhobar (sc O (lift_Ms O ms)))). (Unfold not; Intros; Apply H; Apply OI_RhoBar_Ms1; Auto). Save. Lemma Drop_RhoBar_Bridge : (x:V)(m:M) ~(Occurs_In_M x m)-> (drop_L x (rhobar m))= (rhobar (drop_M x m)). Intros. (Rewrite <- (Lift_Drop_M x m); Auto). Rewrite <- Lift_RhoBar_Bridge. Rewrite -> Drop_Lift_M. (Rewrite -> Drop_Lift_L; Auto). Save. Lemma Drop_Lift_M_Bridge1 : (m:M)(i,j:nat) ~(Occurs_In_M i m)-> (lt j (S i))-> (drop_M (S i) (lift_M j m))=(lift_M j (drop_M i m)). Intros. Rewrite <- (psitheta m). Rewrite -> Lift_Psi_Bridge. Rewrite <- Psi_Drop_N_Bridge. (Rewrite -> Drop_Lift_N_Bridge1; Auto). Rewrite <- Theta_Drop_M_Bridge. Rewrite -> Lift_Theta_Bridge. (Rewrite -> psitheta; Rewrite -> psitheta; Auto). (Apply NOI_Theta; Auto). Save. Lemma Drop_Lift_Ms_Bridge1 : (ms:Ms)(i,j:nat) ~(Occurs_In_Ms i ms)-> (lt j (S i))-> (drop_Ms (S i) (lift_Ms j ms))=(lift_Ms j (drop_Ms i ms)). (Induction ms; Clear ms; Intros). Auto. (Rewrite -> LIFTM4; Rewrite -> DROPM4; Rewrite -> Drop_Lift_M_Bridge1; Auto). (Rewrite -> H; Auto). (Unfold not; Intros; Apply H0; Auto). (Unfold not; Intros; Apply H0; Auto). Save. Definition app_red_m : M->Prop := [m:M](x:V)(m1:M) (L_Permn (app x (rhobar m1) (rhobar m)) (rhobar (MsubstVMV x m1 O m))). Definition app_red_ms : Ms->Prop := [ms:Ms](x,y:V)(m1:M) (L_Permn (app x (rhobar m1) (rhobar (sc y ms))) (app x (rhobar m1) (rhobar (sc y ms)))). Lemma app_red : ((m:M)(app_red_m m))/\ ((ms:Ms)(app_red_ms ms)). Apply M_Ms_Height_ind. (Intro; Case m; Clear m). (Intros x ms; Generalize x ; Clear x; Case ms; Clear ms). (Intros x; Case x; Clear x; Unfold app_red_m; Unfold app_red_ms; Intros). (Apply l_permn_base; Simpl; Auto). (Simpl; Unfold drop_V; Rewrite -> ltb_is_lt3). (Simpl; Apply L_Perm1n; Cut (vr n)=(drop_L O (vr (S n))); Auto). (Intros c; Rewrite -> c; Apply l_perm1_app_wkn; Auto). (Unfold not; Intros; Inversion_clear H0; Inversion_clear H1; Discriminate H0). (Unfold not; Intros c; Inversion c). (Unfold app_red_m; Unfold app_red_ms; Intros). (Case H; Clear H; Intros). Clear H0. (Generalize H ; Case x; Clear H x; Intros). (Rewrite -> MSVMV1; Rewrite -> nateqb_is_eq1; Auto; Unfold Setifb). (Rewrite -> RhoBar2; Rewrite -> RhoBar2). (Cut (OIMs_compare O (mcons m m0)); Auto; Unfold OIM_compare; Intros c; Case c; Clear c; Intros). Apply l_permn_rec with l1:=(app x0 (rhobar m1) (app O (app (lift_V O x0) (lift_L O (rhobar m1)) (lift_L (S O) (rhobar m))) (app (lifts_V (S (S O)) O x0) (lifts_L (S (S O)) O (rhobar m1)) (L_Exchange O (lift_L (S (S O)) (rhobar (sc O (lift_Ms O m0)))))))). Apply l_perm1_app_app2. Inversion_clear H0. (Left; Apply OI_RhoBar_M; Auto). (Right; Apply OI_RhoBar_Ms; Auto). Apply L_Permn_app2. (Rewrite -> Lift_RhoBar_Bridge; Rewrite -> Lift_RhoBar_Bridge). Rewrite -> Lifts_RhoBar_Bridge. (Rewrite -> MSVMV4; Rewrite -> LIFTM4; Rewrite -> RhoBar2). (Repeat Rewrite -> Lift_Mssub_Bridge1; Auto). Cut (MsubstVMV (lift_V O (lift_V O x0)) (lift_M O (lift_M O m1)) O (sc (S O) (lift_Ms (S O) (lift_Ms (S O) m0)))) =(sc O (MssubstVMV (lift_V O (lift_V O x0)) (lift_M O (lift_M O m1)) O (lift_Ms (S O) (lift_Ms (S O) m0)))). Intros. Rewrite <- H1. Apply L_Permn_app. (Rewrite -> Lift_Msub_Bridge1; Auto). (Apply H; Auto). (Rewrite -> Height_Lift_M; Rewrite -> HTM1; Rewrite -> HTM4; Apply ltS; Apply lt_max_nat1; Auto). (Rewrite -> Lift_RhoBar_Bridge; Rewrite -> Exchange_RhoBar_Bridge). Clear H1. Rewrite -> LIFTM1. Rewrite -> MExch1. Unfold 1 lift_V. (Rewrite -> ltb_is_lt1; Auto; Unfold Setifb; Unfold V_Exchange; Rewrite -> nateqb_is_eq1; Auto). Unfold Setifb. (Rewrite <- Lift_Lift_Ms_Bridge; Auto). (Rewrite -> Exchange_Lift_Ms; Auto). Unfold lifts_V. (Repeat Rewrite -> Lifts_M_rec1; Rewrite -> Lifts_M0). (Apply H; Auto). (Rewrite -> HTM1; Rewrite -> Height_Lift_Ms; Rewrite -> Height_Lift_Ms; Rewrite -> HTM1; Apply lt_S; Rewrite -> HTM4; Rewrite -> sym_max_nat; Apply lt_max_nat1; Auto). Auto. (Rewrite -> NOI_Mssub_Bridge; Auto). (Rewrite -> Lift_Drop_Ms; Auto). Apply L_Permn_app2. (Apply L_Permnn with l0:=(rhobar (MsubstVMV O m O (sc O (lift_Ms O m0)))); Auto). (Apply H; Auto). (Rewrite -> HTM1; Rewrite -> HTM1; Apply lt_S; Rewrite -> Height_Lift_Ms; Rewrite -> HTM4; Rewrite -> sym_max_nat; Apply lt_max_nat1; Auto). (Rewrite -> MSVMV1; Rewrite -> nateqb_is_eq1; Auto; Unfold Setifb). (Rewrite -> NOI_Mssub_Bridge; Auto). (Rewrite -> Drop_Lift_Ms; Auto). Apply NOI_Lift_Ms. Rewrite -> RhoBar2. (Rewrite -> MSVMV1; Rewrite -> nateqb_is_eq3; Unfold Setifb). (Cut (OIMs_compare O (mcons m m0)); Auto; Unfold OIMs_compare; Intros c; Case c; Clear c; Intros). Unfold drop_V. (Rewrite -> ltb_is_lt3; Unfold Setifb). Unfold pred. Rewrite -> MSVMV4. Rewrite -> RhoBar2. Apply l_permn_rec with l1:=(app n (app x0 (rhobar m1) (rhobar m)) (app (lift_V O x0) (lift_L O (rhobar m1)) (L_Exchange O (rhobar (sc O (lift_Ms O m0)))))). (Apply l_perm1_app_app1; Auto). Inversion_clear H0. (Left; Apply OI_RhoBar_M; Auto). (Right; Apply OI_RhoBar_Ms; Auto). Apply L_Permn_app. (Apply H; Auto). (Rewrite -> HTM1; Apply ltS; Rewrite -> HTM4; Apply lt_max_nat1; Auto). Rewrite -> Exchange_RhoBar_Bridge. Rewrite -> MExch1. (Unfold V_Exchange; Rewrite -> nateqb_is_eq1; Auto; Unfold Setifb). Rewrite -> Exchange_Lift_Ms. Rewrite -> Lift_RhoBar_Bridge. (Apply L_Permnn with l0:=(rhobar (MsubstVMV (lift_V O x0) (lift_M O m1) O (sc (S O) (lift_Ms (S O) m0)))); Auto). (Apply H; Auto). (Rewrite -> HTM1; Rewrite -> HTM1; Apply lt_S; Rewrite -> Height_Lift_Ms; Rewrite -> HTM4; Rewrite -> sym_max_nat; Apply lt_max_nat1; Auto). (Rewrite -> MSVMV1; Rewrite -> nateqb_is_eq3; Unfold Setifb). Unfold drop_V. Unfold ltb. Unfold Setifb. Unfold pred. (Rewrite -> Lift_Mssub_Bridge1; Auto). Discriminate. Auto. (Unfold not; Intros x; Inversion x). Unfold drop_V. (Unfold ltb; Unfold Setifb). Unfold pred. (Rewrite -> MSVMV4; Rewrite -> RhoBar2). Rewrite -> NOI_Mssub_Bridge. Rewrite -> NOI_Msub_Bridge. Apply l_permn_rec with l1:=(drop_L O (app (S n) (rhobar m) (rhobar (sc O (lift_Ms O m0))))). (Apply l_perm1_app_wkn; Auto). (Apply OIL1_is_OIL4; Rewrite -> Occurs_In_L1_eq2; Apply ororb1; Split; Auto; Apply ororb1; Split; Apply OIL1_is_OIL3). Apply NOI_RhoBar_M1. (Unfold not; Intros; Apply H0; Auto). Apply NOI_RhoBar_Ms1. (Unfold not; Intros; Apply H0; Auto). Rewrite -> drop_L_eq2. Unfold drop_V. Unfold ltb. Unfold Setifb. Rewrite -> Drop_RhoBar_Bridge. Rewrite -> Drop_RhoBar_Bridge. Rewrite -> DROPM1. (Unfold drop_V; Unfold ltb; Unfold Setifb). (Rewrite -> Drop_Lift_Ms_Bridge1; Auto). (Unfold not; Intros; Auto_Contra H0). (Apply OIM1_is_OIM4; Rewrite -> OIM1; Apply ororb1; Split; Auto). (Rewrite -> OI_Lift_Ms1_4; Auto). (Unfold pred; Apply OIMs1_is_OIMs3; Unfold not; Intros; Auto_Contra H0). (Unfold not; Intros; Auto_Contra H0). (Unfold not; Intros; Auto_Contra H0). (Unfold not; Intros; Auto_Contra H0). Discriminate. (Unfold app_red_m; Unfold app_red_ms; Intros). Simpl. (Case H; Clear H; Intros). Clear H0. Apply l_permn_rec with l1:=(lm (app (lift_V O x) (lift_L O (rhobar m1)) (L_Exchange O (rhobar m)))). Apply l_perm1_app_lm. Rewrite -> Exchange_RhoBar_Bridge. Apply L_Permn_lm. Rewrite -> Lift_RhoBar_Bridge. Apply L_Permnn with l0:=(rhobar (MsubstVMV (lift_V O x) (lift_M O m1) O (M_Exchange O m))). (Apply H; Auto). Rewrite -> Height_M_Exchange. (Rewrite -> HTM2; Apply ltiSi; Auto). (Rewrite -> Msub_Exch_Bridge1; Auto). (Unfold app_red_ms; Auto). Save. Lemma App_Red_M : (x:V)(m1,m:M) (L_Permn (app x (rhobar m1) (rhobar m)) (rhobar (MsubstVMV x m1 O m))). Cut ((m:M)(app_red_m m))/\ ((ms:Ms)(app_red_ms ms)). Intros c; Case c; Unfold app_red_m; Auto. Exact app_red. Save. Lemma Norm_Red : (l:L)(L_Permn l (rhobar (phibar l))). (Induction l; Clear l; Auto; Intros). Simpl. Apply L_Permnn with l0:=(app v (rhobar (phibar l)) (rhobar (phibar l0))). (Apply L_Permn_app; Auto). Apply App_Red_M. (Simpl; Apply L_Permn_lm; Auto). Save.