# HG changeset patch # User paulson # Date 1666869831 -3600 # Node ID 2931d8331cc587240a9ef8aab5e2e0f87a222676 # Parent 2510e6f7b11cc49b31a4e622773d7c33f232a1b0 Beautification of some declarations diff -r 2510e6f7b11c -r 2931d8331cc5 src/CTT/CTT.thy --- a/src/CTT/CTT.thy Wed Oct 26 18:08:44 2022 +0100 +++ b/src/CTT/CTT.thy Thu Oct 27 12:23:51 2022 +0100 @@ -17,47 +17,43 @@ typedecl o consts - \ \Types\ + \ \Judgments\ + Type :: "t \ prop" ("(_ type)" [10] 5) + Eqtype :: "[t,t]\prop" ("(_ =/ _)" [10,10] 5) + Elem :: "[i, t]\prop" ("(_ /: _)" [10,10] 5) + Eqelem :: "[i,i,t]\prop" ("(_ =/ _ :/ _)" [10,10,10] 5) + Reduce :: "[i,i]\prop" ("Reduce[_,_]") + \ \Types for truth values\ F :: "t" T :: "t" \ \\F\ is empty, \T\ contains one element\ contr :: "i\i" tt :: "i" \ \Natural numbers\ N :: "t" + Zero :: "i" ("0") succ :: "i\i" rec :: "[i, i, [i,i]\i] \ i" - \ \Unions\ + \ \Binary sum\ + Plus :: "[t,t]\t" (infixr "+" 40) inl :: "i\i" inr :: "i\i" "when" :: "[i, i\i, i\i]\i" - \ \General Sum and Binary Product\ + \ \General sum and binary product\ Sum :: "[t, i\t]\t" + pair :: "[i,i]\i" ("(1<_,/_>)") fst :: "i\i" snd :: "i\i" split :: "[i, [i,i]\i] \i" - \ \General Product and Function Space\ + \ \General product and function space\ Prod :: "[t, i\t]\t" - \ \Types\ - Plus :: "[t,t]\t" (infixr "+" 40) + lambda :: "(i \ i) \ i" (binder "\<^bold>\" 10) + app :: "[i,i]\i" (infixl "`" 60) \ \Equality type\ Eq :: "[t,i,i]\t" eq :: "i" - \ \Judgements\ - Type :: "t \ prop" ("(_ type)" [10] 5) - Eqtype :: "[t,t]\prop" ("(_ =/ _)" [10,10] 5) - Elem :: "[i, t]\prop" ("(_ /: _)" [10,10] 5) - Eqelem :: "[i,i,t]\prop" ("(_ =/ _ :/ _)" [10,10,10] 5) - Reduce :: "[i,i]\prop" ("Reduce[_,_]") - \ \Types\ - - \ \Functions\ - lambda :: "(i \ i) \ i" (binder "\<^bold>\" 10) - app :: "[i,i]\i" (infixl "`" 60) - \ \Natural numbers\ - Zero :: "i" ("0") - \ \Pairing\ - pair :: "[i,i]\i" ("(1<_,/_>)") +text \Some inexplicable syntactic dependencies; in particular, "0" + must be introduced after the judgment forms.\ syntax "_PROD" :: "[idt,t,t]\t" ("(3\_:_./ _)" 10) @@ -78,7 +74,7 @@ that \a\ and \b\ are textually identical. Does not verify \a:A\! Sound because only \trans_red\ uses a \Reduce\ - premise. No new theorems can be proved about the standard judgements. + premise. No new theorems can be proved about the standard judgments. \ axiomatization where @@ -275,7 +271,7 @@ text \OMITTED: \eqC\ are \TC\ because they make rewriting loop: \p = un = un = \\\ lemmas comp_rls = NC0 NC_succ ProdC SumC PlusC_inl PlusC_inr -text \Rules with conclusion \a:A\, an elem judgement.\ +text \Rules with conclusion \a:A\, an elem judgment.\ lemmas element_rls = intr_rls elim_rls text \Definitions are (meta)equality axioms.\ @@ -398,7 +394,7 @@ (** Tactics that instantiate CTT-rules. Vars in the given terms will be incremented! - The (rtac EqE i) lets them apply to equality judgements. **) + The (rtac EqE i) lets them apply to equality judgments. **) fun NE_tac ctxt sp i = TRY (resolve_tac ctxt @{thms EqE} i) THEN @@ -463,7 +459,7 @@ subsection \The elimination rules for fst/snd\ lemma SumE_fst: "p : Sum(A,B) \ fst(p) : A" - apply (unfold basic_defs) + unfolding basic_defs apply (erule SumE) apply assumption done @@ -474,7 +470,7 @@ and "A type" and "\x. x:A \ B(x) type" shows "snd(p) : B(fst(p))" - apply (unfold basic_defs) + unfolding basic_defs apply (rule major [THEN SumE]) apply (rule SumC [THEN subst_eqtyparg, THEN replace_type]) apply (typechk assms) @@ -631,9 +627,7 @@ lemma diff_0_eq_0: "b:N \ 0 - b = 0 : N" unfolding arith_defs - apply (NE b) - apply hyp_rew - done + by (NE b) hyp_rew text \ Essential to simplify FIRST!! (Else we get a critical pair) @@ -692,9 +686,7 @@ text \Associative law for addition.\ lemma add_assoc: "\a:N; b:N; c:N\ \ (a #+ b) #+ c = a #+ (b #+ c) : N" - apply (NE a) - apply hyp_arith_rew - done + by (NE a) hyp_arith_rew text \Commutative law for addition. Can be proved using three inductions. Must simplify after first induction! Orientation of rewrites is delicate.\ @@ -821,9 +813,7 @@ text \Note how easy using commutative laws can be? ...not always...\ lemma absdiff_commute: "\a:N; b:N\ \ a |-| b = b |-| a : N" unfolding absdiff_def - apply (rule add_commute) - apply (typechk diff_typing) - done + by (rule add_commute) (typechk diff_typing) text \If \a + b = 0\ then \a = 0\. Surprisingly tedious.\ schematic_goal add_eq0_lemma: "\a:N; b:N\ \ ?c : Eq(N,a#+b,0) \ Eq(N,a,0)" @@ -850,7 +840,7 @@ text \Here is a lemma to infer \a - b = 0\ and \b - a = 0\ from \a |-| b = 0\, below.\ schematic_goal absdiff_eq0_lem: "\a:N; b:N; a |-| b = 0 : N\ \ ?a : Eq(N, a-b, 0) \ Eq(N, b-a, 0)" - apply (unfold absdiff_def) + unfolding absdiff_def apply intr apply eqintr apply (rule_tac [2] add_eq0)