Quotient-Paper-jv/Paper.thy
author Christian Urban <urbanc@in.tum.de>
Wed, 21 Mar 2012 20:34:04 +0000
changeset 3136 d003938cc952
parent 3125 860df8e1262f
child 3137 de3a89363143
permissions -rw-r--r--
slight tuning of Q-paper-jv
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3082
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     1
(*<*)
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     2
theory Paper
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     3
imports "Quotient"
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     4
        "~~/src/HOL/Library/Quotient_Syntax"
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     5
        "~~/src/HOL/Library/LaTeXsugar"
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     6
        "~~/src/HOL/Quotient_Examples/FSet"
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     7
begin
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     8
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     9
notation (latex output)
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    10
  rel_conj ("_ \<circ>\<circ>\<circ> _" [53, 53] 52) and
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    11
  pred_comp ("_ \<circ>\<circ> _" [1, 1] 30) and
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    12
  implies (infix "\<longrightarrow>" 100) and
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    13
  "==>" (infix "\<Longrightarrow>" 100) and
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    14
  map_fun ("_ \<singlearr> _" 51) and
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    15
  fun_rel ("_ \<doublearr> _" 51) and
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    16
  list_eq (infix "\<approx>" 50) and (* Not sure if we want this notation...? *)
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    17
  empty_fset ("\<emptyset>") and
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    18
  union_fset ("_ \<union> _") and
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    19
  insert_fset ("{_} \<union> _") and
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    20
  Cons ("_::_") and
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    21
  concat ("flat") and
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    22
  concat_fset ("\<Union>") and
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    23
  Quotient ("Quot _ _ _")
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    24
3118
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3115
diff changeset
    25
