src/HOL/Transfer.thy
author blanchet
Mon Jan 20 20:42:43 2014 +0100 (2014-01-20)
changeset 55084 8ee9aabb2bca
parent 53952 b2781a3ce958
child 55415 05f5fdb8d093
permissions -rw-r--r--
rationalized lemmas
huffman@47325
     1
(*  Title:      HOL/Transfer.thy
huffman@47325
     2
    Author:     Brian Huffman, TU Muenchen
kuncar@51956
     3
    Author:     Ondrej Kuncar, TU Muenchen
huffman@47325
     4
*)
huffman@47325
     5
huffman@47325
     6
header {* Generic theorem transfer using relations *}
huffman@47325
     7
huffman@47325
     8
theory Transfer
blanchet@55084
     9
imports Hilbert_Choice Basic_BNFs
huffman@47325
    10
begin
huffman@47325
    11
huffman@47325
    12
subsection {* Relator for function space *}
huffman@47325
    13
kuncar@53011
    14
locale lifting_syntax
kuncar@53011
    15
begin
kuncar@53011
    16
  notation fun_rel (infixr "===>" 55)
kuncar@53011
    17
  notation map_fun (infixr "--->" 55)
kuncar@53011
    18
end
kuncar@53011
    19
kuncar@53011
    20
context
kuncar@53011
    21
begin
kuncar@53011
    22
interpretation lifting_syntax .
kuncar@53011
    23
kuncar@47937
    24
lemma fun_relD2:
blanchet@55084
    25
  assumes "fun_rel A B f g" and "A x x"
kuncar@47937
    26
  shows "B (f x) (g x)"
blanchet@55084
    27
  using assms by (rule fun_relD)
kuncar@47937
    28
huffman@47325
    29
lemma fun_relE:
blanchet@55084
    30
  assumes "fun_rel A B f g" and "A x y"
huffman@47325
    31
  obtains "B (f x) (g y)"
huffman@47325
    32
  using assms by (simp add: fun_rel_def)
huffman@47325
    33
blanchet@55084
    34
lemmas fun_rel_eq = fun.rel_eq
huffman@47325
    35
huffman@47325
    36
lemma fun_rel_eq_rel:
blanchet@55084
    37
shows "fun_rel (op =) R = (\<lambda>f g. \<forall>x. R (f x) (g x))"
huffman@47325
    38
  by (simp add: fun_rel_def)
huffman@47325
    39
huffman@47325
    40
huffman@47325
    41
subsection {* Transfer method *}
huffman@47325
    42
huffman@47789
    43
text {* Explicit tag for relation membership allows for
huffman@47789
    44
  backward proof methods. *}
huffman@47325
    45
huffman@47325
    46
definition Rel :: "('a \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> bool"
huffman@47325
    47
  where "Rel r \<equiv> r"
huffman@47325
    48
huffman@49975
    49
text {* Handling of equality relations *}
huffman@49975
    50
huffman@49975
    51
definition is_equality :: "('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> bool"
huffman@49975
    52
  where "is_equality R \<longleftrightarrow> R = (op =)"
huffman@49975
    53
kuncar@51437
    54
lemma is_equality_eq: "is_equality (op =)"
kuncar@51437
    55
  unfolding is_equality_def by simp
kuncar@51437
    56
huffman@52354
    57
text {* Reverse implication for monotonicity rules *}
huffman@52354
    58
huffman@52354
    59
definition rev_implies where
huffman@52354
    60
  "rev_implies x y \<longleftrightarrow> (y \<longrightarrow> x)"
huffman@52354
    61
huffman@47325
    62
text {* Handling of meta-logic connectives *}
huffman@47325
    63
huffman@47325
    64
definition transfer_forall where
huffman@47325
    65
  "transfer_forall \<equiv> All"
huffman@47325
    66
huffman@47325
    67
definition transfer_implies where
huffman@47325
    68
  "transfer_implies \<equiv> op \<longrightarrow>"
huffman@47325
    69
huffman@47355
    70
definition transfer_bforall :: "('a \<Rightarrow> bool) \<Rightarrow> ('a \<Rightarrow> bool) \<Rightarrow> bool"
huffman@47355
    71
  where "transfer_bforall \<equiv> (\<lambda>P Q. \<forall>x. P x \<longrightarrow> Q x)"
huffman@47355
    72
huffman@47325
    73
