(* 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