src/HOL/Lifting.thy
author bulwahn
Thu Apr 12 11:01:15 2012 +0200 (2012-04-12)
changeset 47436 d8fad618a67a
parent 47376 776254f89a18
parent 47435 e1b761c216ac
child 47501 0b9294e093db
permissions -rw-r--r--
merged
kuncar@47308
     1
(*  Title:      HOL/Lifting.thy
kuncar@47308
     2
    Author:     Brian Huffman and Ondrej Kuncar
kuncar@47308
     3
    Author:     Cezary Kaliszyk and Christian Urban
kuncar@47308
     4
*)
kuncar@47308
     5
kuncar@47308
     6
header {* Lifting package *}
kuncar@47308
     7
kuncar@47308
     8
theory Lifting
huffman@47325
     9
imports Plain Equiv_Relations Transfer
kuncar@47308
    10
keywords
kuncar@47308
    11
  "print_quotmaps" "print_quotients" :: diag and
kuncar@47308
    12
  "lift_definition" :: thy_goal and
kuncar@47308
    13
  "setup_lifting" :: thy_decl
kuncar@47308
    14
uses
kuncar@47308
    15
  ("Tools/Lifting/lifting_info.ML")
kuncar@47308
    16
  ("Tools/Lifting/lifting_term.ML")
kuncar@47308
    17
  ("Tools/Lifting/lifting_def.ML")
kuncar@47308
    18
  ("Tools/Lifting/lifting_setup.ML")
kuncar@47308
    19
begin
kuncar@47308
    20
huffman@47325
    21
subsection {* Function map *}
kuncar@47308
    22
kuncar@47308
    23
notation map_fun (infixr "--->" 55)
kuncar@47308
    24
kuncar@47308
    25
lemma map_fun_id:
kuncar@47308
    26
  "(id ---> id) = id"
kuncar@47308
    27
  by (simp add: fun_eq_iff)
kuncar@47308
    28
kuncar@47308
    29
subsection {* Quotient Predicate *}
kuncar@47308
    30
kuncar@47308
    31
definition
kuncar@47308
    32
  "Quotient R Abs Rep T \<longleftrightarrow>
kuncar@47308
    33
     (\<forall>a. Abs (Rep a) = a) \<and> 
kuncar@47308
    34
     (\<forall>a. R (Rep a) (Rep a)) \<and>
kuncar@47308
    35
     (\<forall>r s. R r s \<longleftrightarrow> R r r \<and> R s s \<and> Abs r = Abs s) \<and>
kuncar@47308
    36
     T = (\<lambda>x y. R x x \<and> Abs x = y)"
kuncar@47308
    37
kuncar@47308
    38
lemma QuotientI:
kuncar@47308
    39
  assumes "\<And>a. Abs (Rep a) = a"
kuncar@47308
    40
    and "\<And>a. R (Rep a) (Rep a)"
kuncar@47308
    41
    and "\<And>r s. R r s \<longleftrightarrow> R r r \<and> R s s \<and> Abs r = Abs s"
kuncar@47308
    42
    and "T = (\<lambda>x y. R x x \<and> Abs x = y)"
kuncar@47308
    43
  shows "Quotient R Abs Rep T"
kuncar@47308
    44
  using assms unfolding Quotient_def by blast
kuncar@47308
    45
kuncar@47308
    46
lemma Quotient_abs_rep:
kuncar@47308
    47
  assumes a: "Quotient R Abs Rep T"
kuncar@47308
    48
  shows "Abs (Rep a) = a"
kuncar@47308
    49
  using a
kuncar@47308
    50
  unfolding Quotient_def
kuncar@47308
    51
  by simp
kuncar@47308
    52
kuncar@47308
    53
lemma Quotient_rep_reflp:
kuncar@47308
    54
  assumes a: "Quotient R Abs Rep T"
kuncar@47308
    55
  shows "R (Rep a) (Rep a)"
kuncar@47308
    56
  using a
