author | blanchet |
Mon, 29 Apr 2013 09:10:49 +0200 | |
changeset 51804 | be6e703908f4 |
parent 49617 | 7ec6471f8388 |
child 52323 | a11bbb5fef56 |
permissions | -rw-r--r-- |
49591
91b228e26348
generate high-level "coinduct" and "strong_coinduct" properties
blanchet
parents:
49510
diff
changeset
|
1 |
(* Title: HOL/BNF/Examples/Misc_Codata.thy |
48975
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 codatatype 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 Codatatype 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_Codata |
49509
163914705f8d
renamed top-level theory from "Codatatype" to "BNF"
blanchet
parents:
49463
diff
changeset
|
12 |
imports "../BNF" |
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 |
|
51804
be6e703908f4
renamed BNF "(co)data" commands to names that are closer to their final names
blanchet
parents:
49617
diff
changeset
|
15 |
codatatype simple = X1 | X2 | X3 | X4 |
49158 | 16 |
|
51804
be6e703908f4
renamed BNF "(co)data" commands to names that are closer to their final names
blanchet
parents:
49617
diff
changeset
|
17 |
codatatype 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
|
18 |
|
51804
be6e703908f4
renamed BNF "(co)data" commands to names that are closer to their final names
blanchet
parents:
49617
diff
changeset
|
19 |
codatatype 'a stream = Stream 'a "'a stream" |
49158 | 20 |
|
51804
be6e703908f4
renamed BNF "(co)data" commands to names that are closer to their final names
blanchet
parents:
49617
diff
changeset
|
21 |
codatatype 'a mylist = MyNil | MyCons 'a "'a mylist" |
49158 | 22 |
|
51804
be6e703908f4
renamed BNF "(co)data" commands to names that are closer to their final names
blanchet
parents:
49617
diff
changeset
|
23 |
codatatype ('b, 'c, 'd, 'e) some_passive = |
49158 | 24 |
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
|
25 |
|
51804
be6e703908f4
renamed BNF "(co)data" commands to names that are closer to their final names
blanchet
parents:
49617
diff
changeset
|
26 |
codatatype lambda = |
49158 | 27 |
Var string | |
28 |
App lambda lambda | |
|
29 |
Abs string lambda | |
|
30 |
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
|
31 |
|
51804
be6e703908f4
renamed BNF "(co)data" commands to names that are closer to their final names
blanchet
parents:
49617
diff
changeset
|
32 |
codatatype 'a par_lambda = |
49158 | 33 |
PVar 'a | |
34 |
PApp "'a par_lambda" "'a par_lambda" | |
|
35 |
PAbs 'a "'a par_lambda" | |
|
36 |
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
|
37 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
38 |
(* |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
39 |
('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
|
40 |
('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
|
41 |
*) |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
42 |
|
51804
be6e703908f4
renamed BNF "(co)data" commands to names that are closer to their final names
blanchet
parents:
49617
diff
changeset
|
43 |
codatatype 'a J1 = J11 'a "'a J1" | J12 'a "'a J2" |
be6e703908f4
renamed BNF "(co)data" commands to names that are closer to their final names
blanchet
parents:
49617
diff
changeset
|
44 |
and 'a J2 = J21 | J22 "'a J1" "'a J2" |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
45 |
|
51804
be6e703908f4
renamed BNF "(co)data" commands to names that are closer to their final names
blanchet
parents:
49617
diff
changeset
|
46 |
codatatype 'a tree = TEmpty | TNode 'a "'a forest" |
be6e703908f4
renamed BNF "(co)data" commands to names that are closer to their final names
blanchet
parents:
49617
diff
changeset
|
47 |
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
|
48 |
|
51804
be6e703908f4
renamed BNF "(co)data" commands to names that are closer to their final names
blanchet
parents:
49617
diff
changeset
|
49 |
codatatype 'a tree' = TEmpty' | TNode' "'a branch" "'a branch" |
be6e703908f4
renamed BNF "(co)data" commands to names that are closer to their final names
blanchet
parents:
49617
diff
changeset
|
50 |
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
|
51 |
|
51804
be6e703908f4
renamed BNF "(co)data" commands to names that are closer to their final names
blanchet
parents:
49617
diff
changeset
|
52 |
codatatype ('a, 'b) exp = Term "('a, 'b) trm" | Sum "('a, 'b) trm" "('a, 'b) exp" |
be6e703908f4
renamed BNF "(co)data" commands to names that are closer to their final names
blanchet
parents:
49617
diff
changeset
|
53 |
and ('a, 'b) trm = Factor "('a, 'b) factor" | Prod "('a, 'b) factor" "('a, 'b) trm" |
be6e703908f4
renamed BNF "(co)data" commands to names that are closer to their final names
blanchet
parents:
49617
diff
changeset
|
54 |
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
|
55 |
|
51804
be6e703908f4
renamed BNF "(co)data" commands to names that are closer to their final names
blanchet
parents:
49617
diff
changeset
|
56 |
codatatype ('a, 'b, 'c) some_killing = |
49158 | 57 |
SK "'a \<Rightarrow> 'b \<Rightarrow> ('a, 'b, 'c) some_killing + ('a, 'b, 'c) in_here" |
51804
be6e703908f4
renamed BNF "(co)data" commands to names that are closer to their final names
blanchet
parents:
49617
diff
changeset
|
58 |
and ('a, 'b, 'c) in_here = |
49158 | 59 |
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
|
60 |
|
51804
be6e703908f4
renamed BNF "(co)data" commands to names that are closer to their final names
blanchet
parents:
49617
diff
changeset
|
61 |
codatatype ('a, 'b, 'c) some_killing' = |
49617 | 62 |
SK' "'a \<Rightarrow> 'b \<Rightarrow> ('a, 'b, 'c) some_killing' + ('a, 'b, 'c) in_here'" |
51804
be6e703908f4
renamed BNF "(co)data" commands to names that are closer to their final names
blanchet
parents:
49617
diff
changeset
|
63 |
and ('a, 'b, 'c) in_here' = |
49617 | 64 |
IH1' 'b | IH2' 'c |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
65 |
|
51804
be6e703908f4
renamed BNF "(co)data" commands to names that are closer to their final names
blanchet
parents:
49617
diff
changeset
|
66 |
codatatype ('a, 'b, 'c) some_killing'' = |
49617 | 67 |
SK'' "'a \<Rightarrow> ('a, 'b, 'c) in_here''" |
51804
be6e703908f4
renamed BNF "(co)data" commands to names that are closer to their final names
blanchet
parents:
49617
diff
changeset
|
68 |
and ('a, 'b, 'c) in_here'' = |
49617 | 69 |
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
|
70 |
|
51804
be6e703908f4
renamed BNF "(co)data" commands to names that are closer to their final names
blanchet
parents:
49617
diff
changeset
|
71 |
codatatype ('b, 'c) less_killing = LK "'b \<Rightarrow> 'c" |
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
72 |
|
51804
be6e703908f4
renamed BNF "(co)data" commands to names that are closer to their final names
blanchet
parents:
49617
diff
changeset
|
73 |
codatatype 'b cps = CPS1 'b | CPS2 "'b \<Rightarrow> 'b cps" |
49158 | 74 |
|
51804
be6e703908f4
renamed BNF "(co)data" commands to names that are closer to their final names
blanchet
parents:
49617
diff
changeset
|
75 |
codatatype ('b1, 'b2, 'b3, 'b4, 'b5, 'b6, 'b7, 'b8, 'b9) fun_rhs = |
49158 | 76 |
FR "'b1 \<Rightarrow> 'b2 \<Rightarrow> 'b3 \<Rightarrow> 'b4 \<Rightarrow> 'b5 \<Rightarrow> 'b6 \<Rightarrow> 'b7 \<Rightarrow> 'b8 \<Rightarrow> 'b9 \<Rightarrow> |
77 |
('b1, 'b2, 'b3, 'b4, 'b5, 'b6, 'b7, 'b8, 'b9) fun_rhs" |
|
49102
ce2ef34eb828
added examples for testing of coinductive witnesses
traytel
parents:
49074
diff
changeset
|
78 |
|
51804
be6e703908f4
renamed BNF "(co)data" commands to names that are closer to their final names
blanchet
parents:
49617
diff
changeset
|
79 |
codatatype ('b1, 'b2, 'b3, 'b4, 'b5, 'b6, 'b7, 'b8, 'b9, 'b10, 'b11, 'b12, 'b13, 'b14, 'b15, 'b16, 'b17, |
49158 | 80 |
'b18, 'b19, 'b20) fun_rhs' = |
81 |
FR' "'b1 \<Rightarrow> 'b2 \<Rightarrow> 'b3 \<Rightarrow> 'b4 \<Rightarrow> 'b5 \<Rightarrow> 'b6 \<Rightarrow> 'b7 \<Rightarrow> 'b8 \<Rightarrow> 'b9 \<Rightarrow> 'b10 \<Rightarrow> 'b11 \<Rightarrow> 'b12 \<Rightarrow> 'b13 \<Rightarrow> 'b14 \<Rightarrow> |
|
82 |
'b15 \<Rightarrow> 'b16 \<Rightarrow> 'b17 \<Rightarrow> 'b18 \<Rightarrow> 'b19 \<Rightarrow> 'b20 \<Rightarrow> |
|
83 |
('b1, 'b2, 'b3, 'b4, 'b5, 'b6, 'b7, 'b8, 'b9, 'b10, 'b11, 'b12, 'b13, 'b14, 'b15, 'b16, 'b17, |
|
84 |
'b18, 'b19, 'b20) fun_rhs'" |
|
85 |
||
51804
be6e703908f4
renamed BNF "(co)data" commands to names that are closer to their final names
blanchet
parents:
49617
diff
changeset
|
86 |
codatatype ('a, 'b, 'c) wit3_F1 = W1 'a "('a, 'b, 'c) wit3_F1" "('a, 'b, 'c) wit3_F2" |
be6e703908f4
renamed BNF "(co)data" commands to names that are closer to their final names
blanchet
parents:
49617
diff
changeset
|
87 |
and ('a, 'b, 'c) wit3_F2 = W2 'b "('a, 'b, 'c) wit3_F2" |
be6e703908f4
renamed BNF "(co)data" commands to names that are closer to their final names
blanchet
parents:
49617
diff
changeset
|
88 |
and ('a, 'b, 'c) wit3_F3 = W31 'a 'b "('a, 'b, 'c) wit3_F1" | W32 'c 'a 'b "('a, 'b, 'c) wit3_F1" |
49158 | 89 |
|
51804
be6e703908f4
renamed BNF "(co)data" commands to names that are closer to their final names
blanchet
parents:
49617
diff
changeset
|
90 |
codatatype ('c, 'e, 'g) coind_wit1 = |
49158 | 91 |
CW1 'c "('c, 'e, 'g) coind_wit1" "('c, 'e, 'g) ind_wit" "('c, 'e, 'g) coind_wit2" |
51804
be6e703908f4
renamed BNF "(co)data" commands to names that are closer to their final names
blanchet
parents:
49617
diff
changeset
|
92 |
and ('c, 'e, 'g) coind_wit2 = |
49158 | 93 |
CW21 "('c, 'e, 'g) coind_wit2" 'e | CW22 'c 'g |
51804
be6e703908f4
renamed BNF "(co)data" commands to names that are closer to their final names
blanchet
parents:
49617
diff
changeset
|
94 |
and ('c, 'e, 'g) ind_wit = |
49158 | 95 |
IW1 | IW2 'c |
49102
ce2ef34eb828
added examples for testing of coinductive witnesses
traytel
parents:
49074
diff
changeset
|
96 |
|
51804
be6e703908f4
renamed BNF "(co)data" commands to names that are closer to their final names
blanchet
parents:
49617
diff
changeset
|
97 |
codatatype ('b, 'a) bar = BAR "'a \<Rightarrow> 'b" |
be6e703908f4
renamed BNF "(co)data" commands to names that are closer to their final names
blanchet
parents:
49617
diff
changeset
|
98 |
codatatype ('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:
49158
diff
changeset
|
99 |
|
51804
be6e703908f4
renamed BNF "(co)data" commands to names that are closer to their final names
blanchet
parents:
49617
diff
changeset
|
100 |
codatatype 'a dead_foo = A |
be6e703908f4
renamed BNF "(co)data" commands to names that are closer to their final names
blanchet
parents:
49617
diff
changeset
|
101 |
codatatype ('a, 'b) use_dead_foo = Y "'a" "'b dead_foo" |
49185
073d7d1b7488
respect order of/additional type variables supplied by the user in fixed point constructions;
traytel
parents:
49158
diff
changeset
|
102 |
|
48975
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
103 |
(* SLOW, MEMORY-HUNGRY |
51804
be6e703908f4
renamed BNF "(co)data" commands to names that are closer to their final names
blanchet
parents:
49617
diff
changeset
|
104 |
codatatype ('a, 'c) D1 = A1 "('a, 'c) D2" | B1 "'a list" |
be6e703908f4
renamed BNF "(co)data" commands to names that are closer to their final names
blanchet
parents:
49617
diff
changeset
|
105 |
and ('a, 'c) D2 = A2 "('a, 'c) D3" | B2 "'c list" |
be6e703908f4
renamed BNF "(co)data" commands to names that are closer to their final names
blanchet
parents:
49617
diff
changeset
|
106 |
and ('a, 'c) D3 = A3 "('a, 'c) D3" | B3 "('a, 'c) D4" | C3 "('a, 'c) D4" "('a, 'c) D5" |
be6e703908f4
renamed BNF "(co)data" commands to names that are closer to their final names
blanchet
parents:
49617
diff
changeset
|
107 |
and ('a, 'c) D4 = A4 "('a, 'c) D5" | B4 "'a list list list" |
be6e703908f4
renamed BNF "(co)data" commands to names that are closer to their final names
blanchet
parents:
49617
diff
changeset
|
108 |
and ('a, 'c) D5 = A5 "('a, 'c) D6" |
be6e703908f4
renamed BNF "(co)data" commands to names that are closer to their final names
blanchet
parents:
49617
diff
changeset
|
109 |
and ('a, 'c) D6 = A6 "('a, 'c) D7" |
be6e703908f4
renamed BNF "(co)data" commands to names that are closer to their final names
blanchet
parents:
49617
diff
changeset
|
110 |
and ('a, 'c) D7 = A7 "('a, 'c) D8" |
be6e703908f4
renamed BNF "(co)data" commands to names that are closer to their final names
blanchet
parents:
49617
diff
changeset
|
111 |
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
|
112 |
*) |
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
113 |
|
7f79f94a432c
added new (co)datatype package + theories of ordinals and cardinals (with Dmitriy and Andrei)
blanchet
parents:
diff
changeset
|
114 |
end |