Quotient-Paper-jv/Paper.thy
author Christian Urban <urbanc@in.tum.de>
Thu, 12 Apr 2012 01:39:54 +0100
changeset 3159 8bda1d947df3
parent 3156 80e2fb39332b
permissions -rw-r--r--
another iteration of the lmcs paper
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
3151
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
    46
fun add_pair :: "(nat \<times> nat) \<Rightarrow> (nat \<times> nat) \<Rightarrow> (nat \<times> nat)" 
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
    47
where "add_pair (n1, m1) (n2, m2) = (n1 + n2, m1 + m2)"
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
    48
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
    49
fun minus_pair :: "(nat \<times> nat) \<Rightarrow> (nat \<times> nat)" 
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
    50
where "minus_pair (n, m) = (m, n)"
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
    51
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
    52
fun
3156
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
    53
  intrel :: "(nat \<times> nat) \<Rightarrow> (nat \<times> nat) \<Rightarrow> bool" ("_ \<approx> _" [50, 50] 50) 
3151
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
    54
where
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
    55
  "intrel (x, y) (u, v) = (x + v = u + y)"
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
    56
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
    57
(*>*)
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    58
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    59
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
    60
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    61
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
    62
  \noindent
3136
d003938cc952 slight tuning of Q-paper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3125
diff changeset
    63
  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
    64
  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
    65
  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
    66
  establish a convenient reasoning infrastructure for quotient
