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