author | Christian Urban <urbanc@in.tum.de> |
Wed, 26 May 2010 15:35:34 +0200 | |
changeset 2186 | 762a739c9eb4 |
parent 2183 | e3ac78e13acc |
child 2188 | 57972032e20e |
permissions | -rw-r--r-- |
1975
b1281a0051ae
added stub for quotient paper; call with isabelle make qpaper
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1 |
(*<*) |
b1281a0051ae
added stub for quotient paper; call with isabelle make qpaper
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
2 |
theory Paper |
2183 | 3 |
imports "Quotient" |
1975
b1281a0051ae
added stub for quotient paper; call with isabelle make qpaper
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
4 |
"LaTeXsugar" |
2186
762a739c9eb4
added FSet to the correct paper
Christian Urban <urbanc@in.tum.de>
parents:
2183
diff
changeset
|
5 |
"../Nominal/FSet" |
1975
b1281a0051ae
added stub for quotient paper; call with isabelle make qpaper
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
6 |
begin |
1994 | 7 |
|
8 |
notation (latex output) |
|
2182 | 9 |
rel_conj ("_ OOO _" [53, 53] 52) |
10 |
and |
|
11 |
fun_map ("_ ---> _" [51, 51] 50) |
|
12 |
and |
|
1994 | 13 |
fun_rel ("_ ===> _" [51, 51] 50) |
14 |
||
2182 | 15 |
ML {* |
16 |
fun nth_conj n (_, r) = nth (HOLogic.dest_conj r) n; |
|
17 |
fun style_lhs_rhs proj = Scan.succeed (fn ctxt => fn t => |
|
18 |
let |
|
19 |
val concl = |
|
20 |
Object_Logic.drop_judgment (ProofContext.theory_of ctxt) (Logic.strip_imp_concl t) |
|
21 |
in |
|
22 |
case concl of (_ $ l $ r) => proj (l, r) |
|
23 |
| _ => error ("Binary operator expected in term: " ^ Syntax.string_of_term ctxt concl) |
|
24 |
end); |
|
25 |
*} |
|
26 |
setup {* |
|
27 |
Term_Style.setup "rhs1" (style_lhs_rhs (nth_conj 0)) #> |
|
28 |
Term_Style.setup "rhs2" (style_lhs_rhs (nth_conj 1)) #> |
|
29 |
Term_Style.setup "rhs3" (style_lhs_rhs (nth_conj 2)) |
|
30 |
*} |
|
1975
b1281a0051ae
added stub for quotient paper; call with isabelle make qpaper
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
31 |
(*>*) |
b1281a0051ae
added stub for quotient paper; call with isabelle make qpaper
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
32 |
|
b1281a0051ae
added stub for quotient paper; call with isabelle make qpaper
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
33 |
section {* Introduction *} |
b1281a0051ae
added stub for quotient paper; call with isabelle make qpaper
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
34 |
|
2102
200954544cae
added some of the quotient literature; a bit more to the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
1994
diff
changeset
|
35 |
text {* |
2103
e08e3c29dbc0
a bit for the introduction of the q-paper
Christian Urban <urbanc@in.tum.de>
parents:
2102
diff
changeset
|
36 |
{\hfill quote by Larry}\bigskip |
e08e3c29dbc0
a bit for the introduction of the q-paper
Christian Urban <urbanc@in.tum.de>
parents:
2102
diff
changeset
|
37 |
|
e08e3c29dbc0
a bit for the introduction of the q-paper
Christian Urban <urbanc@in.tum.de>
parents:
2102
diff
changeset
|
38 |
\noindent |
2102
200954544cae
added some of the quotient literature; a bit more to the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
1994
diff
changeset
|
39 |
Isabelle is a generic theorem prover in which many logics can be implemented. |
200954544cae
added some of the quotient literature; a bit more to the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
1994
diff
changeset
|
40 |
The most widely used one, however, is |
200954544cae
added some of the quotient literature; a bit more to the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
1994
diff
changeset
|
41 |
Higher-Order Logic (HOL). This logic consists of a small number of |
200954544cae
added some of the quotient literature; a bit more to the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
1994
diff
changeset
|
42 |
axioms and inference |
200954544cae
added some of the quotient literature; a bit more to the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
1994
diff
changeset
|
43 |
rules over a simply-typed term-language. Safe reasoning in HOL is ensured by two very restricted |
200954544cae
added some of the quotient literature; a bit more to the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
1994
diff
changeset
|
44 |
mechanisms for extending the logic: one is the definition of new constants |
200954544cae
added some of the quotient literature; a bit more to the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
1994
diff
changeset
|
45 |
in terms of existing ones; the other is the introduction of new types |
200954544cae
added some of the quotient literature; a bit more to the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
1994
diff
changeset
|
46 |
by identifying non-empty subsets in existing types. It is well understood |
200954544cae
added some of the quotient literature; a bit more to the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
1994
diff
changeset
|
47 |
to use both mechanism for dealing with quotient constructions in HOL (cite Larry). |
200954544cae
added some of the quotient literature; a bit more to the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
1994
diff
changeset
|
48 |
For example the integers in Isabelle/HOL are constructed by a quotient construction over |
200954544cae
added some of the quotient literature; a bit more to the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
1994
diff
changeset
|
49 |
the type @{typ "nat \<times> nat"} and the equivalence relation |
200954544cae
added some of the quotient literature; a bit more to the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
1994
diff
changeset
|
50 |
|
2182 | 51 |
% I would avoid substraction for natural numbers. |
52 |
||
2102
200954544cae
added some of the quotient literature; a bit more to the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
1994
diff
changeset
|
53 |
@{text [display] "(n\<^isub>1, n\<^isub>2) \<approx> (m\<^isub>1, m\<^isub>2) \<equiv> n\<^isub>1 - n \<^isub>2 = m\<^isub>1 - m \<^isub>2"} |
200954544cae
added some of the quotient literature; a bit more to the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
1994
diff
changeset
|
54 |
|
200954544cae
added some of the quotient literature; a bit more to the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
1994
diff
changeset
|
55 |
\noindent |
2103
e08e3c29dbc0
a bit for the introduction of the q-paper
Christian Urban <urbanc@in.tum.de>
parents:
2102
diff
changeset
|
56 |
Similarly one can construct the type of finite sets by quotienting lists |
e08e3c29dbc0
a bit for the introduction of the q-paper
Christian Urban <urbanc@in.tum.de>
parents:
2102
diff
changeset
|
57 |
according to the equivalence relation |
e08e3c29dbc0
a bit for the introduction of the q-paper
Christian Urban <urbanc@in.tum.de>
parents:
2102
diff
changeset
|
58 |
|
e08e3c29dbc0
a bit for the introduction of the q-paper
Christian Urban <urbanc@in.tum.de>
parents:
2102
diff
changeset
|
59 |
@{text [display] "xs \<approx> ys \<equiv> (\<forall>x. x \<in> xs \<longleftrightarrow> x \<in> ys)"} |
e08e3c29dbc0
a bit for the introduction of the q-paper
Christian Urban <urbanc@in.tum.de>
parents:
2102
diff
changeset
|
60 |
|
e08e3c29dbc0
a bit for the introduction of the q-paper
Christian Urban <urbanc@in.tum.de>
parents:
2102
diff
changeset
|
61 |
\noindent |
e08e3c29dbc0
a bit for the introduction of the q-paper
Christian Urban <urbanc@in.tum.de>
parents:
2102
diff
changeset
|
62 |
where @{text "\<in>"} stands for membership in a list. |
e08e3c29dbc0
a bit for the introduction of the q-paper
Christian Urban <urbanc@in.tum.de>
parents:
2102
diff
changeset
|
63 |
|
e08e3c29dbc0
a bit for the introduction of the q-paper
Christian Urban <urbanc@in.tum.de>
parents:
2102
diff
changeset
|
64 |
The problem is that in order to start reasoning about, for example integers, |
e08e3c29dbc0
a bit for the introduction of the q-paper
Christian Urban <urbanc@in.tum.de>
parents:
2102
diff
changeset
|
65 |
definitions and theorems need to be transferred, or \emph{lifted}, |
e08e3c29dbc0
a bit for the introduction of the q-paper
Christian Urban <urbanc@in.tum.de>
parents:
2102
diff
changeset
|
66 |
from the ``raw'' type @{typ "nat \<times> nat"} to the quotient type @{typ int}. |
e08e3c29dbc0
a bit for the introduction of the q-paper
Christian Urban <urbanc@in.tum.de>
parents:
2102
diff
changeset
|
67 |
This lifting usually requires a lot of tedious reasoning effort. |
e08e3c29dbc0
a bit for the introduction of the q-paper
Christian Urban <urbanc@in.tum.de>
parents:
2102
diff
changeset
|
68 |
The purpose of a \emph{quotient package} is to ease the lifting and automate |
e08e3c29dbc0
a bit for the introduction of the q-paper
Christian Urban <urbanc@in.tum.de>
parents:
2102
diff
changeset
|
69 |
the reasoning involved as much as possible. Such a package is a central |
e08e3c29dbc0
a bit for the introduction of the q-paper
Christian Urban <urbanc@in.tum.de>
parents:
2102
diff
changeset
|
70 |
component of the new version of Nominal Isabelle where representations |
e08e3c29dbc0
a bit for the introduction of the q-paper
Christian Urban <urbanc@in.tum.de>
parents:
2102
diff
changeset
|
71 |
of alpha-equated terms are constructed according to specifications given by |
e08e3c29dbc0
a bit for the introduction of the q-paper
Christian Urban <urbanc@in.tum.de>
parents:
2102
diff
changeset
|
72 |
the user. |
2102
200954544cae
added some of the quotient literature; a bit more to the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
1994
diff
changeset
|
73 |
|
2103
e08e3c29dbc0
a bit for the introduction of the q-paper
Christian Urban <urbanc@in.tum.de>
parents:
2102
diff
changeset
|
74 |
In the context of HOL, there have been several quotient packages (...). The |
e08e3c29dbc0
a bit for the introduction of the q-paper
Christian Urban <urbanc@in.tum.de>
parents:
2102
diff
changeset
|
75 |
most notable is the one by Homeier (...) implemented in HOL4. However, what is |
e08e3c29dbc0
a bit for the introduction of the q-paper
Christian Urban <urbanc@in.tum.de>
parents:
2102
diff
changeset
|
76 |
surprising, none of them can deal compositions of quotients, for example with |
e08e3c29dbc0
a bit for the introduction of the q-paper
Christian Urban <urbanc@in.tum.de>
parents:
2102
diff
changeset
|
77 |
lifting theorems about @{text "concat"}: |
2102
200954544cae
added some of the quotient literature; a bit more to the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
1994
diff
changeset
|
78 |
|
2183 | 79 |
@{thm concat.simps(1)}\\ |
80 |
@{thm concat.simps(2)[no_vars]} |
|
81 |
||
2103
e08e3c29dbc0
a bit for the introduction of the q-paper
Christian Urban <urbanc@in.tum.de>
parents:
2102
diff
changeset
|
82 |
\noindent |
e08e3c29dbc0
a bit for the introduction of the q-paper
Christian Urban <urbanc@in.tum.de>
parents:
2102
diff
changeset
|
83 |
One would like to lift this definition to the operation |
e08e3c29dbc0
a bit for the introduction of the q-paper
Christian Urban <urbanc@in.tum.de>
parents:
2102
diff
changeset
|
84 |
|
e08e3c29dbc0
a bit for the introduction of the q-paper
Christian Urban <urbanc@in.tum.de>
parents:
2102
diff
changeset
|
85 |
@{text [display] "union definition"} |
2102
200954544cae
added some of the quotient literature; a bit more to the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
1994
diff
changeset
|
86 |
|
2103
e08e3c29dbc0
a bit for the introduction of the q-paper
Christian Urban <urbanc@in.tum.de>
parents:
2102
diff
changeset
|
87 |
\noindent |
e08e3c29dbc0
a bit for the introduction of the q-paper
Christian Urban <urbanc@in.tum.de>
parents:
2102
diff
changeset
|
88 |
What is special about this operation is that we have as input |
e08e3c29dbc0
a bit for the introduction of the q-paper
Christian Urban <urbanc@in.tum.de>
parents:
2102
diff
changeset
|
89 |
lists of lists which after lifting turn into finite sets of finite |
e08e3c29dbc0
a bit for the introduction of the q-paper
Christian Urban <urbanc@in.tum.de>
parents:
2102
diff
changeset
|
90 |
sets. |
2102
200954544cae
added some of the quotient literature; a bit more to the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
1994
diff
changeset
|
91 |
*} |
1975
b1281a0051ae
added stub for quotient paper; call with isabelle make qpaper
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
92 |
|
1978 | 93 |
subsection {* Contributions *} |
1975
b1281a0051ae
added stub for quotient paper; call with isabelle make qpaper
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
94 |
|
1978 | 95 |
text {* |
96 |
We present the detailed lifting procedure, which was not shown before. |
|
97 |
||
98 |
The quotient package presented in this paper has the following |
|
99 |
advantages over existing packages: |
|
100 |
\begin{itemize} |
|
101 |
||
102 |
\item We define quotient composition, function map composition and |
|
103 |
relation map composition. This lets lifting polymorphic types with |
|
104 |
subtypes quotiented as well. We extend the notions of |
|
105 |
respectfullness and preservation to cope with quotient |
|
106 |
composition. |
|
107 |
||
108 |
\item We allow lifting only some occurrences of quotiented |
|
109 |
types. Rsp/Prs extended. (used in nominal) |
|
110 |
||
111 |
\item The quotient package is very modular. Definitions can be added |
|
112 |
separately, rsp and prs can be proved separately and theorems can |
|
2182 | 113 |
be lifted on a need basis. (useful with type-classes). |
1978 | 114 |
|
115 |
\item Can be used both manually (attribute, separate tactics, |
|
116 |
rsp/prs databases) and programatically (automated definition of |
|
117 |
lifted constants, the rsp proof obligations and theorem statement |
|
118 |
translation according to given quotients). |
|
119 |
||
120 |
\end{itemize} |
|
121 |
*} |
|
122 |
||
123 |
section {* Quotient Type*} |
|
124 |
||
2182 | 125 |
|
126 |
||
1978 | 127 |
text {* |
2182 | 128 |
In this section we present the definitions of a quotient that follow |
129 |
those by Homeier, the proofs can be found there. |
|
130 |
||
131 |
\begin{definition}[Quotient] |
|
132 |
A relation $R$ with an abstraction function $Abs$ |
|
133 |
and a representation function $Rep$ is a \emph{quotient} |
|
134 |
if and only if: |
|
1978 | 135 |
|
2182 | 136 |
\begin{enumerate} |
137 |
\item @{thm (rhs1) Quotient_def[of "R", no_vars]} |
|
138 |
\item @{thm (rhs2) Quotient_def[of "R", no_vars]} |
|
139 |
\item @{thm (rhs3) Quotient_def[of "R", no_vars]} |
|
140 |
\end{enumerate} |
|
141 |
||
142 |
\end{definition} |
|
1978 | 143 |
|
2182 | 144 |
\begin{definition}[Relation map and function map] |
145 |
@{thm fun_rel_def[no_vars]}\\ |
|
146 |
@{thm fun_map_def[no_vars]} |
|
147 |
\end{definition} |
|
148 |
||
149 |
The main theorems for building higher order quotients is: |
|
150 |
\begin{lemma}[Function Quotient] |
|
151 |
If @{thm (prem 1) fun_quotient[no_vars]} and @{thm (prem 2) fun_quotient[no_vars]} |
|
152 |
then @{thm (concl) fun_quotient[no_vars]} |
|
153 |
\end{lemma} |
|
154 |
||
1978 | 155 |
*} |
156 |
||
157 |
section {* Constants *} |
|
158 |
||
2182 | 159 |
(* Describe what containers are? *) |
160 |
||
1978 | 161 |
text {* |
2182 | 162 |
\begin{definition}[Composition of Relations] |
163 |
@{abbrev "rel_conj R1 R2"} |
|
164 |
\end{definition} |
|
165 |
||
166 |
The first operation that we describe is the generation of |
|
167 |
aggregate Abs or Rep function for two given compound types. |
|
168 |
This operation will be used for the constant defnitions |
|
169 |
and for the translation of theorems statements. It relies on |
|
170 |
knowing map functions and relation functions for container types. |
|
171 |
It follows the following algorithm: |
|
172 |
||
173 |
\begin{itemize} |
|
174 |
\item For equal types or free type variables return identity. |
|
175 |
||
176 |
\item For function types recurse, change the Rep/Abs flag to |
|
177 |
the opposite one for the domain type and compose the |
|
178 |
results with @{term "fun_map"}. |
|
179 |
||
180 |
\item For equal type constructors use the appropriate map function |
|
181 |
applied to the results for the arguments. |
|
182 |
||
183 |
\item For unequal type constructors are unequal, we look in the |
|
184 |
quotients information for a raw type quotient type pair that |
|
185 |
matches the given types. We apply the environment to the arguments |
|
186 |
and recurse composing it with the aggregate map function. |
|
187 |
\end{itemize} |
|
188 |
||
189 |
||
190 |
||
191 |
Rsp and Prs |
|
1978 | 192 |
*} |
193 |
||
194 |
section {* Lifting Theorems *} |
|
195 |
||
1994 | 196 |
text {* TBD *} |
197 |
||
198 |
text {* Why providing a statement to prove is necessary is some cases *} |
|
199 |
||
200 |
subsection {* Regularization *} |
|
201 |
||
202 |
text {* |
|
203 |
Transformation of the theorem statement: |
|
204 |
\begin{itemize} |
|
205 |
\item Quantifiers and abstractions involving raw types replaced by bounded ones. |
|
206 |
\item Equalities involving raw types replaced by bounded ones. |
|
207 |
\end{itemize} |
|
208 |
||
209 |
The procedure. |
|
210 |
||
211 |
Example of non-regularizable theorem ($0 = 1$). |
|
212 |
||
2152
d7d4491535a9
starting bibliography
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2103
diff
changeset
|
213 |
Separtion of regularization from injection thanks to the following 2 lemmas: |
1994 | 214 |
\begin{lemma} |
215 |
If @{term R2} is an equivalence relation, then: |
|
216 |
\begin{eqnarray} |
|
217 |
@{thm (rhs) ball_reg_eqv_range[no_vars]} & = & @{thm (lhs) ball_reg_eqv_range[no_vars]}\\ |
|
218 |
@{thm (rhs) bex_reg_eqv_range[no_vars]} & = & @{thm (lhs) bex_reg_eqv_range[no_vars]} |
|
219 |
\end{eqnarray} |
|
220 |
\end{lemma} |
|
221 |
||
222 |
*} |
|
223 |
||
224 |
subsection {* Injection *} |
|
225 |
||
226 |
subsection {* Cleaning *} |
|
227 |
||
228 |
text {* Preservation of quantifiers, abstractions, relations, quotient-constants |
|
229 |
(definitions) and user given constant preservation lemmas *} |
|
230 |
||
231 |
section {* Examples *} |
|
232 |
||
1978 | 233 |
section {* Related Work *} |
234 |
||
235 |
text {* |
|
236 |
\begin{itemize} |
|
237 |
||
2152
d7d4491535a9
starting bibliography
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2103
diff
changeset
|
238 |
\item Peter Homeier's package~\cite{Homeier05} (and related work from there) |
d7d4491535a9
starting bibliography
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2103
diff
changeset
|
239 |
\item John Harrison's one~\cite{harrison-thesis} is the first one to lift theorems |
d7d4491535a9
starting bibliography
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2103
diff
changeset
|
240 |
but only first order. |
1978 | 241 |
|
2152
d7d4491535a9
starting bibliography
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2103
diff
changeset
|
242 |
\item PVS~\cite{PVS:Interpretations} |
d7d4491535a9
starting bibliography
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2103
diff
changeset
|
243 |
\item MetaPRL~\cite{Nogin02} |
d7d4491535a9
starting bibliography
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2103
diff
changeset
|
244 |
\item Manually defined quotients in Isabelle/HOL Library (Markus's Quotient\_Type, |
d7d4491535a9
starting bibliography
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2103
diff
changeset
|
245 |
Dixon's FSet, \ldots) |
1978 | 246 |
|
247 |
\item Oscar Slotosch defines quotient-type automatically but no |
|
2152
d7d4491535a9
starting bibliography
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2103
diff
changeset
|
248 |
lifting~\cite{Slotosch97}. |
1978 | 249 |
|
250 |
\item PER. And how to avoid it. |
|
251 |
||
2152
d7d4491535a9
starting bibliography
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2103
diff
changeset
|
252 |
\item Necessity of Hilbert Choice op and Larry's quotients~\cite{Paulson06} |
1978 | 253 |
|
2152
d7d4491535a9
starting bibliography
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2103
diff
changeset
|
254 |
\item Setoids in Coq and \cite{ChicliPS02} |
1978 | 255 |
|
256 |
\end{itemize} |
|
257 |
*} |
|
1975
b1281a0051ae
added stub for quotient paper; call with isabelle make qpaper
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
258 |
|
b1281a0051ae
added stub for quotient paper; call with isabelle make qpaper
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
259 |
(*<*) |
b1281a0051ae
added stub for quotient paper; call with isabelle make qpaper
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
260 |
end |
1978 | 261 |
(*>*) |