11 |
11 |
12 consts |
12 consts |
13 |
13 |
14 one :: "i" |
14 one :: "i" |
15 |
15 |
16 "if" :: "[i,i,i]=>i" ("(3if _/ then _/ else _)" [0,0,60] 60) |
16 "if" :: "[i,i,i]\<Rightarrow>i" ("(3if _/ then _/ else _)" [0,0,60] 60) |
17 |
17 |
18 inl :: "i=>i" |
18 inl :: "i\<Rightarrow>i" |
19 inr :: "i=>i" |
19 inr :: "i\<Rightarrow>i" |
20 when :: "[i,i=>i,i=>i]=>i" |
20 when :: "[i,i\<Rightarrow>i,i\<Rightarrow>i]\<Rightarrow>i" |
21 |
21 |
22 split :: "[i,[i,i]=>i]=>i" |
22 split :: "[i,[i,i]\<Rightarrow>i]\<Rightarrow>i" |
23 fst :: "i=>i" |
23 fst :: "i\<Rightarrow>i" |
24 snd :: "i=>i" |
24 snd :: "i\<Rightarrow>i" |
25 thd :: "i=>i" |
25 thd :: "i\<Rightarrow>i" |
26 |
26 |
27 zero :: "i" |
27 zero :: "i" |
28 succ :: "i=>i" |
28 succ :: "i\<Rightarrow>i" |
29 ncase :: "[i,i,i=>i]=>i" |
29 ncase :: "[i,i,i\<Rightarrow>i]\<Rightarrow>i" |
30 nrec :: "[i,i,[i,i]=>i]=>i" |
30 nrec :: "[i,i,[i,i]\<Rightarrow>i]\<Rightarrow>i" |
31 |
31 |
32 nil :: "i" ("([])") |
32 nil :: "i" ("([])") |
33 cons :: "[i,i]=>i" (infixr "$" 80) |
33 cons :: "[i,i]\<Rightarrow>i" (infixr "$" 80) |
34 lcase :: "[i,i,[i,i]=>i]=>i" |
34 lcase :: "[i,i,[i,i]\<Rightarrow>i]\<Rightarrow>i" |
35 lrec :: "[i,i,[i,i,i]=>i]=>i" |
35 lrec :: "[i,i,[i,i,i]\<Rightarrow>i]\<Rightarrow>i" |
36 |
36 |
37 "let" :: "[i,i=>i]=>i" |
37 "let" :: "[i,i\<Rightarrow>i]\<Rightarrow>i" |
38 letrec :: "[[i,i=>i]=>i,(i=>i)=>i]=>i" |
38 letrec :: "[[i,i\<Rightarrow>i]\<Rightarrow>i,(i\<Rightarrow>i)\<Rightarrow>i]\<Rightarrow>i" |
39 letrec2 :: "[[i,i,i=>i=>i]=>i,(i=>i=>i)=>i]=>i" |
39 letrec2 :: "[[i,i,i\<Rightarrow>i\<Rightarrow>i]\<Rightarrow>i,(i\<Rightarrow>i\<Rightarrow>i)\<Rightarrow>i]\<Rightarrow>i" |
40 letrec3 :: "[[i,i,i,i=>i=>i=>i]=>i,(i=>i=>i=>i)=>i]=>i" |
40 letrec3 :: "[[i,i,i,i\<Rightarrow>i\<Rightarrow>i\<Rightarrow>i]\<Rightarrow>i,(i\<Rightarrow>i\<Rightarrow>i\<Rightarrow>i)\<Rightarrow>i]\<Rightarrow>i" |
41 |
41 |
42 syntax |
42 syntax |
43 "_let" :: "[id,i,i]=>i" ("(3let _ be _/ in _)" |
43 "_let" :: "[id,i,i]\<Rightarrow>i" ("(3let _ be _/ in _)" |
44 [0,0,60] 60) |
44 [0,0,60] 60) |
45 |
45 |
46 "_letrec" :: "[id,id,i,i]=>i" ("(3letrec _ _ be _/ in _)" |
46 "_letrec" :: "[id,id,i,i]\<Rightarrow>i" ("(3letrec _ _ be _/ in _)" |
47 [0,0,0,60] 60) |
47 [0,0,0,60] 60) |
48 |
48 |
49 "_letrec2" :: "[id,id,id,i,i]=>i" ("(3letrec _ _ _ be _/ in _)" |
49 "_letrec2" :: "[id,id,id,i,i]\<Rightarrow>i" ("(3letrec _ _ _ be _/ in _)" |
50 [0,0,0,0,60] 60) |
50 [0,0,0,0,60] 60) |
51 |
51 |
52 "_letrec3" :: "[id,id,id,id,i,i]=>i" ("(3letrec _ _ _ _ be _/ in _)" |
52 "_letrec3" :: "[id,id,id,id,i,i]\<Rightarrow>i" ("(3letrec _ _ _ _ be _/ in _)" |
53 [0,0,0,0,0,60] 60) |
53 [0,0,0,0,0,60] 60) |
54 |
54 |
55 ML {* |
55 ML {* |
56 (** Quantifier translations: variable binding **) |
56 (** Quantifier translations: variable binding **) |
57 |
57 |
106 (@{const_syntax letrec2}, K letrec2_tr'), |
106 (@{const_syntax letrec2}, K letrec2_tr'), |
107 (@{const_syntax letrec3}, K letrec3_tr')] |
107 (@{const_syntax letrec3}, K letrec3_tr')] |
108 *} |
108 *} |
109 |
109 |
110 consts |
110 consts |
111 napply :: "[i=>i,i,i]=>i" ("(_ ^ _ ` _)" [56,56,56] 56) |
111 napply :: "[i\<Rightarrow>i,i,i]\<Rightarrow>i" ("(_ ^ _ ` _)" [56,56,56] 56) |
112 |
112 |
113 defs |
113 defs |
114 one_def: "one == true" |
114 one_def: "one == true" |
115 if_def: "if b then t else u == case(b,t,u,% x y. bot,%v. bot)" |
115 if_def: "if b then t else u == case(b, t, u, \<lambda> x y. bot, \<lambda>v. bot)" |
116 inl_def: "inl(a) == <true,a>" |
116 inl_def: "inl(a) == <true,a>" |
117 inr_def: "inr(b) == <false,b>" |
117 inr_def: "inr(b) == <false,b>" |
118 when_def: "when(t,f,g) == split(t,%b x. if b then f(x) else g(x))" |
118 when_def: "when(t,f,g) == split(t, \<lambda>b x. if b then f(x) else g(x))" |
119 split_def: "split(t,f) == case(t,bot,bot,f,%u. bot)" |
119 split_def: "split(t,f) == case(t, bot, bot, f, \<lambda>u. bot)" |
120 fst_def: "fst(t) == split(t,%x y. x)" |
120 fst_def: "fst(t) == split(t, \<lambda>x y. x)" |
121 snd_def: "snd(t) == split(t,%x y. y)" |
121 snd_def: "snd(t) == split(t, \<lambda>x y. y)" |
122 thd_def: "thd(t) == split(t,%x p. split(p,%y z. z))" |
122 thd_def: "thd(t) == split(t, \<lambda>x p. split(p, \<lambda>y z. z))" |
123 zero_def: "zero == inl(one)" |
123 zero_def: "zero == inl(one)" |
124 succ_def: "succ(n) == inr(n)" |
124 succ_def: "succ(n) == inr(n)" |
125 ncase_def: "ncase(n,b,c) == when(n,%x. b,%y. c(y))" |
125 ncase_def: "ncase(n,b,c) == when(n, \<lambda>x. b, \<lambda>y. c(y))" |
126 nrec_def: " nrec(n,b,c) == letrec g x be ncase(x,b,%y. c(y,g(y))) in g(n)" |
126 nrec_def: " nrec(n,b,c) == letrec g x be ncase(x, b, \<lambda>y. c(y,g(y))) in g(n)" |
127 nil_def: "[] == inl(one)" |
127 nil_def: "[] == inl(one)" |
128 cons_def: "h$t == inr(<h,t>)" |
128 cons_def: "h$t == inr(<h,t>)" |
129 lcase_def: "lcase(l,b,c) == when(l,%x. b,%y. split(y,c))" |
129 lcase_def: "lcase(l,b,c) == when(l, \<lambda>x. b, \<lambda>y. split(y,c))" |
130 lrec_def: "lrec(l,b,c) == letrec g x be lcase(x,b,%h t. c(h,t,g(t))) in g(l)" |
130 lrec_def: "lrec(l,b,c) == letrec g x be lcase(x, b, \<lambda>h t. c(h,t,g(t))) in g(l)" |
131 |
131 |
132 let_def: "let x be t in f(x) == case(t,f(true),f(false),%x y. f(<x,y>),%u. f(lam x. u(x)))" |
132 let_def: "let x be t in f(x) == case(t,f(true),f(false), \<lambda>x y. f(<x,y>), \<lambda>u. f(lam x. u(x)))" |
133 letrec_def: |
133 letrec_def: |
134 "letrec g x be h(x,g) in b(g) == b(%x. fix(%f. lam x. h(x,%y. f`y))`x)" |
134 "letrec g x be h(x,g) in b(g) == b(\<lambda>x. fix(\<lambda>f. lam x. h(x,\<lambda>y. f`y))`x)" |
135 |
135 |
136 letrec2_def: "letrec g x y be h(x,y,g) in f(g)== |
136 letrec2_def: "letrec g x y be h(x,y,g) in f(g)== |
137 letrec g' p be split(p,%x y. h(x,y,%u v. g'(<u,v>))) |
137 letrec g' p be split(p,\<lambda>x y. h(x,y,\<lambda>u v. g'(<u,v>))) |
138 in f(%x y. g'(<x,y>))" |
138 in f(\<lambda>x y. g'(<x,y>))" |
139 |
139 |
140 letrec3_def: "letrec g x y z be h(x,y,z,g) in f(g) == |
140 letrec3_def: "letrec g x y z be h(x,y,z,g) in f(g) == |
141 letrec g' p be split(p,%x xs. split(xs,%y z. h(x,y,z,%u v w. g'(<u,<v,w>>)))) |
141 letrec g' p be split(p,\<lambda>x xs. split(xs,\<lambda>y z. h(x,y,z,\<lambda>u v w. g'(<u,<v,w>>)))) |
142 in f(%x y z. g'(<x,<y,z>>))" |
142 in f(\<lambda>x y z. g'(<x,<y,z>>))" |
143 |
143 |
144 napply_def: "f ^n` a == nrec(n,a,%x g. f(g))" |
144 napply_def: "f ^n` a == nrec(n,a,\<lambda>x g. f(g))" |
145 |
145 |
146 |
146 |
147 lemmas simp_can_defs = one_def inl_def inr_def |
147 lemmas simp_can_defs = one_def inl_def inr_def |
148 and simp_ncan_defs = if_def when_def split_def fst_def snd_def thd_def |
148 and simp_ncan_defs = if_def when_def split_def fst_def snd_def thd_def |
149 lemmas simp_defs = simp_can_defs simp_ncan_defs |
149 lemmas simp_defs = simp_can_defs simp_ncan_defs |
251 and lrecBcons: "lrec(x$xs,t,u) = u(x,xs,lrec(xs,t,u))" |
251 and lrecBcons: "lrec(x$xs,t,u) = u(x,xs,lrec(xs,t,u))" |
252 and lrecBbot: "lrec(bot,t,u) = bot" |
252 and lrecBbot: "lrec(bot,t,u) = bot" |
253 unfolding data_defs by beta_rl+ |
253 unfolding data_defs by beta_rl+ |
254 |
254 |
255 lemma letrec2B: |
255 lemma letrec2B: |
256 "letrec g x y be h(x,y,g) in g(p,q) = h(p,q,%u v. letrec g x y be h(x,y,g) in g(u,v))" |
256 "letrec g x y be h(x,y,g) in g(p,q) = h(p,q,\<lambda>u v. letrec g x y be h(x,y,g) in g(u,v))" |
257 unfolding data_defs letrec2_def by beta_rl+ |
257 unfolding data_defs letrec2_def by beta_rl+ |
258 |
258 |
259 lemma letrec3B: |
259 lemma letrec3B: |
260 "letrec g x y z be h(x,y,z,g) in g(p,q,r) = |
260 "letrec g x y z be h(x,y,z,g) in g(p,q,r) = |
261 h(p,q,r,%u v w. letrec g x y z be h(x,y,z,g) in g(u,v,w))" |
261 h(p,q,r,\<lambda>u v w. letrec g x y z be h(x,y,z,g) in g(u,v,w))" |
262 unfolding data_defs letrec3_def by beta_rl+ |
262 unfolding data_defs letrec3_def by beta_rl+ |
263 |
263 |
264 lemma napplyBzero: "f^zero`a = a" |
264 lemma napplyBzero: "f^zero`a = a" |
265 and napplyBsucc: "f^succ(n)`a = f(f^n`a)" |
265 and napplyBsucc: "f^succ(n)`a = f(f^n`a)" |
266 unfolding data_defs by beta_rl+ |
266 unfolding data_defs by beta_rl+ |