From b4a87cc14acaea8a06ee38032c7f4cd94477ca97 Mon Sep 17 00:00:00 2001 From: Josh Chen Date: Sat, 18 Aug 2018 00:19:42 +0200 Subject: Update test file --- HoTT_Test.thy | 132 +++++++++------------------------------------------------- 1 file changed, 19 insertions(+), 113 deletions(-) diff --git a/HoTT_Test.thy b/HoTT_Test.thy index 67284cf..da044b4 100644 --- a/HoTT_Test.thy +++ b/HoTT_Test.thy @@ -86,130 +86,36 @@ proposition curried_function_formation: proposition higher_order_currying_formation: - fixes - A::Term and - B::"Term \ Term" and - C::"[Term, Term] \ Term" and - D::"[Term, Term, Term] \ Term" assumes - "A : U" and - "B: A \ U" and - "\x y::Term. y : B(x) \ C(x)(y) : U" and - "\x y z::Term. z : C(x)(y) \ D(x)(y)(z) : U" - shows "\x:A. \y:B(x). \z:C(x)(y). D(x)(y)(z) : U" -proof - fix x::Term assume 1: "x : A" - show "\y:B(x). \z:C(x)(y). D(x)(y)(z) : U" - proof - 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 - 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) - -(**** AND PROBABLY THIS TOO? ****) + "A: U(i)" and + "B: A \ U(i)" and + "\x y. y: B(x) \ C(x)(y): U(i)" and + "\x y z. z : C(x)(y) \ D(x)(y)(z): U(i)" + shows "\x:A. \y:B(x). \z:C(x)(y). D(x)(y)(z): U(i)" + by (simple lems: assms) + + lemma curried_type_judgment: - 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" using * ** by (rule assms) - qed -qed + assumes "A: U(i)" "B: A \ U(i)" "\x y. \x : A; y : B(x)\ \ f x y : C x y" + shows "\<^bold>\x y. f x y : \x:A. \y:B(x). C x y" + by (simple lems: assms) + 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. + Polymorphic identity function. Trivial due to lambda expression polymorphism. + (Was more involved in previous monomorphic incarnations.) " +definition Id :: "Term" where "Id \ \<^bold>\x. x" -section \\ type\ - -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_judgment) - 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 +lemma "\x: A\ \ Id`x \ x" +unfolding Id_def by (compute, simple) - then show "indSum(C) : \f:F. \p:P. C(p)" by simp -qed - -(**** AUTOMATION CANDIDATE ****) -text "Propositional uniqueness principle for dependent sums:" - -text "We would like to eventually automate proving that 'a given type \A\ is inhabited', i.e. search for an element \a:A\. - -A good starting point would be to automate the application of elimination rules." -notepad begin - -fix A B assume "A : U" and "B: A \ U" - -define C where "C \ \p. p =[\x:A. B(x)] (fst[A,B]`p, snd[A,B]`p)" -have *: "C: \x:A. B(x) \ U" -proof - - fix p assume "p : \x:A. B(x)" - have "(fst[A,B]`p, snd[A,B]`p) : \x:A. B(x)" - -define f where "f \ \<^bold>\x:A. \<^bold>\y:B(x). refl((x,y))" -have "f`x`y : C((x,y))" -sorry - -have "p : \x:A. B(x) \ indSum(C)`f`p : C(p)" using * ** by (rule Sum_elim) - -end - - -section \Universes and polymorphism\ - -text "Polymorphic identity function. Uses universe types." - - - -definition Id :: "Ord \ Term" where "Id(i) \ \<^bold>\A x. x" - - -(* section \Natural numbers\ -text "Here's a dumb proof that 2 is a natural number." - -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 "Automatic proof methods recognize natural numbers." -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. - -When we get more stuff working, I'd like to aim for formalizing the encode-decode method to be able to prove the only naturals are 0 and those obtained from it by \succ\." -*) +proposition "succ(succ(succ 0)): Nat" by simple end -- cgit v1.2.3