declare [[show_question_marks = false]]
3082
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    26
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    27
ML {*
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    28
fun nth_conj n (_, r) = nth (HOLogic.dest_conj r) n;
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    29
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    30
fun style_lhs_rhs proj = Scan.succeed (fn ctxt => fn t =>
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    31
  let
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    32
    val concl =
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    33
      Object_Logic.drop_judgment (Proof_Context.theory_of ctxt) (Logic.strip_imp_concl t)
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    34
  in
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    35
    case concl of (_ $ l $ r) => proj (l, r)
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    36
    | _ => error ("Binary operator expected in term: " ^ Syntax.string_of_term ctxt concl)
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    37
  end);
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    38
*}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    39
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    40
setup {*
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    41
  Term_Style.setup "rhs1" (style_lhs_rhs (nth_conj 0)) #>
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    42
  Term_Style.setup "rhs2" (style_lhs_rhs (nth_conj 1)) #>
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    43
  Term_Style.setup "rhs3" (style_lhs_rhs (nth_conj 2))
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    44
*}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    45
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    46
(*>*)
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    47
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    48
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    49
section {* Introduction *}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    50
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    51
text {*
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    52
  \noindent
3136
d003938cc952 slight tuning of Q-paper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3125
diff changeset
    53
  One might think quotients have been studied to death, but in the
d003938cc952 slight tuning of Q-paper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3125
diff changeset
    54
  context of theorem provers a number questions concerning them are
d003938cc952 slight tuning of Q-paper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3125
diff changeset
    55
  far from settled. In this paper we address the question of how to
d003938cc952 slight tuning of Q-paper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3125
diff changeset
    56
  establish a convenient reasoning infrastructure for quotient
d003938cc952 slight tuning of Q-paper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3125
diff changeset
    57
  constructions in the Isabelle/HOL theorem prover. Higher-Order Logic
d003938cc952 slight tuning of Q-paper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3125
diff changeset
    58
  (HOL) consists of a small number of axioms and inference rules over
d003938cc952 slight tuning of Q-paper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3125
diff changeset
    59
  a simply-typed term-language. Safe reasoning in HOL is ensured by
d003938cc952 slight tuning of Q-paper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3125
diff changeset
    60
  two very restricted mechanisms for extending the logic: one is the
d003938cc952 slight tuning of Q-paper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3125
diff changeset
    61
  definition of new constants in terms of existing ones; the other is
d003938cc952 slight tuning of Q-paper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3125
diff changeset
    62
  the introduction of new types by identifying non-empty subsets in
d003938cc952 slight tuning of Q-paper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3125
diff changeset
    63
  existing types. Previous work has shown how to use both mechanisms
d003938cc952 slight tuning of Q-paper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3125
diff changeset
    64
  for dealing with quotient constructions in HOL (see
d003938cc952 slight tuning of Q-paper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3125
diff changeset
    65
  \cite{Homeier05,Paulson06}).  For example the integers in
d003938cc952 slight tuning of Q-paper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3125
diff changeset
    66
  Isabelle/HOL are constructed by a quotient construction over the
d003938cc952 slight tuning of Q-paper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3125
diff changeset
    67
  type @{typ "nat \<times> nat"} and the equivalence relation
3082
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    68
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    69
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    70
  \begin{isabelle}\ \ \ \ \ %%%
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    71
  @{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}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    72
  \end{isabelle}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    73
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    74
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    75
  This constructions yields the new type @{typ int}, and definitions for @{text
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    76
  "0"} and @{text "1"} of type @{typ int} can be given in terms of pairs of
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    77
  natural numbers (namely @{text "(0, 0)"} and @{text "(1, 0)"}). Operations
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    78
  such as @{text "add"} with type @{typ "int \<Rightarrow> int \<Rightarrow> int"} can be defined in
3094
8bad9887ad90 moved TODO into the paper
Christian Urban <urbanc@in.tum.de>
parents: 3092
diff changeset
    79
  terms of operations on pairs of natural numbers:
8bad9887ad90 moved TODO into the paper
Christian Urban <urbanc@in.tum.de>
parents: 3092
diff changeset
    80
8bad9887ad90 moved TODO into the paper
Christian Urban <urbanc@in.tum.de>
parents: 3092
diff changeset
    81
  \begin{isabelle}\ \ \ \ \ %%%
8bad9887ad90 moved TODO into the paper
Christian Urban <urbanc@in.tum.de>
parents: 3092
diff changeset
    82
  @{text "add_pair (n\<^isub>1, m\<^isub>1) (n\<^isub>2, m\<^isub>2) \<equiv> (n\<^isub>1 + n\<^isub>2, m\<^isub>1 + m\<^isub>2)"}
8bad9887ad90 moved TODO into the paper
Christian Urban <urbanc@in.tum.de>
parents: 3092
diff changeset
    83
  \end{isabelle}
8bad9887ad90 moved TODO into the paper
Christian Urban <urbanc@in.tum.de>
parents: 3092
diff changeset
    84
8bad9887ad90 moved TODO into the paper
Christian Urban <urbanc@in.tum.de>
parents: 3092
diff changeset
    85
  \noindent
3136
d003938cc952 slight tuning of Q-paper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3125
diff changeset
    86
  Similarly one can construct the type of finite sets, written @{term
d003938cc952 slight tuning of Q-paper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3125
diff changeset
    87
  "\<alpha> fset"}, by quotienting the type @{text "\<alpha> list"} according to the
d003938cc952 slight tuning of Q-paper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3125
diff changeset
    88
  equivalence relation
3082
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    89
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    90
  \begin{isabelle}\ \ \ \ \ %%%
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    91
  @{text "xs \<approx> ys \<equiv> (\<forall>x. memb x xs \<longleftrightarrow> memb x ys)"}\hfill\numbered{listequiv}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    92
  \end{isabelle}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    93
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    94
  \noindent
3136
d003938cc952 slight tuning of Q-paper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3125
diff changeset
    95
  which states that two lists are equivalent if every element in one
d003938cc952 slight tuning of Q-paper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3125
diff changeset
    96
  list is also member in the other, and vice versa. The empty finite
d003938cc952 slight tuning of Q-paper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3125
diff changeset
    97
  set, written @{term "{||}"}, can then be defined as the empty list
d003938cc952 slight tuning of Q-paper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3125
diff changeset
    98
  and the union of two finite sets, written @{text "\<union>"}, as list
d003938cc952 slight tuning of Q-paper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3125
diff changeset
    99
  append.
3082
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   100
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   101
  Quotients are important in a variety of areas, but they are really ubiquitous in
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   102
  the area of reasoning about programming language calculi. A simple example
3136
d003938cc952 slight tuning of Q-paper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3125
diff changeset
   103
  is the lambda-calculus, whose raw, or un-quotient, terms are defined as
3082
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   104
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   105
  \begin{isabelle}\ \ \ \ \ %%%
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   106
  @{text "t ::= x | t t | \<lambda>x.t"}%\hfill\numbered{lambda}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   107
  \end{isabelle}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   108
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   109
  \noindent
3136
d003938cc952 slight tuning of Q-paper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3125
diff changeset
   110
  The problem with this definition arises from the need to reason
d003938cc952 slight tuning of Q-paper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3125
diff changeset
   111
  modulo $\alpha$-equivalence, for instance, when one attempts to
d003938cc952 slight tuning of Q-paper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3125
diff changeset
   112
  prove formally the substitution lemma \cite{Barendregt81} by
d003938cc952 slight tuning of Q-paper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3125
diff changeset
   113
  induction over the structure of terms. This can be fiendishly
d003938cc952 slight tuning of Q-paper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3125
diff changeset
   114
  complicated (see \cite[Pages 94--104]{CurryFeys58} for some
d003938cc952 slight tuning of Q-paper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3125
diff changeset
   115
  ``rough'' sketches of a proof about raw lambda-terms). In contrast,
d003938cc952 slight tuning of Q-paper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3125
diff changeset
   116
  if we reason about $\alpha$-equated lambda-terms, that means terms
d003938cc952 slight tuning of Q-paper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3125
diff changeset
   117
  quotient according to $\alpha$-equivalence, then the reasoning
d003938cc952 slight tuning of Q-paper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3125
diff changeset
   118
  infrastructure provided, for example, by Nominal Isabelle
d003938cc952 slight tuning of Q-paper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3125
diff changeset
   119
  \cite{UrbanKaliszyk11} makes the formal proof of the substitution
d003938cc952 slight tuning of Q-paper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3125
diff changeset
   120
  lemma almost trivial. The fundamental reason is that in case of
d003938cc952 slight tuning of Q-paper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3125
diff changeset
   121
  $\alpha$-equated terms, equality coincides with $\alpha$-equivalence and
d003938cc952 slight tuning of Q-paper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3125
diff changeset
   122
  we can use for reasoning HOL's built-in notion of ``replacing equals by equals''.
3082
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   123
3092
ff377f9d030a some slight tuning
Christian Urban <urbanc@in.tum.de>
parents: 3082
diff changeset
   124
  {\bf MAYBE AN EAMPLE FOR PARTIAL QUOTIENTS?}
ff377f9d030a some slight tuning
Christian Urban <urbanc@in.tum.de>
parents: 3082
diff changeset
   125
ff377f9d030a some slight tuning
Christian Urban <urbanc@in.tum.de>
parents: 3082
diff changeset
   126
3082
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   127
  The difficulty is that in order to be able to reason about integers, finite
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   128
  sets or $\alpha$-equated lambda-terms one needs to establish a reasoning
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   129
  infrastructure by transferring, or \emph{lifting}, definitions and theorems
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   130
  from the raw type @{typ "nat \<times> nat"} to the quotient type @{typ int}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   131
  (similarly for finite sets and $\alpha$-equated lambda-terms). This lifting
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   132
  usually requires a \emph{lot} of tedious reasoning effort \cite{Paulson06}.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   133
  In principle it is feasible to do this work manually, if one has only a few quotient
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   134
  constructions at hand. But if they have to be done over and over again, as in
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   135
  Nominal Isabelle, then manual reasoning is not an option.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   136
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   137
  The purpose of a \emph{quotient package} is to ease the lifting of theorems
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   138
  and automate the reasoning as much as possible. In the
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   139
  context of HOL, there have been a few quotient packages already
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   140
  \cite{harrison-thesis,Slotosch97}. The most notable one is by Homeier
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   141
  \cite{Homeier05} implemented in HOL4.  The fundamental construction these
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   142
  quotient packages perform can be illustrated by the following picture:
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   143
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   144
%%% FIXME: Referee 1 says:
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   145
%%% Diagram is unclear.  Firstly, isn't an existing type a "set (not sets) of raw elements"?
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   146
%%% Secondly, isn't the _set of_ equivalence classes mapped to and from the new type?
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   147
%%% Thirdly, what do the words "non-empty subset" refer to ?
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   148
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   149
%%% Cezary: I like the diagram, maybe 'new type' could be outside, but otherwise
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   150
%%% I wouldn't change it.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   151
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   152
  \begin{center}
3125
860df8e1262f slight polish of the qpaper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3119
diff changeset
   153
  \mbox{}\hspace{20mm}\begin{tikzpicture}[scale=1.1]
3082
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   154
  %%\draw[step=2mm] (-4,-1) grid (4,1);
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   155
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   156
  \draw[very thick] (0.7,0.3) circle (4.85mm);
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   157
  \draw[rounded corners=1mm, very thick] ( 0.0,-0.9) rectangle ( 1.8, 0.9);
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   158
  \draw[rounded corners=1mm, very thick] (-1.95,0.8) rectangle (-2.9,-0.195);
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   159
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   160
  \draw (-2.0, 0.8) --  (0.7,0.8);
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   161
  \draw (-2.0,-0.195)  -- (0.7,-0.195);
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   162
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   163
  \draw ( 0.7, 0.23) node {\begin{tabular}{@ {}c@ {}}equiv-\\[-1mm]clas.\end{tabular}};
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   164
  \draw (-2.45, 0.35) node {\begin{tabular}{@ {}c@ {}}new\\[-1mm]type\end{tabular}};
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   165
  \draw (1.8, 0.35) node[right=-0.1mm]
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   166
    {\begin{tabular}{@ {}l@ {}}existing\\[-1mm] type\\ (sets of raw elements)\end{tabular}};
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   167
  \draw (0.9, -0.55) node {\begin{tabular}{@ {}l@ {}}non-empty\\[-1mm]subset\end{tabular}};
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   168
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   169
  \draw[->, very thick] (-1.8, 0.36) -- (-0.1,0.36);
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   170
  \draw[<-, very thick] (-1.8, 0.16) -- (-0.1,0.16);
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   171
  \draw (-0.95, 0.26) node[above=0.4mm] {@{text Rep}};
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   172
  \draw (-0.95, 0.26) node[below=0.4mm] {@{text Abs}};
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   173
  \end{tikzpicture}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   174
  \end{center}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   175
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   176
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   177
  The starting point is an existing type, to which we refer as the
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   178
  \emph{raw type} and over which an equivalence relation is given by the user.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   179
  With this input the package introduces a new type, to which we
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   180
  refer as the \emph{quotient type}. This type comes with an
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   181
  \emph{abstraction} and a \emph{representation} function, written @{text Abs}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   182
  and @{text Rep}.\footnote{Actually slightly more basic functions are given;
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   183
  the functions @{text Abs} and @{text Rep} need to be derived from them. We
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   184
  will show the details later. } They relate elements in the
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   185
  existing type to elements in the new type, % and vice versa,
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   186
  and can be uniquely
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   187
  identified by their quotient type. For example for the integer quotient construction
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   188
  the types of @{text Abs} and @{text Rep} are
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   189
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   190
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   191
  \begin{isabelle}\ \ \ \ \ %%%
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   192
  @{text "Abs :: nat \<times> nat \<Rightarrow> int"}\hspace{10mm}@{text "Rep :: int \<Rightarrow> nat \<times> nat"}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   193
  \end{isabelle}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   194
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   195
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   196
  We therefore often write @{text Abs_int} and @{text Rep_int} if the
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   197
  typing information is important.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   198
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   199
  Every abstraction and representation function stands for an isomorphism
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   200
  between the non-empty subset and elements in the new type. They are
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   201
  necessary for making definitions involving the new type. For example @{text
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   202
  "0"} and @{text "1"} of type @{typ int} can be defined as
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   203
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   204
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   205
  \begin{isabelle}\ \ \ \ \ %%%
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   206
  @{text "0 \<equiv> Abs_int (0, 0)"}\hspace{10mm}@{text "1 \<equiv> Abs_int (1, 0)"}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   207
  \end{isabelle}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   208
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   209
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   210
  Slightly more complicated is the definition of @{text "add"} having type
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   211
  @{typ "int \<Rightarrow> int \<Rightarrow> int"}. Its definition is as follows
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   212
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   213
  \begin{isabelle}\ \ \ \ \ %%%
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   214
  @{text "add n m \<equiv> Abs_int (add_pair (Rep_int n) (Rep_int m))"}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   215
  \hfill\numbered{adddef}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   216
  \end{isabelle}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   217
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   218
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   219
  where we take the representation of the arguments @{text n} and @{text m},
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   220
  add them according to the function @{text "add_pair"} and then take the
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   221
  abstraction of the result.  This is all straightforward and the existing
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   222
  quotient packages can deal with such definitions. But what is surprising is
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   223
  that none of them can deal with slightly more complicated definitions involving
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   224
  \emph{compositions} of quotients. Such compositions are needed for example
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   225
  in case of quotienting lists to yield finite sets and the operator that
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   226
  flattens lists of lists, defined as follows
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   227
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   228
  \begin{isabelle}\ \ \ \ \ %%%
3125
860df8e1262f slight polish of the qpaper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3119
diff changeset
   229
  \begin{tabular}{@ {}l}
860df8e1262f slight polish of the qpaper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3119
diff changeset
   230
  @{thm concat.simps(1)[THEN eq_reflection]}\\
860df8e1262f slight polish of the qpaper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3119
diff changeset
   231
  @{thm concat.simps(2)[THEN eq_reflection, where x1="x" and xs1="xs"]}
860df8e1262f slight polish of the qpaper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3119
diff changeset
   232
  \end{tabular}
3082
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   233
  \end{isabelle}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   234
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   235
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   236
  where @{text "@"} is the usual
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   237
  list append. We expect that the corresponding
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   238
  operator on finite sets, written @{term "fconcat"},
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   239
  builds finite unions of finite sets:
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   240
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   241
  \begin{isabelle}\ \ \ \ \ %%%
3125
860df8e1262f slight polish of the qpaper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3119
diff changeset
   242
  \begin{tabular}{@ {}l}
860df8e1262f slight polish of the qpaper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3119
diff changeset
   243
  @{thm concat_empty_fset[THEN eq_reflection]}\\
860df8e1262f slight polish of the qpaper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3119
diff changeset
   244
  @{thm concat_insert_fset[THEN eq_reflection, where x1="x" and S1="S"]}
860df8e1262f slight polish of the qpaper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3119
diff changeset
   245
  \end{tabular}
3082
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   246
  \end{isabelle}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   247
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   248
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   249
  The quotient package should automatically provide us with a definition for @{text "\<Union>"} in
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   250
  terms of @{text flat}, @{text Rep_fset} and @{text Abs_fset}. The problem is
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   251
  that the method  used in the existing quotient
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   252
  packages of just taking the representation of the arguments and then taking
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   253
  the abstraction of the result is \emph{not} enough. The reason is that in case
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   254
  of @{text "\<Union>"} we obtain the incorrect definition
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   255
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   256
  \begin{isabelle}\ \ \ \ \ %%%
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   257
  @{text "\<Union> S \<equiv> Abs_fset (flat (Rep_fset S))"}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   258
  \end{isabelle}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   259
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   260
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   261
  where the right-hand side is not even typable! This problem can be remedied in the
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   262
  existing quotient packages by introducing an intermediate step and reasoning
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   263
  about flattening of lists of finite sets. However, this remedy is rather
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   264
  cumbersome and inelegant in light of our work, which can deal with such
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   265
  definitions directly. The solution is that we need to build aggregate
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   266
  representation and abstraction functions, which in case of @{text "\<Union>"}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   267
  generate the %%%following
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   268
  definition
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   269
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   270
  \begin{isabelle}\ \ \ \ \ %%%
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   271
  @{text "\<Union> S \<equiv> Abs_fset (flat ((map_list Rep_fset \<circ> Rep_fset) S))"}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   272
  \end{isabelle}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   273
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   274
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   275
  where @{term map_list} is the usual mapping function for lists. In this paper we
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   276
  will present a formal definition of our aggregate abstraction and
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   277
  representation functions (this definition was omitted in \cite{Homeier05}).
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   278
  They generate definitions, like the one above for @{text "\<Union>"},
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   279
  according to the type of the raw constant and the type
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   280
  of the quotient constant. This means we also have to extend the notions
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   281
  of \emph{aggregate equivalence relation}, \emph{respectfulness} and \emph{preservation}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   282
  from Homeier \cite{Homeier05}.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   283
3118
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3115
diff changeset
   284
  {\bf EXAMPLE BY HUFFMAN @{thm map_concat_fset}}
3094
8bad9887ad90 moved TODO into the paper
Christian Urban <urbanc@in.tum.de>
parents: 3092
diff changeset
   285
3082
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   286
  In addition we are able to clearly specify what is involved
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   287
  in the lifting process (this was only hinted at in \cite{Homeier05} and
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   288
  implemented as a ``rough recipe'' in ML-code). A pleasing side-result
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   289
  is that our procedure for lifting theorems is completely deterministic
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   290
  following the structure of the theorem being lifted and the theorem
3094
8bad9887ad90 moved TODO into the paper
Christian Urban <urbanc@in.tum.de>
parents: 3092
diff changeset
   291
  on the quotient level. {\it Space constraints, unfortunately, allow us to only
3082
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   292
  sketch this part of our work in Section 5 and we defer the reader to a longer
3094
8bad9887ad90 moved TODO into the paper
Christian Urban <urbanc@in.tum.de>
parents: 3092
diff changeset
   293
  version for the details.} However, we will give in Section 3 and 4 all
3082
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   294
  definitions that specify the input and output data of our three-step
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   295
  lifting procedure. Appendix A gives an example how our quotient
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   296
  package works in practise.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   297
*}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   298
3092
ff377f9d030a some slight tuning
Christian Urban <urbanc@in.tum.de>
parents: 3082
diff changeset
   299
