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