kuncar@47308
    57
  unfolding Quotient_def
kuncar@47308
    58
  by blast
kuncar@47308
    59
kuncar@47308
    60
lemma Quotient_rel:
kuncar@47308
    61
  assumes a: "Quotient R Abs Rep T"
kuncar@47308
    62
  shows "R r r \<and> R s s \<and> Abs r = Abs s \<longleftrightarrow> R r s" -- {* orientation does not loop on rewriting *}
kuncar@47308
    63
  using a
kuncar@47308
    64
  unfolding Quotient_def
kuncar@47308
    65
  by blast
kuncar@47308
    66
kuncar@47308
    67
lemma Quotient_cr_rel:
kuncar@47308
    68
  assumes a: "Quotient R Abs Rep T"
kuncar@47308
    69
  shows "T = (\<lambda>x y. R x x \<and> Abs x = y)"
kuncar@47308
    70
  using a
kuncar@47308
    71
  unfolding Quotient_def
kuncar@47308
    72
  by blast
kuncar@47308
    73
kuncar@47308
    74
lemma Quotient_refl1: 
kuncar@47308
    75
  assumes a: "Quotient R Abs Rep T" 
kuncar@47308
    76
  shows "R r s \<Longrightarrow> R r r"
kuncar@47308
    77
  using a unfolding Quotient_def 
kuncar@47308
    78
  by fast
kuncar@47308
    79
kuncar@47308
    80
lemma Quotient_refl2: 
kuncar@47308
    81
  assumes a: "Quotient R Abs Rep T" 
kuncar@47308
    82
  shows "R r s \<Longrightarrow> R s s"
kuncar@47308
    83
  using a unfolding Quotient_def 
kuncar@47308
    84
  by fast
kuncar@47308
    85
kuncar@47308
    86
lemma Quotient_rel_rep:
kuncar@47308
    87
  assumes a: "Quotient R Abs Rep T"
kuncar@47308
    88
  shows "R (Rep a) (Rep b) \<longleftrightarrow> a = b"
kuncar@47308
    89
  using a
kuncar@47308
    90
  unfolding Quotient_def
kuncar@47308
    91
  by metis
kuncar@47308
    92
kuncar@47308
    93
lemma Quotient_rep_abs:
kuncar@47308
    94
  assumes a: "Quotient R Abs Rep T"
kuncar@47308
    95
  shows "R r r \<Longrightarrow> R (Rep (Abs r)) r"
kuncar@47308
    96
  using a unfolding Quotient_def
kuncar@47308
    97
  by blast
kuncar@47308
    98
kuncar@47308
    99
lemma Quotient_rel_abs:
kuncar@47308
   100
  assumes a: "Quotient R Abs Rep T"
kuncar@47308
   101
  shows "R r s \<Longrightarrow> Abs r = Abs s"
kuncar@47308
   102
  using a unfolding Quotient_def
kuncar@47308
   103
  by blast
kuncar@47308
   104
kuncar@47308
   105
lemma Quotient_symp:
kuncar@47308
   106
  assumes a: "Quotient R Abs Rep T"
kuncar@47308
   107
  shows "symp R"
kuncar@47308
   108
  using a unfolding Quotient_def using sympI by (metis (full_types))
kuncar@47308
   109
kuncar@47308
   110
lemma Quotient_transp:
kuncar@47308
   111
  assumes a: "Quotient R Abs Rep T"
kuncar@47308
   112
  shows "transp R"
kuncar@47308
   113
  using a unfolding Quotient_def using transpI by (metis (full_types))
kuncar@47308
   114
kuncar@47308
   115
lemma Quotient_part_equivp:
kuncar@47308
   116
  assumes a: "Quotient R Abs Rep T"
kuncar@47308
   117
  shows "part_equivp R"
kuncar@47308
   118
by (metis Quotient_rep_reflp Quotient_symp Quotient_transp a part_equivpI)
kuncar@47308
   119
kuncar@47308
   120
