From ea0c0c5427888982adce10ab25cebe445997f08b Mon Sep 17 00:00:00 2001 From: Josh Chen Date: Mon, 17 Sep 2018 13:13:08 +0200 Subject: Moved function composition lemmas into Prod.thy --- Prod.thy | 102 +++++++++++++++++++++++++++++----------------------------- ProdProps.thy | 57 -------------------------------- 2 files changed, 51 insertions(+), 108 deletions(-) delete mode 100644 ProdProps.thy diff --git a/Prod.thy b/Prod.thy index a3cc347..db18454 100644 --- a/Prod.thy +++ b/Prod.thy @@ -1,89 +1,89 @@ -(* Title: HoTT/Prod.thy - Author: Josh Chen +(* +Title: Prod.thy +Author: Joshua Chen +Date: 2018 -Dependent product (function) type +Dependent product type *) theory Prod - imports HoTT_Base +imports HoTT_Base HoTT_Methods + begin -section \Constants and syntax\ +section \Basic definitions\ axiomatization - Prod :: "[t, tf] \ t" and + Prod :: "[t, tf] \ t" and lambda :: "(t \ t) \ t" (binder "\<^bold>\" 30) and - appl :: "[t, t] \ t" (infixl "`" 60) - \ \Application binds tighter than abstraction.\ + appl :: "[t, t] \ t" ("(1_`/_)" [60, 61] 60) \ \Application binds tighter than abstraction.\ syntax - "_PROD" :: "[idt, t, t] \ t" ("(3\_:_./ _)" 30) - "_PROD_ASCII" :: "[idt, t, t] \ t" ("(3PROD _:_./ _)" 30) + "_prod" :: "[idt, t, t] \ t" ("(3\_:_./ _)" 30) + "_prod_ascii" :: "[idt, t, t] \ t" ("(3II _:_./ _)" 30) -text "The translations below bind the variable \x\ in the expressions \B\ and \b\." +text \The translations below bind the variable @{term x} in the expressions @{term B} and @{term b}.\ translations "\x:A. B" \ "CONST Prod A (\x. B)" - "PROD x:A. B" \ "CONST Prod A (\x. B)" + "II x:A. B" \ "CONST Prod A (\x. B)" -text "Nondependent functions are a special case." +text \Non-dependent functions are a special case.\ -abbreviation Function :: "[t, t] \ t" (infixr "\" 40) +abbreviation Fun :: "[t, t] \ t" (infixr "\" 40) where "A \ B \ \_: A. B" +axiomatization where +\ \Type rules\ -section \Type rules\ + Prod_form: "\A: U i; B: A \ U i\ \ \x:A. B x: U i" and -axiomatization where - Prod_form: "\A: U i; B: A \ U i\ \ \x:A. B x: U i" -and - Prod_intro: "\\x. x: A \ b x: B x; A: U i\ \ \<^bold>\x. b x: \x:A. B x" -and - Prod_elim: "\f: \x:A. B x; a: A\ \ f`a: B a" -and - Prod_appl: "\\x. x: A \ b x: B x; a: A\ \ (\<^bold>\x. b x)`a \ b a" -and - Prod_uniq: "f : \x:A. B x \ \<^bold>\x. (f`x) \ f" -and - Prod_eq: "\\x. x: A \ b x \ c x; A: U i\ \ \<^bold>\x. b x \ \<^bold>\x. c x" - -text " - The Pure rules for \\\ only let us judge strict syntactic equality of object lambda expressions; Prod_eq is the actual definitional equality rule. - - 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). -" - -text " - In addition to the usual type rules, it is a meta-theorem that whenever \\x:A. B x: U i\ is derivable from some set of premises \, then so are \A: U i\ and \B: A \ U i\. - - That is to say, the following inference rules are admissible, and it simplifies proofs greatly to axiomatize them directly. -" + Prod_intro: "\\x. x: A \ b x: B x; A: U i\ \ \<^bold>\x. b x: \x:A. B x" and -axiomatization where - Prod_wellform1: "(\x:A. B x: U i) \ A: U i" -and - Prod_wellform2: "(\x:A. B x: U i) \ B: A \ U i" + Prod_elim: "\f: \x:A. B x; a: A\ \ f`a: B a" and + + Prod_comp: "\\x. x: A \ b x: B x; a: A\ \ (\<^bold>\x. b x)`a \ b a" and + + Prod_uniq: "f: \x:A. B x \ \<^bold>\x. f`x \ f" and +\ \Congruence rules\ -text "Rule attribute declarations---set up various methods to use the type rules." + Prod_form_eq: "\A: U i; B: A \ U i; C: A \ U i; \x. x: A \ B x \ C x\ \ \x:A. B x \ \x:A. C x" and + + Prod_intro_eq: "\\x. x: A \ b x \ c x; A: U i\ \ \<^bold>\x. b x \ \<^bold>\x. c x" + +text \ +The Pure rules for \\\ only let us judge strict syntactic equality of object lambda expressions. +The actual definitional equality rule is @{thm Prod_intro_eq}. +Note that this is a separate rule from function extensionality. + +Note that the bold lambda symbol \\<^bold>\\ used for dependent functions clashes with the proof term syntax (cf. \
2.5.2 of the Isabelle/Isar Implementation). +\ -lemmas Prod_comp [comp] = Prod_appl Prod_uniq -lemmas Prod_wellform [wellform] = Prod_wellform1 Prod_wellform2 lemmas Prod_routine [intro] = Prod_form Prod_intro Prod_elim +lemmas Prod_comps [comp] = Prod_comp Prod_uniq -section \Function composition\ +section \Additional definitions\ definition compose :: "[t, t] \ t" (infixr "o" 110) where "g o f \ \<^bold>\x. g`(f`x)" - -syntax "_COMPOSE" :: "[t, t] \ t" (infixr "\" 110) +syntax "_compose" :: "[t, t] \ t" (infixr "\" 110) translations "g \ f" \ "g o f" +declare compose_def [comp] + +lemma compose_assoc: + assumes "A: U i" and "f: A \ B" "g: B \ C" "h: \x:C. D x" + shows "(h \ g) \ f \ h \ (g \ f)" +by (derive lems: assms Prod_intro_eq) -section \Polymorphic identity function\ +lemma compose_comp: + assumes "A: U i" and "\x. x: A \ b x: B" and "\x. x: B \ c x: C x" + shows "(\<^bold>\x. c x) \ (\<^bold>\x. b x) \ \<^bold>\x. c (b x)" +by (derive lems: assms Prod_intro_eq) -abbreviation id :: t where "id \ \<^bold>\x. x" +abbreviation id :: t where "id \ \<^bold>\x. x" \ \Polymorphic identity function\ end diff --git a/ProdProps.thy b/ProdProps.thy deleted file mode 100644 index a68f79b..0000000 --- a/ProdProps.thy +++ /dev/null @@ -1,57 +0,0 @@ -(* Title: HoTT/ProdProps.thy - Author: Josh Chen - -Properties of the dependent product -*) - -theory ProdProps - imports - HoTT_Methods - Prod -begin - - -section \Composition\ - -text " - The proof of associativity needs some guidance; it involves telling Isabelle to use the correct rule for \-type definitional equality, and the correct substitutions in the subgoals thereafter. -" - -lemma compose_assoc: - assumes "A: U i" and "f: A \ B" "g: B \ C" "h: \x:C. D x" - shows "(h \ g) \ f \ h \ (g \ f)" -proof (subst (0 1 2 3) compose_def) - show "\<^bold>\x. (\<^bold>\y. h`(g`y))`(f`x) \ \<^bold>\x. h`((\<^bold>\y. g`(f`y))`x)" - proof (subst Prod_eq) - \ \Todo: set the Simplifier (or other simplification methods) up to use \Prod_eq\!\ - - show "\x. x: A \ (\<^bold>\y. h`(g`y))`(f`x) \ h`((\<^bold>\y. g`(f`y))`x)" - proof compute - show "\x. x: A \ h`(g`(f`x)) \ h`((\<^bold>\y. g`(f`y))`x)" - proof compute - show "\x. x: A \ g`(f`x): C" by (routine lems: assms) - qed - show "\x. x: B \ h`(g`x): D (g`x)" by (routine lems: assms) - qed (routine lems: assms) - qed fact -qed - - -lemma compose_comp: - assumes "A: U i" and "\x. x: A \ b x: B" and "\x. x: B \ c x: C x" - shows "(\<^bold>\x. c x) \ (\<^bold>\x. b x) \ \<^bold>\x. c (b x)" -proof (subst compose_def, subst Prod_eq) - show "\a. a: A \ (\<^bold>\x. c x)`((\<^bold>\x. b x)`a) \ (\<^bold>\x. c (b x))`a" - proof compute - show "\a. a: A \ c ((\<^bold>\x. b x)`a) \ (\<^bold>\x. c (b x))`a" - by (derive lems: assms) - qed (routine lems: assms) -qed (derive lems: assms) - - -text "Set up the \compute\ method to automatically simplify function compositions." - -lemmas compose_comp [comp] - - -end -- cgit v1.2.3