src/HOL/Transfer.thy
author huffman
Tue, 17 Apr 2012 14:00:09 +0200
changeset 47523 1bf0e92c1ca0
parent 47503 cb44d09d9d22
child 47612 bc9c7b5c26fd
permissions -rw-r--r--
make transfer method more deterministic by using SOLVED' on some subgoals
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
47325
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
     1
(*  Title:      HOL/Transfer.thy
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
     2
    Author:     Brian Huffman, TU Muenchen
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
     3
*)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
     4
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
     5
header {* Generic theorem transfer using relations *}
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
     6
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
     7
theory Transfer
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
     8
imports Plain Hilbert_Choice
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
     9
uses ("Tools/transfer.ML")
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    10
begin
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    11
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    12
subsection {* Relator for function space *}
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    13
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    14
definition
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    15
  fun_rel :: "('a \<Rightarrow> 'c \<Rightarrow> bool) \<Rightarrow> ('b \<Rightarrow> 'd \<Rightarrow> bool) \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> ('c \<Rightarrow> 'd) \<Rightarrow> bool" (infixr "===>" 55)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    16
where
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    17
  "fun_rel A B = (\<lambda>f g. \<forall>x y. A x y \<longrightarrow> B (f x) (g y))"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    18
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    19
lemma fun_relI [intro]:
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    20
  assumes "\<And>x y. A x y \<Longrightarrow> B (f x) (g y)"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    21
  shows "(A ===> B) f g"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    22
  using assms by (simp add: fun_rel_def)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    23
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    24
lemma fun_relD:
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    25
  assumes "(A ===> B) f g" and "A x y"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    26
  shows "B (f x) (g y)"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    27
  using assms by (simp add: fun_rel_def)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    28
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    29
lemma fun_relE:
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    30
  assumes "(A ===> B) f g" and "A x y"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    31
  obtains "B (f x) (g y)"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    32
  using assms by (simp add: fun_rel_def)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    33
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    34
lemma fun_rel_eq:
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    35
  shows "((op =) ===> (op =)) = (op =)"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    36
  by (auto simp add: fun_eq_iff elim: fun_relE)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    37
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    38
lemma fun_rel_eq_rel:
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    39
  shows "((op =) ===> R) = (\<lambda>f g. \<forall>x. R (f x) (g x))"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    40
  by (simp add: fun_rel_def)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    41
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    42
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    43
subsection {* Transfer method *}
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    44
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    45
text {* Explicit tags for application, abstraction, and relation
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    46
membership allow for backward proof methods. *}
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    47
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    48
definition App :: "('a \<Rightarrow> 'b) \<Rightarrow> 'a \<Rightarrow> 'b"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    49
  where "App f \<equiv> f"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    50
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    51
definition Abs :: "('a \<Rightarrow> 'b) \<Rightarrow> 'a \<Rightarrow> 'b"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    52
  where "Abs f \<equiv> f"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    53
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    54
definition Rel :: "('a \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> bool"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    55
  where "Rel r \<equiv> r"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    56
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    57
text {* Handling of meta-logic connectives *}
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    58
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    59
definition transfer_forall where
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    60
  "transfer_forall \<equiv> All"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    61
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    62
definition transfer_implies where
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    63
  "transfer_implies \<equiv> op \<longrightarrow>"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    64
47355
3d9d98e0f1a4 add bounded quantifier constant transfer_bforall, whose definition is unfolded after transfer
huffman
parents: 47325
diff changeset
    65
definition transfer_bforall :: "('a \<Rightarrow> bool) \<Rightarrow> ('a \<Rightarrow> bool) \<Rightarrow> bool"
3d9d98e0f1a4 add bounded quantifier constant transfer_bforall, whose definition is unfolded after transfer
huffman
parents: 47325
diff changeset
    66
  where "transfer_bforall \<equiv> (\<lambda>P Q. \<forall>x. P x \<longrightarrow> Q x)"
3d9d98e0f1a4 add bounded quantifier constant transfer_bforall, whose definition is unfolded after transfer
huffman
parents: 47325
diff changeset
    67
