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