From 912a4a4b909041cb280ae5cecd40867ce34b58de Mon Sep 17 00:00:00 2001 From: Josh Chen Date: Mon, 18 Jun 2018 11:20:11 +0200 Subject: Removed all [simp] attributes, these will be added later when I set up the simplifier. Proved simplification rule for dependent fst. --- HoTT_Base.thy | 2 +- Prod.thy | 31 +++++++++++++++++++------------ Sum.thy | 49 +++++++++++++++++++++++++++++++------------------ 3 files changed, 51 insertions(+), 31 deletions(-) diff --git a/HoTT_Base.thy b/HoTT_Base.thy index 9b7c3e2..7794601 100644 --- a/HoTT_Base.thy +++ b/HoTT_Base.thy @@ -34,7 +34,7 @@ consts is_of_type :: "[Term, Term] \ prop" ("(1_ :/ _)" [0, 0] 1000) axiomatization where - inhabited_implies_type: "\a A. a : A \ A : U" + inhabited_implies_type [intro]: "\a A. a : A \ A : U" section \Type families\ diff --git a/Prod.thy b/Prod.thy index 7cce7f0..bfb4f42 100644 --- a/Prod.thy +++ b/Prod.thy @@ -16,40 +16,47 @@ axiomatization \ \Application binds tighter than abstraction.\ appl :: "[Term, Term] \ Term" (infixl "`" 60) + +section \Syntax\ + syntax "_PROD" :: "[idt, Term, Term] \ Term" ("(3\_:_./ _)" 30) "_LAMBDA" :: "[idt, Term, Term] \ Term" ("(3\<^bold>\_:_./ _)" 30) "_PROD_ASCII" :: "[idt, Term, Term] \ Term" ("(3PROD _:_./ _)" 30) "_LAMBDA_ASCII" :: "[idt, Term, Term] \ Term" ("(3%%_:_./ _)" 30) -\ \The translations below bind the variable \x\ in the expressions \B\ and \b\.\ +text "The translations below bind the variable \x\ in the expressions \B\ and \b\." + translations "\x:A. B" \ "CONST Prod A (\x. B)" "\<^bold>\x:A. b" \ "CONST lambda A (\x. b)" "PROD x:A. B" \ "CONST Prod A (\x. B)" "%%x:A. b" \ "CONST lambda A (\x. b)" -\ \Type rules\ + +section \Type rules\ + axiomatization where - Prod_form [intro]: "\A B. \A : U; B : A \ U\ \ \x:A. B x : U" + Prod_form: "\A B. \A : U; B : A \ U\ \ \x:A. B x : U" and - Prod_intro [intro]: "\A B b. \A : U; \x. x : A \ b x : B x\ \ \<^bold>\x:A. b x : \x:A. B x" + Prod_intro: "\A B b. \A : U; \x. x : A \ b x : B x\ \ \<^bold>\x:A. b x : \x:A. B x" and - Prod_elim [elim]: "\A B f a. \f : \x:A. B x; a : A\ \ f`a : B a" + Prod_elim: "\A B f a. \f : \x:A. B x; a : A\ \ f`a : B a" and - Prod_comp [simp]: "\A B b a. \\x. x : A \ b x : B x; a : A\ \ (\<^bold>\x:A. b x)`a \ b a" + Prod_comp: "\A B b a. \\x. x : A \ b x : B x; a : A\ \ (\<^bold>\x:A. b x)`a \ b a" and - Prod_uniq [simp]: "\A B f. f : \x:A. B x \ \<^bold>\x:A. (f`x) \ f" + Prod_uniq: "\A B f. f : \x:A. B x \ \<^bold>\x:A. (f`x) \ f" + +text "The type rules should be able to be used as introduction rules by the standard reasoner:" -\ \The funny thing about the first premises of the computation and uniqueness rules is that they introduce a variable B that doesn't actually explicitly appear in the statement of the conclusion. -In a sense, they say something like "if this condition holds for some type family B... (then we can apply the rule)". -This forces the theorem prover to search for a suitable B. Is this additional overhead necessary? -It *is* a safety check for well-formedness...\ +lemmas Prod_rules [intro] = Prod_form Prod_intro Prod_elim Prod_comp Prod_uniq text "Note that the syntax \\<^bold>\\ (bold lambda) used for dependent functions clashes with the proof term syntax (cf. \
2.5.2 of the Isabelle/Isar Implementation)." -\ \Nondependent functions are a special case.\ +text "Nondependent functions are a special case." + abbreviation Function :: "[Term, Term] \ Term" (infixr "\" 40) where "A \ B \ \_:A. B" + end \ No newline at end of file diff --git a/Sum.thy b/Sum.thy index fbfc15a..8e7ccd6 100644 --- a/Sum.thy +++ b/Sum.thy @@ -15,6 +15,9 @@ axiomatization pair :: "[Term, Term] \ Term" ("(1'(_,/ _'))") and indSum :: "[Term, Typefam, Typefam, [Term, Term] \ Term, Term] \ Term" ("(1indSum[_,/ _])") + +section \Syntax\ + syntax "_SUM" :: "[idt, Term, Term] \ Term" ("(3\_:_./ _)" 20) "_SUM_ASCII" :: "[idt, Term, Term] \ Term" ("(3SUM _:_./ _)" 20) @@ -23,30 +26,35 @@ translations "\x:A. B" \ "CONST Sum A (\x. B)" "SUM x:A. B" \ "CONST Sum A (\x. B)" + +section \Type rules\ + axiomatization where - Sum_form [intro]: "\A B. \A : U; B: A \ U\ \ \x:A. B x : U" + Sum_form: "\A B. \A : U; B: A \ U\ \ \x:A. B x : U" and - Sum_intro [intro]: "\A B a b. \B: A \ U; a : A; b : B a\ \ (a,b) : \x:A. B x" + Sum_intro: "\A B a b. \B: A \ U; a : A; b : B a\ \ (a,b) : \x:A. B x" and - Sum_elim [elim]: "\A B C f p. \ + Sum_elim: "\A B C f p. \ C: \x:A. B x \ U; \x y. \x : A; y : B x\ \ f x y : C (x,y); p : \x:A. B x \ \ indSum[A,B] C f p : C p" and - Sum_comp [simp]: "\A B C f a b. \ + Sum_comp: "\A B C f a b. \ C: \x:A. B x \ U; \x y. \x : A; y : B x\ \ f x y : C (x,y); a : A; b : B a \ \ indSum[A,B] C f (a,b) \ f a b" +lemmas Sum_rules [intro] = Sum_form Sum_intro Sum_elim Sum_comp + \ \Nondependent pair\ abbreviation Pair :: "[Term, Term] \ Term" (infixr "\" 50) where "A \ B \ \_:A. B" -section \Projections\ +section \Projection functions\ consts fst :: "[Term, 'a] \ Term" ("(1fst[/_,/ _])") @@ -74,23 +82,28 @@ begin "snd_nondep A B \ \<^bold>\p: A \ B. indSum[A, \_. B] (\_. B) (\x y. y) p" end -text "Properties of projections:" +text "Simplifying projections:" -lemma fst_dep_comp: +lemma fst_dep_comp: (* Potential for automation *) assumes "B: A \ U" and "a : A" and "b : B a" shows "fst[A,B]`(a,b) \ a" -proof (unfold fst_dep_def) (* GOOD AUTOMATION EXAMPLE *) - have "\p. p : \x:A. B x \ indSum[A, B] (\_. A) (\x y. x) p : A" .. - moreover have "(a, b) : \x:A. B x" using assms .. - then have "fst[A,B]`(a,b) \ indSum[A, B] (\_. A) (\x y. x) (a,b)" unfolding fst_dep_def by (simp add: Prod_comp) - have "A : U" using assms(2) .. - then have "\_. A: \x:A. B x \ U" . - moreover have "\x y. x : A \ (\x y. x) x y : A" . - moreover - ultimately show "fst[A,B]`(a,b) \ a" unfolding fst_dep_def using assms by simp -qed +proof (unfold fst_dep_def) + \ "Write about this proof: unfolding, how we set up the introduction rules (explain \..\), do a trace of the proof, explain the meaning of keywords, etc." -thm Sum_comp + have *: "A : U" using assms(2) .. (* I keep thinking this should not have to be done explicitly, but rather automated. *) + + then have "\p. p : \x:A. B x \ indSum[A,B] (\_. A) (\x y. x) p : A" .. + + moreover have "(a,b) : \x:A. B x" using assms .. + + ultimately have "(\<^bold>\p: (\x:A. B x). indSum[A,B] (\_. A) (\x y. x) p)`(a,b) \ + indSum[A,B] (\_. A) (\x y. x) (a,b)" .. + + also have "indSum[A,B] (\_. A) (\x y. x) (a,b) \ a" + by (rule Sum_comp) (rule *, assumption, (rule assms)+) + + finally show "(\<^bold>\p: (\x:A. B x). indSum[A,B] (\_. A) (\x y. x) p)`(a,b) \ a" . +qed lemma snd_dep_comp: assumes "a : A" and "b : B a" -- cgit v1.2.3