lemma identity_quotient: "Quotient (op =) id id (op =)"
kuncar@47308
   121
unfolding Quotient_def by simp 
kuncar@47308
   122
kuncar@47308
   123
lemma Quotient_alt_def:
kuncar@47308
   124
  "Quotient R Abs Rep T \<longleftrightarrow>
kuncar@47308
   125
    (\<forall>a b. T a b \<longrightarrow> Abs a = b) \<and>
kuncar@47308
   126
    (\<forall>b. T (Rep b) b) \<and>
kuncar@47308
   127
    (\<forall>x y. R x y \<longleftrightarrow> T x (Abs x) \<and> T y (Abs y) \<and> Abs x = Abs y)"
kuncar@47308
   128
apply safe
kuncar@47308
   129
apply (simp (no_asm_use) only: Quotient_def, fast)
kuncar@47308
   130
apply (simp (no_asm_use) only: Quotient_def, fast)
kuncar@47308
   131
apply (simp (no_asm_use) only: Quotient_def, fast)
kuncar@47308
   132
apply (simp (no_asm_use) only: Quotient_def, fast)
kuncar@47308
   133
apply (simp (no_asm_use) only: Quotient_def, fast)
kuncar@47308
   134
apply (simp (no_asm_use) only: Quotient_def, fast)
kuncar@47308
   135
apply (rule QuotientI)
kuncar@47308
   136
apply simp
kuncar@47308
   137
apply metis
kuncar@47308
   138
apply simp
kuncar@47308
   139
apply (rule ext, rule ext, metis)
kuncar@47308
   140
done
kuncar@47308
   141
kuncar@47308
   142
lemma Quotient_alt_def2:
kuncar@47308
   143
  "Quotient R Abs Rep T \<longleftrightarrow>
kuncar@47308
   144
    (\<forall>a b. T a b \<longrightarrow> Abs a = b) \<and>
kuncar@47308
   145
    (\<forall>b. T (Rep b) b) \<and>
kuncar@47308
   146
    (\<forall>x y. R x y \<longleftrightarrow> T x (Abs y) \<and> T y (Abs x))"
kuncar@47308
   147
  unfolding Quotient_alt_def by (safe, metis+)
kuncar@47308
   148
kuncar@47308
   149
lemma fun_quotient:
kuncar@47308
   150
  assumes 1: "Quotient R1 abs1 rep1 T1"
kuncar@47308
   151
  assumes 2: "Quotient R2 abs2 rep2 T2"
kuncar@47308
   152
  shows "Quotient (R1 ===> R2) (rep1 ---> abs2) (abs1 ---> rep2) (T1 ===> T2)"
kuncar@47308
   153
  using assms unfolding Quotient_alt_def2
kuncar@47308
   154
  unfolding fun_rel_def fun_eq_iff map_fun_apply
kuncar@47308
   155
  by (safe, metis+)
kuncar@47308
   156
kuncar@47308
   157
lemma apply_rsp:
kuncar@47308
   158
  fixes f g::"'a \<Rightarrow> 'c"
kuncar@47308
   159
  assumes q: "Quotient R1 Abs1 Rep1 T1"
kuncar@47308
   160
  and     a: "(R1 ===> R2) f g" "R1 x y"
kuncar@47308
   161
  shows "R2 (f x) (g y)"
kuncar@47308
   162
  using a by (auto elim: fun_relE)
kuncar@47308
   163
kuncar@47308
   164
lemma apply_rsp':
kuncar@47308
   165
  assumes a: "(R1 ===> R2) f g" "R1 x y"
kuncar@47308
   166
  shows "R2 (f x) (g y)"
kuncar@47308
   167
  using a by (auto elim: fun_relE)
kuncar@47308
   168
kuncar@47308
   169
lemma apply_rsp'':
kuncar@47308
   170
  assumes "Quotient R Abs Rep T"
kuncar@47308
   171
  and "(R ===> S) f f"
kuncar@47308
   172
  shows "S (f (Rep x)) (f (Rep x))"
