src/HOL/Transfer.thy
author huffman
Fri, 20 Apr 2012 22:05:07 +0200
changeset 47637 7a34395441ff
parent 47636 b786388b4b3a
child 47658 7631f6f7873d
permissions -rw-r--r--
add transfer rule for nat_case
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
47635
ebb79474262c rename 'correspondence' method to 'transfer_prover'
huffman
parents: 47627
diff changeset
    84
lemma transfer_prover_start: "\<lbrakk>x = x'; Rel R x' y\<rbrakk> \<Longrightarrow> Rel R x y"
47618
1568dadd598a make correspondence tactic more robust by replacing lhs with schematic variable before applying intro rules
huffman
parents: 47612
diff changeset
    85
  by simp
1568dadd598a make correspondence tactic more robust by replacing lhs with schematic variable before applying intro rules
huffman
parents: 47612
diff changeset
    86
47325
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    87
lemma Rel_eq_refl: "Rel (op =) x x"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    88
  unfolding Rel_def ..
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
    89
47523
1bf0e92c1ca0 make transfer method more deterministic by using SOLVED' on some subgoals
huffman
parents: 47503
diff changeset
    90
lemma Rel_App:
1bf0e92c1ca0 make transfer method more deterministic by using SOLVED' on some subgoals
huffman
parents: 47503
diff changeset
    91
  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
    92
  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
    93
  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
    94
1bf0e92c1ca0 make transfer method more deterministic by using SOLVED' on some subgoals
huffman
parents: 47503
diff changeset
    95
lemma Rel_Abs:
1bf0e92c1ca0 make transfer method more deterministic by using SOLVED' on some subgoals
huffman
parents: 47503
diff changeset
    96
  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
    97
  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
    98
  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
    99
47325
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   100
use "Tools/transfer.ML"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   101
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   102
setup Transfer.setup
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   103
47503
cb44d09d9d22 add theory data for relator identity rules;
huffman
parents: 47355
diff changeset
   104
declare fun_rel_eq [relator_eq]
cb44d09d9d22 add theory data for relator identity rules;
huffman
parents: 47355
diff changeset
   105
