author | Cezary Kaliszyk <kaliszyk@in.tum.de> |
Tue, 15 Jun 2010 12:00:03 +0200 | |
changeset 2272 | bf3a29ea74f6 |
parent 2271 | c0c5bc4ee8cb |
parent 2270 | 4ae32dd02d14 |
child 2273 | d62c082cb56b |
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) |
|
2258
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
9 |
rel_conj ("_ \<circ>\<circ>\<circ> _" [53, 53] 52) and |
2269
e4699a240d2c
tuned everytinh up to section 4
Christian Urban <urbanc@in.tum.de>
parents:
2265
diff
changeset
|
10 |
pred_comp ("_ \<circ>\<circ> _" [1, 1] 30) and |
2258
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
11 |
"op -->" (infix "\<longrightarrow>" 100) and |
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
12 |
"==>" (infix "\<Longrightarrow>" 100) and |
2227 | 13 |
fun_map ("_ \<^raw:\mbox{\singlearr}> _" 51) and |
14 |
fun_rel ("_ \<^raw:\mbox{\doublearr}> _" 51) and |
|
2217 | 15 |
list_eq (infix "\<approx>" 50) and (* Not sure if we want this notation...? *) |
2223 | 16 |
fempty ("\<emptyset>") and |
17 |
funion ("_ \<union> _") and |
|
18 |
finsert ("{_} \<union> _") and |
|
2221
e749cefbf66c
even more on the qpaper (intro almost done)
Christian Urban <urbanc@in.tum.de>
parents:
2220
diff
changeset
|
19 |
Cons ("_::_") and |
e749cefbf66c
even more on the qpaper (intro almost done)
Christian Urban <urbanc@in.tum.de>
parents:
2220
diff
changeset
|
20 |
concat ("flat") and |
2223 | 21 |
fconcat ("\<Union>") |
2220
2c4c0d93daa6
more to the introduction of the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
2217
diff
changeset
|
22 |
|
2217 | 23 |
|
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 |
|
2227 | 43 |
|
1975
b1281a0051ae
added stub for quotient paper; call with isabelle make qpaper
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
44 |
section {* Introduction *} |
b1281a0051ae
added stub for quotient paper; call with isabelle make qpaper
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
45 |
|
2102
200954544cae
added some of the quotient literature; a bit more to the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
1994
diff
changeset
|
46 |
text {* |
2205 | 47 |
\begin{flushright} |
48 |
{\em ``Not using a [quotient] package has its advantages: we do not have to\\ |
|
49 |
collect all the theorems we shall ever want into one giant list;''}\\ |
|
2213
231a20534950
improved abstract, some tuning
Christian Urban <urbanc@in.tum.de>
parents:
2212
diff
changeset
|
50 |
Larry Paulson \cite{Paulson06} |
2237 | 51 |
\end{flushright} |
2103
e08e3c29dbc0
a bit for the introduction of the q-paper
Christian Urban <urbanc@in.tum.de>
parents:
2102
diff
changeset
|
52 |
|
e08e3c29dbc0
a bit for the introduction of the q-paper
Christian Urban <urbanc@in.tum.de>
parents:
2102
diff
changeset
|
53 |
\noindent |
2220
2c4c0d93daa6
more to the introduction of the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
2217
diff
changeset
|
54 |
Isabelle is a popular generic theorem prover in which many logics can be |
2214
02e03d4287ec
a bit more in the introduction and abstract
Christian Urban <urbanc@in.tum.de>
parents:
2213
diff
changeset
|
55 |
implemented. The most widely used one, however, is Higher-Order Logic |
02e03d4287ec
a bit more in the introduction and abstract
Christian Urban <urbanc@in.tum.de>
parents:
2213
diff
changeset
|
56 |
(HOL). This logic consists of a small number of axioms and inference rules |
02e03d4287ec
a bit more in the introduction and abstract
Christian Urban <urbanc@in.tum.de>
parents:
2213
diff
changeset
|
57 |
over a simply-typed term-language. Safe reasoning in HOL is ensured by two |
02e03d4287ec
a bit more in the introduction and abstract
Christian Urban <urbanc@in.tum.de>
parents:
2213
diff
changeset
|
58 |
very restricted mechanisms for extending the logic: one is the definition of |
02e03d4287ec
a bit more in the introduction and abstract
Christian Urban <urbanc@in.tum.de>
parents:
2213
diff
changeset
|
59 |
new constants in terms of existing ones; the other is the introduction of |
02e03d4287ec
a bit more in the introduction and abstract
Christian Urban <urbanc@in.tum.de>
parents:
2213
diff
changeset
|
60 |
new types by identifying non-empty subsets in existing types. It is well |
2223 | 61 |
understood how to use both mechanisms for dealing with quotient |
2220
2c4c0d93daa6
more to the introduction of the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
2217
diff
changeset
|
62 |
constructions in HOL (see \cite{Homeier05,Paulson06}). For example the |
2c4c0d93daa6
more to the introduction of the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
2217
diff
changeset
|
63 |
integers in Isabelle/HOL are constructed by a quotient construction over the |
2c4c0d93daa6
more to the introduction of the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
2217
diff
changeset
|
64 |
type @{typ "nat \<times> nat"} and the equivalence relation |
2102
200954544cae
added some of the quotient literature; a bit more to the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
1994
diff
changeset
|
65 |
|
2237 | 66 |
\begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
67 |
@{text "(n\<^isub>1, n\<^isub>2) \<approx> (m\<^isub>1, m\<^isub>2) \<equiv> n\<^isub>1 + m\<^isub>2 = m\<^isub>1 + n\<^isub>2"}\hfill\numbered{natpairequiv} |
|
68 |
\end{isabelle} |
|
2102
200954544cae
added some of the quotient literature; a bit more to the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
1994
diff
changeset
|
69 |
|
200954544cae
added some of the quotient literature; a bit more to the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
1994
diff
changeset
|
70 |
\noindent |
2217 | 71 |
This constructions yields the new type @{typ int} and definitions for @{text |
2220
2c4c0d93daa6
more to the introduction of the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
2217
diff
changeset
|
72 |
"0"} and @{text "1"} of type @{typ int} can be given in terms of pairs of |
2c4c0d93daa6
more to the introduction of the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
2217
diff
changeset
|
73 |
natural numbers (namely @{text "(0, 0)"} and @{text "(1, 0)"}). Operations |
2c4c0d93daa6
more to the introduction of the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
2217
diff
changeset
|
74 |
such as @{text "add"} with type @{typ "int \<Rightarrow> int \<Rightarrow> int"} can be defined in |
2c4c0d93daa6
more to the introduction of the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
2217
diff
changeset
|
75 |
terms of operations on pairs of natural numbers (namely @{text |
2224
f5b6f9d8a882
completed the intro (except minor things)
Christian Urban <urbanc@in.tum.de>
parents:
2223
diff
changeset
|
76 |
"add_pair (n\<^isub>1, m\<^isub>1) (n\<^isub>2, |
2222 | 77 |
m\<^isub>2) \<equiv> (n\<^isub>1 + n\<^isub>2, m\<^isub>1 + m\<^isub>2)"}). |
78 |
Similarly one can construct the type of finite sets, written @{term "\<alpha> fset"}, |
|
2223 | 79 |
by quotienting the type @{text "\<alpha> list"} according to the equivalence relation |
2103
e08e3c29dbc0
a bit for the introduction of the q-paper
Christian Urban <urbanc@in.tum.de>
parents:
2102
diff
changeset
|
80 |
|
2237 | 81 |
\begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
82 |
@{text "xs \<approx> ys \<equiv> (\<forall>x. memb x xs \<longleftrightarrow> memb x ys)"}\hfill\numbered{listequiv} |
|
83 |
\end{isabelle} |
|
2103
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 |
\noindent |
2224
f5b6f9d8a882
completed the intro (except minor things)
Christian Urban <urbanc@in.tum.de>
parents:
2223
diff
changeset
|
86 |
which states that two lists are equivalent if every element in one list is |
f5b6f9d8a882
completed the intro (except minor things)
Christian Urban <urbanc@in.tum.de>
parents:
2223
diff
changeset
|
87 |
also member in the other. The empty finite set, written @{term "{||}"}, can |
f5b6f9d8a882
completed the intro (except minor things)
Christian Urban <urbanc@in.tum.de>
parents:
2223
diff
changeset
|
88 |
then be defined as the empty list and the union of two finite sets, written |
f5b6f9d8a882
completed the intro (except minor things)
Christian Urban <urbanc@in.tum.de>
parents:
2223
diff
changeset
|
89 |
@{text "\<union>"}, as list append. |
2220
2c4c0d93daa6
more to the introduction of the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
2217
diff
changeset
|
90 |
|
2269
e4699a240d2c
tuned everytinh up to section 4
Christian Urban <urbanc@in.tum.de>
parents:
2265
diff
changeset
|
91 |
Quotients are important in a variety of areas, but they are really ubiquitous in |
2258
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
92 |
the area of reasoning about programming language calculi. A simple example |
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
93 |
is the lambda-calculus, whose raw terms are defined as |
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
94 |
|
2220
2c4c0d93daa6
more to the introduction of the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
2217
diff
changeset
|
95 |
|
2238
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents:
2237
diff
changeset
|
96 |
\begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents:
2237
diff
changeset
|
97 |
@{text "t ::= x | t t | \<lambda>x.t"}\hfill\numbered{lambda} |
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents:
2237
diff
changeset
|
98 |
\end{isabelle} |
2217 | 99 |
|
2220
2c4c0d93daa6
more to the introduction of the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
2217
diff
changeset
|
100 |
\noindent |
2256
f5f21feaa168
some slight tuning of the preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2255
diff
changeset
|
101 |
The problem with this definition arises, for instance, when one attempts to |
f5f21feaa168
some slight tuning of the preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2255
diff
changeset
|
102 |
prove formally the substitution lemma \cite{Barendregt81} by induction |
2222 | 103 |
over the structure of terms. This can be fiendishly complicated (see |
2220
2c4c0d93daa6
more to the introduction of the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
2217
diff
changeset
|
104 |
\cite[Pages 94--104]{CurryFeys58} for some ``rough'' sketches of a proof |
2226
36c9d9e658c7
some slight tuning of the intro
Christian Urban <urbanc@in.tum.de>
parents:
2225
diff
changeset
|
105 |
about raw lambda-terms). In contrast, if we reason about |
2220
2c4c0d93daa6
more to the introduction of the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
2217
diff
changeset
|
106 |
$\alpha$-equated lambda-terms, that means terms quotient according to |
2223 | 107 |
$\alpha$-equivalence, then the reasoning infrastructure provided, |
108 |
for example, by Nominal Isabelle \cite{UrbanKaliszyk11} makes the formal |
|
2222 | 109 |
proof of the substitution lemma almost trivial. |
2220
2c4c0d93daa6
more to the introduction of the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
2217
diff
changeset
|
110 |
|
2c4c0d93daa6
more to the introduction of the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
2217
diff
changeset
|
111 |
The difficulty is that in order to be able to reason about integers, finite |
2221
e749cefbf66c
even more on the qpaper (intro almost done)
Christian Urban <urbanc@in.tum.de>
parents:
2220
diff
changeset
|
112 |
sets or $\alpha$-equated lambda-terms one needs to establish a reasoning |
2220
2c4c0d93daa6
more to the introduction of the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
2217
diff
changeset
|
113 |
infrastructure by transferring, or \emph{lifting}, definitions and theorems |
2226
36c9d9e658c7
some slight tuning of the intro
Christian Urban <urbanc@in.tum.de>
parents:
2225
diff
changeset
|
114 |
from the raw type @{typ "nat \<times> nat"} to the quotient type @{typ int} |
2220
2c4c0d93daa6
more to the introduction of the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
2217
diff
changeset
|
115 |
(similarly for finite sets and $\alpha$-equated lambda-terms). This lifting |
2222 | 116 |
usually requires a \emph{lot} of tedious reasoning effort \cite{Paulson06}. |
2252 | 117 |
It is feasible to do this work manually, if one has only a few quotient |
2247
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
118 |
constructions at hand. But if they have to be done over and over again, as in |
2222 | 119 |
Nominal Isabelle, then manual reasoning is not an option. |
2221
e749cefbf66c
even more on the qpaper (intro almost done)
Christian Urban <urbanc@in.tum.de>
parents:
2220
diff
changeset
|
120 |
|
2223 | 121 |
The purpose of a \emph{quotient package} is to ease the lifting of theorems |
2238
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents:
2237
diff
changeset
|
122 |
and automate the reasoning as much as possible. In the |
2223 | 123 |
context of HOL, there have been a few quotient packages already |
2234
8035515bbbc6
something about the quotient ype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2233
diff
changeset
|
124 |
\cite{harrison-thesis,Slotosch97}. The most notable one is by Homeier |
2223 | 125 |
\cite{Homeier05} implemented in HOL4. The fundamental construction these |
126 |
quotient packages perform can be illustrated by the following picture: |
|
2217 | 127 |
|
128 |
\begin{center} |
|
2220
2c4c0d93daa6
more to the introduction of the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
2217
diff
changeset
|
129 |
\mbox{}\hspace{20mm}\begin{tikzpicture} |
2c4c0d93daa6
more to the introduction of the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
2217
diff
changeset
|
130 |
%%\draw[step=2mm] (-4,-1) grid (4,1); |
2c4c0d93daa6
more to the introduction of the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
2217
diff
changeset
|
131 |
|
2c4c0d93daa6
more to the introduction of the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
2217
diff
changeset
|
132 |
\draw[very thick] (0.7,0.3) circle (4.85mm); |
2c4c0d93daa6
more to the introduction of the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
2217
diff
changeset
|
133 |
\draw[rounded corners=1mm, very thick] ( 0.0,-0.9) rectangle ( 1.8, 0.9); |
2c4c0d93daa6
more to the introduction of the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
2217
diff
changeset
|
134 |
\draw[rounded corners=1mm, very thick] (-1.95,0.8) rectangle (-2.9,-0.195); |
2c4c0d93daa6
more to the introduction of the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
2217
diff
changeset
|
135 |
|
2c4c0d93daa6
more to the introduction of the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
2217
diff
changeset
|
136 |
\draw (-2.0, 0.8) -- (0.7,0.8); |
2c4c0d93daa6
more to the introduction of the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
2217
diff
changeset
|
137 |
\draw (-2.0,-0.195) -- (0.7,-0.195); |
2103
e08e3c29dbc0
a bit for the introduction of the q-paper
Christian Urban <urbanc@in.tum.de>
parents:
2102
diff
changeset
|
138 |
|
2220
2c4c0d93daa6
more to the introduction of the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
2217
diff
changeset
|
139 |
\draw ( 0.7, 0.23) node {\begin{tabular}{@ {}c@ {}}equiv-\\[-1mm]clas.\end{tabular}}; |
2c4c0d93daa6
more to the introduction of the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
2217
diff
changeset
|
140 |
\draw (-2.45, 0.35) node {\begin{tabular}{@ {}c@ {}}new\\[-1mm]type\end{tabular}}; |
2c4c0d93daa6
more to the introduction of the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
2217
diff
changeset
|
141 |
\draw (1.8, 0.35) node[right=-0.1mm] |
2224
f5b6f9d8a882
completed the intro (except minor things)
Christian Urban <urbanc@in.tum.de>
parents:
2223
diff
changeset
|
142 |
{\begin{tabular}{@ {}l@ {}}existing\\[-1mm] type\\ (sets of raw elements)\end{tabular}}; |
2220
2c4c0d93daa6
more to the introduction of the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
2217
diff
changeset
|
143 |
\draw (0.9, -0.55) node {\begin{tabular}{@ {}l@ {}}non-empty\\[-1mm]subset\end{tabular}}; |
2c4c0d93daa6
more to the introduction of the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
2217
diff
changeset
|
144 |
|
2c4c0d93daa6
more to the introduction of the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
2217
diff
changeset
|
145 |
\draw[->, very thick] (-1.8, 0.36) -- (-0.1,0.36); |
2c4c0d93daa6
more to the introduction of the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
2217
diff
changeset
|
146 |
\draw[<-, very thick] (-1.8, 0.16) -- (-0.1,0.16); |
2221
e749cefbf66c
even more on the qpaper (intro almost done)
Christian Urban <urbanc@in.tum.de>
parents:
2220
diff
changeset
|
147 |
\draw (-0.95, 0.26) node[above=0.4mm] {@{text Rep}}; |
e749cefbf66c
even more on the qpaper (intro almost done)
Christian Urban <urbanc@in.tum.de>
parents:
2220
diff
changeset
|
148 |
\draw (-0.95, 0.26) node[below=0.4mm] {@{text Abs}}; |
2220
2c4c0d93daa6
more to the introduction of the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
2217
diff
changeset
|
149 |
|
2c4c0d93daa6
more to the introduction of the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
2217
diff
changeset
|
150 |
\end{tikzpicture} |
2c4c0d93daa6
more to the introduction of the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
2217
diff
changeset
|
151 |
\end{center} |
2217 | 152 |
|
2221
e749cefbf66c
even more on the qpaper (intro almost done)
Christian Urban <urbanc@in.tum.de>
parents:
2220
diff
changeset
|
153 |
\noindent |
2247
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
154 |
The starting point is an existing type, to which we refer as the |
2269
e4699a240d2c
tuned everytinh up to section 4
Christian Urban <urbanc@in.tum.de>
parents:
2265
diff
changeset
|
155 |
\emph{raw type} and over which an equivalence relation given by the user is |
2238
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents:
2237
diff
changeset
|
156 |
defined. With this input the package introduces a new type, to which we |
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents:
2237
diff
changeset
|
157 |
refer as the \emph{quotient type}. This type comes with an |
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents:
2237
diff
changeset
|
158 |
\emph{abstraction} and a \emph{representation} function, written @{text Abs} |
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents:
2237
diff
changeset
|
159 |
and @{text Rep}.\footnote{Actually slightly more basic functions are given; |
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents:
2237
diff
changeset
|
160 |
the functions @{text Abs} and @{text Rep} need to be derived from them. We |
2269
e4699a240d2c
tuned everytinh up to section 4
Christian Urban <urbanc@in.tum.de>
parents:
2265
diff
changeset
|
161 |
will show the details later. } They relate elements in the |
e4699a240d2c
tuned everytinh up to section 4
Christian Urban <urbanc@in.tum.de>
parents:
2265
diff
changeset
|
162 |
existing type to elements in the new type and vice versa, and can be uniquely |
2256
f5f21feaa168
some slight tuning of the preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2255
diff
changeset
|
163 |
identified by their quotient type. For example for the integer quotient construction |
2238
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents:
2237
diff
changeset
|
164 |
the types of @{text Abs} and @{text Rep} are |
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents:
2237
diff
changeset
|
165 |
|
2224
f5b6f9d8a882
completed the intro (except minor things)
Christian Urban <urbanc@in.tum.de>
parents:
2223
diff
changeset
|
166 |
|
f5b6f9d8a882
completed the intro (except minor things)
Christian Urban <urbanc@in.tum.de>
parents:
2223
diff
changeset
|
167 |
\begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
2234
8035515bbbc6
something about the quotient ype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2233
diff
changeset
|
168 |
@{text "Abs :: nat \<times> nat \<Rightarrow> int"}\hspace{10mm}@{text "Rep :: int \<Rightarrow> nat \<times> nat"} |
2224
f5b6f9d8a882
completed the intro (except minor things)
Christian Urban <urbanc@in.tum.de>
parents:
2223
diff
changeset
|
169 |
\end{isabelle} |
f5b6f9d8a882
completed the intro (except minor things)
Christian Urban <urbanc@in.tum.de>
parents:
2223
diff
changeset
|
170 |
|
f5b6f9d8a882
completed the intro (except minor things)
Christian Urban <urbanc@in.tum.de>
parents:
2223
diff
changeset
|
171 |
\noindent |
2238
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents:
2237
diff
changeset
|
172 |
We therefore often write @{text Abs_int} and @{text Rep_int} if the |
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents:
2237
diff
changeset
|
173 |
typing information is important. |
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents:
2237
diff
changeset
|
174 |
|
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents:
2237
diff
changeset
|
175 |
Every abstraction and representation function stands for an isomorphism |
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents:
2237
diff
changeset
|
176 |
between the non-empty subset and elements in the new type. They are |
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents:
2237
diff
changeset
|
177 |
necessary for making definitions involving the new type. For example @{text |
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents:
2237
diff
changeset
|
178 |
"0"} and @{text "1"} of type @{typ int} can be defined as |
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents:
2237
diff
changeset
|
179 |
|
2221
e749cefbf66c
even more on the qpaper (intro almost done)
Christian Urban <urbanc@in.tum.de>
parents:
2220
diff
changeset
|
180 |
|
e749cefbf66c
even more on the qpaper (intro almost done)
Christian Urban <urbanc@in.tum.de>
parents:
2220
diff
changeset
|
181 |
\begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
2238
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents:
2237
diff
changeset
|
182 |
@{text "0 \<equiv> Abs_int (0, 0)"}\hspace{10mm}@{text "1 \<equiv> Abs_int (1, 0)"} |
2221
e749cefbf66c
even more on the qpaper (intro almost done)
Christian Urban <urbanc@in.tum.de>
parents:
2220
diff
changeset
|
183 |
\end{isabelle} |
e749cefbf66c
even more on the qpaper (intro almost done)
Christian Urban <urbanc@in.tum.de>
parents:
2220
diff
changeset
|
184 |
|
e749cefbf66c
even more on the qpaper (intro almost done)
Christian Urban <urbanc@in.tum.de>
parents:
2220
diff
changeset
|
185 |
\noindent |
2224
f5b6f9d8a882
completed the intro (except minor things)
Christian Urban <urbanc@in.tum.de>
parents:
2223
diff
changeset
|
186 |
Slightly more complicated is the definition of @{text "add"} having type |
2222 | 187 |
@{typ "int \<Rightarrow> int \<Rightarrow> int"}. Its definition is as follows |
2221
e749cefbf66c
even more on the qpaper (intro almost done)
Christian Urban <urbanc@in.tum.de>
parents:
2220
diff
changeset
|
188 |
|
2258
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
189 |
\begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
190 |
@{text "add n m \<equiv> Abs_int (add_pair (Rep_int n) (Rep_int m))"} |
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
191 |
\hfill\numbered{adddef} |
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
192 |
\end{isabelle} |
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
193 |
|
2221
e749cefbf66c
even more on the qpaper (intro almost done)
Christian Urban <urbanc@in.tum.de>
parents:
2220
diff
changeset
|
194 |
\noindent |
2224
f5b6f9d8a882
completed the intro (except minor things)
Christian Urban <urbanc@in.tum.de>
parents:
2223
diff
changeset
|
195 |
where we take the representation of the arguments @{text n} and @{text m}, |
2226
36c9d9e658c7
some slight tuning of the intro
Christian Urban <urbanc@in.tum.de>
parents:
2225
diff
changeset
|
196 |
add them according to the function @{text "add_pair"} and then take the |
2221
e749cefbf66c
even more on the qpaper (intro almost done)
Christian Urban <urbanc@in.tum.de>
parents:
2220
diff
changeset
|
197 |
abstraction of the result. This is all straightforward and the existing |
e749cefbf66c
even more on the qpaper (intro almost done)
Christian Urban <urbanc@in.tum.de>
parents:
2220
diff
changeset
|
198 |
quotient packages can deal with such definitions. But what is surprising |
2223 | 199 |
that none of them can deal with slightly more complicated definitions involving |
2221
e749cefbf66c
even more on the qpaper (intro almost done)
Christian Urban <urbanc@in.tum.de>
parents:
2220
diff
changeset
|
200 |
\emph{compositions} of quotients. Such compositions are needed for example |
2247
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
201 |
in case of quotienting lists to yield finite sets and the operator that |
2226
36c9d9e658c7
some slight tuning of the intro
Christian Urban <urbanc@in.tum.de>
parents:
2225
diff
changeset
|
202 |
flattens lists of lists, defined as follows |
2102
200954544cae
added some of the quotient literature; a bit more to the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
1994
diff
changeset
|
203 |
|
2220
2c4c0d93daa6
more to the introduction of the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
2217
diff
changeset
|
204 |
@{thm [display, indent=10] concat.simps(1) concat.simps(2)[no_vars]} |
2183 | 205 |
|
2103
e08e3c29dbc0
a bit for the introduction of the q-paper
Christian Urban <urbanc@in.tum.de>
parents:
2102
diff
changeset
|
206 |
\noindent |
2221
e749cefbf66c
even more on the qpaper (intro almost done)
Christian Urban <urbanc@in.tum.de>
parents:
2220
diff
changeset
|
207 |
We expect that the corresponding operator on finite sets, written @{term "fconcat"}, |
2248 | 208 |
builds finite unions of finite sets: |
2188 | 209 |
|
2220
2c4c0d93daa6
more to the introduction of the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
2217
diff
changeset
|
210 |
@{thm [display, indent=10] fconcat_empty[no_vars] fconcat_insert[no_vars]} |
2102
200954544cae
added some of the quotient literature; a bit more to the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
1994
diff
changeset
|
211 |
|
2103
e08e3c29dbc0
a bit for the introduction of the q-paper
Christian Urban <urbanc@in.tum.de>
parents:
2102
diff
changeset
|
212 |
\noindent |
2256
f5f21feaa168
some slight tuning of the preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2255
diff
changeset
|
213 |
The quotient package should automatically provide us with a definition for @{text "\<Union>"} in |
2238
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents:
2237
diff
changeset
|
214 |
terms of @{text flat}, @{text Rep_fset} and @{text Abs_fset}. The problem is |
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents:
2237
diff
changeset
|
215 |
that the method used in the existing quotient |
2247
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
216 |
packages of just taking the representation of the arguments and then taking |
2258
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
217 |
the abstraction of the result is \emph{not} enough. The reason is that in case |
2224
f5b6f9d8a882
completed the intro (except minor things)
Christian Urban <urbanc@in.tum.de>
parents:
2223
diff
changeset
|
218 |
of @{text "\<Union>"} we obtain the incorrect definition |
f5b6f9d8a882
completed the intro (except minor things)
Christian Urban <urbanc@in.tum.de>
parents:
2223
diff
changeset
|
219 |
|
2234
8035515bbbc6
something about the quotient ype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2233
diff
changeset
|
220 |
@{text [display, indent=10] "\<Union> S \<equiv> Abs_fset (flat (Rep_fset S))"} |
2221
e749cefbf66c
even more on the qpaper (intro almost done)
Christian Urban <urbanc@in.tum.de>
parents:
2220
diff
changeset
|
221 |
|
2224
f5b6f9d8a882
completed the intro (except minor things)
Christian Urban <urbanc@in.tum.de>
parents:
2223
diff
changeset
|
222 |
\noindent |
f5b6f9d8a882
completed the intro (except minor things)
Christian Urban <urbanc@in.tum.de>
parents:
2223
diff
changeset
|
223 |
where the right-hand side is not even typable! This problem can be remedied in the |
f5b6f9d8a882
completed the intro (except minor things)
Christian Urban <urbanc@in.tum.de>
parents:
2223
diff
changeset
|
224 |
existing quotient packages by introducing an intermediate step and reasoning |
2226
36c9d9e658c7
some slight tuning of the intro
Christian Urban <urbanc@in.tum.de>
parents:
2225
diff
changeset
|
225 |
about flattening of lists of finite sets. However, this remedy is rather |
2224
f5b6f9d8a882
completed the intro (except minor things)
Christian Urban <urbanc@in.tum.de>
parents:
2223
diff
changeset
|
226 |
cumbersome and inelegant in light of our work, which can deal with such |
f5b6f9d8a882
completed the intro (except minor things)
Christian Urban <urbanc@in.tum.de>
parents:
2223
diff
changeset
|
227 |
definitions directly. The solution is that we need to build aggregate |
f5b6f9d8a882
completed the intro (except minor things)
Christian Urban <urbanc@in.tum.de>
parents:
2223
diff
changeset
|
228 |
representation and abstraction functions, which in case of @{text "\<Union>"} |
f5b6f9d8a882
completed the intro (except minor things)
Christian Urban <urbanc@in.tum.de>
parents:
2223
diff
changeset
|
229 |
generate the following definition |
f5b6f9d8a882
completed the intro (except minor things)
Christian Urban <urbanc@in.tum.de>
parents:
2223
diff
changeset
|
230 |
|
2234
8035515bbbc6
something about the quotient ype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2233
diff
changeset
|
231 |
@{text [display, indent=10] "\<Union> S \<equiv> Abs_fset (flat ((map Rep_fset \<circ> Rep_fset) S))"} |
2221
e749cefbf66c
even more on the qpaper (intro almost done)
Christian Urban <urbanc@in.tum.de>
parents:
2220
diff
changeset
|
232 |
|
e749cefbf66c
even more on the qpaper (intro almost done)
Christian Urban <urbanc@in.tum.de>
parents:
2220
diff
changeset
|
233 |
\noindent |
2223 | 234 |
where @{term map} is the usual mapping function for lists. In this paper we |
2224
f5b6f9d8a882
completed the intro (except minor things)
Christian Urban <urbanc@in.tum.de>
parents:
2223
diff
changeset
|
235 |
will present a formal definition of our aggregate abstraction and |
2223 | 236 |
representation functions (this definition was omitted in \cite{Homeier05}). |
2224
f5b6f9d8a882
completed the intro (except minor things)
Christian Urban <urbanc@in.tum.de>
parents:
2223
diff
changeset
|
237 |
They generate definitions, like the one above for @{text "\<Union>"}, |
2226
36c9d9e658c7
some slight tuning of the intro
Christian Urban <urbanc@in.tum.de>
parents:
2225
diff
changeset
|
238 |
according to the type of the raw constant and the type |
2224
f5b6f9d8a882
completed the intro (except minor things)
Christian Urban <urbanc@in.tum.de>
parents:
2223
diff
changeset
|
239 |
of the quotient constant. This means we also have to extend the notions |
2237 | 240 |
of \emph{aggregate equivalence relation}, \emph{respectfulness} and \emph{preservation} |
2231 | 241 |
from Homeier \cite{Homeier05}. |
2223 | 242 |
|
2252 | 243 |
In addition we are able to address the criticism by Paulson \cite{Paulson06} cited |
2237 | 244 |
at the beginning of this section about having to collect theorems that are |
2247
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
245 |
lifted from the raw level to the quotient level into one giant list. Our |
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
246 |
quotient package is the first one that is modular so that it allows to lift |
2252 | 247 |
single theorems separately. This has the advantage for the user of being able to develop a |
248 |
formal theory interactively as a natural progression. A pleasing side-result of |
|
2256
f5f21feaa168
some slight tuning of the preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2255
diff
changeset
|
249 |
the modularity is that we are able to clearly specify what is involved |
f5f21feaa168
some slight tuning of the preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2255
diff
changeset
|
250 |
in the lifting process (this was only hinted at in \cite{Homeier05} and |
2247
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
251 |
implemented as a ``rough recipe'' in ML-code). |
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
252 |
|
2237 | 253 |
|
254 |
The paper is organised as follows: Section \ref{sec:prelims} presents briefly |
|
2247
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
255 |
some necessary preliminaries; Section \ref{sec:type} describes the definitions |
2252 | 256 |
of quotient types and shows how definitions of constants can be made over |
257 |
quotient types. Section \ref{sec:resp} introduces the notions of respectfullness |
|
2256
f5f21feaa168
some slight tuning of the preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2255
diff
changeset
|
258 |
and preservation; Section \ref{sec:lift} describes the lifting of theorems, |
f5f21feaa168
some slight tuning of the preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2255
diff
changeset
|
259 |
and Section \ref{sec:conc} concludes and compares our results to existing |
f5f21feaa168
some slight tuning of the preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2255
diff
changeset
|
260 |
work. |
2102
200954544cae
added some of the quotient literature; a bit more to the qpaper
Christian Urban <urbanc@in.tum.de>
parents:
1994
diff
changeset
|
261 |
*} |
1975
b1281a0051ae
added stub for quotient paper; call with isabelle make qpaper
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
262 |
|
2257 | 263 |
section {* Preliminaries and General Quotients\label{sec:prelims} *} |
1978 | 264 |
|
265 |
text {* |
|
2269
e4699a240d2c
tuned everytinh up to section 4
Christian Urban <urbanc@in.tum.de>
parents:
2265
diff
changeset
|
266 |
We describe in this section briefly the most basic notions of HOL we rely on, and |
2258
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
267 |
the important definitions given by Homeier for quotients \cite{Homeier05}. |
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
268 |
|
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
269 |
At its core HOL is based on a simply-typed term language, where types are |
2269
e4699a240d2c
tuned everytinh up to section 4
Christian Urban <urbanc@in.tum.de>
parents:
2265
diff
changeset
|
270 |
recorded in Church-style fashion (that means, we can always infer the type of |
2258
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
271 |
a term and its subterms without any additional information). The grammars |
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
272 |
for types and terms are as follows |
2256
f5f21feaa168
some slight tuning of the preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2255
diff
changeset
|
273 |
|
f5f21feaa168
some slight tuning of the preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2255
diff
changeset
|
274 |
\begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
f5f21feaa168
some slight tuning of the preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2255
diff
changeset
|
275 |
\begin{tabular}{@ {}rl@ {\hspace{3mm}}l@ {}} |
f5f21feaa168
some slight tuning of the preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2255
diff
changeset
|
276 |
@{text "\<sigma>, \<tau> ::="} & @{text "\<alpha> | (\<sigma>,\<dots>, \<sigma>) \<kappa>"} & (type variables and type constructors)\\ |
f5f21feaa168
some slight tuning of the preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2255
diff
changeset
|
277 |
@{text "t, s ::="} & @{text "x\<^isup>\<sigma> | c\<^isup>\<sigma> | t t | \<lambda>x\<^isup>\<sigma>. t"} & |
f5f21feaa168
some slight tuning of the preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2255
diff
changeset
|
278 |
(variables, constants, applications and abstractions)\\ |
f5f21feaa168
some slight tuning of the preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2255
diff
changeset
|
279 |
\end{tabular} |
f5f21feaa168
some slight tuning of the preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2255
diff
changeset
|
280 |
\end{isabelle} |
f5f21feaa168
some slight tuning of the preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2255
diff
changeset
|
281 |
|
f5f21feaa168
some slight tuning of the preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2255
diff
changeset
|
282 |
\noindent |
f5f21feaa168
some slight tuning of the preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2255
diff
changeset
|
283 |
We often write just @{text \<kappa>} for @{text "() \<kappa>"}, and use @{text "\<alpha>s"} and |
2258
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
284 |
@{text "\<sigma>s"} to stand for collections of type variables and types, |
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
285 |
respectively. The type of a term is often made explicit by writing @{text |
2269
e4699a240d2c
tuned everytinh up to section 4
Christian Urban <urbanc@in.tum.de>
parents:
2265
diff
changeset
|
286 |
"t :: \<sigma>"}. HOL includes a type @{typ bool} for booleans and the function |
2258
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
287 |
type, written @{text "\<sigma> \<Rightarrow> \<tau>"}. HOL also contains |
2269
e4699a240d2c
tuned everytinh up to section 4
Christian Urban <urbanc@in.tum.de>
parents:
2265
diff
changeset
|
288 |
many primitive and defined constants; this includes equality, with type @{text "= :: \<sigma> \<Rightarrow> |
e4699a240d2c
tuned everytinh up to section 4
Christian Urban <urbanc@in.tum.de>
parents:
2265
diff
changeset
|
289 |
\<sigma> \<Rightarrow> bool"}, and the identity function, with type @{text "id :: \<sigma> => \<sigma>"} (the former |
2258
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
290 |
being primitive and the latter being defined as @{text |
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
291 |
"\<lambda>x\<^sup>\<sigma>. x\<^sup>\<sigma>"}). |
2256
f5f21feaa168
some slight tuning of the preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2255
diff
changeset
|
292 |
|
2258
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
293 |
An important point to note is that theorems in HOL can be seen as a subset |
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
294 |
of terms that are constructed specially (namely through axioms and prove |
2269
e4699a240d2c
tuned everytinh up to section 4
Christian Urban <urbanc@in.tum.de>
parents:
2265
diff
changeset
|
295 |
rules). As a result we are able to define automatic proof |
2258
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
296 |
procedures showing that one theorem implies another by decomposing the term |
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
297 |
underlying the first theorem. |
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
298 |
|
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
299 |
Like Homeier, our work relies on map-functions defined for every type constructor, |
2269
e4699a240d2c
tuned everytinh up to section 4
Christian Urban <urbanc@in.tum.de>
parents:
2265
diff
changeset
|
300 |
like @{text map} for lists. Homeier describes in \cite{Homeier05} map-functions |
e4699a240d2c
tuned everytinh up to section 4
Christian Urban <urbanc@in.tum.de>
parents:
2265
diff
changeset
|
301 |
for products, sums, |
2258
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
302 |
options and also the following map for function types |
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
303 |
|
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
304 |
@{thm [display, indent=10] fun_map_def[no_vars, THEN eq_reflection]} |
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
305 |
|
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
306 |
\noindent |
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
307 |
Using this map-function, we can give the following, equivalent, but more |
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
308 |
uniform, definition for @{text add} shown in \eqref{adddef}: |
2256
f5f21feaa168
some slight tuning of the preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2255
diff
changeset
|
309 |
|
2258
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
310 |
@{text [display, indent=10] "add \<equiv> (Rep_int \<singlearr> Rep_int \<singlearr> Abs_int) add_pair"} |
2182 | 311 |
|
2258
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
312 |
\noindent |
2269
e4699a240d2c
tuned everytinh up to section 4
Christian Urban <urbanc@in.tum.de>
parents:
2265
diff
changeset
|
313 |
Using extensionality and unfolding the definition, we can get back to \eqref{adddef}. |
e4699a240d2c
tuned everytinh up to section 4
Christian Urban <urbanc@in.tum.de>
parents:
2265
diff
changeset
|
314 |
In what follows we shall use the terminology @{text "map_\<kappa>"} for a map-function |
e4699a240d2c
tuned everytinh up to section 4
Christian Urban <urbanc@in.tum.de>
parents:
2265
diff
changeset
|
315 |
defined for the type-constructor @{text \<kappa>}. In our implementation we have |
e4699a240d2c
tuned everytinh up to section 4
Christian Urban <urbanc@in.tum.de>
parents:
2265
diff
changeset
|
316 |
a database of map-functions that can be dynamically extended. |
2258
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
317 |
|
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
318 |
It will also be necessary to have operators, referred to as @{text "rel_\<kappa>"}, |
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
319 |
which define equivalence relations in terms of constituent equivalence |
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
320 |
relations. For example given two equivalence relations @{text "R\<^isub>1"} |
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
321 |
and @{text "R\<^isub>2"}, we can define an equivalence relations over |
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
322 |
products as follows |
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
323 |
% |
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
324 |
@{text [display, indent=10] "(R\<^isub>1 \<tripple> R\<^isub>2) (x\<^isub>1, x\<^isub>2) (y\<^isub>1, y\<^isub>2) \<equiv> R\<^isub>1 x\<^isub>1 y\<^isub>1 \<and> R\<^isub>2 x\<^isub>2 y\<^isub>2"} |
1978 | 325 |
|
2258
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
326 |
\noindent |
2269
e4699a240d2c
tuned everytinh up to section 4
Christian Urban <urbanc@in.tum.de>
parents:
2265
diff
changeset
|
327 |
Homeier gives also the following operator for defining equivalence |
e4699a240d2c
tuned everytinh up to section 4
Christian Urban <urbanc@in.tum.de>
parents:
2265
diff
changeset
|
328 |
relations over function types |
2258
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
329 |
% |
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
330 |
@{thm [display, indent=10] fun_rel_def[of "R\<^isub>1" "R\<^isub>2", no_vars, THEN eq_reflection]} |
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
331 |
|
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
332 |
The central definition in Homeier's work \cite{Homeier05} relates equivalence |
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
333 |
relations, abstraction and representation functions: |
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
334 |
|
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
335 |
\begin{definition}[Quotient Types] |
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
336 |
Given a relation $R$, an abstraction function $Abs$ |
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
337 |
and a representation function $Rep$, the predicate @{term "Quotient R Abs Rep"} |
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
338 |
means |
2182 | 339 |
\begin{enumerate} |
340 |
\item @{thm (rhs1) Quotient_def[of "R", no_vars]} |
|
341 |
\item @{thm (rhs2) Quotient_def[of "R", no_vars]} |
|
342 |
\item @{thm (rhs3) Quotient_def[of "R", no_vars]} |
|
343 |
\end{enumerate} |
|
344 |
\end{definition} |
|
345 |
||
2258
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
346 |
\noindent |
2269
e4699a240d2c
tuned everytinh up to section 4
Christian Urban <urbanc@in.tum.de>
parents:
2265
diff
changeset
|
347 |
The value of this definition is that validity of @{text "Quotient R Abs Rep"} can |
e4699a240d2c
tuned everytinh up to section 4
Christian Urban <urbanc@in.tum.de>
parents:
2265
diff
changeset
|
348 |
often be proved in terms of the validity of @{text "Quotient"} over the constituent |
e4699a240d2c
tuned everytinh up to section 4
Christian Urban <urbanc@in.tum.de>
parents:
2265
diff
changeset
|
349 |
types of @{text "R"}, @{text Abs} and @{text Rep}. |
2258
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
350 |
For example Homeier proves the following property for higher-order quotient |
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
351 |
types: |
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
352 |
|
2269
e4699a240d2c
tuned everytinh up to section 4
Christian Urban <urbanc@in.tum.de>
parents:
2265
diff
changeset
|
353 |
\begin{proposition}\label{funquot} |
2258
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
354 |
@{thm[mode=IfThen] fun_quotient[where ?R1.0="R\<^isub>1" and ?R2.0="R\<^isub>2" |
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
355 |
and ?abs1.0="Abs\<^isub>1" and ?abs2.0="Abs\<^isub>2" and ?rep1.0="Rep\<^isub>1" and ?rep2.0="Rep\<^isub>2"]} |
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
356 |
\end{proposition} |
2195
0c1dcdefb515
Functionalized the ABS/REP definition.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2194
diff
changeset
|
357 |
|
2271
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
358 |
\begin{definition}[Respects]\label{def:respects} |
2268
1fd6809f5a44
Definition of Respects.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2267
diff
changeset
|
359 |
An element @{text "x"} respects a relation @{text "R"} if and only if @{text "R x x"}. |
1fd6809f5a44
Definition of Respects.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2267
diff
changeset
|
360 |
\end{definition} |
1fd6809f5a44
Definition of Respects.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2267
diff
changeset
|
361 |
|
2258
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
362 |
\noindent |
2269
e4699a240d2c
tuned everytinh up to section 4
Christian Urban <urbanc@in.tum.de>
parents:
2265
diff
changeset
|
363 |
As a result, Homeier was able to build an automatic prover that can nearly |
e4699a240d2c
tuned everytinh up to section 4
Christian Urban <urbanc@in.tum.de>
parents:
2265
diff
changeset
|
364 |
always discharge a proof obligation involving @{text "Quotient"}. Our quotient |
e4699a240d2c
tuned everytinh up to section 4
Christian Urban <urbanc@in.tum.de>
parents:
2265
diff
changeset
|
365 |
package makes heavy |
e4699a240d2c
tuned everytinh up to section 4
Christian Urban <urbanc@in.tum.de>
parents:
2265
diff
changeset
|
366 |
use of this part of Homeier's work including an extension |
2258
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
367 |
to deal with compositions of equivalence relations defined as follows |
2234
8035515bbbc6
something about the quotient ype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2233
diff
changeset
|
368 |
|
2258
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
369 |
\begin{definition}[Composition of Relations] |
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
370 |
@{abbrev "rel_conj R\<^isub>1 R\<^isub>2"} where @{text "\<circ>\<circ>"} is the predicate |
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
371 |
composition defined by the rule |
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
372 |
% |
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
373 |
@{thm [mode=Rule, display, indent=10] pred_compI[of "R\<^isub>1" "x" "y" "R\<^isub>2" "z"]} |
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
374 |
\end{definition} |
2237 | 375 |
|
2258
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
376 |
\noindent |
2266
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2265
diff
changeset
|
377 |
Unfortunately a quotient type theorem, like Proposition \ref{funquot}, for |
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2265
diff
changeset
|
378 |
the composition of any two quotients in not true (it is not even typable in |
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2265
diff
changeset
|
379 |
the HOL type system). However, we can prove useful instances for compatible |
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2265
diff
changeset
|
380 |
containers. We will show such example in Section \ref{sec:resp}. |
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2265
diff
changeset
|
381 |
|
2268
1fd6809f5a44
Definition of Respects.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2267
diff
changeset
|
382 |
|
2195
0c1dcdefb515
Functionalized the ABS/REP definition.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2194
diff
changeset
|
383 |
*} |
0c1dcdefb515
Functionalized the ABS/REP definition.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2194
diff
changeset
|
384 |
|
2237 | 385 |
section {* Quotient Types and Quotient Definitions\label{sec:type} *} |
1978 | 386 |
|
2234
8035515bbbc6
something about the quotient ype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2233
diff
changeset
|
387 |
text {* |
2247
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
388 |
The first step in a quotient construction is to take a name for the new |
2238
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents:
2237
diff
changeset
|
389 |
type, say @{text "\<kappa>\<^isub>q"}, and an equivalence relation, say @{text R}, |
2247
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
390 |
defined over a raw type, say @{text "\<sigma>"}. The type of the equivalence |
2269
e4699a240d2c
tuned everytinh up to section 4
Christian Urban <urbanc@in.tum.de>
parents:
2265
diff
changeset
|
391 |
relation must be @{text "\<sigma> \<Rightarrow> \<sigma> \<Rightarrow> bool"}. The user-visible part of |
e4699a240d2c
tuned everytinh up to section 4
Christian Urban <urbanc@in.tum.de>
parents:
2265
diff
changeset
|
392 |
the quotient type declaration is therefore |
2234
8035515bbbc6
something about the quotient ype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2233
diff
changeset
|
393 |
|
2235
ad725de6e39b
more on the constant lifting section
Christian Urban <urbanc@in.tum.de>
parents:
2234
diff
changeset
|
394 |
\begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
2269
e4699a240d2c
tuned everytinh up to section 4
Christian Urban <urbanc@in.tum.de>
parents:
2265
diff
changeset
|
395 |
\isacommand{quotient\_type}~~@{text "\<alpha>s \<kappa>\<^isub>q = \<sigma> / R"}\hfill\numbered{typedecl} |
2235
ad725de6e39b
more on the constant lifting section
Christian Urban <urbanc@in.tum.de>
parents:
2234
diff
changeset
|
396 |
\end{isabelle} |
ad725de6e39b
more on the constant lifting section
Christian Urban <urbanc@in.tum.de>
parents:
2234
diff
changeset
|
397 |
|
ad725de6e39b
more on the constant lifting section
Christian Urban <urbanc@in.tum.de>
parents:
2234
diff
changeset
|
398 |
\noindent |
2237 | 399 |
and a proof that @{text "R"} is indeed an equivalence relation. Two concrete |
400 |
examples are |
|
401 |
||
402 |
||
403 |
\begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
|
404 |
\begin{tabular}{@ {}l} |
|
405 |
\isacommand{quotient\_type}~~@{text "int = nat \<times> nat / \<approx>\<^bsub>nat \<times> nat\<^esub>"}\\ |
|
406 |
\isacommand{quotient\_type}~~@{text "\<alpha> fset = \<alpha> list / \<approx>\<^bsub>list\<^esub>"} |
|
407 |
\end{tabular} |
|
408 |
\end{isabelle} |
|
409 |
||
410 |
\noindent |
|
411 |
which introduce the type of integers and of finite sets using the |
|
412 |
equivalence relations @{text "\<approx>\<^bsub>nat \<times> nat\<^esub>"} and @{text |
|
2269
e4699a240d2c
tuned everytinh up to section 4
Christian Urban <urbanc@in.tum.de>
parents:
2265
diff
changeset
|
413 |
"\<approx>\<^bsub>list\<^esub>"} defined in \eqref{natpairequiv} and |
2247
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
414 |
\eqref{listequiv}, respectively (the proofs about being equivalence |
2269
e4699a240d2c
tuned everytinh up to section 4
Christian Urban <urbanc@in.tum.de>
parents:
2265
diff
changeset
|
415 |
relations is omitted). Given this data, we declare for \eqref{typedecl} internally |
2237 | 416 |
the quotient types as |
2234
8035515bbbc6
something about the quotient ype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2233
diff
changeset
|
417 |
|
8035515bbbc6
something about the quotient ype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2233
diff
changeset
|
418 |
\begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
8035515bbbc6
something about the quotient ype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2233
diff
changeset
|
419 |
\isacommand{typedef}~~@{text "\<alpha>s \<kappa>\<^isub>q = {c. \<exists>x. c = R x}"} |
8035515bbbc6
something about the quotient ype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2233
diff
changeset
|
420 |
\end{isabelle} |
8035515bbbc6
something about the quotient ype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2233
diff
changeset
|
421 |
|
8035515bbbc6
something about the quotient ype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2233
diff
changeset
|
422 |
\noindent |
2247
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
423 |
where the right-hand side is the (non-empty) set of equivalence classes of |
2237 | 424 |
@{text "R"}. The restriction in this declaration is that the type variables |
425 |
in the raw type @{text "\<sigma>"} must be included in the type variables @{text |
|
2247
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
426 |
"\<alpha>s"} declared for @{text "\<kappa>\<^isub>q"}. HOL will provide us with the following |
2269
e4699a240d2c
tuned everytinh up to section 4
Christian Urban <urbanc@in.tum.de>
parents:
2265
diff
changeset
|
427 |
abstraction and representation functions |
2182 | 428 |
|
2234
8035515bbbc6
something about the quotient ype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2233
diff
changeset
|
429 |
\begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
8035515bbbc6
something about the quotient ype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2233
diff
changeset
|
430 |
@{text "abs_\<kappa>\<^isub>q :: \<sigma> set \<Rightarrow> \<alpha>s \<kappa>\<^isub>q"}\hspace{10mm}@{text "rep_\<kappa>\<^isub>q :: \<alpha>s \<kappa>\<^isub>q \<Rightarrow> \<sigma> set"} |
8035515bbbc6
something about the quotient ype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2233
diff
changeset
|
431 |
\end{isabelle} |
8035515bbbc6
something about the quotient ype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2233
diff
changeset
|
432 |
|
2235
ad725de6e39b
more on the constant lifting section
Christian Urban <urbanc@in.tum.de>
parents:
2234
diff
changeset
|
433 |
\noindent |
2269
e4699a240d2c
tuned everytinh up to section 4
Christian Urban <urbanc@in.tum.de>
parents:
2265
diff
changeset
|
434 |
As can be seen from the type, they relate the new quotient type and equivalence classes of the raw |
2235
ad725de6e39b
more on the constant lifting section
Christian Urban <urbanc@in.tum.de>
parents:
2234
diff
changeset
|
435 |
type. However, as Homeier \cite{Homeier05} noted, it is much more convenient |
ad725de6e39b
more on the constant lifting section
Christian Urban <urbanc@in.tum.de>
parents:
2234
diff
changeset
|
436 |
to work with the following derived abstraction and representation functions |
ad725de6e39b
more on the constant lifting section
Christian Urban <urbanc@in.tum.de>
parents:
2234
diff
changeset
|
437 |
|
2234
8035515bbbc6
something about the quotient ype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2233
diff
changeset
|
438 |
\begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
8035515bbbc6
something about the quotient ype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2233
diff
changeset
|
439 |
@{text "Abs_\<kappa>\<^isub>q x \<equiv> abs_\<kappa>\<^isub>q (R x)"}\hspace{10mm}@{text "Rep_\<kappa>\<^isub>q x \<equiv> \<epsilon> (rep_\<kappa>\<^isub>q x)"} |
8035515bbbc6
something about the quotient ype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2233
diff
changeset
|
440 |
\end{isabelle} |
8035515bbbc6
something about the quotient ype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2233
diff
changeset
|
441 |
|
8035515bbbc6
something about the quotient ype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2233
diff
changeset
|
442 |
\noindent |
2235
ad725de6e39b
more on the constant lifting section
Christian Urban <urbanc@in.tum.de>
parents:
2234
diff
changeset
|
443 |
on the expense of having to use Hilbert's choice operator @{text "\<epsilon>"} in the |
2237 | 444 |
definition of @{text "Rep_\<kappa>\<^isub>q"}. These derived notions relate the |
445 |
quotient type and the raw type directly, as can be seen from their type, |
|
446 |
namely @{text "\<sigma> \<Rightarrow> \<alpha>s \<kappa>\<^isub>q"} and @{text "\<alpha>s \<kappa>\<^isub>q \<Rightarrow> \<sigma>"}, |
|
447 |
respectively. Given that @{text "R"} is an equivalence relation, the |
|
448 |
following property |
|
449 |
||
2258
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
450 |
\begin{proposition} |
2252 | 451 |
@{text "Quotient R Abs_\<kappa>\<^isub>q Rep_\<kappa>\<^isub>q"} |
2258
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
452 |
\end{proposition} |
2234
8035515bbbc6
something about the quotient ype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2233
diff
changeset
|
453 |
|
8035515bbbc6
something about the quotient ype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2233
diff
changeset
|
454 |
\noindent |
2252 | 455 |
holds for every quotient type defined |
456 |
as above (for the proof see \cite{Homeier05}). |
|
2182 | 457 |
|
2247
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
458 |
The next step in a quotient construction is to introduce definitions of new constants |
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
459 |
involving the quotient type. These definitions need to be given in terms of concepts |
2238
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents:
2237
diff
changeset
|
460 |
of the raw type (remember this is the only way how to extend HOL |
2269
e4699a240d2c
tuned everytinh up to section 4
Christian Urban <urbanc@in.tum.de>
parents:
2265
diff
changeset
|
461 |
with new definitions). For the user the visible part of such definitions is the declaration |
2235
ad725de6e39b
more on the constant lifting section
Christian Urban <urbanc@in.tum.de>
parents:
2234
diff
changeset
|
462 |
|
ad725de6e39b
more on the constant lifting section
Christian Urban <urbanc@in.tum.de>
parents:
2234
diff
changeset
|
463 |
\begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
2237 | 464 |
\isacommand{quotient\_definition}~~@{text "c :: \<tau>"}~~\isacommand{is}~~@{text "t :: \<sigma>"} |
2235
ad725de6e39b
more on the constant lifting section
Christian Urban <urbanc@in.tum.de>
parents:
2234
diff
changeset
|
465 |
\end{isabelle} |
ad725de6e39b
more on the constant lifting section
Christian Urban <urbanc@in.tum.de>
parents:
2234
diff
changeset
|
466 |
|
2237 | 467 |
\noindent |
468 |
where @{text t} is the definiens (its type @{text \<sigma>} can always be inferred) |
|
469 |
and @{text "c"} is the name of definiendum, whose type @{text "\<tau>"} needs to be |
|
470 |
given explicitly (the point is that @{text "\<tau>"} and @{text "\<sigma>"} can only differ |
|
2269
e4699a240d2c
tuned everytinh up to section 4
Christian Urban <urbanc@in.tum.de>
parents:
2265
diff
changeset
|
471 |
in places where a quotient and raw type is involved). Two concrete examples are |
2188 | 472 |
|
2237 | 473 |
\begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
474 |
\begin{tabular}{@ {}l} |
|
475 |
\isacommand{quotient\_definition}~~@{text "0 :: int"}~~\isacommand{is}~~@{text "(0::nat, 0::nat)"}\\ |
|
476 |
\isacommand{quotient\_definition}~~@{text "\<Union> :: (\<alpha> fset) fset \<Rightarrow> \<alpha> fset"}~~% |
|
477 |
\isacommand{is}~~@{text "flat"} |
|
478 |
\end{tabular} |
|
479 |
\end{isabelle} |
|
480 |
||
481 |
\noindent |
|
482 |
The first one declares zero for integers and the second the operator for |
|
2238
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents:
2237
diff
changeset
|
483 |
building unions of finite sets. |
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents:
2237
diff
changeset
|
484 |
|
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents:
2237
diff
changeset
|
485 |
The problem for us is that from such declarations we need to derive proper |
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents:
2237
diff
changeset
|
486 |
definitions using the @{text "Abs"} and @{text "Rep"} functions for the |
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents:
2237
diff
changeset
|
487 |
quotient types involved. The data we rely on is the given quotient type |
2247
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
488 |
@{text "\<tau>"} and the raw type @{text "\<sigma>"}. They allow us to define \emph{aggregate |
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
489 |
abstraction} and \emph{representation functions} using the functions @{text "ABS (\<sigma>, |
2252 | 490 |
\<tau>)"} and @{text "REP (\<sigma>, \<tau>)"} whose clauses we give below. The idea behind |
2247
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
491 |
these two functions is to recursively descend into the raw types @{text \<sigma>} and |
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
492 |
quotient types @{text \<tau>}, and generate the appropriate |
2238
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents:
2237
diff
changeset
|
493 |
@{text "Abs"} and @{text "Rep"} in places where the types differ. Therefore |
2269
e4699a240d2c
tuned everytinh up to section 4
Christian Urban <urbanc@in.tum.de>
parents:
2265
diff
changeset
|
494 |
we generate just the identity whenever the types are equal. On the ``way'' down, |
e4699a240d2c
tuned everytinh up to section 4
Christian Urban <urbanc@in.tum.de>
parents:
2265
diff
changeset
|
495 |
however we might have to use map-functions to let @{text Abs} and @{text Rep} act |
e4699a240d2c
tuned everytinh up to section 4
Christian Urban <urbanc@in.tum.de>
parents:
2265
diff
changeset
|
496 |
over the appropriate types. The clauses of @{text ABS} and @{text REP} |
e4699a240d2c
tuned everytinh up to section 4
Christian Urban <urbanc@in.tum.de>
parents:
2265
diff
changeset
|
497 |
are as follows (where we use the short-hand notation @{text "ABS (\<sigma>s, \<tau>s)"} to mean |
e4699a240d2c
tuned everytinh up to section 4
Christian Urban <urbanc@in.tum.de>
parents:
2265
diff
changeset
|
498 |
@{text "ABS (\<sigma>\<^isub>1, \<tau>\<^isub>1)\<dots>ABS (\<sigma>\<^isub>i, \<tau>\<^isub>i)"}; similarly for @{text REP}): |
2182 | 499 |
|
2227 | 500 |
\begin{center} |
2252 | 501 |
\hfill |
2238
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents:
2237
diff
changeset
|
502 |
\begin{tabular}{rcl} |
2227 | 503 |
\multicolumn{3}{@ {\hspace{-4mm}}l}{equal types:}\\ |
2238
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents:
2237
diff
changeset
|
504 |
@{text "ABS (\<sigma>, \<sigma>)"} & $\dn$ & @{text "id :: \<sigma> \<Rightarrow> \<sigma>"}\\ |
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents:
2237
diff
changeset
|
505 |
@{text "REP (\<sigma>, \<sigma>)"} & $\dn$ & @{text "id :: \<sigma> \<Rightarrow> \<sigma>"}\smallskip\\ |
2227 | 506 |
\multicolumn{3}{@ {\hspace{-4mm}}l}{function types:}\\ |
2233 | 507 |
@{text "ABS (\<sigma>\<^isub>1 \<Rightarrow> \<sigma>\<^isub>2, \<tau>\<^isub>1 \<Rightarrow> \<tau>\<^isub>2)"} & $\dn$ & @{text "REP (\<sigma>\<^isub>1, \<tau>\<^isub>1) \<singlearr> ABS (\<sigma>\<^isub>2, \<tau>\<^isub>2)"}\\ |
508 |
@{text "REP (\<sigma>\<^isub>1 \<Rightarrow> \<sigma>\<^isub>2, \<tau>\<^isub>1 \<Rightarrow> \<tau>\<^isub>2)"} & $\dn$ & @{text "ABS (\<sigma>\<^isub>1, \<tau>\<^isub>1) \<singlearr> REP (\<sigma>\<^isub>2, \<tau>\<^isub>2)"}\smallskip\\ |
|
2227 | 509 |
\multicolumn{3}{@ {\hspace{-4mm}}l}{equal type constructors:}\\ |
2232
f49b5dfabd59
improved definition of ABS and REP
Christian Urban <urbanc@in.tum.de>
parents:
2231
diff
changeset
|
510 |
@{text "ABS (\<sigma>s \<kappa>, \<tau>s \<kappa>)"} & $\dn$ & @{text "map_\<kappa> (ABS (\<sigma>s, \<tau>s))"}\\ |
f49b5dfabd59
improved definition of ABS and REP
Christian Urban <urbanc@in.tum.de>
parents:
2231
diff
changeset
|
511 |
@{text "REP (\<sigma>s \<kappa>, \<tau>s \<kappa>)"} & $\dn$ & @{text "map_\<kappa> (REP (\<sigma>s, \<tau>s))"}\smallskip\\ |
2227 | 512 |
\multicolumn{3}{@ {\hspace{-4mm}}l}{unequal type constructors:}\\ |
2238
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents:
2237
diff
changeset
|
513 |
@{text "ABS (\<sigma>s \<kappa>, \<tau>s \<kappa>\<^isub>q)"} & $\dn$ & @{text "Abs_\<kappa>\<^isub>q \<circ> (MAP(\<rho>s \<kappa>) (ABS (\<sigma>s', \<tau>s)))"}\\ |
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents:
2237
diff
changeset
|
514 |
@{text "REP (\<sigma>s \<kappa>, \<tau>s \<kappa>\<^isub>q)"} & $\dn$ & @{text "(MAP(\<rho>s \<kappa>) (REP (\<sigma>s', \<tau>s))) \<circ> Rep_\<kappa>\<^isub>q"} |
2247
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
515 |
\end{tabular}\hfill\numbered{ABSREP} |
2227 | 516 |
\end{center} |
2234
8035515bbbc6
something about the quotient ype definitions
Christian Urban <urbanc@in.tum.de>
parents:
2233
diff
changeset
|
517 |
% |
2232
f49b5dfabd59
improved definition of ABS and REP
Christian Urban <urbanc@in.tum.de>
parents:
2231
diff
changeset
|
518 |
\noindent |
2269
e4699a240d2c
tuned everytinh up to section 4
Christian Urban <urbanc@in.tum.de>
parents:
2265
diff
changeset
|
519 |
where in the last two clauses we have that the type @{text "\<alpha>s |
2238
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents:
2237
diff
changeset
|
520 |
\<kappa>\<^isub>q"} is the quotient of the raw type @{text "\<rho>s \<kappa>"} (for example |
2237 | 521 |
@{text "int"} and @{text "nat \<times> nat"}, or @{text "\<alpha> fset"} and @{text "\<alpha> |
522 |
list"}). The quotient construction ensures that the type variables in @{text |
|
2247
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
523 |
"\<rho>s"} must be among the @{text "\<alpha>s"}. The @{text "\<sigma>s'"} are given by the |
2238
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents:
2237
diff
changeset
|
524 |
matchers for the @{text "\<alpha>s"} when matching @{text "\<rho>s \<kappa>"} against |
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents:
2237
diff
changeset
|
525 |
@{text "\<sigma>s \<kappa>"}. The |
2237 | 526 |
function @{text "MAP"} calculates an \emph{aggregate map-function} for a raw |
527 |
type as follows: |
|
528 |
% |
|
2227 | 529 |
\begin{center} |
2238
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents:
2237
diff
changeset
|
530 |
\begin{tabular}{rcl} |
2237 | 531 |
@{text "MAP' (\<alpha>)"} & $\dn$ & @{text "a\<^sup>\<alpha>"}\\ |
2238
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents:
2237
diff
changeset
|
532 |
@{text "MAP' (\<kappa>)"} & $\dn$ & @{text "id :: \<kappa> \<Rightarrow> \<kappa>"}\\ |
2232
f49b5dfabd59
improved definition of ABS and REP
Christian Urban <urbanc@in.tum.de>
parents:
2231
diff
changeset
|
533 |
@{text "MAP' (\<sigma>s \<kappa>)"} & $\dn$ & @{text "map_\<kappa> (MAP'(\<sigma>s))"}\smallskip\\ |
2233 | 534 |
@{text "MAP (\<sigma>)"} & $\dn$ & @{text "\<lambda>as. MAP'(\<sigma>)"} |
2238
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents:
2237
diff
changeset
|
535 |
\end{tabular} |
2227 | 536 |
\end{center} |
2237 | 537 |
% |
2232
f49b5dfabd59
improved definition of ABS and REP
Christian Urban <urbanc@in.tum.de>
parents:
2231
diff
changeset
|
538 |
\noindent |
2252 | 539 |
In this definition we rely on the fact that we can interpret type-variables @{text \<alpha>} as |
2238
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents:
2237
diff
changeset
|
540 |
term variables @{text a}. In the last clause we build an abstraction over all |
2247
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
541 |
term-variables inside map-function generated by the auxiliary function |
2238
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents:
2237
diff
changeset
|
542 |
@{text "MAP'"}. |
2247
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
543 |
The need of aggregate map-functions can be seen in cases where we build quotients, |
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
544 |
say @{text "(\<alpha>, \<beta>) \<kappa>\<^isub>q"}, out of compound raw types, say @{text "(\<alpha> list) \<times> \<beta>"}. |
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
545 |
In this case @{text MAP} generates the |
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
546 |
aggregate map-function: |
2232
f49b5dfabd59
improved definition of ABS and REP
Christian Urban <urbanc@in.tum.de>
parents:
2231
diff
changeset
|
547 |
|
2233 | 548 |
@{text [display, indent=10] "\<lambda>a b. map_prod (map a) b"} |
549 |
||
550 |
\noindent |
|
2269
e4699a240d2c
tuned everytinh up to section 4
Christian Urban <urbanc@in.tum.de>
parents:
2265
diff
changeset
|
551 |
which we need in order to define the aggregate abstraction and representation |
e4699a240d2c
tuned everytinh up to section 4
Christian Urban <urbanc@in.tum.de>
parents:
2265
diff
changeset
|
552 |
functions. |
2238
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents:
2237
diff
changeset
|
553 |
|
2247
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
554 |
To see how these definitions pan out in practise, let us return to our |
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
555 |
example about @{term "concat"} and @{term "fconcat"}, where we have the raw type |
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
556 |
@{text "(\<alpha> list) list \<Rightarrow> \<alpha> list"} and the quotient type @{text "(\<alpha> fset) fset \<Rightarrow> \<alpha> |
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
557 |
fset"}. Feeding them into @{text ABS} gives us (after some @{text "\<beta>"}-simplifications) |
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
558 |
the abstraction function |
2233 | 559 |
|
560 |
@{text [display, indent=10] "(map (map id \<circ> Rep_fset) \<circ> Rep_fset) \<singlearr> Abs_fset \<circ> map id"} |
|
561 |
||
562 |
\noindent |
|
2247
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
563 |
In our implementation we further |
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
564 |
simplify this function by rewriting with the usual laws about @{text |
2238
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents:
2237
diff
changeset
|
565 |
"map"}s and @{text "id"}, namely @{term "map id = id"} and @{text "f \<circ> id = |
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents:
2237
diff
changeset
|
566 |
id \<circ> f = f"}. This gives us the abstraction function |
2237 | 567 |
|
2233 | 568 |
@{text [display, indent=10] "(map Rep_fset \<circ> Rep_fset) \<singlearr> Abs_fset"} |
569 |
||
570 |
\noindent |
|
571 |
which we can use for defining @{term "fconcat"} as follows |
|
572 |
||
573 |
@{text [display, indent=10] "\<Union> \<equiv> ((map Rep_fset \<circ> Rep_fset) \<singlearr> Abs_fset) flat"} |
|
2232
f49b5dfabd59
improved definition of ABS and REP
Christian Urban <urbanc@in.tum.de>
parents:
2231
diff
changeset
|
574 |
|
2237 | 575 |
\noindent |
2247
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
576 |
Note that by using the operator @{text "\<singlearr>"} and special clauses |
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
577 |
for function types in \eqref{ABSREP}, we do not have to |
2252 | 578 |
distinguish between arguments and results, but can deal with them uniformly. |
579 |
Consequently, all definitions in the quotient package |
|
2238
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents:
2237
diff
changeset
|
580 |
are of the general form |
2188 | 581 |
|
2237 | 582 |
@{text [display, indent=10] "c \<equiv> ABS (\<sigma>, \<tau>) t"} |
2227 | 583 |
|
2237 | 584 |
\noindent |
2238
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents:
2237
diff
changeset
|
585 |
where @{text \<sigma>} is the type of the definiens @{text "t"} and @{text "\<tau>"} the |
2247
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
586 |
type of the defined quotient constant @{text "c"}. This data can be easily |
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
587 |
generated from the declaration given by the user. |
2252 | 588 |
To increase the confidence in this way of making definitions, we can prove |
2247
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
589 |
that the terms involved are all typable. |
2227 | 590 |
|
591 |
\begin{lemma} |
|
592 |
If @{text "ABS (\<sigma>, \<tau>)"} returns some abstraction function @{text "Abs"} |
|
593 |
and @{text "REP (\<sigma>, \<tau>)"} some representation function @{text "Rep"}, |
|
594 |
then @{text "Abs"} is of type @{text "\<sigma> \<Rightarrow> \<tau>"} and @{text "Rep"} of type |
|
595 |
@{text "\<tau> \<Rightarrow> \<sigma>"}. |
|
596 |
\end{lemma} |
|
2233 | 597 |
|
2237 | 598 |
\begin{proof} |
2269
e4699a240d2c
tuned everytinh up to section 4
Christian Urban <urbanc@in.tum.de>
parents:
2265
diff
changeset
|
599 |
By mutual induction and analysing the definitions of @{text "ABS"}, @{text "REP"} |
2247
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
600 |
and @{text "MAP"}. The cases of equal types and function types are |
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
601 |
straightforward (the latter follows from @{text "\<singlearr>"} having the |
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
602 |
type @{text "(\<alpha> \<Rightarrow> \<beta>) \<Rightarrow> (\<gamma> \<Rightarrow> \<delta>) \<Rightarrow> (\<beta> \<Rightarrow> \<gamma>) \<Rightarrow> (\<alpha> \<Rightarrow> \<delta>)"}). In case of equal type |
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
603 |
constructors we can observe that a map-function after applying the functions |
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
604 |
@{text "ABS (\<sigma>s, \<tau>s)"} produces a term of type @{text "\<sigma>s \<kappa> \<Rightarrow> \<tau>s \<kappa>"}. The |
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
605 |
interesting case is the one with unequal type constructors. Since we know |
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
606 |
the quotient is between @{text "\<alpha>s \<kappa>\<^isub>q"} and @{text "\<rho>s \<kappa>"}, we have |
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
607 |
that @{text "Abs_\<kappa>\<^isub>q"} is of type @{text "\<rho>s \<kappa> \<Rightarrow> \<alpha>s |
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
608 |
\<kappa>\<^isub>q"}. This type can be more specialised to @{text "\<rho>s[\<tau>s] \<kappa> \<Rightarrow> \<tau>s |
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
609 |
\<kappa>\<^isub>q"} where the type variables @{text "\<alpha>s"} are instantiated with the |
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
610 |
@{text "\<tau>s"}. The complete type can be calculated by observing that @{text |
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
611 |
"MAP (\<rho>s \<kappa>)"}, after applying the functions @{text "ABS (\<sigma>s', \<tau>s)"} to it, |
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
612 |
returns a term of type @{text "\<rho>s[\<sigma>s'] \<kappa> \<Rightarrow> \<rho>s[\<tau>s] \<kappa>"}. This type is |
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
613 |
equivalent to @{text "\<sigma>s \<kappa> \<Rightarrow> \<rho>s[\<tau>s] \<kappa>"}, which we just have to compose with |
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
614 |
@{text "\<rho>s[\<tau>s] \<kappa> \<Rightarrow> \<tau>s \<kappa>\<^isub>q"} according to the type of @{text "\<circ>"}.\qed |
2237 | 615 |
\end{proof} |
616 |
||
617 |
\noindent |
|
2238
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents:
2237
diff
changeset
|
618 |
The reader should note that this lemma fails for the abstraction and representation |
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents:
2237
diff
changeset
|
619 |
functions used, for example, in Homeier's quotient package. |
2188 | 620 |
*} |
621 |
||
2252 | 622 |
section {* Respectfulness and Preservation \label{sec:resp} *} |
2188 | 623 |
|
624 |
text {* |
|
2247
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
625 |
The main point of the quotient package is to automatically ``lift'' theorems |
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
626 |
involving constants over the raw type to theorems involving constants over |
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
627 |
the quotient type. Before we can describe this lift process, we need to impose |
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
628 |
some restrictions. The reason is that even if definitions for all raw constants |
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
629 |
can be given, \emph{not} all theorems can be actually be lifted. Most notably is |
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
630 |
the bound variable function, that is the constant @{text bn}, defined for |
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
631 |
raw lambda-terms as follows |
2188 | 632 |
|
2247
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
633 |
\begin{isabelle}\ \ \ \ \ \ \ \ \ \ %%% |
2252 | 634 |
@{text "bn (x) \<equiv> \<emptyset>"}\hspace{4mm} |
635 |
@{text "bn (t\<^isub>1 t\<^isub>2) \<equiv> bn (t\<^isub>1) \<union> bn (t\<^isub>2)"}\hspace{4mm} |
|
2247
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
636 |
@{text "bn (\<lambda>x. t) \<equiv> {x} \<union> bn (t)"} |
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
637 |
\end{isabelle} |
2238
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents:
2237
diff
changeset
|
638 |
|
2247
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
639 |
\noindent |
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
640 |
This constant just does not respect @{text "\<alpha>"}-equivalence and as |
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
641 |
consequently no theorem involving this constant can be lifted to @{text |
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
642 |
"\<alpha>"}-equated lambda terms. Homeier formulates the restrictions in terms of |
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
643 |
the properties of \emph{respectfullness} and \emph{preservation}. We have |
2258
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
644 |
to slightly extend Homeier's definitions in order to deal with quotient |
2247
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
645 |
compositions. |
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
646 |
|
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
647 |
To formally define what respectfulness is, we have to first define |
084b2b7df98a
some tuning and start work on section 4
Christian Urban <urbanc@in.tum.de>
parents:
2243
diff
changeset
|
648 |
the notion of \emph{aggregate equivalence relations}. |
2238
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents:
2237
diff
changeset
|
649 |
|
2258
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
650 |
TBD |
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
651 |
|
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
652 |
\begin{itemize} |
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
653 |
\item @{text "REL(\<alpha>\<^isub>1, \<alpha>\<^isub>2)"} = @{text "op ="} |
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
654 |
\item @{text "REL(\<sigma>, \<sigma>)"} = @{text "op ="} |
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
655 |
\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))"} |
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
656 |
\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"} |
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
657 |
\end{itemize} |
2238
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents:
2237
diff
changeset
|
658 |
|
2188 | 659 |
class returned by this constant depends only on the equivalence |
2207 | 660 |
classes of the arguments applied to the constant. To automatically |
661 |
lift a theorem that talks about a raw constant, to a theorem about |
|
662 |
the quotient type a respectfulness theorem is required. |
|
663 |
||
664 |
A respectfulness condition for a constant can be expressed in |
|
665 |
terms of an aggregate relation between the constant and itself, |
|
2238
8ddf1330f2ed
completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents:
2237
diff
changeset
|
666 |
for example the respectfullness for @{text "append"} |
2188 | 667 |
can be stated as: |
668 |
||
2258
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
669 |
@{text [display, indent=10] "(\<approx>\<^bsub>list\<^esub> \<doublearr> \<approx>\<^bsub>list\<^esub> \<doublearr> \<approx>\<^bsub>list\<^esub>) append append"} |
2182 | 670 |
|
2190 | 671 |
\noindent |
2228
a827d36fa467
qpaper / tuning in preservation and general display
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2227
diff
changeset
|
672 |
Which after unfolding the definition of @{term "op ===>"} is equivalent to: |
2188 | 673 |
|
2228
a827d36fa467
qpaper / tuning in preservation and general display
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2227
diff
changeset
|
674 |
@{thm [display, indent=10] append_rsp_unfolded[no_vars]} |
2188 | 675 |
|
2228
a827d36fa467
qpaper / tuning in preservation and general display
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2227
diff
changeset
|
676 |
\noindent An aggregate relation is defined in terms of relation |
a827d36fa467
qpaper / tuning in preservation and general display
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2227
diff
changeset
|
677 |
composition, so we define it first: |
2188 | 678 |
|
2258
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
679 |
|
2188 | 680 |
|
2207 | 681 |
The aggregate relation for an aggregate raw type and quotient type |
682 |
is defined as: |
|
2188 | 683 |
|
684 |
||
2207 | 685 |
Again, the last case is novel, so lets look at the example of |
686 |
respectfullness for @{term concat}. The statement according to |
|
687 |
the definition above is: |
|
2190 | 688 |
|
2228
a827d36fa467
qpaper / tuning in preservation and general display
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2227
diff
changeset
|
689 |
@{thm [display, indent=10] concat_rsp[no_vars]} |
2189 | 690 |
|
2190 | 691 |
\noindent |
692 |
By unfolding the definition of relation composition and relation map |
|
693 |
we can see the equivalent statement just using the primitive list |
|
694 |
equivalence relation: |
|
695 |
||
2228
a827d36fa467
qpaper / tuning in preservation and general display
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2227
diff
changeset
|
696 |
@{thm [display, indent=10] concat_rsp_unfolded[of "a" "a'" "b'" "b", no_vars]} |
2189 | 697 |
|
2190 | 698 |
The statement reads that, for any lists of lists @{term a} and @{term b} |
699 |
if there exist intermediate lists of lists @{term "a'"} and @{term "b'"} |
|
700 |
such that each element of @{term a} is in the relation with an appropriate |
|
701 |
element of @{term a'}, @{term a'} is in relation with @{term b'} and each |
|
702 |
element of @{term b'} is in relation with the appropriate element of |
|
703 |
@{term b}. |
|
2189 | 704 |
|
705 |
||
2228
a827d36fa467
qpaper / tuning in preservation and general display
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2227
diff
changeset
|
706 |
Sometimes a non-lifted polymorphic constant is instantiated to a |
a827d36fa467
qpaper / tuning in preservation and general display
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2227
diff
changeset
|
707 |
type being lifted. For example take the @{term "op #"} which inserts |
a827d36fa467
qpaper / tuning in preservation and general display
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2227
diff
changeset
|
708 |
an element in a list of pairs of natural numbers. When the theorem |
a827d36fa467
qpaper / tuning in preservation and general display
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2227
diff
changeset
|
709 |
is lifted, the pairs of natural numbers are to become integers, but |
a827d36fa467
qpaper / tuning in preservation and general display
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2227
diff
changeset
|
710 |
the head constant is still supposed to be the head constant, just |
a827d36fa467
qpaper / tuning in preservation and general display
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2227
diff
changeset
|
711 |
with a different type. To be able to lift such theorems |
a827d36fa467
qpaper / tuning in preservation and general display
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2227
diff
changeset
|
712 |
automatically, additional theorems provided by the user are |
a827d36fa467
qpaper / tuning in preservation and general display
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2227
diff
changeset
|
713 |
necessary, we call these \emph{preservation} theorems following |
a827d36fa467
qpaper / tuning in preservation and general display
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2227
diff
changeset
|
714 |
Homeier's naming. |
2196
74637f186af7
qpaper / a bit about prs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2195
diff
changeset
|
715 |
|
74637f186af7
qpaper / a bit about prs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2195
diff
changeset
|
716 |
To lift theorems that talk about insertion in lists of lifted types |
74637f186af7
qpaper / a bit about prs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2195
diff
changeset
|
717 |
we need to know that for any quotient type with the abstraction and |
74637f186af7
qpaper / a bit about prs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2195
diff
changeset
|
718 |
representation functions @{text "Abs"} and @{text Rep} we have: |
74637f186af7
qpaper / a bit about prs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2195
diff
changeset
|
719 |
|
2228
a827d36fa467
qpaper / tuning in preservation and general display
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2227
diff
changeset
|
720 |
@{thm [display, indent=10] (concl) cons_prs[no_vars]} |
2196
74637f186af7
qpaper / a bit about prs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2195
diff
changeset
|
721 |
|
74637f186af7
qpaper / a bit about prs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2195
diff
changeset
|
722 |
This is not enough to lift theorems that talk about quotient compositions. |
74637f186af7
qpaper / a bit about prs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2195
diff
changeset
|
723 |
For some constants (for example empty list) it is possible to show a |
74637f186af7
qpaper / a bit about prs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2195
diff
changeset
|
724 |
general compositional theorem, but for @{term "op #"} it is necessary |
74637f186af7
qpaper / a bit about prs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2195
diff
changeset
|
725 |
to show that it respects the particular quotient type: |
74637f186af7
qpaper / a bit about prs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2195
diff
changeset
|
726 |
|
2228
a827d36fa467
qpaper / tuning in preservation and general display
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2227
diff
changeset
|
727 |
@{thm [display, indent=10] insert_preserve2[no_vars]} |
2190 | 728 |
|
2258
72ce58b76c3b
finished preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2257
diff
changeset
|
729 |
{\it Composition of Quotient theorems} |
2189 | 730 |
|
2191
8fdfbec54229
qpaper / composition of quotients.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2190
diff
changeset
|
731 |
Given two quotients, one of which quotients a container, and the |
8fdfbec54229
qpaper / composition of quotients.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2190
diff
changeset
|
732 |
other quotients the type in the container, we can write the |
2193 | 733 |
composition of those quotients. To compose two quotient theorems |
2207 | 734 |
we compose the relations with relation composition as defined above |
735 |
and the abstraction and relation functions are the ones of the sub |
|
736 |
quotients composed with the usual function composition. |
|
737 |
The @{term "Rep"} and @{term "Abs"} functions that we obtain agree |
|
738 |
with the definition of aggregate Abs/Rep functions and the |
|
2193 | 739 |
relation is the same as the one given by aggregate relations. |
740 |
This becomes especially interesting |
|
2191
8fdfbec54229
qpaper / composition of quotients.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2190
diff
changeset
|
741 |
when we compose the quotient with itself, as there is no simple |
8fdfbec54229
qpaper / composition of quotients.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2190
diff
changeset
|
742 |
intermediate step. |
8fdfbec54229
qpaper / composition of quotients.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2190
diff
changeset
|
743 |
|
2242 | 744 |
Lets take again the example of @{term flat}. To be able to lift |
2207 | 745 |
theorems that talk about it we provide the composition quotient |
2266
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2265
diff
changeset
|
746 |
theorem which allows quotienting inside the container: |
2254 | 747 |
|
2266
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2265
diff
changeset
|
748 |
If @{term R} is an equivalence relation and @{term "Quotient R Abs Rep"} |
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2265
diff
changeset
|
749 |
then |
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2265
diff
changeset
|
750 |
|
dcffc2f132c9
Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2265
diff
changeset
|
751 |
@{text [display, indent=10] "Quotient (list_rel R \<circ>\<circ>\<circ> \<approx>\<^bsub>list\<^esub>) (abs_fset \<circ> map Abs) (map Rep o rep_fset)"} |
2188 | 752 |
|
2254 | 753 |
\noindent |
754 |
this theorem will then instantiate the quotients needed in the |
|
755 |
injection and cleaning proofs allowing the lifting procedure to |
|
756 |
proceed in an unchanged way. |
|
757 |
||
2192 | 758 |
*} |
759 |
||
2256
f5f21feaa168
some slight tuning of the preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2255
diff
changeset
|
760 |
section {* Lifting of Theorems\label{sec:lift} *} |
1978 | 761 |
|
2194
a52499e125ce
qpaper / lifting introduction
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2193
diff
changeset
|
762 |
text {* |
2271
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
763 |
|
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
764 |
The core of a quotient package lifts an original theorem to a lifted |
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
765 |
version. We will perform this operation in three phases. In the |
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
766 |
following we call these phases \emph{regularization}, |
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
767 |
\emph{injection} and \emph{cleaning} following the names used in |
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
768 |
Homeier's HOL4 implementation. |
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
769 |
|
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
770 |
Regularization is supposed to change the quantifications and abstractions |
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
771 |
in the theorem to quantification over variables that respect the relation |
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
772 |
(definition \ref{def:respects}). Injection is supposed to add @{term Rep} |
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
773 |
and @{term Abs} of appropriate types in front of constants and variables |
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
774 |
of the raw type so that they can be replaced by the ones that include the |
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
775 |
quotient type. Cleaning rewrites the obtained injected theorem with |
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
776 |
preservation rules obtaining the desired goal theorem. |
2193 | 777 |
|
2271
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
778 |
Most quotient packages take only an original theorem involving raw |
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
779 |
types and lift it. The procedure in our package takes both an |
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
780 |
original theorem involving raw types and a statement of the theorem |
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
781 |
that it is supposed to produce. To simplify the use of the quotient |
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
782 |
package we additionally provide an automated statement translation |
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
783 |
mechanism which can produce the latter automatically given a list of |
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
784 |
quotient types. It is possible that a user wants to lift only some |
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
785 |
occurrences of a raw type. In this case the user specifies the |
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
786 |
complete lifted goal instead of using the automated mechanism. |
2193 | 787 |
|
2271
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
788 |
In the following we will first define the statement of the |
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
789 |
regularized theorem based on the original theorem and the goal |
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
790 |
theorem. Then we define the statement of the injected theorem, based |
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
791 |
on the regularized theorem and the goal. We then show the 3 proofs, |
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
792 |
all three can be performed independently from each other. |
2197 | 793 |
|
2251
1a4fc8d3873f
Qpaper / beginnig of sec5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2250
diff
changeset
|
794 |
We define the function @{text REG}, which takes the statements |
2207 | 795 |
of the raw theorem and the lifted theorem (both as terms) and |
796 |
returns the statement of the regularized version. The intuition |
|
797 |
behind this function is that it replaces quantifiers and |
|
798 |
abstractions involving raw types by bounded ones, and equalities |
|
799 |
involving raw types are replaced by appropriate aggregate |
|
2251
1a4fc8d3873f
Qpaper / beginnig of sec5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2250
diff
changeset
|
800 |
equivalence relations. It is defined as follows: |
1994 | 801 |
|
2244 | 802 |
\begin{center} |
803 |
\begin{tabular}{rcl} |
|
804 |
\multicolumn{3}{@ {\hspace{-4mm}}l}{abstractions (with same types and different types):}\\ |
|
805 |
@{text "REG (\<lambda>x : \<sigma>. t, \<lambda>x : \<sigma>. s)"} & $\dn$ & @{text "\<lambda>x : \<sigma>. REG (t, s)"}\\ |
|
2267 | 806 |
@{text "REG (\<lambda>x : \<sigma>. t, \<lambda>x : \<tau>. s)"} & $\dn$ & @{text "\<lambda>x : \<sigma> \<in> Respects (REL (\<sigma>, \<tau>)). REG (t, s)"}\\ |
2244 | 807 |
\multicolumn{3}{@ {\hspace{-4mm}}l}{quantification (over same types and different types):}\\ |
808 |
@{text "REG (\<forall>x : \<sigma>. t, \<forall>x : \<sigma>. s)"} & $\dn$ & @{text "\<forall>x : \<sigma>. REG (t, s)"}\\ |
|
2267 | 809 |
@{text "REG (\<forall>x : \<sigma>. t, \<forall>x : \<tau>. s)"} & $\dn$ & @{text "\<forall>x : \<sigma> \<in> Respects (REL (\<sigma>, \<tau>)). REG (t, s)"}\\ |
2245 | 810 |
\multicolumn{3}{@ {\hspace{-4mm}}l}{equalities (with same types and different types):}\\ |
2244 | 811 |
@{text "REG ((op =) : \<sigma>, (op =) : \<sigma>)"} & $\dn$ & @{text "(op =) : \<sigma>"}\\ |
812 |
@{text "REG ((op =) : \<sigma>, (op =) : \<tau>)"} & $\dn$ & @{text "REL (\<sigma>, \<tau>) : \<sigma>"}\\ |
|
2245 | 813 |
\multicolumn{3}{@ {\hspace{-4mm}}l}{applications, variables, constants:}\\ |
2244 | 814 |
@{text "REG (t\<^isub>1 t\<^isub>2, s\<^isub>1 s\<^isub>2)"} & $\dn$ & @{text "REG (t\<^isub>1, s\<^isub>1) REG (t\<^isub>2, s\<^isub>2)"}\\ |
815 |
@{text "REG (v\<^isub>1, v\<^isub>2)"} & $\dn$ & @{text "v\<^isub>1"}\\ |
|
816 |
@{text "REG (c\<^isub>1, c\<^isub>2)"} & $\dn$ & @{text "c\<^isub>1"}\\ |
|
817 |
\end{tabular} |
|
818 |
\end{center} |
|
1994 | 819 |
|
2230 | 820 |
In the above definition we omitted the cases for existential quantifiers |
2207 | 821 |
and unique existential quantifiers, as they are very similar to the cases |
822 |
for the universal quantifier. |
|
823 |
Next we define the function @{text INJ} which takes the statement of |
|
824 |
the regularized theorems and the statement of the lifted theorem both as |
|
2230 | 825 |
terms and returns the statement of the injected theorem: |
2198
8fe1a706ade7
qpaper / injection statement
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2197
diff
changeset
|
826 |
|
2245 | 827 |
\begin{center} |
828 |
\begin{tabular}{rcl} |
|
829 |
\multicolumn{3}{@ {\hspace{-4mm}}l}{abstractions (with same types and different types):}\\ |
|
830 |
@{text "INJ ((\<lambda>x. t) : \<sigma>, (\<lambda>x. s) : \<sigma>) "} & $\dn$ & @{text "\<lambda>x. INJ (t, s)"}\\ |
|
831 |
@{text "INJ ((\<lambda>x. t) : \<sigma>, (\<lambda>x. s) : \<tau>) "} & $\dn$ & @{text "REP(\<sigma>,\<tau>) (ABS (\<sigma>,\<tau>) (\<lambda>x. (INJ (t, s))))"}\\ |
|
832 |
@{text "INJ ((\<lambda>x \<in> R. t) : \<sigma>, (\<lambda>x. s) : \<tau>) "} & $\dn$ & @{text "REP(\<sigma>,\<tau>) (ABS (\<sigma>,\<tau>) (\<lambda>x \<in> R. (INJ (t, s))))"}\\ |
|
833 |
\multicolumn{3}{@ {\hspace{-4mm}}l}{quantification (over same types and different types):}\\ |
|
834 |
@{text "INJ (\<forall> t, \<forall> s) "} & $\dn$ & @{text "\<forall> (INJ (t, s))"}\\ |
|
835 |
@{text "INJ (\<forall> t \<in> R, \<forall> s) "} & $\dn$ & @{text "\<forall> INJ (t, s) \<in> R"}\\ |
|
836 |
\multicolumn{3}{@ {\hspace{-4mm}}l}{applications, variables, constants:}\\ |
|
837 |
@{text "INJ (t\<^isub>1 t\<^isub>2, s\<^isub>1 s\<^isub>2) "} & $\dn$ & @{text " INJ (t\<^isub>1, s\<^isub>1) INJ (t\<^isub>2, s\<^isub>2)"}\\ |
|
838 |
@{text "INJ (v\<^isub>1 : \<sigma>, v\<^isub>2 : \<sigma>) "} & $\dn$ & @{text "v\<^isub>1"}\\ |
|
839 |
@{text "INJ (v\<^isub>1 : \<sigma>, v\<^isub>2 : \<tau>) "} & $\dn$ & @{text "REP(\<sigma>,\<tau>) (ABS (\<sigma>,\<tau>) (v\<^isub>1))"}\\ |
|
840 |
@{text "INJ (c\<^isub>1 : \<sigma>, c\<^isub>2 : \<sigma>) "} & $\dn$ & @{text "c\<^isub>1"}\\ |
|
841 |
@{text "INJ (c\<^isub>1 : \<sigma>, c\<^isub>2 : \<tau>) "} & $\dn$ & @{text "REP(\<sigma>,\<tau>) (ABS (\<sigma>,\<tau>) (c\<^isub>1))"}\\ |
|
842 |
\end{tabular} |
|
843 |
\end{center} |
|
2198
8fe1a706ade7
qpaper / injection statement
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2197
diff
changeset
|
844 |
|
2271
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
845 |
\noindent where the cases for existential quantifiers and unique existential |
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
846 |
quantifiers have been omitted for clarity; are similar to universal quantifier. |
2208 | 847 |
|
2271
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
848 |
We can now define the subgoals that will imply the lifted theorem. Given |
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
849 |
the statement of the original theorem @{term t} and the statement of the |
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
850 |
goal @{term g} the regularization subgoal is @{term "t \<longrightarrow> REG(t, g)"}, |
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
851 |
the injection subgoal is @{term "REG(t, g) = INJ(REG(t, g), g)"} and the |
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
852 |
cleaning subgoal is @{term "INJ(REG(t, g), g) = g"}. We will now describe |
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
853 |
the three tactics provided for these three subgoals. |
2208 | 854 |
|
855 |
The injection and cleaning subgoals are always solved if the appropriate |
|
856 |
respectfulness and preservation theorems are given. It is not the case |
|
857 |
with regularization; sometimes a theorem given by the user does not |
|
858 |
imply a regularized version and a stronger one needs to be proved. This |
|
2242 | 859 |
is outside of the scope of the quotient package, so such obligations are |
860 |
left to the user. Take a simple statement for integers @{term "0 \<noteq> 1"}. |
|
861 |
It does not follow from the fact that @{term "\<not> (0, 0) = (1, 0)"} because |
|
862 |
of regularization. The raw theorem only shows that particular items in the |
|
863 |
equivalence classes are not equal. A more general statement saying that |
|
864 |
the classes are not equal is necessary. |
|
2261 | 865 |
|
2271
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
866 |
In the proof of the regularization subgoal we always start with an implication. |
2209
5952b0f28261
Qpaper/regularization proof.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2208
diff
changeset
|
867 |
Isabelle provides a set of \emph{mono} rules, that are used to split implications |
2230 | 868 |
of similar statements into simpler implication subgoals. These are enhanced |
2249
1476c26d4310
qpaper/unfold the ball_reg_right statement
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2246
diff
changeset
|
869 |
with special quotient theorem in the regularization proof. Below we only show |
2209
5952b0f28261
Qpaper/regularization proof.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2208
diff
changeset
|
870 |
the versions for the universal quantifier. For the existential quantifier |
2242 | 871 |
and abstraction they are analogous. |
2199
6ce64fb5cbd9
qpaper / lemmas used in proofs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2198
diff
changeset
|
872 |
|
2209
5952b0f28261
Qpaper/regularization proof.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2208
diff
changeset
|
873 |
First, bounded universal quantifiers can be removed on the right: |
2199
6ce64fb5cbd9
qpaper / lemmas used in proofs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2198
diff
changeset
|
874 |
|
2249
1476c26d4310
qpaper/unfold the ball_reg_right statement
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2246
diff
changeset
|
875 |
@{thm [display, indent=10] ball_reg_right_unfolded[no_vars]} |
2206 | 876 |
|
2209
5952b0f28261
Qpaper/regularization proof.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2208
diff
changeset
|
877 |
They can be removed anywhere if the relation is an equivalence relation: |
5952b0f28261
Qpaper/regularization proof.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2208
diff
changeset
|
878 |
|
2265
9c44db3eef95
Remove only reference to 'equivp'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2264
diff
changeset
|
879 |
@{thm [display, indent=10] (concl) ball_reg_eqv[no_vars]} |
2209
5952b0f28261
Qpaper/regularization proof.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2208
diff
changeset
|
880 |
|
2259 | 881 |
And finally it can be removed anywhere if @{term R2} is an equivalence relation: |
2231 | 882 |
|
883 |
@{thm [display, indent=10] (concl) ball_reg_eqv_range[no_vars]} |
|
2209
5952b0f28261
Qpaper/regularization proof.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2208
diff
changeset
|
884 |
|
2242 | 885 |
The last theorem is new in comparison with Homeier's package. There the |
2231 | 886 |
injection procedure would be used to prove goals with such shape, and there |
2242 | 887 |
the equivalence assumption would be used. We use the above theorem directly |
888 |
also for composed relations where the range type is a type for which we know an |
|
2231 | 889 |
equivalence theorem. This allows separating regularization from injection. |
2206 | 890 |
|
2211
9d0673c319d1
qpaper / injection proof.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2210
diff
changeset
|
891 |
The injection proof starts with an equality between the regularized theorem |
9d0673c319d1
qpaper / injection proof.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2210
diff
changeset
|
892 |
and the injected version. The proof again follows by the structure of the |
2242 | 893 |
two terms, and is defined for a goal being a relation between these two terms. |
2199
6ce64fb5cbd9
qpaper / lemmas used in proofs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2198
diff
changeset
|
894 |
|
2211
9d0673c319d1
qpaper / injection proof.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2210
diff
changeset
|
895 |
\begin{itemize} |
9d0673c319d1
qpaper / injection proof.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2210
diff
changeset
|
896 |
\item For two constants, an appropriate constant respectfullness assumption is used. |
2242 | 897 |
\item For two variables, we use the assumptions proved in regularization. |
2211
9d0673c319d1
qpaper / injection proof.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2210
diff
changeset
|
898 |
\item For two abstractions, they are eta-expanded and beta-reduced. |
2271
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
899 |
\item For two applications, if the right side is an application of |
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
900 |
@{term Rep} to an @{term Abs} and @{term "Quotient R Rep Abs"} we |
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
901 |
can reduce the injected pair using the theorem: |
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
902 |
|
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
903 |
@{term [display, indent=10] "R x y \<longrightarrow> R x (Rep (Abs y))"} |
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
904 |
|
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
905 |
otherwise we introduce an appropriate relation between the subterms |
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
906 |
and continue with two subgoals using the lemma: |
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
907 |
|
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
908 |
@{term [display, indent=10] "(R1 ===> R2) f g \<longrightarrow> R1 x 1 \<longrightarrow> R2 (f x) (g y)"} |
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
909 |
|
2211
9d0673c319d1
qpaper / injection proof.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2210
diff
changeset
|
910 |
\end{itemize} |
2199
6ce64fb5cbd9
qpaper / lemmas used in proofs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2198
diff
changeset
|
911 |
|
2271
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
912 |
The cleaning subgoal has been defined in such a way that |
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
913 |
establishing the goal theorem now consists only on rewriting the |
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
914 |
injected theorem with the preservation theorems and quotient |
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
915 |
definitions. First for all lifted constants, their definitions |
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
916 |
are used to fold the @{term Rep} with the raw constant. Next for |
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
917 |
all lambda abstractions and quantifications the lambda and |
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
918 |
quantifier preservation theorems are used to replace the |
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
919 |
variables that include raw types with respects by quantification |
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
920 |
over variables that include quotient types. We show here only |
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
921 |
the lambda preservation theorem; assuming |
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
922 |
@{term "Quotient R1 Abs1 Rep1"} and @{term "Quotient R2 Abs2 Rep2"} |
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
923 |
we have: |
2211
9d0673c319d1
qpaper / injection proof.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2210
diff
changeset
|
924 |
|
2271
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
925 |
@{thm [display, indent=10] (concl) lambda_prs[no_vars]} |
2199
6ce64fb5cbd9
qpaper / lemmas used in proofs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2198
diff
changeset
|
926 |
|
2243 | 927 |
\noindent |
2271
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
928 |
holds. Next relations over lifted types are folded to equality. |
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
929 |
The following theorem has been shown in Homeier~\cite{Homeier05}: |
2211
9d0673c319d1
qpaper / injection proof.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2210
diff
changeset
|
930 |
|
2271
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
931 |
@{thm [display, indent=10] (concl) Quotient_rel_rep[no_vars]} |
2199
6ce64fb5cbd9
qpaper / lemmas used in proofs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2198
diff
changeset
|
932 |
|
2271
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
933 |
\noindent |
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
934 |
Finally the user given preservation theorems, that allow using |
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
935 |
higher level operations and containers of types being lifted. |
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
936 |
We show the preservation theorem for @{term map}. Again assuming |
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
937 |
that @{term "Quotient R1 Abs1 Rep1"} and @{term "Quotient R2 Abs2 Rep2"} |
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
938 |
we have: |
2212
79cebcc230d6
Qpaper / minor on cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2211
diff
changeset
|
939 |
|
2271
c0c5bc4ee8cb
qpaper/Rewrite section5
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2268
diff
changeset
|
940 |
@{thm [display, indent=10] (concl) map_prs(1)[of R1 Abs1 Rep1 R2 Abs2 Rep2,no_vars]} |
2212
79cebcc230d6
Qpaper / minor on cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2211
diff
changeset
|
941 |
|
2246 | 942 |
*} |
1994 | 943 |
|
944 |
section {* Examples *} |
|
945 |
||
2210
6aaec9dd0c62
qpaper / example interaction
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2209
diff
changeset
|
946 |
(* Mention why equivalence *) |
2206 | 947 |
|
2210
6aaec9dd0c62
qpaper / example interaction
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2209
diff
changeset
|
948 |
text {* |
6aaec9dd0c62
qpaper / example interaction
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2209
diff
changeset
|
949 |
|
2239 | 950 |
In this section we will show, a complete interaction with the quotient package |
2240
6c4b54482396
qpaper/more on example
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2239
diff
changeset
|
951 |
for defining the type of integers by quotienting pairs of natural numbers and |
6c4b54482396
qpaper/more on example
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2239
diff
changeset
|
952 |
lifting theorems to integers. Our quotient package is fully compatible with |
6c4b54482396
qpaper/more on example
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2239
diff
changeset
|
953 |
Isabelle type classes, but for clarity we will not use them in this example. |
6c4b54482396
qpaper/more on example
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2239
diff
changeset
|
954 |
In a larger formalization of integers using the type class mechanism would |
6c4b54482396
qpaper/more on example
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2239
diff
changeset
|
955 |
provide many algebraic properties ``for free''. |
2210
6aaec9dd0c62
qpaper / example interaction
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2209
diff
changeset
|
956 |
|
2240
6c4b54482396
qpaper/more on example
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2239
diff
changeset
|
957 |
A user of our quotient package first needs to define a relation on |
6c4b54482396
qpaper/more on example
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2239
diff
changeset
|
958 |
the raw type, by which the quotienting will be performed. We give |
6c4b54482396
qpaper/more on example
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2239
diff
changeset
|
959 |
the same integer relation as the one presented in the introduction: |
6c4b54482396
qpaper/more on example
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2239
diff
changeset
|
960 |
|
6c4b54482396
qpaper/more on example
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2239
diff
changeset
|
961 |
\begin{isabelle}\ \ \ \ \ \ \ \ \ \ % |
2241 | 962 |
\isacommand{fun}~~@{text "int_rel"}~~\isacommand{where}~~@{text "(m \<Colon> nat, n) int_rel (p, q) = (m + q = n + p)"} |
2239 | 963 |
\end{isabelle} |
2210
6aaec9dd0c62
qpaper / example interaction
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2209
diff
changeset
|
964 |
|
2239 | 965 |
\noindent |
966 |
Next the quotient type is defined. This leaves a proof obligation that the |
|
967 |
relation is an equivalence relation which is solved automatically using the |
|
968 |
definitions: |
|
2210
6aaec9dd0c62
qpaper / example interaction
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2209
diff
changeset
|
969 |
|
2240
6c4b54482396
qpaper/more on example
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2239
diff
changeset
|
970 |
\begin{isabelle}\ \ \ \ \ \ \ \ \ \ % |
2241 | 971 |
\isacommand{quotient\_type}~~@{text "int"}~~\isacommand{=}~~@{text "(nat \<times> nat)"}~~\isacommand{/}~~@{text "int_rel"} |
2239 | 972 |
\end{isabelle} |
2210
6aaec9dd0c62
qpaper / example interaction
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2209
diff
changeset
|
973 |
|
2239 | 974 |
\noindent |
2210
6aaec9dd0c62
qpaper / example interaction
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2209
diff
changeset
|
975 |
The user can then specify the constants on the quotient type: |
6aaec9dd0c62
qpaper / example interaction
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2209
diff
changeset
|
976 |
|
2240
6c4b54482396
qpaper/more on example
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2239
diff
changeset
|
977 |
\begin{isabelle}\ \ \ \ \ \ \ \ \ \ % |
6c4b54482396
qpaper/more on example
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2239
diff
changeset
|
978 |
\begin{tabular}{@ {}l} |
6c4b54482396
qpaper/more on example
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2239
diff
changeset
|
979 |
\isacommand{quotient\_definition}~~@{text "0 :: int"}~~\isacommand{is}~~@{text "(0::nat, 0::nat)"}\\ |
6c4b54482396
qpaper/more on example
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2239
diff
changeset
|
980 |
\isacommand{fun}~~@{text "plus_raw"}~~\isacommand{where}~~@{text "plus_raw (m :: nat, n) (p, q) = (m + p, n + q)"}\\ |
6c4b54482396
qpaper/more on example
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2239
diff
changeset
|
981 |
\isacommand{quotient\_definition}~~@{text "(op +) \<Colon> (int \<Rightarrow> int \<Rightarrow> int)"}~~\isacommand{is}~~@{text "plus_raw"}\\ |
6c4b54482396
qpaper/more on example
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2239
diff
changeset
|
982 |
\end{tabular} |
6c4b54482396
qpaper/more on example
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2239
diff
changeset
|
983 |
\end{isabelle} |
2210
6aaec9dd0c62
qpaper / example interaction
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2209
diff
changeset
|
984 |
|
2240
6c4b54482396
qpaper/more on example
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2239
diff
changeset
|
985 |
\noindent |
2210
6aaec9dd0c62
qpaper / example interaction
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2209
diff
changeset
|
986 |
Lets first take a simple theorem about addition on the raw level: |
6aaec9dd0c62
qpaper / example interaction
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2209
diff
changeset
|
987 |
|
2240
6c4b54482396
qpaper/more on example
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2239
diff
changeset
|
988 |
\begin{isabelle}\ \ \ \ \ \ \ \ \ \ % |
2241 | 989 |
\isacommand{lemma}~~@{text "plus_zero_raw: int_rel (plus_raw (0, 0) x) x"} |
2240
6c4b54482396
qpaper/more on example
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2239
diff
changeset
|
990 |
\end{isabelle} |
2210
6aaec9dd0c62
qpaper / example interaction
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2209
diff
changeset
|
991 |
|
2240
6c4b54482396
qpaper/more on example
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2239
diff
changeset
|
992 |
\noindent |
2210
6aaec9dd0c62
qpaper / example interaction
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2209
diff
changeset
|
993 |
When the user tries to lift a theorem about integer addition, the respectfulness |
6aaec9dd0c62
qpaper / example interaction
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2209
diff
changeset
|
994 |
proof obligation is left, so let us prove it first: |
6aaec9dd0c62
qpaper / example interaction
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2209
diff
changeset
|
995 |
|
2240
6c4b54482396
qpaper/more on example
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2239
diff
changeset
|
996 |
\begin{isabelle}\ \ \ \ \ \ \ \ \ \ % |
2241 | 997 |
\isacommand{lemma}~~@{text "[quot_respect]: (int_rel \<Longrightarrow> int_rel \<Longrightarrow> int_rel) plus_raw plus_raw"} |
2240
6c4b54482396
qpaper/more on example
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2239
diff
changeset
|
998 |
\end{isabelle} |
6c4b54482396
qpaper/more on example
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2239
diff
changeset
|
999 |
|
6c4b54482396
qpaper/more on example
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2239
diff
changeset
|
1000 |
\noindent |
2210
6aaec9dd0c62
qpaper / example interaction
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2209
diff
changeset
|
1001 |
Can be proved automatically by the system just by unfolding the definition |
2240
6c4b54482396
qpaper/more on example
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2239
diff
changeset
|
1002 |
of @{text "op \<Longrightarrow>"}. |
2230 | 1003 |
Now the user can either prove a lifted lemma explicitly: |
2210
6aaec9dd0c62
qpaper / example interaction
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2209
diff
changeset
|
1004 |
|
2240
6c4b54482396
qpaper/more on example
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2239
diff
changeset
|
1005 |
\begin{isabelle}\ \ \ \ \ \ \ \ \ \ % |
6c4b54482396
qpaper/more on example
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2239
diff
changeset
|
1006 |
\isacommand{lemma}~~@{text "0 + (x :: int) = x"}~~\isacommand{by}~~@{text "lifting plus_zero_raw"} |
6c4b54482396
qpaper/more on example
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2239
diff
changeset
|
1007 |
\end{isabelle} |
2210
6aaec9dd0c62
qpaper / example interaction
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2209
diff
changeset
|
1008 |
|
2240
6c4b54482396
qpaper/more on example
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2239
diff
changeset
|
1009 |
\noindent |
2210
6aaec9dd0c62
qpaper / example interaction
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2209
diff
changeset
|
1010 |
Or in this simple case use the automated translation mechanism: |
6aaec9dd0c62
qpaper / example interaction
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2209
diff
changeset
|
1011 |
|
2240
6c4b54482396
qpaper/more on example
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2239
diff
changeset
|
1012 |
\begin{isabelle}\ \ \ \ \ \ \ \ \ \ % |
6c4b54482396
qpaper/more on example
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2239
diff
changeset
|
1013 |
\isacommand{thm}~~@{text "plus_zero_raw[quot_lifted]"} |
6c4b54482396
qpaper/more on example
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2239
diff
changeset
|
1014 |
\end{isabelle} |
2210
6aaec9dd0c62
qpaper / example interaction
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2209
diff
changeset
|
1015 |
|
2240
6c4b54482396
qpaper/more on example
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2239
diff
changeset
|
1016 |
\noindent |
2210
6aaec9dd0c62
qpaper / example interaction
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2209
diff
changeset
|
1017 |
obtaining the same result. |
6aaec9dd0c62
qpaper / example interaction
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2209
diff
changeset
|
1018 |
*} |
2206 | 1019 |
|
2256
f5f21feaa168
some slight tuning of the preliminary section
Christian Urban <urbanc@in.tum.de>
parents:
2255
diff
changeset
|
1020 |
section {* Conclusion and Related Work\label{sec:conc}*} |
1978 | 1021 |
|
1022 |
text {* |
|
2243 | 1023 |
|
2267 | 1024 |
The code of the quotient package and the examples described here are |
1025 |
already included in the |
|
2254 | 1026 |
standard distribution of Isabelle.\footnote{Available from |
2237 | 1027 |
\href{http://isabelle.in.tum.de/}{http://isabelle.in.tum.de/}.} It is |
1028 |
heavily used in Nominal Isabelle, which provides a convenient reasoning |
|
1029 |
infrastructure for programming language calculi involving binders. Earlier |
|
1030 |
versions of Nominal Isabelle have been used successfully in formalisations |
|
1031 |
of an equivalence checking algorithm for LF \cite{UrbanCheneyBerghofer08}, |
|
1032 |
Typed Scheme~\cite{TobinHochstadtFelleisen08}, several calculi for |
|
1033 |
concurrency \cite{BengtsonParow09} and a strong normalisation result for |
|
1034 |
cut-elimination in classical logic \cite{UrbanZhu08}. |
|
1035 |
||
2267 | 1036 |
Oscar Slotosch~\cite{Slotosch97} implemented a mechanism that automatically |
1037 |
defines quotient types for Isabelle/HOL. It did not include theorem lifting. |
|
1038 |
John Harrison's quotient package~\cite{harrison-thesis} is the first one to |
|
1039 |
lift theorems, however only first order. There is work on quotient types in |
|
1040 |
non-HOL based systems and logical frameworks, namely theory interpretations |
|
1041 |
in PVS~\cite{PVS:Interpretations}, new types in MetaPRL~\cite{Nogin02}, or |
|
1042 |
the use of setoids in Coq, with some higher order issues~\cite{ChicliPS02}. |
|
1043 |
Larry Paulson shows a construction of quotients that does not require the |
|
1044 |
Hilbert Choice operator, again only first order~\cite{Paulson06}. |
|
1045 |
The closest to our package is the package for HOL4 by Peter Homeier~\cite{Homeier05}, |
|
1046 |
which is the first one to support lifting of higher order theorems. |
|
2224
f5b6f9d8a882
completed the intro (except minor things)
Christian Urban <urbanc@in.tum.de>
parents:
2223
diff
changeset
|
1047 |
|
f5b6f9d8a882
completed the intro (except minor things)
Christian Urban <urbanc@in.tum.de>
parents:
2223
diff
changeset
|
1048 |
|
2267 | 1049 |
Our quotient package for the first time explore the notion of |
1050 |
composition of quotients, which allows lifting constants like @{term |
|
1051 |
"concat"} and theorems about it. We defined the composition of |
|
1052 |
relations and showed examples of compositions of quotients which |
|
1053 |
allows lifting polymorphic types with subtypes quotiented as well. |
|
1054 |
We extended the notions of respectfullness and preservation; |
|
1055 |
with quotient compositions there is more than one condition needed |
|
1056 |
for a constant. |
|
2224
f5b6f9d8a882
completed the intro (except minor things)
Christian Urban <urbanc@in.tum.de>
parents:
2223
diff
changeset
|
1057 |
|
2267 | 1058 |
Our package is modularized, so that single definitions, single |
1059 |
theorems or single respectfullness conditions etc can be added, |
|
1060 |
which allows the use of the quotient package together with |
|
1061 |
type-classes and locales. This has the advantage over packages |
|
1062 |
requiring big lists as input for the user of being able to develop |
|
1063 |
a theory progressively. |
|
2224
f5b6f9d8a882
completed the intro (except minor things)
Christian Urban <urbanc@in.tum.de>
parents:
2223
diff
changeset
|
1064 |
|
2267 | 1065 |
We allow lifting only some occurrences of quotiented types, which |
1066 |
is useful in Nominal. The package can be used automatically with |
|
1067 |
an attribute, manually with separate tactics for parts of the lifting |
|
1068 |
procedure, and programatically. Automated definitions of constants |
|
1069 |
and respectfulness proof obligations are used in Nominal. Finally |
|
1070 |
we streamlined and showed the detailed lifting procedure, which |
|
1071 |
has not been presented before. |
|
2263 | 1072 |
|
1073 |
\medskip |
|
1074 |
\noindent |
|
1075 |
{\bf Acknowledgements:} We would like to thank Peter Homeier for the |
|
1076 |
discussions about the HOL4 quotient package and explaining us its |
|
1077 |
implementation details. |
|
1078 |
||
2224
f5b6f9d8a882
completed the intro (except minor things)
Christian Urban <urbanc@in.tum.de>
parents:
2223
diff
changeset
|
1079 |
*} |
f5b6f9d8a882
completed the intro (except minor things)
Christian Urban <urbanc@in.tum.de>
parents:
2223
diff
changeset
|
1080 |
|
f5b6f9d8a882
completed the intro (except minor things)
Christian Urban <urbanc@in.tum.de>
parents:
2223
diff
changeset
|
1081 |
|
2227 | 1082 |
|
1975
b1281a0051ae
added stub for quotient paper; call with isabelle make qpaper
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1083 |
(*<*) |
b1281a0051ae
added stub for quotient paper; call with isabelle make qpaper
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1084 |
end |
1978 | 1085 |
(*>*) |