From a7303e36651ea1f8ec50958415fa0db7295ad957 Mon Sep 17 00:00:00 2001 From: Josh Chen Date: Fri, 1 Jun 2018 03:39:51 +0200 Subject: Should be final version of Prod. Theorems proving stuff about currying. Rules for Sum, going to change them to use object-level arguments more. --- HoTT_Theorems.thy | 69 ++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 50 insertions(+), 19 deletions(-) (limited to 'HoTT_Theorems.thy') diff --git a/HoTT_Theorems.thy b/HoTT_Theorems.thy index 0aefe94..5922b51 100644 --- a/HoTT_Theorems.thy +++ b/HoTT_Theorems.thy @@ -21,34 +21,65 @@ 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\ proposition "a : A \ (\<^bold>\x:A. x)`a \ a" by simp -text "Two arguments:" +text "Currying:" + +lemma "(\<^bold>\x:A. \<^bold>\y:B. f x y)`a \ \<^bold>\y:B. f a y" by simp + +lemma "(\<^bold>\x:A. \<^bold>\y:B. \<^bold>\z:C. f x y z)`a`b`c \ f a b c" by simp + +proposition wellformed_currying: + fixes + A::Term and + B::"Term \ Term" and + C::"Term \ Term \ Term" + assumes + "A : U" and + "B: A \ U" and + "\x::Term. C(x): B(x) \ U" + shows "\x:A. \y:B(x). C x y : U" +proof (rule Prod_formation) + show "\x::Term. x : A \ \y:B(x). C x y : U" + proof (rule Prod_formation) + fix x y::Term + assume "x : A" + show "y : B x \ C x y : U" by (rule assms(3)) + qed (rule assms(2)) +qed (rule assms(1)) lemma - assumes "a : A" and "b : B" - shows "(\<^bold>\x:A. \<^bold>\y:B. x)`a`b \ a" -proof - - have "(\<^bold>\x:A. \<^bold>\y:B. x)`a \ \<^bold>\y:B. a" using assms(1) by (rule Prod_comp[of a A "\x. \<^bold>\y:B. x"]) - then have "(\<^bold>\x:A. \<^bold>\y:B. x)`a`b \ (\<^bold>\y:B. a)`b" by simp - also have "(\<^bold>\y:B. a)`b \ a" using assms by simp - finally show "(\<^bold>\x:A. \<^bold>\y:B. x)`a`b \ a" . + fixes + a b A::Term and + B::"Term \ Term" and + f C::"[Term, Term] \ Term" + 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 + fix y::Term + assume **: "y : B(x)" + show "f x y : C x y" by (rule assms[OF * **]) + 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! -- cgit v1.2.3