(* Autor(s): Andrej Dudenhefner (1) Affiliation(s): (1) Saarland University, Saarbrücken, Germany  Description: Theorem "pure_typable_intro_prenex" can be used to introduce/eliminate closed assumption ∀..∀.s where s is simple. Theorem "pure_typable_intro_poly_arr_0_0" can be used to introduce/eliminate the assumption 0 -> 0 [1].  Related Work: [1] Wells, Joe B. "Typability and Type-Checking in the Second-Order lambda-Calculus are Equivalent and Undecidable." Proceedings Ninth Annual IEEE Symposium on Logic In Computer Science. IEEE, 1994. *)
From Undecidability.SystemF.Util Require Import Facts poly_type_facts pure_term_facts term_facts typing_facts iipc2_facts pure_typing_facts.
(* (\_.M) N *)
Definition K' M N := pure_app (pure_abs (ren_pure_term S M)) N.
Definition Mω := pure_abs (pure_app (pure_var 0) (pure_var 0)).
(* \x. K x (K (\w.(x (x w))) N) N can be used to work further with x *)
Definition M_Wells N :=
pure_abs (K' (pure_var 0) (K' (pure_abs (pure_app (pure_var 1) (pure_app (pure_var 1) (pure_var 0)))) N)).
(* (\y. K (y y) (y Mω)) (M_Wells N) *)
Definition M_Wells_J N := pure_app
(pure_abs (K' (pure_app (pure_var 0) (pure_var 0)) (pure_app (pure_var 0) Mω)))
(M_Wells N).

Lemma pure_typable_pure_app_0_0' {n1 n2 n3 n4 x y n5 s t Gamma}:
pure_typable
(many_poly_abs n1
(poly_arr
(many_poly_abs n2
(poly_arr (many_poly_abs n3 (poly_var (n3 + (n2 + x)))) (many_poly_abs n4 (poly_var y))))
(many_poly_abs n5 (poly_arr s t))) :: Gamma)
(pure_app (pure_var 0) (pure_var 0)) ->
exists y', y = n4 + (n2 + y').