From 120879c099a2fb71e67a41a1c852c5db65e9eb4f Mon Sep 17 00:00:00 2001 From: Josh Chen Date: Mon, 28 May 2018 15:53:07 +0200 Subject: Dependent product rules done and proofs of typing properties so far work. Starting on dependent sums. --- HoTT_Theorems.thy | 93 +++++++++++++++++++++++++++++++++---------------------- 1 file changed, 56 insertions(+), 37 deletions(-) (limited to 'HoTT_Theorems.thy') diff --git a/HoTT_Theorems.thy b/HoTT_Theorems.thy index bea3dfe..33b0957 100644 --- a/HoTT_Theorems.thy +++ b/HoTT_Theorems.thy @@ -2,63 +2,82 @@ theory HoTT_Theorems imports HoTT begin -text "A bunch of theorems and other statements for sanity-checking, as well as things that should be automatically simplified." +text "A bunch of theorems and other statements for sanity-checking, as well as things that should be automatically simplified. -section \Foundational stuff\ +Things that *should* be automated: + \ Checking that \A\ is a well-formed type, when writing things like \x : A\ and \A : U\. +" -theorem "\A : U; A \ B\ \ B : U" by simp +\ \Turn on trace for unification and the simplifier, for debugging.\ +declare[[unify_trace_simp, unify_trace_types, simp_trace]] section \Functions\ -lemma "A : U \ \<^bold>\x. x : A\A" - by (rule Prod_intro) +text "Declaring \Prod_intro\ with the \intro\ attribute (in HoTT.thy) enables \standard\ to prove the following." + +lemma id_function: "A : U \ \<^bold>\x. x : A\A" .. + +text "Here is the same result, stated and proved differently. +The standard method invoked after the keyword \proof\ is applied to the goal \\<^bold>\x. x: A\A\, and so we need to show the prover how to continue, as opposed to the previous lemma." + +lemma + assumes "A : U" + shows "\<^bold>\x. x : A\A" +proof + show "A : U" using assms . + show "\x. A : A \ U" using assms .. +qed text "Note that there is no provision for declaring the type of bound variables outside of the scope of a lambda expression. -Hence a statement like \x : A\ is not needed (nor possible!) in the premises of the following lemma." +More generally, we cannot write an assumption stating 'Let \x\ be a variable of type \A\'." -lemma "\A : U; A \ B\ \ \<^bold>\x. x : B\A" +proposition "\A : U; A \ B\ \ \<^bold>\x. x : B\A" proof - assume - 0: "A : U" and - 1: "A \ B" - from 0 have 2: "\<^bold>\x. x : A\A" by (rule Prod_intro) - from 1 have 3: "A\A \ B\A" by simp - from 3 and 2 show "\<^bold>\x. x : B\A" by (rule equal_types) - qed - -lemma "\A : U; B : U; x : A\ \ \<^bold>\y. x : B\A" -proof - -assume - 1: "A : U" and - 2: "B : U" and - 3: "x : A" -then show "\<^bold>\y. x : B\A" -proof - -from 3 have "\<^bold>\y. x : B\A" by (rule Prod_intro) + 1: "A : U" and + 2: "A \ B" + from id_function[OF 1] have 3: "\<^bold>\x. x : A\A" . + from 2 have "A\A \ B\A" by simp + with 3 show "\<^bold>\x. x : B\A" .. qed + +text "It is instructive to try to prove \\A : U; B : U\ \ \<^bold>\x. \<^bold>\y. x : A\B\A\. +First we prove an intermediate step." + +lemma constant_function: "\A : U; B : U; x : A\ \ \<^bold>\y. x : B\A" .. + +text "And now the actual result:" + +proposition + assumes 1: "A : U" and 2: "B : U" + shows "\<^bold>\x. \<^bold>\y. x : A\B\A" +proof + show "A : U" using assms(1) . + show "\x. x : A \ \<^bold>\y. x : B \ A" using assms by (rule constant_function) + + from assms have "B \ A : U" by (rule Prod_formation) + then show "\x. B \ A: A \ U" using assms(1) by (rule constant_type_family) qed -lemma "\A : U; B : U\ \ \<^bold>\x. \<^bold>\y. x : A\B\A" -proof - +text "Maybe a nicer way to write it:" + +proposition "\A : U; B: U\ \ \<^bold>\x. \<^bold>\y. x : A\B\A" +proof fix x - assume - "A : U" and - "B : U" and - "x : A" - then have "\<^bold>\y. x : B\A" by (rule Prod_intro) - + show "\A : U; B : U; x : A\ \ \<^bold>\y. x : B \ A" by (rule constant_function) + show "\A : U; B : U\ \ B\A : U" by (rule Prod_formation) qed section \Nats\ text "Here's a dumb proof that 2 is a natural number." -lemma "succ(succ 0) : Nat" -proof - - have "0 : Nat" by (rule Nat_intro1) - from this have "(succ 0) : Nat" by (rule Nat_intro2) - thus "succ(succ 0) : Nat" by (rule Nat_intro2) -qed +proposition "succ(succ 0) : Nat" + proof - + have "0 : Nat" by (rule Nat_intro1) + from this have "(succ 0) : Nat" by (rule Nat_intro2) + thus "succ(succ 0) : Nat" by (rule Nat_intro2) + qed text "We can of course iterate the above for as many applications of \succ\ as we like. The next thing to do is to implement induction to automate such proofs. -- cgit v1.2.3