(******** Isabelle/HoTT: Projections Feb 2019 Projection functions for the dependent sum type. ********) theory Projections imports HoTT_Methods Prod Sum begin definition fst :: "[t, t] \ t" where "fst A p \ indSum (\_. A) (\x y. x) p" lemma fst_type: assumes "A: U i" and "p: \x: A. B x" shows "fst A p: A" unfolding fst_def by (derive lems: assms) declare fst_type [intro] lemma fst_cmp: assumes "A: U i" and "B: A \ U i" and "a: A" and "b: B a" shows "fst A \ a" unfolding fst_def by (subst comp) (derive lems: assms) declare fst_cmp [comp] definition snd :: "[t, t \ t, t] \ t" where "snd A B p \ indSum (\p. B (fst A p)) (\x y. y) p" lemma snd_type: assumes "A: U i" and "B: A \ U i" and "p: \x: A. B x" shows "snd A B p: B (fst A p)" unfolding snd_def proof (routine add: assms) fix x y assume "x: A" and "y: B x" with assms have [comp]: "fst A \ x" by derive note \y: B x\ then show "y: B (fst A )" by compute qed lemma snd_cmp: assumes "A: U i" and "B: A \ U i" and "a: A" and "b: B a" shows "snd A B \ b" unfolding snd_def by (derive lems: assms) lemmas Proj_type [intro] = fst_type snd_type lemmas Proj_comp [comp] = fst_cmp snd_cmp end