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
|
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)
|
2188
|
14 |
and
|
|
15 |
list_eq (infix "\<approx>" 50) (* Not sure if we want this notation...? *)
|
1994
|
16 |
|
2182
|
17 |
ML {*
|
|
18 |
fun nth_conj n (_, r) = nth (HOLogic.dest_conj r) n;
|
|
19 |
fun style_lhs_rhs proj = Scan.succeed (fn ctxt => fn t =>
|
|
20 |
let
|
|
21 |
val concl =
|
|
22 |
Object_Logic.drop_judgment (ProofContext.theory_of ctxt) (Logic.strip_imp_concl t)
|
|
23 |
in
|
|
24 |
case concl of (_ $ l $ r) => proj (l, r)
|
|
25 |
| _ => error ("Binary operator expected in term: " ^ Syntax.string_of_term ctxt concl)
|
|
26 |
end);
|
|
27 |
*}
|
|
28 |
setup {*
|
|
29 |
Term_Style.setup "rhs1" (style_lhs_rhs (nth_conj 0)) #>
|
|
30 |
Term_Style.setup "rhs2" (style_lhs_rhs (nth_conj 1)) #>
|
|
31 |
Term_Style.setup "rhs3" (style_lhs_rhs (nth_conj 2))
|
|
32 |
*}
|
1975
b1281a0051ae
added stub for quotient paper; call with isabelle make qpaper
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
33 |
(*>*)
|
b1281a0051ae
added stub for quotient paper; call with isabelle make qpaper
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
34 |
|
b1281a0051ae
added stub for quotient paper; call with isabelle make qpaper
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
35 |
section {* Introduction *}
|
b1281a0051ae
added stub for quotient paper; call with isabelle make qpaper
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
36 |
|
2102
200954544cae
added some of the quotient literature; a bit more to the qpaper
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
37 |
text {*
|
2103
|
38 |
{\hfill quote by Larry}\bigskip
|
|
39 |
|
|
40 |
\noindent
|
2102
200954544cae
added some of the quotient literature; a bit more to the qpaper
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
41 |
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>
diff
changeset
|
42 |
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>
diff
changeset
|
43 |
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>
diff
changeset
|
44 |
axioms and inference
|
200954544cae
added some of the quotient literature; a bit more to the qpaper
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
45 |
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>
diff
changeset
|
46 |
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>
diff
changeset
|
47 |
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>
diff
changeset
|
48 |
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>
diff
changeset
|
49 |
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>
diff
changeset
|
50 |
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>
diff
changeset
|
51 |
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>
diff
changeset
|
52 |
|
2182
|
53 |
% I would avoid substraction for natural numbers.
|
|
54 |
|
2102
200954544cae
added some of the quotient literature; a bit more to the qpaper
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
55 |
@{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>
diff
changeset
|
56 |
|
200954544cae
added some of the quotient literature; a bit more to the qpaper
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
57 |
\noindent
|
2103
|
58 |
Similarly one can construct the type of finite sets by quotienting lists
|
|
59 |
according to the equivalence relation
|
|
60 |
|
|
61 |
@{text [display] "xs \<approx> ys \<equiv> (\<forall>x. x \<in> xs \<longleftrightarrow> x \<in> ys)"}
|
|
62 |
|
|
63 |
\noindent
|
|
64 |
where @{text "\<in>"} stands for membership in a list.
|
|
65 |
|
|
66 |
The problem is that in order to start reasoning about, for example integers,
|
|
67 |
definitions and theorems need to be transferred, or \emph{lifted},
|
|
68 |
from the ``raw'' type @{typ "nat \<times> nat"} to the quotient type @{typ int}.
|
|
69 |
This lifting usually requires a lot of tedious reasoning effort.
|
|
70 |
The purpose of a \emph{quotient package} is to ease the lifting and automate
|
|
71 |
the reasoning involved as much as possible. Such a package is a central
|
|
72 |
component of the new version of Nominal Isabelle where representations
|
|
73 |
of alpha-equated terms are constructed according to specifications given by
|
|
74 |
the user.
|
2102
200954544cae
added some of the quotient literature; a bit more to the qpaper
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
75 |
|
2103
|
76 |
In the context of HOL, there have been several quotient packages (...). The
|
|
77 |
most notable is the one by Homeier (...) implemented in HOL4. However, what is
|
|
78 |
surprising, none of them can deal compositions of quotients, for example with
|
|
79 |
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>
diff
changeset
|
80 |
|
2183
|
81 |
@{thm concat.simps(1)}\\
|
|
82 |
@{thm concat.simps(2)[no_vars]}
|
|
83 |
|
2103
|
84 |
\noindent
|
2188
|
85 |
One would like to lift this definition to the operation:
|
|
86 |
|
|
87 |
@{thm fconcat_empty[no_vars]}\\
|
|
88 |
@{thm fconcat_insert[no_vars]}
|
2102
200954544cae
added some of the quotient literature; a bit more to the qpaper
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
89 |
|
2103
|
90 |
\noindent
|
|
91 |
What is special about this operation is that we have as input
|
|
92 |
lists of lists which after lifting turn into finite sets of finite
|
|
93 |
sets.
|
2102
200954544cae
added some of the quotient literature; a bit more to the qpaper
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
94 |
*}
|
1975
b1281a0051ae
added stub for quotient paper; call with isabelle make qpaper
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
95 |
|
1978
|
96 |
subsection {* Contributions *}
|
1975
b1281a0051ae
added stub for quotient paper; call with isabelle make qpaper
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
97 |
|
1978
|
98 |
text {*
|
|
99 |
We present the detailed lifting procedure, which was not shown before.
|
|
100 |
|
|
101 |
The quotient package presented in this paper has the following
|
|
102 |
advantages over existing packages:
|
|
103 |
\begin{itemize}
|
|
104 |
|
|
105 |
\item We define quotient composition, function map composition and
|
|
106 |
relation map composition. This lets lifting polymorphic types with
|
|
107 |
subtypes quotiented as well. We extend the notions of
|
2188
|
108 |
respectfulness and preservation to cope with quotient
|
1978
|
109 |
composition.
|
|
110 |
|
|
111 |
\item We allow lifting only some occurrences of quotiented
|
|
112 |
types. Rsp/Prs extended. (used in nominal)
|
|
113 |
|
|
114 |
\item The quotient package is very modular. Definitions can be added
|
|
115 |
separately, rsp and prs can be proved separately and theorems can
|
2182
|
116 |
be lifted on a need basis. (useful with type-classes).
|
1978
|
117 |
|
|
118 |
\item Can be used both manually (attribute, separate tactics,
|
|
119 |
rsp/prs databases) and programatically (automated definition of
|
|
120 |
lifted constants, the rsp proof obligations and theorem statement
|
|
121 |
translation according to given quotients).
|
|
122 |
|
|
123 |
\end{itemize}
|
|
124 |
*}
|
|
125 |
|
|
126 |
section {* Quotient Type*}
|
|
127 |
|
2182
|
128 |
|
|
129 |
|
1978
|
130 |
text {*
|
2182
|
131 |
In this section we present the definitions of a quotient that follow
|
|
132 |
those by Homeier, the proofs can be found there.
|
|
133 |
|
|
134 |
\begin{definition}[Quotient]
|
|
135 |
A relation $R$ with an abstraction function $Abs$
|
|
136 |
and a representation function $Rep$ is a \emph{quotient}
|
|
137 |
if and only if:
|
1978
|
138 |
|
2182
|
139 |
\begin{enumerate}
|
|
140 |
\item @{thm (rhs1) Quotient_def[of "R", no_vars]}
|
|
141 |
\item @{thm (rhs2) Quotient_def[of "R", no_vars]}
|
|
142 |
\item @{thm (rhs3) Quotient_def[of "R", no_vars]}
|
|
143 |
\end{enumerate}
|
|
144 |
|
|
145 |
\end{definition}
|
1978
|
146 |
|
2188
|
147 |
\begin{definition}[Relation map and function map]\\
|
2182
|
148 |
@{thm fun_rel_def[no_vars]}\\
|
|
149 |
@{thm fun_map_def[no_vars]}
|
|
150 |
\end{definition}
|
|
151 |
|
|
152 |
The main theorems for building higher order quotients is:
|
|
153 |
\begin{lemma}[Function Quotient]
|
|
154 |
If @{thm (prem 1) fun_quotient[no_vars]} and @{thm (prem 2) fun_quotient[no_vars]}
|
|
155 |
then @{thm (concl) fun_quotient[no_vars]}
|
|
156 |
\end{lemma}
|
|
157 |
|
1978
|
158 |
*}
|
|
159 |
|
|
160 |
section {* Constants *}
|
|
161 |
|
2188
|
162 |
(* Say more about containers? *)
|
2182
|
163 |
|
1978
|
164 |
text {*
|
2182
|
165 |
|
2188
|
166 |
To define a constant on the lifted type, an aggregate abstraction
|
|
167 |
function is applied to the raw constant. Below we describe the operation
|
|
168 |
that generates
|
|
169 |
an aggregate @{term "Abs"} or @{term "Rep"} function given the
|
|
170 |
compound raw type and the compound quotient type.
|
|
171 |
This operation will also be used in translations of theorem statements
|
|
172 |
and in the lifting procedure.
|
|
173 |
|
|
174 |
The operation is additionally able to descend into types for which
|
|
175 |
maps are known. Such maps for most common types (list, pair, sum,
|
|
176 |
option, \ldots) are described in Homeier, and our algorithm uses the
|
|
177 |
same kind of maps. Given the raw compound type and the quotient compound
|
|
178 |
type the Rep/Abs algorithm does:
|
2182
|
179 |
|
|
180 |
\begin{itemize}
|
|
181 |
\item For equal types or free type variables return identity.
|
|
182 |
|
|
183 |
\item For function types recurse, change the Rep/Abs flag to
|
|
184 |
the opposite one for the domain type and compose the
|
|
185 |
results with @{term "fun_map"}.
|
|
186 |
|
|
187 |
\item For equal type constructors use the appropriate map function
|
|
188 |
applied to the results for the arguments.
|
|
189 |
|
2188
|
190 |
\item For unequal type constructors, look in the quotients information
|
|
191 |
for a quotient type that matches, and instantiate the raw type
|
|
192 |
appropriately getting back an instantiation environment. We apply
|
|
193 |
the environment to the arguments and recurse composing it with the
|
|
194 |
aggregate map function.
|
2182
|
195 |
\end{itemize}
|
|
196 |
|
2188
|
197 |
The first three points above are identical to the algorithm present in
|
|
198 |
in Homeier's HOL implementation, below is the definition of @{term fconcat}
|
|
199 |
that shows the last step:
|
2182
|
200 |
|
2188
|
201 |
@{thm fconcat_def[no_vars]}
|
|
202 |
|
|
203 |
The aggregate @{term Abs} function takes a finite set of finite sets
|
|
204 |
and applies @{term "map rep_fset"} composed with @{term rep_fset} to
|
|
205 |
its input, obtaining a list of lists, passes the result to @{term concat}
|
|
206 |
obtaining a list and applies @{term abs_fset} obtaining the composed
|
|
207 |
finite set.
|
|
208 |
*}
|
|
209 |
|
|
210 |
subsection {* Respectfulness *}
|
|
211 |
|
|
212 |
text {*
|
|
213 |
|
|
214 |
A respectfulness lemma for a constant states that the equivalence
|
|
215 |
class returned by this constant depends only on the equivalence
|
|
216 |
classes of the arguments applied to the constant. This can be
|
|
217 |
expressed in terms of an aggregate relation between the constant
|
|
218 |
and itself, for example the respectfullness for @{term "append"}
|
|
219 |
can be stated as:
|
|
220 |
|
|
221 |
@{thm append_rsp[no_vars]}
|
2182
|
222 |
|
2188
|
223 |
Which is equivalent to:
|
|
224 |
|
|
225 |
@{thm append_rsp[no_vars,simplified fun_rel_def]}
|
|
226 |
|
|
227 |
Below we show the algorithm for finding the aggregate relation.
|
|
228 |
This algorithm uses
|
|
229 |
the relation composition which we define as:
|
|
230 |
|
|
231 |
\begin{definition}[Composition of Relations]
|
|
232 |
@{abbrev "rel_conj R1 R2"}
|
|
233 |
\end{definition}
|
|
234 |
|
|
235 |
Given an aggregate raw type and quotient type:
|
|
236 |
|
|
237 |
\begin{itemize}
|
|
238 |
\item ...
|
|
239 |
\end{itemize}
|
|
240 |
|
|
241 |
Aggregate @{term "Rep"} and @{term "Abs"} functions are also
|
|
242 |
present in composition quotients. An example composition quotient
|
|
243 |
theorem that needs to be proved is the one needed to lift theorems
|
|
244 |
about concat:
|
|
245 |
|
|
246 |
@{thm quotient_compose_list[no_vars]}
|
|
247 |
|
|
248 |
Prs
|
1978
|
249 |
*}
|
|
250 |
|
|
251 |
section {* Lifting Theorems *}
|
|
252 |
|
1994
|
253 |
text {* TBD *}
|
|
254 |
|
|
255 |
text {* Why providing a statement to prove is necessary is some cases *}
|
|
256 |
|
|
257 |
subsection {* Regularization *}
|
|
258 |
|
|
259 |
text {*
|
|
260 |
Transformation of the theorem statement:
|
|
261 |
\begin{itemize}
|
|
262 |
\item Quantifiers and abstractions involving raw types replaced by bounded ones.
|
|
263 |
\item Equalities involving raw types replaced by bounded ones.
|
|
264 |
\end{itemize}
|
|
265 |
|
|
266 |
The procedure.
|
|
267 |
|
|
268 |
Example of non-regularizable theorem ($0 = 1$).
|
|
269 |
|
2152
|
270 |
Separtion of regularization from injection thanks to the following 2 lemmas:
|
1994
|
271 |
\begin{lemma}
|
|
272 |
If @{term R2} is an equivalence relation, then:
|
|
273 |
\begin{eqnarray}
|
|
274 |
@{thm (rhs) ball_reg_eqv_range[no_vars]} & = & @{thm (lhs) ball_reg_eqv_range[no_vars]}\\
|
|
275 |
@{thm (rhs) bex_reg_eqv_range[no_vars]} & = & @{thm (lhs) bex_reg_eqv_range[no_vars]}
|
|
276 |
\end{eqnarray}
|
|
277 |
\end{lemma}
|
|
278 |
|
|
279 |
*}
|
|
280 |
|
|
281 |
subsection {* Injection *}
|
|
282 |
|
|
283 |
subsection {* Cleaning *}
|
|
284 |
|
|
285 |
text {* Preservation of quantifiers, abstractions, relations, quotient-constants
|
|
286 |
(definitions) and user given constant preservation lemmas *}
|
|
287 |
|
|
288 |
section {* Examples *}
|
|
289 |
|
1978
|
290 |
section {* Related Work *}
|
|
291 |
|
|
292 |
text {*
|
|
293 |
\begin{itemize}
|
|
294 |
|
2152
|
295 |
\item Peter Homeier's package~\cite{Homeier05} (and related work from there)
|
|
296 |
\item John Harrison's one~\cite{harrison-thesis} is the first one to lift theorems
|
|
297 |
but only first order.
|
1978
|
298 |
|
2152
|
299 |
\item PVS~\cite{PVS:Interpretations}
|
|
300 |
\item MetaPRL~\cite{Nogin02}
|
|
301 |
\item Manually defined quotients in Isabelle/HOL Library (Markus's Quotient\_Type,
|
|
302 |
Dixon's FSet, \ldots)
|
1978
|
303 |
|
|
304 |
\item Oscar Slotosch defines quotient-type automatically but no
|
2152
|
305 |
lifting~\cite{Slotosch97}.
|
1978
|
306 |
|
|
307 |
\item PER. And how to avoid it.
|
|
308 |
|
2152
|
309 |
\item Necessity of Hilbert Choice op and Larry's quotients~\cite{Paulson06}
|
1978
|
310 |
|
2152
|
311 |
\item Setoids in Coq and \cite{ChicliPS02}
|
1978
|
312 |
|
|
313 |
\end{itemize}
|
|
314 |
*}
|
1975
b1281a0051ae
added stub for quotient paper; call with isabelle make qpaper
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
315 |
|
b1281a0051ae
added stub for quotient paper; call with isabelle make qpaper
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
316 |
(*<*)
|
b1281a0051ae
added stub for quotient paper; call with isabelle make qpaper
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
317 |
end
|
1978
|
318 |
(*>*)
|