section {* Preliminaries and General Quotients\label{sec:prelims} *}
3082
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   300
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   301
text {*
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   302
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   303
  We will give in this section a crude overview of HOL and describe the main
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   304
  definitions given by Homeier for quotients \cite{Homeier05}.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   305
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   306
  At its core, HOL is based on a simply-typed term language, where types are
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   307
  recorded in Church-style fashion (that means, we can always infer the type of
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   308
  a term and its subterms without any additional information). The grammars
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   309
  for types and terms are
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   310
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   311
  \begin{isabelle}\ \ \ \ \ %%%
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   312
  \begin{tabular}{@ {}c@ {\hspace{10mm}}c@ {}}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   313
  @{text "\<sigma>, \<tau> ::= \<alpha> | (\<sigma>,\<dots>, \<sigma>) \<kappa>"} &
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   314
  @{text "t, s ::= x\<^isup>\<sigma> | c\<^isup>\<sigma> | t t | \<lambda>x\<^isup>\<sigma>. t"}\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   315
  \end{tabular}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   316
  \end{isabelle}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   317
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   318
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   319
  with types being either type variables or type constructors and terms
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   320
  being variables, constants, applications or abstractions.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   321
  We often write just @{text \<kappa>} for @{text "() \<kappa>"}, and use @{text "\<alpha>s"} and
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   322
  @{text "\<sigma>s"} to stand for collections of type variables and types,
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   323
  respectively.  The type of a term is often made explicit by writing @{text
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   324
  "t :: \<sigma>"}. HOL includes a type @{typ bool} for booleans and the function
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   325
  type, written @{text "\<sigma> \<Rightarrow> \<tau>"}. HOL also contains many primitive and defined
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   326
  constants; for example, a primitive constant is equality, with type @{text "= :: \<sigma> \<Rightarrow> \<sigma> \<Rightarrow>
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   327
  bool"}, and the identity function with type @{text "id :: \<sigma> \<Rightarrow> \<sigma>"} is
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   328
  defined as @{text "\<lambda>x\<^sup>\<sigma>. x\<^sup>\<sigma>"}.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   329
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   330
  An important point to note is that theorems in HOL can be seen as a subset
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   331
  of terms that are constructed specially (namely through axioms and proof
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   332
  rules). As a result we are able to define automatic proof
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   333
  procedures showing that one theorem implies another by decomposing the term
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   334
  underlying the first theorem.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   335
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   336
  Like Homeier's, our work relies on map-functions defined for every type
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   337
  constructor taking some arguments, for example @{text map_list} for lists. Homeier
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   338
  describes in \cite{Homeier05} map-functions for products, sums, options and
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   339
  also the following map for function types
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   340
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   341
  \begin{isabelle}\ \ \ \ \ %%%
3118
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3115
diff changeset
   342
  @{thm map_fun_def[THEN eq_reflection]}
3082
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   343
  \end{isabelle}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   344
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   345
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   346
  Using this map-function, we can give the following, equivalent, but more
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   347
  uniform definition for @{text add} shown in \eqref{adddef}:
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   348
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   349
  \begin{isabelle}\ \ \ \ \ %%%
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   350
  @{text "add \<equiv> (Rep_int \<singlearr> Rep_int \<singlearr> Abs_int) add_pair"}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   351
  \end{isabelle}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   352
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   353
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   354
  Using extensionality and unfolding the definition of @{text "\<singlearr>"},
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   355
  we can get back to \eqref{adddef}.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   356
  In what follows we shall use the convention to write @{text "map_\<kappa>"} for a map-function
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   357
  of the type-constructor @{text \<kappa>}.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   358
  %% a general type for map all types is difficult to give (algebraic types are
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   359
  %% easy, but for example the function type is not algebraic
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   360
  %For a type @{text \<kappa>} with arguments @{text "\<alpha>\<^isub>1\<^isub>\<dots>\<^isub>n"} the
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   361
  %type of the function @{text "map_\<kappa>"} has to be @{text "\<alpha>\<^isub>1\<Rightarrow>\<dots>\<Rightarrow>\<alpha>\<^isub>n\<Rightarrow>\<alpha>\<^isub>1\<dots>\<alpha>\<^isub>n \<kappa>"}.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   362
  %For example @{text "map_list"}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   363
  %has to have the type @{text "\<alpha>\<Rightarrow>\<alpha> list"}.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   364
  In our implementation we maintain
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   365
  a database of these map-functions that can be dynamically extended.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   366
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   367
  It will also be necessary to have operators, referred to as @{text "rel_\<kappa>"},
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   368
  which define equivalence relations in terms of constituent equivalence
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   369
  relations. For example given two equivalence relations @{text "R\<^isub>1"}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   370
  and @{text "R\<^isub>2"}, we can define an equivalence relations over
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   371
  products as %% follows
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   372
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   373
  \begin{isabelle}\ \ \ \ \ %%%
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   374
  @{text "(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"}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   375
  \end{isabelle}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   376
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   377
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   378
  Homeier gives also the following operator for defining equivalence
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   379
  relations over function types
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   380
  %
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   381
  \begin{isabelle}\ \ \ \ \ %%%
3118
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3115
diff changeset
   382
  @{thm fun_rel_def[of "R\<^isub>1" "R\<^isub>2", THEN eq_reflection]}
3082
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   383
  \hfill\numbered{relfun}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   384
  \end{isabelle}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   385
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   386
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   387
  In the context of quotients, the following two notions from \cite{Homeier05}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   388
  are needed later on.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   389
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   390
  \begin{definition}[Respects]\label{def:respects}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   391
  An element @{text "x"} respects a relation @{text "R"} provided @{text "R x x"}.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   392
  \end{definition}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   393
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   394
  \begin{definition}[Bounded $\forall$ and $\lambda$]\label{def:babs}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   395
  @{text "\<forall>x \<in> S. P x"} holds if for all @{text x}, @{text "x \<in> S"} implies @{text "P x"};
3114
a9a4baa7779f 2 typos found by John Wickerson in QPaper
Christian Urban <urbanc@in.tum.de>
parents: 3094
diff changeset
   396
  and @{text "(\<lambda>x \<in> S. f x) x = f x"} provided @{text "x \<in> S"}.
3082
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   397
  \end{definition}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   398
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   399
  The central definition in Homeier's work \cite{Homeier05} relates equivalence
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   400
  relations, abstraction and representation functions:
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   401
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   402
  \begin{definition}[Quotient Types]
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   403
  Given a relation $R$, an abstraction function $Abs$
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   404
  and a representation function $Rep$, the predicate @{term "Quotient R Abs Rep"}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   405
  holds if and only if
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   406
  \begin{isabelle}\ \ \ \ \ %%%%
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   407
  \begin{tabular}{rl}
3118
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3115
diff changeset
   408
  (i) & \begin{isa}@{thm (rhs1) Quotient_def[of "R"]}\end{isa}\\
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3115
diff changeset
   409
  (ii) & \begin{isa}@{thm (rhs2) Quotient_def[of "R"]}\end{isa}\\
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3115
diff changeset
   410
  (iii) & \begin{isa}@{thm (rhs3) Quotient_def[of "R"]}\end{isa}\\
3082
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   411
  \end{tabular}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   412
  \end{isabelle}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   413
  \end{definition}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   414
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   415
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   416
  The value of this definition lies in the fact that validity of @{term "Quotient R Abs Rep"} can
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   417
  often be proved in terms of the validity of @{term "Quot"} over the constituent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   418
  types of @{text "R"}, @{text Abs} and @{text Rep}.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   419
  For example Homeier proves the following property for higher-order quotient
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   420
  types:
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   421
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   422
  \begin{proposition}\label{funquot}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   423
  \begin{isa}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   424
  @{thm[mode=IfThen] fun_quotient[where ?R1.0="R\<^isub>1" and ?R2.0="R\<^isub>2"
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   425
      and ?abs1.0="Abs\<^isub>1" and ?abs2.0="Abs\<^isub>2" and ?rep1.0="Rep\<^isub>1" and ?rep2.0="Rep\<^isub>2"]}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   426
  \end{isa}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   427
  \end{proposition}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   428
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   429
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   430
  As a result, Homeier is able to build an automatic prover that can nearly
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   431
  always discharge a proof obligation involving @{text "Quot"}. Our quotient
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   432
  package makes heavy
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   433
  use of this part of Homeier's work including an extension
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   434
  for dealing with \emph{conjugations} of equivalence relations\footnote{That are
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   435
  symmetric by definition.} defined as follows:
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   436
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   437
%%% FIXME Referee 2 claims that composition-of-relations means OO, and this is also
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   438
%%% what wikipedia says. Any idea for a different name? Conjugation of Relations?
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   439
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   440
  \begin{definition}%%[Composition of Relations]
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   441
  @{abbrev "rel_conj R\<^isub>1 R\<^isub>2"} where @{text "\<circ>\<circ>"} is the predicate
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   442
  composition defined by
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   443
  @{thm (concl) pred_compI[of "R\<^isub>1" "x" "y" "R\<^isub>2" "z"]}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   444
  holds if and only if there exists a @{text y} such that @{thm (prem 1) pred_compI[of "R\<^isub>1" "x" "y" "R\<^isub>2" "z"]} and
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   445
  @{thm (prem 2) pred_compI[of "R\<^isub>1" "x" "y" "R\<^isub>2" "z"]}.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   446
  \end{definition}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   447
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   448
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   449
  Unfortunately a general quotient theorem for @{text "\<circ>\<circ>\<circ>"}, analogous to the one
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   450
  for @{text "\<singlearr>"} given in Proposition \ref{funquot}, would not be true
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   451
  in general. It cannot even be stated inside HOL, because of restrictions on types.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   452
  However, we can prove specific instances of a
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   453
  quotient theorem for composing particular quotient relations.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   454
  For example, to lift theorems involving @{term flat} the quotient theorem for
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   455
  composing @{text "\<approx>\<^bsub>list\<^esub>"} will be necessary: given @{term "Quotient R Abs Rep"}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   456
  with @{text R} being an equivalence relation, then
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   457
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   458
  \begin{isabelle}\ \ \ \ \ %%%
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   459
  \begin{tabular}{r@ {\hspace{1mm}}l}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   460
  @{text  "Quot"} & @{text "(rel_list R \<circ>\<circ>\<circ> \<approx>\<^bsub>list\<^esub>)"}\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   461
                  & @{text "(Abs_fset \<circ> map_list Abs)"} @{text "(map_list Rep \<circ> Rep_fset)"}\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   462
  \end{tabular}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   463
  \end{isabelle}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   464
*}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   465
3092
ff377f9d030a some slight tuning
Christian Urban <urbanc@in.tum.de>
parents: 3082
diff changeset
   466
section {* Quotient Types and Quotient Definitions\label{sec:type} *}
3082
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   467
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   468
text {*
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   469
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   470
  The first step in a quotient construction is to take a name for the new
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   471
  type, say @{text "\<kappa>\<^isub>q"}, and an equivalence relation, say @{text R},
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   472
  defined over a raw type, say @{text "\<sigma>"}. The type of the equivalence
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   473
  relation must be @{text "\<sigma> \<Rightarrow> \<sigma> \<Rightarrow> bool"}. The user-visible part of
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   474
  the quotient type declaration is therefore
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   475
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   476
  \begin{isabelle}\ \ \ \ \ %%%
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   477
  \isacommand{quotient\_type}~~@{text "\<alpha>s \<kappa>\<^isub>q = \<sigma> / R"}\hfill\numbered{typedecl}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   478
  \end{isabelle}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   479
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   480
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   481
  and a proof that @{text "R"} is indeed an equivalence relation. The @{text "\<alpha>s"}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   482
  indicate the arity of the new type and the type-variables of @{text "\<sigma>"} can only
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   483
  be contained in @{text "\<alpha>s"}. Two concrete
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   484
  examples are
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   485
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   486
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   487
  \begin{isabelle}\ \ \ \ \ %%%
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   488
  \begin{tabular}{@ {}l}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   489
  \isacommand{quotient\_type}~~@{text "int = nat \<times> nat / \<approx>\<^bsub>nat \<times> nat\<^esub>"}\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   490
  \isacommand{quotient\_type}~~@{text "\<alpha> fset = \<alpha> list / \<approx>\<^bsub>list\<^esub>"}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   491
  \end{tabular}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   492
  \end{isabelle}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   493
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   494
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   495
  which introduce the type of integers and of finite sets using the
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   496
  equivalence relations @{text "\<approx>\<^bsub>nat \<times> nat\<^esub>"} and @{text
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   497
  "\<approx>\<^bsub>list\<^esub>"} defined in \eqref{natpairequiv} and
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   498
  \eqref{listequiv}, respectively (the proofs about being equivalence
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   499
  relations are omitted).  Given this data, we define for declarations shown in
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   500
  \eqref{typedecl} the quotient types internally as
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   501
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   502
  \begin{isabelle}\ \ \ \ \ %%%
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   503
  \isacommand{typedef}~~@{text "\<alpha>s \<kappa>\<^isub>q = {c. \<exists>x. c = R x}"}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   504
  \end{isabelle}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   505
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   506
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   507
  where the right-hand side is the (non-empty) set of equivalence classes of
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   508
  @{text "R"}. The constraint in this declaration is that the type variables
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   509
  in the raw type @{text "\<sigma>"} must be included in the type variables @{text
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   510
  "\<alpha>s"} declared for @{text "\<kappa>\<^isub>q"}. HOL will then provide us with the following
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   511
  abstraction and representation functions
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   512
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   513
  \begin{isabelle}\ \ \ \ \ %%%
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   514
  @{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"}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   515
  \end{isabelle}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   516
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   517
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   518
  As can be seen from the type, they relate the new quotient type and equivalence classes of the raw
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   519
  type. However, as Homeier \cite{Homeier05} noted, it is much more convenient
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   520
  to work with the following derived abstraction and representation functions
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   521
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   522
  \begin{isabelle}\ \ \ \ \ %%%
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   523
  @{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)"}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   524
  \end{isabelle}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   525
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   526
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   527
  on the expense of having to use Hilbert's choice operator @{text "\<epsilon>"} in the
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   528
  definition of @{text "Rep_\<kappa>\<^isub>q"}. These derived notions relate the
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   529
  quotient type and the raw type directly, as can be seen from their type,
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   530
  namely @{text "\<sigma> \<Rightarrow> \<alpha>s \<kappa>\<^isub>q"} and @{text "\<alpha>s \<kappa>\<^isub>q \<Rightarrow> \<sigma>"},
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   531
  respectively.  Given that @{text "R"} is an equivalence relation, the
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   532
  following property holds  for every quotient type
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   533
  (for the proof see \cite{Homeier05}).
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   534
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   535
  \begin{proposition}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   536
  \begin{isa}@{term "Quotient R Abs_\<kappa>\<^isub>q Rep_\<kappa>\<^isub>q"}.\end{isa}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   537
  \end{proposition}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   538
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   539
  The next step in a quotient construction is to introduce definitions of new constants
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   540
  involving the quotient type. These definitions need to be given in terms of concepts
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   541
  of the raw type (remember this is the only way how to extend HOL
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   542
  with new definitions). For the user the visible part of such definitions is the declaration
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   543
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   544
  \begin{isabelle}\ \ \ \ \ %%%
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   545
  \isacommand{quotient\_definition}~~@{text "c :: \<tau>"}~~\isacommand{is}~~@{text "t :: \<sigma>"}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   546
  \end{isabelle}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   547
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   548
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   549
  where @{text t} is the definiens (its type @{text \<sigma>} can always be inferred)
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   550
  and @{text "c"} is the name of definiendum, whose type @{text "\<tau>"} needs to be
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   551
  given explicitly (the point is that @{text "\<tau>"} and @{text "\<sigma>"} can only differ
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   552
  in places where a quotient and raw type is involved). Two concrete examples are
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   553
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   554
  \begin{isabelle}\ \ \ \ \ %%%
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   555
  \begin{tabular}{@ {}l}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   556
  \isacommand{quotient\_definition}~~@{text "0 :: int"}~~\isacommand{is}~~@{text "(0::nat, 0::nat)"}\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   557
  \isacommand{quotient\_definition}~~@{text "\<Union> :: (\<alpha> fset) fset \<Rightarrow> \<alpha> fset"}~~%
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   558
  \isacommand{is}~~@{text "flat"}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   559
  \end{tabular}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   560
  \end{isabelle}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   561
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   562
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   563
  The first one declares zero for integers and the second the operator for
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   564
  building unions of finite sets (@{text "flat"} having the type
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   565
  @{text "(\<alpha> list) list \<Rightarrow> \<alpha> list"}).
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   566
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   567
  From such declarations given by the user, the quotient package needs to derive proper
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   568
  definitions using @{text "Abs"} and @{text "Rep"}. The data we rely on is the given quotient type
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   569
  @{text "\<tau>"} and the raw type @{text "\<sigma>"}.  They allow us to define \emph{aggregate
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   570
  abstraction} and \emph{representation functions} using the functions @{text "ABS (\<sigma>,
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   571
  \<tau>)"} and @{text "REP (\<sigma>, \<tau>)"} whose clauses we shall give below. The idea behind
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   572
  these two functions is to simultaneously descend into the raw types @{text \<sigma>} and
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   573
  quotient types @{text \<tau>}, and generate the appropriate
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   574
  @{text "Abs"} and @{text "Rep"} in places where the types differ. Therefore
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   575
  we generate just the identity whenever the types are equal. On the ``way'' down,
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   576
  however we might have to use map-functions to let @{text Abs} and @{text Rep} act
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   577
  over the appropriate types. In what follows we use the short-hand notation
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   578
  @{text "ABS (\<sigma>s, \<tau>s)"} to mean @{text "ABS (\<sigma>\<^isub>1, \<tau>\<^isub>1)\<dots>ABS (\<sigma>\<^isub>n, \<tau>\<^isub>n)"}; similarly
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   579
  for @{text REP}.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   580
  %
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   581
  \begin{center}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   582
  \hfill
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   583
  \begin{tabular}{@ {\hspace{2mm}}l@ {}}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   584
  \multicolumn{1}{@ {}l}{equal types:}\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   585
  @{text "ABS (\<sigma>, \<sigma>)"} $\dn$ @{text "id :: \<sigma> \<Rightarrow> \<sigma>"}\hspace{5mm}%\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   586
  @{text "REP (\<sigma>, \<sigma>)"} $\dn$ @{text "id :: \<sigma> \<Rightarrow> \<sigma>"}\smallskip\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   587
  \multicolumn{1}{@ {}l}{function types:}\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   588
  @{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)"}\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   589
  @{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\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   590
  \multicolumn{1}{@ {}l}{equal type constructors:}\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   591
  @{text "ABS (\<sigma>s \<kappa>, \<tau>s \<kappa>)"} $\dn$ @{text "map_\<kappa> (ABS (\<sigma>s, \<tau>s))"}\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   592
  @{text "REP (\<sigma>s \<kappa>, \<tau>s \<kappa>)"} $\dn$ @{text "map_\<kappa> (REP (\<sigma>s, \<tau>s))"}\smallskip\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   593
  \multicolumn{1}{@ {}l}{unequal type constructors:}\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   594
  @{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)))"}\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   595
  @{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"}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   596
  \end{tabular}\hfill\numbered{ABSREP}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   597
  \end{center}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   598
  %
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   599
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   600
  In the last two clauses are subtle. We rely in them on the fact that the type @{text "\<alpha>s
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   601
  \<kappa>\<^isub>q"} is the quotient of the raw type @{text "\<rho>s \<kappa>"} (for example
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   602
  @{text "int"} and @{text "nat \<times> nat"}, or @{text "\<alpha> fset"} and @{text "\<alpha>
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   603
  list"}). This data is given by declarations shown in \eqref{typedecl}.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   604
  The quotient construction ensures that the type variables in @{text
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   605
  "\<rho>s \<kappa>"} must be among the @{text "\<alpha>s"}. The @{text "\<sigma>s'"} are given by the
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   606
  substitutions for the @{text "\<alpha>s"} when matching  @{text "\<sigma>s \<kappa>"} against
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   607
  @{text "\<rho>s \<kappa>"}. This calculation determines what are the types in place
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   608
  of the type variables @{text "\<alpha>s"} in the instance of
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   609
  quotient type @{text "\<alpha>s \<kappa>\<^isub>q"}---namely @{text "\<tau>s"}, and the corresponding
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   610
  types in place of the @{text "\<alpha>s"} in the raw type @{text "\<rho>s \<kappa>"}---namely @{text "\<sigma>s'"}. The
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   611
  function @{text "MAP"} calculates an \emph{aggregate map-function} for a raw
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   612
  type as follows:
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   613
  %
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   614
  \begin{center}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   615
  \begin{tabular}{r@ {\hspace{1mm}}c@ {\hspace{1mm}}l}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   616
  @{text "MAP' (\<alpha>)"} & $\dn$ & @{text "a\<^sup>\<alpha>"}\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   617
  @{text "MAP' (\<kappa>)"} & $\dn$ & @{text "id :: \<kappa> \<Rightarrow> \<kappa>"}\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   618
  @{text "MAP' (\<sigma>s \<kappa>)"} & $\dn$ & @{text "map_\<kappa> (MAP'(\<sigma>s))"}\smallskip\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   619
  @{text "MAP (\<sigma>)"} & $\dn$ & @{text "\<lambda>as. MAP'(\<sigma>)"}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   620
  \end{tabular}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   621
  \end{center}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   622
  %
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   623
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   624
  In this definition we rely on the fact that in the first clause we can interpret type-variables @{text \<alpha>} as
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   625
  term variables @{text a}. In the last clause we build an abstraction over all
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   626
  term-variables of the map-function generated by the auxiliary function
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   627
  @{text "MAP'"}.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   628
  The need for aggregate map-functions can be seen in cases where we build quotients,
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   629
  say @{text "(\<alpha>, \<beta>) \<kappa>\<^isub>q"}, out of compound raw types, say @{text "(\<alpha> list) \<times> \<beta>"}.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   630
  In this case @{text MAP} generates  the
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   631
  aggregate map-function:
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   632
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   633
%%% FIXME: Reviewer 2 asks: last two lines defining ABS and REP for
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   634
%%% unequal type constructors: How are the $\varrho$s defined? The
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   635
%%% following paragraph mentions them, but this paragraph is unclear,
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   636
%%% since it then mentions $\alpha$s, which do not seem to be defined
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   637
%%% either. As a result, I do not understand the first two sentences
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   638
%%% in this paragraph. I can imagine roughly what the following
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   639
%%% sentence `The $\sigma$s' are given by the matchers for the
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   640
%%% $\alpha$s$ when matching $\varrho$s $\kappa$ against $\sigma$s
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   641
%%% $\kappa$.' means, but also think that it is too vague.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   642
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   643
  \begin{isabelle}\ \ \ \ \ %%%
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   644
  @{text "\<lambda>a b. map_prod (map_list a) b"}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   645
  \end{isabelle}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   646
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   647
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   648
  which is essential in order to define the corresponding aggregate
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   649
  abstraction and representation functions.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   650
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   651
  To see how these definitions pan out in practise, let us return to our
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   652
  example about @{term "concat"} and @{term "fconcat"}, where we have the raw type
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   653
  @{text "(\<alpha> list) list \<Rightarrow> \<alpha> list"} and the quotient type @{text "(\<alpha> fset) fset \<Rightarrow> \<alpha>
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   654
  fset"}. Feeding these types into @{text ABS} gives us (after some @{text "\<beta>"}-simplifications)
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   655
  the abstraction function
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   656
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   657
  \begin{isabelle}\ \ \ %%%
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   658
  \begin{tabular}{l}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   659
  @{text "(map_list (map_list id \<circ> Rep_fset) \<circ> Rep_fset) \<singlearr>"}\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   660
  \mbox{}\hspace{4.5cm}@{text " Abs_fset \<circ> map_list id"}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   661
  \end{tabular}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   662
  \end{isabelle}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   663
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   664
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   665
  In our implementation we further
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   666
  simplify this function by rewriting with the usual laws about @{text
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   667
  "map"}s and @{text "id"}, for example @{term "map_list id = id"} and @{text "f \<circ> id =
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   668
  id \<circ> f = f"}. This gives us the simpler abstraction function
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   669
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   670
  \begin{isabelle}\ \ \ \ \ %%%
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   671
  @{text "(map_list Rep_fset \<circ> Rep_fset) \<singlearr> Abs_fset"}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   672
  \end{isabelle}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   673
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   674
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   675
  which we can use for defining @{term "fconcat"} as follows
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   676
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   677
  \begin{isabelle}\ \ \ \ \ %%%
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   678
  @{text "\<Union> \<equiv> ((map_list Rep_fset \<circ> Rep_fset) \<singlearr> Abs_fset) flat"}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   679
  \end{isabelle}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   680
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   681
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   682
  Note that by using the operator @{text "\<singlearr>"} and special clauses
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   683
  for function types in \eqref{ABSREP}, we do not have to
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   684
  distinguish between arguments and results, but can deal with them uniformly.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   685
  Consequently, all definitions in the quotient package
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   686
  are of the general form
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   687
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   688
  \begin{isabelle}\ \ \ \ \ %%%
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   689
  \mbox{@{text "c \<equiv> ABS (\<sigma>, \<tau>) t"}}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   690
  \end{isabelle}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   691
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   692
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   693
  where @{text \<sigma>} is the type of the definiens @{text "t"} and @{text "\<tau>"} the
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   694
  type of the defined quotient constant @{text "c"}. This data can be easily
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   695
  generated from the declaration given by the user.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   696
  To increase the confidence in this way of making definitions, we can prove
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   697
  that the terms involved are all typable.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   698
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   699
  \begin{lemma}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   700
  If @{text "ABS (\<sigma>, \<tau>)"} returns some abstraction function @{text "Abs"}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   701
  and @{text "REP (\<sigma>, \<tau>)"} some representation function @{text "Rep"},
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   702
  then @{text "Abs"} is of type @{text "\<sigma> \<Rightarrow> \<tau>"} and @{text "Rep"} of type
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   703
  @{text "\<tau> \<Rightarrow> \<sigma>"}.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   704
  \end{lemma}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   705
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   706
  \begin{proof}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   707
  By mutual induction and analysing the definitions of @{text "ABS"} and @{text "REP"}.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   708
  The cases of equal types and function types are
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   709
  straightforward (the latter follows from @{text "\<singlearr>"} having the
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   710
  type @{text "(\<alpha> \<Rightarrow> \<beta>) \<Rightarrow> (\<gamma> \<Rightarrow> \<delta>) \<Rightarrow> (\<beta> \<Rightarrow> \<gamma>) \<Rightarrow> (\<alpha> \<Rightarrow> \<delta>)"}). In case of equal type
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   711
  constructors we can observe that a map-function after applying the functions
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   712
  @{text "ABS (\<sigma>s, \<tau>s)"} produces a term of type @{text "\<sigma>s \<kappa> \<Rightarrow> \<tau>s \<kappa>"}.  The
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   713
  interesting case is the one with unequal type constructors. Since we know
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   714
  the quotient is between @{text "\<alpha>s \<kappa>\<^isub>q"} and @{text "\<rho>s \<kappa>"}, we have
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   715
  that @{text "Abs_\<kappa>\<^isub>q"} is of type @{text "\<rho>s \<kappa> \<Rightarrow> \<alpha>s
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   716
  \<kappa>\<^isub>q"}. This type can be more specialised to @{text "\<rho>s[\<tau>s] \<kappa> \<Rightarrow> \<tau>s
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   717
  \<kappa>\<^isub>q"} where the type variables @{text "\<alpha>s"} are instantiated with the
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   718
  @{text "\<tau>s"}. The complete type can be calculated by observing that @{text
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   719
  "MAP (\<rho>s \<kappa>)"}, after applying the functions @{text "ABS (\<sigma>s', \<tau>s)"} to it,
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   720
  returns a term of type @{text "\<rho>s[\<sigma>s'] \<kappa> \<Rightarrow> \<rho>s[\<tau>s] \<kappa>"}. This type is
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   721
  equivalent to @{text "\<sigma>s \<kappa> \<Rightarrow> \<rho>s[\<tau>s] \<kappa>"}, which we just have to compose with
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   722
  @{text "\<rho>s[\<tau>s] \<kappa> \<Rightarrow> \<tau>s \<kappa>\<^isub>q"} according to the type of @{text "\<circ>"}.\qed
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   723
  \end{proof}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   724
*}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   725
3092
ff377f9d030a some slight tuning
Christian Urban <urbanc@in.tum.de>
parents: 3082
diff changeset
   726
section {* Respectfulness and Preservation \label{sec:resp} *}
3082
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   727
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   728
text {*
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   729
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   730
  The main point of the quotient package is to automatically ``lift'' theorems
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   731
  involving constants over the raw type to theorems involving constants over
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   732
  the quotient type. Before we can describe this lifting process, we need to impose
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   733
  two restrictions in form of proof obligations that arise during the
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   734
  lifting. The reason is that even if definitions for all raw constants
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   735
  can be given, \emph{not} all theorems can be lifted to the quotient type. Most
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   736
  notable is the bound variable function, that is the constant @{text bn},
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   737
  defined
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   738
  for raw lambda-terms as follows
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   739
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   740
  \begin{isabelle}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   741
  \begin{center}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   742
  @{text "bn (x) \<equiv> \<emptyset>"}\hspace{4mm}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   743
  @{text "bn (t\<^isub>1 t\<^isub>2) \<equiv> bn (t\<^isub>1) \<union> bn (t\<^isub>2)"}\smallskip\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   744
  @{text "bn (\<lambda>x. t) \<equiv> {x} \<union> bn (t)"}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   745
  \end{center}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   746
  \end{isabelle}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   747
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   748
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   749
  We can generate a definition for this constant using @{text ABS} and @{text REP}.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   750
  But this constant does \emph{not} respect @{text "\<alpha>"}-equivalence and
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   751
  consequently no theorem involving this constant can be lifted to @{text
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   752
  "\<alpha>"}-equated lambda terms. Homeier formulates the restrictions in terms of
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   753
  the properties of \emph{respectfulness} and \emph{preservation}. We have
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   754
  to slightly extend Homeier's definitions in order to deal with quotient
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   755
  compositions.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   756
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   757
%%% FIXME: Reviewer 3 asks why are the definitions that follow enough to deal
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   758
%%% with quotient composition.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   759
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   760
  To formally define what respectfulness is, we have to first define
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   761
  the notion of \emph{aggregate equivalence relations} using the function @{text "REL(\<sigma>, \<tau>)"}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   762
  The idea behind this function is to simultaneously descend into the raw types
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   763
  @{text \<sigma>} and quotient types @{text \<tau>}, and generate the appropriate
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   764
  quotient equivalence relations in places where the types differ and equalities
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   765
  elsewhere.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   766
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   767
  \begin{center}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   768
  \hfill
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   769
  \begin{tabular}{l}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   770
  \multicolumn{1}{@ {}l}{equal types:}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   771
  @{text "REL (\<sigma>, \<sigma>)"} $\dn$ @{text "= :: \<sigma> \<Rightarrow> \<sigma> \<Rightarrow> bool"}\smallskip\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   772
   \multicolumn{1}{@ {}l}{equal type constructors:}\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   773
  @{text "REL (\<sigma>s \<kappa>, \<tau>s \<kappa>)"} $\dn$ @{text "rel_\<kappa> (REL (\<sigma>s, \<tau>s))"}\smallskip\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   774
  \multicolumn{1}{@ {}l}{unequal type constructors:}\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   775
  @{text "REL (\<sigma>s \<kappa>, \<tau>s \<kappa>\<^isub>q)"} $\dn$ @{text "rel_\<kappa>\<^isub>q (REL (\<sigma>s', \<tau>s))"}\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   776
  \end{tabular}\hfill\numbered{REL}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   777
  \end{center}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   778
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   779
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   780
  The @{text "\<sigma>s'"} in the last clause are calculated as in \eqref{ABSREP}:
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   781
  again we know that type @{text "\<alpha>s \<kappa>\<^isub>q"} is the quotient of the raw type
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   782
  @{text "\<rho>s \<kappa>"}. The @{text "\<sigma>s'"} are the substitutions for @{text "\<alpha>s"} obtained by matching
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   783
  @{text "\<rho>s \<kappa>"} and @{text "\<sigma>s \<kappa>"}.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   784
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   785
  Let us return to the lifting procedure of theorems. Assume we have a theorem
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   786
  that contains the raw constant @{text "c\<^isub>r :: \<sigma>"} and which we want to
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   787
  lift to a theorem where @{text "c\<^isub>r"} is replaced by the corresponding
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   788
  constant @{text "c\<^isub>q :: \<tau>"} defined over a quotient type. In this situation
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   789
  we generate the following proof obligation
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   790
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   791
  \begin{isabelle}\ \ \ \ \ %%%
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   792
  @{text "REL (\<sigma>, \<tau>) c\<^isub>r c\<^isub>r"}.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   793
  \end{isabelle}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   794
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   795
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   796
  Homeier calls these proof obligations \emph{respectfulness
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   797
  theorems}. However, unlike his quotient package, we might have several
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   798
  respectfulness theorems for one constant---he has at most one.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   799
  The reason is that because of our quotient compositions, the types
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   800
  @{text \<sigma>} and @{text \<tau>} are not completely determined by @{text "c\<^bsub>r\<^esub>"}.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   801
  And for every instantiation of the types, a corresponding
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   802
  respectfulness theorem is necessary.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   803
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   804
  Before lifting a theorem, we require the user to discharge
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   805
  respectfulness proof obligations. In case of @{text bn}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   806
  this obligation is %%as follows
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   807
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   808
  \begin{isabelle}\ \ \ \ \ %%%
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   809
  @{text  "(\<approx>\<^isub>\<alpha> \<doublearr> =) bn bn"}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   810
  \end{isabelle}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   811
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   812
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   813
  and the point is that the user cannot discharge it: because it is not true. To see this,
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   814
  we can just unfold the definition of @{text "\<doublearr>"} \eqref{relfun}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   815
  using extensionality to obtain the false statement
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   816
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   817
  \begin{isabelle}\ \ \ \ \ %%%
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   818
  @{text "\<forall>t\<^isub>1 t\<^isub>2. if t\<^isub>1 \<approx>\<^isub>\<alpha> t\<^isub>2 then bn(t\<^isub>1) = bn(t\<^isub>2)"}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   819
  \end{isabelle}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   820
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   821
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   822
  In contrast, lifting a theorem about @{text "append"} to a theorem describing
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   823
  the union of finite sets will mean to discharge the proof obligation
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   824
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   825
  \begin{isabelle}\ \ \ \ \ %%%
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   826
  @{text "(\<approx>\<^bsub>list\<^esub> \<doublearr> \<approx>\<^bsub>list\<^esub> \<doublearr> \<approx>\<^bsub>list\<^esub>) append append"}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   827
  \end{isabelle}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   828
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   829
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   830
  To do so, we have to establish
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   831
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   832
  \begin{isabelle}\ \ \ \ \ %%%
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   833
  if @{text "xs \<approx>\<^bsub>list\<^esub> ys"} and  @{text "us \<approx>\<^bsub>list\<^esub> vs"}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   834
  then @{text "xs @ us \<approx>\<^bsub>list\<^esub> ys @ vs"}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   835
  \end{isabelle}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   836
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   837
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   838
  which is straightforward given the definition shown in \eqref{listequiv}.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   839
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   840
  The second restriction we have to impose arises from non-lifted polymorphic
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   841
  constants, which are instantiated to a type being quotient. For example,
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   842
  take the @{term "cons"}-constructor to add a pair of natural numbers to a
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   843
  list, whereby we assume the pair of natural numbers turns into an integer in
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   844
  the quotient construction. The point is that we still want to use @{text
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   845
  cons} for adding integers to lists---just with a different type. To be able
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   846
  to lift such theorems, we need a \emph{preservation property} for @{text
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   847
  cons}. Assuming we have a polymorphic raw constant @{text "c\<^isub>r :: \<sigma>"}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   848
  and a corresponding quotient constant @{text "c\<^isub>q :: \<tau>"}, then a
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   849
  preservation property is as follows
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   850
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   851
%%% FIXME: Reviewer 2 asks: You say what a preservation theorem is,
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   852
%%% but not which preservation theorems you assume. Do you generate a
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   853
%%% proof obligation for a preservation theorem for each raw constant
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   854
%%% and its corresponding lifted constant?
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   855
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   856
%%% Cezary: I think this would be a nice thing to do but we have not
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   857
%%% done it, the theorems need to be 'guessed' from the remaining obligations
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   858
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   859
  \begin{isabelle}\ \ \ \ \ %%%
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   860
  @{text "Quot R\<^bsub>\<alpha>s\<^esub> Abs\<^bsub>\<alpha>s\<^esub> Rep\<^bsub>\<alpha>s\<^esub> implies  ABS (\<sigma>, \<tau>) c\<^isub>r = c\<^isub>r"}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   861
  \end{isabelle}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   862
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   863
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   864
  where the @{text "\<alpha>s"} stand for the type variables in the type of @{text "c\<^isub>r"}.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   865
  In case of @{text cons} (which has type @{text "\<alpha> \<Rightarrow> \<alpha> list \<Rightarrow> \<alpha> list"}) we have
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   866
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   867
  \begin{isabelle}\ \ \ \ \ %%%
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   868
  @{text "(Rep \<singlearr> map_list Rep \<singlearr> map_list Abs) cons = cons"}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   869
  \end{isabelle}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   870
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   871
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   872
  under the assumption @{term "Quotient R Abs Rep"}. The point is that if we have
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   873
  an instance of @{text cons} where the type variable @{text \<alpha>} is instantiated
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   874
  with @{text "nat \<times> nat"} and we also quotient this type to yield integers,
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   875
  then we need to show this preservation property.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   876
3118
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3115
diff changeset
   877
  %%%@ {thm [display, indent=10] Cons_prs2}
3082
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   878
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   879
  %Given two quotients, one of which quotients a container, and the
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   880
  %other quotients the type in the container, we can write the
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   881
  %composition of those quotients. To compose two quotient theorems
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   882
  %we compose the relations with relation composition as defined above
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   883
  %and the abstraction and relation functions are the ones of the sub
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   884
  %quotients composed with the usual function composition.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   885
  %The @ {term "Rep"} and @ {term "Abs"} functions that we obtain agree
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   886
  %with the definition of aggregate Abs/Rep functions and the
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   887
  %relation is the same as the one given by aggregate relations.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   888
  %This becomes especially interesting
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   889
  %when we compose the quotient with itself, as there is no simple
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   890
  %intermediate step.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   891
  %
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   892
  %Lets take again the example of @ {term flat}. To be able to lift
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   893
  %theorems that talk about it we provide the composition quotient
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   894
  %theorem which allows quotienting inside the container:
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   895
  %
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   896
  %If @ {term R} is an equivalence relation and @ {term "Quotient R Abs Rep"}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   897
  %then
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   898
  %
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   899
  %@ {text [display, indent=10] "Quotient (list_rel R \<circ>\<circ>\<circ> \<approx>\<^bsub>list\<^esub>) (abs_fset \<circ> map_list Abs) (map_list Rep o rep_fset)"}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   900
  %%%
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   901
  %%%\noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   902
  %%%this theorem will then instantiate the quotients needed in the
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   903
  %%%injection and cleaning proofs allowing the lifting procedure to
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   904
  %%%proceed in an unchanged way.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   905
*}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   906
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   907
section {* Lifting of Theorems\label{sec:lift} *}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   908
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   909
text {*
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   910
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   911
%%% FIXME Reviewer 3 asks: Section 5 shows the technicalities of
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   912
%%% lifting theorems. But there is no clarification about the
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   913
%%% correctness. A reader would also be interested in seeing some
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   914
%%% discussions about the generality and limitation of the approach
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   915
%%% proposed there
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   916
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   917
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   918
  The main benefit of a quotient package is to lift automatically theorems over raw
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   919
  types to theorems over quotient types. We will perform this lifting in
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   920
  three phases, called \emph{regularization},
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   921
  \emph{injection} and \emph{cleaning} according to procedures in Homeier's ML-code.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   922
  Space restrictions, unfortunately, prevent us from giving anything but a sketch of these three
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   923
  phases. However, we will precisely define the input and output data of these phases
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   924
  (this was omitted in \cite{Homeier05}).
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   925
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   926
  The purpose of regularization is to change the quantifiers and abstractions
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   927
  in a ``raw'' theorem to quantifiers over variables that respect their respective relations
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   928
  (Definition \ref{def:respects} states what respects means). The purpose of injection is to add @{term Rep}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   929
  and @{term Abs} of appropriate types in front of constants and variables
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   930
  of the raw type so that they can be replaced by the corresponding constants from the
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   931
  quotient type. The purpose of cleaning is to bring the theorem derived in the
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   932
  first two phases into the form the user has specified. Abstractly, our
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   933
  package establishes the following three proof steps:
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   934
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   935
%%% FIXME: Reviewer 1 complains that the reader needs to guess the
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   936
%%% meaning of reg_thm and inj_thm, as well as the arguments of REG
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   937
%%% which are given above. I wouldn't change it.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   938
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   939
  \begin{center}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   940
  \begin{tabular}{l@ {\hspace{4mm}}l}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   941
  1.) Regularization & @{text "raw_thm \<longrightarrow> reg_thm"}\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   942
  2.) Injection & @{text "reg_thm \<longleftrightarrow> inj_thm"}\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   943
  3.) Cleaning & @{text "inj_thm \<longleftrightarrow> quot_thm"}\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   944
  \end{tabular}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   945
  \end{center}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   946
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   947
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   948
  which means, stringed together, the raw theorem implies the quotient theorem.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   949
  In contrast to other quotient packages, our package requires that the user specifies
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   950
  both, the @{text "raw_thm"} (as theorem) and the \emph{term} of the @{text "quot_thm"}.\footnote{Though we
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   951
  also provide a fully automated mode, where the @{text "quot_thm"} is guessed
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   952
  from the form of @{text "raw_thm"}.} As a result, the user has fine control
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   953
  over which parts of a raw theorem should be lifted.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   954
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   955
  The second and third proof step performed in package will always succeed if the appropriate
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   956
  respectfulness and preservation theorems are given. In contrast, the first
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   957
  proof step can fail: a theorem given by the user does not always
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   958
  imply a regularized version and a stronger one needs to be proved. An example
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   959
  for this kind of failure is the simple statement for integers @{text "0 \<noteq> 1"}.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   960
  One might hope that it can be proved by lifting @{text "(0, 0) \<noteq> (1, 0)"},
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   961
  but this raw theorem only shows that two particular elements in the
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   962
  equivalence classes are not equal. In order to obtain @{text "0 \<noteq> 1"}, a
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   963
  more general statement stipulating that the equivalence classes are not
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   964
  equal is necessary.  This kind of failure is beyond the scope where the
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   965
  quotient package can help: the user has to provide a raw theorem that
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   966
  can be regularized automatically, or has to provide an explicit proof
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   967
  for the first proof step. Homeier gives more details about this issue
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   968
  in the long version of \cite{Homeier05}.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   969
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   970
  In the following we will first define the statement of the
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   971
  regularized theorem based on @{text "raw_thm"} and
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   972
  @{text "quot_thm"}. Then we define the statement of the injected theorem, based
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   973
  on @{text "reg_thm"} and @{text "quot_thm"}. We then show the three proof steps,
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   974
  which can all be performed independently from each other.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   975
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   976
  We first define the function @{text REG}, which takes the terms of the
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   977
  @{text "raw_thm"} and @{text "quot_thm"} as input and returns
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   978
  @{text "reg_thm"}. The idea
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   979
  behind this function is that it replaces quantifiers and
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   980
  abstractions involving raw types by bounded ones, and equalities
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   981
  involving raw types by appropriate aggregate
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   982
  equivalence relations. It is defined by simultaneous recursion on
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   983
  the structure of  the terms of @{text "raw_thm"} and @{text "quot_thm"} as follows:
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   984
  %
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   985
  \begin{center}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   986
  \begin{tabular}{@ {}l@ {}}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   987
  \multicolumn{1}{@ {}l@ {}}{abstractions:}\\%%\smallskip\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   988
  @{text "REG (\<lambda>x\<^sup>\<sigma>. t, \<lambda>x\<^sup>\<tau>. s)"} $\dn$
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   989
  $\begin{cases}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   990
  @{text "\<lambda>x\<^sup>\<sigma>. REG (t, s)"} \quad\mbox{provided @{text "\<sigma> = \<tau>"}}\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   991
  @{text "\<lambda>x\<^sup>\<sigma> \<in> Resp (REL (\<sigma>, \<tau>)). REG (t, s)"}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   992
  \end{cases}$\\%%\smallskip\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   993
  \multicolumn{1}{@ {}l@ {}}{universal quantifiers:}\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   994
  @{text "REG (\<forall>x\<^sup>\<sigma>. t, \<forall>x\<^sup>\<tau>. s)"} $\dn$
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   995
  $\begin{cases}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   996
  @{text "\<forall>x\<^sup>\<sigma>. REG (t, s)"} \quad\mbox{provided @{text "\<sigma> = \<tau>"}}\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   997
  @{text "\<forall>x\<^sup>\<sigma> \<in> Resp (REL (\<sigma>, \<tau>)). REG (t, s)"}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   998
  \end{cases}$\\%%\smallskip\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   999
  \multicolumn{1}{@ {}l@ {}}{equality:  \hspace{3mm}%%}\smallskip\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1000
  %% REL of two equal types is the equality so we do not need a separate case
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1001
  @{text "REG (=\<^bsup>\<sigma>\<Rightarrow>\<sigma>\<Rightarrow>bool\<^esup>, =\<^bsup>\<tau>\<Rightarrow>\<tau>\<Rightarrow>bool\<^esup>)"} $\dn$ @{text "REL (\<sigma>, \<tau>)"}}\smallskip\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1002
  \multicolumn{1}{@ {}l@ {}}{applications, variables and constants:}\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1003
  @{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)"}\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1004
  @{text "REG (x\<^isub>1, x\<^isub>2)"} $\dn$ @{text "x\<^isub>1"}\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1005
  @{text "REG (c\<^isub>1, c\<^isub>2)"} $\dn$ @{text "c\<^isub>1"}\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1006
  \end{tabular}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1007
  \end{center}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1008
  %
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1009
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1010
  In the above definition we omitted the cases for existential quantifiers
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1011
  and unique existential quantifiers, as they are very similar to the cases
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1012
  for the universal quantifier.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1013
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1014
  Next we define the function @{text INJ} which takes as argument
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1015
  @{text "reg_thm"} and @{text "quot_thm"} (both as
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1016
  terms) and returns @{text "inj_thm"}:
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1017
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1018
  \begin{center}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1019
  \begin{tabular}{l}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1020
  \multicolumn{1}{@ {}l}{abstractions:}\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1021
  @{text "INJ (\<lambda>x. t :: \<sigma>, \<lambda>x. s :: \<tau>) "} $\dn$\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1022
  \hspace{18mm}$\begin{cases}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1023
  @{text "\<lambda>x. INJ (t, s)"} \quad\mbox{provided @{text "\<sigma> = \<tau>"}}\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1024
  @{text "REP (\<sigma>, \<tau>) (ABS (\<sigma>, \<tau>) (\<lambda>x. INJ (t, s)))"}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1025
  \end{cases}$\smallskip\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1026
  @{text "INJ (\<lambda>x \<in> R. t :: \<sigma>, \<lambda>x. s :: \<tau>) "} $\dn$\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1027
  \hspace{18mm}@{text "REP (\<sigma>, \<tau>) (ABS (\<sigma>, \<tau>) (\<lambda>x \<in> R. INJ (t, s)))"}\smallskip\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1028
  \multicolumn{1}{@ {}l}{universal quantifiers:}\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1029
  @{text "INJ (\<forall> t, \<forall> s) "} $\dn$ @{text "\<forall> INJ (t, s)"}\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1030
  @{text "INJ (\<forall> t \<in> R, \<forall> s) "} $\dn$ @{text "\<forall> INJ (t, s) \<in> R"}\smallskip\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1031
  \multicolumn{1}{@ {}l}{applications, variables and constants:}\smallskip\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1032
  @{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)"}\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1033
  @{text "INJ (x\<^isub>1\<^sup>\<sigma>, x\<^isub>2\<^sup>\<tau>) "} $\dn$
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1034
  $\begin{cases}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1035
  @{text "x\<^isub>1"} \quad\mbox{provided @{text "\<sigma> = \<tau>"}}\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1036
  @{text "REP (\<sigma>, \<tau>) (ABS (\<sigma>, \<tau>) x\<^isub>1)"}\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1037
  \end{cases}$\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1038
  @{text "INJ (c\<^isub>1\<^sup>\<sigma>, c\<^isub>2\<^sup>\<tau>) "} $\dn$
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1039
  $\begin{cases}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1040
  @{text "c\<^isub>1"} \quad\mbox{provided @{text "\<sigma> = \<tau>"}}\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1041
  @{text "REP (\<sigma>, \<tau>) (ABS (\<sigma>, \<tau>) c\<^isub>1)"}\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1042
  \end{cases}$\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1043
  \end{tabular}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1044
  \end{center}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1045
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1046
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1047
  In this definition we again omitted the cases for existential and unique existential
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1048
  quantifiers.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1049
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1050
%%% FIXME: Reviewer2 citing following sentence: You mention earlier
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1051
%%% that this implication may fail to be true. Does that meant that
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1052
%%% the `first proof step' is a heuristic that proves the implication
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1053
%%% raw_thm \implies reg_thm in some instances, but fails in others?
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1054
%%% You should clarify under which circumstances the implication is
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1055
%%% being proved here.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1056
%%% Cezary: It would be nice to cite Homeiers discussions in the
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1057
%%% Quotient Package manual from HOL (the longer paper), do you agree?
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1058
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1059
  In the first phase, establishing @{text "raw_thm \<longrightarrow> reg_thm"}, we always
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1060
  start with an implication. Isabelle provides \emph{mono} rules that can split up
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1061
  the implications into simpler implicational subgoals. This succeeds for every
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1062
  monotone connective, except in places where the function @{text REG} replaced,
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1063
  for instance, a quantifier by a bounded quantifier. To decompose them, we have
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1064
  to prove that the relations involved are aggregate equivalence relations.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1065
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1066
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1067
  %In this case we have
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1068
  %rules of the form
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1069
  %
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1070
  % \begin{isabelle}\ \ \ \ \ %%%
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1071
  %@{text "(\<forall>x. R x \<longrightarrow> (P x \<longrightarrow> Q x)) \<longrightarrow> (\<forall>x. P x \<longrightarrow> \<forall>x \<in> R. Q x)"}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1072
  %\end{isabelle}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1073
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1074
  %\noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1075
  %They decompose a bounded quantifier on the right-hand side. We can decompose a
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1076
  %bounded quantifier anywhere if R is an equivalence relation or
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1077
  %if it is a relation over function types with the range being an equivalence
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1078
  %relation. If @{text R} is an equivalence relation we can prove that
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1079
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1080
  %\begin{isabelle}\ \ \ \ \ %%%
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1081
  %@{text "\<forall>x \<in> Resp R. P x = \<forall>x. P x"}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1082
  %\end{isabelle}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1083
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1084
  %\noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1085
  %If @{term R\<^isub>2} is an equivalence relation, we can prove that for any predicate @{term P}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1086
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1087
%%% FIXME Reviewer 1 claims the theorem is obviously false so maybe we
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1088
%%% should include a proof sketch?
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1089
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1090
  %\begin{isabelle}\ \ \ \ \ %%%
3118
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3115
diff changeset
  1091
  %@{thm (concl) ball_reg_eqv_range[of R\<^isub>1 R\<^isub>2]}
3082
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1092
  %\end{isabelle}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1093
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1094
  %\noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1095
  %The last theorem is new in comparison with Homeier's package. There the
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1096
  %injection procedure would be used to prove such goals and
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1097
  %the assumption about the equivalence relation would be used. We use the above theorem directly,
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1098
  %because this allows us to completely separate the first and the second
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1099
  %proof step into two independent ``units''.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1100
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1101
  The second phase, establishing @{text "reg_thm \<longleftrightarrow> inj_thm"},  starts with an equality
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1102
  between the terms of the regularized theorem and the injected theorem.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1103
  The proof again follows the structure of the
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1104
  two underlying terms taking respectfulness theorems into account.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1105
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1106
  %\begin{itemize}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1107
  %\item For two constants an appropriate respectfulness theorem is applied.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1108
  %\item For two variables, we use the assumptions proved in the regularization step.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1109
  %\item For two abstractions, we @{text "\<eta>"}-expand and @{text "\<beta>"}-reduce them.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1110
  %\item For two applications, we check that the right-hand side is an application of
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1111
  %  @{term Rep} to an @{term Abs} and @{term "Quotient R Rep Abs"} holds. If yes then we
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1112
  %  can apply the theorem:
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1113
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1114
  %\begin{isabelle}\ \ \ \ \ %%%
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1115
  %  @{term "R x y \<longrightarrow> R x (Rep (Abs y))"}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1116
  %\end{isabelle}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1117
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1118
  %  Otherwise we introduce an appropriate relation between the subterms
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1119
  %  and continue with two subgoals using the lemma:
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1120
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1121
  %\begin{isabelle}\ \ \ \ \ %%%
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1122
  %  @{text "(R\<^isub>1 \<doublearr> R\<^isub>2) f g \<longrightarrow> R\<^isub>1 x y \<longrightarrow> R\<^isub>2 (f x) (g y)"}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1123
  %\end{isabelle}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1124
  %\end{itemize}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1125
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1126
  We defined the theorem @{text "inj_thm"} in such a way that
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1127
  establishing in the third phase the equivalence @{text "inj_thm \<longleftrightarrow> quot_thm"} can be
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1128
  achieved by rewriting @{text "inj_thm"} with the preservation theorems and quotient
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1129
  definitions. This step also requires that the definitions of all lifted constants
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1130
  are used to fold the @{term Rep} with the raw constants. We will give more details
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1131
  about our lifting procedure in a longer version of this paper.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1132
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1133
  %Next for
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1134
  %all abstractions and quantifiers the lambda and
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1135
  %quantifier preservation theorems are used to replace the
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1136
  %variables that include raw types with respects by quantifiers
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1137
  %over variables that include quotient types. We show here only
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1138
  %the lambda preservation theorem. Given
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1139
  %@{term "Quotient R\<^isub>1 Abs\<^isub>1 Rep\<^isub>1"} and @{term "Quotient R\<^isub>2 Abs\<^isub>2 Rep\<^isub>2"}, we have:
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1140
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1141
  %\begin{isabelle}\ \ \ \ \ %%%
3118
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3115
diff changeset
  1142
  %@{thm (concl) lambda_prs[of _ "Abs\<^isub>1" "Rep\<^isub>1" _ "Abs\<^isub>2" "Rep\<^isub>2"]}
3082
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1143
  %\end{isabelle}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1144
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1145
  %\noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1146
  %Next, relations over lifted types can be rewritten to equalities
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1147
  %over lifted type. Rewriting is performed with the following theorem,
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1148
  %which has been shown by Homeier~\cite{Homeier05}:
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1149
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1150
  %\begin{isabelle}\ \ \ \ \ %%%
3118
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3115
diff changeset
  1151
  %@{thm (concl) Quotient_rel_rep}
3082
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1152
  %\end{isabelle}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1153
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1154
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1155
  %Finally, we rewrite with the preservation theorems. This will result
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1156
  %in two equal terms that can be solved by reflexivity.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1157
*}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1158
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1159
section {* Conclusion and Related Work\label{sec:conc}*}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1160
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1161
text {*
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1162
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1163
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1164
  The code of the quotient package and the examples described here are already
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1165
  included in the standard distribution of Isabelle.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1166
  \footnote{Available from \href{http://isabelle.in.tum.de/}{http://isabelle.in.tum.de/}.}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1167
  The package is
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1168
  heavily used in the new version of Nominal Isabelle, which provides a
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1169
  convenient reasoning infrastructure for programming language calculi
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1170
  involving general binders.  To achieve this, it builds types representing
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1171
  @{text \<alpha>}-equivalent terms.  Earlier versions of Nominal Isabelle have been
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1172
  used successfully in formalisations of an equivalence checking algorithm for
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1173
  LF \cite{UrbanCheneyBerghofer08}, Typed
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1174
  Scheme~\cite{TobinHochstadtFelleisen08}, several calculi for concurrency
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1175
  \cite{BengtsonParow09} and a strong normalisation result for cut-elimination
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1176
  in classical logic \cite{UrbanZhu08}.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1177
3094
8bad9887ad90 moved TODO into the paper
Christian Urban <urbanc@in.tum.de>
parents: 3092
diff changeset
  1178
  {\bf INSTEAD OF NOMINAL WORK, GIVE WORK BY BULWAHN ET AL?}
3082
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1179
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1180
  There is a wide range of existing literature for dealing with quotients
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1181
  in theorem provers.  Slotosch~\cite{Slotosch97} implemented a mechanism that
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1182
  automatically defines quotient types for Isabelle/HOL. But he did not
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1183
  include theorem lifting.  Harrison's quotient package~\cite{harrison-thesis}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1184
  is the first one that is able to automatically lift theorems, however only
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1185
  first-order theorems (that is theorems where abstractions, quantifiers and
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1186
  variables do not involve functions that include the quotient type). There is
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1187
  also some work on quotient types in non-HOL based systems and logical
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1188
  frameworks, including theory interpretations in
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1189
  PVS~\cite{PVS:Interpretations}, new types in MetaPRL~\cite{Nogin02}, and
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1190
  setoids in Coq \cite{ChicliPS02}.  Paulson showed a construction of
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1191
  quotients that does not require the Hilbert Choice operator, but also only
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1192
  first-order theorems can be lifted~\cite{Paulson06}.  The most related work
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1193
  to our package is the package for HOL4 by Homeier~\cite{Homeier05}.  He
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1194
  introduced most of the abstract notions about quotients and also deals with
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1195
  lifting of higher-order theorems. However, he cannot deal with quotient
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1196
  compositions (needed for lifting theorems about @{text flat}). Also, a
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1197
  number of his definitions, like @{text ABS}, @{text REP} and @{text INJ} etc
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1198
  only exist in \cite{Homeier05} as ML-code, not included in the paper.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1199
  Like Homeier's, our quotient package can deal with partial equivalence
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1200
  relations, but for lack of space we do not describe the mechanisms
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1201
  needed for this kind of quotient constructions.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1202
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1203
%%% FIXME Reviewer 3 would like to know more about the lifting in Coq and PVS,
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1204
%%% and some comparison. I don't think we have the space for any additions...
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1205
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1206
  One feature of our quotient package is that when lifting theorems, the user
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1207
  can precisely specify what the lifted theorem should look like. This feature
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1208
  is necessary, for example, when lifting an induction principle for two
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1209
  lists.  Assuming this principle has as the conclusion a predicate of the
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1210
  form @{text "P xs ys"}, then we can precisely specify whether we want to
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1211
  quotient @{text "xs"} or @{text "ys"}, or both. We found this feature very
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1212
  useful in the new version of Nominal Isabelle, where such a choice is
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1213
  required to generate a reasoning infrastructure for alpha-equated terms.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1214
%%
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1215
%% give an example for this
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1216
%%
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1217
  \smallskip
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1218
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1219
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1220
  {\bf Acknowledgements:} We would like to thank Peter Homeier for the many
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1221
  discussions about his HOL4 quotient package and explaining to us
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1222
  some of its finer points in the implementation. Without his patient
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1223
  help, this work would have been impossible.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1224
*}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1225
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1226
text_raw {*
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1227
  %%\bibliographystyle{abbrv}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1228
  \bibliography{root}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1229
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1230
  \appendix
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1231
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1232
*}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1233
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1234
section {* Examples \label{sec:examples} *}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1235
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1236
text {*
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1237
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1238
%%% FIXME Reviewer 1 would like an example of regularized and injected
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1239
%%% statements. He asks for the examples twice, but I would still ignore
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1240
%%% it due to lack of space...
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1241
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1242
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1243
  In this appendix we will show a sequence of declarations for defining the
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1244
  type of integers by quotienting pairs of natural numbers, and
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1245
  lifting one theorem.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1246
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1247
  A user of our quotient package first needs to define a relation on
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1248
  the raw type with which the quotienting will be performed. We give
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1249
  the same integer relation as the one presented in \eqref{natpairequiv}:
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1250
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1251
  \begin{isabelle}\ \ \ \ \ %
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1252
  \begin{tabular}{@ {}l}
3114
a9a4baa7779f 2 typos found by John Wickerson in QPaper
Christian Urban <urbanc@in.tum.de>
parents: 3094
diff changeset
  1253
  \isacommand{fun}~~@{text "int_rel :: (nat \<times> nat) \<Rightarrow> (nat \<times> nat) \<Rightarrow> bool"}\\
3082
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1254
  \isacommand{where}~~@{text "int_rel (m, n) (p, q) = (m + q = n + p)"}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1255
  \end{tabular}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1256
  \end{isabelle}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1257
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1258
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1259
  Next the quotient type must be defined. This generates a proof obligation that the
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1260
  relation is an equivalence relation, which is solved automatically using the
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1261
  definition of equivalence and extensionality:
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1262
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1263
  \begin{isabelle}\ \ \ \ \ %
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1264
  \begin{tabular}{@ {}l}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1265
  \isacommand{quotient\_type}~~@{text "int"}~~\isacommand{=}~~@{text "(nat \<times> nat)"}~~\isacommand{/}~~@{text "int_rel"}\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1266
  \hspace{5mm}@{text "by (auto simp add: equivp_def expand_fun_eq)"}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1267
  \end{tabular}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1268
  \end{isabelle}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1269
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1270
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1271
  The user can then specify the constants on the quotient type:
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1272
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1273
  \begin{isabelle}\ \ \ \ \ %
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1274
  \begin{tabular}{@ {}l}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1275
  \isacommand{quotient\_definition}~~@{text "0 :: int"}~~\isacommand{is}~~@{text "(0 :: nat, 0 :: nat)"}\\[3mm]
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1276
  \isacommand{fun}~~@{text "add_pair"}\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1277
  \isacommand{where}~~%
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1278
  @{text "add_pair (m, n) (p, q) \<equiv> (m + p :: nat, n + q :: nat)"}\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1279
  \isacommand{quotient\_definition}~~@{text "+ :: int \<Rightarrow> int \<Rightarrow> int"}~~%
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1280
  \isacommand{is}~~@{text "add_pair"}\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1281
  \end{tabular}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1282
  \end{isabelle}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1283
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1284
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1285
  The following theorem about addition on the raw level can be proved.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1286
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1287
  \begin{isabelle}\ \ \ \ \ %
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1288
  \isacommand{lemma}~~@{text "add_pair_zero: int_rel (add_pair (0, 0) x) x"}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1289
  \end{isabelle}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1290
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1291
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1292
  If the user lifts this theorem, the quotient package performs all the lifting
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1293
  automatically leaving the respectfulness proof for the constant @{text "add_pair"}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1294
  as the only remaining proof obligation. This property needs to be proved by the user:
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1295
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1296
  \begin{isabelle}\ \ \ \ \ %
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1297
  \begin{tabular}{@ {}l}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1298
  \isacommand{lemma}~~@{text "[quot_respect]:"}\\
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1299
  @{text "(int_rel \<doublearr> int_rel \<doublearr> int_rel) add_pair add_pair"}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1300
  \end{tabular}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1301
  \end{isabelle}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1302
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1303
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1304
  It can be discharged automatically by Isabelle when hinting to unfold the definition
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1305
  of @{text "\<doublearr>"}.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1306
  After this, the user can prove the lifted lemma as follows:
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1307
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1308
  \begin{isabelle}\ \ \ \ \ %
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1309
  \isacommand{lemma}~~@{text "0 + (x :: int) = x"}~~\isacommand{by}~~@{text "lifting add_pair_zero"}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1310
  \end{isabelle}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1311
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1312
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1313
  or by using the completely automated mode stating just:
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1314
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1315
  \begin{isabelle}\ \ \ \ \ %
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1316
  \isacommand{thm}~~@{text "add_pair_zero[quot_lifted]"}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1317
  \end{isabelle}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1318
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1319
  \noindent
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1320
  Both methods give the same result, namely @{text "0 + x = x"}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1321
  where @{text x} is of type integer.
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1322
  Although seemingly simple, arriving at this result without the help of a quotient
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1323
  package requires a substantial reasoning effort (see \cite{Paulson06}).
3094
8bad9887ad90 moved TODO into the paper
Christian Urban <urbanc@in.tum.de>
parents: 3092
diff changeset
  1324
8bad9887ad90 moved TODO into the paper
Christian Urban <urbanc@in.tum.de>
parents: 3092
diff changeset
  1325
  {\bf \begin{itemize}
3119
ed0196555690 qpaper-jv: merge and add to TODOs in the paper and in front.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3118
diff changeset
  1326
  \item explain how Quotient R Abs Rep is proved
3094
8bad9887ad90 moved TODO into the paper
Christian Urban <urbanc@in.tum.de>
parents: 3092
diff changeset
  1327
  \item Type maps and Relation maps (show the case for functions)
3119
ed0196555690 qpaper-jv: merge and add to TODOs in the paper and in front.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3118
diff changeset
  1328
  \item Quotient extensions (quot\_thms)
3094
8bad9887ad90 moved TODO into the paper
Christian Urban <urbanc@in.tum.de>
parents: 3092
diff changeset
  1329
  \item Respectfulness and preservation
8bad9887ad90 moved TODO into the paper
Christian Urban <urbanc@in.tum.de>
parents: 3092
diff changeset
  1330
  - Show special cases for quantifiers and lambda
3119
ed0196555690 qpaper-jv: merge and add to TODOs in the paper and in front.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3118
diff changeset
  1331
  - How do prs theorems look like for quotient compositions
3094
8bad9887ad90 moved TODO into the paper
Christian Urban <urbanc@in.tum.de>
parents: 3092
diff changeset
  1332
  \item Quotient-type locale
8bad9887ad90 moved TODO into the paper
Christian Urban <urbanc@in.tum.de>
parents: 3092
diff changeset
  1333
  - Show the proof as much simpler than Homeier's one
8bad9887ad90 moved TODO into the paper
Christian Urban <urbanc@in.tum.de>
parents: 3092
diff changeset
  1334
  \item ??? Infrastructure for storing theorems (rsp, prs, eqv, quot and idsimp)
8bad9887ad90 moved TODO into the paper
Christian Urban <urbanc@in.tum.de>
parents: 3092
diff changeset
  1335
  \item Lifting vs Descending vs quot\_lifted
3119
ed0196555690 qpaper-jv: merge and add to TODOs in the paper and in front.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3118
diff changeset
  1336
  - Mention Andreas Lochbiler in Acknowledgements
3094
8bad9887ad90 moved TODO into the paper
Christian Urban <urbanc@in.tum.de>
parents: 3092
diff changeset
  1337
  - automatic theorem translation heuristic
8bad9887ad90 moved TODO into the paper
Christian Urban <urbanc@in.tum.de>
parents: 3092
diff changeset
  1338
  \item Partial equivalence quotients
8bad9887ad90 moved TODO into the paper
Christian Urban <urbanc@in.tum.de>
parents: 3092
diff changeset
  1339
  - Bounded abstraction
8bad9887ad90 moved TODO into the paper
Christian Urban <urbanc@in.tum.de>
parents: 3092
diff changeset
  1340
  - Respects
8bad9887ad90 moved TODO into the paper
Christian Urban <urbanc@in.tum.de>
parents: 3092
diff changeset
  1341
  - partial descending
8bad9887ad90 moved TODO into the paper
Christian Urban <urbanc@in.tum.de>
parents: 3092
diff changeset
  1342
  \item The heuristics for automatic regularization, injection and cleaning.
8bad9887ad90 moved TODO into the paper
Christian Urban <urbanc@in.tum.de>
parents: 3092
diff changeset
  1343
  \item A complete example of a lifted theorem together with the regularized
8bad9887ad90 moved TODO into the paper
Christian Urban <urbanc@in.tum.de>
parents: 3092
diff changeset
  1344
  injected and cleaned statement
8bad9887ad90 moved TODO into the paper
Christian Urban <urbanc@in.tum.de>
parents: 3092
diff changeset
  1345
  \item Examples of quotients and properties that we used the package for.
8bad9887ad90 moved TODO into the paper
Christian Urban <urbanc@in.tum.de>
parents: 3092
diff changeset
  1346
  \item co/contra-variance from Ondrej should be taken into account
3119
ed0196555690 qpaper-jv: merge and add to TODOs in the paper and in front.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3118
diff changeset
  1347
  \item give an example where precise specification of goal is necessary
ed0196555690 qpaper-jv: merge and add to TODOs in the paper and in front.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3118
diff changeset
  1348
  \item mention multiple map\_prs2 theorems for compositional quotients
3094
8bad9887ad90 moved TODO into the paper
Christian Urban <urbanc@in.tum.de>
parents: 3092
diff changeset
  1349
  \end{itemize}}
3082
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1350
*}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1351
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1352
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1353
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1354
(*<*)
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1355
end
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1356
(*>*)