d003938cc952 slight tuning of Q-paper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3125
diff changeset
    67
  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
    68
  (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
    69
  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
    70
  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
    71
  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
    72
  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
    73
  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
    74
  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
    75
  \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
    76
  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
    77
  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
    78
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    79
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    80
  \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
    81
  @{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
    82
  \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
    83
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    84
  \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
    85
  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
    86
  "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
    87
  natural numbers (namely @{text "(0, 0)"} and @{text "(1, 0)"}). Operations
3151
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
    88
  such as @{text "add"} with type @{typ "int \<Rightarrow> int \<Rightarrow> int"} can be defined 
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
    89
  in terms of operations on pairs of natural numbers:
3094
8bad9887ad90 moved TODO into the paper
Christian Urban <urbanc@in.tum.de>
parents: 3092
diff changeset
    90
8bad9887ad90 moved TODO into the paper
Christian Urban <urbanc@in.tum.de>
parents: 3092
diff changeset
    91
  \begin{isabelle}\ \ \ \ \ %%%
3151
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
    92
  @{thm add_pair.simps[where ?n1.0="n\<^isub>1" and ?n2.0="n\<^isub>2" and ?m1.0="m\<^isub>1" and ?m2.0="m\<^isub>2", THEN eq_reflection]}%
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
    93
  \hfill\numbered{addpair}
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
    94
  \end{isabelle}
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
    95
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
    96
  \noindent
3156
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
    97
  Negation on integers is defined in terms of swapping of pairs:
3151
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
    98
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
    99
  \begin{isabelle}\ \ \ \ \ %%%
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   100
  @{thm minus_pair.simps[where ?n="n" and ?m="m", THEN eq_reflection]}%
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   101
  \hfill\numbered{minuspair}
3094
8bad9887ad90 moved TODO into the paper
Christian Urban <urbanc@in.tum.de>
parents: 3092
diff changeset
   102
  \end{isabelle}
8bad9887ad90 moved TODO into the paper
Christian Urban <urbanc@in.tum.de>
parents: 3092
diff changeset
   103
8bad9887ad90 moved TODO into the paper
Christian Urban <urbanc@in.tum.de>
parents: 3092
diff changeset
   104
  \noindent
3136
d003938cc952 slight tuning of Q-paper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3125
diff changeset
   105
  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
   106
  "\<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
   107
  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
   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
  \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
   110
  @{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
   111
  \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
   112
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   113
  \noindent
3136
d003938cc952 slight tuning of Q-paper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3125
diff changeset
   114
  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
   115
  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
   116
  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
   117
  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
   118
  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
   119
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   120
  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
   121
  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
   122
  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
   123
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   124
  \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
   125
  @{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
   126
  \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
   127
a6b0220fb8ae 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
  \noindent
3136
d003938cc952 slight tuning of Q-paper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3125
diff changeset
   129
  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
   130
  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
   131
  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
   132
  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
   133
  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
   134
  ``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
   135
  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
   136
  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
   137
  infrastructure provided, for example, by Nominal Isabelle
d003938cc952 slight tuning of Q-paper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3125
diff changeset
   138
  \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
   139
  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
   140
  $\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
   141
  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
   142
3151
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   143
  There is also often a need to consider quotients of parial equivalence relations. For 
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   144
  example the rational numbers
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   145
  can be constructed using pairs of integers and the partial equivalence relation
3092
ff377f9d030a some slight tuning
Christian Urban <urbanc@in.tum.de>
parents: 3082
diff changeset
   146
3151
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   147
  \begin{isabelle}\ \ \ \ \ %%%
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   148
  @{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{ratpairequiv}
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   149
  \end{isabelle}
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   150
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   151
  \noindent
3156
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   152
  where @{text "n\<^isub>2"} and @{text "m\<^isub>2"} are not allowed to be zero.
3092
ff377f9d030a some slight tuning
Christian Urban <urbanc@in.tum.de>
parents: 3082
diff changeset
   153
3151
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   154
  The difficulty is that in order to be able to reason about integers,
3156
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   155
  finite sets, etc.~one needs to establish a reasoning infrastructure
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   156
  by transferring, or \emph{lifting}, definitions and theorems from
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   157
  the raw type @{typ "nat \<times> nat"} to the quotient type @{typ int}
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   158
  (similarly for finite sets, $\alpha$-equated lambda-terms and
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   159
  rational numbers). This lifting usually requires a reasoning effort
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   160
  that can be rather repetitive and involves explicit conversions 
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   161
  between the quotient and raw level in form of abstraction and 
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   162
  representation functions \cite{Paulson06}.  In principle it is feasible to do this
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   163
  work manually if one has only a few quotient constructions at
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   164
  hand. But if they have to be done over and over again, as in Nominal
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   165
  Isabelle, then manual reasoning is not an option.
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
   166
3156
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   167
  The purpose of a \emph{quotient package} is to ease the lifting of
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   168
  theorems and automate the reasoning as much as possible. Before we
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   169
  delve into the details, let us show how the user interacts with our
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   170
  quotient package when defining integers. We assume the definitions
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   171
  involving pairs of natural numbers shown in \eqref{natpairequiv},
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   172
  \eqref{addpair} and \eqref{minuspair} have already been made. A
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   173
  quotient can then be introduced by declaring the new type (in this case
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   174
  @{typ int}), the raw type (that is @{typ "nat \<times> nat"}) and the
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   175
  equivalence relation (that is @{text intrel} defined in
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   176
  \eqref{natpairequiv}).
3151
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   177
*}
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   178
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   179
  quotient_type int = "nat \<times> nat" / intrel
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   180
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   181
txt {*
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   182
  \noindent
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   183
  This declaration requires the user to prove that @{text intrel} is
3156
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   184
  indeed an equivalence relation, whereby an equivalence 
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   185
  relation is defined as one that is reflexive, symmetric and
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   186
  transitive.  This proof obligation can thus be discharged by
3151
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   187
  unfolding the definitions and using the standard automatic proving
3156
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   188
  tactic in Isabelle/HOL.
3151
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   189
*}
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   190
    unfolding equivp_reflp_symp_transp
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   191
    unfolding reflp_def symp_def transp_def
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   192
    by auto
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   193
(*<*)
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   194
    instantiation int :: "{zero, one, plus, uminus}"
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   195
    begin
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   196
(*>*)
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   197
text {*
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   198
  \noindent
3156
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   199
  Next we can declare the constants @{text "0"} and @{text "1"} for the 
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   200
  quotient type @{text int}.
3151
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   201
*}
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   202
    quotient_definition
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   203
      "0 \<Colon> int"  is  "(0\<Colon>nat, 0\<Colon>nat)" .
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   204
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   205
    quotient_definition
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   206
      "1 \<Colon> int"  is  "(1\<Colon>nat, 0\<Colon>nat)" .
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   207
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   208
text {*
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   209
  \noindent
3156
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   210
  To be useful, we can also need declare two operations for adding two
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   211
  integers (written @{text plus}) and negating an integer
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   212
  (written @{text "uminus"}).
3151
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   213
*}
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   214
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   215
    quotient_definition
3156
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   216
      "plus \<Colon> int \<Rightarrow> int \<Rightarrow> int"  is  add_pair 
3151
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   217
      by auto
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   218
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   219
    quotient_definition
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   220
      "uminus \<Colon> int \<Rightarrow> int"  is  minus_pair 
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   221
      by auto
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   222
(*<*)    
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   223
    instance ..
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   224
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   225
    end
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   226
(*>*)
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   227
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   228
text {*
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   229
  \noindent
3156
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   230
  Isabelle/HOL can introduce some convenient short-hand notation for these
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   231
  operations allowing the user to write
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   232
  addition as infix operation, for example @{text "i + j"}, and
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   233
  negation as prefix operation, for example @{text "- i"}.  In both
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   234
  cases, however, the declaration requires the user to discharge a
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   235
  proof-obligation which ensures that the operations a
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   236
  \emph{respectful}. This property ensures that the operations are
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   237
  well-defined on the quotient level (a formal definition of
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   238
  respectfulness will be given later). Both proofs can be solved by
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   239
  the automatic proving tactic in Isabelle/HOL.
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   240
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   241
  Besides helping with declarations of quotient types and definitions 
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   242
  of constants, the point of a quotient package is to help with 
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   243
  proving properties about quotient types. For example we might be
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   244
  interested in the usual property that zero is an ???. This property 
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   245
  can be stated as follows:
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   246
*}
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   247
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   248
     lemma zero_add:
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   249
       shows "0 + i = (i::int)"
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   250
     proof(descending)
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   251
txt {*
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   252
  \noindent 
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   253
  The tactic @{text "descending"} automatically transfers this property of integers
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   254
  to a proof-obligation involving pairs of @{typ nat}s. (There is also
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   255
  a tactic, called @{text lifting}, which automatically transfers properties
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   256
  from the raw level to the quotient type.) In case of lemma @{text "zero_add"}
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   257
  we obtain the subgoal
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   258
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   259
  \begin{isabelle}\ \ \ \ \ %%%
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   260
  @{text "add_pair (0, 0) i \<approx> i"}
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   261
  \end{isabelle}
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   262
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   263
  \noindent
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   264
  which can be solved again by the automatic proving tactic @{text "auto"}, as follows
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   265
*}
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   266
     qed(auto)
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   267
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   268
text {*
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   269
  In this simple example the task of the user is to state the property for integers
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   270
  and use the quotient package and automatic proving tools of Isabelle/HOL to do
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   271
  the ``rest''. A more interesting example is to establish an induction principle for 
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   272
  integers. For this we first establish the following induction principle where the 
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   273
  induction proceeds over two natural numbers. 
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   274
*}
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   275
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   276
    lemma nat_induct2:
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   277
      assumes "P 0 0"
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   278
      and     "\<And>n m. P n m \<Longrightarrow> P (Suc n) m"
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   279
      and     "\<And>n m. P n m \<Longrightarrow> P n (Suc m)"
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   280
      shows   "P n m"
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   281
      using assms
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   282
      by (induction_schema) (pat_completeness, lexicographic_order)
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   283
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   284
text {*
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   285
  \noindent
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   286
  The symbol @{text "\<And>"} stands for Isabelle/HOL's universal quantifier and
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   287
  @{text "\<Longrightarrow>"} for its implication.
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   288
  As can be seen, this induction principle can be conveniently established using the
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   289
  reasoning infrastructure of the function package \cite{???}, which 
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   290
  provides the tactics @{text "induction_schema"}, @{text "pat_completeness"}
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   291
  and @{text "lexicographic_order"}. These tactics enable Isabelle/HOL
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   292
  to use well-founded induction to prove @{text "nat_induct2"}. Our 
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   293
  quotient package can now be used to prove the following property:
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   294
*}
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   295
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   296
    lemma int_induct:
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   297
      assumes "P 0"
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   298
      and     "\<And>i. P i \<Longrightarrow> P (i + 1)"
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   299
      and     "\<And>i. P i \<Longrightarrow> P (i + (- 1))"
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   300
      shows   "P (j::int)"
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   301
      using assms 
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   302
      proof (descending)
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   303
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   304
txt {*
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   305
  \noindent
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   306
  The @{text descending} tactic transfers it to the following proof 
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   307
  obligation on the raw level.
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   308
  
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   309
  @{subgoals[display]}
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   310
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   311
  \noindent
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   312
  Note that the variable @{text "j"} in this subgoal is of type
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   313
  @{text "nat \<times> nat"}. This subgoal cannot be proved automatically by 
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   314
  @{text auto}, but if we give it the hint to use @{text nat_induct2},
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   315
  then @{text auto} can discharge it as follows.
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   316
  
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   317
*}
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   318
       qed (auto intro: nat_induct2)
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   319
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   320
text {*
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   321
  This completes the proof of the induction principle
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   322
  for integers. Isabelle/HOL would allow us to inspect the 
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   323
  detailed reasoning steps involved which would confirm that
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   324
  @{text "int_induct"} has been proved from ``first-principles''
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   325
  by transforming the property over the quotient type @{text int}
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   326
  to a corresponding property one on the raw level.
80e2fb39332b slight polishing on Quotient paper
Christian Urban <urbanc@in.tum.de>
parents: 3151
diff changeset
   327
3151
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   328
16e6140225af a bit more on the qpaper
Christian Urban <urbanc@in.tum.de>
parents: 3137
diff changeset
   329
  In the
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
   330
  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
   331
  \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
   332
  \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
   333
  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
   334
a6b0220fb8ae 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
%%% 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
   336
%%% 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
   337
%%% 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
   338
%%% 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
   339
a6b0220fb8ae 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
%%% 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
   341
%%% 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
   342
a6b0220fb8ae 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
  \begin{center}
3125
860df8e1262f slight polish of the qpaper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3119
diff changeset
   344
  \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
   345
  %%\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
   346
a6b0220fb8ae 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
  \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
   348
  \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
   349
  \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
   350
a6b0220fb8ae 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
  \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
   352
  \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
   353
a6b0220fb8ae 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
  \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
   355
  \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
   356
  \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
   357
    {\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
   358
  \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
   359
a6b0220fb8ae 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
  \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
   361
  \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
   362
  \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
   363
  \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
   364
  \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
   365
  \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
   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
  \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
   368
  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
   369
  \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
   370
  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
   371
  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
   372
  \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
   373
  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
   374
  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
   375
  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
   376
  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
   377
  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
   378
  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
   379
  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
   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
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   382
  \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
   383
  @{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
   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
  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
   388
  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
   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
  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
   391
  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
   392
  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
   393
  "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
   394
a6b0220fb8ae 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
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   396
  \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
   397
  @{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
   398
  \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
   399
a6b0220fb8ae 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
  \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
   401
  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
   402
  @{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
   403
a6b0220fb8ae 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
  \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
   405
  @{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
   406
  \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
   407
  \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
   408
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   409
  \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
   410
  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
   411
  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
   412
  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
   413
  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
   414
  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
   415
  \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
   416
  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
   417
  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
   418
a6b0220fb8ae 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
  \begin{isabelle}\ \ \ \ \ %%%
3125
860df8e1262f slight polish of the qpaper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3119
diff changeset
   420
  \begin{tabular}{@ {}l}
860df8e1262f slight polish of the qpaper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3119
diff changeset
   421
  @{thm concat.simps(1)[THEN eq_reflection]}\\
860df8e1262f slight polish of the qpaper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3119
diff changeset
   422
  @{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
   423
  \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
   424
  \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
   425
a6b0220fb8ae 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
  \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
   427
  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
   428
  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
   429
  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
   430
  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
   431
a6b0220fb8ae 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
  \begin{isabelle}\ \ \ \ \ %%%
3125
860df8e1262f slight polish of the qpaper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3119
diff changeset
   433
  \begin{tabular}{@ {}l}
860df8e1262f slight polish of the qpaper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3119
diff changeset
   434
  @{thm concat_empty_fset[THEN eq_reflection]}\\
860df8e1262f slight polish of the qpaper-jv
Christian Urban <urbanc@in.tum.de>
parents: 3119
diff changeset
   435
  @{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
   436
  \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
   437
  \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
   438
a6b0220fb8ae 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
  \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
   440
  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
   441
  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
   442
  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
   443
  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
   444
  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
   445
  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
   446
a6b0220fb8ae 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
  \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
   448
  @{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
   449
  \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
   450
a6b0220fb8ae 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
  \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
   452
  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
   453
  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
   454
  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
   455
  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
   456
  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
   457
  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
   458
  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
   459
  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
   460
a6b0220fb8ae 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
  \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
   462
  @{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
   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
  \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
   466
  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
   467
  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
   468
  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
   469
  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
   470
  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
   471
  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
   472
  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
   473
  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
   474
3118
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3115
diff changeset
   475
  {\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
   476
3137
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
   477
%%%TODO Update the contents.
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
   478
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
   479
  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
   480
  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
   481
  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
   482
  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
   483
  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
   484
  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
   485
  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
   486
  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
   487
  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
   488
  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
   489
  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
   490
*}
a6b0220fb8ae 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
3092
ff377f9d030a some slight tuning
Christian Urban <urbanc@in.tum.de>
parents: 3082
diff changeset
   492
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
   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
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
   495
  \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
   496
  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
   497
  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
   498
a6b0220fb8ae 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
  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
   500
  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
   501
  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
   502
  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
   503
a6b0220fb8ae 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
  \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
   505
  \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
   506
  @{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
   507
  @{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
   508
  \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
   509
  \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
   510
a6b0220fb8ae 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
  \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
   512
  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
   513
  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
   514
  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
   515
  @{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
   516
  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
   517
  "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
   518
  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
   519
  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
   520
  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
   521
  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
   522
a6b0220fb8ae 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
  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
   524
  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
   525
  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
   526
  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
   527
  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
   528
a6b0220fb8ae 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
  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
   530
  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
   531
  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
   532
  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
   533
a6b0220fb8ae 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
  \begin{isabelle}\ \ \ \ \ %%%
3118
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3115
diff changeset
   535
  @{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
   536
  \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
   537
a6b0220fb8ae 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
  \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
   539
  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
   540
  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
   541
a6b0220fb8ae 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
  \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
   543
  @{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
   544
  \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
   545
a6b0220fb8ae 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
  \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
   547
  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
   548
  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
   549
  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
   550
  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
   551
  %% 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
   552
  %% 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
   553
  %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
   554
  %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
   555
  %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
   556
  %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
   557
  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
   558
  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
   559
a6b0220fb8ae 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
  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
   561
  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
   562
  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
   563
  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
   564
  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
   565
a6b0220fb8ae 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
  \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
   567
  @{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
   568
  \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
   569
a6b0220fb8ae 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
  \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
   571
  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
   572
  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
   573
  %
a6b0220fb8ae 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
  \begin{isabelle}\ \ \ \ \ %%%
3118
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3115
diff changeset
   575
  @{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
   576
  \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
   577
  \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
   578
a6b0220fb8ae 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
  \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
   580
  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
   581
  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
   582
a6b0220fb8ae 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{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
   584
  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
   585
  \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
   586
a6b0220fb8ae 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
  \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
   588
  @{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
   589
  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
   590
  \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
   591
a6b0220fb8ae 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
  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
   593
  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
   594
a6b0220fb8ae 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
  \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
   596
  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
   597
  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
   598
  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
   599
  \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
   600
  \begin{tabular}{rl}
3118
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3115
diff changeset
   601
  (i) & \begin{isa}@{thm (rhs1) Quotient_def[of "R"]}\end{isa}\\
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3115
diff changeset
   602
  (ii) & \begin{isa}@{thm (rhs2) Quotient_def[of "R"]}\end{isa}\\
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3115
diff changeset
   603
  (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
   604
  \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
   605
  \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
   606
  \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
   607
a6b0220fb8ae 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
  \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
   609
  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
   610
  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
   611
  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
   612
  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
   613
  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
   614
a6b0220fb8ae 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{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
   616
  \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
   617
  @{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
   618
      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
   619
  \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
   620
  \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
   621
a6b0220fb8ae 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
  \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
   623
  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
   624
  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
   625
  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
   626
  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
   627
  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
   628
  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
   629
a6b0220fb8ae 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
%%% 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
   631
%%% 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
   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
  \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
   634
  @{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
   635
  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
   636
  @{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
   637
  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
   638
  @{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
   639
  \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
   640
a6b0220fb8ae 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
  \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
   642
  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
   643
  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
   644
  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
   645
  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
   646
  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
   647
  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
   648
  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
   649
  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
   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
  \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
   652
  \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
   653
  @{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
   654
                  & @{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
   655
  \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
   656
  \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
   657
*}
a6b0220fb8ae 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
3092
ff377f9d030a some slight tuning
Christian Urban <urbanc@in.tum.de>
parents: 3082
diff changeset
   659
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
   660
a6b0220fb8ae 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
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
   662
  \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
   663
  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
   664
  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
   665
  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
   666
  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
   667
  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
   668
a6b0220fb8ae 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
  \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
   670
  \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
   671
  \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
   672
a6b0220fb8ae 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
  \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
   674
  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
   675
  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
   676
  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
   677
  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
   678
a6b0220fb8ae 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
a6b0220fb8ae 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
  \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
   681
  \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
   682
  \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
   683
  \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
   684
  \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
   685
  \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
   686
a6b0220fb8ae 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
  \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
   688
  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
   689
  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
   690
  "\<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
   691
  \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
   692
  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
   693
  \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
   694
a6b0220fb8ae 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
  \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
   696
  \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
   697
  \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
   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
  \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
   700
  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
   701
  @{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
   702
  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
   703
  "\<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
   704
  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
   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{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
   707
  @{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
   708
  \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
   709
a6b0220fb8ae 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
  \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
   711
  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
   712
  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
   713
  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
   714
a6b0220fb8ae 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
  \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
   716
  @{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
   717
  \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
   718
a6b0220fb8ae 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
  \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
   720
  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
   721
  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
   722
  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
   723
  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
   724
  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
   725
  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
   726
  (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
   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
  \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
   729
  \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
   730
  \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
   731
a6b0220fb8ae 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 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
   733
  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
   734
  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
   735
  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
   736
a6b0220fb8ae 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
  \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
   738
  \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
   739
  \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
   740
a6b0220fb8ae 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
  \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
   742
  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
   743
  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
   744
  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
   745
  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
   746
a6b0220fb8ae 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
  \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
   748
  \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
   749
  \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
   750
  \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
   751
  \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
   752
  \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
   753
  \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
   754
a6b0220fb8ae 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
  \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
   756
  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
   757
  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
   758
  @{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
   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
  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
   761
  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
   762
  @{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
   763
  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
   764
  \<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
   765
  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
   766
  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
   767
  @{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
   768
  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
   769
  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
   770
  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
   771
  @{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
   772
  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
   773
  %
a6b0220fb8ae 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
  \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
   775
  \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
   776
  \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
   777
  \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
   778
  @{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
   779
  @{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
   780
  \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
   781
  @{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
   782
  @{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
   783
  \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
   784
  @{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
   785
  @{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
   786
  \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
   787
  @{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
   788
  @{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
   789
  \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
   790
  \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
   791
  %
a6b0220fb8ae 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
  \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
   793
  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
   794
  \<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
   795
  @{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
   796
  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
   797
  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
   798
  "\<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
   799
  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
   800
  @{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
   801
  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
   802
  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
   803
  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
   804
  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
   805
  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
   806
  %
a6b0220fb8ae 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
  \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
   808
  \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
   809
  @{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
   810
  @{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
   811
  @{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
   812
  @{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
   813
  \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
   814
  \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
   815
  %
a6b0220fb8ae 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
  \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
   817
  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
   818
  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
   819
  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
   820
  @{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
   821
  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
   822
  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
   823
  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
   824
  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
   825
a6b0220fb8ae 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
%%% 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
   827
%%% 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
   828
%%% 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
   829
%%% 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
   830
%%% 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
   831
%%% 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
   832
%%% 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
   833
%%% $\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
   834
%%% $\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
   835
a6b0220fb8ae 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
  \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
   837
  @{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
   838
  \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
   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
  \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
   841
  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
   842
  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
   843
a6b0220fb8ae 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
  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
   845
  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
   846
  @{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
   847
  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
   848
  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
   849
a6b0220fb8ae 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
  \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
   851
  \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
   852
  @{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
   853
  \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
   854
  \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
   855
  \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
   856
a6b0220fb8ae 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
  \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
   858
  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
   859
  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
   860
  "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
   861
  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
   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
  \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
   864
  @{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
   865
  \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
   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
  \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
   868
  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
   869
a6b0220fb8ae 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
  \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
   871
  @{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
   872
  \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
   873
a6b0220fb8ae 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
  \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
   875
  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
   876
  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
   877
  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
   878
  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
   879
  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
   880
a6b0220fb8ae 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
  \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
   882
  \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
   883
  \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
   884
a6b0220fb8ae 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
  \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
   886
  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
   887
  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
   888
  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
   889
  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
   890
  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
   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
  \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
   893
  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
   894
  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
   895
  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
   896
  @{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
   897
  \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
   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
  \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
   900
  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
   901
  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
   902
  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
   903
  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
   904
  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
   905
  @{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
   906
  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
   907
  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
   908
  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
   909
  \<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
   910
  \<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
   911
  @{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
   912
  "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
   913
  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
   914
  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
   915
  @{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
   916
  \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
   917
*}
a6b0220fb8ae 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
3092
ff377f9d030a some slight tuning
Christian Urban <urbanc@in.tum.de>
parents: 3082
diff changeset
   919
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
   920
a6b0220fb8ae 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
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
   922
  \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
   923
  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
   924
  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
   925
  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
   926
  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
   927
  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
   928
  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
   929
  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
   930
  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
   931
  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
   932
a6b0220fb8ae 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
  \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
   934
  \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
   935
  @{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
   936
  @{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
   937
  @{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
   938
  \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
   939
  \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
   940
a6b0220fb8ae 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
  \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
   942
  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
   943
  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
   944
  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
   945
  "\<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
   946
  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
   947
  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
   948
  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
   949
a6b0220fb8ae 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
%%% 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
   951
%%% 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
   952
a6b0220fb8ae 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
  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
   954
  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
   955
  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
   956
  @{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
   957
  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
   958
  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
   959
a6b0220fb8ae 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
  \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
   961
  \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
   962
  \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
   963
  \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
   964
  @{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
   965
   \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
   966
  @{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
   967
  \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
   968
  @{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
   969
  \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
   970
  \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
   971
a6b0220fb8ae 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
  \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
   973
  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
   974
  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
   975
  @{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
   976
  @{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
   977
a6b0220fb8ae 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
  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
   979
  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
   980
  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
   981
  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
   982
  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
   983
a6b0220fb8ae 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
  \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
   985
  @{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
   986
  \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
   987
a6b0220fb8ae 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
  \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
   989
  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
   990
  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
   991
  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
   992
  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
   993
  @{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
   994
  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
   995
  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
   996
a6b0220fb8ae 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
  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
   998
  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
   999
  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
  1000
a6b0220fb8ae 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
  \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
  1002
  @{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
  1003
  \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
  1004
a6b0220fb8ae 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
  \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
  1006
  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
  1007
  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
  1008
  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
  1009
a6b0220fb8ae 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
  \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
  1011
  @{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
  1012
  \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
  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
  \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
  1015
  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
  1016
  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
  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{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
  1019
  @{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
  1020
  \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
  1021
a6b0220fb8ae 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
  \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
  1023
  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
  1024
a6b0220fb8ae 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
  \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
  1026
  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
  1027
  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
  1028
  \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
  1029
a6b0220fb8ae 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
  \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
  1031
  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
  1032
a6b0220fb8ae 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
  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
  1034
  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
  1035
  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
  1036
  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
  1037
  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
  1038
  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
  1039
  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
  1040
  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
  1041
  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
  1042
  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
  1043
a6b0220fb8ae 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
%%% 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
  1045
%%% 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
  1046
%%% 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
  1047
%%% 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
  1048
a6b0220fb8ae 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
%%% 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
  1050
%%% 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
  1051
a6b0220fb8ae 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
  \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
  1053
  @{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
  1054
  \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
  1055
a6b0220fb8ae 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
  \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
  1057
  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
  1058
  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
  1059
a6b0220fb8ae 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
  \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
  1061
  @{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
  1062
  \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
  1063
a6b0220fb8ae 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
  \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
  1065
  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
  1066
  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
  1067
  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
  1068
  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
  1069
3118
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3115
diff changeset
  1070
  %%%@ {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
  1071
a6b0220fb8ae 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
  %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
  1073
  %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
  1074
  %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
  1075
  %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
  1076
  %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
  1077
  %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
  1078
  %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
  1079
  %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
  1080
  %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
  1081
  %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
  1082
  %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
  1083
  %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
  1084
  %
a6b0220fb8ae 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
  %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
  1086
  %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
  1087
  %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
  1088
  %
a6b0220fb8ae 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
  %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
  1090
  %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
  1091
  %
a6b0220fb8ae 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
  %@ {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
  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
  %%%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
  1096
  %%%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
  1097
  %%%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
  1098
*}
a6b0220fb8ae 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
a6b0220fb8ae 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
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
  1101
a6b0220fb8ae 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
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
  1103
a6b0220fb8ae 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
%%% 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
  1105
%%% 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
  1106
%%% 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
  1107
%%% 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
  1108
%%% 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
  1109
3137
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1110
%%% TODO: This introduction is same as the introduction to the previous section.
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1111
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
  1112
  \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
  1113
  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
  1114
  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
  1115
  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
  1116
  \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
  1117
  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
  1118
  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
  1119
  (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
  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
  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
  1122
  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
  1123
  (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
  1124
  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
  1125
  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
  1126
  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
  1127
  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
  1128
  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
  1129
a6b0220fb8ae 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
%%% 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
  1131
%%% 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
  1132
%%% 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
  1133
a6b0220fb8ae 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
  \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
  1135
  \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
  1136
  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
  1137
  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
  1138
  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
  1139
  \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
  1140
  \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
  1141
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1142
  \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
  1143
  which means, stringed together, the raw theorem implies the quotient theorem.
3137
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1144
  The core of the quotient package requires both the @{text "raw_thm"} (as a
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1145
  theorem) and the \emph{term} of the @{text "quot_thm"}. This lets the user
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1146
  have a finer control over which parts of a raw theorem should be lifted.
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1147
  We also provide more automated modes where either the @{text "quot_thm"} 
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1148
  is guessed from the form of @{text "raw_thm"} or the @{text "raw_thm"} is
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1149
  guessed from the current goal and these are described in Section \ref{sec:descending}.
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
  1150
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1151
  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
  1152
  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
  1153
  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
  1154
  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
  1155
  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
  1156
  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
  1157
  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
  1158
  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
  1159
  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
  1160
  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
  1161
  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
  1162
  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
  1163
  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
  1164
  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
  1165
a6b0220fb8ae 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
  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
  1167
  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
  1168
  @{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
  1169
  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
  1170
  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
  1171
a6b0220fb8ae 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
  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
  1173
  @{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
  1174
  @{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
  1175
  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
  1176
  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
  1177
  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
  1178
  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
  1179
  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
  1180
  %
a6b0220fb8ae 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
  \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
  1182
  \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
  1183
  \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
  1184
  @{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
  1185
  $\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
  1186
  @{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
  1187
  @{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
  1188
  \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
  1189
  \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
  1190
  @{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
  1191
  $\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
  1192
  @{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
  1193
  @{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
  1194
  \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
  1195
  \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
  1196
  %% 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
  1197
  @{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
  1198
  \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
  1199
  @{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
  1200
  @{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
  1201
  @{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
  1202
  \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
  1203
  \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
  1204
  %
a6b0220fb8ae 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
  \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
  1206
  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
  1207
  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
  1208
  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
  1209
a6b0220fb8ae 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
  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
  1211
  @{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
  1212
  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
  1213
a6b0220fb8ae 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
  \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
  1215
  \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
  1216
  \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
  1217
  @{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
  1218
  \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
  1219
  @{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
  1220
  @{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
  1221
  \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
  1222
  @{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
  1223
  \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
  1224
  \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
  1225
  @{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
  1226
  @{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
  1227
  \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
  1228
  @{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
  1229
  @{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
  1230
  $\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
  1231
  @{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
  1232
  @{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
  1233
  \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
  1234
  @{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
  1235
  $\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
  1236
  @{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
  1237
  @{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
  1238
  \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
  1239
  \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
  1240
  \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
  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 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
  1244
  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
  1245
a6b0220fb8ae 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
%%% 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
  1247
%%% 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
  1248
%%% 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
  1249
%%% 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
  1250
%%% 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
  1251
%%% 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
  1252
%%% 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
  1253
%%% 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
  1254
a6b0220fb8ae 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
  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
  1256
  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
  1257
  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
  1258
  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
  1259
  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
  1260
  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
  1261
a6b0220fb8ae 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
  %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
  1264
  %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
  1265
  %
a6b0220fb8ae 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
  % \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
  1267
  %@{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
  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
  %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
  1272
  %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
  1273
  %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
  1274
  %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
  1275
a6b0220fb8ae 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
  %\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
  1277
  %@{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
  1278
  %\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
  1279
a6b0220fb8ae 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
  %\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
  1281
  %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
  1282
a6b0220fb8ae 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
%%% 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
  1284
%%% 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
  1285
a6b0220fb8ae 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
  %\begin{isabelle}\ \ \ \ \ %%%
3118
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3115
diff changeset
  1287
  %@{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
  1288
  %\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
  1289
a6b0220fb8ae 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
  %\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
  1291
  %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
  1292
  %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
  1293
  %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
  1294
  %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
  1295
  %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
  1296
a6b0220fb8ae 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
  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
  1298
  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
  1299
  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
  1300
  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
  1301
a6b0220fb8ae 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
  %\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
  1303
  %\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
  1304
  %\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
  1305
  %\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
  1306
  %\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
  1307
  %  @{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
  1308
  %  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
  1309
a6b0220fb8ae 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
  %\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
  1311
  %  @{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
  1312
  %\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
  1313
a6b0220fb8ae 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
  %  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
  1315
  %  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
  1316
a6b0220fb8ae 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
  %\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
  1318
  %  @{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
  1319
  %\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
  1320
  %\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
  1321
a6b0220fb8ae 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
  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
  1323
  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
  1324
  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
  1325
  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
  1326
  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
  1327
  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
  1328
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1329
  %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
  1330
  %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
  1331
  %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
  1332
  %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
  1333
  %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
  1334
  %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
  1335
  %@{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
  1336
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1337
  %\begin{isabelle}\ \ \ \ \ %%%
3118
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3115
diff changeset
  1338
  %@{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
  1339
  %\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
  1340
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1341
  %\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
  1342
  %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
  1343
  %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
  1344
  %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
  1345
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1346
  %\begin{isabelle}\ \ \ \ \ %%%
3118
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3115
diff changeset
  1347
  %@{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
  1348
  %\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
  1349
a6b0220fb8ae 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
  %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
  1352
  %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
  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
3137
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1355
section {* Derivation of the shape of lifted and raw theorems\label{sec:descending} *}
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1356
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1357
text {*
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1358
  In the previous sections we have assumed, that the user specifies
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1359
  both the raw theorem and the statement of the quotient one.
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1360
  This allows complete flexibility, as to which parts of the statement
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1361
  are lifted to the quotient level and which are intact. In
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1362
  other implementations of automatic quotients (for example Homeier's
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1363
  package) only the raw theorem is given to the quotient package and
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1364
  the package is able to guess the quotient one. In this
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1365
  section we give examples where there are multiple possible valid lifted
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1366
  theorems starting from a raw one. We also show a heuristic for
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1367
  computing the quotient theorem from a raw one, and a mechanism for
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1368
  guessing a raw theorem starting with a quotient one.
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1369
*}
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1370
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1371
subsection {* Multiple lifted theorems *}
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1372
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1373
text {*
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1374
  There are multiple reasons why multiple valid lifted theorems can arize.
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1375
  Below we describe three possible scenarios: multiple raw variable,
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1376
  multiple quotients for the same raw type and multiple quotients.
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1377
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1378
  Given a raw theorem there are often several variables that include
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1379
  a raw type. It this case, one can choose which of the variables to
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1380
  lift. In certain cases this can lead to a number of valid theorem
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1381
  statements, however type constraints may disallow certain combinations.
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1382
  Lets see an example where multiple variables can have different types.
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1383
  The Isabelle/HOL induction principle for two lists is:
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1384
  \begin{isabelle}\ \ \ \ \ %%%
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1385
  @{thm list_induct2'}
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1386
  \end{isabelle}
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1387
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1388
  the conclusion is a predicate of the form @{text "P xs ys"}, where
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1389
  the two variables are lists. When lifting such theorem to the quotient
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1390
  type one can choose if one want to quotient @{text "xs"} or @{text "ys"}, or
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1391
  both. All these give rise to valid quotiented theorems, however the
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1392
  automatic mode (or other quotient packages) would derive only the version
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1393
  with both being quotiented, namely:
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1394
  \begin{isabelle}\ \ \ \ \ %%%
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1395
  @{thm list_induct2'[quot_lifted]}
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1396
  \end{isabelle}
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1397
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1398
  A second scenario, where multiple possible quotient theorems arise is
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1399
  when a single raw type is used in two quotients. Consider three quotients
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1400
  of the list type: finite sets, finite multisets and lists with distinct
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1401
  elements. We have developed all three types with the help of the quotient
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1402
  package. Given a theorem that talks about lists --- for example the regular
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1403
  induction principle --- one can lift it to three possible theorems: the
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1404
  induction principle for finite sets, induction principle for finite
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1405
  multisets or the induction principle for distinct lists. Again given an
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1406
  induction principle for two lists this gives rise to 15 possible valid
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1407
  lifted theorems.
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1408
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1409
  In our developments using the quotient package we also encountered a
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1410
  scenario where multiple valid theorem statements arise, but the raw
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1411
  types are not identical. Consider the type of lambda terms, where the
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1412
  variables are indexed with strings. Quotienting lambda terms by alpha
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1413
  equivalence gives rise to a Nominal construction~\cite{Nominal}. However
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1414
  at the same time the type of strings being a list of characters can
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1415
  lift to theorems about finite sets of characters.
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1416
*}
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1417
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1418
subsection {* Derivation of the shape of theorems *}
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1419
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1420
text {*
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1421
  To derive a the shape of a lifted or raw theorem the quotient package
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1422
  first builds a type and term substitution.
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1423
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1424
  The list of type substitution is created by taking the pairs
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1425
  @{text "(raw_type, quotient_type)"} for every user defined quotient.
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1426
  The term substitutions are of two types: First for every user-defined
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1427
  quotient constant, the pair @{text "(raw_term, quotient_constant)"}
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1428
  is included in the substitution. Second, for every quotient relation
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1429
  @{text "\<approx>"} the pair @{text "(\<approx>, =)"} with the equality being the
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1430
  equality on the defined quotient type is included in the substitution.
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1431
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1432
  The derivation function next traverses the theorem statement expressed
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1433
  as a term and replaces the types of all free variables and of all
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1434
  lambda-abstractions using the type substitution. For every constant
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1435
  is not matched by the term substitution and we perform the type substitution
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1436
  on the type of the constant (this is necessary for quotienting theorems
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1437
  with polymorphic constants) or the type of the substitution is matched
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1438
  and the match is returned.
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1439
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1440
  The heuristic defined above is greedy and according to our experience
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1441
  this is what the user wants. The procedure may in some cases produce
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1442
  theorem statements that do not type-check. However verifying all
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1443
  possible theorem statements is too costly in general.
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1444
*}
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1445
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1446
subsection {* Interaction modes and derivation of the the shape of theorems *}
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1447
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1448
text {*
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1449
  In the quotient package we provide three interaction modes, that use
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1450
  can the procedure procedure defined in the previous subsection.
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1451
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1452
  First, the completely manual mode which we implemented as the
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1453
  Isabelle method @{text lifting}. In this mode the user first
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1454
  proves the raw theorem. Then the lifted theorem can be proved
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1455
  by the method lifting, that takes the reference to the raw theorem
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1456
  (or theorem list) as an argument. Such completely manual mode is
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1457
  necessary for theorems where the specification of the lifted theorem
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1458
  from the raw one is not unique, which we discussed in the previous
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1459
  subsection.
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1460
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1461
  Next, we provide a mode for automatically lifting a given
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1462
  raw theorem. We implemented this mode as an isabelle attribute,
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1463
  so given the raw theorem @{text thm}, the user can refer to the
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1464
  theorem @{text "thm[quot_lifted]"}.
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1465
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1466
  Finally we provie a method for translating a given quotient
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1467
  level theorem to a raw one. We implemented this as an Isabelle
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1468
  method @{text descending}. The user starts with expressing a
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1469
  quotient level theorem statement and applies this method.
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1470
  The quotient package derives a raw level statement and assumes
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1471
  it as a subgoal. Given that this subgoal is proved, the quotient
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1472
  package can lift the raw theorem fulfilling the proof of the
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1473
  original lifted theorem statement. 
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1474
*}
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1475
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
  1476
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
  1477
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1478
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
  1479
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1480
  \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
  1481
  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
  1482
  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
  1483
  \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
  1484
  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
  1485
  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
  1486
  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
  1487
  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
  1488
  @{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
  1489
  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
  1490
  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
  1491
  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
  1492
  \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
  1493
  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
  1494
3094
8bad9887ad90 moved TODO into the paper
Christian Urban <urbanc@in.tum.de>
parents: 3092
diff changeset
  1495
  {\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
  1496
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1497
  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
  1498
  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
  1499
  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
  1500
  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
  1501
  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
  1502
  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
  1503
  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
  1504
  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
  1505
  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
  1506
  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
  1507
  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
  1508
  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
  1509
  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
  1510
  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
  1511
  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
  1512
  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
  1513
  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
  1514
  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
  1515
  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
  1516
  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
  1517
  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
  1518
  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
  1519
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1520
%%% 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
  1521
%%% 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
  1522
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1523
  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
  1524
  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
  1525
  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
  1526
  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
  1527
  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
  1528
  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
  1529
  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
  1530
  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
  1531
%%
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1532
%% 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
  1533
%%
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1534
  \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
  1535
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1536
  \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
  1537
  {\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
  1538
  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
  1539
  some of its finer points in the implementation. Without his patient
3137
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1540
  help, this work would have been impossible. We would like to thank
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1541
  Andreas Lochbiler for his comments on the first version of the quotient
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1542
  package, in particular for the suggestions about the descending method.
de3a89363143 qpaper-jv add a section about descending etc
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 3136
diff changeset
  1543
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
  1544
*}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1545
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1546
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
  1547
  %%\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
  1548
  \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
  1549
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1550
  \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
  1551
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1552
*}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1553
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1554
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
  1555
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1556
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
  1557
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1558
%%% 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
  1559
%%% 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
  1560
%%% 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
  1561
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1562
  \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
  1563
  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
  1564
  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
  1565
  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
  1566
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1567
  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
  1568
  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
  1569
  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
  1570
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1571
  \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
  1572
  \begin{tabular}{@ {}l}
3114
a9a4baa7779f 2 typos found by John Wickerson in QPaper
Christian Urban <urbanc@in.tum.de>
parents: 3094
diff changeset
  1573
  \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
  1574
  \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
  1575
  \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
  1576
  \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
  1577
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1578
  \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
  1579
  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
  1580
  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
  1581
  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
  1582
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1583
  \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
  1584
  \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
  1585
  \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
  1586
  \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
  1587
  \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
  1588
  \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
  1589
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1590
  \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
  1591
  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
  1592
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1593
  \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
  1594
  \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
  1595
  \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
  1596
  \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
  1597
  \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
  1598
  @{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
  1599
  \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
  1600
  \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
  1601
  \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
  1602
  \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
  1603
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1604
  \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
  1605
  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
  1606
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1607
  \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
  1608
  \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
  1609
  \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
  1610
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1611
  \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
  1612
  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
  1613
  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
  1614
  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
  1615
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1616
  \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
  1617
  \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
  1618
  \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
  1619
  @{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
  1620
  \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
  1621
  \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
  1622
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1623
  \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
  1624
  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
  1625
  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
  1626
  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
  1627
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1628
  \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
  1629
  \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
  1630
  \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
  1631
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1632
  \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
  1633
  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
  1634
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1635
  \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
  1636
  \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
  1637
  \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
  1638
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1639
  \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
  1640
  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
  1641
  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
  1642
  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
  1643
  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
  1644
8bad9887ad90 moved TODO into the paper
Christian Urban <urbanc@in.tum.de>
parents: 3092
diff changeset
  1645
  {\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
  1646
  \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
  1647
  \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
  1648
  \item Quotient extensions (quot\_thms)
3094
8bad9887ad90 moved TODO into the paper
Christian Urban <urbanc@in.tum.de>
parents: 3092
diff changeset
  1649
  \item Respectfulness and preservation
8bad9887ad90 moved TODO into the paper
Christian Urban <urbanc@in.tum.de>
parents: 3092
diff changeset
  1650
  - 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
  1651
  - 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
  1652
  \item Quotient-type locale
8bad9887ad90 moved TODO into the paper
Christian Urban <urbanc@in.tum.de>
parents: 3092
diff changeset
  1653
  - 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
  1654
  \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
  1655
  \item Lifting vs Descending vs quot\_lifted
8bad9887ad90 moved TODO into the paper
Christian Urban <urbanc@in.tum.de>
parents: 3092
diff changeset
  1656
  - automatic theorem translation heuristic
8bad9887ad90 moved TODO into the paper
Christian Urban <urbanc@in.tum.de>
parents: 3092
diff changeset
  1657
  \item Partial equivalence quotients
8bad9887ad90 moved TODO into the paper
Christian Urban <urbanc@in.tum.de>
parents: 3092
diff changeset
  1658
  - Bounded abstraction
8bad9887ad90 moved TODO into the paper
Christian Urban <urbanc@in.tum.de>
parents: 3092
diff changeset
  1659
  - Respects
8bad9887ad90 moved TODO into the paper
Christian Urban <urbanc@in.tum.de>
parents: 3092
diff changeset
  1660
  - partial descending
8bad9887ad90 moved TODO into the paper
Christian Urban <urbanc@in.tum.de>
parents: 3092
diff changeset
  1661
  \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
  1662
  \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
  1663
  injected and cleaned statement
8bad9887ad90 moved TODO into the paper
Christian Urban <urbanc@in.tum.de>
parents: 3092
diff changeset
  1664
  \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
  1665
  \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
  1666
  \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
  1667
  \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
  1668
  \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
  1669
*}
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1670
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1671
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1672
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1673
(*<*)
a6b0220fb8ae Added an initial version of qpaper-jv and a TODO of things to write about.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1674
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
  1675
(*>*)