47325
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   106
hide_const (open) App Abs Rel
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   107
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   108
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   109
subsection {* Predicates on relations, i.e. ``class constraints'' *}
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   110
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   111
definition right_total :: "('a \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> bool"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   112
  where "right_total R \<longleftrightarrow> (\<forall>y. \<exists>x. R x y)"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   113
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   114
definition right_unique :: "('a \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> bool"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   115
  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
   116
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   117
definition bi_total :: "('a \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> bool"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   118
  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
   119
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   120
definition bi_unique :: "('a \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> bool"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   121
  where "bi_unique R \<longleftrightarrow>
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   122
    (\<forall>x y z. R x y \<longrightarrow> R x z \<longrightarrow> y = z) \<and>
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   123
    (\<forall>x y z. R x z \<longrightarrow> R y z \<longrightarrow> x = y)"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   124
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   125
lemma right_total_alt_def:
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   126
  "right_total R \<longleftrightarrow> ((R ===> op \<longrightarrow>) ===> op \<longrightarrow>) All All"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   127
  unfolding right_total_def fun_rel_def
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   128
  apply (rule iffI, fast)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   129
  apply (rule allI)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   130
  apply (drule_tac x="\<lambda>x. True" in spec)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   131
  apply (drule_tac x="\<lambda>y. \<exists>x. R x y" in spec)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   132
  apply fast
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   133
  done
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   134
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   135
lemma right_unique_alt_def:
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   136
  "right_unique R \<longleftrightarrow> (R ===> R ===> op \<longrightarrow>) (op =) (op =)"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   137
  unfolding right_unique_def fun_rel_def by auto
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   138
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   139
lemma bi_total_alt_def:
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   140
  "bi_total R \<longleftrightarrow> ((R ===> op =) ===> op =) All All"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   141
  unfolding bi_total_def fun_rel_def
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   142
  apply (rule iffI, fast)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   143
  apply safe
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   144
  apply (drule_tac x="\<lambda>x. \<exists>y. R x y" in spec)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   145
  apply (drule_tac x="\<lambda>y. True" in spec)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   146
  apply fast
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   147
  apply (drule_tac x="\<lambda>x. True" in spec)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   148
  apply (drule_tac x="\<lambda>y. \<exists>x. R x y" in spec)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   149
  apply fast
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   150
  done
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   151
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   152
lemma bi_unique_alt_def:
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   153
  "bi_unique R \<longleftrightarrow> (R ===> R ===> op =) (op =) (op =)"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   154
  unfolding bi_unique_def fun_rel_def by auto
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   155
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   156
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   157
subsection {* Properties of relators *}
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   158
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   159
lemma right_total_eq [transfer_rule]: "right_total (op =)"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   160
  unfolding right_total_def by simp
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   161
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   162
lemma right_unique_eq [transfer_rule]: "right_unique (op =)"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   163
  unfolding right_unique_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_total_eq [transfer_rule]: "bi_total (op =)"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   166
  unfolding bi_total_def by simp
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   167
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   168
lemma bi_unique_eq [transfer_rule]: "bi_unique (op =)"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   169
  unfolding bi_unique_def by simp
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   170
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   171
lemma right_total_fun [transfer_rule]:
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   172
  "\<lbrakk>right_unique A; right_total B\<rbrakk> \<Longrightarrow> right_total (A ===> B)"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   173
  unfolding right_total_def fun_rel_def
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   174
  apply (rule allI, rename_tac g)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   175
  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
   176
  apply clarify
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   177
  apply (subgoal_tac "(THE y. A x y) = y", simp)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   178
  apply (rule someI_ex)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   179
  apply (simp)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   180
  apply (rule the_equality)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   181
  apply assumption
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   182
  apply (simp add: right_unique_def)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   183
  done
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   184
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   185
lemma right_unique_fun [transfer_rule]:
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   186
  "\<lbrakk>right_total A; right_unique B\<rbrakk> \<Longrightarrow> right_unique (A ===> B)"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   187
  unfolding right_total_def right_unique_def fun_rel_def
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   188
  by (clarify, rule ext, fast)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   189
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   190
lemma bi_total_fun [transfer_rule]:
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   191
  "\<lbrakk>bi_unique A; bi_total B\<rbrakk> \<Longrightarrow> bi_total (A ===> B)"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   192
  unfolding bi_total_def fun_rel_def
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   193
  apply safe
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   194
  apply (rename_tac f)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   195
  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
   196
  apply clarify
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   197
  apply (subgoal_tac "(THE x. A x y) = x", simp)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   198
  apply (rule someI_ex)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   199
  apply (simp)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   200
  apply (rule the_equality)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   201
  apply assumption
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   202
  apply (simp add: bi_unique_def)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   203
  apply (rename_tac g)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   204
  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
   205
  apply clarify
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   206
  apply (subgoal_tac "(THE y. A x y) = y", simp)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   207
  apply (rule someI_ex)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   208
  apply (simp)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   209
  apply (rule the_equality)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   210
  apply assumption
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   211
  apply (simp add: bi_unique_def)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   212
  done
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   213
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   214
lemma bi_unique_fun [transfer_rule]:
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   215
  "\<lbrakk>bi_total A; bi_unique B\<rbrakk> \<Longrightarrow> bi_unique (A ===> B)"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   216
  unfolding bi_total_def bi_unique_def fun_rel_def fun_eq_iff
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   217
  by (safe, metis, fast)
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   218
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   219
47635
ebb79474262c rename 'correspondence' method to 'transfer_prover'
huffman
parents: 47627
diff changeset
   220
