(* File: Derivable.v  (last edited on 1/1/2000) (c) Klaus Weich  *)


Require Export Derivable_Def.


Lemma derivable_eq :
 forall (context context' : flist) (a a' : form),
 context = context' -> a = a' -> Derivable context a -> Derivable context' a'.
(* Goal: forall (context context' : flist) (a a' : form) (_ : @eq flist context context') (_ : @eq form a a') (_ : Derivable context a), Derivable context' a' *)
intros context context' a a' eq_context eq_a.
(* Goal: @eq flist (@cons form a context) (@app form (@cons form a l1) (@cons form c l2)) *)
(* Goal: Derivable fnil c *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b)) (_ : derives context s a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (_ : derives context s b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
 rewrite eq_context.
(* Goal: forall _ : Derivable context' a, Derivable context' a' *)
 rewrite eq_a.
(* Goal: forall (_ : @eq (list form) context (@app form l1 (@cons form c l2))) (_ : @eq form a d), @eq flist context (@app form l1 (@cons form c l2)) *)
intros; assumption.
Qed.



Lemma derivable_subst :
 forall (i : Int) (g : form) (context : flist) (a : form),
 Derivable context a -> Derivable (subst_list i g context) (subst_form i g a).
(* Goal: forall (i : Int) (g : form) (context : flist) (a : form) (_ : Derivable context a), Derivable (subst_list i g context) (subst_form i g a) *)
intros i g context a der.
(* Goal: Derivable context (Imp a b) *)
elim der; clear der.
(* Goal: forall (t : proof_term) (_ : derives context t (Imp (AndF a0 a1) b)), Derivable context (Imp a0 (Imp a1 b)) *)
intros t der.
(* Goal: Derivable (subst_list i g context) (subst_form i g a) *)
elim der; clear der a t context.

(* Goal: forall (context : flist) (n : nat) (a : form) (_ : my_nth form n context a), Derivable (subst_list i g context) (subst_form i g a) *)
(* Goal: forall (context : flist) (t : proof_term) (a : form) (_ : derives context t Falsum) (_ : Derivable (subst_list i g context) (subst_form i g Falsum)), Derivable (subst_list i g context) (subst_form i g a) *)
(* Goal: forall (context : flist) (a : form) (r : proof_term) (b : form) (_ : derives (@cons form a context) r b) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (Imp a b)) *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : Derivable (subst_list i g context) (subst_form i g (Imp a b))) (_ : derives context s a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g b) *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)) (_ : derives context s b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (AndF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *)
intros context n a nth.
(* Goal: Derivable (@app form l1 l2) a *)
(* Goal: forall (n' : nat) (_ : my_nth form n' (@cons form b l2) a) (_ : Derivable fnil b), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (t : proof_term) (a : form) (_ : derives context t Falsum) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) Falsum) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (a : form) (r : proof_term) (b : form) (_ : derives (@cons form a context) r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b) *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b)) (_ : derives context s a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (_ : derives context s b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
apply Derivable_Intro with (Var n).
(* Goal: derives (@cons form (Atom i) context') (Var O) (Atom i) *)
apply ByAssumption.
(* Goal: my_nth form n (subst_list i g context) (subst_form i g a) *)
(* Goal: forall (context : flist) (t : proof_term) (a : form) (_ : derives context t Falsum) (_ : Derivable (subst_list i g context) (subst_form i g Falsum)), Derivable (subst_list i g context) (subst_form i g a) *)
(* Goal: forall (context : flist) (a : form) (r : proof_term) (b : form) (_ : derives (@cons form a context) r b) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (Imp a b)) *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : Derivable (subst_list i g context) (subst_form i g (Imp a b))) (_ : derives context s a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g b) *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)) (_ : derives context s b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (AndF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *)
apply subst_nth; assumption.

(* Goal: forall (context : flist) (t : proof_term) (a : form) (_ : derives context t Falsum) (_ : Derivable (subst_list i g context) (subst_form i g Falsum)), Derivable (subst_list i g context) (subst_form i g a) *)
(* Goal: forall (context : flist) (a : form) (r : proof_term) (b : form) (_ : derives (@cons form a context) r b) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (Imp a b)) *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : Derivable (subst_list i g context) (subst_form i g (Imp a b))) (_ : derives context s a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g b) *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)) (_ : derives context s b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (AndF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *)
intros context t a der ih.
(* Goal: Derivable (subst_list i g context) (subst_form i g (Imp a b)) *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : Derivable (subst_list i g context) (subst_form i g (Imp a b))) (_ : derives context s a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g b) *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)) (_ : derives context s b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (AndF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *)
elim ih; clear ih.
(* Goal: forall (t : proof_term) (_ : derives (subst_list i g (@cons form a context)) t (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (Imp a b)) *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : Derivable (subst_list i g context) (subst_form i g (Imp a b))) (_ : derives context s a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g b) *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)) (_ : derives context s b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (AndF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *)
intros t1 der1.
(* Goal: Derivable (subst_list i g context) (subst_form i g a) *)
(* Goal: forall (context : flist) (a : form) (r : proof_term) (b : form) (_ : derives (@cons form a context) r b) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (Imp a b)) *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : Derivable (subst_list i g context) (subst_form i g (Imp a b))) (_ : derives context s a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g b) *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)) (_ : derives context s b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (AndF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *)
apply Derivable_Intro with (Efq t1 (subst_form i g a)).
(* Goal: derives (@app form l1 l2) (Efq t0 a) a *)
(* Goal: forall (context : flist) (a : form) (r : proof_term) (b : form) (_ : derives (@cons form a context) r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b) *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b)) (_ : derives context s a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (_ : derives context s b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
apply ByAbsurdity; assumption.

(* Goal: forall (context : flist) (a : form) (r : proof_term) (b : form) (_ : derives (@cons form a context) r b) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (Imp a b)) *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : Derivable (subst_list i g context) (subst_form i g (Imp a b))) (_ : derives context s a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g b) *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)) (_ : derives context s b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (AndF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *)
intros context a t b der ih.
(* Goal: Derivable (subst_list i g context) (subst_form i g (Imp a b)) *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : Derivable (subst_list i g context) (subst_form i g (Imp a b))) (_ : derives context s a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g b) *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)) (_ : derives context s b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (AndF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *)
elim ih; clear ih.
(* Goal: forall (t : proof_term) (_ : derives (subst_list i g (@cons form a context)) t (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (Imp a b)) *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : Derivable (subst_list i g context) (subst_form i g (Imp a b))) (_ : derives context s a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g b) *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)) (_ : derives context s b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (AndF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *)
intros t1 der1.
(* Goal: Derivable (subst_list i g context) (subst_form i g (Imp a b)) *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : Derivable (subst_list i g context) (subst_form i g (Imp a b))) (_ : derives context s a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g b) *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)) (_ : derives context s b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (AndF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *)
apply Derivable_Intro with (Abs (subst_form i g a) t1).
(* Goal: @eq form (subst_form i b (Atom i)) b *)
simpl in |- *.
(* Goal: derives context' (Abs (Atom i) t) (Imp (Atom i) a) *)
apply ImpIntro; assumption.

(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)) (_ : derives context s b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (AndF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *)
intros context r s a b der_r ih_r der_s ih_s.
(* Goal: Derivable (subst_list i g context) (subst_form i g (AndF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *)
elim ih_r; clear ih_r.
(* Goal: forall (t : proof_term) (_ : derives (subst_list i g context) t (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (AndF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *)
intros r1 der_r1.
(* Goal: Derivable (subst_list i g context) (subst_form i g (AndF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *)
elim ih_s; clear ih_s.
(* Goal: forall (t : proof_term) (_ : derives (subst_list i g context) t (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (AndF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *)
intros s1 der_s1.
(* Goal: Derivable (subst_list i g context) (subst_form i g b) *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)) (_ : derives context s b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (AndF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *)
apply Derivable_Intro with (App (subst_form i g a) r1 s1).
(* Goal: derives context (App a s t) b *)
apply ImpElim; assumption.

(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)) (_ : derives context s b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (AndF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *)
intros context r s a b der_r ih_r der_s ih_s.
(* Goal: Derivable (subst_list i g context) (subst_form i g (AndF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *)
elim ih_r; clear ih_r.
(* Goal: forall (t : proof_term) (_ : derives (subst_list i g context) t (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (AndF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *)
intros r1 der_r1.
(* Goal: Derivable (subst_list i g context) (subst_form i g (AndF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *)
elim ih_s; clear ih_s.
(* Goal: forall (t : proof_term) (_ : derives (subst_list i g context) t (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (AndF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *)
intros s1 der_s1.
(* Goal: Derivable (subst_list i g context) (subst_form i g (AndF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *)
apply Derivable_Intro with (Pair r1 s1).
(* Goal: derives (subst_list i g context) (Pair r1 s1) (subst_form i g (AndF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *)
simpl in |- *; apply AndFIntro; assumption.

(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *)
intros context r a b der_r ih.
(* Goal: forall (t : proof_term) (_ : derives (subst_list i g context) t (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (AndF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *)
elim ih; clear ih; intros r1 der_r1.
(* Goal: Derivable (subst_list i g context) (subst_form i g a) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *)
apply Derivable_Intro with (PrL (subst_form i g b) r1).
(* Goal: derives context (PrL b t) a *)
apply AndFElimL; assumption.

(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *)
intros context r a b der_r ih.
(* Goal: forall (t : proof_term) (_ : derives (subst_list i g context) t (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (AndF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *)
elim ih; clear ih; intros r1 der_r1.
(* Goal: Derivable (subst_list i g context) (subst_form i g b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *)
apply Derivable_Intro with (PrR (subst_form i g a) r1).
(* Goal: derives context (PrR a t) b *)
apply AndFElimR; assumption.

(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *)
intros context r a b der_r ih.
(* Goal: forall (t : proof_term) (_ : derives (subst_list i g context) t (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (AndF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *)
elim ih; clear ih; intros r1 der_r1.
(* Goal: Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *)
apply Derivable_Intro with (OrFL r1 (subst_form i g b)).
(* Goal: derives (subst_list i g context) (OrFL r1 (subst_form i g b)) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *)
simpl in |- *; apply OrFIntroL; assumption.

(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *)
intros context r a b der_r ih.
(* Goal: forall (t : proof_term) (_ : derives (subst_list i g context) t (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (AndF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *)
elim ih; clear ih; intros r1 der_r1.
(* Goal: Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *)
apply Derivable_Intro with (OrFR r1 (subst_form i g a)).
(* Goal: derives (subst_list i g context) (OrFR r1 (subst_form i g a)) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *)
simpl in |- *; apply OrFIntroR; assumption.

(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *)
intros context r s t a b c der_r ih_r der_s ih_s der_t ih_t.
(* Goal: forall (t : proof_term) (_ : derives (subst_list i g context) t (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (AndF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *)
elim ih_r; clear ih_r; intros r1 der_r1.
(* Goal: forall (t : proof_term) (_ : derives (subst_list i g context) t (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (AndF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *)
elim ih_s; clear ih_s; intros s1 der_s1.
(* Goal: Derivable (subst_list i g context) (subst_form i g c) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *)
elim ih_t; clear ih_t; intros t1 der_t1.
apply
 Derivable_Intro with (Cas (subst_form i g a) (subst_form i g b) r1 s1 t1).
(* Goal: derives (@app form l1 l2) (Cas a b r0 s0 t0) c *)
(* Goal: @eq flist (@cons form b context) (@app form (@cons form b l1) (@cons form d l2)) *)
(* Goal: Derivable fnil d *)
(* Goal: @eq flist (@cons form a context) (@app form (@cons form a l1) (@cons form d l2)) *)
(* Goal: Derivable fnil d *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
apply OrFElim; assumption.

(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *)
intros context r a b der_r ih_r.
(* Goal: forall (t : proof_term) (_ : derives (subst_list i g context) t (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (AndF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g a) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (AndF a b))), Derivable (subst_list i g context) (subst_form i g b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : Derivable (subst_list i g context) (subst_form i g a)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g context) (subst_form i g (OrF a b)) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : Derivable (subst_list i g context) (subst_form i g (OrF a b))) (_ : derives (@cons form a context) s c) (_ : Derivable (subst_list i g (@cons form a context)) (subst_form i g c)) (_ : derives (@cons form b context) t c) (_ : Derivable (subst_list i g (@cons form b context)) (subst_form i g c)), Derivable (subst_list i g context) (subst_form i g c) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : Derivable (subst_list i g context) (subst_form i g b)), Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *)
elim ih_r; clear ih_r; intros r1 der_r1.
(* Goal: Derivable (subst_list i g (@cons form a context)) (subst_form i g b) *)
apply Derivable_Intro with (Shift r1).
(* Goal: derives (subst_list i g (@cons form a context)) (Shift r1) (subst_form i g b) *)
simpl in |- *; apply ShiftIntro; assumption.
Qed.


Lemma snd_order_inst :
 forall (context : flist) (i : Int),
 Derivable context (Atom i) ->
 below_list context i -> forall b : form, Derivable context b.
(* Goal: forall (context : flist) (i : Int) (_ : Derivable context (Atom i)) (_ : below_list context i) (b : form), Derivable context b *)
intros context i der below b.
(* Goal: Derivable context b *)
cut (subst_form i b (Atom i) = b).
(* Goal: forall _ : @eq form (subst_form i b (Atom i)) b, Derivable context b *)
(* Goal: @eq form (subst_form i b (Atom i)) b *)
intro eq_b.
(* Goal: Derivable context b *)
(* Goal: @eq form (subst_form i b (Atom i)) b *)
 rewrite <- eq_b.
(* Goal: Derivable context (subst_form i b (Atom i)) *)
(* Goal: @eq form (subst_form i b (Atom i)) b *)
 rewrite <- (subst_list_below i b context).
(* Goal: Derivable (subst_list i b context) (subst_form i b (Atom i)) *)
(* Goal: below_list context i *)
(* Goal: @eq form (subst_form i b (Atom i)) b *)
apply derivable_subst; assumption.
(* Goal: derives context t (Imp (Imp Falsum b) c) *)
(* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *)
assumption.
(* Goal: @eq form (subst_form i b (Atom i)) b *)
simpl in |- *.
(* Goal: @eq form (if equal_dec i i then b else Atom i) b *)
apply equal_dec_refl.
Qed.


Lemma derivable_weak :
 forall (context : flist) (a b : form),
 Derivable context a -> Derivable (b :: context) a.
(* Goal: forall (context : flist) (a b : form) (_ : Derivable context a), Derivable (@cons form b context) a *)
intros context a b der_a.
(* Goal: Derivable context b *)
elim der_a; clear der_a.
(* Goal: forall (t : proof_term) (_ : derives (@cons form a context) t b), Derivable context (Imp a b) *)
intros t der_t.
(* Goal: Derivable (@cons form b context) a *)
apply Derivable_Intro with (Shift t).
(* Goal: derives context t (Imp (Imp Falsum b) c) *)
(* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *)
apply ShiftIntro; assumption.
Qed.


Lemma derivable_weak_list :
 forall (context1 context2 : flist) (a : form),
 Derivable context1 a -> Derivable (context2 ++ context1) a.
(* Goal: forall (context1 context2 : flist) (a : form) (_ : Derivable context1 a), Derivable (@app form context2 context1) a *)
intros context1 context2 a der1.
(* Goal: Derivable (@app form context2 context1) a *)
elim context2; clear context2.
(* Goal: derives context t (Imp (Imp Falsum b) c) *)
(* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *)
assumption.
(* Goal: forall (a0 : form) (l : list form) (_ : Derivable (@app form l context1) a), Derivable (@app form (@cons form a0 l) context1) a *)
intros b context2 ih.
(* Goal: derives context t (Imp (Imp Falsum b) c) *)
(* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *)
simpl in |- *; apply derivable_weak; assumption.
Qed.


Lemma derivable_cut_aux :
 forall (context : flist) (t : proof_term) (b : form),
 derives context t b ->
 forall (a : form) (l1 l2 : flist),
 context = l1 ++ a :: l2 -> Derivable fnil a -> Derivable (l1 ++ l2) b.
(* Goal: forall (context : flist) (t : proof_term) (b : form) (_ : derives context t b) (a : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a l2))) (_ : Derivable fnil a), Derivable (@app form l1 l2) b *)
intros context t b der_t.
(* Goal: forall (a : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a l2))) (_ : Derivable fnil a), Derivable (@app form l1 l2) b *)
elim der_t; clear der_t context t b.

(* Goal: forall (context : flist) (n : nat) (a : form) (_ : my_nth form n context a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (t : proof_term) (a : form) (_ : derives context t Falsum) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) Falsum) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (a : form) (r : proof_term) (b : form) (_ : derives (@cons form a context) r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b) *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b)) (_ : derives context s a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (_ : derives context s b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
intros context n a nth b l1 l2 eq_context.
(* Goal: forall _ : Derivable fnil b, Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (t : proof_term) (a : form) (_ : derives context t Falsum) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) Falsum) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (a : form) (r : proof_term) (b : form) (_ : derives (@cons form a context) r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b) *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b)) (_ : derives context s a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (_ : derives context s b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
 rewrite eq_context in nth.
(* Goal: forall _ : Derivable fnil b, Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (t : proof_term) (a : form) (_ : derives context t Falsum) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) Falsum) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (a : form) (r : proof_term) (b : form) (_ : derives (@cons form a context) r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b) *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b)) (_ : derives context s a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (_ : derives context s b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
elim (inv_nth_app form n l1 (b :: l2) a nth); clear nth.
(* Goal: forall (_ : my_nth form n l1 a) (_ : Derivable fnil b), Derivable (@app form l1 l2) a *)
(* Goal: forall (n' : nat) (_ : my_nth form n' (@cons form b l2) a) (_ : Derivable fnil b), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (t : proof_term) (a : form) (_ : derives context t Falsum) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) Falsum) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (a : form) (r : proof_term) (b : form) (_ : derives (@cons form a context) r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b) *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b)) (_ : derives context s a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (_ : derives context s b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
intros nth0 der_b.
(* Goal: Derivable (@app form l1 l2) a *)
(* Goal: forall (n' : nat) (_ : my_nth form n' (@cons form b l2) a) (_ : Derivable fnil b), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (t : proof_term) (a : form) (_ : derives context t Falsum) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) Falsum) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (a : form) (r : proof_term) (b : form) (_ : derives (@cons form a context) r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b) *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b)) (_ : derives context s a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (_ : derives context s b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
apply Derivable_Intro with (Var n).
(* Goal: derives (@cons form (Atom i) context') (Var O) (Atom i) *)
apply ByAssumption.
(* Goal: derives context t (Imp (Imp Falsum b) c) *)
(* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *)
apply nth_app0; assumption.
(* Goal: forall (n' : nat) (_ : my_nth form n' (@cons form b l2) a) (_ : Derivable fnil b), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (t : proof_term) (a : form) (_ : derives context t Falsum) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) Falsum) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (a : form) (r : proof_term) (b : form) (_ : derives (@cons form a context) r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b) *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b)) (_ : derives context s a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (_ : derives context s b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
clear n; intros n; case n; clear n.
(* Goal: forall (_ : my_nth form O (@cons form b l2) a) (_ : Derivable fnil b), Derivable (@app form l1 l2) a *)
(* Goal: forall (n : nat) (_ : my_nth form (S n) (@cons form b l2) a) (_ : Derivable fnil b), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (t : proof_term) (a : form) (_ : derives context t Falsum) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) Falsum) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (a : form) (r : proof_term) (b : form) (_ : derives (@cons form a context) r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b) *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b)) (_ : derives context s a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (_ : derives context s b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
intros nth_eq.
(* Goal: forall _ : Derivable fnil b, Derivable (@app form l1 l2) a *)
(* Goal: forall (n : nat) (_ : my_nth form (S n) (@cons form b l2) a) (_ : Derivable fnil b), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (t : proof_term) (a : form) (_ : derives context t Falsum) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) Falsum) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (a : form) (r : proof_term) (b : form) (_ : derives (@cons form a context) r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b) *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b)) (_ : derives context s a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (_ : derives context s b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
 rewrite (inv_nthO form b l2 a nth_eq).
(* Goal: forall _ : Derivable fnil a, Derivable (@app form l1 l2) a *)
(* Goal: forall (n : nat) (_ : my_nth form (S n) (@cons form b l2) a) (_ : Derivable fnil b), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (t : proof_term) (a : form) (_ : derives context t Falsum) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) Falsum) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (a : form) (r : proof_term) (b : form) (_ : derives (@cons form a context) r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b) *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b)) (_ : derives context s a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (_ : derives context s b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
intros der_a.
(* Goal: Derivable (@app form l1 l2) a *)
(* Goal: forall (n : nat) (_ : my_nth form (S n) (@cons form b l2) a) (_ : Derivable fnil b), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (t : proof_term) (a : form) (_ : derives context t Falsum) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) Falsum) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (a : form) (r : proof_term) (b : form) (_ : derives (@cons form a context) r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b) *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b)) (_ : derives context s a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (_ : derives context s b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
 rewrite (app_nil_end (l1 ++ l2)).
(* Goal: Derivable (@app form (@app form l1 l2) (@nil form)) a *)
(* Goal: forall (n : nat) (_ : my_nth form (S n) (@cons form b l2) a) (_ : Derivable fnil b), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (t : proof_term) (a : form) (_ : derives context t Falsum) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) Falsum) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (a : form) (r : proof_term) (b : form) (_ : derives (@cons form a context) r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b) *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b)) (_ : derives context s a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (_ : derives context s b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
apply derivable_weak_list.
(* Goal: derives context t (Imp (Imp Falsum b) c) *)
(* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *)
assumption.
(* Goal: forall (n : nat) (_ : my_nth form (S n) (@cons form b l2) a) (_ : Derivable fnil b), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (t : proof_term) (a : form) (_ : derives context t Falsum) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) Falsum) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (a : form) (r : proof_term) (b : form) (_ : derives (@cons form a context) r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b) *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b)) (_ : derives context s a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (_ : derives context s b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
intros n nth1 der_b.
(* Goal: Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (t : proof_term) (a : form) (_ : derives context t Falsum) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) Falsum) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (a : form) (r : proof_term) (b : form) (_ : derives (@cons form a context) r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b) *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b)) (_ : derives context s a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (_ : derives context s b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
apply Derivable_Intro with (Var (length l1 + n)).
(* Goal: derives (@cons form (Atom i) context') (Var O) (Atom i) *)
apply ByAssumption.
(* Goal: my_nth form (Nat.add (@length form l1) n) (@app form l1 l2) a *)
(* Goal: forall (context : flist) (t : proof_term) (a : form) (_ : derives context t Falsum) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) Falsum) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (a : form) (r : proof_term) (b : form) (_ : derives (@cons form a context) r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b) *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b)) (_ : derives context s a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (_ : derives context s b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
apply nth_app1.
(* Goal: derives context t (Imp (Imp Falsum b) c) *)
(* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *)
inversion_clear nth1; assumption.

(* Goal: forall (context : flist) (t : proof_term) (a : form) (_ : derives context t Falsum) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) Falsum) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (a : form) (r : proof_term) (b : form) (_ : derives (@cons form a context) r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b) *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b)) (_ : derives context s a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (_ : derives context s b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
intros context t a der_t ih b l1 l2 eq_context der_b.
(* Goal: derives context t (Imp (Imp Falsum b) c) *)
(* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *)
elim (ih b l1 l2); try assumption.
(* Goal: forall (t : proof_term) (_ : derives (@app form (@cons form b l1) l2) t c), Derivable (@app form l1 l2) c *)
(* Goal: @eq flist (@cons form b context) (@app form (@cons form b l1) (@cons form d l2)) *)
(* Goal: Derivable fnil d *)
(* Goal: @eq flist (@cons form a context) (@app form (@cons form a l1) (@cons form d l2)) *)
(* Goal: Derivable fnil d *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
intros t0 der_t0.
(* Goal: Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (a : form) (r : proof_term) (b : form) (_ : derives (@cons form a context) r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b) *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b)) (_ : derives context s a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (_ : derives context s b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
apply Derivable_Intro with (Efq t0 a).
(* Goal: derives (@app form l1 l2) (Efq t0 a) a *)
(* Goal: forall (context : flist) (a : form) (r : proof_term) (b : form) (_ : derives (@cons form a context) r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b) *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b)) (_ : derives context s a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (_ : derives context s b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
apply ByAbsurdity; assumption.

(* Goal: forall (context : flist) (a : form) (r : proof_term) (b : form) (_ : derives (@cons form a context) r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b) *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b)) (_ : derives context s a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (_ : derives context s b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
intros context a t b der_t ih c l1 l2 eq_context der_c.
(* Goal: Derivable (@app form l1 l2) (Imp a b) *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b)) (_ : derives context s a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (_ : derives context s b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
elim (ih c (a :: l1) l2); clear ih.
(* Goal: forall (t : proof_term) (_ : derives (@app form (@cons form b l1) l2) t c), Derivable (@app form l1 l2) c *)
(* Goal: @eq flist (@cons form b context) (@app form (@cons form b l1) (@cons form d l2)) *)
(* Goal: Derivable fnil d *)
(* Goal: @eq flist (@cons form a context) (@app form (@cons form a l1) (@cons form d l2)) *)
(* Goal: Derivable fnil d *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
intros t0 der_t0.
(* Goal: Derivable (@app form l1 l2) (Imp a b) *)
(* Goal: @eq flist (@cons form a context) (@app form (@cons form a l1) (@cons form c l2)) *)
(* Goal: Derivable fnil c *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b)) (_ : derives context s a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (_ : derives context s b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
apply Derivable_Intro with (Abs a t0).
(* Goal: derives context' (Abs (Atom i) t) (Imp (Atom i) a) *)
apply ImpIntro; assumption.
(* Goal: @eq flist (@cons form a context) (@app form (@cons form a l1) (@cons form c l2)) *)
(* Goal: Derivable fnil c *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r (Imp a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (Imp a b)) (_ : derives context s a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (_ : derives context s b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
 rewrite eq_context.
(* Goal: @eq flist (@cons form a context) (@app form fnil (@cons form a context)) *)
(* Goal: Derivable fnil a *)
trivial.
(* Goal: derives context t (Imp (Imp Falsum b) c) *)
(* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *)
assumption.

(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (_ : derives context s b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
intros context r s a b der_r ih_r der_s ih_s c l1 l2 eq_context der_c.
(* Goal: derives context t (Imp (Imp Falsum b) c) *)
(* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *)
elim (ih_r c l1 l2); clear ih_r; try assumption.
(* Goal: forall (t : proof_term) (_ : derives (@app form l1 l2) t b), Derivable (@cons form d (@app form l1 l2)) b *)
(* Goal: @eq flist context (@app form l1 (@cons form c l2)) *)
intros r0 der_r0.
(* Goal: derives context t (Imp (Imp Falsum b) c) *)
(* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *)
elim (ih_s c l1 l2); clear ih_s; try assumption.
(* Goal: forall (t : proof_term) (_ : derives (@app form (@cons form a l1) l2) t c), Derivable (@app form l1 l2) c *)
(* Goal: @eq flist (@cons form a context) (@app form (@cons form a l1) (@cons form d l2)) *)
(* Goal: Derivable fnil d *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
intros s0 der_s0.
(* Goal: Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (_ : derives context s b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
apply Derivable_Intro with (App a r0 s0).
(* Goal: derives context (App a s t) b *)
apply ImpElim; assumption.

(* Goal: forall (context : flist) (r s : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (_ : derives context s b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
intros context r s a b der_r ih_r der_s ih_s c l1 l2 eq_context der_c.
(* Goal: derives context t (Imp (Imp Falsum b) c) *)
(* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *)
elim (ih_r c l1 l2); clear ih_r; try assumption.
(* Goal: forall (t : proof_term) (_ : derives (@app form l1 l2) t b), Derivable (@cons form d (@app form l1 l2)) b *)
(* Goal: @eq flist context (@app form l1 (@cons form c l2)) *)
intros r0 der_r0.
(* Goal: derives context t (Imp (Imp Falsum b) c) *)
(* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *)
elim (ih_s c l1 l2); clear ih_s; try assumption.
(* Goal: forall (t : proof_term) (_ : derives (@app form (@cons form a l1) l2) t c), Derivable (@app form l1 l2) c *)
(* Goal: @eq flist (@cons form a context) (@app form (@cons form a l1) (@cons form d l2)) *)
(* Goal: Derivable fnil d *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
intros s0 der_s0.
(* Goal: Derivable (@app form l1 l2) (AndF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
apply Derivable_Intro with (Pair r0 s0).
(* Goal: derives context t (Imp (Imp Falsum b) c) *)
(* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *)
apply AndFIntro; assumption.

(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
intros context r a b der_r ih_r c l1 l2 eq_context der_c.
(* Goal: derives context t (Imp (Imp Falsum b) c) *)
(* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *)
elim (ih_r c l1 l2); clear ih_r; try assumption.
(* Goal: forall (t : proof_term) (_ : derives (@app form l1 l2) t b), Derivable (@cons form d (@app form l1 l2)) b *)
(* Goal: @eq flist context (@app form l1 (@cons form c l2)) *)
intros r0 der_r0.
(* Goal: Derivable (@app form l1 l2) a *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r (AndF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (AndF a b)) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
apply Derivable_Intro with (PrL b r0).
(* Goal: derives context (PrL b t) a *)
apply AndFElimL; assumption.

(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
intros context r a b der_r ih_r c l1 l2 eq_context der_c.
(* Goal: derives context t (Imp (Imp Falsum b) c) *)
(* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *)
elim (ih_r c l1 l2); clear ih_r; try assumption.
(* Goal: forall (t : proof_term) (_ : derives (@app form l1 l2) t b), Derivable (@cons form d (@app form l1 l2)) b *)
(* Goal: @eq flist context (@app form l1 (@cons form c l2)) *)
intros r0 der_r0.
(* Goal: Derivable (@app form l1 l2) b *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r a) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) a) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
apply Derivable_Intro with (PrR a r0).
(* Goal: derives context (PrR a t) b *)
apply AndFElimR; assumption.

(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
intros context r a b der_r ih_r c l1 l2 eq_context der_c.
(* Goal: derives context t (Imp (Imp Falsum b) c) *)
(* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *)
elim (ih_r c l1 l2); clear ih_r; try assumption.
(* Goal: forall (t : proof_term) (_ : derives (@app form l1 l2) t b), Derivable (@cons form d (@app form l1 l2)) b *)
(* Goal: @eq flist context (@app form l1 (@cons form c l2)) *)
intros r0 der_r0.
(* Goal: Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
apply Derivable_Intro with (OrFL r0 b).
(* Goal: derives context t (Imp (Imp Falsum b) c) *)
(* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *)
apply OrFIntroL; assumption.

(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
intros context r a b der_r ih_r c l1 l2 eq_context der_c.
(* Goal: derives context t (Imp (Imp Falsum b) c) *)
(* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *)
elim (ih_r c l1 l2); clear ih_r; try assumption.
(* Goal: forall (t : proof_term) (_ : derives (@app form l1 l2) t b), Derivable (@cons form d (@app form l1 l2)) b *)
(* Goal: @eq flist context (@app form l1 (@cons form c l2)) *)
intros r0 der_r0.
(* Goal: Derivable (@app form l1 l2) (OrF a b) *)
(* Goal: forall (context : flist) (r s t : proof_term) (a b c : form) (_ : derives context r (OrF a b)) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) (OrF a b)) (_ : derives (@cons form a context) s c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (_ : derives (@cons form b context) t c) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form b context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c) (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) c *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
apply Derivable_Intro with (OrFR r0 a).
(* Goal: derives context t (Imp (Imp Falsum b) c) *)
(* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *)
apply OrFIntroR; assumption.

intros context r s t a b c der_r ih_r der_s ih_s der_t ih_t d l1 l2
 eq_context der_d; clear der_r der_s der_t.
(* Goal: Derivable (@app form l1 l2) c *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
elim (ih_r d l1 l2); try assumption; clear ih_r.
(* Goal: forall (t : proof_term) (_ : derives (@app form l1 l2) t b), Derivable (@cons form d (@app form l1 l2)) b *)
(* Goal: @eq flist context (@app form l1 (@cons form c l2)) *)
intros r0 der_r0.
(* Goal: Derivable (@app form l1 l2) c *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
elim (ih_s d (a :: l1) l2); clear ih_s.
(* Goal: forall (t : proof_term) (_ : derives (@app form (@cons form a l1) l2) t c), Derivable (@app form l1 l2) c *)
(* Goal: @eq flist (@cons form a context) (@app form (@cons form a l1) (@cons form d l2)) *)
(* Goal: Derivable fnil d *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
intros s0 der_s0.
(* Goal: Derivable (@app form l1 l2) c *)
(* Goal: @eq flist (@cons form a context) (@app form (@cons form a l1) (@cons form d l2)) *)
(* Goal: Derivable fnil d *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
elim (ih_t d (b :: l1) l2); clear ih_t.
(* Goal: forall (t : proof_term) (_ : derives (@app form (@cons form b l1) l2) t c), Derivable (@app form l1 l2) c *)
(* Goal: @eq flist (@cons form b context) (@app form (@cons form b l1) (@cons form d l2)) *)
(* Goal: Derivable fnil d *)
(* Goal: @eq flist (@cons form a context) (@app form (@cons form a l1) (@cons form d l2)) *)
(* Goal: Derivable fnil d *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
intros t0 der_t0.
(* Goal: Derivable (@app form l1 l2) c *)
(* Goal: @eq flist (@cons form b context) (@app form (@cons form b l1) (@cons form d l2)) *)
(* Goal: Derivable fnil d *)
(* Goal: @eq flist (@cons form a context) (@app form (@cons form a l1) (@cons form d l2)) *)
(* Goal: Derivable fnil d *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
apply Derivable_Intro with (Cas a b r0 s0 t0).
(* Goal: derives (@app form l1 l2) (Cas a b r0 s0 t0) c *)
(* Goal: @eq flist (@cons form b context) (@app form (@cons form b l1) (@cons form d l2)) *)
(* Goal: Derivable fnil d *)
(* Goal: @eq flist (@cons form a context) (@app form (@cons form a l1) (@cons form d l2)) *)
(* Goal: Derivable fnil d *)
(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
apply OrFElim; assumption.
(* Goal: @eq flist (@cons form a context) (@app form fnil (@cons form a context)) *)
(* Goal: Derivable fnil a *)
 rewrite eq_context; trivial.
(* Goal: derives context t (Imp (Imp Falsum b) c) *)
(* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *)
assumption.
(* Goal: @eq flist (@cons form a context) (@app form fnil (@cons form a context)) *)
(* Goal: Derivable fnil a *)
 rewrite eq_context; trivial.
(* Goal: derives context t (Imp (Imp Falsum b) c) *)
(* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *)
assumption.

(* Goal: forall (context : flist) (r : proof_term) (a b : form) (_ : derives context r b) (_ : forall (a0 : form) (l1 l2 : flist) (_ : @eq flist context (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b) (a0 : form) (l1 l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form a0 l2))) (_ : Derivable fnil a0), Derivable (@app form l1 l2) b *)
intros context r a b der_r ih_r c l1.
(* Goal: forall (l2 : flist) (_ : @eq flist (@cons form a context) (@app form l1 (@cons form c l2))) (_ : Derivable fnil c), Derivable (@app form l1 l2) b *)
case l1; clear l1.
(* Goal: forall (l2 : flist) (_ : @eq flist (@cons form a context) (@app form (@nil form) (@cons form c l2))) (_ : Derivable fnil c), Derivable (@app form (@nil form) l2) b *)
(* Goal: forall (f : form) (l : list form) (l2 : flist) (_ : @eq flist (@cons form a context) (@app form (@cons form f l) (@cons form c l2))) (_ : Derivable fnil c), Derivable (@app form (@cons form f l) l2) b *)
simpl in |- *; intros l2 eq_context der_c.
(* Goal: Derivable l2 b *)
(* Goal: forall (f : form) (l : list form) (l2 : flist) (_ : @eq flist (@cons form a context) (@app form (@cons form f l) (@cons form c l2))) (_ : Derivable fnil c), Derivable (@app form (@cons form f l) l2) b *)
apply Derivable_Intro with r.
(* Goal: derives l2 r b *)
(* Goal: forall (f : form) (l : list form) (l2 : flist) (_ : @eq flist (@cons form a context) (@app form (@cons form f l) (@cons form c l2))) (_ : Derivable fnil c), Derivable (@app form (@cons form f l) l2) b *)
 injection eq_context; intros H1 H2.
(* Goal: derives context t (Imp (Imp Falsum b) c) *)
(* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *)
 rewrite <- H1; assumption.
(* Goal: forall (f : form) (l : list form) (l2 : flist) (_ : @eq flist (@cons form a context) (@app form (@cons form f l) (@cons form c l2))) (_ : Derivable fnil c), Derivable (@app form (@cons form f l) l2) b *)
simpl in |- *; intros d l1 l2 eq_context der_c.
(* Goal: derives context t (Imp (Imp Falsum b) c) *)
(* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *)
elim (ih_r c l1 l2); clear ih_r; try assumption.
(* Goal: forall (t : proof_term) (_ : derives (@app form l1 l2) t b), Derivable (@cons form d (@app form l1 l2)) b *)
(* Goal: @eq flist context (@app form l1 (@cons form c l2)) *)
intros r0 der_r0.
(* Goal: Derivable (@cons form d (@app form l1 l2)) b *)
(* Goal: @eq flist context (@app form l1 (@cons form c l2)) *)
apply derivable_weak.
(* Goal: derives context t (Imp (Imp Falsum b) c) *)
(* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *)
apply Derivable_Intro with r0; assumption.

(* Goal: @eq flist context (@app form l1 (@cons form c l2)) *)
 injection eq_context.
(* Goal: forall (_ : @eq (list form) context (@app form l1 (@cons form c l2))) (_ : @eq form a d), @eq flist context (@app form l1 (@cons form c l2)) *)
intros; assumption.
Qed.




Lemma derivable_cut :
 forall (context : flist) (a b : form),
 Derivable fnil a -> Derivable (a :: context) b -> Derivable context b.
(* Goal: forall (context : flist) (a b : form) (_ : Derivable fnil a) (_ : Derivable (@cons form a context) b), Derivable context b *)
intros context a b der_a der_b.
(* Goal: Derivable context b *)
elim der_b; clear der_b.
(* Goal: forall (t : proof_term) (_ : derives (@cons form a context) t b), Derivable context b *)
intros t der_b.
(* Goal: Derivable context b *)
apply (derivable_cut_aux (a :: context) t b der_b a fnil context).
(* Goal: @eq flist (@cons form a context) (@app form fnil (@cons form a context)) *)
(* Goal: Derivable fnil a *)
trivial.
(* Goal: derives context t (Imp (Imp Falsum b) c) *)
(* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *)
assumption.
Qed.


Lemma derivable_cut_merge :
 forall (context : flist) (a b : form),
 Derivable context a -> Derivable (a :: context) b -> Derivable context b.
(* Goal: forall (context : flist) (a b : form) (_ : Derivable context a) (_ : Derivable (@cons form a context) b), Derivable context b *)
intros context; elim context; clear context.

(* Goal: derives context t (Imp (Imp Falsum b) c) *)
(* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *)
intros; apply derivable_cut with a; assumption.

(* Goal: forall (a : form) (l : list form) (_ : forall (a0 b : form) (_ : Derivable l a0) (_ : Derivable (@cons form a0 l) b), Derivable l b) (a0 b : form) (_ : Derivable (@cons form a l) a0) (_ : Derivable (@cons form a0 (@cons form a l)) b), Derivable (@cons form a l) b *)
intros c context ih a b der_a der_b.
(* Goal: Derivable (@cons form c context) b *)
elim (ih (Imp c a) (Imp c b)); clear ih.
(* Goal: forall (t : proof_term) (_ : derives (@cons form a context) t b), Derivable context (Imp a b) *)
intros t der_t.
(* Goal: Derivable (@cons form c context) b *)
(* Goal: Derivable context (Imp c a) *)
(* Goal: Derivable (@cons form (Imp c a) context) (Imp c b) *)
apply Derivable_Intro with (App c (Shift t) (Var 0)).
(* Goal: derives (@cons form (Atom i) context') (App (Atom i) (Shift s) (Var O)) b *)
apply ImpElim.
(* Goal: derives context t (Imp (Imp Falsum b) c) *)
(* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *)
apply ShiftIntro; assumption.
(* Goal: derives (@cons form (Atom i) context') (Var O) (Atom i) *)
apply ByAssumption.
(* Goal: my_nth form O (@cons form (Atom i) context') (Atom i) *)
apply My_NthO.
(* Goal: forall (t : proof_term) (_ : derives (@cons form a context) t b), Derivable context (Imp a b) *)
elim der_a; clear der_a; intros t der_t.
(* Goal: Derivable context (Imp c a) *)
(* Goal: Derivable (@cons form (Imp c a) context) (Imp c b) *)
apply Derivable_Intro with (Abs c t).
(* Goal: derives context' (Abs (Atom i) t) (Imp (Atom i) a) *)
apply ImpIntro; assumption.
(* Goal: forall (t : proof_term) (_ : derives (@cons form a context) t b), Derivable context (Imp a b) *)
elim der_b; clear der_b; intros t der_t.
apply
 Derivable_Intro
  with
    (Abs c
       (App a (App c (Shift (Shift (Abs c (Abs a t)))) (Var 0))
          (App c (Var 1) (Var 0)))).
(* Goal: derives context (Abs a (Shift t)) (Imp a b) *)
apply ImpIntro.
(* Goal: derives (@cons form (Atom i) context') (App (Atom i) (Shift s) (Var O)) b *)
apply ImpElim.
(* Goal: derives (@cons form (Atom i) context') (App (Atom i) (Shift s) (Var O)) b *)
apply ImpElim.
(* Goal: derives (@cons form a0 context) (Shift t) (Imp (AndF a0 a1) b) *)
(* Goal: derives (@cons form a1 (@cons form a0 context)) (Pair (Var (S O)) (Var O)) (AndF a0 a1) *)
apply ShiftIntro.
(* Goal: derives (@cons form a0 context) (Shift t) (Imp (AndF a0 a1) b) *)
(* Goal: derives (@cons form a1 (@cons form a0 context)) (Pair (Var (S O)) (Var O)) (AndF a0 a1) *)
apply ShiftIntro.
(* Goal: derives context (Abs a (Shift t)) (Imp a b) *)
apply ImpIntro.
(* Goal: derives context (Abs a (Shift t)) (Imp a b) *)
apply ImpIntro.
(* Goal: derives context t (Imp (Imp Falsum b) c) *)
(* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *)
assumption.
(* Goal: derives (@cons form (Atom i) context') (Var O) (Atom i) *)
apply ByAssumption.
(* Goal: my_nth form O (@cons form (Atom i) context') (Atom i) *)
apply My_NthO.
(* Goal: derives (@cons form (Atom i) context') (App (Atom i) (Shift s) (Var O)) b *)
apply ImpElim.
(* Goal: derives (@cons form (Atom i) context') (Var O) (Atom i) *)
apply ByAssumption.
(* Goal: my_nth form (S O) (@cons form c (@cons form (Imp c a) context)) (Imp c a) *)
(* Goal: derives (@cons form c (@cons form (Imp c a) context)) (Var O) c *)
apply My_NthS.
(* Goal: my_nth form O (@cons form (Atom i) context') (Atom i) *)
apply My_NthO.
(* Goal: derives (@cons form (Atom i) context') (Var O) (Atom i) *)
apply ByAssumption.
(* Goal: my_nth form O (@cons form (Atom i) context') (Atom i) *)
apply My_NthO.
Qed.


(************************************************************************)


Lemma derivable_a_imp_a : forall a : form, Derivable fnil (Imp a a).
(* Goal: forall a : form, Derivable fnil (Imp a a) *)
intros a.
(* Goal: Derivable fnil (Imp a a) *)
apply Derivable_Intro with (Abs a (Var 0)).
(* Goal: derives context (Abs a (Shift t)) (Imp a b) *)
apply ImpIntro.
(* Goal: derives (@cons form (Atom i) context') (Var O) (Atom i) *)
apply ByAssumption.
(* Goal: my_nth form O (@cons form (Atom i) context') (Atom i) *)
apply My_NthO.
Qed.

     

Lemma derivable_a_and_b__derivable_a :
 forall (a b : form) (context : flist),
 Derivable context (AndF a b) -> Derivable context a.
(* Goal: forall (a b : form) (context : flist) (_ : Derivable (@cons form a context) b), Derivable context (Imp a b) *)
intros a b context der.
(* Goal: Derivable context (Imp a b) *)
elim der; clear der.
(* Goal: forall (t : proof_term) (_ : derives (@cons form a context) t b), Derivable context (Imp a b) *)
intros t der_t.
(* Goal: Derivable context a *)
apply Derivable_Intro with (PrL b t).
(* Goal: derives context (PrL b t) a *)
apply AndFElimL; assumption.
Qed.


Lemma derivable_a_and_b__derivable_b :
 forall (a b : form) (context : flist),
 Derivable context (AndF a b) -> Derivable context b.
(* Goal: forall (a b : form) (context : flist) (_ : Derivable (@cons form a context) b), Derivable context (Imp a b) *)
intros a b context der.
(* Goal: Derivable context (Imp a b) *)
elim der; clear der.
(* Goal: forall (t : proof_term) (_ : derives (@cons form a context) t b), Derivable context (Imp a b) *)
intros t der_t.
(* Goal: Derivable context b *)
apply Derivable_Intro with (PrR a t).
(* Goal: derives context (PrR a t) b *)
apply AndFElimR; assumption.
Qed.




Lemma derivable_falsum_or_a__derivable_a :
 forall (a : form) (context : flist),
 Derivable context (OrF Falsum a) -> Derivable context a.
(* Goal: forall (a : form) (context : flist) (_ : Derivable context (OrF a Falsum)), Derivable context a *)
intros a context der.
(* Goal: Derivable context (Imp a b) *)
elim der; clear der.
(* Goal: forall (t : proof_term) (_ : derives (@cons form a context) t b), Derivable context (Imp a b) *)
intros t der_t.
(* Goal: Derivable context a *)
apply Derivable_Intro with (Cas Falsum a t (Efq (Var 0) a) (Var 0)).
(* Goal: derives (@cons form a context) (Cas b Falsum (App a (Shift t) (Var O)) (Var O) (Efq (Var O) b)) b *)
apply OrFElim.
(* Goal: derives context t (Imp (Imp Falsum b) c) *)
(* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *)
assumption.
(* Goal: derives (@cons form Falsum context) (Efq (Var O) b) b *)
apply ByAbsurdity.
(* Goal: derives (@cons form (Atom i) context') (Var O) (Atom i) *)
apply ByAssumption.
(* Goal: my_nth form O (@cons form (Atom i) context') (Atom i) *)
apply My_NthO.
(* Goal: derives (@cons form (Atom i) context') (Var O) (Atom i) *)
apply ByAssumption.
(* Goal: my_nth form O (@cons form (Atom i) context') (Atom i) *)
apply My_NthO.
Qed.



Lemma derivable_a_or_falsum__derivable_a :
 forall (a : form) (context : flist),
 Derivable context (OrF a Falsum) -> Derivable context a.
(* Goal: forall (a : form) (context : flist) (_ : Derivable context (OrF a Falsum)), Derivable context a *)
intros a context der.
(* Goal: Derivable context (Imp a b) *)
elim der; clear der.
(* Goal: forall (t : proof_term) (_ : derives (@cons form a context) t b), Derivable context (Imp a b) *)
intros t der_t.
(* Goal: Derivable context a *)
apply Derivable_Intro with (Cas a Falsum t (Var 0) (Efq (Var 0) a)).
(* Goal: derives (@cons form a context) (Cas b Falsum (App a (Shift t) (Var O)) (Var O) (Efq (Var O) b)) b *)
apply OrFElim.
(* Goal: derives context t (Imp (Imp Falsum b) c) *)
(* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *)
assumption.
(* Goal: derives (@cons form (Atom i) context') (Var O) (Atom i) *)
apply ByAssumption.
(* Goal: my_nth form O (@cons form (Atom i) context') (Atom i) *)
apply My_NthO.
(* Goal: derives (@cons form Falsum context) (Efq (Var O) b) b *)
apply ByAbsurdity.
(* Goal: derives (@cons form (Atom i) context') (Var O) (Atom i) *)
apply ByAssumption.
(* Goal: my_nth form O (@cons form (Atom i) context') (Atom i) *)
apply My_NthO.
Qed.



Lemma derivable_a_imp_falsum_or_b__derivable_a_imp_b :
 forall (context : flist) (a b : form),
 Derivable context (Imp a (OrF Falsum b)) -> Derivable context (Imp a b).
(* Goal: forall (context : flist) (a b : form) (_ : Derivable context (Imp a (OrF b Falsum))), Derivable context (Imp a b) *)
intros context a b der.
(* Goal: Derivable context (Imp a b) *)
elim der; clear der.
(* Goal: forall (t : proof_term) (_ : derives (@cons form a context) t b), Derivable context (Imp a b) *)
intros t der_t.
apply
 Derivable_Intro
  with
    (Abs a (Cas Falsum b (App a (Shift t) (Var 0)) (Efq (Var 0) b) (Var 0))).
(* Goal: derives context (Abs a (Shift t)) (Imp a b) *)
apply ImpIntro.
(* Goal: derives (@cons form a context) (Cas b Falsum (App a (Shift t) (Var O)) (Var O) (Efq (Var O) b)) b *)
apply OrFElim.
(* Goal: derives (@cons form (Atom i) context') (App (Atom i) (Shift s) (Var O)) b *)
apply ImpElim.
(* Goal: derives context t (Imp (Imp Falsum b) c) *)
(* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *)
apply ShiftIntro; assumption.
(* Goal: my_nth form O (@cons form (Atom i) context') (Atom i) *)
apply ByAssumption; apply My_NthO.
(* Goal: derives (@cons form Falsum context) (Efq (Var O) b) b *)
apply ByAbsurdity.
(* Goal: my_nth form O (@cons form (Atom i) context') (Atom i) *)
apply ByAssumption; apply My_NthO.
(* Goal: my_nth form O (@cons form (Atom i) context') (Atom i) *)
apply ByAssumption; apply My_NthO.
Qed.




Lemma derivable_a_imp_b_or_falsum__derivable_a_imp_b :
 forall (context : flist) (a b : form),
 Derivable context (Imp a (OrF b Falsum)) -> Derivable context (Imp a b).
(* Goal: forall (context : flist) (a b : form) (_ : Derivable context (Imp a (OrF b Falsum))), Derivable context (Imp a b) *)
intros context a b der.
(* Goal: Derivable context (Imp a b) *)
elim der; clear der.
(* Goal: forall (t : proof_term) (_ : derives (@cons form a context) t b), Derivable context (Imp a b) *)
intros t der_t.
apply
 Derivable_Intro
  with
    (Abs a (Cas b Falsum (App a (Shift t) (Var 0)) (Var 0) (Efq (Var 0) b))).
(* Goal: derives context (Abs a (Shift t)) (Imp a b) *)
apply ImpIntro.
(* Goal: derives (@cons form a context) (Cas b Falsum (App a (Shift t) (Var O)) (Var O) (Efq (Var O) b)) b *)
apply OrFElim.
(* Goal: derives (@cons form (Atom i) context') (App (Atom i) (Shift s) (Var O)) b *)
apply ImpElim.
(* Goal: derives context t (Imp (Imp Falsum b) c) *)
(* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *)
apply ShiftIntro; assumption.
(* Goal: my_nth form O (@cons form (Atom i) context') (Atom i) *)
apply ByAssumption; apply My_NthO.
(* Goal: my_nth form O (@cons form (Atom i) context') (Atom i) *)
apply ByAssumption; apply My_NthO.
(* Goal: derives (@cons form Falsum context) (Efq (Var O) b) b *)
apply ByAbsurdity.
(* Goal: my_nth form O (@cons form (Atom i) context') (Atom i) *)
apply ByAssumption; apply My_NthO.
Qed.




Lemma derivable_a0_and_a1_imp_b__derivable_a0_imp_a1_imp_b :
 forall (a0 a1 b : form) (context : flist),
 Derivable context (Imp (AndF a0 a1) b) ->
 Derivable context (Imp a0 (Imp a1 b)).
(* Goal: forall (a0 a1 b : form) (context : flist) (_ : Derivable context (Imp (AndF a0 a1) b)), Derivable context (Imp a0 (Imp a1 b)) *)
intros a0 a1 b context der.
(* Goal: Derivable context (Imp a b) *)
elim der; clear der.
(* Goal: forall (t : proof_term) (_ : derives context t (Imp (AndF a0 a1) b)), Derivable context (Imp a0 (Imp a1 b)) *)
intros t der.
apply
 Derivable_Intro
  with
    (Abs a0
       (Abs a1 (App (AndF a0 a1) (Shift (Shift t)) (Pair (Var 1) (Var 0))))).
(* Goal: derives context (Abs a (Shift t)) (Imp a b) *)
apply ImpIntro.
(* Goal: derives context (Abs a (Shift t)) (Imp a b) *)
apply ImpIntro.
(* Goal: derives (@cons form (Atom i) context') (App (Atom i) (Shift s) (Var O)) b *)
apply ImpElim.
(* Goal: derives (@cons form a0 context) (Shift t) (Imp (AndF a0 a1) b) *)
(* Goal: derives (@cons form a1 (@cons form a0 context)) (Pair (Var (S O)) (Var O)) (AndF a0 a1) *)
apply ShiftIntro.
(* Goal: derives (@cons form a0 context) (Shift t) (Imp (AndF a0 a1) b) *)
(* Goal: derives (@cons form a1 (@cons form a0 context)) (Pair (Var (S O)) (Var O)) (AndF a0 a1) *)
apply ShiftIntro.
(* Goal: derives context t (Imp (Imp Falsum b) c) *)
(* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *)
assumption.
(* Goal: derives (@cons form a1 (@cons form a0 context)) (Pair (Var (S O)) (Var O)) (AndF a0 a1) *)
apply AndFIntro.
(* Goal: derives (@cons form (Atom i) context') (Var O) (Atom i) *)
apply ByAssumption.
(* Goal: my_nth form O (@cons form (Atom i) context') (Atom i) *)
apply My_NthS; apply My_NthO.
(* Goal: derives (@cons form (Atom i) context') (Var O) (Atom i) *)
apply ByAssumption.
(* Goal: my_nth form O (@cons form (Atom i) context') (Atom i) *)
apply My_NthO.
Qed.



Lemma derivable_a0_or_a1_imp_b__derivable_a0_imp_b :
 forall (context : flist) (a0 a1 b : form),
 Derivable context (Imp (OrF a0 a1) b) -> Derivable context (Imp a0 b).
(* Goal: forall (context : flist) (a0 a1 b : form) (_ : Derivable context (Imp (OrF a0 a1) b)), Derivable context (Imp a1 b) *)
intros context a0 a1 b der.
(* Goal: Derivable context (Imp a b) *)
elim der; clear der.
(* Goal: forall (t : proof_term) (_ : derives (@cons form a context) t b), Derivable context (Imp a b) *)
intros t der_t.
apply
 Derivable_Intro with (Abs a0 (App (OrF a0 a1) (Shift t) (OrFL (Var 0) a1))).
(* Goal: derives context (Abs a (Shift t)) (Imp a b) *)
apply ImpIntro.
(* Goal: derives (@cons form (Atom i) context') (App (Atom i) (Shift s) (Var O)) b *)
apply ImpElim.
(* Goal: derives context t (Imp (Imp Falsum b) c) *)
(* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *)
apply ShiftIntro; assumption.
(* Goal: derives (@cons form a0 context) (OrFL (Var O) a1) (OrF a0 a1) *)
apply OrFIntroL.
(* Goal: my_nth form O (@cons form (Atom i) context') (Atom i) *)
apply ByAssumption; apply My_NthO.
Qed.


Lemma derivable_a0_or_a1_imp_b__derivable_a1_imp_b :
 forall (context : flist) (a0 a1 b : form),
 Derivable context (Imp (OrF a0 a1) b) -> Derivable context (Imp a1 b).
(* Goal: forall (context : flist) (a0 a1 b : form) (_ : Derivable context (Imp (OrF a0 a1) b)), Derivable context (Imp a1 b) *)
intros context a0 a1 b der.
(* Goal: Derivable context (Imp a b) *)
elim der; clear der.
(* Goal: forall (t : proof_term) (_ : derives (@cons form a context) t b), Derivable context (Imp a b) *)
intros t der_t.
apply
 Derivable_Intro with (Abs a1 (App (OrF a0 a1) (Shift t) (OrFR (Var 0) a0))).
(* Goal: derives context (Abs a (Shift t)) (Imp a b) *)
apply ImpIntro.
(* Goal: derives (@cons form (Atom i) context') (App (Atom i) (Shift s) (Var O)) b *)
apply ImpElim.
(* Goal: derives context t (Imp (Imp Falsum b) c) *)
(* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *)
apply ShiftIntro; assumption.
(* Goal: derives (@cons form a1 context) (OrFR (Var O) a0) (OrF a0 a1) *)
apply OrFIntroR.
(* Goal: my_nth form O (@cons form (Atom i) context') (Atom i) *)
apply ByAssumption; apply My_NthO.
Qed.




Lemma derivable_falsum_imp_b_imp_c__derivable_c :
 forall (context : flist) (b c : form),
 Derivable context (Imp (Imp Falsum b) c) -> Derivable context c.
(* Goal: forall (context : flist) (b c : form) (_ : Derivable context (Imp (Imp Falsum b) c)), Derivable context c *)
intros context b c der.
(* Goal: Derivable context (Imp a b) *)
elim der; clear der.
(* Goal: forall (t : proof_term) (_ : derives (@cons form a context) t b), Derivable context (Imp a b) *)
intros t der_t.
apply
 Derivable_Intro with (App (Imp Falsum b) t (Abs Falsum (Efq (Var 0) b))).
(* Goal: derives (@cons form (Atom i) context') (App (Atom i) (Shift s) (Var O)) b *)
apply ImpElim.
(* Goal: derives context t (Imp (Imp Falsum b) c) *)
(* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *)
assumption.
(* Goal: derives context (Abs a (Shift t)) (Imp a b) *)
apply ImpIntro.
(* Goal: derives (@cons form Falsum context) (Efq (Var O) b) b *)
apply ByAbsurdity.
(* Goal: my_nth form O (@cons form (Atom i) context') (Atom i) *)
apply ByAssumption; apply My_NthO.
Qed.


Lemma derivable_b__derivable_a_imp_b :
 forall (a b : form) (context : flist),
 Derivable context b -> Derivable context (Imp a b).
(* Goal: forall (a b : form) (context : flist) (_ : Derivable (@cons form a context) b), Derivable context (Imp a b) *)
intros a b context der.
(* Goal: Derivable context (Imp a b) *)
elim der; clear der.
(* Goal: forall (t : proof_term) (_ : derives (@cons form a context) t b), Derivable context (Imp a b) *)
intros t der_t.
(* Goal: Derivable context (Imp a b) *)
apply Derivable_Intro with (Abs a (Shift t)).
(* Goal: derives context (Abs a (Shift t)) (Imp a b) *)
apply ImpIntro.
(* Goal: derives context t (Imp (Imp Falsum b) c) *)
(* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *)
apply ShiftIntro; assumption.
Qed.


Lemma derivable_a_a_imp_b__derivable_b :
 forall (a b : form) (context : flist),
 Derivable context a -> Derivable context (Imp a b) -> Derivable context b.
(* Goal: forall (a b : form) (context : flist) (_ : Derivable context a) (_ : Derivable context (Imp a b)), Derivable context b *)
intros a b context der_a der_ab.
(* Goal: Derivable context b *)
elim der_a; clear der_a.
(* Goal: forall (t : proof_term) (_ : derives (@cons form a context) t b), Derivable context (Imp a b) *)
intros t der_t.
(* Goal: Derivable context b *)
elim der_ab; clear der_ab.
(* Goal: forall (t : proof_term) (_ : derives context t (Imp a b)), Derivable context b *)
intros s der_s.
(* Goal: Derivable context b *)
apply Derivable_Intro with (App a s t).
(* Goal: derives context (App a s t) b *)
apply ImpElim; assumption.
Qed.


Lemma derivable_a_context_b__derivable_a_imp_b :
 forall (a b : form) (context : flist),
 Derivable (a :: context) b -> Derivable context (Imp a b).
(* Goal: forall (a b : form) (context : flist) (_ : Derivable (@cons form a context) b), Derivable context (Imp a b) *)
intros a b context der.
(* Goal: Derivable context (Imp a b) *)
elim der; clear der.
(* Goal: forall (t : proof_term) (_ : derives (@cons form a context) t b), Derivable context (Imp a b) *)
intros t der_t.
(* Goal: Derivable context (Imp a b) *)
apply Derivable_Intro with (Abs a t).
(* Goal: derives context' (Abs (Atom i) t) (Imp (Atom i) a) *)
apply ImpIntro; assumption.
Qed.


Lemma derivable_vimp :
 forall (context : flist) (l : list Int) (a b : form),
 (forall context : flist, Derivable context a -> Derivable context b) ->
 Derivable context (vimp l a) -> Derivable context (vimp l b).
(* Goal: forall (context : flist) (l : list Int) (a : form) (_ : forall context0 : flist, Derivable context0 a), Derivable context (vimp l a) *)
intros context l.
(* Goal: forall (a : form) (_ : forall context : flist, Derivable context a), Derivable context (vimp l a) *)
elim l; clear l.
(* Goal: forall (a b : form) (_ : forall (context : flist) (_ : Derivable context a), Derivable context b) (_ : Derivable context (vimp (@nil Int) a)), Derivable context (vimp (@nil Int) b) *)
(* Goal: forall (a : Int) (l : list Int) (_ : forall (a0 b : form) (_ : forall (context : flist) (_ : Derivable context a0), Derivable context b) (_ : Derivable context (vimp l a0)), Derivable context (vimp l b)) (a0 b : form) (_ : forall (context : flist) (_ : Derivable context a0), Derivable context b) (_ : Derivable context (vimp (@cons Int a l) a0)), Derivable context (vimp (@cons Int a l) b) *)
intros a b der_ab der_a.
(* Goal: derives context t (Imp (Imp Falsum b) c) *)
(* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *)
apply der_ab; assumption.
(* Goal: forall (a : Int) (l : list Int) (_ : forall (a0 b : form) (_ : forall (context : flist) (_ : Derivable context a0), Derivable context b) (_ : Derivable context (vimp l a0)), Derivable context (vimp l b)) (a0 b : form) (_ : forall (context : flist) (_ : Derivable context a0), Derivable context b) (_ : Derivable context (vimp (@cons Int a l) a0)), Derivable context (vimp (@cons Int a l) b) *)
simpl in |- *; intros i l ih a b der_ab der_a.
(* Goal: derives context t (Imp (Imp Falsum b) c) *)
(* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *)
apply ih with (a := Imp (Atom i) a); try assumption.
(* Goal: forall (context : flist) (_ : Derivable context (Imp (Atom i) a)), Derivable context (Imp (Atom i) b) *)
intros context' der_ia.
(* Goal: Derivable context' (Imp (Atom i) c) *)
elim der_ia; clear der_ia; intros t der_ia.
(* Goal: Derivable context' (Imp (Atom i) b) *)
elim (der_ab (Atom i :: context')).
(* Goal: forall (t : proof_term) (_ : derives (@cons form (Atom i) context') t b), Derivable context' (Imp (Atom i) b) *)
(* Goal: Derivable (@cons form (Atom i) context') a *)
intros s der_b.
(* Goal: Derivable context' (Imp (Atom i) b) *)
(* Goal: Derivable (@cons form (Atom i) context') a *)
apply Derivable_Intro with (Abs (Atom i) s).
(* Goal: derives context' (Abs (Atom i) t) (Imp (Atom i) a) *)
apply ImpIntro; assumption.
(* Goal: Derivable (@cons form (Atom i) context') a *)
(* Goal: Derivable (@cons form (Atom i) context') b *)
apply Derivable_Intro with (App (Atom i) (Shift t) (Var 0)).
(* Goal: derives (@cons form (Atom i) context') (App (Atom i) (Shift s) (Var O)) b *)
apply ImpElim.
(* Goal: derives context t (Imp (Imp Falsum b) c) *)
(* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *)
apply ShiftIntro; assumption.
(* Goal: derives (@cons form (Atom i) context') (Var O) (Atom i) *)
apply ByAssumption.
(* Goal: my_nth form O (@cons form (Atom i) context') (Atom i) *)
apply My_NthO.
Qed.


Lemma derivable_vimp2 :
 forall (context : flist) (l : list Int) (a b c : form),
 (forall context : flist,
  Derivable context a -> Derivable context b -> Derivable context c) ->
 Derivable context (vimp l a) ->
 Derivable context (vimp l b) -> Derivable context (vimp l c).
(* Goal: forall (context : flist) (l : list Int) (a : form) (_ : forall context0 : flist, Derivable context0 a), Derivable context (vimp l a) *)
intros context l.
(* Goal: forall (a : form) (_ : forall context : flist, Derivable context a), Derivable context (vimp l a) *)
elim l; clear l.
(* Goal: forall (a b c : form) (_ : forall (context : flist) (_ : Derivable context a) (_ : Derivable context b), Derivable context c) (_ : Derivable context (vimp (@nil Int) a)) (_ : Derivable context (vimp (@nil Int) b)), Derivable context (vimp (@nil Int) c) *)
(* Goal: forall (a : Int) (l : list Int) (_ : forall (a0 b c : form) (_ : forall (context : flist) (_ : Derivable context a0) (_ : Derivable context b), Derivable context c) (_ : Derivable context (vimp l a0)) (_ : Derivable context (vimp l b)), Derivable context (vimp l c)) (a0 b c : form) (_ : forall (context : flist) (_ : Derivable context a0) (_ : Derivable context b), Derivable context c) (_ : Derivable context (vimp (@cons Int a l) a0)) (_ : Derivable context (vimp (@cons Int a l) b)), Derivable context (vimp (@cons Int a l) c) *)
intros a b c der_abc der_a der_b.
(* Goal: derives context t (Imp (Imp Falsum b) c) *)
(* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *)
apply der_abc; assumption.
(* Goal: forall (a : Int) (l : list Int) (_ : forall (a0 b c : form) (_ : forall (context : flist) (_ : Derivable context a0) (_ : Derivable context b), Derivable context c) (_ : Derivable context (vimp l a0)) (_ : Derivable context (vimp l b)), Derivable context (vimp l c)) (a0 b c : form) (_ : forall (context : flist) (_ : Derivable context a0) (_ : Derivable context b), Derivable context c) (_ : Derivable context (vimp (@cons Int a l) a0)) (_ : Derivable context (vimp (@cons Int a l) b)), Derivable context (vimp (@cons Int a l) c) *)
simpl in |- *; intros i l ih a b c der_abc der_a der_b.
(* Goal: derives context t (Imp (Imp Falsum b) c) *)
(* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *)
apply ih with (a := Imp (Atom i) a) (b := Imp (Atom i) b); try assumption.
(* Goal: forall (context : flist) (_ : Derivable context (Imp (Atom i) a)) (_ : Derivable context (Imp (Atom i) b)), Derivable context (Imp (Atom i) c) *)
clear ih.
(* Goal: forall (context : flist) (_ : Derivable context (Imp (Atom i) a)) (_ : Derivable context (Imp (Atom i) b)), Derivable context (Imp (Atom i) c) *)
intros context' der_ia der_ib.
(* Goal: Derivable context' (Imp (Atom i) c) *)
elim der_ia; clear der_ia; intros t der_ia.
(* Goal: Derivable context' (Imp (Atom i) c) *)
elim der_ib; clear der_ib; intros s der_ib.
(* Goal: Derivable context' (Imp (Atom i) c) *)
elim (der_abc (Atom i :: context')).
(* Goal: forall (t : proof_term) (_ : derives (@cons form (Atom i) context') t c), Derivable context' (Imp (Atom i) c) *)
(* Goal: Derivable (@cons form (Atom i) context') a *)
(* Goal: Derivable (@cons form (Atom i) context') b *)
intros r der_r.
(* Goal: Derivable context' (Imp (Atom i) c) *)
(* Goal: Derivable (@cons form (Atom i) context') a *)
(* Goal: Derivable (@cons form (Atom i) context') b *)
apply Derivable_Intro with (Abs (Atom i) r).
(* Goal: derives context' (Abs (Atom i) t) (Imp (Atom i) a) *)
apply ImpIntro; assumption.
(* Goal: Derivable (@cons form (Atom i) context') a *)
(* Goal: Derivable (@cons form (Atom i) context') b *)
apply Derivable_Intro with (App (Atom i) (Shift t) (Var 0)).
(* Goal: derives (@cons form (Atom i) context') (App (Atom i) (Shift s) (Var O)) b *)
apply ImpElim.
(* Goal: derives context t (Imp (Imp Falsum b) c) *)
(* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *)
apply ShiftIntro; assumption.
(* Goal: derives (@cons form (Atom i) context') (Var O) (Atom i) *)
apply ByAssumption.
(* Goal: my_nth form O (@cons form (Atom i) context') (Atom i) *)
apply My_NthO.
(* Goal: Derivable (@cons form (Atom i) context') b *)
apply Derivable_Intro with (App (Atom i) (Shift s) (Var 0)).
(* Goal: derives (@cons form (Atom i) context') (App (Atom i) (Shift s) (Var O)) b *)
apply ImpElim.
(* Goal: derives context t (Imp (Imp Falsum b) c) *)
(* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *)
apply ShiftIntro; assumption.
(* Goal: derives (@cons form (Atom i) context') (Var O) (Atom i) *)
apply ByAssumption.
(* Goal: my_nth form O (@cons form (Atom i) context') (Atom i) *)
apply My_NthO.
Qed.


Lemma derivable_vimp0 :
 forall (context : flist) (l : list Int) (a : form),
 (forall context : flist, Derivable context a) ->
 Derivable context (vimp l a).
(* Goal: forall (context : flist) (l : list Int) (a : form) (_ : forall context0 : flist, Derivable context0 a), Derivable context (vimp l a) *)
intros context l.
(* Goal: forall (a : form) (_ : forall context : flist, Derivable context a), Derivable context (vimp l a) *)
elim l; clear l.
(* Goal: forall (a : form) (_ : forall context : flist, Derivable context a), Derivable context (vimp (@nil Int) a) *)
(* Goal: forall (a : Int) (l : list Int) (_ : forall (a0 : form) (_ : forall context : flist, Derivable context a0), Derivable context (vimp l a0)) (a0 : form) (_ : forall context : flist, Derivable context a0), Derivable context (vimp (@cons Int a l) a0) *)
intros a der_a.
(* Goal: derives context t (Imp (Imp Falsum b) c) *)
(* Goal: derives context (Abs Falsum (Efq (Var O) b)) (Imp Falsum b) *)
apply der_a; assumption.
(* Goal: forall (a : Int) (l : list Int) (_ : forall (a0 : form) (_ : forall context : flist, Derivable context a0), Derivable context (vimp l a0)) (a0 : form) (_ : forall context : flist, Derivable context a0), Derivable context (vimp (@cons Int a l) a0) *)
simpl in |- *; intros i l ih a der_a.
(* Goal: Derivable context (vimp l (Imp (Atom i) a)) *)
apply ih.
(* Goal: forall context : flist, Derivable context (Imp (Atom i) a) *)
intros context'.
(* Goal: Derivable context' (Imp (Atom i) a) *)
elim der_a with (Atom i :: context'); clear der_a; intros t der_a.
(* Goal: Derivable context' (Imp (Atom i) a) *)
apply Derivable_Intro with (Abs (Atom i) t).
(* Goal: derives context' (Abs (Atom i) t) (Imp (Atom i) a) *)
apply ImpIntro; assumption.
Qed.
