163
|
1 |
theory QuotTest
|
|
2 |
imports QuotMain
|
|
3 |
begin
|
|
4 |
|
|
5 |
section {* various tests for quotient types*}
|
|
6 |
datatype trm =
|
|
7 |
var "nat"
|
|
8 |
| app "trm" "trm"
|
|
9 |
| lam "nat" "trm"
|
|
10 |
|
|
11 |
axiomatization
|
177
bdfe4388955d
changed encoding from utf8 to ISO8 (needed to work with xemacs)
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
12 |
RR :: "trm \<Rightarrow> trm \<Rightarrow> bool"
|
163
|
13 |
where
|
|
14 |
r_eq: "EQUIV RR"
|
|
15 |
|
|
16 |
ML {* print_quotdata @{context} *}
|
|
17 |
|
|
18 |
quotient qtrm = trm / "RR"
|
|
19 |
apply(rule r_eq)
|
|
20 |
done
|
|
21 |
|
|
22 |
ML {* print_quotdata @{context} *}
|
|
23 |
|
|
24 |
typ qtrm
|
|
25 |
term Rep_qtrm
|
|
26 |
term REP_qtrm
|
|
27 |
term Abs_qtrm
|
|
28 |
term ABS_qtrm
|
|
29 |
thm QUOT_TYPE_qtrm
|
|
30 |
thm QUOTIENT_qtrm
|
|
31 |
thm REP_qtrm_def
|
|
32 |
|
|
33 |
(* Test interpretation *)
|
|
34 |
thm QUOT_TYPE_I_qtrm.thm11
|
|
35 |
thm QUOT_TYPE.thm11
|
|
36 |
|
|
37 |
print_theorems
|
|
38 |
|
|
39 |
thm Rep_qtrm
|
|
40 |
|
|
41 |
text {* another test *}
|
|
42 |
datatype 'a trm' =
|
|
43 |
var' "'a"
|
|
44 |
| app' "'a trm'" "'a trm'"
|
|
45 |
| lam' "'a" "'a trm'"
|
|
46 |
|
177
bdfe4388955d
changed encoding from utf8 to ISO8 (needed to work with xemacs)
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
47 |
consts R' :: "'a trm' \<Rightarrow> 'a trm' \<Rightarrow> bool"
|
163
|
48 |
axioms r_eq': "EQUIV R'"
|
|
49 |
|
|
50 |
quotient qtrm' = "'a trm'" / "R'"
|
|
51 |
apply(rule r_eq')
|
|
52 |
done
|
|
53 |
|
|
54 |
print_theorems
|
|
55 |
|
|
56 |
term ABS_qtrm'
|
|
57 |
term REP_qtrm'
|
|
58 |
thm QUOT_TYPE_qtrm'
|
|
59 |
thm QUOTIENT_qtrm'
|
|
60 |
thm Rep_qtrm'
|
|
61 |
|
|
62 |
|
|
63 |
text {* a test with lists of terms *}
|
|
64 |
datatype t =
|
|
65 |
vr "string"
|
|
66 |
| ap "t list"
|
|
67 |
| lm "string" "t"
|
|
68 |
|
177
bdfe4388955d
changed encoding from utf8 to ISO8 (needed to work with xemacs)
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
69 |
consts Rt :: "t \<Rightarrow> t \<Rightarrow> bool"
|
163
|
70 |
axioms t_eq: "EQUIV Rt"
|
|
71 |
|
|
72 |
quotient qt = "t" / "Rt"
|
|
73 |
by (rule t_eq)
|
|
74 |
|
|
75 |
ML {*
|
177
bdfe4388955d
changed encoding from utf8 to ISO8 (needed to work with xemacs)
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
76 |
get_fun repF @{typ t} @{typ qt} @{context} @{typ "((((qt \<Rightarrow> qt) \<Rightarrow> qt) \<Rightarrow> qt) list) * nat"}
|
163
|
77 |
|> fst
|
|
78 |
|> Syntax.string_of_term @{context}
|
|
79 |
|> writeln
|
|
80 |
*}
|
|
81 |
|
|
82 |
ML {*
|
|
83 |
get_fun absF @{typ t} @{typ qt} @{context} @{typ "qt * nat"}
|
|
84 |
|> fst
|
|
85 |
|> Syntax.string_of_term @{context}
|
|
86 |
|> writeln
|
|
87 |
*}
|
|
88 |
|
|
89 |
ML {*
|
177
bdfe4388955d
changed encoding from utf8 to ISO8 (needed to work with xemacs)
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
90 |
get_fun absF @{typ t} @{typ qt} @{context} @{typ "(qt \<Rightarrow> qt) \<Rightarrow> qt"}
|
163
|
91 |
|> fst
|
|
92 |
|> Syntax.pretty_term @{context}
|
|
93 |
|> Pretty.string_of
|
|
94 |
|> writeln
|
|
95 |
*}
|
|
96 |
|
|
97 |
(* A test whether get_fun works properly
|
177
bdfe4388955d
changed encoding from utf8 to ISO8 (needed to work with xemacs)
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
98 |
consts bla :: "(t \<Rightarrow> t) \<Rightarrow> t"
|
163
|
99 |
local_setup {*
|
|
100 |
fn lthy => (Toplevel.program (fn () =>
|
|
101 |
make_const_def @{binding bla'} @{term "bla"} NoSyn @{typ "t"} @{typ "qt"} lthy
|
|
102 |
)) |> snd
|
|
103 |
*}
|
|
104 |
*)
|
|
105 |
|
|
106 |
local_setup {*
|
|
107 |
make_const_def @{binding VR} @{term "vr"} NoSyn @{typ "t"} @{typ "qt"} #> snd #>
|
|
108 |
make_const_def @{binding AP} @{term "ap"} NoSyn @{typ "t"} @{typ "qt"} #> snd #>
|
|
109 |
make_const_def @{binding LM} @{term "lm"} NoSyn @{typ "t"} @{typ "qt"} #> snd
|
|
110 |
*}
|
|
111 |
|
|
112 |
term vr
|
|
113 |
term ap
|
|
114 |
term lm
|
|
115 |
thm VR_def AP_def LM_def
|
|
116 |
term LM
|
|
117 |
term VR
|
|
118 |
term AP
|
|
119 |
|
|
120 |
text {* a test with functions *}
|
|
121 |
datatype 'a t' =
|
|
122 |
vr' "string"
|
|
123 |
| ap' "('a t') * ('a t')"
|
177
bdfe4388955d
changed encoding from utf8 to ISO8 (needed to work with xemacs)
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
124 |
| lm' "'a" "string \<Rightarrow> ('a t')"
|
163
|
125 |
|
177
bdfe4388955d
changed encoding from utf8 to ISO8 (needed to work with xemacs)
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
126 |
consts Rt' :: "('a t') \<Rightarrow> ('a t') \<Rightarrow> bool"
|
163
|
127 |
axioms t_eq': "EQUIV Rt'"
|
|
128 |
|
|
129 |
quotient qt' = "'a t'" / "Rt'"
|
|
130 |
apply(rule t_eq')
|
|
131 |
done
|
|
132 |
|
|
133 |
print_theorems
|
|
134 |
|
|
135 |
local_setup {*
|
|
136 |
make_const_def @{binding VR'} @{term "vr'"} NoSyn @{typ "'a t'"} @{typ "'a qt'"} #> snd #>
|
|
137 |
make_const_def @{binding AP'} @{term "ap'"} NoSyn @{typ "'a t'"} @{typ "'a qt'"} #> snd #>
|
|
138 |
make_const_def @{binding LM'} @{term "lm'"} NoSyn @{typ "'a t'"} @{typ "'a qt'"} #> snd
|
|
139 |
*}
|
|
140 |
|
|
141 |
term vr'
|
|
142 |
term ap'
|
|
143 |
term ap'
|
|
144 |
thm VR'_def AP'_def LM'_def
|
|
145 |
term LM'
|
|
146 |
term VR'
|
|
147 |
term AP'
|
|
148 |
|
|
149 |
text {* Tests of regularise *}
|
|
150 |
ML {*
|
177
bdfe4388955d
changed encoding from utf8 to ISO8 (needed to work with xemacs)
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
151 |
cterm_of @{theory} (regularise @{term "\<lambda>x :: int. x"} @{typ "trm"} @{term "RR"} @{context});
|
bdfe4388955d
changed encoding from utf8 to ISO8 (needed to work with xemacs)
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
152 |
cterm_of @{theory} (regularise @{term "\<lambda>x :: trm. x"} @{typ "trm"} @{term "RR"} @{context});
|
bdfe4388955d
changed encoding from utf8 to ISO8 (needed to work with xemacs)
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
153 |
cterm_of @{theory} (regularise @{term "\<forall>x :: trm. P x"} @{typ "trm"} @{term "RR"} @{context});
|
bdfe4388955d
changed encoding from utf8 to ISO8 (needed to work with xemacs)
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
154 |
cterm_of @{theory} (regularise @{term "\<exists>x :: trm. P x"} @{typ "trm"} @{term "RR"} @{context});
|
bdfe4388955d
changed encoding from utf8 to ISO8 (needed to work with xemacs)
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
155 |
cterm_of @{theory} (regularise @{term "All (P :: trm \<Rightarrow> bool)"} @{typ "trm"} @{term "RR"} @{context});
|
163
|
156 |
*}
|
|
157 |
|
|
158 |
ML {*
|
177
bdfe4388955d
changed encoding from utf8 to ISO8 (needed to work with xemacs)
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
159 |
cterm_of @{theory} (regularise @{term "\<exists>(y::trm). P (\<lambda>(x::trm). y)"} @{typ "trm"}
|
163
|
160 |
@{term "RR"} @{context});
|
177
bdfe4388955d
changed encoding from utf8 to ISO8 (needed to work with xemacs)
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
161 |
cterm_of @{theory} (my_reg @{term "RR"} @{term "\<exists>(y::trm). P (\<lambda>(x::trm). y)"})
|
163
|
162 |
*}
|
|
163 |
|
|
164 |
ML {*
|
177
bdfe4388955d
changed encoding from utf8 to ISO8 (needed to work with xemacs)
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
165 |
cterm_of @{theory} (regularise @{term "\<lambda>x::trm. x"} @{typ "trm"} @{term "RR"} @{context});
|
bdfe4388955d
changed encoding from utf8 to ISO8 (needed to work with xemacs)
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
166 |
cterm_of @{theory} (my_reg @{term "RR"} @{term "\<lambda>x::trm. x"})
|
163
|
167 |
*}
|
|
168 |
|
|
169 |
ML {*
|
177
bdfe4388955d
changed encoding from utf8 to ISO8 (needed to work with xemacs)
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
170 |
cterm_of @{theory} (regularise @{term "\<forall>(x::trm) (y::trm). P x y"} @{typ "trm"} @{term "RR"} @{context});
|
bdfe4388955d
changed encoding from utf8 to ISO8 (needed to work with xemacs)
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
171 |
cterm_of @{theory} (my_reg @{term "RR"} @{term "\<forall>(x::trm) (y::trm). P x y"})
|
163
|
172 |
*}
|
|
173 |
|
|
174 |
ML {*
|
177
bdfe4388955d
changed encoding from utf8 to ISO8 (needed to work with xemacs)
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
175 |
cterm_of @{theory} (regularise @{term "\<forall>x::trm. P x"} @{typ "trm"} @{term "RR"} @{context});
|
bdfe4388955d
changed encoding from utf8 to ISO8 (needed to work with xemacs)
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
176 |
cterm_of @{theory} (my_reg @{term "RR"} @{term "\<forall>x::trm. P x"})
|
163
|
177 |
*}
|
|
178 |
|
|
179 |
ML {*
|
177
bdfe4388955d
changed encoding from utf8 to ISO8 (needed to work with xemacs)
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
180 |
cterm_of @{theory} (regularise @{term "\<exists>x::trm. P x"} @{typ "trm"} @{term "RR"} @{context});
|
bdfe4388955d
changed encoding from utf8 to ISO8 (needed to work with xemacs)
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
181 |
cterm_of @{theory} (my_reg @{term "RR"} @{term "\<exists>x::trm. P x"})
|
163
|
182 |
*}
|
|
183 |
|
|
184 |
(* my version is not eta-expanded, but that should be OK *)
|
|
185 |
ML {*
|
177
bdfe4388955d
changed encoding from utf8 to ISO8 (needed to work with xemacs)
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
186 |
cterm_of @{theory} (regularise @{term "All (P::trm \<Rightarrow> bool)"} @{typ "trm"} @{term "RR"} @{context});
|
bdfe4388955d
changed encoding from utf8 to ISO8 (needed to work with xemacs)
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
187 |
cterm_of @{theory} (my_reg @{term "RR"} @{term "All (P::trm \<Rightarrow> bool)"})
|
163
|
188 |
*}
|