68 in if T = Bound 0 then a else Const(Syntax.constrainAbsC,dummyT) $ a $ T end |
68 in if T = Bound 0 then a else Const(Syntax.constrainAbsC,dummyT) $ a $ T end |
69 in |
69 in |
70 |
70 |
71 fun mk_abstuple [x] body = abs (x, body) |
71 fun mk_abstuple [x] body = abs (x, body) |
72 | mk_abstuple (x::xs) body = |
72 | mk_abstuple (x::xs) body = |
73 Syntax.const @{const_syntax split} $ abs (x, mk_abstuple xs body); |
73 Syntax.const @{const_syntax prod_case} $ abs (x, mk_abstuple xs body); |
74 |
74 |
75 fun mk_fbody a e [x as (b,_)] = if a=b then e else free b |
75 fun mk_fbody a e [x as (b,_)] = if a=b then e else free b |
76 | mk_fbody a e ((b,_)::xs) = |
76 | mk_fbody a e ((b,_)::xs) = |
77 Syntax.const @{const_syntax Pair} $ (if a=b then e else free b) $ mk_fbody a e xs; |
77 Syntax.const @{const_syntax Pair} $ (if a=b then e else free b) $ mk_fbody a e xs; |
78 |
78 |
128 |
128 |
129 (*****************************************************************************) |
129 (*****************************************************************************) |
130 |
130 |
131 (*** print translations ***) |
131 (*** print translations ***) |
132 ML{* |
132 ML{* |
133 fun dest_abstuple (Const (@{const_syntax split},_) $ (Abs(v,_, body))) = |
133 fun dest_abstuple (Const (@{const_syntax prod_case},_) $ (Abs(v,_, body))) = |
134 subst_bound (Syntax.free v, dest_abstuple body) |
134 subst_bound (Syntax.free v, dest_abstuple body) |
135 | dest_abstuple (Abs(v,_, body)) = subst_bound (Syntax.free v, body) |
135 | dest_abstuple (Abs(v,_, body)) = subst_bound (Syntax.free v, body) |
136 | dest_abstuple trm = trm; |
136 | dest_abstuple trm = trm; |
137 |
137 |
138 fun abs2list (Const (@{const_syntax split},_) $ (Abs(x,T,t))) = Free (x, T)::abs2list t |
138 fun abs2list (Const (@{const_syntax prod_case},_) $ (Abs(x,T,t))) = Free (x, T)::abs2list t |
139 | abs2list (Abs(x,T,t)) = [Free (x, T)] |
139 | abs2list (Abs(x,T,t)) = [Free (x, T)] |
140 | abs2list _ = []; |
140 | abs2list _ = []; |
141 |
141 |
142 fun mk_ts (Const (@{const_syntax split},_) $ (Abs(x,_,t))) = mk_ts t |
142 fun mk_ts (Const (@{const_syntax prod_case},_) $ (Abs(x,_,t))) = mk_ts t |
143 | mk_ts (Abs(x,_,t)) = mk_ts t |
143 | mk_ts (Abs(x,_,t)) = mk_ts t |
144 | mk_ts (Const (@{const_syntax Pair},_) $ a $ b) = a::(mk_ts b) |
144 | mk_ts (Const (@{const_syntax Pair},_) $ a $ b) = a::(mk_ts b) |
145 | mk_ts t = [t]; |
145 | mk_ts t = [t]; |
146 |
146 |
147 fun mk_vts (Const (@{const_syntax split},_) $ (Abs(x,_,t))) = |
147 fun mk_vts (Const (@{const_syntax prod_case},_) $ (Abs(x,_,t))) = |
148 ((Syntax.free x)::(abs2list t), mk_ts t) |
148 ((Syntax.free x)::(abs2list t), mk_ts t) |
149 | mk_vts (Abs(x,_,t)) = ([Syntax.free x], [t]) |
149 | mk_vts (Abs(x,_,t)) = ([Syntax.free x], [t]) |
150 | mk_vts t = raise Match; |
150 | mk_vts t = raise Match; |
151 |
151 |
152 fun find_ch [] i xs = (false, (Syntax.free "not_ch", Syntax.free "not_ch")) |
152 fun find_ch [] i xs = (false, (Syntax.free "not_ch", Syntax.free "not_ch")) |
153 | find_ch ((v,t)::vts) i xs = |
153 | find_ch ((v,t)::vts) i xs = |
154 if t = Bound i then find_ch vts (i-1) xs |
154 if t = Bound i then find_ch vts (i-1) xs |
155 else (true, (v, subst_bounds (xs,t))); |
155 else (true, (v, subst_bounds (xs,t))); |
156 |
156 |
157 fun is_f (Const (@{const_syntax split},_) $ (Abs(x,_,t))) = true |
157 fun is_f (Const (@{const_syntax prod_case},_) $ (Abs(x,_,t))) = true |
158 | is_f (Abs(x,_,t)) = true |
158 | is_f (Abs(x,_,t)) = true |
159 | is_f t = false; |
159 | is_f t = false; |
160 *} |
160 *} |
161 |
161 |
162 (* assn_tr' & bexp_tr'*) |
162 (* assn_tr' & bexp_tr'*) |