From 5b217a7eb36906eabdcb6ec626a2d02e0f94c308 Mon Sep 17 00:00:00 2001 From: Josh Chen Date: Thu, 10 May 2018 19:13:05 +0200 Subject: Decided to go with no explicit type declarations in object-lambda expressions. Everything in the proof stuff is working at the moment. --- HoTT.thy | 39 +++++++++++++++++++++++++-------------- test.thy | 29 ++++++++++++++++++----------- 2 files changed, 43 insertions(+), 25 deletions(-) diff --git a/HoTT.thy b/HoTT.thy index 9d63388..3e5ba71 100644 --- a/HoTT.thy +++ b/HoTT.thy @@ -3,32 +3,42 @@ imports Pure begin section \Setup\ - -(* ML files, routines and setup should probably go here *) +text \ +For ML files, routines and setup. +\ section \Basic definitions\ - text \ A single meta-level type \Term\ suffices to implement the object-level types and terms. - For now we do not implement universes, but simply follow the informal notation in the HoTT book. -\ -(* Actually unsure if a single meta-type suffices... *) +\ (* Actually unsure if a single meta-type suffices... *) typedecl Term subsection \Judgements\ - consts is_a_type :: "Term \ prop" ("(_ : U)") (* Add precedences when I figure them out! *) is_of_type :: "Term \ Term \ prop" ("(_ : _)") subsection \Basic axioms\ +subsubsection \Definitional equality\ +text\ +We take the meta-equality \, defined by the Pure framework for any of its terms, +and use it additionally for definitional/judgmental equality of types and terms in our theory. -axiomatization -where - inhabited_implies_type: "\x A. x : A \ A : U" and - equal_types: "\A B x. A \ B \ x : A \ x : B" +Note that the Pure framework already provides axioms and results for the various properties of \, +which we make use of and extend where necessary. +\ + + +theorem DefEq_symmetry: "\A B. A \ B \ B \ A" + by (rule Pure.symmetric) + +subsubsection \Type-related properties\ + +axiomatization where + equal_types: "\A B x. \A \ B; x : A\ \ x : B" and + inhabited_implies_type: "\x A. x : A \ A : U" subsection \Basic types\ @@ -41,7 +51,8 @@ Same for the nondependent product below. axiomatization Function :: "Term \ Term \ Term" (infixr "\" 10) and - lambda :: "(Term \ Term) \ Term" (binder "\<^bold>\" 10) and (* precedence! *) + lambda :: "(Term \ Term) \ Term" (binder "\<^bold>\" 10) and + (* Is bold lambda already used by something else? Proof transformers in Pure maybe?... *) appl :: "Term \ Term \ Term" ("(_`_)") where Function_form: "\A B. \A : U; B : U\ \ A\B : U" and @@ -62,8 +73,8 @@ where Product_comp: "\A B C g a b. \C : U; g : A\B\C; a : A; b : B\ \ rec_Product(A,B,C,g)`(a,b) \ (g`a)`b" \ \Projection onto first component\ -definition proj1 :: "Term \ Term \ Term" ("(proj1'(_,_'))") where - "proj1(A,B) \ rec_Product(A, B, A, \<^bold>\x. \<^bold>\y. x)" +definition proj1 :: "Term \ Term \ Term" ("(proj1\_,_\)") where + "proj1\A,B\ \ rec_Product(A, B, A, \<^bold>\x. \<^bold>\y. x)" subsubsection \Empty type\ diff --git a/test.thy b/test.thy index 94ba900..d22e710 100644 --- a/test.thy +++ b/test.thy @@ -2,12 +2,19 @@ theory test imports HoTT begin +text \Check trivial stuff:\ lemma "Null : U" by (rule Null_form) +text \ +Do functions behave like we expect them to? +(Or, is my implementation at least somewhat correct?... +\ + lemma "A \ B \ (\<^bold>\x. x) : B\A" proof - - have "\x. A \ B \ x : B \ x : A" by (rule equal_types) + have "A \ B \ B \ A" by (rule DefEq_symmetry) + then have "\x. A \ B \ x : B \ x : A" by (rule equal_types) thus "A \ B \ (\<^bold>\x. x) : B\A" by (rule Function_intro) qed @@ -17,19 +24,19 @@ proof - thus "\<^bold>\x. \<^bold>\y. x : A\B\A" by (rule Function_intro) qed -(* The previous proofs are nice, BUT I want to be able to do something like the following: -lemma "x : A \ \<^bold>\x. x : B\B" -i.e. I want to be able to associate a type to variables, and have the type remembered by any -binding I define later. - -Do I need to give up using the \binder\ syntax in order to do this? -*) - +text \Here's a dumb proof that 2 is a natural number:\ lemma "succ(succ 0) : Nat" proof - - have "(succ 0) : Nat" by (rule Nat_intro2) - from this have "succ(succ 0) : Nat" by (rule Nat_intro2) + 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 some kind of induction tactic to automate such proofs. + +When we get more stuff working, I'd like to aim for formalizing the encode-decode method. +\ end \ No newline at end of file -- cgit v1.2.3