lemma transfer_forall_eq: "(\<And>x. P x) \<equiv> Trueprop (transfer_forall (\<lambda>x. P x))"
huffman@47325
    74
  unfolding atomize_all transfer_forall_def ..
huffman@47325
    75
huffman@47325
    76
lemma transfer_implies_eq: "(A \<Longrightarrow> B) \<equiv> Trueprop (transfer_implies A B)"
huffman@47325
    77
  unfolding atomize_imp transfer_implies_def ..
huffman@47325
    78
huffman@47355
    79
lemma transfer_bforall_unfold:
huffman@47355
    80
  "Trueprop (transfer_bforall P (\<lambda>x. Q x)) \<equiv> (\<And>x. P x \<Longrightarrow> Q x)"
huffman@47355
    81
  unfolding transfer_bforall_def atomize_imp atomize_all ..
huffman@47355
    82
huffman@47658
    83
lemma transfer_start: "\<lbrakk>P; Rel (op =) P Q\<rbrakk> \<Longrightarrow> Q"
huffman@47325
    84
  unfolding Rel_def by simp
huffman@47325
    85
huffman@47658
    86
lemma transfer_start': "\<lbrakk>P; Rel (op \<longrightarrow>) P Q\<rbrakk> \<Longrightarrow> Q"
huffman@47325
    87
  unfolding Rel_def by simp
huffman@47325
    88
huffman@47635
    89
lemma transfer_prover_start: "\<lbrakk>x = x'; Rel R x' y\<rbrakk> \<Longrightarrow> Rel R x y"
huffman@47618
    90
  by simp
huffman@47618
    91
huffman@52358
    92
lemma untransfer_start: "\<lbrakk>Q; Rel (op =) P Q\<rbrakk> \<Longrightarrow> P"
huffman@52358
    93
  unfolding Rel_def by simp
huffman@52358
    94
huffman@47325
    95
lemma Rel_eq_refl: "Rel (op =) x x"
huffman@47325
    96
  unfolding Rel_def ..
huffman@47325
    97
huffman@47789
    98
lemma Rel_app:
huffman@47523
    99
  assumes "Rel (A ===> B) f g" and "Rel A x y"
huffman@47789
   100
  shows "Rel B (f x) (g y)"
huffman@47789
   101
  using assms unfolding Rel_def fun_rel_def by fast
huffman@47523
   102
huffman@47789
   103
lemma Rel_abs:
huffman@47523
   104
  assumes "\<And>x y. Rel A x y \<Longrightarrow> Rel B (f x) (g y)"
huffman@47789
   105
  shows "Rel (A ===> B) (\<lambda>x. f x) (\<lambda>y. g y)"
huffman@47789
   106
  using assms unfolding Rel_def fun_rel_def by fast
huffman@47523
   107
kuncar@53011
   108
end
kuncar@53011
   109
wenzelm@48891
   110
ML_file "Tools/transfer.ML"
huffman@47325
   111
setup Transfer.setup
huffman@47325
   112
huffman@49975
   113
declare refl [transfer_rule]
huffman@49975
   114
huffman@47503
   115
declare fun_rel_eq [relator_eq]
huffman@47503
   116
huffman@47789
   117
hide_const (open) Rel
huffman@47325
   118
kuncar@53011
   119
context
kuncar@53011
   120
begin
kuncar@53011
   121
interpretation lifting_syntax .
kuncar@53011
   122
kuncar@51956
   123
text {* Handling of domains *}
kuncar@51956
   124
kuncar@51956
   125
lemma Domaimp_refl[transfer_domain_rule]:
kuncar@51956
   126
  "Domainp T = Domainp T" ..
huffman@47325
   127
huffman@47325
   128
subsection {* Predicates on relations, i.e. ``class constraints'' *}
huffman@47325
   129
huffman@47325
   130
definition right_total :: "('a \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> bool"
huffman@47325
   131
  where "right_total R \<longleftrightarrow> (\<forall>y. \<exists>x. R x y)"
huffman@47325
   132
huffman@47325
   133
definition right_unique :: "('a \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> bool"
huffman@47325
   134
  where "right_unique R \<longleftrightarrow> (\<forall>x y z. R x y \<longrightarrow> R x z \<longrightarrow> y = z)"
huffman@47325
   135
huffman@47325
   136
definition bi_total :: "('a \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> bool"
huffman@47325
   137
  where "bi_total R \<longleftrightarrow> (\<forall>x. \<exists>y. R x y) \<and> (\<forall>y. \<exists>x. R x y)"
