From 593faab277de53cbe2cb0c2feca5de307d9334ac Mon Sep 17 00:00:00 2001 From: Josh Chen Date: Sat, 9 Jun 2018 00:11:39 +0200 Subject: Reorganize code --- Sum.thy | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 Sum.thy (limited to 'Sum.thy') diff --git a/Sum.thy b/Sum.thy new file mode 100644 index 0000000..e34749a --- /dev/null +++ b/Sum.thy @@ -0,0 +1,78 @@ +(* Title: HoTT/Sum.thy + Author: Josh Chen + +Dependent sum type. +*) + +theory Sum + imports HoTT_Base Prod + +begin + +axiomatization + Sum :: "[Term, Term \ Term] \ Term" and + pair :: "[Term, Term] \ Term" ("(1'(_,/ _'))") and + indSum :: "(Term \ Term) \ Term" + +syntax + "_SUM" :: "[idt, Term, Term] \ Term" ("(3\_:_./ _)" 20) + "_SUM_ASCII" :: "[idt, Term, Term] \ Term" ("(3SUM _:_./ _)" 20) + +translations + "\x:A. B" \ "CONST Sum A (\x. B)" + "SUM x:A. B" \ "CONST Sum A (\x. B)" + +axiomatization where + Sum_form [intro]: "\A B. \A : U; B: A \ U\ \ \x:A. B(x) : U" +and + Sum_intro [intro]: "\A B a b. \a : A; b : B(a)\ \ (a, b) : \x:A. B(x)" +and + Sum_elim [elim]: "\A B C f p. + \ C: \x:A. B(x) \ U; + f : \x:A. \y:B(x). C((x,y)); + p : \x:A. B(x) \ \ indSum(C)`f`p : C(p)" +and + Sum_comp [simp]: "\(C::Term \ Term) (f::Term) (a::Term) (b::Term). indSum(C)`f`(a,b) \ f`a`b" + +text "We choose to formulate the elimination rule by using the object-level function type and function application as much as possible. +Hence only the type family \C\ is left as a meta-level argument to the inductor indSum." + +\ \Nondependent pair\ +abbreviation Pair :: "[Term, Term] \ Term" (infixr "\" 50) + where "A\B \ \_:A. B" + +subsubsection \Projections\ + +consts + fst :: "[Term, 'a] \ Term" ("(1fst[/_,/ _])") + snd :: "[Term, 'a] \ Term" ("(1snd[/_,/ _])") + +overloading + fst_dep \ fst + snd_dep \ snd + fst_nondep \ fst + snd_nondep \ snd +begin + definition fst_dep :: "[Term, Term \ Term] \ Term" where + "fst_dep A B \ indSum(\_. A)`(\<^bold>\x:A. \<^bold>\y:B(x). x)" + + definition snd_dep :: "[Term, Term \ Term] \ Term" where + "snd_dep A B \ indSum(\_. A)`(\<^bold>\x:A. \<^bold>\y:B(x). y)" + + definition fst_nondep :: "[Term, Term] \ Term" where + "fst_nondep A B \ indSum(\_. A)`(\<^bold>\x:A. \<^bold>\y:B. x)" + + definition snd_nondep :: "[Term, Term] \ Term" where + "snd_nondep A B \ indSum(\_. A)`(\<^bold>\x:A. \<^bold>\y:B. y)" +end + +text "Simplification rules for the projections:" + +lemma fst_dep_comp: "\a : A; b : B(a)\ \ fst[A,B]`(a,b) \ a" unfolding fst_dep_def by simp +lemma snd_dep_comp: "\a : A; b : B(a)\ \ snd[A,B]`(a,b) \ b" unfolding snd_dep_def by simp + +lemma fst_nondep_comp: "\a : A; b : B\ \ fst[A,B]`(a,b) \ a" unfolding fst_nondep_def by simp +lemma snd_nondep_comp: "\a : A; b : B\ \ snd[A,B]`(a,b) \ b" unfolding snd_nondep_def by simp + +lemmas fst_snd_simps [simp] = fst_dep_comp snd_dep_comp fst_nondep_comp snd_nondep_comp +end \ No newline at end of file -- cgit v1.2.3