2208
|
1 |
(* How to change the notation for \<lbrakk> \<rbrakk> meta-level implications? *)
|
2195
|
2 |
|
1975
b1281a0051ae
added stub for quotient paper; call with isabelle make qpaper
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
3 |
(*<*)
|
b1281a0051ae
added stub for quotient paper; call with isabelle make qpaper
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
4 |
theory Paper
|
2183
|
5 |
imports "Quotient"
|
1975
b1281a0051ae
added stub for quotient paper; call with isabelle make qpaper
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
6 |
"LaTeXsugar"
|
2186
|
7 |
"../Nominal/FSet"
|
1975
b1281a0051ae
added stub for quotient paper; call with isabelle make qpaper
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
8 |
begin
|
1994
|
9 |
|
2208
|
10 |
print_syntax
|
|
11 |
|
1994
|
12 |
notation (latex output)
|
2182
|
13 |
rel_conj ("_ OOO _" [53, 53] 52)
|
|
14 |
and
|
2208
|
15 |
"op -->" (infix "\<rightarrow>" 100)
|
|
16 |
and
|
|
17 |
"==>" (infix "\<Rightarrow>" 100)
|
2182
|
18 |
and
|
2208
|
19 |
fun_map (infix "\<longrightarrow>" 51)
|
|
20 |
and
|
|
21 |
fun_rel (infix "\<Longrightarrow>" 51)
|
2188
|
22 |
and
|
|
23 |
list_eq (infix "\<approx>" 50) (* Not sure if we want this notation...? *)
|
1994
|
24 |
|
2182
|
25 |
ML {*
|
|
26 |
fun nth_conj n (_, r) = nth (HOLogic.dest_conj r) n;
|
|
27 |
fun style_lhs_rhs proj = Scan.succeed (fn ctxt => fn t =>
|
|
28 |
let
|
|
29 |
val concl =
|
|
30 |
Object_Logic.drop_judgment (ProofContext.theory_of ctxt) (Logic.strip_imp_concl t)
|
|
31 |
in
|
|
32 |
case concl of (_ $ l $ r) => proj (l, r)
|
|
33 |
| _ => error ("Binary operator expected in term: " ^ Syntax.string_of_term ctxt concl)
|
|
34 |
end);
|
|
35 |
*}
|
|
36 |
setup {*
|
|
37 |
Term_Style.setup "rhs1" (style_lhs_rhs (nth_conj 0)) #>
|
|
38 |
Term_Style.setup "rhs2" (style_lhs_rhs (nth_conj 1)) #>
|
|
39 |
Term_Style.setup "rhs3" (style_lhs_rhs (nth_conj 2))
|
|
40 |
*}
|
1975
b1281a0051ae
added stub for quotient paper; call with isabelle make qpaper
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
41 |
(*>*)
|
b1281a0051ae
added stub for quotient paper; call with isabelle make qpaper
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
42 |
|
b1281a0051ae
added stub for quotient paper; call with isabelle make qpaper
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
43 |
section {* Introduction *}
|
b1281a0051ae
added stub for quotient paper; call with isabelle make qpaper
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
44 |
|
2102
200954544cae
added some of the quotient literature; a bit more to the qpaper
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
45 |
text {*
|
2205
|
46 |
\begin{flushright}
|
|
47 |
{\em ``Not using a [quotient] package has its advantages: we do not have to\\
|
|
48 |
collect all the theorems we shall ever want into one giant list;''}\\
|
|
49 |
Paulson \cite{Paulson06}
|
|
50 |
\end{flushright}\smallskip
|
2103
|
51 |
|
|
52 |
\noindent
|
2102
200954544cae
added some of the quotient literature; a bit more to the qpaper
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
53 |
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
|
54 |
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
|
55 |
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
|
56 |
axioms and inference
|
200954544cae
added some of the quotient literature; a bit more to the qpaper
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
57 |
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
|
58 |
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
|
59 |
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
|
60 |
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
|
61 |
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
|
62 |
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
|
63 |
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
|
64 |
|
2182
|
65 |
% I would avoid substraction for natural numbers.
|
|
66 |
|
2102
200954544cae
added some of the quotient literature; a bit more to the qpaper
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
67 |
@{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
|
68 |
|
200954544cae
added some of the quotient literature; a bit more to the qpaper
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
69 |
\noindent
|
2103
|
70 |
Similarly one can construct the type of finite sets by quotienting lists
|
|
71 |
according to the equivalence relation
|
|
72 |
|
|
73 |
@{text [display] "xs \<approx> ys \<equiv> (\<forall>x. x \<in> xs \<longleftrightarrow> x \<in> ys)"}
|
|
74 |
|
|
75 |
\noindent
|
|
76 |
where @{text "\<in>"} stands for membership in a list.
|
|
77 |
|
|
78 |
The problem is that in order to start reasoning about, for example integers,
|
|
79 |
definitions and theorems need to be transferred, or \emph{lifted},
|
|
80 |
from the ``raw'' type @{typ "nat \<times> nat"} to the quotient type @{typ int}.
|
|
81 |
This lifting usually requires a lot of tedious reasoning effort.
|
|
82 |
The purpose of a \emph{quotient package} is to ease the lifting and automate
|
|
83 |
the reasoning involved as much as possible. Such a package is a central
|
|
84 |
component of the new version of Nominal Isabelle where representations
|
|
85 |
of alpha-equated terms are constructed according to specifications given by
|
|
86 |
the user.
|
2102
200954544cae
added some of the quotient literature; a bit more to the qpaper
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
87 |
|
2103
|
88 |
In the context of HOL, there have been several quotient packages (...). The
|
|
89 |
most notable is the one by Homeier (...) implemented in HOL4. However, what is
|
|
90 |
surprising, none of them can deal compositions of quotients, for example with
|
|
91 |
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
|
92 |
|
2190
|
93 |
@{thm [display] concat.simps(1)}
|
|
94 |
@{thm [display] concat.simps(2)[no_vars]}
|
2183
|
95 |
|
2103
|
96 |
\noindent
|
2188
|
97 |
One would like to lift this definition to the operation:
|
|
98 |
|
2190
|
99 |
@{thm [display] fconcat_empty[no_vars]}
|
|
100 |
@{thm [display] 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
|
101 |
|
2103
|
102 |
\noindent
|
|
103 |
What is special about this operation is that we have as input
|
|
104 |
lists of lists which after lifting turn into finite sets of finite
|
2190
|
105 |
sets.
|
2102
200954544cae
added some of the quotient literature; a bit more to the qpaper
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
106 |
*}
|
1975
b1281a0051ae
added stub for quotient paper; call with isabelle make qpaper
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
107 |
|
1978
|
108 |
subsection {* Contributions *}
|
1975
b1281a0051ae
added stub for quotient paper; call with isabelle make qpaper
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
109 |
|
1978
|
110 |
text {*
|
|
111 |
We present the detailed lifting procedure, which was not shown before.
|
|
112 |
|
|
113 |
The quotient package presented in this paper has the following
|
|
114 |
advantages over existing packages:
|
|
115 |
\begin{itemize}
|
|
116 |
|
|
117 |
\item We define quotient composition, function map composition and
|
|
118 |
relation map composition. This lets lifting polymorphic types with
|
|
119 |
subtypes quotiented as well. We extend the notions of
|
2188
|
120 |
respectfulness and preservation to cope with quotient
|
1978
|
121 |
composition.
|
|
122 |
|
|
123 |
\item We allow lifting only some occurrences of quotiented
|
|
124 |
types. Rsp/Prs extended. (used in nominal)
|
|
125 |
|
|
126 |
\item The quotient package is very modular. Definitions can be added
|
2206
|
127 |
separately, rsp and prs can be proved separately, Quotients and maps
|
|
128 |
can be defined separately and theorems can
|
|
129 |
be lifted on a need basis. (useful with type-classes).
|
1978
|
130 |
|
|
131 |
\item Can be used both manually (attribute, separate tactics,
|
|
132 |
rsp/prs databases) and programatically (automated definition of
|
|
133 |
lifted constants, the rsp proof obligations and theorem statement
|
|
134 |
translation according to given quotients).
|
|
135 |
|
|
136 |
\end{itemize}
|
|
137 |
*}
|
|
138 |
|
|
139 |
section {* Quotient Type*}
|
|
140 |
|
2182
|
141 |
|
|
142 |
|
1978
|
143 |
text {*
|
2182
|
144 |
In this section we present the definitions of a quotient that follow
|
|
145 |
those by Homeier, the proofs can be found there.
|
|
146 |
|
|
147 |
\begin{definition}[Quotient]
|
|
148 |
A relation $R$ with an abstraction function $Abs$
|
|
149 |
and a representation function $Rep$ is a \emph{quotient}
|
|
150 |
if and only if:
|
1978
|
151 |
|
2182
|
152 |
\begin{enumerate}
|
|
153 |
\item @{thm (rhs1) Quotient_def[of "R", no_vars]}
|
|
154 |
\item @{thm (rhs2) Quotient_def[of "R", no_vars]}
|
|
155 |
\item @{thm (rhs3) Quotient_def[of "R", no_vars]}
|
|
156 |
\end{enumerate}
|
|
157 |
|
|
158 |
\end{definition}
|
1978
|
159 |
|
2188
|
160 |
\begin{definition}[Relation map and function map]\\
|
2190
|
161 |
@{thm fun_rel_def[of "R1" "R2", no_vars]}\\
|
2182
|
162 |
@{thm fun_map_def[no_vars]}
|
|
163 |
\end{definition}
|
|
164 |
|
|
165 |
The main theorems for building higher order quotients is:
|
|
166 |
\begin{lemma}[Function Quotient]
|
|
167 |
If @{thm (prem 1) fun_quotient[no_vars]} and @{thm (prem 2) fun_quotient[no_vars]}
|
|
168 |
then @{thm (concl) fun_quotient[no_vars]}
|
|
169 |
\end{lemma}
|
|
170 |
|
1978
|
171 |
*}
|
|
172 |
|
2195
|
173 |
subsection {* Higher Order Logic *}
|
|
174 |
|
|
175 |
text {*
|
|
176 |
|
|
177 |
Types:
|
|
178 |
\begin{eqnarray}\nonumber
|
|
179 |
@{text "\<sigma> ::="} & @{text "\<alpha>"} & \textrm{(type variable)} \\ \nonumber
|
|
180 |
@{text "|"} & @{text "(\<sigma>,\<dots>,\<sigma>)\<kappa>"} & \textrm{(type construction)}
|
|
181 |
\end{eqnarray}
|
|
182 |
|
|
183 |
Terms:
|
|
184 |
\begin{eqnarray}\nonumber
|
|
185 |
@{text "t ::="} & @{text "x\<^isup>\<sigma>"} & \textrm{(variable)} \\ \nonumber
|
|
186 |
@{text "|"} & @{text "c\<^isup>\<sigma>"} & \textrm{(constant)} \\ \nonumber
|
|
187 |
@{text "|"} & @{text "t t"} & \textrm{(application)} \\ \nonumber
|
|
188 |
@{text "|"} & @{text "\<lambda>x\<^isup>\<sigma>. t"} & \textrm{(abstraction)} \\ \nonumber
|
|
189 |
\end{eqnarray}
|
|
190 |
|
|
191 |
*}
|
|
192 |
|
1978
|
193 |
section {* Constants *}
|
|
194 |
|
2188
|
195 |
(* Say more about containers? *)
|
2182
|
196 |
|
1978
|
197 |
text {*
|
2182
|
198 |
|
2188
|
199 |
To define a constant on the lifted type, an aggregate abstraction
|
|
200 |
function is applied to the raw constant. Below we describe the operation
|
|
201 |
that generates
|
|
202 |
an aggregate @{term "Abs"} or @{term "Rep"} function given the
|
|
203 |
compound raw type and the compound quotient type.
|
|
204 |
This operation will also be used in translations of theorem statements
|
|
205 |
and in the lifting procedure.
|
|
206 |
|
|
207 |
The operation is additionally able to descend into types for which
|
|
208 |
maps are known. Such maps for most common types (list, pair, sum,
|
2195
|
209 |
option, \ldots) are described in Homeier, and we assume that @{text "map"}
|
|
210 |
is the function that returns a map for a given type. Then REP/ABS is defined
|
|
211 |
as follows:
|
2182
|
212 |
|
|
213 |
\begin{itemize}
|
2195
|
214 |
\item @{text "ABS(\<alpha>\<^isub>1, \<alpha>\<^isub>2)"} = @{text "id"}
|
|
215 |
\item @{text "REP(\<alpha>\<^isub>1, \<alpha>\<^isub>2)"} = @{text "id"}
|
|
216 |
\item @{text "ABS(\<sigma>, \<sigma>)"} = @{text "id"}
|
|
217 |
\item @{text "REP(\<sigma>, \<sigma>)"} = @{text "id"}
|
2208
|
218 |
\item @{text "ABS(\<sigma>\<^isub>1\<rightarrow>\<sigma>\<^isub>2,\<tau>\<^isub>1\<rightarrow>\<tau>\<^isub>2)"} = @{text "REP(\<sigma>\<^isub>1,\<tau>\<^isub>1) \<longrightarrow> ABS(\<sigma>\<^isub>2,\<tau>\<^isub>2)"}
|
|
219 |
\item @{text "REP(\<sigma>\<^isub>1\<rightarrow>\<sigma>\<^isub>2,\<tau>\<^isub>1\<rightarrow>\<tau>\<^isub>2)"} = @{text "ABS(\<sigma>\<^isub>1,\<tau>\<^isub>1) \<longrightarrow> REP(\<sigma>\<^isub>2,\<tau>\<^isub>2)"}
|
2195
|
220 |
\item @{text "ABS((\<sigma>\<^isub>1,\<dots>,\<sigma>\<^isub>n))\<kappa>, (\<tau>\<^isub>1,\<dots>,\<tau>\<^isub>n))\<kappa>)"} = @{text "(map \<kappa>) (ABS(\<sigma>\<^isub>1,\<tau>\<^isub>1)) \<dots> (ABS(\<sigma>\<^isub>n,\<tau>\<^isub>n))"}
|
|
221 |
\item @{text "REP((\<sigma>\<^isub>1,\<dots>,\<sigma>\<^isub>n))\<kappa>, (\<tau>\<^isub>1,\<dots>,\<tau>\<^isub>n))\<kappa>)"} = @{text "(map \<kappa>) (REP(\<sigma>\<^isub>1,\<tau>\<^isub>1)) \<dots> (REP(\<sigma>\<^isub>n,\<tau>\<^isub>n))"}
|
|
222 |
\item @{text "ABS((\<sigma>\<^isub>1,\<dots>,\<sigma>\<^isub>n))\<kappa>\<^isub>1, (\<tau>\<^isub>1,\<dots>,\<tau>\<^isub>m))\<kappa>\<^isub>2)"} = @{text "Abs_\<kappa>\<^isub>2 \<circ> (map \<kappa>\<^isub>1) (ABS(\<rho>\<^isub>1,\<nu>\<^isub>1) \<dots> (ABS(\<rho>\<^isub>p,\<nu>\<^isub>p)"} provided @{text "\<eta> \<kappa>\<^isub>2 = (\<alpha>\<^isub>1\<dots>\<alpha>\<^isub>p)\<kappa>\<^isub>1 \<and> \<exists>s. s(\<sigma>s\<kappa>\<^isub>1)=\<rho>s\<kappa>\<^isub>1 \<and> s(\<tau>s\<kappa>\<^isub>2)=\<nu>s\<kappa>\<^isub>2"}
|
|
223 |
\item @{text "REP((\<sigma>\<^isub>1,\<dots>,\<sigma>\<^isub>n))\<kappa>\<^isub>1, (\<tau>\<^isub>1,\<dots>,\<tau>\<^isub>m))\<kappa>\<^isub>2)"} = @{text "(map \<kappa>\<^isub>1) (REP(\<rho>\<^isub>1,\<nu>\<^isub>1) \<dots> (REP(\<rho>\<^isub>p,\<nu>\<^isub>p) \<circ> Rep_\<kappa>\<^isub>2"} provided @{text "\<eta> \<kappa>\<^isub>2 = (\<alpha>\<^isub>1\<dots>\<alpha>\<^isub>p)\<kappa>\<^isub>1 \<and> \<exists>s. s(\<sigma>s\<kappa>\<^isub>1)=\<rho>s\<kappa>\<^isub>1 \<and> s(\<tau>s\<kappa>\<^isub>2)=\<nu>s\<kappa>\<^isub>2"}
|
2182
|
224 |
\end{itemize}
|
|
225 |
|
2195
|
226 |
Apart from the last 2 points the definition is same as the one implemented in
|
2208
|
227 |
in Homeier's HOL package. Adding composition in last two cases is necessary
|
|
228 |
for compositional quotients. We ilustrate the different behaviour of the
|
|
229 |
definition by showing the derived definition of @{term fconcat}:
|
2182
|
230 |
|
2188
|
231 |
@{thm fconcat_def[no_vars]}
|
|
232 |
|
|
233 |
The aggregate @{term Abs} function takes a finite set of finite sets
|
|
234 |
and applies @{term "map rep_fset"} composed with @{term rep_fset} to
|
|
235 |
its input, obtaining a list of lists, passes the result to @{term concat}
|
|
236 |
obtaining a list and applies @{term abs_fset} obtaining the composed
|
|
237 |
finite set.
|
|
238 |
*}
|
|
239 |
|
|
240 |
subsection {* Respectfulness *}
|
|
241 |
|
|
242 |
text {*
|
|
243 |
|
|
244 |
A respectfulness lemma for a constant states that the equivalence
|
|
245 |
class returned by this constant depends only on the equivalence
|
2207
|
246 |
classes of the arguments applied to the constant. To automatically
|
|
247 |
lift a theorem that talks about a raw constant, to a theorem about
|
|
248 |
the quotient type a respectfulness theorem is required.
|
|
249 |
|
|
250 |
A respectfulness condition for a constant can be expressed in
|
|
251 |
terms of an aggregate relation between the constant and itself,
|
|
252 |
for example the respectfullness for @{term "append"}
|
2188
|
253 |
can be stated as:
|
|
254 |
|
2190
|
255 |
@{thm [display] append_rsp[no_vars]}
|
2182
|
256 |
|
2190
|
257 |
\noindent
|
2208
|
258 |
Which after unfolding @{term "op \<Longrightarrow>"} is equivalent to:
|
2188
|
259 |
|
2190
|
260 |
@{thm [display] append_rsp_unfolded[no_vars]}
|
2188
|
261 |
|
2207
|
262 |
An aggregate relation is defined in terms of relation composition,
|
|
263 |
so we define it first:
|
2188
|
264 |
|
|
265 |
\begin{definition}[Composition of Relations]
|
2190
|
266 |
@{abbrev "rel_conj R1 R2"} where @{text OO} is the predicate
|
|
267 |
composition @{thm pred_compI[no_vars]}
|
2188
|
268 |
\end{definition}
|
|
269 |
|
2207
|
270 |
The aggregate relation for an aggregate raw type and quotient type
|
|
271 |
is defined as:
|
2188
|
272 |
|
|
273 |
\begin{itemize}
|
2207
|
274 |
\item @{text "REL(\<alpha>\<^isub>1, \<alpha>\<^isub>2)"} = @{text "op ="}
|
|
275 |
\item @{text "REL(\<sigma>, \<sigma>)"} = @{text "op ="}
|
|
276 |
\item @{text "REL((\<sigma>\<^isub>1,\<dots>,\<sigma>\<^isub>n))\<kappa>, (\<tau>\<^isub>1,\<dots>,\<tau>\<^isub>n))\<kappa>)"} = @{text "(rel \<kappa>) (REL(\<sigma>\<^isub>1,\<tau>\<^isub>1)) \<dots> (REL(\<sigma>\<^isub>n,\<tau>\<^isub>n))"}
|
|
277 |
\item @{text "REL((\<sigma>\<^isub>1,\<dots>,\<sigma>\<^isub>n))\<kappa>\<^isub>1, (\<tau>\<^isub>1,\<dots>,\<tau>\<^isub>m))\<kappa>\<^isub>2)"} = @{text "(rel \<kappa>\<^isub>1) (REL(\<rho>\<^isub>1,\<nu>\<^isub>1) \<dots> (REL(\<rho>\<^isub>p,\<nu>\<^isub>p) OOO Eqv_\<kappa>\<^isub>2"} provided @{text "\<eta> \<kappa>\<^isub>2 = (\<alpha>\<^isub>1\<dots>\<alpha>\<^isub>p)\<kappa>\<^isub>1 \<and> \<exists>s. s(\<sigma>s\<kappa>\<^isub>1)=\<rho>s\<kappa>\<^isub>1 \<and> s(\<tau>s\<kappa>\<^isub>2)=\<nu>s\<kappa>\<^isub>2"}
|
2189
|
278 |
|
2188
|
279 |
\end{itemize}
|
|
280 |
|
2207
|
281 |
Again, the last case is novel, so lets look at the example of
|
|
282 |
respectfullness for @{term concat}. The statement according to
|
|
283 |
the definition above is:
|
2190
|
284 |
|
|
285 |
@{thm [display] concat_rsp[no_vars]}
|
2189
|
286 |
|
2190
|
287 |
\noindent
|
|
288 |
By unfolding the definition of relation composition and relation map
|
|
289 |
we can see the equivalent statement just using the primitive list
|
|
290 |
equivalence relation:
|
|
291 |
|
|
292 |
@{thm [display] concat_rsp_unfolded[of "a" "a'" "b'" "b", no_vars]}
|
2189
|
293 |
|
2190
|
294 |
The statement reads that, for any lists of lists @{term a} and @{term b}
|
|
295 |
if there exist intermediate lists of lists @{term "a'"} and @{term "b'"}
|
|
296 |
such that each element of @{term a} is in the relation with an appropriate
|
|
297 |
element of @{term a'}, @{term a'} is in relation with @{term b'} and each
|
|
298 |
element of @{term b'} is in relation with the appropriate element of
|
|
299 |
@{term b}.
|
2189
|
300 |
|
|
301 |
*}
|
|
302 |
|
|
303 |
subsection {* Preservation *}
|
|
304 |
|
2190
|
305 |
text {*
|
|
306 |
To be able to lift theorems that talk about constants that are not
|
|
307 |
lifted but whose type changes when lifting is performed additionally
|
|
308 |
preservation theorems are needed.
|
2196
|
309 |
|
|
310 |
To lift theorems that talk about insertion in lists of lifted types
|
|
311 |
we need to know that for any quotient type with the abstraction and
|
|
312 |
representation functions @{text "Abs"} and @{text Rep} we have:
|
|
313 |
|
|
314 |
@{thm [display] (concl) cons_prs[no_vars]}
|
|
315 |
|
|
316 |
This is not enough to lift theorems that talk about quotient compositions.
|
|
317 |
For some constants (for example empty list) it is possible to show a
|
|
318 |
general compositional theorem, but for @{term "op #"} it is necessary
|
|
319 |
to show that it respects the particular quotient type:
|
|
320 |
|
|
321 |
@{thm [display] insert_preserve2[no_vars]}
|
2190
|
322 |
*}
|
|
323 |
|
2191
|
324 |
subsection {* Composition of Quotient theorems *}
|
2189
|
325 |
|
2191
|
326 |
text {*
|
|
327 |
Given two quotients, one of which quotients a container, and the
|
|
328 |
other quotients the type in the container, we can write the
|
2193
|
329 |
composition of those quotients. To compose two quotient theorems
|
2207
|
330 |
we compose the relations with relation composition as defined above
|
|
331 |
and the abstraction and relation functions are the ones of the sub
|
|
332 |
quotients composed with the usual function composition.
|
|
333 |
The @{term "Rep"} and @{term "Abs"} functions that we obtain agree
|
|
334 |
with the definition of aggregate Abs/Rep functions and the
|
2193
|
335 |
relation is the same as the one given by aggregate relations.
|
|
336 |
This becomes especially interesting
|
2191
|
337 |
when we compose the quotient with itself, as there is no simple
|
|
338 |
intermediate step.
|
|
339 |
|
2193
|
340 |
Lets take again the example of @{term concat}. To be able to lift
|
2207
|
341 |
theorems that talk about it we provide the composition quotient
|
|
342 |
theorems, which then lets us perform the lifting procedure in an
|
|
343 |
unchanged way:
|
2188
|
344 |
|
2190
|
345 |
@{thm [display] quotient_compose_list[no_vars]}
|
2192
|
346 |
*}
|
|
347 |
|
2191
|
348 |
|
|
349 |
section {* Lifting Theorems *}
|
1978
|
350 |
|
2194
|
351 |
text {*
|
|
352 |
The core of the quotient package takes an original theorem that
|
|
353 |
talks about the raw types, and the statement of the theorem that
|
|
354 |
it is supposed to produce. This is different from other existing
|
2207
|
355 |
quotient packages, where only the raw theorems were necessary.
|
2194
|
356 |
We notice that in some cases only some occurrences of the raw
|
|
357 |
types need to be lifted. This is for example the case in the
|
|
358 |
new Nominal package, where a raw datatype that talks about
|
|
359 |
pairs of natural numbers or strings (being lists of characters)
|
|
360 |
should not be changed to a quotient datatype with constructors
|
|
361 |
taking integers or finite sets of characters. To simplify the
|
|
362 |
use of the quotient package we additionally provide an automated
|
|
363 |
statement translation mechanism that replaces occurrences of
|
|
364 |
types that match given quotients by appropriate lifted types.
|
|
365 |
|
|
366 |
Lifting the theorems is performed in three steps. In the following
|
|
367 |
we call these steps \emph{regularization}, \emph{injection} and
|
|
368 |
\emph{cleaning} following the names used in Homeier's HOL
|
2197
|
369 |
implementation.
|
2193
|
370 |
|
2197
|
371 |
We first define the statement of the regularized theorem based
|
|
372 |
on the original theorem and the goal theorem. Then we define
|
|
373 |
the statement of the injected theorem, based on the regularized
|
2208
|
374 |
theorem and the goal. We then show the 3 proofs, as all three
|
2197
|
375 |
can be performed independently from each other.
|
2193
|
376 |
|
2194
|
377 |
*}
|
1994
|
378 |
|
2197
|
379 |
subsection {* Regularization and Injection statements *}
|
1994
|
380 |
|
|
381 |
text {*
|
2197
|
382 |
|
2207
|
383 |
We first define the function @{text REG}, which takes the statements
|
|
384 |
of the raw theorem and the lifted theorem (both as terms) and
|
|
385 |
returns the statement of the regularized version. The intuition
|
|
386 |
behind this function is that it replaces quantifiers and
|
|
387 |
abstractions involving raw types by bounded ones, and equalities
|
|
388 |
involving raw types are replaced by appropriate aggregate
|
|
389 |
relations. It is defined as follows:
|
1994
|
390 |
|
2197
|
391 |
\begin{itemize}
|
2198
|
392 |
\item @{text "REG (\<lambda>x : \<sigma>. t, \<lambda>x : \<sigma>. s) = \<lambda>x : \<sigma>. REG (t, s)"}
|
|
393 |
\item @{text "REG (\<lambda>x : \<sigma>. t, \<lambda>x : \<tau>. s) = \<lambda>x : \<sigma> \<in> Res (REL (\<sigma>, \<tau>)). REG (t, s)"}
|
|
394 |
\item @{text "REG (\<forall>x : \<sigma>. t, \<forall>x : \<sigma>. s) = \<forall>x : \<sigma>. REG (t, s)"}
|
|
395 |
\item @{text "REG (\<forall>x : \<sigma>. t, \<forall>x : \<tau>. s) = \<forall>x : \<sigma> \<in> Res (REL (\<sigma>, \<tau>)). REG (t, s)"}
|
2197
|
396 |
\item @{text "REG ((op =) : \<sigma>, (op =) : \<sigma>) = (op =) : \<sigma>"}
|
|
397 |
\item @{text "REG ((op =) : \<sigma>, (op =) : \<tau>) = REL (\<sigma>, \<tau>) : \<sigma>"}
|
|
398 |
\item @{text "REG (t\<^isub>1 t\<^isub>2, s\<^isub>1 s\<^isub>2) = REG (t\<^isub>1, s\<^isub>1) REG (t\<^isub>2, s\<^isub>2)"}
|
2198
|
399 |
\item @{text "REG (v\<^isub>1, v\<^isub>2) = v\<^isub>1"}
|
|
400 |
\item @{text "REG (c\<^isub>1, c\<^isub>2) = c\<^isub>1"}
|
2197
|
401 |
\end{itemize}
|
1994
|
402 |
|
2207
|
403 |
In the above definition we ommited the cases for existential quantifiers
|
|
404 |
and unique existential quantifiers, as they are very similar to the cases
|
|
405 |
for the universal quantifier.
|
2197
|
406 |
|
2207
|
407 |
Next we define the function @{text INJ} which takes the statement of
|
|
408 |
the regularized theorems and the statement of the lifted theorem both as
|
|
409 |
terms and returns the statment of the injected theorem:
|
2198
|
410 |
|
|
411 |
\begin{itemize}
|
|
412 |
\item @{text "INJ ((\<lambda>x. t) : \<sigma>, (\<lambda>x. s) : \<sigma>) = \<lambda>x. (INJ (t, s)"}
|
|
413 |
\item @{text "INJ ((\<lambda>x. t) : \<sigma>, (\<lambda>x. s) : \<tau>) = REP(\<sigma>,\<tau>) (ABS (\<sigma>,\<tau>) (\<lambda>x. (INJ (t, s))))"}
|
|
414 |
\item @{text "INJ ((\<lambda>x \<in> R. t) : \<sigma>, (\<lambda>x. s) : \<tau>) = REP(\<sigma>,\<tau>) (ABS (\<sigma>,\<tau>) (\<lambda>x \<in> R. (INJ (t, s))))"}
|
|
415 |
\item @{text "INJ (\<forall> t, \<forall> s) = \<forall> (INJ (t, s)"}
|
|
416 |
\item @{text "INJ (\<forall> t \<in> R, \<forall> s) = \<forall> (INJ (t, s) \<in> R"}
|
|
417 |
\item @{text "INJ (t\<^isub>1 t\<^isub>2, s\<^isub>1 s\<^isub>2) = INJ (t\<^isub>1, s\<^isub>1) INJ (t\<^isub>2, s\<^isub>2)"}
|
|
418 |
\item @{text "INJ (v\<^isub>1 : \<sigma>, v\<^isub>2 : \<sigma>) = v\<^isub>1"}
|
|
419 |
\item @{text "INJ (v\<^isub>1 : \<sigma>, v\<^isub>2 : \<tau>) = REP(\<sigma>,\<tau>) (ABS (\<sigma>,\<tau>) (v\<^isub>1))"}
|
|
420 |
\item @{text "INJ (c\<^isub>1 : \<sigma>, c\<^isub>2 : \<sigma>) = c\<^isub>1"}
|
|
421 |
\item @{text "INJ (c\<^isub>1 : \<sigma>, c\<^isub>2 : \<tau>) = REP(\<sigma>,\<tau>) (ABS (\<sigma>,\<tau>) (c\<^isub>1))"}
|
|
422 |
\end{itemize}
|
|
423 |
|
|
424 |
For existential quantifiers and unique existential quantifiers it is
|
|
425 |
defined similarily to the universal one.
|
|
426 |
|
2197
|
427 |
*}
|
|
428 |
|
2208
|
429 |
subsection {* Proof procedure *}
|
|
430 |
|
|
431 |
(* In the below the type-guiding 'QuotTrue' assumption is removed; since we
|
|
432 |
present in a paper a version with typed-variables it is not necessary *)
|
2197
|
433 |
|
|
434 |
text {*
|
2208
|
435 |
|
|
436 |
With the above definitions of @{text "REG"} and @{text "INJ"} we can show
|
|
437 |
how the proof is performed. The first step is always the application of
|
|
438 |
of the following lemma:
|
|
439 |
|
|
440 |
@{term "[|A; A --> B; B = C; C = D|] ==> D"}
|
|
441 |
|
|
442 |
With @{text A} instantiated to the original raw theorem,
|
|
443 |
@{text B} instantiated to @{text "REG(A)"},
|
|
444 |
@{text C} instantiated to @{text "INJ(REG(A))"},
|
|
445 |
and @{text D} instantiated to the statement of the lifted theorem.
|
|
446 |
The first assumption can be immediately discharged using the original
|
|
447 |
theorem and the three left subgoals are exactly the subgoals of regularization,
|
|
448 |
injection and cleaning. The three can be proved independently by the
|
|
449 |
framework and in case there are non-solved subgoals they can be left
|
|
450 |
to the user.
|
|
451 |
|
|
452 |
The injection and cleaning subgoals are always solved if the appropriate
|
|
453 |
respectfulness and preservation theorems are given. It is not the case
|
|
454 |
with regularization; sometimes a theorem given by the user does not
|
|
455 |
imply a regularized version and a stronger one needs to be proved. This
|
|
456 |
is outside of the scope of the quotient package, so the user is then left
|
|
457 |
with such obligations. As an example lets see the simplest possible
|
|
458 |
non-liftable theorem for integers: When we want to prove @{term "0 \<noteq> 1"}
|
|
459 |
on integers the fact that @{term "\<not> (0, 0) = (1, 0)"} is not enough. It
|
|
460 |
only shows that particular items in the equivalence classes are not equal,
|
|
461 |
a more general statement saying that the classes are not equal is necessary.
|
|
462 |
*}
|
|
463 |
|
|
464 |
subsection {* Proving Regularization *}
|
|
465 |
|
|
466 |
text {*
|
|
467 |
Isabelle provides
|
|
468 |
|
2199
|
469 |
|
1994
|
470 |
|
2199
|
471 |
Separtion of regularization from injection thanks to the following 2 lemmas:
|
|
472 |
\begin{lemma}
|
|
473 |
If @{term R2} is an equivalence relation, then:
|
|
474 |
\begin{eqnarray}
|
|
475 |
@{thm (rhs) ball_reg_eqv_range[no_vars]} & = & @{thm (lhs) ball_reg_eqv_range[no_vars]}\\
|
|
476 |
@{thm (rhs) bex_reg_eqv_range[no_vars]} & = & @{thm (lhs) bex_reg_eqv_range[no_vars]}
|
|
477 |
\end{eqnarray}
|
|
478 |
\end{lemma}
|
|
479 |
|
2206
|
480 |
Monos.
|
|
481 |
|
2199
|
482 |
Other lemmas used in regularization:
|
|
483 |
@{thm [display] ball_reg_eqv[no_vars]}
|
|
484 |
@{thm [display] babs_reg_eqv[no_vars]}
|
|
485 |
@{thm [display] babs_simp[no_vars]}
|
|
486 |
|
|
487 |
@{thm [display] ball_reg_right[no_vars]}
|
2206
|
488 |
|
|
489 |
*}
|
|
490 |
|
|
491 |
(*
|
2199
|
492 |
@{thm [display] bex_reg_left[no_vars]}
|
|
493 |
@{thm [display] bex1_bexeq_reg[no_vars]}
|
2206
|
494 |
@{thm [display] bex_reg_eqv[no_vars]}
|
|
495 |
*)
|
1994
|
496 |
|
|
497 |
subsection {* Injection *}
|
|
498 |
|
2199
|
499 |
text {*
|
|
500 |
|
|
501 |
The 2 key lemmas are:
|
|
502 |
|
|
503 |
@{thm [display] apply_rsp[no_vars]}
|
|
504 |
@{thm [display] rep_abs_rsp[no_vars]}
|
|
505 |
|
|
506 |
|
|
507 |
|
|
508 |
*}
|
|
509 |
|
|
510 |
|
|
511 |
|
|
512 |
|
1994
|
513 |
subsection {* Cleaning *}
|
|
514 |
|
|
515 |
text {* Preservation of quantifiers, abstractions, relations, quotient-constants
|
|
516 |
(definitions) and user given constant preservation lemmas *}
|
|
517 |
|
|
518 |
section {* Examples *}
|
|
519 |
|
2206
|
520 |
|
|
521 |
|
1978
|
522 |
section {* Related Work *}
|
|
523 |
|
|
524 |
text {*
|
|
525 |
\begin{itemize}
|
|
526 |
|
2152
|
527 |
\item Peter Homeier's package~\cite{Homeier05} (and related work from there)
|
|
528 |
\item John Harrison's one~\cite{harrison-thesis} is the first one to lift theorems
|
|
529 |
but only first order.
|
1978
|
530 |
|
2152
|
531 |
\item PVS~\cite{PVS:Interpretations}
|
|
532 |
\item MetaPRL~\cite{Nogin02}
|
|
533 |
\item Manually defined quotients in Isabelle/HOL Library (Markus's Quotient\_Type,
|
|
534 |
Dixon's FSet, \ldots)
|
1978
|
535 |
|
|
536 |
\item Oscar Slotosch defines quotient-type automatically but no
|
2152
|
537 |
lifting~\cite{Slotosch97}.
|
1978
|
538 |
|
|
539 |
\item PER. And how to avoid it.
|
|
540 |
|
2152
|
541 |
\item Necessity of Hilbert Choice op and Larry's quotients~\cite{Paulson06}
|
1978
|
542 |
|
2152
|
543 |
\item Setoids in Coq and \cite{ChicliPS02}
|
1978
|
544 |
|
|
545 |
\end{itemize}
|
|
546 |
*}
|
1975
b1281a0051ae
added stub for quotient paper; call with isabelle make qpaper
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
547 |
|
b1281a0051ae
added stub for quotient paper; call with isabelle make qpaper
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
548 |
(*<*)
|
b1281a0051ae
added stub for quotient paper; call with isabelle make qpaper
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
549 |
end
|
1978
|
550 |
(*>*)
|