kuncar@47308
   173
proof -
kuncar@47308
   174
  from assms(1) have "R (Rep x) (Rep x)" by (rule Quotient_rep_reflp)
kuncar@47308
   175
  then show ?thesis using assms(2) by (auto intro: apply_rsp')
kuncar@47308
   176
qed
kuncar@47308
   177
kuncar@47308
   178
subsection {* Quotient composition *}
kuncar@47308
   179
kuncar@47308
   180
lemma Quotient_compose:
kuncar@47308
   181
  assumes 1: "Quotient R1 Abs1 Rep1 T1"
kuncar@47308
   182
  assumes 2: "Quotient R2 Abs2 Rep2 T2"
kuncar@47308
   183
  shows "Quotient (T1 OO R2 OO conversep T1) (Abs2 \<circ> Abs1) (Rep1 \<circ> Rep2) (T1 OO T2)"
kuncar@47308
   184
proof -
kuncar@47308
   185
  from 1 have Abs1: "\<And>a b. T1 a b \<Longrightarrow> Abs1 a = b"
kuncar@47308
   186
    unfolding Quotient_alt_def by simp
kuncar@47308
   187
  from 1 have Rep1: "\<And>b. T1 (Rep1 b) b"
kuncar@47308
   188
    unfolding Quotient_alt_def by simp
kuncar@47308
   189
  from 2 have Abs2: "\<And>a b. T2 a b \<Longrightarrow> Abs2 a = b"
kuncar@47308
   190
    unfolding Quotient_alt_def by simp
kuncar@47308
   191
  from 2 have Rep2: "\<And>b. T2 (Rep2 b) b"
kuncar@47308
   192
    unfolding Quotient_alt_def by simp
kuncar@47308
   193
  from 2 have R2:
kuncar@47308
   194
    "\<And>x y. R2 x y \<longleftrightarrow> T2 x (Abs2 x) \<and> T2 y (Abs2 y) \<and> Abs2 x = Abs2 y"
kuncar@47308
   195
    unfolding Quotient_alt_def by simp
kuncar@47308
   196
  show ?thesis
kuncar@47308
   197
    unfolding Quotient_alt_def
kuncar@47308
   198
    apply simp
kuncar@47308
   199
    apply safe
kuncar@47308
   200
    apply (drule Abs1, simp)
kuncar@47308
   201
    apply (erule Abs2)
griff@47435
   202
    apply (rule relcomppI)
kuncar@47308
   203
    apply (rule Rep1)
kuncar@47308
   204
    apply (rule Rep2)
griff@47435
   205
    apply (rule relcomppI, assumption)
kuncar@47308
   206
    apply (drule Abs1, simp)
kuncar@47308
   207
    apply (clarsimp simp add: R2)
griff@47435
   208
    apply (rule relcomppI, assumption)
kuncar@47308
   209
    apply (drule Abs1, simp)+
kuncar@47308
   210
    apply (clarsimp simp add: R2)
kuncar@47308
   211
    apply (drule Abs1, simp)+
kuncar@47308
   212
    apply (clarsimp simp add: R2)
griff@47435
   213
    apply (rule relcomppI, assumption)
griff@47435
   214
    apply (rule relcomppI [rotated])
kuncar@47308
   215
    apply (erule conversepI)
kuncar@47308
   216
    apply (drule Abs1, simp)+
kuncar@47308
   217
    apply (simp add: R2)
kuncar@47308
   218
    done
kuncar@47308
   219
qed
kuncar@47308
   220
kuncar@47308
   221
subsection {* Invariant *}
kuncar@47308
   222
kuncar@47308
   223
definition invariant :: "('a \<Rightarrow> bool) \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> bool" 
kuncar@47308
   224
  where "invariant R = (\<lambda>x y. R x \<and> x = y)"
kuncar@47308
   225
kuncar@47308
   226
lemma invariant_to_eq:
kuncar@47308
   227
  assumes "invariant P x y"
kuncar@47308
   228
  shows "x = y"
kuncar@47308
   229
using assms by (simp add: invariant_def)
kuncar@47308
   230
kuncar@47308
   231
lemma fun_rel_eq_invariant:
kuncar@47308
   232
  shows "((invariant R) ===> S) = (\<lambda>f g. \<forall>x. R x \<longrightarrow> S (f x) (g x))"
kuncar@47308
   233
by (auto simp add: invariant_def fun_rel_def)
kuncar@47308
   234
kuncar@47308
   235
lemma invariant_same_args:
kuncar@47308
   236
  shows "invariant P x x \<equiv> P x"
kuncar@47308
   237
using assms by (auto simp add: invariant_def)
kuncar@47308
   238
kuncar@47361
   239
lemma UNIV_typedef_to_Quotient:
kuncar@47308
   240
  assumes "type_definition Rep Abs UNIV"
kuncar@47361
   241
  and T_def: "T \<equiv> (\<lambda>x y. x = Rep y)"
kuncar@47308
   242
  shows "Quotient (op =) Abs Rep T"
kuncar@47308
   243
proof -
kuncar@47308
   244
  interpret type_definition Rep Abs UNIV by fact
kuncar@47361
   245
  from Abs_inject Rep_inverse Abs_inverse T_def show ?thesis 
kuncar@47361
   246
    by (fastforce intro!: QuotientI fun_eq_iff)
kuncar@47308
   247
qed
kuncar@47308
   248
kuncar@47361
   249
lemma UNIV_typedef_to_equivp:
kuncar@47308
   250
  fixes Abs :: "'a \<Rightarrow> 'b"
kuncar@47308
   251
  and Rep :: "'b \<Rightarrow> 'a"
kuncar@47308
   252
  assumes "type_definition Rep Abs (UNIV::'a set)"
kuncar@47308
   253
  shows "equivp (op=::'a\<Rightarrow>'a\<Rightarrow>bool)"
kuncar@47308
   254
by (rule identity_equivp)
kuncar@47308
   255
huffman@47354
   256
lemma typedef_to_Quotient:
kuncar@47361
   257
  assumes "type_definition Rep Abs S"
kuncar@47361
   258
  and T_def: "T \<equiv> (\<lambda>x y. x = Rep y)"
kuncar@47361
   259
  shows "Quotient (Lifting.invariant (\<lambda>x. x \<in> S)) Abs Rep T"
kuncar@47361
   260
proof -
kuncar@47361
   261
  interpret type_definition Rep Abs S by fact
kuncar@47361
   262
  from Rep Abs_inject Rep_inverse Abs_inverse T_def show ?thesis
kuncar@47361
   263
    by (auto intro!: QuotientI simp: invariant_def fun_eq_iff)
kuncar@47361
   264
qed
kuncar@47361
   265
kuncar@47361
   266
lemma typedef_to_part_equivp:
kuncar@47361
   267
  assumes "type_definition Rep Abs S"
kuncar@47361
   268
  shows "part_equivp (Lifting.invariant (\<lambda>x. x \<in> S))"
kuncar@47361
   269
proof (intro part_equivpI)
kuncar@47361
   270
  interpret type_definition Rep Abs S by fact
kuncar@47361
   271
  show "\<exists>x. Lifting.invariant (\<lambda>x. x \<in> S) x x" using Rep by (auto simp: invariant_def)
kuncar@47361
   272
next
kuncar@47361
   273
  show "symp (Lifting.invariant (\<lambda>x. x \<in> S))" by (auto intro: sympI simp: invariant_def)
kuncar@47361
   274
next
kuncar@47361
   275
  show "transp (Lifting.invariant (\<lambda>x. x \<in> S))" by (auto intro: transpI simp: invariant_def)
kuncar@47361
   276
qed
kuncar@47361
   277
kuncar@47361
   278
lemma open_typedef_to_Quotient:
kuncar@47308
   279
  assumes "type_definition Rep Abs {x. P x}"
huffman@47354
   280
  and T_def: "T \<equiv> (\<lambda>x y. x = Rep y)"
kuncar@47308
   281
  shows "Quotient (invariant P) Abs Rep T"
kuncar@47308
   282
proof -
kuncar@47308
   283
  interpret type_definition Rep Abs "{x. P x}" by fact
huffman@47354
   284
  from Rep Abs_inject Rep_inverse Abs_inverse T_def show ?thesis
huffman@47354
   285
    by (auto intro!: QuotientI simp: invariant_def fun_eq_iff)
kuncar@47308
   286
qed
kuncar@47308
   287
kuncar@47361
   288
lemma open_typedef_to_part_equivp:
kuncar@47308
   289
  assumes "type_definition Rep Abs {x. P x}"
kuncar@47308
   290
  shows "part_equivp (invariant P)"
kuncar@47308
   291
proof (intro part_equivpI)
kuncar@47308
   292
  interpret type_definition Rep Abs "{x. P x}" by fact
kuncar@47308
   293
  show "\<exists>x. invariant P x x" using Rep by (auto simp: invariant_def)
kuncar@47308
   294
next
kuncar@47308
   295
  show "symp (invariant P)" by (auto intro: sympI simp: invariant_def)
kuncar@47308
   296
next
kuncar@47308
   297
  show "transp (invariant P)" by (auto intro: transpI simp: invariant_def)
kuncar@47308
   298
qed
kuncar@47308
   299
huffman@47376
   300
text {* Generating transfer rules for quotients. *}
huffman@47376
   301
huffman@47376
   302
lemma Quotient_right_unique:
huffman@47376
   303
  assumes "Quotient R Abs Rep T" shows "right_unique T"
huffman@47376
   304
  using assms unfolding Quotient_alt_def right_unique_def by metis
huffman@47376
   305
huffman@47376
   306
lemma Quotient_right_total:
huffman@47376
   307
  assumes "Quotient R Abs Rep T" shows "right_total T"
huffman@47376
   308
  using assms unfolding Quotient_alt_def right_total_def by metis
huffman@47376
   309
huffman@47376
   310
lemma Quotient_rel_eq_transfer:
huffman@47376
   311
  assumes "Quotient R Abs Rep T"
huffman@47376
   312
  shows "(T ===> T ===> op =) R (op =)"
huffman@47376
   313
  using assms unfolding Quotient_alt_def fun_rel_def by simp
huffman@47376
   314
huffman@47376
   315
lemma Quotient_bi_total:
huffman@47376
   316
  assumes "Quotient R Abs Rep T" and "reflp R"
huffman@47376
   317
  shows "bi_total T"
huffman@47376
   318
  using assms unfolding Quotient_alt_def bi_total_def reflp_def by auto
huffman@47376
   319
huffman@47376
   320
lemma Quotient_id_abs_transfer:
huffman@47376
   321
  assumes "Quotient R Abs Rep T" and "reflp R"
huffman@47376
   322
  shows "(op = ===> T) (\<lambda>x. x) Abs"
huffman@47376
   323
  using assms unfolding Quotient_alt_def reflp_def fun_rel_def by simp
huffman@47376
   324
huffman@47368
   325
text {* Generating transfer rules for a type defined with @{text "typedef"}. *}
huffman@47368
   326
huffman@47368
   327
lemma typedef_bi_unique:
huffman@47368
   328
  assumes type: "type_definition Rep Abs A"
huffman@47368
   329
  assumes T_def: "T \<equiv> (\<lambda>x y. x = Rep y)"
huffman@47368
   330
  shows "bi_unique T"
huffman@47368
   331
  unfolding bi_unique_def T_def
huffman@47368
   332
  by (simp add: type_definition.Rep_inject [OF type])
huffman@47368
   333
huffman@47368
   334
lemma typedef_right_total:
huffman@47368
   335
  assumes T_def: "T \<equiv> (\<lambda>x y. x = Rep y)"
huffman@47368
   336
  shows "right_total T"
huffman@47368
   337
  unfolding right_total_def T_def by simp
huffman@47368
   338
huffman@47368
   339
lemma copy_type_bi_total:
huffman@47368
   340
  assumes type: "type_definition Rep Abs UNIV"
huffman@47368
   341
  assumes T_def: "T \<equiv> (\<lambda>x y. x = Rep y)"
huffman@47368
   342
  shows "bi_total T"
huffman@47368
   343
  unfolding bi_total_def T_def
huffman@47368
   344
  by (metis type_definition.Abs_inverse [OF type] UNIV_I)
huffman@47368
   345
huffman@47368
   346
lemma typedef_transfer_All:
huffman@47368
   347
  assumes type: "type_definition Rep Abs A"
huffman@47368
   348
  assumes T_def: "T \<equiv> (\<lambda>x y. x = Rep y)"
huffman@47368
   349
  shows "((T ===> op =) ===> op =) (Ball A) All"
huffman@47368
   350
  unfolding T_def fun_rel_def
huffman@47368
   351
  by (metis type_definition.Rep [OF type]
huffman@47368
   352
    type_definition.Abs_inverse [OF type])
huffman@47368
   353
huffman@47368
   354
lemma typedef_transfer_Ex:
huffman@47368
   355
  assumes type: "type_definition Rep Abs A"
huffman@47368
   356
  assumes T_def: "T \<equiv> (\<lambda>x y. x = Rep y)"
huffman@47368
   357
  shows "((T ===> op =) ===> op =) (Bex A) Ex"
huffman@47368
   358
  unfolding T_def fun_rel_def
huffman@47368
   359
  by (metis type_definition.Rep [OF type]
huffman@47368
   360
    type_definition.Abs_inverse [OF type])
huffman@47368
   361
huffman@47368
   362
lemma typedef_transfer_bforall:
huffman@47368
   363
  assumes type: "type_definition Rep Abs A"
huffman@47368
   364
  assumes T_def: "T \<equiv> (\<lambda>x y. x = Rep y)"
huffman@47368
   365
  shows "((T ===> op =) ===> op =)
huffman@47368
   366
    (transfer_bforall (\<lambda>x. x \<in> A)) transfer_forall"
huffman@47368
   367
  unfolding transfer_bforall_def transfer_forall_def Ball_def [symmetric]
huffman@47368
   368
  by (rule typedef_transfer_All [OF assms])
huffman@47368
   369
huffman@47368
   370
text {* Generating the correspondence rule for a constant defined with
huffman@47368
   371
  @{text "lift_definition"}. *}
huffman@47368
   372
huffman@47351
   373
lemma Quotient_to_transfer:
huffman@47351
   374
  assumes "Quotient R Abs Rep T" and "R c c" and "c' \<equiv> Abs c"
huffman@47351
   375
  shows "T c c'"
huffman@47351
   376
  using assms by (auto dest: Quotient_cr_rel)
huffman@47351
   377
kuncar@47308
   378
subsection {* ML setup *}
kuncar@47308
   379
kuncar@47308
   380
text {* Auxiliary data for the lifting package *}
kuncar@47308
   381
kuncar@47308
   382
use "Tools/Lifting/lifting_info.ML"
kuncar@47308
   383
setup Lifting_Info.setup
kuncar@47308
   384
kuncar@47308
   385
declare [[map "fun" = (fun_rel, fun_quotient)]]
kuncar@47308
   386
kuncar@47308
   387
use "Tools/Lifting/lifting_term.ML"
kuncar@47308
   388
kuncar@47308
   389
use "Tools/Lifting/lifting_def.ML"
kuncar@47308
   390
kuncar@47308
   391
use "Tools/Lifting/lifting_setup.ML"
kuncar@47308
   392
kuncar@47308
   393
hide_const (open) invariant
kuncar@47308
   394
kuncar@47308
   395
end