author | blanchet |
Wed, 25 Sep 2013 14:28:10 +0200 | |
changeset 53879 | 87941795956c |
parent 53878 | eb3075935edf |
child 53887 | ee91bd2a506a |
permissions | -rw-r--r-- |
53303
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
1 |
(* Title: HOL/BNF/Tools/bnf_fp_rec_sugar_util.ML |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
2 |
Author: Lorenz Panny, TU Muenchen |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
3 |
Author: Jasmin Blanchette, TU Muenchen |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
4 |
Copyright 2013 |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
5 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
6 |
Library for recursor and corecursor sugar. |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
7 |
*) |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
8 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
9 |
signature BNF_FP_REC_SUGAR_UTIL = |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
10 |
sig |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
11 |
datatype rec_call = |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
12 |
No_Rec of int | |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
13 |
Direct_Rec of int (*before*) * int (*after*) | |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
14 |
Indirect_Rec of int |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
15 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
16 |
datatype corec_call = |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
17 |
Dummy_No_Corec of int | |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
18 |
No_Corec of int | |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
19 |
Direct_Corec of int (*stop?*) * int (*end*) * int (*continue*) | |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
20 |
Indirect_Corec of int |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
21 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
22 |
type rec_ctr_spec = |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
23 |
{ctr: term, |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
24 |
offset: int, |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
25 |
calls: rec_call list, |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
26 |
rec_thm: thm} |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
27 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
28 |
type corec_ctr_spec = |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
29 |
{ctr: term, |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
30 |
disc: term, |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
31 |
sels: term list, |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
32 |
pred: int option, |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
33 |
calls: corec_call list, |
53705 | 34 |
discI: thm, |
35 |
sel_thms: thm list, |
|
53475 | 36 |
collapse: thm, |
37 |
corec_thm: thm, |
|
38 |
disc_corec: thm, |
|
39 |
sel_corecs: thm list} |
|
53303
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
40 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
41 |
type rec_spec = |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
42 |
{recx: term, |
53329 | 43 |
nested_map_idents: thm list, |
53303
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
44 |
nested_map_comps: thm list, |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
45 |
ctr_specs: rec_ctr_spec list} |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
46 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
47 |
type corec_spec = |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
48 |
{corec: term, |
53475 | 49 |
nested_maps: thm list, |
50 |
nested_map_idents: thm list, |
|
51 |
nested_map_comps: thm list, |
|
53303
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
52 |
ctr_specs: corec_ctr_spec list} |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
53 |
|
53871 | 54 |
val s_not: term -> term |
53878 | 55 |
val mk_conjs: term list -> term |
56 |
val mk_disjs: term list -> term |
|
57 |
val s_not_disj: term -> term list |
|
58 |
val negate_conj: term list -> term list |
|
59 |
val negate_disj: term list -> term list |
|
60 |
||
53303
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
61 |
val massage_indirect_rec_call: Proof.context -> (term -> bool) -> (typ -> typ -> term -> term) -> |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
62 |
typ list -> term -> term -> term -> term |
53835
687116951569
started adding support for "nat_case" as case study for all "case" constructs
blanchet
parents:
53833
diff
changeset
|
63 |
val massage_direct_corec_call: Proof.context -> (term -> bool) -> (term -> term) -> typ list -> |
687116951569
started adding support for "nat_case" as case study for all "case" constructs
blanchet
parents:
53833
diff
changeset
|
64 |
typ -> term -> term |
53303
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
65 |
val massage_indirect_corec_call: Proof.context -> (term -> bool) -> |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
66 |
(typ -> typ -> term -> term) -> typ list -> typ -> term -> term |
53727
1d88a7ee4e3e
split functionality into two functions to avoid redoing work over and over
blanchet
parents:
53726
diff
changeset
|
67 |
val expand_corec_code_rhs: Proof.context -> (term -> bool) -> typ list -> term -> term |
53835
687116951569
started adding support for "nat_case" as case study for all "case" constructs
blanchet
parents:
53833
diff
changeset
|
68 |
val massage_corec_code_rhs: Proof.context -> (term -> term list -> term) -> typ list -> typ -> |
687116951569
started adding support for "nat_case" as case study for all "case" constructs
blanchet
parents:
53833
diff
changeset
|
69 |
term -> term |
53871 | 70 |
val fold_rev_corec_code_rhs: Proof.context -> (term list -> term -> term list -> 'a -> 'a) -> |
71 |
typ list -> term -> 'a -> 'a |
|
53878 | 72 |
|
53303
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
73 |
val rec_specs_of: binding list -> typ list -> typ list -> (term -> int list) -> |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
74 |
((term * term list list) list) list -> local_theory -> |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
75 |
(bool * rec_spec list * typ list * thm * thm list) * local_theory |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
76 |
val corec_specs_of: binding list -> typ list -> typ list -> (term -> int list) -> |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
77 |
((term * term list list) list) list -> local_theory -> |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
78 |
(bool * corec_spec list * typ list * thm * thm * thm list * thm list) * local_theory |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
79 |
end; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
80 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
81 |
structure BNF_FP_Rec_Sugar_Util : BNF_FP_REC_SUGAR_UTIL = |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
82 |
struct |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
83 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
84 |
open BNF_Util |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
85 |
open BNF_Def |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
86 |
open BNF_Ctr_Sugar |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
87 |
open BNF_FP_Util |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
88 |
open BNF_FP_Def_Sugar |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
89 |
open BNF_FP_N2M_Sugar |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
90 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
91 |
datatype rec_call = |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
92 |
No_Rec of int | |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
93 |
Direct_Rec of int * int | |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
94 |
Indirect_Rec of int; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
95 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
96 |
datatype corec_call = |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
97 |
Dummy_No_Corec of int | |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
98 |
No_Corec of int | |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
99 |
Direct_Corec of int * int * int | |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
100 |
Indirect_Corec of int; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
101 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
102 |
type rec_ctr_spec = |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
103 |
{ctr: term, |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
104 |
offset: int, |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
105 |
calls: rec_call list, |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
106 |
rec_thm: thm}; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
107 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
108 |
type corec_ctr_spec = |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
109 |
{ctr: term, |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
110 |
disc: term, |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
111 |
sels: term list, |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
112 |
pred: int option, |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
113 |
calls: corec_call list, |
53705 | 114 |
discI: thm, |
115 |
sel_thms: thm list, |
|
53475 | 116 |
collapse: thm, |
117 |
corec_thm: thm, |
|
118 |
disc_corec: thm, |
|
119 |
sel_corecs: thm list}; |
|
53303
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
120 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
121 |
type rec_spec = |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
122 |
{recx: term, |
53329 | 123 |
nested_map_idents: thm list, |
53303
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
124 |
nested_map_comps: thm list, |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
125 |
ctr_specs: rec_ctr_spec list}; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
126 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
127 |
type corec_spec = |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
128 |
{corec: term, |
53475 | 129 |
nested_maps: thm list, |
130 |
nested_map_idents: thm list, |
|
131 |
nested_map_comps: thm list, |
|
53303
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
132 |
ctr_specs: corec_ctr_spec list}; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
133 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
134 |
val id_def = @{thm id_def}; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
135 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
136 |
exception AINT_NO_MAP of term; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
137 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
138 |
fun ill_formed_rec_call ctxt t = |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
139 |
error ("Ill-formed recursive call: " ^ quote (Syntax.string_of_term ctxt t)); |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
140 |
fun ill_formed_corec_call ctxt t = |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
141 |
error ("Ill-formed corecursive call: " ^ quote (Syntax.string_of_term ctxt t)); |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
142 |
fun invalid_map ctxt t = |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
143 |
error ("Invalid map function in " ^ quote (Syntax.string_of_term ctxt t)); |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
144 |
fun unexpected_rec_call ctxt t = |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
145 |
error ("Unexpected recursive call: " ^ quote (Syntax.string_of_term ctxt t)); |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
146 |
fun unexpected_corec_call ctxt t = |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
147 |
error ("Unexpected corecursive call: " ^ quote (Syntax.string_of_term ctxt t)); |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
148 |
|
53871 | 149 |
fun s_not @{const True} = @{const False} |
150 |
| s_not @{const False} = @{const True} |
|
151 |
| s_not (@{const Not} $ t) = t |
|
53878 | 152 |
(* TODO: is the next case really needed? *) |
53871 | 153 |
| s_not (@{const Trueprop} $ t) = @{const Trueprop} $ s_not t |
154 |
| s_not t = HOLogic.mk_not t |
|
155 |
||
53878 | 156 |
val mk_conjs = try (foldr1 HOLogic.mk_conj) #> the_default @{const True}; |
157 |
val mk_disjs = try (foldr1 HOLogic.mk_disj) #> the_default @{const False}; |
|
158 |
||
159 |
val s_not_disj = map s_not o HOLogic.disjuncts; |
|
160 |
||
161 |
fun negate_conj [t] = s_not_disj t |
|
162 |
| negate_conj ts = [mk_disjs (map s_not ts)]; |
|
163 |
||
164 |
fun negate_disj [t] = s_not_disj t |
|
165 |
| negate_disj ts = [mk_disjs (map (mk_conjs o s_not_disj) ts)]; |
|
166 |
||
53303
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
167 |
fun factor_out_types ctxt massage destU U T = |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
168 |
(case try destU U of |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
169 |
SOME (U1, U2) => if U1 = T then massage T U2 else invalid_map ctxt |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
170 |
| NONE => invalid_map ctxt); |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
171 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
172 |
fun map_flattened_map_args ctxt s map_args fs = |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
173 |
let |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
174 |
val flat_fs = flatten_type_args_of_bnf (the (bnf_of ctxt s)) Term.dummy fs; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
175 |
val flat_fs' = map_args flat_fs; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
176 |
in |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
177 |
permute_like (op aconv) flat_fs fs flat_fs' |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
178 |
end; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
179 |
|
53734
7613573f023a
avoid infinite loop for unapplied terms + tuning
blanchet
parents:
53732
diff
changeset
|
180 |
fun massage_indirect_rec_call ctxt has_call raw_massage_fun bound_Ts y y' = |
53303
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
181 |
let |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
182 |
val typof = curry fastype_of1 bound_Ts; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
183 |
val build_map_fst = build_map ctxt (fst_const o fst); |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
184 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
185 |
val yT = typof y; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
186 |
val yU = typof y'; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
187 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
188 |
fun y_of_y' () = build_map_fst (yU, yT) $ y'; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
189 |
val elim_y = Term.map_aterms (fn t => if t = y then y_of_y' () else t); |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
190 |
|
53734
7613573f023a
avoid infinite loop for unapplied terms + tuning
blanchet
parents:
53732
diff
changeset
|
191 |
fun massage_direct_fun U T t = |
7613573f023a
avoid infinite loop for unapplied terms + tuning
blanchet
parents:
53732
diff
changeset
|
192 |
if has_call t then factor_out_types ctxt raw_massage_fun HOLogic.dest_prodT U T t |
7613573f023a
avoid infinite loop for unapplied terms + tuning
blanchet
parents:
53732
diff
changeset
|
193 |
else HOLogic.mk_comp (t, build_map_fst (U, T)); |
53303
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
194 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
195 |
fun massage_map (Type (_, Us)) (Type (s, Ts)) t = |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
196 |
(case try (dest_map ctxt s) t of |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
197 |
SOME (map0, fs) => |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
198 |
let |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
199 |
val Type (_, ran_Ts) = range_type (typof t); |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
200 |
val map' = mk_map (length fs) Us ran_Ts map0; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
201 |
val fs' = map_flattened_map_args ctxt s (map3 massage_map_or_map_arg Us Ts) fs; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
202 |
in |
53870 | 203 |
Term.list_comb (map', fs') |
53303
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
204 |
end |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
205 |
| NONE => raise AINT_NO_MAP t) |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
206 |
| massage_map _ _ t = raise AINT_NO_MAP t |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
207 |
and massage_map_or_map_arg U T t = |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
208 |
if T = U then |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
209 |
if has_call t then unexpected_rec_call ctxt t else t |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
210 |
else |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
211 |
massage_map U T t |
53734
7613573f023a
avoid infinite loop for unapplied terms + tuning
blanchet
parents:
53732
diff
changeset
|
212 |
handle AINT_NO_MAP _ => massage_direct_fun U T t; |
53303
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
213 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
214 |
fun massage_call (t as t1 $ t2) = |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
215 |
if t2 = y then |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
216 |
massage_map yU yT (elim_y t1) $ y' |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
217 |
handle AINT_NO_MAP t' => invalid_map ctxt t' |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
218 |
else |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
219 |
ill_formed_rec_call ctxt t |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
220 |
| massage_call t = if t = y then y_of_y' () else ill_formed_rec_call ctxt t; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
221 |
in |
53724 | 222 |
massage_call |
53303
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
223 |
end; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
224 |
|
53866 | 225 |
fun fold_rev_let_if_case ctxt f bound_Ts = |
226 |
let |
|
53870 | 227 |
val thy = Proof_Context.theory_of ctxt; |
228 |
||
53871 | 229 |
fun fld conds t = |
53866 | 230 |
(case Term.strip_comb t of |
53871 | 231 |
(Const (@{const_name Let}, _), [arg1, arg2]) => fld conds (betapply (arg2, arg1)) |
232 |
| (Const (@{const_name If}, _), [cond, then_branch, else_branch]) => |
|
53879 | 233 |
fld (conds @ conjuncts cond) then_branch |
234 |
o fld (conds @ s_not_disj cond) else_branch |
|
53866 | 235 |
| (Const (c, _), args as _ :: _) => |
53870 | 236 |
let val n = num_binder_types (Sign.the_const_type thy c) in |
237 |
(case fastype_of1 (bound_Ts, nth args (n - 1)) of |
|
238 |
Type (s, Ts) => |
|
239 |
(case dest_case ctxt s Ts t of |
|
53871 | 240 |
NONE => f conds t |
241 |
| SOME (conds', branches) => |
|
53879 | 242 |
fold_rev (uncurry fld) (map (append conds o conjuncts) conds' ~~ branches)) |
53871 | 243 |
| _ => f conds t) |
53866 | 244 |
end |
53871 | 245 |
| _ => f conds t) |
53866 | 246 |
in |
53871 | 247 |
fld [] |
53866 | 248 |
end; |
249 |
||
53870 | 250 |
fun case_of ctxt = ctr_sugar_of ctxt #> Option.map (fst o dest_Const o #casex); |
251 |
||
53866 | 252 |
fun massage_let_if_case ctxt has_call massage_leaf bound_Ts U = |
53723 | 253 |
let |
53835
687116951569
started adding support for "nat_case" as case study for all "case" constructs
blanchet
parents:
53833
diff
changeset
|
254 |
val typof = curry fastype_of1 bound_Ts; |
687116951569
started adding support for "nat_case" as case study for all "case" constructs
blanchet
parents:
53833
diff
changeset
|
255 |
val check_obj = ((not o has_call) orf unexpected_corec_call ctxt); |
687116951569
started adding support for "nat_case" as case study for all "case" constructs
blanchet
parents:
53833
diff
changeset
|
256 |
|
53725 | 257 |
fun massage_rec t = |
53723 | 258 |
(case Term.strip_comb t of |
53725 | 259 |
(Const (@{const_name Let}, _), [arg1, arg2]) => massage_rec (betapply (arg2, arg1)) |
53835
687116951569
started adding support for "nat_case" as case study for all "case" constructs
blanchet
parents:
53833
diff
changeset
|
260 |
| (Const (@{const_name If}, _), obj :: branches) => |
53870 | 261 |
Term.list_comb (If_const U $ tap check_obj obj, map massage_rec branches) |
53866 | 262 |
| (Const (c, _), args as _ :: _) => |
263 |
let val (branches, obj) = split_last args in |
|
264 |
(case fastype_of1 (bound_Ts, obj) of |
|
265 |
Type (T_name, _) => |
|
266 |
if case_of ctxt T_name = SOME c then |
|
267 |
let |
|
268 |
val branches' = map massage_rec branches; |
|
269 |
val casex' = Const (c, map typof branches' ---> typof obj); |
|
270 |
in |
|
53870 | 271 |
Term.list_comb (casex', branches') $ tap check_obj obj |
53866 | 272 |
end |
273 |
else |
|
274 |
massage_leaf t |
|
275 |
| _ => massage_leaf t) |
|
53835
687116951569
started adding support for "nat_case" as case study for all "case" constructs
blanchet
parents:
53833
diff
changeset
|
276 |
end |
53725 | 277 |
| _ => massage_leaf t) |
53723 | 278 |
in |
279 |
massage_rec |
|
280 |
end; |
|
53303
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
281 |
|
53866 | 282 |
val massage_direct_corec_call = massage_let_if_case; |
53303
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
283 |
|
53734
7613573f023a
avoid infinite loop for unapplied terms + tuning
blanchet
parents:
53732
diff
changeset
|
284 |
fun massage_indirect_corec_call ctxt has_call raw_massage_call bound_Ts U t = |
53303
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
285 |
let |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
286 |
val typof = curry fastype_of1 bound_Ts; |
53411 | 287 |
val build_map_Inl = build_map ctxt (uncurry Inl_const o dest_sumT o snd) |
53303
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
288 |
|
53734
7613573f023a
avoid infinite loop for unapplied terms + tuning
blanchet
parents:
53732
diff
changeset
|
289 |
fun massage_direct_call U T t = |
7613573f023a
avoid infinite loop for unapplied terms + tuning
blanchet
parents:
53732
diff
changeset
|
290 |
if has_call t then factor_out_types ctxt raw_massage_call dest_sumT U T t |
53411 | 291 |
else build_map_Inl (T, U) $ t; |
53303
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
292 |
|
53734
7613573f023a
avoid infinite loop for unapplied terms + tuning
blanchet
parents:
53732
diff
changeset
|
293 |
fun massage_direct_fun U T t = |
53303
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
294 |
let val var = Var ((Name.uu, Term.maxidx_of_term t + 1), domain_type (typof t)) in |
53734
7613573f023a
avoid infinite loop for unapplied terms + tuning
blanchet
parents:
53732
diff
changeset
|
295 |
Term.lambda var (massage_direct_call U T (t $ var)) |
53303
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
296 |
end; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
297 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
298 |
fun massage_map (Type (_, Us)) (Type (s, Ts)) t = |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
299 |
(case try (dest_map ctxt s) t of |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
300 |
SOME (map0, fs) => |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
301 |
let |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
302 |
val Type (_, dom_Ts) = domain_type (typof t); |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
303 |
val map' = mk_map (length fs) dom_Ts Us map0; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
304 |
val fs' = map_flattened_map_args ctxt s (map3 massage_map_or_map_arg Us Ts) fs; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
305 |
in |
53870 | 306 |
Term.list_comb (map', fs') |
53303
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
307 |
end |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
308 |
| NONE => raise AINT_NO_MAP t) |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
309 |
| massage_map _ _ t = raise AINT_NO_MAP t |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
310 |
and massage_map_or_map_arg U T t = |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
311 |
if T = U then |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
312 |
if has_call t then unexpected_corec_call ctxt t else t |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
313 |
else |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
314 |
massage_map U T t |
53734
7613573f023a
avoid infinite loop for unapplied terms + tuning
blanchet
parents:
53732
diff
changeset
|
315 |
handle AINT_NO_MAP _ => massage_direct_fun U T t; |
53303
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
316 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
317 |
fun massage_call U T = |
53866 | 318 |
massage_let_if_case ctxt has_call (fn t => |
53732
e2c0d0426d2b
give lambda abstractions a chance, as an alternative to function composition, for corecursion via "fun"
blanchet
parents:
53731
diff
changeset
|
319 |
if has_call t then |
e2c0d0426d2b
give lambda abstractions a chance, as an alternative to function composition, for corecursion via "fun"
blanchet
parents:
53731
diff
changeset
|
320 |
(case U of |
e2c0d0426d2b
give lambda abstractions a chance, as an alternative to function composition, for corecursion via "fun"
blanchet
parents:
53731
diff
changeset
|
321 |
Type (s, Us) => |
e2c0d0426d2b
give lambda abstractions a chance, as an alternative to function composition, for corecursion via "fun"
blanchet
parents:
53731
diff
changeset
|
322 |
(case try (dest_ctr ctxt s) t of |
e2c0d0426d2b
give lambda abstractions a chance, as an alternative to function composition, for corecursion via "fun"
blanchet
parents:
53731
diff
changeset
|
323 |
SOME (f, args) => |
e2c0d0426d2b
give lambda abstractions a chance, as an alternative to function composition, for corecursion via "fun"
blanchet
parents:
53731
diff
changeset
|
324 |
let val f' = mk_ctr Us f in |
53870 | 325 |
Term.list_comb (f', |
326 |
map3 massage_call (binder_types (typof f')) (map typof args) args) |
|
53732
e2c0d0426d2b
give lambda abstractions a chance, as an alternative to function composition, for corecursion via "fun"
blanchet
parents:
53731
diff
changeset
|
327 |
end |
e2c0d0426d2b
give lambda abstractions a chance, as an alternative to function composition, for corecursion via "fun"
blanchet
parents:
53731
diff
changeset
|
328 |
| NONE => |
e2c0d0426d2b
give lambda abstractions a chance, as an alternative to function composition, for corecursion via "fun"
blanchet
parents:
53731
diff
changeset
|
329 |
(case t of |
e2c0d0426d2b
give lambda abstractions a chance, as an alternative to function composition, for corecursion via "fun"
blanchet
parents:
53731
diff
changeset
|
330 |
t1 $ t2 => |
e2c0d0426d2b
give lambda abstractions a chance, as an alternative to function composition, for corecursion via "fun"
blanchet
parents:
53731
diff
changeset
|
331 |
(if has_call t2 then |
53734
7613573f023a
avoid infinite loop for unapplied terms + tuning
blanchet
parents:
53732
diff
changeset
|
332 |
massage_direct_call U T t |
53732
e2c0d0426d2b
give lambda abstractions a chance, as an alternative to function composition, for corecursion via "fun"
blanchet
parents:
53731
diff
changeset
|
333 |
else |
e2c0d0426d2b
give lambda abstractions a chance, as an alternative to function composition, for corecursion via "fun"
blanchet
parents:
53731
diff
changeset
|
334 |
massage_map U T t1 $ t2 |
53734
7613573f023a
avoid infinite loop for unapplied terms + tuning
blanchet
parents:
53732
diff
changeset
|
335 |
handle AINT_NO_MAP _ => massage_direct_call U T t) |
53732
e2c0d0426d2b
give lambda abstractions a chance, as an alternative to function composition, for corecursion via "fun"
blanchet
parents:
53731
diff
changeset
|
336 |
| Abs (s, T', t') => Abs (s, T', massage_call (range_type U) (range_type T) t') |
53734
7613573f023a
avoid infinite loop for unapplied terms + tuning
blanchet
parents:
53732
diff
changeset
|
337 |
| _ => massage_direct_call U T t)) |
53732
e2c0d0426d2b
give lambda abstractions a chance, as an alternative to function composition, for corecursion via "fun"
blanchet
parents:
53731
diff
changeset
|
338 |
| _ => ill_formed_corec_call ctxt t) |
e2c0d0426d2b
give lambda abstractions a chance, as an alternative to function composition, for corecursion via "fun"
blanchet
parents:
53731
diff
changeset
|
339 |
else |
53835
687116951569
started adding support for "nat_case" as case study for all "case" constructs
blanchet
parents:
53833
diff
changeset
|
340 |
build_map_Inl (T, U) $ t) bound_Ts U |
53303
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
341 |
in |
53725 | 342 |
massage_call U (typof t) t |
53303
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
343 |
end; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
344 |
|
53727
1d88a7ee4e3e
split functionality into two functions to avoid redoing work over and over
blanchet
parents:
53726
diff
changeset
|
345 |
fun expand_ctr_term ctxt s Ts t = |
53867
8ad44ecc0d15
keep a database of free constructor type information
blanchet
parents:
53866
diff
changeset
|
346 |
(case ctr_sugar_of ctxt s of |
53870 | 347 |
SOME {ctrs, casex, ...} => |
348 |
Term.list_comb (mk_case Ts (Type (s, Ts)) casex, map (mk_ctr Ts) ctrs) $ t |
|
53727
1d88a7ee4e3e
split functionality into two functions to avoid redoing work over and over
blanchet
parents:
53726
diff
changeset
|
349 |
| NONE => raise Fail "expand_ctr_term"); |
53726
d41a30db83d9
added massaging function for primcorec code equations
blanchet
parents:
53725
diff
changeset
|
350 |
|
53727
1d88a7ee4e3e
split functionality into two functions to avoid redoing work over and over
blanchet
parents:
53726
diff
changeset
|
351 |
fun expand_corec_code_rhs ctxt has_call bound_Ts t = |
1d88a7ee4e3e
split functionality into two functions to avoid redoing work over and over
blanchet
parents:
53726
diff
changeset
|
352 |
(case fastype_of1 (bound_Ts, t) of |
1d88a7ee4e3e
split functionality into two functions to avoid redoing work over and over
blanchet
parents:
53726
diff
changeset
|
353 |
T as Type (s, Ts) => |
53866 | 354 |
massage_let_if_case ctxt has_call (fn t => |
355 |
if can (dest_ctr ctxt s) t then |
|
356 |
t |
|
357 |
else |
|
358 |
massage_let_if_case ctxt has_call I bound_Ts T (expand_ctr_term ctxt s Ts t)) bound_Ts T t |
|
53727
1d88a7ee4e3e
split functionality into two functions to avoid redoing work over and over
blanchet
parents:
53726
diff
changeset
|
359 |
| _ => raise Fail "expand_corec_code_rhs"); |
1d88a7ee4e3e
split functionality into two functions to avoid redoing work over and over
blanchet
parents:
53726
diff
changeset
|
360 |
|
1d88a7ee4e3e
split functionality into two functions to avoid redoing work over and over
blanchet
parents:
53726
diff
changeset
|
361 |
fun massage_corec_code_rhs ctxt massage_ctr = |
53866 | 362 |
massage_let_if_case ctxt (K false) (uncurry massage_ctr o Term.strip_comb); |
53865 | 363 |
|
53871 | 364 |
fun fold_rev_corec_code_rhs ctxt f = |
365 |
fold_rev_let_if_case ctxt (fn conds => uncurry (f conds) o Term.strip_comb); |
|
53731 | 366 |
|
53303
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
367 |
fun indexed xs h = let val h' = h + length xs in (h upto h' - 1, h') end; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
368 |
fun indexedd xss = fold_map indexed xss; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
369 |
fun indexeddd xsss = fold_map indexedd xsss; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
370 |
fun indexedddd xssss = fold_map indexeddd xssss; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
371 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
372 |
fun find_index_eq hs h = find_index (curry (op =) h) hs; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
373 |
|
53476
eb3865c3ee58
include map theorems in datastructure for "primcorec"
blanchet
parents:
53475
diff
changeset
|
374 |
(*FIXME: remove special cases for products and sum once they are registered as datatypes*) |
eb3865c3ee58
include map theorems in datastructure for "primcorec"
blanchet
parents:
53475
diff
changeset
|
375 |
fun map_thms_of_typ ctxt (Type (s, _)) = |
eb3865c3ee58
include map theorems in datastructure for "primcorec"
blanchet
parents:
53475
diff
changeset
|
376 |
if s = @{type_name prod} then |
eb3865c3ee58
include map theorems in datastructure for "primcorec"
blanchet
parents:
53475
diff
changeset
|
377 |
@{thms map_pair_simp} |
eb3865c3ee58
include map theorems in datastructure for "primcorec"
blanchet
parents:
53475
diff
changeset
|
378 |
else if s = @{type_name sum} then |
eb3865c3ee58
include map theorems in datastructure for "primcorec"
blanchet
parents:
53475
diff
changeset
|
379 |
@{thms sum_map.simps} |
eb3865c3ee58
include map theorems in datastructure for "primcorec"
blanchet
parents:
53475
diff
changeset
|
380 |
else |
eb3865c3ee58
include map theorems in datastructure for "primcorec"
blanchet
parents:
53475
diff
changeset
|
381 |
(case fp_sugar_of ctxt s of |
eb3865c3ee58
include map theorems in datastructure for "primcorec"
blanchet
parents:
53475
diff
changeset
|
382 |
SOME {index, mapss, ...} => nth mapss index |
eb3865c3ee58
include map theorems in datastructure for "primcorec"
blanchet
parents:
53475
diff
changeset
|
383 |
| NONE => []) |
eb3865c3ee58
include map theorems in datastructure for "primcorec"
blanchet
parents:
53475
diff
changeset
|
384 |
| map_thms_of_typ _ _ = []; |
eb3865c3ee58
include map theorems in datastructure for "primcorec"
blanchet
parents:
53475
diff
changeset
|
385 |
|
53303
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
386 |
val lose_co_rec = false (*FIXME: try true?*); |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
387 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
388 |
fun rec_specs_of bs arg_Ts res_Ts get_indices callssss0 lthy = |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
389 |
let |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
390 |
val thy = Proof_Context.theory_of lthy; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
391 |
|
53746
bd038e48526d
have "datatype_new_compat" register induction and recursion theorems in nested case
blanchet
parents:
53741
diff
changeset
|
392 |
val ((missing_arg_Ts, perm0_kks, |
53303
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
393 |
fp_sugars as {nested_bnfs, fp_res = {xtor_co_iterss = ctor_iters1 :: _, ...}, |
53746
bd038e48526d
have "datatype_new_compat" register induction and recursion theorems in nested case
blanchet
parents:
53741
diff
changeset
|
394 |
co_inducts = [induct_thm], ...} :: _, (lfp_sugar_thms, _)), lthy') = |
53303
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
395 |
nested_to_mutual_fps lose_co_rec Least_FP bs arg_Ts get_indices callssss0 lthy; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
396 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
397 |
val perm_fp_sugars = sort (int_ord o pairself #index) fp_sugars; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
398 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
399 |
val indices = map #index fp_sugars; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
400 |
val perm_indices = map #index perm_fp_sugars; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
401 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
402 |
val perm_ctrss = map (#ctrs o of_fp_sugar #ctr_sugars) perm_fp_sugars; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
403 |
val perm_ctr_Tsss = map (map (binder_types o fastype_of)) perm_ctrss; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
404 |
val perm_fpTs = map (body_type o fastype_of o hd) perm_ctrss; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
405 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
406 |
val nn0 = length arg_Ts; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
407 |
val nn = length perm_fpTs; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
408 |
val kks = 0 upto nn - 1; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
409 |
val perm_ns = map length perm_ctr_Tsss; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
410 |
val perm_mss = map (map length) perm_ctr_Tsss; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
411 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
412 |
val perm_Cs = map (body_type o fastype_of o co_rec_of o of_fp_sugar (#xtor_co_iterss o #fp_res)) |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
413 |
perm_fp_sugars; |
53592
5a7bf8c859f6
made non-co case more robust as well (cf. b6e2993fd0d3)
blanchet
parents:
53591
diff
changeset
|
414 |
val perm_fun_arg_Tssss = |
5a7bf8c859f6
made non-co case more robust as well (cf. b6e2993fd0d3)
blanchet
parents:
53591
diff
changeset
|
415 |
mk_iter_fun_arg_types perm_ctr_Tsss perm_ns perm_mss (co_rec_of ctor_iters1); |
53303
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
416 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
417 |
fun unpermute0 perm0_xs = permute_like (op =) perm0_kks kks perm0_xs; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
418 |
fun unpermute perm_xs = permute_like (op =) perm_indices indices perm_xs; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
419 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
420 |
val induct_thms = unpermute0 (conj_dests nn induct_thm); |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
421 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
422 |
val fpTs = unpermute perm_fpTs; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
423 |
val Cs = unpermute perm_Cs; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
424 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
425 |
val As_rho = tvar_subst thy (take nn0 fpTs) arg_Ts; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
426 |
val Cs_rho = map (fst o dest_TVar) Cs ~~ pad_list HOLogic.unitT nn res_Ts; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
427 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
428 |
val substA = Term.subst_TVars As_rho; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
429 |
val substAT = Term.typ_subst_TVars As_rho; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
430 |
val substCT = Term.typ_subst_TVars Cs_rho; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
431 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
432 |
val perm_Cs' = map substCT perm_Cs; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
433 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
434 |
fun offset_of_ctr 0 _ = 0 |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
435 |
| offset_of_ctr n ({ctrs, ...} :: ctr_sugars) = |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
436 |
length ctrs + offset_of_ctr (n - 1) ctr_sugars; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
437 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
438 |
fun call_of [i] [T] = (if exists_subtype_in Cs T then Indirect_Rec else No_Rec) i |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
439 |
| call_of [i, i'] _ = Direct_Rec (i, i'); |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
440 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
441 |
fun mk_ctr_spec ctr offset fun_arg_Tss rec_thm = |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
442 |
let |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
443 |
val (fun_arg_hss, _) = indexedd fun_arg_Tss 0; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
444 |
val fun_arg_hs = flat_rec_arg_args fun_arg_hss; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
445 |
val fun_arg_iss = map (map (find_index_eq fun_arg_hs)) fun_arg_hss; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
446 |
in |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
447 |
{ctr = substA ctr, offset = offset, calls = map2 call_of fun_arg_iss fun_arg_Tss, |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
448 |
rec_thm = rec_thm} |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
449 |
end; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
450 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
451 |
fun mk_ctr_specs index ctr_sugars iter_thmsss = |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
452 |
let |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
453 |
val ctrs = #ctrs (nth ctr_sugars index); |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
454 |
val rec_thmss = co_rec_of (nth iter_thmsss index); |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
455 |
val k = offset_of_ctr index ctr_sugars; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
456 |
val n = length ctrs; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
457 |
in |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
458 |
map4 mk_ctr_spec ctrs (k upto k + n - 1) (nth perm_fun_arg_Tssss index) rec_thmss |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
459 |
end; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
460 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
461 |
fun mk_spec {T, index, ctr_sugars, co_iterss = iterss, co_iter_thmsss = iter_thmsss, ...} = |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
462 |
{recx = mk_co_iter thy Least_FP (substAT T) perm_Cs' (co_rec_of (nth iterss index)), |
53329 | 463 |
nested_map_idents = map (unfold_thms lthy [id_def] o map_id0_of_bnf) nested_bnfs, |
53303
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
464 |
nested_map_comps = map map_comp_of_bnf nested_bnfs, |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
465 |
ctr_specs = mk_ctr_specs index ctr_sugars iter_thmsss}; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
466 |
in |
53746
bd038e48526d
have "datatype_new_compat" register induction and recursion theorems in nested case
blanchet
parents:
53741
diff
changeset
|
467 |
((is_some lfp_sugar_thms, map mk_spec fp_sugars, missing_arg_Ts, induct_thm, induct_thms), |
bd038e48526d
have "datatype_new_compat" register induction and recursion theorems in nested case
blanchet
parents:
53741
diff
changeset
|
468 |
lthy') |
53303
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
469 |
end; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
470 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
471 |
fun corec_specs_of bs arg_Ts res_Ts get_indices callssss0 lthy = |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
472 |
let |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
473 |
val thy = Proof_Context.theory_of lthy; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
474 |
|
53746
bd038e48526d
have "datatype_new_compat" register induction and recursion theorems in nested case
blanchet
parents:
53741
diff
changeset
|
475 |
val ((missing_res_Ts, perm0_kks, |
53475 | 476 |
fp_sugars as {nested_bnfs, fp_res = {xtor_co_iterss = dtor_coiters1 :: _, ...}, |
53746
bd038e48526d
have "datatype_new_compat" register induction and recursion theorems in nested case
blanchet
parents:
53741
diff
changeset
|
477 |
co_inducts = coinduct_thms, ...} :: _, (_, gfp_sugar_thms)), lthy') = |
53303
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
478 |
nested_to_mutual_fps lose_co_rec Greatest_FP bs res_Ts get_indices callssss0 lthy; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
479 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
480 |
val perm_fp_sugars = sort (int_ord o pairself #index) fp_sugars; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
481 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
482 |
val indices = map #index fp_sugars; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
483 |
val perm_indices = map #index perm_fp_sugars; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
484 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
485 |
val perm_ctrss = map (#ctrs o of_fp_sugar #ctr_sugars) perm_fp_sugars; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
486 |
val perm_ctr_Tsss = map (map (binder_types o fastype_of)) perm_ctrss; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
487 |
val perm_fpTs = map (body_type o fastype_of o hd) perm_ctrss; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
488 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
489 |
val nn0 = length res_Ts; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
490 |
val nn = length perm_fpTs; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
491 |
val kks = 0 upto nn - 1; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
492 |
val perm_ns = map length perm_ctr_Tsss; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
493 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
494 |
val perm_Cs = map (domain_type o body_fun_type o fastype_of o co_rec_of o |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
495 |
of_fp_sugar (#xtor_co_iterss o #fp_res)) perm_fp_sugars; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
496 |
val (perm_p_Tss, (perm_q_Tssss, _, perm_f_Tssss, _)) = |
53591 | 497 |
mk_coiter_fun_arg_types perm_ctr_Tsss perm_Cs perm_ns (co_rec_of dtor_coiters1); |
53303
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
498 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
499 |
val (perm_p_hss, h) = indexedd perm_p_Tss 0; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
500 |
val (perm_q_hssss, h') = indexedddd perm_q_Tssss h; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
501 |
val (perm_f_hssss, _) = indexedddd perm_f_Tssss h'; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
502 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
503 |
val fun_arg_hs = |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
504 |
flat (map3 flat_corec_preds_predsss_gettersss perm_p_hss perm_q_hssss perm_f_hssss); |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
505 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
506 |
fun unpermute0 perm0_xs = permute_like (op =) perm0_kks kks perm0_xs; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
507 |
fun unpermute perm_xs = permute_like (op =) perm_indices indices perm_xs; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
508 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
509 |
val coinduct_thmss = map (unpermute0 o conj_dests nn) coinduct_thms; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
510 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
511 |
val p_iss = map (map (find_index_eq fun_arg_hs)) (unpermute perm_p_hss); |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
512 |
val q_issss = map (map (map (map (find_index_eq fun_arg_hs)))) (unpermute perm_q_hssss); |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
513 |
val f_issss = map (map (map (map (find_index_eq fun_arg_hs)))) (unpermute perm_f_hssss); |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
514 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
515 |
val f_Tssss = unpermute perm_f_Tssss; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
516 |
val fpTs = unpermute perm_fpTs; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
517 |
val Cs = unpermute perm_Cs; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
518 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
519 |
val As_rho = tvar_subst thy (take nn0 fpTs) res_Ts; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
520 |
val Cs_rho = map (fst o dest_TVar) Cs ~~ pad_list HOLogic.unitT nn arg_Ts; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
521 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
522 |
val substA = Term.subst_TVars As_rho; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
523 |
val substAT = Term.typ_subst_TVars As_rho; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
524 |
val substCT = Term.typ_subst_TVars Cs_rho; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
525 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
526 |
val perm_Cs' = map substCT perm_Cs; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
527 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
528 |
fun call_of nullary [] [g_i] [Type (@{type_name fun}, [_, T])] = |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
529 |
(if exists_subtype_in Cs T then Indirect_Corec |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
530 |
else if nullary then Dummy_No_Corec |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
531 |
else No_Corec) g_i |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
532 |
| call_of _ [q_i] [g_i, g_i'] _ = Direct_Corec (q_i, g_i, g_i'); |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
533 |
|
53705 | 534 |
fun mk_ctr_spec ctr disc sels p_ho q_iss f_iss f_Tss discI sel_thms collapse corec_thm |
535 |
disc_corec sel_corecs = |
|
53303
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
536 |
let val nullary = not (can dest_funT (fastype_of ctr)) in |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
537 |
{ctr = substA ctr, disc = substA disc, sels = map substA sels, pred = p_ho, |
53705 | 538 |
calls = map3 (call_of nullary) q_iss f_iss f_Tss, discI = discI, sel_thms = sel_thms, |
539 |
collapse = collapse, corec_thm = corec_thm, disc_corec = disc_corec, |
|
540 |
sel_corecs = sel_corecs} |
|
53303
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
541 |
end; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
542 |
|
53475 | 543 |
fun mk_ctr_specs index ctr_sugars p_is q_isss f_isss f_Tsss coiter_thmsss disc_coitersss |
544 |
sel_coiterssss = |
|
53303
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
545 |
let |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
546 |
val ctrs = #ctrs (nth ctr_sugars index); |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
547 |
val discs = #discs (nth ctr_sugars index); |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
548 |
val selss = #selss (nth ctr_sugars index); |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
549 |
val p_ios = map SOME p_is @ [NONE]; |
53705 | 550 |
val discIs = #discIs (nth ctr_sugars index); |
551 |
val sel_thmss = #sel_thmss (nth ctr_sugars index); |
|
53475 | 552 |
val collapses = #collapses (nth ctr_sugars index); |
553 |
val corec_thms = co_rec_of (nth coiter_thmsss index); |
|
53741
c9068aade859
killed exceptional code that is anyway no longer needed, now that the 'simp' attribute has been taken away -- this solves issues in 'primcorec'
blanchet
parents:
53734
diff
changeset
|
554 |
val disc_corecs = co_rec_of (nth disc_coitersss index); |
53475 | 555 |
val sel_corecss = co_rec_of (nth sel_coiterssss index); |
53303
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
556 |
in |
53705 | 557 |
map13 mk_ctr_spec ctrs discs selss p_ios q_isss f_isss f_Tsss discIs sel_thmss collapses |
558 |
corec_thms disc_corecs sel_corecss |
|
53303
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
559 |
end; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
560 |
|
53475 | 561 |
fun mk_spec {T, index, ctr_sugars, co_iterss = coiterss, co_iter_thmsss = coiter_thmsss, |
562 |
disc_co_itersss = disc_coitersss, sel_co_iterssss = sel_coiterssss, ...} |
|
53303
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
563 |
p_is q_isss f_isss f_Tsss = |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
564 |
{corec = mk_co_iter thy Greatest_FP (substAT T) perm_Cs' (co_rec_of (nth coiterss index)), |
53476
eb3865c3ee58
include map theorems in datastructure for "primcorec"
blanchet
parents:
53475
diff
changeset
|
565 |
nested_maps = maps (map_thms_of_typ lthy o T_of_bnf) nested_bnfs, |
53475 | 566 |
nested_map_idents = map (unfold_thms lthy [id_def] o map_id0_of_bnf) nested_bnfs, |
567 |
nested_map_comps = map map_comp_of_bnf nested_bnfs, |
|
568 |
ctr_specs = mk_ctr_specs index ctr_sugars p_is q_isss f_isss f_Tsss coiter_thmsss |
|
569 |
disc_coitersss sel_coiterssss}; |
|
53303
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
570 |
in |
53746
bd038e48526d
have "datatype_new_compat" register induction and recursion theorems in nested case
blanchet
parents:
53741
diff
changeset
|
571 |
((is_some gfp_sugar_thms, map5 mk_spec fp_sugars p_iss q_issss f_issss f_Tssss, missing_res_Ts, |
53303
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
572 |
co_induct_of coinduct_thms, strong_co_induct_of coinduct_thms, co_induct_of coinduct_thmss, |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
573 |
strong_co_induct_of coinduct_thmss), lthy') |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
574 |
end; |
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
575 |
|
ae49b835ca01
moved files related to "primrec_new", "primcorec", and "datatype_compat" from bitbucket co-rec repository
blanchet
parents:
diff
changeset
|
576 |
end; |