subsection {* Transfer rules *}
47325
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   221
47636
b786388b4b3a uniform naming scheme for transfer rules
huffman
parents: 47635
diff changeset
   222
lemma eq_transfer [transfer_rule]:
47325
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   223
  assumes "bi_unique A"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   224
  shows "(A ===> A ===> op =) (op =) (op =)"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   225
  using assms unfolding bi_unique_def fun_rel_def by auto
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   226
47636
b786388b4b3a uniform naming scheme for transfer rules
huffman
parents: 47635
diff changeset
   227
lemma All_transfer [transfer_rule]:
47325
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   228
  assumes "bi_total A"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   229
  shows "((A ===> op =) ===> op =) All All"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   230
  using assms unfolding bi_total_def fun_rel_def by fast
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   231
47636
b786388b4b3a uniform naming scheme for transfer rules
huffman
parents: 47635
diff changeset
   232
lemma Ex_transfer [transfer_rule]:
47325
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   233
  assumes "bi_total A"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   234
  shows "((A ===> op =) ===> op =) Ex Ex"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   235
  using assms unfolding bi_total_def fun_rel_def by fast
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   236
47636
b786388b4b3a uniform naming scheme for transfer rules
huffman
parents: 47635
diff changeset
   237
lemma If_transfer [transfer_rule]: "(op = ===> A ===> A ===> A) If If"
47325
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   238
  unfolding fun_rel_def by simp
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   239
47636
b786388b4b3a uniform naming scheme for transfer rules
huffman
parents: 47635
diff changeset
   240
lemma Let_transfer [transfer_rule]: "(A ===> (A ===> B) ===> B) Let Let"
47612
bc9c7b5c26fd add transfer rule for Let
huffman
parents: 47523
diff changeset
   241
  unfolding fun_rel_def by simp
bc9c7b5c26fd add transfer rule for Let
huffman
parents: 47523
diff changeset
   242
47636
b786388b4b3a uniform naming scheme for transfer rules
huffman
parents: 47635
diff changeset
   243
lemma id_transfer [transfer_rule]: "(A ===> A) id id"
47625
10cfaf771687 add transfer rule for 'id'
huffman
parents: 47618
diff changeset
   244
  unfolding fun_rel_def by simp
10cfaf771687 add transfer rule for 'id'
huffman
parents: 47618
diff changeset
   245
47636
b786388b4b3a uniform naming scheme for transfer rules
huffman
parents: 47635
diff changeset
   246
lemma comp_transfer [transfer_rule]:
47325
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   247
  "((B ===> C) ===> (A ===> B) ===> (A ===> C)) (op \<circ>) (op \<circ>)"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   248
  unfolding fun_rel_def by simp
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   249
47636
b786388b4b3a uniform naming scheme for transfer rules
huffman
parents: 47635
diff changeset
   250
lemma fun_upd_transfer [transfer_rule]:
47325
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   251
  assumes [transfer_rule]: "bi_unique A"
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   252
  shows "((A ===> B) ===> A ===> B ===> A ===> B) fun_upd fun_upd"
47635
ebb79474262c rename 'correspondence' method to 'transfer_prover'
huffman
parents: 47627
diff changeset
   253
  unfolding fun_upd_def [abs_def] by transfer_prover
47325
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   254
47637
7a34395441ff add transfer rule for nat_case
huffman
parents: 47636
diff changeset
   255
lemma nat_case_transfer [transfer_rule]:
7a34395441ff add transfer rule for nat_case
huffman
parents: 47636
diff changeset
   256
  "(A ===> (op = ===> A) ===> op = ===> A) nat_case nat_case"
7a34395441ff add transfer rule for nat_case
huffman
parents: 47636
diff changeset
   257
  unfolding fun_rel_def by (simp split: nat.split)
47627
2b1d3eda59eb add secondary transfer rule for universal quantifiers on non-bi-total relations
huffman
parents: 47625
diff changeset
   258
