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