huffman@47325
   138
huffman@47325
   139
definition bi_unique :: "('a \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> bool"
huffman@47325
   140
  where "bi_unique R \<longleftrightarrow>
huffman@47325
   141
    (\<forall>x y z. R x y \<longrightarrow> R x z \<longrightarrow> y = z) \<and>
huffman@47325
   142
    (\<forall>x y z. R x z \<longrightarrow> R y z \<longrightarrow> x = y)"
huffman@47325
   143
Andreas@53927
   144
lemma bi_uniqueDr: "\<lbrakk> bi_unique A; A x y; A x z \<rbrakk> \<Longrightarrow> y = z"
Andreas@53927
   145
by(simp add: bi_unique_def)
Andreas@53927
   146
Andreas@53927
   147
lemma bi_uniqueDl: "\<lbrakk> bi_unique A; A x y; A z y \<rbrakk> \<Longrightarrow> x = z"
Andreas@53927
   148
by(simp add: bi_unique_def)
Andreas@53927
   149
Andreas@53927
   150
lemma right_uniqueI: "(\<And>x y z. \<lbrakk> A x y; A x z \<rbrakk> \<Longrightarrow> y = z) \<Longrightarrow> right_unique A"
Andreas@53927
   151
unfolding right_unique_def by blast
Andreas@53927
   152
Andreas@53927
   153
lemma right_uniqueD: "\<lbrakk> right_unique A; A x y; A x z \<rbrakk> \<Longrightarrow> y = z"
Andreas@53927
   154
unfolding right_unique_def by blast
Andreas@53927
   155
huffman@47325
   156
lemma right_total_alt_def:
huffman@47325
   157
  "right_total R \<longleftrightarrow> ((R ===> op \<longrightarrow>) ===> op \<longrightarrow>) All All"
huffman@47325
   158
  unfolding right_total_def fun_rel_def
huffman@47325
   159
  apply (rule iffI, fast)
huffman@47325
   160
  apply (rule allI)
huffman@47325
   161
  apply (drule_tac x="\<lambda>x. True" in spec)
huffman@47325
   162
  apply (drule_tac x="\<lambda>y. \<exists>x. R x y" in spec)
huffman@47325
   163
  apply fast
huffman@47325
   164
  done
huffman@47325
   165
huffman@47325
   166
lemma right_unique_alt_def:
huffman@47325
   167
  "right_unique R \<longleftrightarrow> (R ===> R ===> op \<longrightarrow>) (op =) (op =)"
huffman@47325
   168
  unfolding right_unique_def fun_rel_def by auto
huffman@47325
   169
huffman@47325
   170
lemma bi_total_alt_def:
huffman@47325
   171
  "bi_total R \<longleftrightarrow> ((R ===> op =) ===> op =) All All"
huffman@47325
   172
  unfolding bi_total_def fun_rel_def
huffman@47325
   173
  apply (rule iffI, fast)
huffman@47325
   174
  apply safe
huffman@47325
   175
  apply (drule_tac x="\<lambda>x. \<exists>y. R x y" in spec)
huffman@47325
   176
  apply (drule_tac x="\<lambda>y. True" in spec)
huffman@47325
   177
  apply fast
huffman@47325
   178
  apply (drule_tac x="\<lambda>x. True" in spec)
huffman@47325
   179
  apply (drule_tac x="\<lambda>y. \<exists>x. R x y" in spec)
huffman@47325
   180
  apply fast
huffman@47325
   181
  done
huffman@47325
   182
huffman@47325
   183
lemma bi_unique_alt_def:
huffman@47325
   184
  "bi_unique R \<longleftrightarrow> (R ===> R ===> op =) (op =) (op =)"
huffman@47325
   185
  unfolding bi_unique_def fun_rel_def by auto
huffman@47325
   186
Andreas@53944
   187
lemma bi_unique_conversep [simp]: "bi_unique R\<inverse>\<inverse> = bi_unique R"
Andreas@53944
   188
by(auto simp add: bi_unique_def)
Andreas@53944
   189
Andreas@53944
   190
lemma bi_total_conversep [simp]: "bi_total R\<inverse>\<inverse> = bi_total R"
Andreas@53944
   191
by(auto simp add: bi_total_def)
Andreas@53944
   192
huffman@47660
   193
text {* Properties are preserved by relation composition. *}
huffman@47660
   194
