From 0dfe6d34967faaf366ed4ac7b5718b64b7f5a721 Mon Sep 17 00:00:00 2001 From: Josh Chen Date: Sat, 30 Jun 2018 07:07:19 +0200 Subject: Finished proofs of projections --- Prod.thy | 2 +- Proj.thy | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++-------------- 2 files changed, 77 insertions(+), 21 deletions(-) diff --git a/Prod.thy b/Prod.thy index 7facc27..5f0d272 100644 --- a/Prod.thy +++ b/Prod.thy @@ -64,7 +64,7 @@ lemmas Prod_form_conds [elim] = Prod_form_cond1 Prod_form_cond2 text "Nondependent functions are a special case." abbreviation Function :: "[Term, Term] \ Term" (infixr "\" 40) - where "A \ B \ \_:A. B" + where "A \ B \ \_:A. B" end \ No newline at end of file diff --git a/Proj.thy b/Proj.thy index 22feecb..c4703d7 100644 --- a/Proj.thy +++ b/Proj.thy @@ -118,8 +118,7 @@ proof fix p assume *: "p : \x:A. B x" have **: "B: A \ U" by (wellformed jdgmt: *) fix x y assume "x : A" and "y : B x" - note ** this - then show "y : B (fst[A,B]`(x,y))" by (rule lemma2) + with ** show "y : B (fst[A,B]`(x,y))" by (rule lemma2) qed qed (wellformed jdgmt: assms) qed (rule assms) @@ -136,16 +135,16 @@ proof - fix p assume *: "p : \x:A. B x" show "indSum[A,B] (\q. B (fst[A,B]`q)) (\x y. y) p : B (fst[A,B]`p)" - proof (standard, elim snd_dep_welltyped) - show "\x y. \x : A; y : B x\ \ y : B (fst[A,B]`(x,y))" using assms - by (elim snd_dep_const_type) + proof (standard, elim lemma1) + fix x y assume "x : A" and "y : B x" + with assms(1) show "y : B (fst[A,B]`(x,y))" by (rule lemma2) qed (rule *) qed also have "indSum[A, B] (\q. B (fst[A,B]`q)) (\x y. y) (a,b) \ b" - proof (standard, elim snd_dep_welltyped) - show "\x y. \x : A; y : B x\ \ y : B (fst[A,B]`(x,y))" using assms - by (elim snd_dep_const_type) + proof (standard, elim lemma1) + fix x y assume "x : A" and "y : B x" + with assms(1) show "y : B (fst[A,B]`(x,y))" by (rule lemma2) qed (rule assms)+ finally show "snd[A,B]`(a,b) \ b" . @@ -154,26 +153,83 @@ qed text "For non-dependent projection functions:" -print_statement fst_dep_type -print_statement fst_dep_type[where ?p = p and ?A = A and ?B = "\_. B"] +lemma fst_nondep_type: + assumes "p : A \ B" + shows "fst[A,B]`p : A" +proof + show "fst[A,B] : A \ B \ A" + proof (unfold fst_nondep_def, standard) + fix q assume *: "q : A \ B" + show "indSum[A, \_. B] (\_. A) (\x y. x) q : A" + proof + show "A : U" by (wellformed jdgmt: assms) + qed (assumption, rule *) + qed (wellformed jdgmt: assms) +qed (rule assms) -lemma fst_nondep_type: "p : A \ B \ fst[A,B]`p : A" -by (rule fst_dep_type[where ?B = "\_. B"]) - lemma fst_nondep_comp: assumes "a : A" and "b : B" shows "fst[A,B]`(a,b) \ a" -proof (unfold fst_nondep_def) - have "A : U" using assms(1) .. - then show "fst[A,B]`(a,b) \ a" unfolding fst_nondep_def + +proof - + have "fst[A,B]`(a,b) \ indSum[A, \_. B] (\_. A) (\x y. x) (a,b)" + proof (unfold fst_nondep_def, standard) + show "(a,b) : A \ B" using assms .. + show "\p. p : A \ B \ indSum[A, \_. B] (\_. A) (\x y. x) p : A" + proof + show "A : U" by (wellformed jdgmt: assms(1)) + qed + qed + + also have "indSum[A, \_. B] (\_. A) (\x y. x) (a,b) \ a" + proof + show "A : U" by (wellformed jdgmt: assms(1)) + qed (assumption, (rule assms)+) + + finally show "fst[A,B]`(a,b) \ a" . qed -lemma snd_nondep_comp: "\a : A; b : B\ \ snd[A,B]`(a,b) \ b" + +lemma snd_nondep_type: + assumes "p : A \ B" + shows "snd[A,B]`p : B" + +proof + show "snd[A,B] : A \ B \ B" + proof (unfold snd_nondep_def, standard) + fix q assume *: "q : A \ B" + show "indSum[A, \_. B] (\_. B) (\x y. y) q : B" + proof + have **: "\_. B: A \ U" by (wellformed jdgmt: assms) + have "fst[A,B]`p : A" using assms by (rule fst_nondep_type) + then show "B : U" by (rule **) + qed (assumption, rule *) + qed (wellformed jdgmt: assms) +qed (rule assms) + + +lemma snd_nondep_comp: + assumes "a : A" and "b : B" + shows "snd[A,B]`(a,b) \ b" proof - - assume "a : A" and "b : B" - then have "(a, b) : A \ B" .. - then show "snd[A,B]`(a,b) \ b" unfolding snd_nondep_def by simp + have "snd[A,B]`(a,b) \ indSum[A, \_. B] (\_. B) (\x y. y) (a,b)" + proof (unfold snd_nondep_def, standard) + show "(a,b) : A \ B" using assms .. + show "\p. p : A \ B \ indSum[A, \_. B] (\_. B) (\x y. y) p : B" + proof + show "B : U" by (wellformed jdgmt: assms(2)) + qed + qed + + also have "indSum[A, \_. B] (\_. B) (\x y. y) (a,b) \ b" + proof + show "B : U" by (wellformed jdgmt: assms(2)) + qed (assumption, (rule assms)+) + + finally show "snd[A,B]`(a,b) \ b" . qed + +end \ No newline at end of file -- cgit v1.2.3