47325
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    68
lemma transfer_forall_eq: "(\<And>x. P x) \<equiv> Trueprop (transfer_forall (\<lambda>x. P x))"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    69
  unfolding atomize_all transfer_forall_def ..
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    70
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    71
lemma transfer_implies_eq: "(A \<Longrightarrow> B) \<equiv> Trueprop (transfer_implies A B)"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    72
  unfolding atomize_imp transfer_implies_def ..
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    73
47355
3d9d98e0f1a4 add bounded quantifier constant transfer_bforall, whose definition is unfolded after transfer
huffman
parents: 47325
diff changeset
    74
lemma transfer_bforall_unfold:
3d9d98e0f1a4 add bounded quantifier constant transfer_bforall, whose definition is unfolded after transfer
huffman
parents: 47325
diff changeset
    75
  "Trueprop (transfer_bforall P (\<lambda>x. Q x)) \<equiv> (\<And>x. P x \<Longrightarrow> Q x)"
3d9d98e0f1a4 add bounded quantifier constant transfer_bforall, whose definition is unfolded after transfer
huffman
parents: 47325
diff changeset
    76
  unfolding transfer_bforall_def atomize_imp atomize_all ..
3d9d98e0f1a4 add bounded quantifier constant transfer_bforall, whose definition is unfolded after transfer
huffman
parents: 47325
diff changeset
    77
47325
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    78
lemma transfer_start: "\<lbrakk>Rel (op =) P Q; P\<rbrakk> \<Longrightarrow> Q"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    79
  unfolding Rel_def by simp
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    80
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    81
lemma transfer_start': "\<lbrakk>Rel (op \<longrightarrow>) P Q; P\<rbrakk> \<Longrightarrow> Q"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    82
  unfolding Rel_def by simp
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    83
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    84
lemma Rel_eq_refl: "Rel (op =) x x"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    85
  unfolding Rel_def ..
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    86
47523
1bf0e92c1ca0 make transfer method more deterministic by using SOLVED' on some subgoals
huffman
parents: 47503
diff changeset
    87
lemma Rel_App:
1bf0e92c1ca0 make transfer method more deterministic by using SOLVED' on some subgoals
huffman
parents: 47503
diff changeset
    88
  assumes "Rel (A ===> B) f g" and "Rel A x y"
1bf0e92c1ca0 make transfer method more deterministic by using SOLVED' on some subgoals
huffman
parents: 47503
diff changeset
    89
  shows "Rel B (App f x) (App g y)"
1bf0e92c1ca0 make transfer method more deterministic by using SOLVED' on some subgoals
huffman
parents: 47503
diff changeset
    90
  using assms unfolding Rel_def App_def fun_rel_def by fast
1bf0e92c1ca0 make transfer method more deterministic by using SOLVED' on some subgoals
huffman
parents: 47503
diff changeset
    91
1bf0e92c1ca0 make transfer method more deterministic by using SOLVED' on some subgoals
huffman
parents: 47503
diff changeset
    92
lemma Rel_Abs:
1bf0e92c1ca0 make transfer method more deterministic by using SOLVED' on some subgoals
huffman
parents: 47503
diff changeset
    93
  assumes "\<And>x y. Rel A x y \<Longrightarrow> Rel B (f x) (g y)"
1bf0e92c1ca0 make transfer method more deterministic by using SOLVED' on some subgoals
huffman
parents: 47503
diff changeset
    94
  shows "Rel (A ===> B) (Abs (\<lambda>x. f x)) (Abs (\<lambda>y. g y))"
1bf0e92c1ca0 make transfer method more deterministic by using SOLVED' on some subgoals
huffman
parents: 47503
diff changeset
    95
  using assms unfolding Rel_def Abs_def fun_rel_def by fast
1bf0e92c1ca0 make transfer method more deterministic by using SOLVED' on some subgoals
huffman
parents: 47503
diff changeset
    96
