# HG changeset patch # User wenzelm # Date 1444506187 -7200 # Node ID 2332d9be352b0c33abce4959dde3ab5ac835ea8f # Parent a705f42b244d6ac4c4fc371ff364dea3098e09d6 tuned syntax -- more symbols; diff -r a705f42b244d -r 2332d9be352b src/CTT/Arith.thy --- a/src/CTT/Arith.thy Sat Oct 10 21:14:00 2015 +0200 +++ b/src/CTT/Arith.thy Sat Oct 10 21:43:07 2015 +0200 @@ -13,31 +13,27 @@ definition add :: "[i,i]\i" (infixr "#+" 65) where - "a#+b == rec(a, b, \u v. succ(v))" + "a#+b \ rec(a, b, \u v. succ(v))" definition diff :: "[i,i]\i" (infixr "-" 65) where - "a-b == rec(b, a, \u v. rec(v, 0, \x y. x))" + "a-b \ rec(b, a, \u v. rec(v, 0, \x y. x))" definition absdiff :: "[i,i]\i" (infixr "|-|" 65) where - "a|-|b == (a-b) #+ (b-a)" + "a|-|b \ (a-b) #+ (b-a)" definition mult :: "[i,i]\i" (infixr "#*" 70) where - "a#*b == rec(a, 0, \u v. b #+ v)" + "a#*b \ rec(a, 0, \u v. b #+ v)" definition mod :: "[i,i]\i" (infixr "mod" 70) where - "a mod b == rec(a, 0, %u v. rec(succ(v) |-| b, 0, %x y. succ(v)))" + "a mod b \ rec(a, 0, \u v. rec(succ(v) |-| b, 0, \x y. succ(v)))" definition div :: "[i,i]\i" (infixr "div" 70) where - "a div b == rec(a, 0, \u v. rec(succ(u) mod b, succ(v), \x y. v))" - - -notation (xsymbols) - mult (infixr "#\" 70) + "a div b \ rec(a, 0, \u v. rec(succ(u) mod b, succ(v), \x y. v))" lemmas arith_defs = add_def diff_def absdiff_def mult_def mod_def div_def @@ -264,12 +260,12 @@ An example of induction over a quantified formula (a product). Uses rewriting with a quantified, implicative inductive hypothesis.*) schematic_goal add_diff_inverse_lemma: - "b:N \ ?a : PROD x:N. Eq(N, b-x, 0) --> Eq(N, b #+ (x-b), x)" + "b:N \ ?a : \x:N. Eq(N, b-x, 0) \ Eq(N, b #+ (x-b), x)" apply (NE b) (*strip one "universal quantifier" but not the "implication"*) apply (rule_tac [3] intr_rls) (*case analysis on x in - (succ(u) <= x) --> (succ(u)#+(x-succ(u)) = x) *) + (succ(u) <= x) \ (succ(u)#+(x-succ(u)) = x) *) prefer 4 apply (NE x) apply assumption @@ -334,7 +330,7 @@ done (*If a+b=0 then a=0. Surprisingly tedious*) -schematic_goal add_eq0_lemma: "\a:N; b:N\ \ ?c : PROD u: Eq(N,a#+b,0) . Eq(N,a,0)" +schematic_goal add_eq0_lemma: "\a:N; b:N\ \ ?c : \u: Eq(N,a#+b,0) . Eq(N,a,0)" apply (NE a) apply (rule_tac [3] replace_type) apply arith_rew @@ -355,7 +351,7 @@ (*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 : SUM v: Eq(N, a-b, 0) . Eq(N, b-a, 0)" + "\a:N; b:N; a |-| b = 0 : N\ \ ?a : \v: Eq(N, a-b, 0) . Eq(N, b-a, 0)" apply (unfold absdiff_def) apply intr apply eqintr @@ -446,7 +442,7 @@ (*for case analysis on whether a number is 0 or a successor*) lemma iszero_decidable: "a:N \ rec(a, inl(eq), \ka kb. inr()) : - Eq(N,a,0) + (SUM x:N. Eq(N,a, succ(x)))" + Eq(N,a,0) + (\x:N. Eq(N,a, succ(x)))" apply (NE a) apply (rule_tac [3] PlusI_inr) apply (rule_tac [2] PlusI_inl) diff -r a705f42b244d -r 2332d9be352b src/CTT/Bool.thy --- a/src/CTT/Bool.thy Sat Oct 10 21:14:00 2015 +0200 +++ b/src/CTT/Bool.thy Sat Oct 10 21:43:07 2015 +0200 @@ -11,19 +11,19 @@ definition Bool :: "t" where - "Bool == T+T" + "Bool \ T+T" definition true :: "i" where - "true == inl(tt)" + "true \ inl(tt)" definition false :: "i" where - "false == inr(tt)" + "false \ inr(tt)" definition cond :: "[i,i,i]\i" where - "cond(a,b,c) == when(a, \u. b, \u. c)" + "cond(a,b,c) \ when(a, \u. b, \u. c)" lemmas bool_defs = Bool_def true_def false_def cond_def diff -r a705f42b244d -r 2332d9be352b src/CTT/CTT.thy --- a/src/CTT/CTT.thy Sat Oct 10 21:14:00 2015 +0200 +++ b/src/CTT/CTT.thy Sat Oct 10 21:43:07 2015 +0200 @@ -51,7 +51,7 @@ (*Types*) (*Functions*) - lambda :: "(i \ i) \ i" (binder "lam " 10) + lambda :: "(i \ i) \ i" (binder "\<^bold>\" 10) app :: "[i,i]\i" (infixl "`" 60) (*Natural numbers*) Zero :: "i" ("0") @@ -59,29 +59,18 @@ pair :: "[i,i]\i" ("(1<_,/_>)") syntax - "_PROD" :: "[idt,t,t]\t" ("(3PROD _:_./ _)" 10) - "_SUM" :: "[idt,t,t]\t" ("(3SUM _:_./ _)" 10) + "_PROD" :: "[idt,t,t]\t" ("(3\_:_./ _)" 10) + "_SUM" :: "[idt,t,t]\t" ("(3\_:_./ _)" 10) translations - "PROD x:A. B" == "CONST Prod(A, \x. B)" - "SUM x:A. B" == "CONST Sum(A, \x. B)" + "\x:A. B" \ "CONST Prod(A, \x. B)" + "\x:A. B" \ "CONST Sum(A, \x. B)" abbreviation - Arrow :: "[t,t]\t" (infixr "-->" 30) where - "A --> B == PROD _:A. B" + Arrow :: "[t,t]\t" (infixr "\" 30) where + "A \ B \ \_:A. B" abbreviation - Times :: "[t,t]\t" (infixr "*" 50) where - "A * B == SUM _:A. B" - -notation (xsymbols) - lambda (binder "\\" 10) and - Elem ("(_ /\ _)" [10,10] 5) and - Eqelem ("(2_ =/ _ \/ _)" [10,10,10] 5) and - Arrow (infixr "\" 30) and - Times (infixr "\" 50) - -syntax (xsymbols) - "_PROD" :: "[idt,t,t] \ t" ("(3\ _\_./ _)" 10) - "_SUM" :: "[idt,t,t] \ t" ("(3\ _\_./ _)" 10) + Times :: "[t,t]\t" (infixr "\" 50) where + "A \ B \ \_:A. B" (*Reduction: a weaker notion than equality; a hack for simplification. Reduce[a,b] means either that a=b:A for some A or else that "a" and "b" @@ -146,51 +135,51 @@ "\p a b C. \p: N; a: C(0); \u v. \u: N; v: C(u)\ \ b(u,v): C(succ(u))\ \ rec(succ(p), a, \u v. b(u,v)) = b(p, rec(p, a, \u v. b(u,v))) : C(succ(p))" and - (*The fourth Peano axiom. See page 91 of Martin-Lof's book*) + (*The fourth Peano axiom. See page 91 of Martin-Löf's book*) zero_ne_succ: "\a. \a: N; 0 = succ(a) : N\ \ 0: F" and (*The Product of a family of types*) - ProdF: "\A B. \A type; \x. x:A \ B(x) type\ \ PROD x:A. B(x) type" and + ProdF: "\A B. \A type; \x. x:A \ B(x) type\ \ \x:A. B(x) type" and ProdFL: - "\A B C D. \A = C; \x. x:A \ B(x) = D(x)\ \ PROD x:A. B(x) = PROD x:C. D(x)" and + "\A B C D. \A = C; \x. x:A \ B(x) = D(x)\ \ \x:A. B(x) = \x:C. D(x)" and ProdI: - "\b A B. \A type; \x. x:A \ b(x):B(x)\ \ lam x. b(x) : PROD x:A. B(x)" and + "\b A B. \A type; \x. x:A \ b(x):B(x)\ \ \<^bold>\x. b(x) : \x:A. B(x)" and ProdIL: "\b c A B. \A type; \x. x:A \ b(x) = c(x) : B(x)\ \ - lam x. b(x) = lam x. c(x) : PROD x:A. B(x)" and + \<^bold>\x. b(x) = \<^bold>\x. c(x) : \x:A. B(x)" and - ProdE: "\p a A B. \p : PROD x:A. B(x); a : A\ \ p`a : B(a)" and - ProdEL: "\p q a b A B. \p = q: PROD x:A. B(x); a = b : A\ \ p`a = q`b : B(a)" and + ProdE: "\p a A B. \p : \x:A. B(x); a : A\ \ p`a : B(a)" and + ProdEL: "\p q a b A B. \p = q: \x:A. B(x); a = b : A\ \ p`a = q`b : B(a)" and - ProdC: "\a b A B. \a : A; \x. x:A \ b(x) : B(x)\ \ (lam x. b(x)) ` a = b(a) : B(a)" and + ProdC: "\a b A B. \a : A; \x. x:A \ b(x) : B(x)\ \ (\<^bold>\x. b(x)) ` a = b(a) : B(a)" and - ProdC2: "\p A B. p : PROD x:A. B(x) \ (lam x. p`x) = p : PROD x:A. B(x)" and + ProdC2: "\p A B. p : \x:A. B(x) \ (\<^bold>\x. p`x) = p : \x:A. B(x)" and (*The Sum of a family of types*) - SumF: "\A B. \A type; \x. x:A \ B(x) type\ \ SUM x:A. B(x) type" and - SumFL: "\A B C D. \A = C; \x. x:A \ B(x) = D(x)\ \ SUM x:A. B(x) = SUM x:C. D(x)" and + SumF: "\A B. \A type; \x. x:A \ B(x) type\ \ \x:A. B(x) type" and + SumFL: "\A B C D. \A = C; \x. x:A \ B(x) = D(x)\ \ \x:A. B(x) = \x:C. D(x)" and - SumI: "\a b A B. \a : A; b : B(a)\ \ : SUM x:A. B(x)" and - SumIL: "\a b c d A B. \ a = c : A; b = d : B(a)\ \ = : SUM x:A. B(x)" and + SumI: "\a b A B. \a : A; b : B(a)\ \ : \x:A. B(x)" and + SumIL: "\a b c d A B. \ a = c : A; b = d : B(a)\ \ = : \x:A. B(x)" and - SumE: "\p c A B C. \p: SUM x:A. B(x); \x y. \x:A; y:B(x)\ \ c(x,y): C()\ + SumE: "\p c A B C. \p: \x:A. B(x); \x y. \x:A; y:B(x)\ \ c(x,y): C()\ \ split(p, \x y. c(x,y)) : C(p)" and - SumEL: "\p q c d A B C. \p = q : SUM x:A. B(x); + SumEL: "\p q c d A B C. \p = q : \x:A. B(x); \x y. \x:A; y:B(x)\ \ c(x,y)=d(x,y): C()\ \ split(p, \x y. c(x,y)) = split(q, \x y. d(x,y)) : C(p)" and SumC: "\a b c A B C. \a: A; b: B(a); \x y. \x:A; y:B(x)\ \ c(x,y): C()\ \ split(, \x y. c(x,y)) = c(a,b) : C()" and - fst_def: "\a. fst(a) == split(a, \x y. x)" and - snd_def: "\a. snd(a) == split(a, \x y. y)" and + fst_def: "\a. fst(a) \ split(a, \x y. x)" and + snd_def: "\a. snd(a) \ split(a, \x y. y)" and (*The sum of two types*) @@ -245,7 +234,7 @@ FEL: "\p q C. \p = q : F; C type\ \ contr(p) = contr(q) : C" and (*The type T - Martin-Lof's book (page 68) discusses elimination and computation. + Martin-Löf's book (page 68) discusses elimination and computation. Elimination can be derived by computation and equality of types, but with an extra premise C(x) type x:T. Also computation can be derived from elimination. *) @@ -428,7 +417,7 @@ fun add_mp_tac ctxt i = resolve_tac ctxt @{thms subst_prodE} i THEN assume_tac ctxt i THEN assume_tac ctxt i -(*Finds P-->Q and P in the assumptions, replaces implication by Q *) +(*Finds P\Q and P in the assumptions, replaces implication by Q *) fun mp_tac ctxt i = eresolve_tac ctxt @{thms subst_prodE} i THEN assume_tac ctxt i (*"safe" when regarded as predicate calculus rules*) diff -r a705f42b244d -r 2332d9be352b src/CTT/ex/Elimination.thy --- a/src/CTT/ex/Elimination.thy Sat Oct 10 21:14:00 2015 +0200 +++ b/src/CTT/ex/Elimination.thy Sat Oct 10 21:43:07 2015 +0200 @@ -14,36 +14,36 @@ text "This finds the functions fst and snd!" -schematic_goal [folded basic_defs]: "A type \ ?a : (A*A) --> A" +schematic_goal [folded basic_defs]: "A type \ ?a : (A \ A) \ A" apply pc done -schematic_goal [folded basic_defs]: "A type \ ?a : (A*A) --> A" +schematic_goal [folded basic_defs]: "A type \ ?a : (A \ A) \ A" apply pc back done text "Double negation of the Excluded Middle" -schematic_goal "A type \ ?a : ((A + (A-->F)) --> F) --> F" +schematic_goal "A type \ ?a : ((A + (A\F)) \ F) \ F" apply intr apply (rule ProdE) apply assumption apply pc done -schematic_goal "\A type; B type\ \ ?a : (A*B) \ (B*A)" +schematic_goal "\A type; B type\ \ ?a : (A \ B) \ (B \ A)" apply pc done (*The sequent version (ITT) could produce an interesting alternative by backtracking. No longer.*) text "Binary sums and products" -schematic_goal "\A type; B type; C type\ \ ?a : (A+B --> C) --> (A-->C) * (B-->C)" +schematic_goal "\A type; B type; C type\ \ ?a : (A + B \ C) \ (A \ C) \ (B \ C)" apply pc done (*A distributive law*) -schematic_goal "\A type; B type; C type\ \ ?a : A * (B+C) --> (A*B + A*C)" +schematic_goal "\A type; B type; C type\ \ ?a : A \ (B + C) \ (A \ B + A \ C)" apply pc done @@ -52,12 +52,12 @@ assumes "A type" and "\x. x:A \ B(x) type" and "\x. x:A \ C(x) type" - shows "?a : (SUM x:A. B(x) + C(x)) --> (SUM x:A. B(x)) + (SUM x:A. C(x))" + shows "?a : (\x:A. B(x) + C(x)) \ (\x:A. B(x)) + (\x:A. C(x))" apply (pc assms) done text "Construction of the currying functional" -schematic_goal "\A type; B type; C type\ \ ?a : (A*B --> C) --> (A--> (B-->C))" +schematic_goal "\A type; B type; C type\ \ ?a : (A \ B \ C) \ (A \ (B \ C))" apply pc done @@ -65,14 +65,14 @@ schematic_goal assumes "A type" and "\x. x:A \ B(x) type" - and "\z. z: (SUM x:A. B(x)) \ C(z) type" - shows "?a : PROD f: (PROD z : (SUM x:A . B(x)) . C(z)). - (PROD x:A . PROD y:B(x) . C())" + and "\z. z: (\x:A. B(x)) \ C(z) type" + shows "?a : \f: (\z : (\x:A . B(x)) . C(z)). + (\x:A . \y:B(x) . C())" apply (pc assms) done -text "Martin-Lof (1984), page 48: axiom of sum-elimination (uncurry)" -schematic_goal "\A type; B type; C type\ \ ?a : (A --> (B-->C)) --> (A*B --> C)" +text "Martin-Löf (1984), page 48: axiom of sum-elimination (uncurry)" +schematic_goal "\A type; B type; C type\ \ ?a : (A \ (B \ C)) \ (A \ B \ C)" apply pc done @@ -80,14 +80,14 @@ schematic_goal assumes "A type" and "\x. x:A \ B(x) type" - and "\z. z: (SUM x:A . B(x)) \ C(z) type" - shows "?a : (PROD x:A . PROD y:B(x) . C()) - --> (PROD z : (SUM x:A . B(x)) . C(z))" + and "\z. z: (\x:A . B(x)) \ C(z) type" + shows "?a : (\x:A . \y:B(x) . C()) + \ (\z : (\x:A . B(x)) . C(z))" apply (pc assms) done text "Function application" -schematic_goal "\A type; B type\ \ ?a : ((A --> B) * A) --> B" +schematic_goal "\A type; B type\ \ ?a : ((A \ B) \ A) \ B" apply pc done @@ -97,46 +97,46 @@ and "B type" and "\x y. \x:A; y:B\ \ C(x,y) type" shows - "?a : (SUM y:B . PROD x:A . C(x,y)) - --> (PROD x:A . SUM y:B . C(x,y))" + "?a : (\y:B . \x:A . C(x,y)) + \ (\x:A . \y:B . C(x,y))" apply (pc assms) done -text "Martin-Lof (1984) pages 36-7: the combinator S" +text "Martin-Löf (1984) pages 36-7: the combinator S" schematic_goal assumes "A type" and "\x. x:A \ B(x) type" and "\x y. \x:A; y:B(x)\ \ C(x,y) type" - shows "?a : (PROD x:A. PROD y:B(x). C(x,y)) - --> (PROD f: (PROD x:A. B(x)). PROD x:A. C(x, f`x))" + shows "?a : (\x:A. \y:B(x). C(x,y)) + \ (\f: (\x:A. B(x)). \x:A. C(x, f`x))" apply (pc assms) done -text "Martin-Lof (1984) page 58: the axiom of disjunction elimination" +text "Martin-Löf (1984) page 58: the axiom of disjunction elimination" schematic_goal assumes "A type" and "B type" and "\z. z: A+B \ C(z) type" - shows "?a : (PROD x:A. C(inl(x))) --> (PROD y:B. C(inr(y))) - --> (PROD z: A+B. C(z))" + shows "?a : (\x:A. C(inl(x))) \ (\y:B. C(inr(y))) + \ (\z: A+B. C(z))" apply (pc assms) done (*towards AXIOM OF CHOICE*) schematic_goal [folded basic_defs]: - "\A type; B type; C type\ \ ?a : (A --> B*C) --> (A-->B) * (A-->C)" + "\A type; B type; C type\ \ ?a : (A \ B \ C) \ (A \ B) \ (A \ C)" apply pc done -(*Martin-Lof (1984) page 50*) +(*Martin-Löf (1984) page 50*) text "AXIOM OF CHOICE! Delicate use of elimination rules" schematic_goal assumes "A type" and "\x. x:A \ B(x) type" and "\x y. \x:A; y:B(x)\ \ C(x,y) type" - shows "?a : PROD h: (PROD x:A. SUM y:B(x). C(x,y)). - (SUM f: (PROD x:A. B(x)). PROD x:A. C(x, f`x))" + shows "?a : \h: (\x:A. \y:B(x). C(x,y)). + (\f: (\x:A. B(x)). \x:A. C(x, f`x))" apply (intr assms) prefer 2 apply add_mp prefer 2 apply add_mp @@ -153,8 +153,8 @@ assumes "A type" and "\x. x:A \ B(x) type" and "\x y. \x:A; y:B(x)\ \ C(x,y) type" - shows "?a : PROD h: (PROD x:A. SUM y:B(x). C(x,y)). - (SUM f: (PROD x:A. B(x)). PROD x:A. C(x, f`x))" + shows "?a : \h: (\x:A. \y:B(x). C(x,y)). + (\f: (\x:A. B(x)). \x:A. C(x, f`x))" apply (intr assms) (*Must not use add_mp as subst_prodE hides the construction.*) apply (rule ProdE [THEN SumE]) @@ -174,13 +174,13 @@ done text "Example of sequent_style deduction" -(*When splitting z:A*B, the assumption C(z) is affected; ?a becomes - lam u. split(u,\v w.split(v,\x y.lam z. >) ` w) *) +(*When splitting z:A \ B, the assumption C(z) is affected; ?a becomes + \<^bold>\u. split(u,\v w.split(v,\x y.\<^bold> \z. >) ` w) *) schematic_goal assumes "A type" and "B type" - and "\z. z:A*B \ C(z) type" - shows "?a : (SUM z:A*B. C(z)) --> (SUM u:A. SUM v:B. C())" + and "\z. z:A \ B \ C(z) type" + shows "?a : (\z:A \ B. C(z)) \ (\u:A. \v:B. C())" apply (rule intr_rls) apply (tactic \biresolve_tac @{context} safe_brls 2\) (*Now must convert assumption C(z) into antecedent C() *) diff -r a705f42b244d -r 2332d9be352b src/CTT/ex/Equality.thy --- a/src/CTT/ex/Equality.thy Sat Oct 10 21:14:00 2015 +0200 +++ b/src/CTT/ex/Equality.thy Sat Oct 10 21:43:07 2015 +0200 @@ -43,20 +43,20 @@ apply hyp_rew done -(*Martin-Lof (1984) page 62: pairing is surjective*) +(*Martin-Löf (1984) page 62: pairing is surjective*) lemma "p : Sum(A,B) \ x y. x), split(p,\x y. y)> = p : Sum(A,B)" apply (rule EqE) apply (rule elim_rls, assumption) apply (tactic \DEPTH_SOLVE_1 (rew_tac @{context} [])\) (*!!!!!!!*) done -lemma "\a : A; b : B\ \ (lam u. split(u, \v w.)) ` = : SUM x:B. A" +lemma "\a : A; b : B\ \ (\<^bold>\u. split(u, \v w.)) ` = : \x:B. A" apply rew done (*a contrived, complicated simplication, requires sum-elimination also*) -lemma "(lam f. lam x. f`(f`x)) ` (lam u. split(u, \v w.)) = - lam x. x : PROD x:(SUM y:N. N). (SUM y:N. N)" +lemma "(\<^bold>\f. \<^bold>\x. f`(f`x)) ` (\<^bold>\u. split(u, \v w.)) = + \<^bold>\x. x : \x:(\y:N. N). (\y:N. N)" apply (rule reduction_rls) apply (rule_tac [3] intrL_rls) apply (rule_tac [4] EqE) diff -r a705f42b244d -r 2332d9be352b src/CTT/ex/Synthesis.thy --- a/src/CTT/ex/Synthesis.thy Sat Oct 10 21:14:00 2015 +0200 +++ b/src/CTT/ex/Synthesis.thy Sat Oct 10 21:43:07 2015 +0200 @@ -10,8 +10,7 @@ begin text "discovery of predecessor function" -schematic_goal "?a : SUM pred:?A . Eq(N, pred`0, 0) - * (PROD n:N. Eq(N, pred ` succ(n), n))" +schematic_goal "?a : \pred:?A . Eq(N, pred`0, 0) \ (\n:N. Eq(N, pred ` succ(n), n))" apply intr apply eqintr apply (rule_tac [3] reduction_rls) @@ -21,7 +20,7 @@ text "the function fst as an element of a function type" schematic_goal [folded basic_defs]: - "A type \ ?a: SUM f:?B . PROD i:A. PROD j:A. Eq(A, f ` , i)" + "A type \ ?a: \f:?B . \i:A. \j:A. Eq(A, f ` , i)" apply intr apply eqintr apply (rule_tac [2] reduction_rls) @@ -34,8 +33,8 @@ text "An interesting use of the eliminator, when" (*The early implementation of unification caused non-rigid path in occur check See following example.*) -schematic_goal "?a : PROD i:N. Eq(?A, ?b(inl(i)), <0 , i>) - * Eq(?A, ?b(inr(i)), )" +schematic_goal "?a : \i:N. Eq(?A, ?b(inl(i)), <0 , i>) + \ Eq(?A, ?b(inr(i)), )" apply intr apply eqintr apply (rule comp_rls) @@ -45,16 +44,16 @@ (*Here we allow the type to depend on i. This prevents the cycle in the first unification (no longer needed). Requires flex-flex to preserve the dependence. - Simpler still: make ?A into a constant type N*N.*) -schematic_goal "?a : PROD i:N. Eq(?A(i), ?b(inl(i)), <0 , i>) - * Eq(?A(i), ?b(inr(i)), )" + Simpler still: make ?A into a constant type N \ N.*) +schematic_goal "?a : \i:N. Eq(?A(i), ?b(inl(i)), <0 , i>) + \ Eq(?A(i), ?b(inr(i)), )" oops text "A tricky combination of when and split" (*Now handled easily, but caused great problems once*) schematic_goal [folded basic_defs]: - "?a : PROD i:N. PROD j:N. Eq(?A, ?b(inl()), i) - * Eq(?A, ?b(inr()), j)" + "?a : \i:N. \j:N. Eq(?A, ?b(inl()), i) + \ Eq(?A, ?b(inr()), j)" apply intr apply eqintr apply (rule PlusC_inl [THEN trans_elem]) @@ -65,20 +64,20 @@ done (*similar but allows the type to depend on i and j*) -schematic_goal "?a : PROD i:N. PROD j:N. Eq(?A(i,j), ?b(inl()), i) - * Eq(?A(i,j), ?b(inr()), j)" +schematic_goal "?a : \i:N. \j:N. Eq(?A(i,j), ?b(inl()), i) + \ Eq(?A(i,j), ?b(inr()), j)" oops (*similar but specifying the type N simplifies the unification problems*) -schematic_goal "?a : PROD i:N. PROD j:N. Eq(N, ?b(inl()), i) - * Eq(N, ?b(inr()), j)" +schematic_goal "?a : \i:N. \j:N. Eq(N, ?b(inl()), i) + \ Eq(N, ?b(inr()), j)" oops text "Deriving the addition operator" schematic_goal [folded arith_defs]: - "?c : PROD n:N. Eq(N, ?f(0,n), n) - * (PROD m:N. Eq(N, ?f(succ(m), n), succ(?f(m,n))))" + "?c : \n:N. Eq(N, ?f(0,n), n) + \ (\m:N. Eq(N, ?f(succ(m), n), succ(?f(m,n))))" apply intr apply eqintr apply (rule comp_rls) @@ -87,9 +86,9 @@ text "The addition function -- using explicit lambdas" schematic_goal [folded arith_defs]: - "?c : SUM plus : ?A . - PROD x:N. Eq(N, plus`0`x, x) - * (PROD y:N. Eq(N, plus`succ(y)`x, succ(plus`y`x)))" + "?c : \plus : ?A . + \x:N. Eq(N, plus`0`x, x) + \ (\y:N. Eq(N, plus`succ(y)`x, succ(plus`y`x)))" apply intr apply eqintr apply (tactic "resolve_tac @{context} [TSimp.split_eqn] 3") diff -r a705f42b244d -r 2332d9be352b src/CTT/ex/Typechecking.thy --- a/src/CTT/ex/Typechecking.thy Sat Oct 10 21:14:00 2015 +0200 +++ b/src/CTT/ex/Typechecking.thy Sat Oct 10 21:43:07 2015 +0200 @@ -22,7 +22,7 @@ apply (rule form_rls) done -schematic_goal "PROD z:?A . N + ?B(z) type" +schematic_goal "\z:?A . N + ?B(z) type" apply (rule form_rls) apply (rule form_rls) apply (rule form_rls) @@ -33,7 +33,7 @@ subsection \Multi-step proofs: Type inference\ -lemma "PROD w:N. N + N type" +lemma "\w:N. N + N type" apply form done @@ -41,26 +41,26 @@ apply intr done -schematic_goal "PROD w:N . Eq(?A,w,w) type" +schematic_goal "\w:N . Eq(?A,w,w) type" apply typechk done -schematic_goal "PROD x:N . PROD y:N . Eq(?A,x,y) type" +schematic_goal "\x:N . \y:N . Eq(?A,x,y) type" apply typechk done text "typechecking an application of fst" -schematic_goal "(lam u. split(u, \v w. v)) ` <0, succ(0)> : ?A" +schematic_goal "(\<^bold>\u. split(u, \v w. v)) ` <0, succ(0)> : ?A" apply typechk done text "typechecking the predecessor function" -schematic_goal "lam n. rec(n, 0, \x y. x) : ?A" +schematic_goal "\<^bold>\n. rec(n, 0, \x y. x) : ?A" apply typechk done text "typechecking the addition function" -schematic_goal "lam n. lam m. rec(n, m, \x y. succ(y)) : ?A" +schematic_goal "\<^bold>\n. \<^bold>\m. rec(n, m, \x y. succ(y)) : ?A" apply typechk done @@ -69,18 +69,18 @@ method_setup N = \Scan.succeed (fn ctxt => SIMPLE_METHOD (TRYALL (resolve_tac ctxt @{thms NF})))\ -schematic_goal "lam w. : ?A" +schematic_goal "\<^bold>\w. : ?A" apply typechk apply N done -schematic_goal "lam x. lam y. x : ?A" +schematic_goal "\<^bold>\x. \<^bold>\y. x : ?A" apply typechk apply N done text "typechecking fst (as a function object)" -schematic_goal "lam i. split(i, \j k. j) : ?A" +schematic_goal "\<^bold>\i. split(i, \j k. j) : ?A" apply typechk apply N done