From 80412abb0fdec553d80a56af16d1cfd8da52e7ed Mon Sep 17 00:00:00 2001 From: Josh Chen Date: Tue, 5 Jun 2018 17:35:49 +0200 Subject: Proved that the inductor on Sum has the correct type. --- HoTT_Theorems.thy | 77 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 50 insertions(+), 27 deletions(-) (limited to 'HoTT_Theorems.thy') diff --git a/HoTT_Theorems.thy b/HoTT_Theorems.thy index a44c8f9..1ac4484 100644 --- a/HoTT_Theorems.thy +++ b/HoTT_Theorems.thy @@ -21,19 +21,19 @@ text "Declaring \Prod_intro\ with the \intro\ attribut lemma "\<^bold>\x:A. x : A\A" .. proposition "A \ B \ \<^bold>\x:A. x : B\A" - proof - - assume assm: "A \ B" - have id: "\<^bold>\x:A. x : A\A" .. - from assm have "A\A \ B\A" by simp - with id show "\<^bold>\x:A. x : B\A" .. - qed +proof - + assume assm: "A \ B" + have id: "\<^bold>\x:A. x : A\A" .. + from assm have "A\A \ B\A" by simp + with id show "\<^bold>\x:A. x : B\A" .. +qed proposition "\<^bold>\x:A. \<^bold>\y:B. x : A\B\A" - proof - fix a - assume "a : A" - then show "\<^bold>\y:B. a : B \ A" .. - qed +proof + fix a + assume "a : A" + then show "\<^bold>\y:B. a : B \ A" .. +qed subsection \Function application\ @@ -61,9 +61,9 @@ proof (rule Prod_formation) fix x::Term assume *: "x : A" show "\y:B(x). C x y : U" - proof (rule Prod_formation) - show "B(x) : U" using * by (rule assms) - qed (rule assms) + proof (rule Prod_formation) + show "B(x) : U" using * by (rule assms) + qed (rule assms) qed (rule assms) proposition triply_curried: @@ -81,36 +81,59 @@ proposition triply_curried: proof (rule Prod_formation) fix x::Term assume 1: "x : A" show "\y:B(x). \z:C(x)(y). D(x)(y)(z) : U" + proof (rule Prod_formation) + show "B(x) : U" using 1 by (rule assms) + + fix y::Term assume 2: "y : B(x)" + show "\z:C(x)(y). D(x)(y)(z) : U" proof (rule Prod_formation) - show "B(x) : U" using 1 by (rule assms) - - fix y::Term assume 2: "y : B(x)" - show "\z:C(x)(y). D(x)(y)(z) : U" - proof (rule Prod_formation) - show "C x y : U" using 2 by (rule assms) - show "\z::Term. z : C(x)(y) \ D(x)(y)(z) : U" by (rule assms) - qed + show "C x y : U" using 2 by (rule assms) + show "\z::Term. z : C(x)(y) \ D(x)(y)(z) : U" by (rule assms) qed + qed qed (rule assms) -lemma +lemma curried_type: fixes a b A::Term and B::"Term \ Term" and f C::"[Term, Term] \ Term" - assumes "\x y::Term. f x y : C x y" + assumes "\x y::Term. \x : A; y : B(x)\ \ f x y : C x y" shows "\<^bold>\x:A. \<^bold>\y:B(x). f x y : \x:A. \y:B(x). C x y" proof fix x::Term + assume *: "x : A" show "\<^bold>\y:B(x). f x y : \y:B(x). C x y" - proof - show "\y. f x y : C x y" by (rule assms) - qed + proof + fix y::Term + assume **: "y : B(x)" + show "f x y : C x y" using * ** by (rule assms) + qed qed text "Note that the propositions and proofs above often say nothing about the well-formedness of the types, or the well-typedness of the lambdas involved; one has to be very explicit and prove such things separately! This is the result of the choices made regarding the premises of the type rules." +text "The following shows that the dependent sum inductor has the type we expect it to have:" + +lemma + assumes "C: \x:A. B(x) \ U" + shows "indSum(C) : \f:(\x:A. \y:B(x). C((x,y))). \p:(\x:A. B(x)). C(p)" +proof - + define F and P where + "F \ \x:A. \y:B(x). C((x,y))" and + "P \ \x:A. B(x)" + + have "\<^bold>\f:F. \<^bold>\p:P. indSum(C)`f`p : \f:F. \p:P. C(p)" + proof (rule curried_type) + fix f p::Term + assume "f : F" and "p : P" + with assms show "indSum(C)`f`p : C(p)" unfolding F_def P_def .. + qed + + then show "indSum(C) : \f:F. \p:P. C(p)" by simp +qed + text "Polymorphic identity function." consts Ui::Term -- cgit v1.2.3