huffman@47660
   195
lemma OO_def: "R OO S = (\<lambda>x z. \<exists>y. R x y \<and> S y z)"
huffman@47660
   196
  by auto
huffman@47660
   197
huffman@47660
   198
lemma bi_total_OO: "\<lbrakk>bi_total A; bi_total B\<rbrakk> \<Longrightarrow> bi_total (A OO B)"
huffman@47660
   199
  unfolding bi_total_def OO_def by metis
huffman@47660
   200
huffman@47660
   201
lemma bi_unique_OO: "\<lbrakk>bi_unique A; bi_unique B\<rbrakk> \<Longrightarrow> bi_unique (A OO B)"
huffman@47660
   202
  unfolding bi_unique_def OO_def by metis
huffman@47660
   203
huffman@47660
   204
lemma right_total_OO:
huffman@47660
   205
  "\<lbrakk>right_total A; right_total B\<rbrakk> \<Longrightarrow> right_total (A OO B)"
huffman@47660
   206
  unfolding right_total_def OO_def by metis
huffman@47660
   207
huffman@47660
   208
lemma right_unique_OO:
huffman@47660
   209
  "\<lbrakk>right_unique A; right_unique B\<rbrakk> \<Longrightarrow> right_unique (A OO B)"
huffman@47660
   210
  unfolding right_unique_def OO_def by metis
huffman@47660
   211
huffman@47325
   212
huffman@47325
   213
subsection {* Properties of relators *}
huffman@47325
   214
huffman@47325
   215
lemma right_total_eq [transfer_rule]: "right_total (op =)"
huffman@47325
   216
  unfolding right_total_def by simp
huffman@47325
   217
huffman@47325
   218
lemma right_unique_eq [transfer_rule]: "right_unique (op =)"
huffman@47325
   219
  unfolding right_unique_def by simp
huffman@47325
   220
huffman@47325
   221
lemma bi_total_eq [transfer_rule]: "bi_total (op =)"
huffman@47325
   222
  unfolding bi_total_def by simp
huffman@47325
   223
huffman@47325
   224
lemma bi_unique_eq [transfer_rule]: "bi_unique (op =)"
huffman@47325
   225
  unfolding bi_unique_def by simp
huffman@47325
   226
huffman@47325
   227
lemma right_total_fun [transfer_rule]:
huffman@47325
   228
  "\<lbrakk>right_unique A; right_total B\<rbrakk> \<Longrightarrow> right_total (A ===> B)"
huffman@47325
   229
  unfolding right_total_def fun_rel_def
huffman@47325
   230
  apply (rule allI, rename_tac g)
huffman@47325
   231
  apply (rule_tac x="\<lambda>x. SOME z. B z (g (THE y. A x y))" in exI)
huffman@47325
   232
  apply clarify
huffman@47325
   233
  apply (subgoal_tac "(THE y. A x y) = y", simp)
huffman@47325
   234
  apply (rule someI_ex)
huffman@47325
   235
  apply (simp)
huffman@47325
   236
  apply (rule the_equality)
huffman@47325
   237
  apply assumption
huffman@47325
   238
  apply (simp add: right_unique_def)
huffman@47325
   239
  done
huffman@47325
   240
huffman@47325
   241
lemma right_unique_fun [transfer_rule]:
huffman@47325
   242
  "\<lbrakk>right_total A; right_unique B\<rbrakk> \<Longrightarrow> right_unique (A ===> B)"
huffman@47325
   243
  unfolding right_total_def right_unique_def fun_rel_def
huffman@47325
   244
  by (clarify, rule ext, fast)
huffman@47325
   245
huffman@47325
   246
lemma bi_total_fun [transfer_rule]:
huffman@47325
   247
  "\<lbrakk>bi_unique A; bi_total B\<rbrakk> \<Longrightarrow> bi_total (A ===> B)"
huffman@47325
   248
  unfolding bi_total_def fun_rel_def
huffman@47325
   249
  apply safe
huffman@47325
   250
  apply (rename_tac f)
huffman@47325
   251
  apply (rule_tac x="\<lambda>y. SOME z. B (f (THE x. A x y)) z" in exI)
huffman@47325
   252
  apply clarify
huffman@47325
   253
  apply (subgoal_tac "(THE x. A x y) = x", simp)
huffman@47325
   254
  apply (rule someI_ex)
huffman@47325
   255
  apply (simp)
