equal
deleted
inserted
replaced
297 let val Ts = map (typ_of_dtyp descr' sorts) cargs |
297 let val Ts = map (typ_of_dtyp descr' sorts) cargs |
298 in Ts ---> freeT end) constrs) (hd descr); |
298 in Ts ---> freeT end) constrs) (hd descr); |
299 |
299 |
300 val case_names = map (fn s => (s ^ "_case")) new_type_names; |
300 val case_names = map (fn s => (s ^ "_case")) new_type_names; |
301 |
301 |
302 val thy2 = thy |> |
302 val thy2' = thy |> |
303 |
303 |
304 (** new types **) |
304 (** new types **) |
305 |
305 |
306 curry (foldr (fn (((name, mx), tvs), thy') => thy' |> |
306 curry (foldr (fn (((name, mx), tvs), thy') => thy' |> |
307 PureThy.add_typedecls [(name, tvs, mx)] |> |
307 PureThy.add_typedecls [(name, tvs, mx)] |> |
321 (** case combinators **) |
321 (** case combinators **) |
322 |
322 |
323 Theory.add_consts_i (map (fn ((name, T), Ts) => |
323 Theory.add_consts_i (map (fn ((name, T), Ts) => |
324 (name, Ts @ [T] ---> freeT, NoSyn)) |
324 (name, Ts @ [T] ---> freeT, NoSyn)) |
325 (case_names ~~ newTs ~~ case_fn_Ts)) |> |
325 (case_names ~~ newTs ~~ case_fn_Ts)) |> |
326 Theory.add_trrules_i (DatatypeProp.make_case_trrules new_type_names descr) |> |
326 Theory.add_trrules_i (DatatypeProp.make_case_trrules new_type_names descr); |
|
327 |
|
328 val reccomb_names' = map (Sign.intern_const (sign_of thy2')) reccomb_names; |
|
329 val case_names' = map (Sign.intern_const (sign_of thy2')) case_names; |
|
330 |
|
331 val thy2 = thy2' |> |
327 |
332 |
328 (** t_ord functions **) |
333 (** t_ord functions **) |
329 |
334 |
330 Theory.add_consts_i |
335 Theory.add_consts_i |
331 (foldr (fn ((((_, (_, _, constrs)), tname), T), decls) => |
336 (foldr (fn ((((_, (_, _, constrs)), tname), T), decls) => |
381 val (thy9, nchotomys) = add_and_get_axioms "nchotomy" new_type_names |
386 val (thy9, nchotomys) = add_and_get_axioms "nchotomy" new_type_names |
382 (DatatypeProp.make_nchotomys descr sorts) thy8; |
387 (DatatypeProp.make_nchotomys descr sorts) thy8; |
383 val (thy10, case_congs) = add_and_get_axioms "case_cong" new_type_names |
388 val (thy10, case_congs) = add_and_get_axioms "case_cong" new_type_names |
384 (DatatypeProp.make_case_congs new_type_names descr sorts thy9) thy9; |
389 (DatatypeProp.make_case_congs new_type_names descr sorts thy9) thy9; |
385 |
390 |
386 val dt_infos = map (make_dt_info descr' induct reccomb_names rec_thms) |
391 val dt_infos = map (make_dt_info descr' induct reccomb_names' rec_thms) |
387 ((0 upto length (hd descr) - 1) ~~ (hd descr) ~~ case_names ~~ case_thms ~~ |
392 ((0 upto length (hd descr) - 1) ~~ (hd descr) ~~ case_names' ~~ case_thms ~~ |
388 exhaustion ~~ distinct ~~ inject ~~ nchotomys ~~ case_congs); |
393 exhaustion ~~ distinct ~~ inject ~~ nchotomys ~~ case_congs); |
389 |
394 |
390 val simps = flat (distinct @ inject @ case_thms) @ size_thms @ rec_thms; |
395 val simps = flat (distinct @ inject @ case_thms) @ size_thms @ rec_thms; |
391 |
396 |
392 val thy11 = thy10 |> |
397 val thy11 = thy10 |> |