2b1d3eda59eb add secondary transfer rule for universal quantifiers on non-bi-total relations
huffman
parents: 47625
diff changeset
   259
text {* Fallback rule for transferring universal quantifiers over
2b1d3eda59eb add secondary transfer rule for universal quantifiers on non-bi-total relations
huffman
parents: 47625
diff changeset
   260
  correspondence relations that are not bi-total, and do not have
2b1d3eda59eb add secondary transfer rule for universal quantifiers on non-bi-total relations
huffman
parents: 47625
diff changeset
   261
  custom transfer rules (e.g. relations between function types). *}
2b1d3eda59eb add secondary transfer rule for universal quantifiers on non-bi-total relations
huffman
parents: 47625
diff changeset
   262
47637
7a34395441ff add transfer rule for nat_case
huffman
parents: 47636
diff changeset
   263
lemma Domainp_iff: "Domainp T x \<longleftrightarrow> (\<exists>y. T x y)"
7a34395441ff add transfer rule for nat_case
huffman
parents: 47636
diff changeset
   264
  by auto
7a34395441ff add transfer rule for nat_case
huffman
parents: 47636
diff changeset
   265
47627
2b1d3eda59eb add secondary transfer rule for universal quantifiers on non-bi-total relations
huffman
parents: 47625
diff changeset
   266
lemma Domainp_forall_transfer [transfer_rule]:
2b1d3eda59eb add secondary transfer rule for universal quantifiers on non-bi-total relations
huffman
parents: 47625
diff changeset
   267
  assumes "right_total A"
2b1d3eda59eb add secondary transfer rule for universal quantifiers on non-bi-total relations
huffman
parents: 47625
diff changeset
   268
  shows "((A ===> op =) ===> op =)
2b1d3eda59eb add secondary transfer rule for universal quantifiers on non-bi-total relations
huffman
parents: 47625
diff changeset
   269
    (transfer_bforall (Domainp A)) transfer_forall"
2b1d3eda59eb add secondary transfer rule for universal quantifiers on non-bi-total relations
huffman
parents: 47625
diff changeset
   270
  using assms unfolding right_total_def
2b1d3eda59eb add secondary transfer rule for universal quantifiers on non-bi-total relations
huffman
parents: 47625
diff changeset
   271
  unfolding transfer_forall_def transfer_bforall_def fun_rel_def Domainp_iff
2b1d3eda59eb add secondary transfer rule for universal quantifiers on non-bi-total relations
huffman
parents: 47625
diff changeset
   272
  by metis
2b1d3eda59eb add secondary transfer rule for universal quantifiers on non-bi-total relations
huffman
parents: 47625
diff changeset
   273
2b1d3eda59eb add secondary transfer rule for universal quantifiers on non-bi-total relations
huffman
parents: 47625
diff changeset
   274
text {* Preferred rule for transferring universal quantifiers over
2b1d3eda59eb add secondary transfer rule for universal quantifiers on non-bi-total relations
huffman
parents: 47625
diff changeset
   275
  bi-total correspondence relations (later rules are tried first). *}
2b1d3eda59eb add secondary transfer rule for universal quantifiers on non-bi-total relations
huffman
parents: 47625
diff changeset
   276
47636
b786388b4b3a uniform naming scheme for transfer rules
huffman
parents: 47635
diff changeset
   277
lemma forall_transfer [transfer_rule]:
47627
2b1d3eda59eb add secondary transfer rule for universal quantifiers on non-bi-total relations
huffman
parents: 47625
diff changeset
   278
  "bi_total A \<Longrightarrow> ((A ===> op =) ===> op =) transfer_forall transfer_forall"
47636
b786388b4b3a uniform naming scheme for transfer rules
huffman
parents: 47635
diff changeset
   279
  unfolding transfer_forall_def by (rule All_transfer)
47325
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   280
ec6187036495 new transfer proof method
huffman
parents:
diff changeset
   281
end