huffman@47325
   256
  apply (rule the_equality)
huffman@47325
   257
  apply assumption
huffman@47325
   258
  apply (simp add: bi_unique_def)
huffman@47325
   259
  apply (rename_tac g)
huffman@47325
   260
  apply (rule_tac x="\<lambda>x. SOME z. B z (g (THE y. A x y))" in exI)
huffman@47325
   261
  apply clarify
huffman@47325
   262
  apply (subgoal_tac "(THE y. A x y) = y", simp)
huffman@47325
   263
  apply (rule someI_ex)
huffman@47325
   264
  apply (simp)
huffman@47325
   265
  apply (rule the_equality)
huffman@47325
   266
  apply assumption
huffman@47325
   267
  apply (simp add: bi_unique_def)
huffman@47325
   268
  done
huffman@47325
   269
huffman@47325
   270
lemma bi_unique_fun [transfer_rule]:
huffman@47325
   271
  "\<lbrakk>bi_total A; bi_unique B\<rbrakk> \<Longrightarrow> bi_unique (A ===> B)"
huffman@47325
   272
  unfolding bi_total_def bi_unique_def fun_rel_def fun_eq_iff
huffman@47325
   273
  by (safe, metis, fast)
huffman@47325
   274
huffman@47325
   275
huffman@47635
   276
subsection {* Transfer rules *}
huffman@47325
   277
kuncar@53952
   278
lemma Domainp_iff: "Domainp T x \<longleftrightarrow> (\<exists>y. T x y)"
kuncar@53952
   279
  by auto
kuncar@53952
   280
kuncar@53952
   281
lemma Domainp_forall_transfer [transfer_rule]:
kuncar@53952
   282
  assumes "right_total A"
kuncar@53952
   283
  shows "((A ===> op =) ===> op =)
kuncar@53952
   284
    (transfer_bforall (Domainp A)) transfer_forall"
kuncar@53952
   285
  using assms unfolding right_total_def
kuncar@53952
   286
  unfolding transfer_forall_def transfer_bforall_def fun_rel_def Domainp_iff
kuncar@53952
   287
  by metis
kuncar@53952
   288
huffman@47684
   289
text {* Transfer rules using implication instead of equality on booleans. *}
huffman@47684
   290
huffman@52354
   291
lemma transfer_forall_transfer [transfer_rule]:
huffman@52354
   292
  "bi_total A \<Longrightarrow> ((A ===> op =) ===> op =) transfer_forall transfer_forall"
huffman@52354
   293
  "right_total A \<Longrightarrow> ((A ===> op =) ===> implies) transfer_forall transfer_forall"
huffman@52354
   294
  "right_total A \<Longrightarrow> ((A ===> implies) ===> implies) transfer_forall transfer_forall"
huffman@52354
   295
  "bi_total A \<Longrightarrow> ((A ===> op =) ===> rev_implies) transfer_forall transfer_forall"
huffman@52354
   296
  "bi_total A \<Longrightarrow> ((A ===> rev_implies) ===> rev_implies) transfer_forall transfer_forall"
huffman@52354
   297
  unfolding transfer_forall_def rev_implies_def fun_rel_def right_total_def bi_total_def
huffman@52354
   298
  by metis+
huffman@52354
   299
huffman@52354
   300
lemma transfer_implies_transfer [transfer_rule]:
huffman@52354
   301
  "(op =        ===> op =        ===> op =       ) transfer_implies transfer_implies"
huffman@52354
   302
  "(rev_implies ===> implies     ===> implies    ) transfer_implies transfer_implies"
huffman@52354
   303
  "(rev_implies ===> op =        ===> implies    ) transfer_implies transfer_implies"
huffman@52354
   304
  "(op =        ===> implies     ===> implies    ) transfer_implies transfer_implies"
huffman@52354
   305
  "(op =        ===> op =        ===> implies    ) transfer_implies transfer_implies"
huffman@52354
   306
  "(implies     ===> rev_implies ===> rev_implies) transfer_implies transfer_implies"
huffman@52354
   307
  "(implies     ===> op =        ===> rev_implies) transfer_implies transfer_implies"
huffman@52354
   308
  "(op =        ===> rev_implies ===> rev_implies) transfer_implies transfer_implies"
huffman@52354
   309
  "(op =        ===> op =        ===> rev_implies) transfer_implies transfer_implies"
