author | wenzelm |
Thu, 15 Dec 2011 19:53:28 +0100 | |
changeset 45894 | 629d123b7dbe |
parent 45891 | d73605c829cc |
child 45898 | b619242b0439 |
permissions | -rw-r--r-- |
33968
f94fb13ecbb3
modernized structures and tuned headers of datatype package modules; joined former datatype.ML and datatype_rep_proofs.ML
haftmann
parents:
33040
diff
changeset
|
1 |
(* Title: HOL/Tools/Datatype/datatype_case.ML |
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
2 |
Author: Konrad Slind, Cambridge University Computer Laboratory |
29266 | 3 |
Author: Stefan Berghofer, TU Muenchen |
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
4 |
|
33968
f94fb13ecbb3
modernized structures and tuned headers of datatype package modules; joined former datatype.ML and datatype_rep_proofs.ML
haftmann
parents:
33040
diff
changeset
|
5 |
Datatype package: nested case expressions on datatypes. |
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
6 |
*) |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
7 |
|
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
8 |
signature DATATYPE_CASE = |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
9 |
sig |
33968
f94fb13ecbb3
modernized structures and tuned headers of datatype package modules; joined former datatype.ML and datatype_rep_proofs.ML
haftmann
parents:
33040
diff
changeset
|
10 |
datatype config = Error | Warning | Quiet |
f94fb13ecbb3
modernized structures and tuned headers of datatype package modules; joined former datatype.ML and datatype_rep_proofs.ML
haftmann
parents:
33040
diff
changeset
|
11 |
type info = Datatype_Aux.info |
45891
d73605c829cc
clarified module dependencies: Datatype_Data, Datatype_Case, Rep_Datatype;
wenzelm
parents:
45889
diff
changeset
|
12 |
val make_case : Proof.context -> config -> string list -> term -> (term * term) list -> term |
d73605c829cc
clarified module dependencies: Datatype_Data, Datatype_Case, Rep_Datatype;
wenzelm
parents:
45889
diff
changeset
|
13 |
val strip_case : Proof.context -> bool -> term -> (term * (term * term) list) option |
d73605c829cc
clarified module dependencies: Datatype_Data, Datatype_Case, Rep_Datatype;
wenzelm
parents:
45889
diff
changeset
|
14 |
val case_tr: bool -> Proof.context -> term list -> term |
d73605c829cc
clarified module dependencies: Datatype_Data, Datatype_Case, Rep_Datatype;
wenzelm
parents:
45889
diff
changeset
|
15 |
val case_tr': string -> Proof.context -> term list -> term |
d73605c829cc
clarified module dependencies: Datatype_Data, Datatype_Case, Rep_Datatype;
wenzelm
parents:
45889
diff
changeset
|
16 |
val add_case_tr' : string list -> theory -> theory |
d73605c829cc
clarified module dependencies: Datatype_Data, Datatype_Case, Rep_Datatype;
wenzelm
parents:
45889
diff
changeset
|
17 |
val setup: theory -> theory |
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
18 |
end; |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
19 |
|
33968
f94fb13ecbb3
modernized structures and tuned headers of datatype package modules; joined former datatype.ML and datatype_rep_proofs.ML
haftmann
parents:
33040
diff
changeset
|
20 |
structure Datatype_Case : DATATYPE_CASE = |
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
21 |
struct |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
22 |
|
32671 | 23 |
datatype config = Error | Warning | Quiet; |
33968
f94fb13ecbb3
modernized structures and tuned headers of datatype package modules; joined former datatype.ML and datatype_rep_proofs.ML
haftmann
parents:
33040
diff
changeset
|
24 |
type info = Datatype_Aux.info; |
32671 | 25 |
|
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
26 |
exception CASE_ERROR of string * int; |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
27 |
|
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
28 |
fun match_type thy pat ob = Sign.typ_match thy (pat, ob) Vartab.empty; |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
29 |
|
43255 | 30 |
(* Get information about datatypes *) |
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
31 |
|
45894 | 32 |
fun ty_info ({descr, case_name, index, ...} : info) = |
33 |
let |
|
34 |
val (_, (tname, dts, constrs)) = nth descr index; |
|
35 |
val mk_ty = Datatype_Aux.typ_of_dtyp descr; |
|
36 |
val T = Type (tname, map mk_ty dts); |
|
37 |
in |
|
38 |
{case_name = case_name, |
|
39 |
constructors = map (fn (cname, dts') => |
|
40 |
Const (cname, Logic.varifyT_global (map mk_ty dts' ---> T))) constrs} |
|
41 |
end; |
|
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
42 |
|
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
43 |
|
43255 | 44 |
(*Each pattern carries with it a tag i, which denotes the clause it |
45 |
came from. i = ~1 indicates that the clause was added by pattern |
|
46 |
completion.*) |
|
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
47 |
|
29281 | 48 |
fun add_row_used ((prfx, pats), (tm, tag)) = |
43252 | 49 |
fold Term.add_free_names (tm :: pats @ map Free prfx); |
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
50 |
|
43255 | 51 |
(*try to preserve names given by user*) |
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
52 |
fun default_names names ts = |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
53 |
map (fn ("", Free (name', _)) => name' | (name, _) => name) (names ~~ ts); |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
54 |
|
35124 | 55 |
fun strip_constraints (Const (@{syntax_const "_constrain"}, _) $ t $ tT) = |
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
56 |
strip_constraints t ||> cons tT |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
57 |
| strip_constraints t = (t, []); |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
58 |
|
35124 | 59 |
fun mk_fun_constrain tT t = |
60 |
Syntax.const @{syntax_const "_constrain"} $ t $ |
|
35363 | 61 |
(Syntax.const @{type_syntax fun} $ tT $ Syntax.const @{type_syntax dummy}); |
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
62 |
|
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
63 |
|
43255 | 64 |
(*Produce an instance of a constructor, plus fresh variables for its arguments.*) |
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
65 |
fun fresh_constr ty_match ty_inst colty used c = |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
66 |
let |
45889 | 67 |
val (_, Ty) = dest_Const c; |
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
68 |
val Ts = binder_types Ty; |
45700 | 69 |
val names = |
70 |
Name.variant_list used (Datatype_Prop.make_tnames (map Logic.unvarifyT_global Ts)); |
|
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
71 |
val ty = body_type Ty; |
45700 | 72 |
val ty_theta = ty_match ty colty |
73 |
handle Type.TYPE_MATCH => raise CASE_ERROR ("type mismatch", ~1); |
|
74 |
val c' = ty_inst ty_theta c; |
|
75 |
val gvars = map (ty_inst ty_theta o Free) (names ~~ Ts); |
|
42049 | 76 |
in (c', gvars) end; |
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
77 |
|
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
78 |
|
45889 | 79 |
(*Go through a list of rows and pick out the ones beginning with a |
45700 | 80 |
pattern with constructor = name.*) |
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
81 |
fun mk_group (name, T) rows = |
42049 | 82 |
let val k = length (binder_types T) in |
43256 | 83 |
fold (fn (row as ((prfx, p :: ps), rhs as (_, i))) => |
42049 | 84 |
fn ((in_group, not_in_group), (names, cnstrts)) => |
85 |
(case strip_comb p of |
|
86 |
(Const (name', _), args) => |
|
87 |
if name = name' then |
|
88 |
if length args = k then |
|
45700 | 89 |
let val (args', cnstrts') = split_list (map strip_constraints args) in |
43256 | 90 |
((((prfx, args' @ ps), rhs) :: in_group, not_in_group), |
42049 | 91 |
(default_names names args', map2 append cnstrts cnstrts')) |
92 |
end |
|
45700 | 93 |
else raise CASE_ERROR ("Wrong number of arguments for constructor " ^ name, i) |
42049 | 94 |
else ((in_group, row :: not_in_group), (names, cnstrts)) |
95 |
| _ => raise CASE_ERROR ("Not a constructor pattern", i))) |
|
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
96 |
rows (([], []), (replicate k "", replicate k [])) |>> pairself rev |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
97 |
end; |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
98 |
|
43255 | 99 |
|
100 |
(* Partitioning *) |
|
101 |
||
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
102 |
fun partition _ _ _ _ _ _ _ [] = raise CASE_ERROR ("partition: no rows", ~1) |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
103 |
| partition ty_match ty_inst type_of used constructors colty res_ty |
43256 | 104 |
(rows as (((prfx, _ :: ps), _) :: _)) = |
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
105 |
let |
43257
b81fd5c8f2dc
eliminated unnecessary tail-recursion and funny use of records as 'named arguments' for functions
krauss
parents:
43256
diff
changeset
|
106 |
fun part [] [] = [] |
45700 | 107 |
| part [] ((_, (_, i)) :: _) = raise CASE_ERROR ("Not a constructor pattern", i) |
43257
b81fd5c8f2dc
eliminated unnecessary tail-recursion and funny use of records as 'named arguments' for functions
krauss
parents:
43256
diff
changeset
|
108 |
| part (c :: cs) rows = |
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
109 |
let |
45700 | 110 |
val ((in_group, not_in_group), (names, cnstrts)) = mk_group (dest_Const c) rows; |
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
111 |
val used' = fold add_row_used in_group used; |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
112 |
val (c', gvars) = fresh_constr ty_match ty_inst colty used' c; |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
113 |
val in_group' = |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
114 |
if null in_group (* Constructor not given *) |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
115 |
then |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
116 |
let |
43256 | 117 |
val Ts = map type_of ps; |
45700 | 118 |
val xs = |
119 |
Name.variant_list |
|
120 |
(fold Term.add_free_names gvars used') |
|
121 |
(replicate (length ps) "x"); |
|
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
122 |
in |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
123 |
[((prfx, gvars @ map Free (xs ~~ Ts)), |
43254 | 124 |
(Const (@{const_syntax undefined}, res_ty), ~1))] |
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
125 |
end |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
126 |
else in_group |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
127 |
in |
43257
b81fd5c8f2dc
eliminated unnecessary tail-recursion and funny use of records as 'named arguments' for functions
krauss
parents:
43256
diff
changeset
|
128 |
{constructor = c', |
b81fd5c8f2dc
eliminated unnecessary tail-recursion and funny use of records as 'named arguments' for functions
krauss
parents:
43256
diff
changeset
|
129 |
new_formals = gvars, |
b81fd5c8f2dc
eliminated unnecessary tail-recursion and funny use of records as 'named arguments' for functions
krauss
parents:
43256
diff
changeset
|
130 |
names = names, |
b81fd5c8f2dc
eliminated unnecessary tail-recursion and funny use of records as 'named arguments' for functions
krauss
parents:
43256
diff
changeset
|
131 |
constraints = cnstrts, |
b81fd5c8f2dc
eliminated unnecessary tail-recursion and funny use of records as 'named arguments' for functions
krauss
parents:
43256
diff
changeset
|
132 |
group = in_group'} :: part cs not_in_group |
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
133 |
end |
43257
b81fd5c8f2dc
eliminated unnecessary tail-recursion and funny use of records as 'named arguments' for functions
krauss
parents:
43256
diff
changeset
|
134 |
in part constructors rows end; |
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
135 |
|
45700 | 136 |
fun v_to_prfx (prfx, Free v :: pats) = (v :: prfx, pats) |
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
137 |
| v_to_prfx _ = raise CASE_ERROR ("mk_case: v_to_prfx", ~1); |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
138 |
|
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
139 |
|
43255 | 140 |
(* Translation of pattern terms into nested case expressions. *) |
45700 | 141 |
|
45891
d73605c829cc
clarified module dependencies: Datatype_Data, Datatype_Case, Rep_Datatype;
wenzelm
parents:
45889
diff
changeset
|
142 |
fun mk_case ctxt ty_match ty_inst type_of used range_ty = |
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
143 |
let |
45894 | 144 |
val get_info = Datatype_Data.info_of_constr_permissive (Proof_Context.theory_of ctxt); |
45891
d73605c829cc
clarified module dependencies: Datatype_Data, Datatype_Case, Rep_Datatype;
wenzelm
parents:
45889
diff
changeset
|
145 |
|
43324
2b47822868e4
discontinued Name.variant to emphasize that this is old-style / indirect;
wenzelm
parents:
43257
diff
changeset
|
146 |
val name = singleton (Name.variant_list used) "a"; |
45700 | 147 |
fun expand constructors used ty ((_, []), _) = raise CASE_ERROR ("mk_case: expand_var_row", ~1) |
43256 | 148 |
| expand constructors used ty (row as ((prfx, p :: ps), (rhs, tag))) = |
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
149 |
if is_Free p then |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
150 |
let |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
151 |
val used' = add_row_used row used; |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
152 |
fun expnd c = |
45700 | 153 |
let val capp = list_comb (fresh_constr ty_match ty_inst ty used' c) |
154 |
in ((prfx, capp :: ps), (subst_free [(p, capp)] rhs, tag)) end |
|
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
155 |
in map expnd constructors end |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
156 |
else [row] |
43257
b81fd5c8f2dc
eliminated unnecessary tail-recursion and funny use of records as 'named arguments' for functions
krauss
parents:
43256
diff
changeset
|
157 |
fun mk _ [] = raise CASE_ERROR ("no rows", ~1) |
45700 | 158 |
| mk [] (((_, []), (tm, tag)) :: _) = ([tag], tm) (* Done *) |
159 |
| mk path (rows as ((row as ((_, [Free _]), _)) :: _ :: _)) = mk path [row] |
|
43257
b81fd5c8f2dc
eliminated unnecessary tail-recursion and funny use of records as 'named arguments' for functions
krauss
parents:
43256
diff
changeset
|
160 |
| mk (u :: us) (rows as ((_, _ :: _), _) :: _) = |
43254 | 161 |
let val col0 = map (fn ((_, p :: _), (_, i)) => (p, i)) rows in |
42049 | 162 |
(case Option.map (apfst head_of) (find_first (not o is_Free o fst) col0) of |
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
163 |
NONE => |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
164 |
let |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
165 |
val rows' = map (fn ((v, _), row) => row ||> |
43255 | 166 |
apfst (subst_free [(v, u)]) |>> v_to_prfx) (col0 ~~ rows); |
43257
b81fd5c8f2dc
eliminated unnecessary tail-recursion and funny use of records as 'named arguments' for functions
krauss
parents:
43256
diff
changeset
|
167 |
in mk us rows' end |
42049 | 168 |
| SOME (Const (cname, cT), i) => |
45894 | 169 |
(case Option.map ty_info (get_info (cname, cT)) of |
42049 | 170 |
NONE => raise CASE_ERROR ("Not a datatype constructor: " ^ cname, i) |
171 |
| SOME {case_name, constructors} => |
|
45700 | 172 |
let |
173 |
val pty = body_type cT; |
|
174 |
val used' = fold Term.add_free_names us used; |
|
175 |
val nrows = maps (expand constructors used' pty) rows; |
|
176 |
val subproblems = |
|
177 |
partition ty_match ty_inst type_of used' |
|
178 |
constructors pty range_ty nrows; |
|
179 |
val (pat_rect, dtrees) = |
|
180 |
split_list (map (fn {new_formals, group, ...} => |
|
181 |
mk (new_formals @ us) group) subproblems); |
|
182 |
val case_functions = |
|
183 |
map2 (fn {new_formals, names, constraints, ...} => |
|
184 |
fold_rev (fn ((x as Free (_, T), s), cnstrts) => fn t => |
|
185 |
Abs (if s = "" then name else s, T, abstract_over (x, t)) |
|
186 |
|> fold mk_fun_constrain cnstrts) (new_formals ~~ names ~~ constraints)) |
|
187 |
subproblems dtrees; |
|
188 |
val types = map type_of (case_functions @ [u]); |
|
189 |
val case_const = Const (case_name, types ---> range_ty); |
|
190 |
val tree = list_comb (case_const, case_functions @ [u]); |
|
191 |
in (flat pat_rect, tree) end) |
|
192 |
| SOME (t, i) => |
|
193 |
raise CASE_ERROR ("Not a datatype constructor: " ^ Syntax.string_of_term ctxt t, i)) |
|
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
194 |
end |
43257
b81fd5c8f2dc
eliminated unnecessary tail-recursion and funny use of records as 'named arguments' for functions
krauss
parents:
43256
diff
changeset
|
195 |
| mk _ _ = raise CASE_ERROR ("Malformed row matrix", ~1) |
42049 | 196 |
in mk end; |
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
197 |
|
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
198 |
fun case_error s = error ("Error in case expression:\n" ^ s); |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
199 |
|
45889 | 200 |
local |
201 |
||
43255 | 202 |
(*Repeated variable occurrences in a pattern are not allowed.*) |
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
203 |
fun no_repeat_vars ctxt pat = fold_aterms |
45700 | 204 |
(fn x as Free (s, _) => |
45889 | 205 |
(fn xs => |
206 |
if member op aconv xs x then |
|
207 |
case_error (quote s ^ " occurs repeatedly in the pattern " ^ |
|
208 |
quote (Syntax.string_of_term ctxt pat)) |
|
209 |
else x :: xs) |
|
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
210 |
| _ => I) pat []; |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
211 |
|
45891
d73605c829cc
clarified module dependencies: Datatype_Data, Datatype_Case, Rep_Datatype;
wenzelm
parents:
45889
diff
changeset
|
212 |
fun gen_make_case ty_match ty_inst type_of ctxt config used x clauses = |
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
213 |
let |
35124 | 214 |
fun string_of_clause (pat, rhs) = |
215 |
Syntax.string_of_term ctxt (Syntax.const @{syntax_const "_case1"} $ pat $ rhs); |
|
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
216 |
val _ = map (no_repeat_vars ctxt o fst) clauses; |
45700 | 217 |
val rows = map_index (fn (i, (pat, rhs)) => (([], [pat]), (rhs, i))) clauses; |
35124 | 218 |
val rangeT = |
45700 | 219 |
(case distinct (op =) (map (type_of o snd) clauses) of |
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
220 |
[] => case_error "no clauses given" |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
221 |
| [T] => T |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
222 |
| _ => case_error "all cases must have the same result type"); |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
223 |
val used' = fold add_row_used rows used; |
45700 | 224 |
val (tags, case_tm) = |
45891
d73605c829cc
clarified module dependencies: Datatype_Data, Datatype_Case, Rep_Datatype;
wenzelm
parents:
45889
diff
changeset
|
225 |
mk_case ctxt ty_match ty_inst type_of used' rangeT [x] rows |
45700 | 226 |
handle CASE_ERROR (msg, i) => |
227 |
case_error |
|
228 |
(msg ^ (if i < 0 then "" else "\nIn clause\n" ^ string_of_clause (nth clauses i))); |
|
35124 | 229 |
val _ = |
43254 | 230 |
(case subtract (op =) tags (map (snd o snd) rows) of |
42049 | 231 |
[] => () |
232 |
| is => |
|
45700 | 233 |
(case config of Error => case_error | Warning => warning | Quiet => fn _ => ()) |
42049 | 234 |
("The following clauses are redundant (covered by preceding clauses):\n" ^ |
45700 | 235 |
cat_lines (map (string_of_clause o nth clauses) is))); |
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
236 |
in |
43253
fa3c61dc9f2c
removed generation of instantiated pattern set, which is never actually used
krauss
parents:
43252
diff
changeset
|
237 |
case_tm |
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
238 |
end; |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
239 |
|
45889 | 240 |
in |
241 |
||
45891
d73605c829cc
clarified module dependencies: Datatype_Data, Datatype_Case, Rep_Datatype;
wenzelm
parents:
45889
diff
changeset
|
242 |
fun make_case ctxt = |
45700 | 243 |
gen_make_case (match_type (Proof_Context.theory_of ctxt)) |
45891
d73605c829cc
clarified module dependencies: Datatype_Data, Datatype_Case, Rep_Datatype;
wenzelm
parents:
45889
diff
changeset
|
244 |
Envir.subst_term_types fastype_of ctxt; |
45700 | 245 |
|
246 |
val make_case_untyped = |
|
247 |
gen_make_case (K (K Vartab.empty)) (K (Term.map_types (K dummyT))) (K dummyT); |
|
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
248 |
|
45889 | 249 |
end; |
250 |
||
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
251 |
|
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
252 |
(* parse translation *) |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
253 |
|
45891
d73605c829cc
clarified module dependencies: Datatype_Data, Datatype_Case, Rep_Datatype;
wenzelm
parents:
45889
diff
changeset
|
254 |
fun case_tr err ctxt [t, u] = |
42049 | 255 |
let |
42361 | 256 |
val thy = Proof_Context.theory_of ctxt; |
257 |
val intern_const_syntax = Consts.intern_syntax (Proof_Context.consts_of ctxt); |
|
35256 | 258 |
|
42049 | 259 |
(* replace occurrences of dummy_pattern by distinct variables *) |
260 |
(* internalize constant names *) |
|
43324
2b47822868e4
discontinued Name.variant to emphasize that this is old-style / indirect;
wenzelm
parents:
43257
diff
changeset
|
261 |
(* FIXME proper name context!? *) |
42049 | 262 |
fun prep_pat ((c as Const (@{syntax_const "_constrain"}, _)) $ t $ tT) used = |
263 |
let val (t', used') = prep_pat t used |
|
264 |
in (c $ t' $ tT, used') end |
|
265 |
| prep_pat (Const (@{const_syntax dummy_pattern}, T)) used = |
|
43324
2b47822868e4
discontinued Name.variant to emphasize that this is old-style / indirect;
wenzelm
parents:
43257
diff
changeset
|
266 |
let val x = singleton (Name.variant_list used) "x" |
42049 | 267 |
in (Free (x, T), x :: used) end |
45700 | 268 |
| prep_pat (Const (s, T)) used = (Const (intern_const_syntax s, T), used) |
42049 | 269 |
| prep_pat (v as Free (s, T)) used = |
42361 | 270 |
let val s' = Proof_Context.intern_const ctxt s in |
45700 | 271 |
if Sign.declared_const thy s' then (Const (s', T), used) |
42049 | 272 |
else (v, used) |
273 |
end |
|
274 |
| prep_pat (t $ u) used = |
|
275 |
let |
|
276 |
val (t', used') = prep_pat t used; |
|
42359 | 277 |
val (u', used'') = prep_pat u used'; |
45700 | 278 |
in (t' $ u', used'') end |
42049 | 279 |
| prep_pat t used = case_error ("Bad pattern: " ^ Syntax.string_of_term ctxt t); |
280 |
fun dest_case1 (t as Const (@{syntax_const "_case1"}, _) $ l $ r) = |
|
281 |
let val (l', cnstrts) = strip_constraints l |
|
282 |
in ((fst (prep_pat l' (Term.add_free_names t [])), r), cnstrts) end |
|
283 |
| dest_case1 t = case_error "dest_case1"; |
|
284 |
fun dest_case2 (Const (@{syntax_const "_case2"}, _) $ t $ u) = t :: dest_case2 u |
|
285 |
| dest_case2 t = [t]; |
|
42057
3eba96ff3d3e
more selective strip_positions in case patterns -- reactivate translations based on "case _ of _" in HOL and special patterns in HOLCF;
wenzelm
parents:
42050
diff
changeset
|
286 |
val (cases, cnstrts) = split_list (map dest_case1 (dest_case2 u)); |
45700 | 287 |
val case_tm = |
45891
d73605c829cc
clarified module dependencies: Datatype_Data, Datatype_Case, Rep_Datatype;
wenzelm
parents:
45889
diff
changeset
|
288 |
make_case_untyped ctxt |
45700 | 289 |
(if err then Error else Warning) [] |
290 |
(fold (fn tT => fn t => Syntax.const @{syntax_const "_constrain"} $ t $ tT) |
|
291 |
(flat cnstrts) t) cases; |
|
42049 | 292 |
in case_tm end |
45894 | 293 |
| case_tr _ _ _ = case_error "case_tr"; |
45891
d73605c829cc
clarified module dependencies: Datatype_Data, Datatype_Case, Rep_Datatype;
wenzelm
parents:
45889
diff
changeset
|
294 |
|
d73605c829cc
clarified module dependencies: Datatype_Data, Datatype_Case, Rep_Datatype;
wenzelm
parents:
45889
diff
changeset
|
295 |
val trfun_setup = |
d73605c829cc
clarified module dependencies: Datatype_Data, Datatype_Case, Rep_Datatype;
wenzelm
parents:
45889
diff
changeset
|
296 |
Sign.add_advanced_trfuns ([], |
d73605c829cc
clarified module dependencies: Datatype_Data, Datatype_Case, Rep_Datatype;
wenzelm
parents:
45889
diff
changeset
|
297 |
[(@{syntax_const "_case_syntax"}, case_tr true)], |
d73605c829cc
clarified module dependencies: Datatype_Data, Datatype_Case, Rep_Datatype;
wenzelm
parents:
45889
diff
changeset
|
298 |
[], []); |
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
299 |
|
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
300 |
|
43255 | 301 |
(* Pretty printing of nested case expressions *) |
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
302 |
|
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
303 |
(* destruct one level of pattern matching *) |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
304 |
|
45889 | 305 |
local |
306 |
||
43324
2b47822868e4
discontinued Name.variant to emphasize that this is old-style / indirect;
wenzelm
parents:
43257
diff
changeset
|
307 |
(* FIXME proper name context!? *) |
45891
d73605c829cc
clarified module dependencies: Datatype_Data, Datatype_Case, Rep_Datatype;
wenzelm
parents:
45889
diff
changeset
|
308 |
fun gen_dest_case name_of type_of ctxt d used t = |
42049 | 309 |
(case apfst name_of (strip_comb t) of |
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
310 |
(SOME cname, ts as _ :: _) => |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
311 |
let |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
312 |
val (fs, x) = split_last ts; |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
313 |
fun strip_abs i t = |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
314 |
let |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
315 |
val zs = strip_abs_vars t; |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
316 |
val _ = if length zs < i then raise CASE_ERROR ("", 0) else (); |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
317 |
val (xs, ys) = chop i zs; |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
318 |
val u = list_abs (ys, strip_abs_body t); |
45700 | 319 |
val xs' = |
320 |
map Free |
|
321 |
(Name.variant_list (Misc_Legacy.add_term_names (u, used)) (map #1 xs) ~~ map #2 xs); |
|
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
322 |
in (xs', subst_bounds (rev xs', u)) end; |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
323 |
fun is_dependent i t = |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
324 |
let val k = length (strip_abs_vars t) - i |
42049 | 325 |
in k < 0 orelse exists (fn j => j >= k) (loose_bnos (strip_abs_body t)) end; |
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
326 |
fun count_cases (_, _, true) = I |
45700 | 327 |
| count_cases (c, (_, body), false) = AList.map_default op aconv (body, []) (cons c); |
35392
5da5ac6c6b77
gen_dest_case: recovered @{const_name} from c8a6fae0ad0c, because of separate Syntax.mark_const in case_tr' -- avoid extra syntax markers in output;
wenzelm
parents:
35363
diff
changeset
|
328 |
val is_undefined = name_of #> equal (SOME @{const_name undefined}); |
45700 | 329 |
fun mk_case (c, (xs, body), _) = (list_comb (c, xs), body); |
45894 | 330 |
val get_info = Datatype_Data.info_of_case (Proof_Context.theory_of ctxt); |
42049 | 331 |
in |
45894 | 332 |
(case Option.map ty_info (get_info cname) of |
333 |
SOME {constructors, ...} => |
|
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
334 |
if length fs = length constructors then |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
335 |
let |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
336 |
val cases = map (fn (Const (s, U), t) => |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
337 |
let |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
338 |
val k = length (binder_types U); |
45700 | 339 |
val p as (xs, _) = strip_abs k t; |
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
340 |
in |
45700 | 341 |
(Const (s, map type_of xs ---> type_of x), p, is_dependent k t) |
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
342 |
end) (constructors ~~ fs); |
45700 | 343 |
val cases' = |
344 |
sort (int_ord o swap o pairself (length o snd)) |
|
345 |
(fold_rev count_cases cases []); |
|
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
346 |
val R = type_of t; |
35124 | 347 |
val dummy = |
45156 | 348 |
if d then Term.dummy_pattern R |
43324
2b47822868e4
discontinued Name.variant to emphasize that this is old-style / indirect;
wenzelm
parents:
43257
diff
changeset
|
349 |
else Free (singleton (Name.variant_list used) "x", R); |
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
350 |
in |
42049 | 351 |
SOME (x, |
352 |
map mk_case |
|
353 |
(case find_first (is_undefined o fst) cases' of |
|
354 |
SOME (_, cs) => |
|
45700 | 355 |
if length cs = length constructors then [hd cases] |
356 |
else filter_out (fn (_, (_, body), _) => is_undefined body) cases |
|
357 |
| NONE => |
|
358 |
(case cases' of |
|
359 |
[] => cases |
|
360 |
| (default, cs) :: _ => |
|
361 |
if length cs = 1 then cases |
|
362 |
else if length cs = length constructors then |
|
363 |
[hd cases, (dummy, ([], default), false)] |
|
364 |
else |
|
365 |
filter_out (fn (c, _, _) => member op aconv cs c) cases @ |
|
366 |
[(dummy, ([], default), false)]))) |
|
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
367 |
end handle CASE_ERROR _ => NONE |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
368 |
else NONE |
42049 | 369 |
| _ => NONE) |
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
370 |
end |
42049 | 371 |
| _ => NONE); |
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
372 |
|
45889 | 373 |
in |
374 |
||
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
375 |
val dest_case = gen_dest_case (try (dest_Const #> fst)) fastype_of; |
42290
b1f544c84040
discontinued special treatment of structure Lexicon;
wenzelm
parents:
42284
diff
changeset
|
376 |
val dest_case' = gen_dest_case (try (dest_Const #> fst #> Lexicon.unmark_const)) (K dummyT); |
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
377 |
|
45889 | 378 |
end; |
379 |
||
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
380 |
|
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
381 |
(* destruct nested patterns *) |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
382 |
|
45889 | 383 |
local |
384 |
||
29623 | 385 |
fun strip_case'' dest (pat, rhs) = |
42049 | 386 |
(case dest (Term.add_free_names pat []) rhs of |
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
387 |
SOME (exp as Free _, clauses) => |
45738 | 388 |
if Term.exists_subterm (curry (op aconv) exp) pat andalso |
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
389 |
not (exists (fn (_, rhs') => |
45738 | 390 |
Term.exists_subterm (curry (op aconv) exp) rhs') clauses) |
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
391 |
then |
29623 | 392 |
maps (strip_case'' dest) (map (fn (pat', rhs') => |
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
393 |
(subst_free [(exp, pat')] pat, rhs')) clauses) |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
394 |
else [(pat, rhs)] |
42049 | 395 |
| _ => [(pat, rhs)]); |
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
396 |
|
35124 | 397 |
fun gen_strip_case dest t = |
42049 | 398 |
(case dest [] t of |
45700 | 399 |
SOME (x, clauses) => SOME (x, maps (strip_case'' dest) clauses) |
42049 | 400 |
| NONE => NONE); |
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
401 |
|
45889 | 402 |
in |
403 |
||
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
404 |
val strip_case = gen_strip_case oo dest_case; |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
405 |
val strip_case' = gen_strip_case oo dest_case'; |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
406 |
|
45889 | 407 |
end; |
408 |
||
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
409 |
|
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
410 |
(* print translation *) |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
411 |
|
45891
d73605c829cc
clarified module dependencies: Datatype_Data, Datatype_Case, Rep_Datatype;
wenzelm
parents:
45889
diff
changeset
|
412 |
fun case_tr' cname ctxt ts = |
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
413 |
let |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
414 |
fun mk_clause (pat, rhs) = |
42049 | 415 |
let val xs = Term.add_frees pat [] in |
35124 | 416 |
Syntax.const @{syntax_const "_case1"} $ |
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
417 |
map_aterms |
42284 | 418 |
(fn Free p => Syntax_Trans.mark_boundT p |
42290
b1f544c84040
discontinued special treatment of structure Lexicon;
wenzelm
parents:
42284
diff
changeset
|
419 |
| Const (s, _) => Syntax.const (Lexicon.mark_const s) |
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
420 |
| t => t) pat $ |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
421 |
map_aterms |
45700 | 422 |
(fn x as Free (s, T) => if member (op =) xs (s, T) then Syntax_Trans.mark_bound s else x |
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
423 |
| t => t) rhs |
42049 | 424 |
end; |
35124 | 425 |
in |
45891
d73605c829cc
clarified module dependencies: Datatype_Data, Datatype_Case, Rep_Datatype;
wenzelm
parents:
45889
diff
changeset
|
426 |
(case strip_case' ctxt true (list_comb (Syntax.const cname, ts)) of |
35124 | 427 |
SOME (x, clauses) => |
428 |
Syntax.const @{syntax_const "_case_syntax"} $ x $ |
|
429 |
foldr1 (fn (t, u) => Syntax.const @{syntax_const "_case2"} $ t $ u) |
|
430 |
(map mk_clause clauses) |
|
42049 | 431 |
| NONE => raise Match) |
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
432 |
end; |
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
433 |
|
45891
d73605c829cc
clarified module dependencies: Datatype_Data, Datatype_Case, Rep_Datatype;
wenzelm
parents:
45889
diff
changeset
|
434 |
fun add_case_tr' case_names thy = |
d73605c829cc
clarified module dependencies: Datatype_Data, Datatype_Case, Rep_Datatype;
wenzelm
parents:
45889
diff
changeset
|
435 |
Sign.add_advanced_trfuns ([], [], |
d73605c829cc
clarified module dependencies: Datatype_Data, Datatype_Case, Rep_Datatype;
wenzelm
parents:
45889
diff
changeset
|
436 |
map (fn case_name => |
d73605c829cc
clarified module dependencies: Datatype_Data, Datatype_Case, Rep_Datatype;
wenzelm
parents:
45889
diff
changeset
|
437 |
let val case_name' = Lexicon.mark_const case_name |
d73605c829cc
clarified module dependencies: Datatype_Data, Datatype_Case, Rep_Datatype;
wenzelm
parents:
45889
diff
changeset
|
438 |
in (case_name', case_tr' case_name') end) case_names, []) thy; |
d73605c829cc
clarified module dependencies: Datatype_Data, Datatype_Case, Rep_Datatype;
wenzelm
parents:
45889
diff
changeset
|
439 |
|
d73605c829cc
clarified module dependencies: Datatype_Data, Datatype_Case, Rep_Datatype;
wenzelm
parents:
45889
diff
changeset
|
440 |
|
d73605c829cc
clarified module dependencies: Datatype_Data, Datatype_Case, Rep_Datatype;
wenzelm
parents:
45889
diff
changeset
|
441 |
(* theory setup *) |
d73605c829cc
clarified module dependencies: Datatype_Data, Datatype_Case, Rep_Datatype;
wenzelm
parents:
45889
diff
changeset
|
442 |
|
d73605c829cc
clarified module dependencies: Datatype_Data, Datatype_Case, Rep_Datatype;
wenzelm
parents:
45889
diff
changeset
|
443 |
val setup = trfun_setup; |
d73605c829cc
clarified module dependencies: Datatype_Data, Datatype_Case, Rep_Datatype;
wenzelm
parents:
45889
diff
changeset
|
444 |
|
22779
9ac0ca736969
Parse / print translations for nested case expressions, taken
berghofe
parents:
diff
changeset
|
445 |
end; |