
diff -r 2d6cada7d5e0 -r ea7c3f21d6df Quotient-Paper/Paper.thy
--- a/Quotient-Paper/Paper.thy	Wed Jun 02 13:58:37 2010 +0200
+++ b/Quotient-Paper/Paper.thy	Wed Jun 02 14:24:16 2010 +0200
@@ -235,46 +235,44 @@
 
   A respectfulness lemma for a constant states that the equivalence
   class returned by this constant depends only on the equivalence
-  classes of the arguments applied to the constant. This can be
-  expressed in terms of an aggregate relation between the constant
-  and itself, for example the respectfullness for @{term "append"}
+  classes of the arguments applied to the constant. To automatically
+  lift a theorem that talks about a raw constant, to a theorem about
+  the quotient type a respectfulness theorem is required.
+
+  A respectfulness condition for a constant can be expressed in
+  terms of an aggregate relation between the constant and itself,
+  for example the respectfullness for @{term "append"}
   can be stated as:
 
   @{thm [display] append_rsp[no_vars]}
 
   \noindent
-  Which is equivalent to:
+  Which after unfolding @{term "op ===>"} is equivalent to:
 
   @{thm [display] append_rsp_unfolded[no_vars]}
 
-  Below we show the algorithm for finding the aggregate relation.
-  This algorithm uses
-  the relation composition which we define as:
+  An aggregate relation is defined in terms of relation composition,
+  so we define it first:
 
   \begin{definition}[Composition of Relations]
   @{abbrev "rel_conj R1 R2"} where @{text OO} is the predicate
   composition @{thm pred_compI[no_vars]}
   \end{definition}
 
-  Given an aggregate raw type and quotient type:
+  The aggregate relation for an aggregate raw type and quotient type
+  is defined as:
 
   \begin{itemize}
-  \item For equal types or free type variables return equality
-
-  \item For equal type constructors use the appropriate rel
-    function applied to the results for the argument pairs
-
-  \item For unequal type constructors, look in the quotients information
-    for a quotient type that matches the type constructor, and instantiate
-    the type appropriately getting back an instantiation environment. We
-    apply the environment to the arguments and recurse composing it with
-    the aggregate relation function.
+  \item @{text "REL(\<alpha>\<^isub>1, \<alpha>\<^isub>2)"} = @{text "op ="}
+  \item @{text "REL(\<sigma>, \<sigma>)"}  =  @{text "op ="}
+  \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))"}
+  \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"}
 
   \end{itemize}
 
-  Again, the the behaviour of our algorithm in the last situation is
-  novel, so lets look at the example of respectfullness for @{term concat}.
-  The statement as computed by the algorithm above is:
+  Again, the last case is novel, so lets look at the example of
+  respectfullness for @{term concat}. The statement according to
+  the definition above is:
 
   @{thm [display] concat_rsp[no_vars]}
 
@@ -321,19 +319,20 @@
   Given two quotients, one of which quotients a container, and the
   other quotients the type in the container, we can write the
   composition of those quotients. To compose two quotient theorems
-  we compose the relations with relation composition
-  and the abstraction and relation functions with function composition.
-  The @{term "Rep"} and @{term "Abs"} functions that we obtain are
-  the same as the ones created by in the aggregate functions and the
+  we compose the relations with relation composition as defined above
+  and the abstraction and relation functions are the ones of the sub
+  quotients composed with the usual function composition.
+  The @{term "Rep"} and @{term "Abs"} functions that we obtain agree
+  with the definition of aggregate Abs/Rep functions and the
   relation is the same as the one given by aggregate relations.
   This becomes especially interesting
   when we compose the quotient with itself, as there is no simple
   intermediate step.
 
   Lets take again the example of @{term concat}. To be able to lift
-  theorems that talk about it we will first prove the composition
-  quotient theorems, which then lets us perform the lifting procedure
-  in an unchanged way:
+  theorems that talk about it we provide the composition quotient
+  theorems, which then lets us perform the lifting procedure in an
+  unchanged way:
 
   @{thm [display] quotient_compose_list[no_vars]}
 *}
@@ -345,7 +344,7 @@
   The core of the quotient package takes an original theorem that
   talks about the raw types, and the statement of the theorem that
   it is supposed to produce. This is different from other existing
-  quotient packages, where only the raw theorems was necessary.
+  quotient packages, where only the raw theorems were necessary.
   We notice that in some cases only some occurrences of the raw
   types need to be lifted. This is for example the case in the
   new Nominal package, where a raw datatype that talks about
@@ -364,7 +363,7 @@
   We first define the statement of the regularized theorem based
   on the original theorem and the goal theorem. Then we define
   the statement of the injected theorem, based on the regularized
-  theorem and the goal. We then show the 3 proofs, and all three
+  theorem and the goal. We then show the 3 proofs as all three
   can be performed independently from each other.
 
 *}
@@ -373,12 +372,13 @@
 
 text {*
 
-  The function that gives the statement of the regularized theorem
-  takes the statement of the raw theorem (a term) and the statement
-  of the lifted theorem. The intuition behind the procedure is that
-  it replaces quantifiers and abstractions involving raw types
-  by bounded ones, and equalities involving raw types are replaced
-  by appropriate aggregate relations. It is defined as follows:
+  We first define the function @{text REG}, which takes the statements
+  of the raw theorem and the lifted theorem (both as terms) and
+  returns the statement of the regularized version. The intuition
+  behind this function is that it replaces quantifiers and
+  abstractions involving raw types by bounded ones, and equalities
+  involving raw types are replaced by appropriate aggregate
+  relations. It is defined as follows:
 
   \begin{itemize}
   \item @{text "REG (\<lambda>x : \<sigma>. t, \<lambda>x : \<sigma>. s) = \<lambda>x : \<sigma>. REG (t, s)"}
@@ -392,12 +392,13 @@
   \item @{text "REG (c\<^isub>1, c\<^isub>2) = c\<^isub>1"}
   \end{itemize}
 
-  Existential quantifiers and unique existential quantifiers are defined
-  similarily to the universal one.
+  In the above definition we ommited the cases for existential quantifiers
+  and unique existential quantifiers, as they are very similar to the cases
+  for the universal quantifier.
 
-  The function that gives the statment of the injected theorem
-  takes the statement of the regularized theorems and the statement
-  of the lifted theorem both as terms.
+  Next we define the function @{text INJ} which takes the statement of
+  the regularized theorems and the statement of the lifted theorem both as
+  terms and returns the statment of the injected theorem:
 
   \begin{itemize}
   \item @{text "INJ ((\<lambda>x. t) : \<sigma>, (\<lambda>x. s) : \<sigma>) = \<lambda>x. (INJ (t, s)"}