huffman@52354
   310
  unfolding transfer_implies_def rev_implies_def fun_rel_def by auto
huffman@52354
   311
huffman@47684
   312
lemma eq_imp_transfer [transfer_rule]:
huffman@47684
   313
  "right_unique A \<Longrightarrow> (A ===> A ===> op \<longrightarrow>) (op =) (op =)"
huffman@47684
   314
  unfolding right_unique_alt_def .
huffman@47684
   315
huffman@47636
   316
lemma eq_transfer [transfer_rule]:
huffman@47325
   317
  assumes "bi_unique A"
huffman@47325
   318
  shows "(A ===> A ===> op =) (op =) (op =)"
huffman@47325
   319
  using assms unfolding bi_unique_def fun_rel_def by auto
huffman@47325
   320
kuncar@51956
   321
lemma right_total_Ex_transfer[transfer_rule]:
kuncar@51956
   322
  assumes "right_total A"
kuncar@51956
   323
  shows "((A ===> op=) ===> op=) (Bex (Collect (Domainp A))) Ex"
kuncar@51956
   324
using assms unfolding right_total_def Bex_def fun_rel_def Domainp_iff[abs_def]
kuncar@51956
   325
by blast
kuncar@51956
   326
kuncar@51956
   327
lemma right_total_All_transfer[transfer_rule]:
kuncar@51956
   328
  assumes "right_total A"
kuncar@51956
   329
  shows "((A ===> op =) ===> op =) (Ball (Collect (Domainp A))) All"
kuncar@51956
   330
using assms unfolding right_total_def Ball_def fun_rel_def Domainp_iff[abs_def]
kuncar@51956
   331
by blast
kuncar@51956
   332
huffman@47636
   333
lemma All_transfer [transfer_rule]:
huffman@47325
   334
  assumes "bi_total A"
huffman@47325
   335
  shows "((A ===> op =) ===> op =) All All"
huffman@47325
   336
  using assms unfolding bi_total_def fun_rel_def by fast
huffman@47325
   337
huffman@47636
   338
lemma Ex_transfer [transfer_rule]:
huffman@47325
   339
  assumes "bi_total A"
huffman@47325
   340
  shows "((A ===> op =) ===> op =) Ex Ex"
huffman@47325
   341
  using assms unfolding bi_total_def fun_rel_def by fast
huffman@47325
   342
huffman@47636
   343
lemma If_transfer [transfer_rule]: "(op = ===> A ===> A ===> A) If If"
huffman@47325
   344
  unfolding fun_rel_def by simp
huffman@47325
   345
huffman@47636
   346
lemma Let_transfer [transfer_rule]: "(A ===> (A ===> B) ===> B) Let Let"
huffman@47612
   347
  unfolding fun_rel_def by simp
huffman@47612
   348
huffman@47636
   349
lemma id_transfer [transfer_rule]: "(A ===> A) id id"
huffman@47625
   350
  unfolding fun_rel_def by simp
huffman@47625
   351
huffman@47636
   352
lemma comp_transfer [transfer_rule]:
huffman@47325
   353
  "((B ===> C) ===> (A ===> B) ===> (A ===> C)) (op \<circ>) (op \<circ>)"
huffman@47325
   354
  unfolding fun_rel_def by simp
huffman@47325
   355
huffman@47636
   356
lemma fun_upd_transfer [transfer_rule]:
huffman@47325
   357
  assumes [transfer_rule]: "bi_unique A"
huffman@47325
   358
  shows "((A ===> B) ===> A ===> B ===> A ===> B) fun_upd fun_upd"
huffman@47635
   359
  unfolding fun_upd_def [abs_def] by transfer_prover
huffman@47325
   360
huffman@47637
   361
lemma nat_case_transfer [transfer_rule]:
huffman@47637
   362
  "(A ===> (op = ===> A) ===> op = ===> A) nat_case nat_case"
huffman@47637
   363
  unfolding fun_rel_def by (simp split: nat.split)
huffman@47627
   364
huffman@47924
   365
lemma nat_rec_transfer [transfer_rule]:
huffman@47924
   366
  "(A ===> (op = ===> A ===> A) ===> op = ===> A) nat_rec nat_rec"
huffman@47924
   367
  unfolding fun_rel_def by (clarsimp, rename_tac n, induct_tac n, simp_all)
huffman@47924
   368
huffman@47924
   369
