author | blanchet |
Thu, 20 Sep 2012 02:42:48 +0200 | |
changeset 49456 | fa8302c8dea1 |
parent 49436 | 37cae324d73e |
child 49459 | 3f8e2b5249ec |
permissions | -rw-r--r-- |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
1 |
(* Title: Codatatype_Examples/Misc_Data.thy |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
2 |
Author: Dmitriy Traytel, TU Muenchen |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
3 |
Author: Andrei Popescu, TU Muenchen |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
4 |
Copyright 2012 |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
5 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
6 |
Miscellaneous datatype declarations. |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
7 |
*) |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
8 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
9 |
header {* Miscellaneous Datatype Declarations *} |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
10 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
11 |
theory Misc_Data |
49456 | 12 |
imports (* "../Codatatype" *) "../BNF_LFP" |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
13 |
begin |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
14 |
|
49456 | 15 |
declare [[bnf_note_all = false]] |
16 |
||
17 |
local_setup {* fn lthy => |
|
18 |
snd (snd (BNF_Comp.bnf_of_typ BNF_Def.Dont_Inline (Binding.qualify true "xxx") |
|
19 |
BNF_Comp.default_comp_sort |
|
20 |
@{typ "('a \<Rightarrow> 'a) + ('a + 'b) + 'c"} (BNF_Comp.empty_unfold, lthy))) |
|
21 |
*} |
|
22 |
||
23 |
data 'a lst = Nl | Cns 'a "'a lst" |
|
24 |
||
25 |
thm pre_lst.rel_unfold |
|
26 |
pre_lst.pred_unfold |
|
27 |
lst.rel_unfold |
|
28 |
lst.pred_unfold |
|
29 |
||
49157 | 30 |
data simple = X1 | X2 | X3 | X4 |
31 |
||
49456 | 32 |
thm simple.rel_unfold |
33 |
||
49157 | 34 |
data simple' = X1' unit | X2' unit | X3' unit | X4' unit |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
35 |
|
49157 | 36 |
data 'a mylist = MyNil | MyCons 'a "'a mylist" |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
37 |
|
49157 | 38 |
data ('b, 'c, 'd, 'e) some_passive = |
39 |
SP1 "('b, 'c, 'd, 'e) some_passive" | SP2 'b | SP3 'c | SP4 'd | SP5 'e |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
40 |
|
49157 | 41 |
data lambda = |
42 |
Var string | |
|
43 |
App lambda lambda | |
|
44 |
Abs string lambda | |
|
45 |
Let "(string \<times> lambda) fset" lambda |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
46 |
|
49157 | 47 |
data 'a par_lambda = |
48 |
PVar 'a | |
|
49 |
PApp "'a par_lambda" "'a par_lambda" | |
|
50 |
PAbs 'a "'a par_lambda" | |
|
51 |
PLet "('a \<times> 'a par_lambda) fset" "'a par_lambda" |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
52 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
53 |
(* |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
54 |
('a, 'b1, 'b2) F1 = 'a * 'b1 + 'a * 'b2 |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
55 |
('a, 'b1, 'b2) F2 = unit + 'b1 * 'b2 |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
56 |
*) |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
57 |
|
49157 | 58 |
data 'a I1 = I11 'a "'a I1" | I12 'a "'a I2" |
59 |
and 'a I2 = I21 | I22 "'a I1" "'a I2" |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
60 |
|
49157 | 61 |
data 'a tree = TEmpty | TNode 'a "'a forest" |
62 |
and 'a forest = FNil | FCons "'a tree" "'a forest" |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
63 |
|
49157 | 64 |
data 'a tree' = TEmpty' | TNode' "'a branch" "'a branch" |
65 |
and 'a branch = Branch 'a "'a tree'" |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
66 |
|
49157 | 67 |
data ('a, 'b) exp = Term "('a, 'b) trm" | Sum "('a, 'b) trm" "('a, 'b) exp" |
68 |
and ('a, 'b) trm = Factor "('a, 'b) factor" | Prod "('a, 'b) factor" "('a, 'b) trm" |
|
69 |
and ('a, 'b) factor = C 'a | V 'b | Paren "('a, 'b) exp" |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
70 |
|
49157 | 71 |
data ('a, 'b, 'c) some_killing = |
72 |
SK "'a \<Rightarrow> 'b \<Rightarrow> ('a, 'b, 'c) some_killing + ('a, 'b, 'c) in_here" |
|
73 |
and ('a, 'b, 'c) in_here = |
|
74 |
IH1 'b 'a | IH2 'c |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
75 |
|
49219 | 76 |
data 'b nofail1 = NF11 "'b nofail1" 'b | NF12 'b |
49157 | 77 |
data 'b nofail2 = NF2 "('b nofail2 \<times> 'b \<times> 'b nofail2 \<times> 'b) list" |
49219 | 78 |
data 'b nofail3 = NF3 'b "('b nofail3 \<times> 'b \<times> 'b nofail3 \<times> 'b) fset" |
79 |
data 'b nofail4 = NF4 "('b nofail4 \<times> ('b nofail4 \<times> 'b \<times> 'b nofail4 \<times> 'b) fset) list" |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
80 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
81 |
(* |
49219 | 82 |
data 'b fail = F "'b fail" 'b "'b fail" "'b list" |
83 |
data 'b fail = F "'b fail" 'b "'b fail" 'b |
|
84 |
data 'b fail = F1 "'b fail" 'b | F2 "'b fail" |
|
85 |
data 'b fail = F "'b fail" 'b |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
86 |
*) |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
87 |
|
49157 | 88 |
data l1 = L1 "l2 list" |
89 |
and l2 = L21 "l1 fset" | L22 l2 |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
90 |
|
49157 | 91 |
data kk1 = KK1 kk2 |
92 |
and kk2 = KK2 kk3 |
|
93 |
and kk3 = KK3 "kk1 list" |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
94 |
|
49157 | 95 |
data t1 = T11 t3 | T12 t2 |
96 |
and t2 = T2 t1 |
|
97 |
and t3 = T3 |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
98 |
|
49157 | 99 |
data t1' = T11' t2' | T12' t3' |
100 |
and t2' = T2' t1' |
|
101 |
and t3' = T3' |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
102 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
103 |
(* |
49157 | 104 |
data fail1 = F1 fail2 |
105 |
and fail2 = F2 fail3 |
|
106 |
and fail3 = F3 fail1 |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
107 |
|
49157 | 108 |
data fail1 = F1 "fail2 list" fail2 |
109 |
and fail2 = F2 "fail2 fset" fail3 |
|
110 |
and fail3 = F3 fail1 |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
111 |
|
49157 | 112 |
data fail1 = F1 "fail2 list" fail2 |
113 |
and fail2 = F2 "fail1 fset" fail1 |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
114 |
*) |
49157 | 115 |
|
49162 | 116 |
(* SLOW |
49157 | 117 |
data ('a, 'c) D1 = A1 "('a, 'c) D2" | B1 "'a list" |
118 |
and ('a, 'c) D2 = A2 "('a, 'c) D3" | B2 "'c list" |
|
119 |
and ('a, 'c) D3 = A3 "('a, 'c) D3" | B3 "('a, 'c) D4" | C3 "('a, 'c) D4" "('a, 'c) D5" |
|
120 |
and ('a, 'c) D4 = A4 "('a, 'c) D5" | B4 "'a list list list" |
|
121 |
and ('a, 'c) D5 = A5 "('a, 'c) D6" |
|
122 |
and ('a, 'c) D6 = A6 "('a, 'c) D7" |
|
123 |
and ('a, 'c) D7 = A7 "('a, 'c) D8" |
|
124 |
and ('a, 'c) D8 = A8 "('a, 'c) D1 list" |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
125 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
126 |
(*time comparison*) |
49157 | 127 |
datatype ('a, 'c) D1' = A1' "('a, 'c) D2'" | B1' "'a list" |
128 |
and ('a, 'c) D2' = A2' "('a, 'c) D3'" | B2' "'c list" |
|
129 |
and ('a, 'c) D3' = A3' "('a, 'c) D3'" | B3' "('a, 'c) D4'" | C3' "('a, 'c) D4'" "('a, 'c) D5'" |
|
130 |
and ('a, 'c) D4' = A4' "('a, 'c) D5'" | B4' "'a list list list" |
|
131 |
and ('a, 'c) D5' = A5' "('a, 'c) D6'" |
|
132 |
and ('a, 'c) D6' = A6' "('a, 'c) D7'" |
|
133 |
and ('a, 'c) D7' = A7' "('a, 'c) D8'" |
|
134 |
and ('a, 'c) D8' = A8' "('a, 'c) D1' list" |
|
49162 | 135 |
*) |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
136 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
137 |
(* fail: |
49157 | 138 |
data tt1 = TT11 tt2 tt3 | TT12 tt2 tt4 |
139 |
and tt2 = TT2 |
|
140 |
and tt3 = TT3 tt4 |
|
141 |
and tt4 = TT4 tt1 |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
142 |
*) |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
143 |
|
49157 | 144 |
data k1 = K11 k2 k3 | K12 k2 k4 |
145 |
and k2 = K2 |
|
146 |
and k3 = K3 k4 |
|
147 |
and k4 = K4 |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
148 |
|
49157 | 149 |
data tt1 = TT11 tt3 tt2 | TT12 tt2 tt4 |
150 |
and tt2 = TT2 |
|
151 |
and tt3 = TT3 tt1 |
|
152 |
and tt4 = TT4 |
|
153 |
||
49162 | 154 |
(* SLOW |
49157 | 155 |
data s1 = S11 s2 s3 s4 | S12 s3 | S13 s2 s6 | S14 s4 s2 | S15 s2 s2 |
156 |
and s2 = S21 s7 s5 | S22 s5 s4 s6 |
|
157 |
and s3 = S31 s1 s7 s2 | S32 s3 s3 | S33 s4 s5 |
|
158 |
and s4 = S4 s5 |
|
159 |
and s5 = S5 |
|
160 |
and s6 = S61 s6 | S62 s1 s2 | S63 s6 |
|
161 |
and s7 = S71 s8 | S72 s5 |
|
162 |
and s8 = S8 nat |
|
49162 | 163 |
*) |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
164 |
|
49436 | 165 |
data ('a, 'b) bar = Bar "'b \<Rightarrow> 'a" |
166 |
data ('a, 'b, 'c, 'd) foo = Foo "'d + 'b \<Rightarrow> 'c + 'a" |
|
49185
073d7d1b7488
respect order of/additional type variables supplied by the user in fixed point constructions;
traytel
parents:
49166
diff
changeset
|
167 |
|
073d7d1b7488
respect order of/additional type variables supplied by the user in fixed point constructions;
traytel
parents:
49166
diff
changeset
|
168 |
data 'a dead_foo = A |
073d7d1b7488
respect order of/additional type variables supplied by the user in fixed point constructions;
traytel
parents:
49166
diff
changeset
|
169 |
data ('a, 'b) use_dead_foo = Y "'a" "'b dead_foo" |
49186
4b5fa9d5e330
handle type constructors not known to be a BNF using the DEADID BNF
traytel
parents:
49185
diff
changeset
|
170 |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
171 |
end |