47325
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    97
use "Tools/transfer.ML"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    98
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    99
setup Transfer.setup
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   100
47503
cb44d09d9d22 add theory data for relator identity rules;
huffman
parents: 47355
diff changeset
   101
declare fun_rel_eq [relator_eq]
cb44d09d9d22 add theory data for relator identity rules;
huffman
parents: 47355
diff changeset
   102
47325
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   103
hide_const (open) App Abs Rel
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   104
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   105
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   106
subsection {* Predicates on relations, i.e. ``class constraints'' *}
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   107
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   108
definition right_total :: "('a \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> bool"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   109
  where "right_total R \<longleftrightarrow> (\<forall>y. \<exists>x. R x y)"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   110
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   111
definition right_unique :: "('a \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> bool"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   112
  where "right_unique R \<longleftrightarrow> (\<forall>x y z. R x y \<longrightarrow> R x z \<longrightarrow> y = z)"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   113
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   114
definition bi_total :: "('a \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> bool"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   115
  where "bi_total R \<longleftrightarrow> (\<forall>x. \<exists>y. R x y) \<and> (\<forall>y. \<exists>x. R x y)"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   116
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   117
definition bi_unique :: "('a \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> bool"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   118
  where "bi_unique R \<longleftrightarrow>
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   119
    (\<forall>x y z. R x y \<longrightarrow> R x z \<longrightarrow> y = z) \<and>
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   120
    (\<forall>x y z. R x z \<longrightarrow> R y z \<longrightarrow> x = y)"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   121
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   122
lemma right_total_alt_def:
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   123
  "right_total R \<longleftrightarrow> ((R ===> op \<longrightarrow>) ===> op \<longrightarrow>) All All"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   124
  unfolding right_total_def fun_rel_def
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   125
  apply (rule iffI, fast)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   126
  apply (rule allI)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   127
  apply (drule_tac x="\<lambda>x. True" in spec)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   128
  apply (drule_tac x="\<lambda>y. \<exists>x. R x y" in spec)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   129
  apply fast
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   130
  done
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   131
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   132
lemma right_unique_alt_def:
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   133
  "right_unique R \<longleftrightarrow> (R ===> R ===> op \<longrightarrow>) (op =) (op =)"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   134
  unfolding right_unique_def fun_rel_def by auto
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   135
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   136
lemma bi_total_alt_def:
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   137
  "bi_total R \<longleftrightarrow> ((R ===> op =) ===> op =) All All"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   138
  unfolding bi_total_def fun_rel_def
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   139
  apply (rule iffI, fast)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   140
  apply safe
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   141
  apply (drule_tac x="\<lambda>x. \<exists>y. R x y" in spec)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   142
  apply (drule_tac x="\<lambda>y. True" in spec)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   143
  apply fast
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   144
  apply (drule_tac x="\<lambda>x. True" in spec)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   145
  apply (drule_tac x="\<lambda>y. \<exists>x. R x y" in spec)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   146
  apply fast
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   147
  done
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   148
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   149
lemma bi_unique_alt_def:
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   150
  "bi_unique R \<longleftrightarrow> (R ===> R ===> op =) (op =) (op =)"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   151
  unfolding bi_unique_def fun_rel_def by auto
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   152
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   153
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   154
subsection {* Properties of relators *}
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   155
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   156
lemma right_total_eq [transfer_rule]: "right_total (op =)"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   157
  unfolding right_total_def by simp
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   158
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   159
lemma right_unique_eq [transfer_rule]: "right_unique (op =)"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   160
  unfolding right_unique_def by simp
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   161
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   162
lemma bi_total_eq [transfer_rule]: "bi_total (op =)"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   163
  unfolding bi_total_def by simp
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   164
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   165
lemma bi_unique_eq [transfer_rule]: "bi_unique (op =)"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   166
  unfolding bi_unique_def by simp
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   167
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   168
lemma right_total_fun [transfer_rule]:
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   169
  "\<lbrakk>right_unique A; right_total B\<rbrakk> \<Longrightarrow> right_total (A ===> B)"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   170
  unfolding right_total_def fun_rel_def
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   171
  apply (rule allI, rename_tac g)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   172
  apply (rule_tac x="\<lambda>x. SOME z. B z (g (THE y. A x y))" in exI)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   173
  apply clarify
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   174
  apply (subgoal_tac "(THE y. A x y) = y", simp)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   175
  apply (rule someI_ex)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   176
  apply (simp)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   177
  apply (rule the_equality)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   178
  apply assumption
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   179
  apply (simp add: right_unique_def)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   180
  done
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   181
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   182
lemma right_unique_fun [transfer_rule]:
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   183
  "\<lbrakk>right_total A; right_unique B\<rbrakk> \<Longrightarrow> right_unique (A ===> B)"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   184
  unfolding right_total_def right_unique_def fun_rel_def
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   185
  by (clarify, rule ext, fast)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   186
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   187
lemma bi_total_fun [transfer_rule]:
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   188
  "\<lbrakk>bi_unique A; bi_total B\<rbrakk> \<Longrightarrow> bi_total (A ===> B)"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   189
  unfolding bi_total_def fun_rel_def
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   190
  apply safe
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   191
  apply (rename_tac f)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   192
  apply (rule_tac x="\<lambda>y. SOME z. B (f (THE x. A x y)) z" in exI)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   193
  apply clarify
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   194
  apply (subgoal_tac "(THE x. A x y) = x", simp)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   195
  apply (rule someI_ex)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   196
  apply (simp)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   197
  apply (rule the_equality)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   198
  apply assumption
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   199
  apply (simp add: bi_unique_def)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   200
  apply (rename_tac g)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   201
  apply (rule_tac x="\<lambda>x. SOME z. B z (g (THE y. A x y))" in exI)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   202
  apply clarify
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   203
  apply (subgoal_tac "(THE y. A x y) = y", simp)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   204
  apply (rule someI_ex)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   205
  apply (simp)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   206
  apply (rule the_equality)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   207
  apply assumption
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   208
  apply (simp add: bi_unique_def)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   209
  done
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   210
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   211
lemma bi_unique_fun [transfer_rule]:
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   212
  "\<lbrakk>bi_total A; bi_unique B\<rbrakk> \<Longrightarrow> bi_unique (A ===> B)"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   213
  unfolding bi_total_def bi_unique_def fun_rel_def fun_eq_iff
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   214
  by (safe, metis, fast)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   215
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   216
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   217
subsection {* Correspondence rules *}
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   218
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   219
lemma eq_parametric [transfer_rule]:
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   220
  assumes "bi_unique A"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   221
  shows "(A ===> A ===> op =) (op =) (op =)"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   222
  using assms unfolding bi_unique_def fun_rel_def by auto
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   223
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   224
lemma All_parametric [transfer_rule]:
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   225
  assumes "bi_total A"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   226
  shows "((A ===> op =) ===> op =) All All"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   227
  using assms unfolding bi_total_def fun_rel_def by fast
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   228
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   229
lemma Ex_parametric [transfer_rule]:
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   230
  assumes "bi_total A"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   231
  shows "((A ===> op =) ===> op =) Ex Ex"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   232
  using assms unfolding bi_total_def fun_rel_def by fast
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   233
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   234
lemma If_parametric [transfer_rule]: "(op = ===> A ===> A ===> A) If If"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   235
  unfolding fun_rel_def by simp
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   236
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   237
lemma comp_parametric [transfer_rule]:
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   238
  "((B ===> C) ===> (A ===> B) ===> (A ===> C)) (op \<circ>) (op \<circ>)"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   239
  unfolding fun_rel_def by simp
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   240
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   241
lemma fun_upd_parametric [transfer_rule]:
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   242
  assumes [transfer_rule]: "bi_unique A"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   243
  shows "((A ===> B) ===> A ===> B ===> A ===> B) fun_upd fun_upd"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   244
  unfolding fun_upd_def [abs_def] by correspondence
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   245
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   246
lemmas transfer_forall_parametric [transfer_rule]
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   247
  = All_parametric [folded transfer_forall_def]
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   248
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   249
end