lemma funpow_transfer [transfer_rule]:
huffman@47924
   370
  "(op = ===> (A ===> A) ===> (A ===> A)) compow compow"
huffman@47924
   371
  unfolding funpow_def by transfer_prover
huffman@47924
   372
kuncar@53952
   373
lemma mono_transfer[transfer_rule]:
kuncar@53952
   374
  assumes [transfer_rule]: "bi_total A"
kuncar@53952
   375
  assumes [transfer_rule]: "(A ===> A ===> op=) op\<le> op\<le>"
kuncar@53952
   376
  assumes [transfer_rule]: "(B ===> B ===> op=) op\<le> op\<le>"
kuncar@53952
   377
  shows "((A ===> B) ===> op=) mono mono"
kuncar@53952
   378
unfolding mono_def[abs_def] by transfer_prover
kuncar@53952
   379
kuncar@53952
   380
lemma right_total_relcompp_transfer[transfer_rule]: 
kuncar@53952
   381
  assumes [transfer_rule]: "right_total B"
kuncar@53952
   382
  shows "((A ===> B ===> op=) ===> (B ===> C ===> op=) ===> A ===> C ===> op=) 
kuncar@53952
   383
    (\<lambda>R S x z. \<exists>y\<in>Collect (Domainp B). R x y \<and> S y z) op OO"
kuncar@53952
   384
unfolding OO_def[abs_def] by transfer_prover
kuncar@53952
   385
kuncar@53952
   386
lemma relcompp_transfer[transfer_rule]: 
kuncar@53952
   387
  assumes [transfer_rule]: "bi_total B"
kuncar@53952
   388
  shows "((A ===> B ===> op=) ===> (B ===> C ===> op=) ===> A ===> C ===> op=) op OO op OO"
kuncar@53952
   389
unfolding OO_def[abs_def] by transfer_prover
huffman@47627
   390
kuncar@53952
   391
lemma right_total_Domainp_transfer[transfer_rule]:
kuncar@53952
   392
  assumes [transfer_rule]: "right_total B"
kuncar@53952
   393
  shows "((A ===> B ===> op=) ===> A ===> op=) (\<lambda>T x. \<exists>y\<in>Collect(Domainp B). T x y) Domainp"
kuncar@53952
   394
apply(subst(2) Domainp_iff[abs_def]) by transfer_prover
kuncar@53952
   395
kuncar@53952
   396
lemma Domainp_transfer[transfer_rule]:
kuncar@53952
   397
  assumes [transfer_rule]: "bi_total B"
kuncar@53952
   398
  shows "((A ===> B ===> op=) ===> A ===> op=) Domainp Domainp"
kuncar@53952
   399
unfolding Domainp_iff[abs_def] by transfer_prover
kuncar@53952
   400
kuncar@53952
   401
lemma reflp_transfer[transfer_rule]: 
kuncar@53952
   402
  "bi_total A \<Longrightarrow> ((A ===> A ===> op=) ===> op=) reflp reflp"
kuncar@53952
   403
  "right_total A \<Longrightarrow> ((A ===> A ===> implies) ===> implies) reflp reflp"
kuncar@53952
   404
  "right_total A \<Longrightarrow> ((A ===> A ===> op=) ===> implies) reflp reflp"
kuncar@53952
   405
  "bi_total A \<Longrightarrow> ((A ===> A ===> rev_implies) ===> rev_implies) reflp reflp"
kuncar@53952
   406
  "bi_total A \<Longrightarrow> ((A ===> A ===> op=) ===> rev_implies) reflp reflp"
kuncar@53952
   407
using assms unfolding reflp_def[abs_def] rev_implies_def bi_total_def right_total_def fun_rel_def 
kuncar@53952
   408
by fast+
kuncar@53952
   409
kuncar@53952
   410
lemma right_unique_transfer [transfer_rule]:
kuncar@53952
   411
  assumes [transfer_rule]: "right_total A"
kuncar@53952
   412
  assumes [transfer_rule]: "right_total B"
kuncar@53952
   413
  assumes [transfer_rule]: "bi_unique B"
kuncar@53952
   414
  shows "((A ===> B ===> op=) ===> implies) right_unique right_unique"
kuncar@53952
   415
using assms unfolding right_unique_def[abs_def] right_total_def bi_unique_def fun_rel_def
kuncar@53952
   416
by metis
huffman@47325
   417
huffman@47325
   418
end
kuncar@53011
   419
kuncar@53011
   420
end