From f4f468878fc0459a806b02cdf8921af6fcac2759 Mon Sep 17 00:00:00 2001 From: Josh Chen Date: Wed, 15 Aug 2018 11:47:30 +0200 Subject: Tweak proof methods, some type rules; add HoTT Book examples --- ex/HoTT Book/Ch1.thy | 37 +++++++++++++++++++++++++++++++++++++ ex/Methods.thy | 4 ++-- ex/Synthesis.thy | 10 +++++----- 3 files changed, 44 insertions(+), 7 deletions(-) create mode 100644 ex/HoTT Book/Ch1.thy (limited to 'ex') diff --git a/ex/HoTT Book/Ch1.thy b/ex/HoTT Book/Ch1.thy new file mode 100644 index 0000000..84a5cf4 --- /dev/null +++ b/ex/HoTT Book/Ch1.thy @@ -0,0 +1,37 @@ +theory Ch1 + imports "../../HoTT" +begin + +chapter \HoTT Book, Chapter 1\ + +section \1.6 Dependent pair types (\-types)\ + +text "Prove that the only inhabitants of the \-type are those given by the pair constructor." + +schematic_goal + assumes "(\x:A. B(x)): U(i)" and "p: \x:A. B(x)" + shows "?a: p =[\x:A. B(x)] " + +text "Proof by induction on \p: \x:A. B(x)\:" + +proof (rule Sum_elim[where ?p=p]) + text "We just need to prove the base case; the rest will be taken care of automatically." + + fix x y assume asm: "x: A" "y: B(x)" show + "refl(): =[\x:A. B(x)] , snd >" + proof (subst (0 1) comp) + text " + The computation rules for \fst\ and \snd\ require that \x\ and \y\ have appropriate types. + The automatic proof methods have trouble picking the appropriate types, so we state them explicitly, + " + show "x: A" and "y: B(x)" by (fact asm)+ + + text "...twice, once each for the substitutions of \fst\ and \snd\." + show "x: A" and "y: B(x)" by (fact asm)+ + + qed (derive lems: assms asm) + +qed (derive lems: assms) + + +end \ No newline at end of file diff --git a/ex/Methods.thy b/ex/Methods.thy index b0c5f92..699d620 100644 --- a/ex/Methods.thy +++ b/ex/Methods.thy @@ -13,7 +13,7 @@ begin lemma assumes "A : U(i)" "B: A \ U(i)" "\x. x : A \ C x: B x \ U(i)" shows "\x:A. \y:B x. \z:C x y. \w:A. x =\<^sub>A w : U(i)" -by (simple lem: assms) +by (simple lems: assms) lemma @@ -29,7 +29,7 @@ proof - "B: A \ U(i)" and "\x. x : A \ C x: B x \ U(i)" and "\x y. \x : A; y : B x\ \ D x y: C x y \ U(i)" - by (derive lem: assms) + by (derive lems: assms) qed diff --git a/ex/Synthesis.thy b/ex/Synthesis.thy index 60655e5..48d762c 100644 --- a/ex/Synthesis.thy +++ b/ex/Synthesis.thy @@ -33,10 +33,10 @@ text " " schematic_goal "?p`0 \ 0" and "\n. n: \ \ (?p`(succ n)) \ n" -apply (subst comp, rule Nat_rules) -prefer 3 apply (subst comp, rule Nat_rules) +apply (subst comp) +prefer 4 apply (subst comp) prefer 3 apply (rule Nat_rules) -prefer 8 apply (rule Nat_rules | assumption)+ +apply (rule Nat_rules | assumption)+ done text " @@ -49,7 +49,7 @@ definition pred :: Term where "pred \ \<^bold>\n. ind\<^sub>\ \ \" unfolding pred_def by simple lemma pred_props: "\n. refl(n)>: ((pred`0) =\<^sub>\ 0) \ (\n:\. (pred`(succ n)) =\<^sub>\ n)" -proof (simple lem: pred_type) +proof (simple lems: pred_type) have *: "pred`0 \ 0" unfolding pred_def proof (subst comp) show "\n. n: \ \ ind\<^sub>\ (\a b. a) n n: \" by simple @@ -75,7 +75,7 @@ qed theorem "\n. refl(n)>>: \pred:\\\ . ((pred`0) =\<^sub>\ 0) \ (\n:\. (pred`(succ n)) =\<^sub>\ n)" -by (simple lem: pred_welltyped pred_type pred_props) +by (simple lems: pred_welltyped pred_type pred_props) end \ No newline at end of file -- cgit v1.2.3