Quot/QuotMain.thy
author Cezary Kaliszyk <kaliszyk@in.tum.de>
Thu, 11 Feb 2010 09:23:59 +0100
changeset 1127 243a5ceaa088
parent 1124 4a4c714ff795
permissions -rw-r--r--
Merging QuotBase into QuotMain.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
919
c46b6abad24b cleaned some theorems
Christian Urban <urbanc@in.tum.de>
parents: 911
diff changeset
     1
(*  Title:      QuotMain.thy
759
119f7d6a3556 minor cleaning
Christian Urban <urbanc@in.tum.de>
parents: 758
diff changeset
     2
    Author:     Cezary Kaliszyk and Christian Urban
119f7d6a3556 minor cleaning
Christian Urban <urbanc@in.tum.de>
parents: 758
diff changeset
     3
*)
119f7d6a3556 minor cleaning
Christian Urban <urbanc@in.tum.de>
parents: 758
diff changeset
     4
597
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
theory QuotMain
1127
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
     6
imports Plain ATP_Linkup
1122
d1eaed018e5d Changes from Makarius's code review + some noticed fixes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1116
diff changeset
     7
uses
d1eaed018e5d Changes from Makarius's code review + some noticed fixes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1116
diff changeset
     8
  ("quotient_info.ML")
d1eaed018e5d Changes from Makarius's code review + some noticed fixes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1116
diff changeset
     9
  ("quotient_typ.ML")
d1eaed018e5d Changes from Makarius's code review + some noticed fixes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1116
diff changeset
    10
  ("quotient_def.ML")
d1eaed018e5d Changes from Makarius's code review + some noticed fixes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1116
diff changeset
    11
  ("quotient_term.ML")
d1eaed018e5d Changes from Makarius's code review + some noticed fixes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1116
diff changeset
    12
  ("quotient_tacs.ML")
597
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
begin
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
1127
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    15
text {*
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    16
  Basic definition for equivalence relations
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    17
  that are represented by predicates.
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    18
*}
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    19
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    20
definition
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    21
  "equivp E \<longleftrightarrow> (\<forall>x y. E x y = (E x = E y))"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    22
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    23
definition
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    24
  "reflp E \<longleftrightarrow> (\<forall>x. E x x)"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    25
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    26
definition
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    27
  "symp E \<longleftrightarrow> (\<forall>x y. E x y \<longrightarrow> E y x)"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    28
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    29
definition
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    30
  "transp E \<longleftrightarrow> (\<forall>x y z. E x y \<and> E y z \<longrightarrow> E x z)"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    31
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    32
lemma equivp_reflp_symp_transp:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    33
  shows "equivp E = (reflp E \<and> symp E \<and> transp E)"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    34
  unfolding equivp_def reflp_def symp_def transp_def expand_fun_eq
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    35
  by blast
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    36
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    37
lemma equivp_reflp:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    38
  shows "equivp E \<Longrightarrow> E x x"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    39
  by (simp only: equivp_reflp_symp_transp reflp_def)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    40
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    41
lemma equivp_symp:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    42
  shows "equivp E \<Longrightarrow> E x y \<Longrightarrow> E y x"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    43
  by (metis equivp_reflp_symp_transp symp_def)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    44
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    45
lemma equivp_transp:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    46
  shows "equivp E \<Longrightarrow> E x y \<Longrightarrow> E y z \<Longrightarrow> E x z"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    47
  by (metis equivp_reflp_symp_transp transp_def)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    48
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    49
lemma equivpI:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    50
  assumes "reflp R" "symp R" "transp R"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    51
  shows "equivp R"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    52
  using assms by (simp add: equivp_reflp_symp_transp)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    53
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    54
lemma eq_imp_rel:  
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    55
  shows "equivp R \<Longrightarrow> a = b \<longrightarrow> R a b" 
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    56
  by (simp add: equivp_reflp)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    57
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    58
lemma identity_equivp:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    59
  shows "equivp (op =)"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    60
  unfolding equivp_def
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    61
  by auto
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    62
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    63
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    64
text {* Partial equivalences: not yet used anywhere *}
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    65
definition
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    66
  "part_equivp E \<longleftrightarrow> ((\<exists>x. E x x) \<and> (\<forall>x y. E x y = (E x x \<and> E y y \<and> (E x = E y))))"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    67
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    68
lemma equivp_implies_part_equivp:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    69
  assumes a: "equivp E"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    70
  shows "part_equivp E"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    71
  using a 
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    72
  unfolding equivp_def part_equivp_def
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    73
  by auto
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    74
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    75
text {* Composition of Relations *}
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    76
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    77
abbreviation 
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    78
  rel_conj (infixr "OOO" 75)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    79
where
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    80
  "r1 OOO r2 \<equiv> r1 OO r2 OO r1"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    81
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    82
lemma eq_comp_r: 
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    83
  shows "((op =) OOO R) = R"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    84
  by (auto simp add: expand_fun_eq)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    85
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    86
section {* Respects predicate *}
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    87
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    88
definition
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    89
  Respects
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    90
where
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    91
  "Respects R x \<longleftrightarrow> (R x x)"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    92
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    93
lemma in_respects:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    94
  shows "(x \<in> Respects R) = R x x"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    95
  unfolding mem_def Respects_def 
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    96
  by simp
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    97
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    98
section {* Function map and function relation *}
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
    99
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   100
definition
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   101
  fun_map (infixr "--->" 55)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   102
where
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   103
[simp]: "fun_map f g h x = g (h (f x))"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   104
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   105
definition
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   106
  fun_rel (infixr "===>" 55)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   107
where
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   108
[simp]: "fun_rel E1 E2 f g = (\<forall>x y. E1 x y \<longrightarrow> E2 (f x) (g y))"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   109
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   110
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   111
lemma fun_map_id:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   112
  shows "(id ---> id) = id"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   113
  by (simp add: expand_fun_eq id_def)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   114
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   115
lemma fun_rel_eq:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   116
  shows "((op =) ===> (op =)) = (op =)"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   117
  by (simp add: expand_fun_eq)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   118
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   119
lemma fun_rel_id:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   120
  assumes a: "\<And>x y. R1 x y \<Longrightarrow> R2 (f x) (g y)"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   121
  shows "(R1 ===> R2) f g"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   122
  using a by simp
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   123
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   124
lemma fun_rel_id_asm:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   125
  assumes a: "\<And>x y. R1 x y \<Longrightarrow> (A \<longrightarrow> R2 (f x) (g y))"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   126
  shows "A \<longrightarrow> (R1 ===> R2) f g"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   127
  using a by auto
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   128
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   129
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   130
section {* Quotient Predicate *}
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   131
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   132
definition
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   133
  "Quotient E Abs Rep \<longleftrightarrow>
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   134
     (\<forall>a. Abs (Rep a) = a) \<and> (\<forall>a. E (Rep a) (Rep a)) \<and>
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   135
     (\<forall>r s. E r s = (E r r \<and> E s s \<and> (Abs r = Abs s)))"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   136
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   137
lemma Quotient_abs_rep:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   138
  assumes a: "Quotient E Abs Rep"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   139
  shows "Abs (Rep a) = a"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   140
  using a 
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   141
  unfolding Quotient_def
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   142
  by simp
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   143
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   144
lemma Quotient_rep_reflp:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   145
  assumes a: "Quotient E Abs Rep"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   146
  shows "E (Rep a) (Rep a)"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   147
  using a 
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   148
  unfolding Quotient_def
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   149
  by blast
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   150
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   151
lemma Quotient_rel:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   152
  assumes a: "Quotient E Abs Rep"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   153
  shows " E r s = (E r r \<and> E s s \<and> (Abs r = Abs s))"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   154
  using a 
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   155
  unfolding Quotient_def
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   156
  by blast
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   157
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   158
lemma Quotient_rel_rep:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   159
  assumes a: "Quotient R Abs Rep"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   160
  shows "R (Rep a) (Rep b) = (a = b)"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   161
  using a 
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   162
  unfolding Quotient_def
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   163
  by metis
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   164
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   165
lemma Quotient_rep_abs:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   166
  assumes a: "Quotient R Abs Rep"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   167
  shows "R r r \<Longrightarrow> R (Rep (Abs r)) r"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   168
  using a unfolding Quotient_def
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   169
  by blast
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   170
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   171
lemma Quotient_rel_abs:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   172
  assumes a: "Quotient E Abs Rep"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   173
  shows "E r s \<Longrightarrow> Abs r = Abs s"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   174
  using a unfolding Quotient_def
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   175
  by blast
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   176
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   177
lemma Quotient_symp:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   178
  assumes a: "Quotient E Abs Rep"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   179
  shows "symp E"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   180
  using a unfolding Quotient_def symp_def
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   181
  by metis
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   182
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   183
lemma Quotient_transp:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   184
  assumes a: "Quotient E Abs Rep"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   185
  shows "transp E"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   186
  using a unfolding Quotient_def transp_def
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   187
  by metis
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   188
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   189
lemma identity_quotient:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   190
  shows "Quotient (op =) id id"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   191
  unfolding Quotient_def id_def
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   192
  by blast
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   193
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   194
lemma fun_quotient:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   195
  assumes q1: "Quotient R1 abs1 rep1"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   196
  and     q2: "Quotient R2 abs2 rep2"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   197
  shows "Quotient (R1 ===> R2) (rep1 ---> abs2) (abs1 ---> rep2)"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   198
proof -
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   199
  have "\<forall>a. (rep1 ---> abs2) ((abs1 ---> rep2) a) = a"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   200
    using q1 q2 
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   201
    unfolding Quotient_def
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   202
    unfolding expand_fun_eq
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   203
    by simp
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   204
  moreover
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   205
  have "\<forall>a. (R1 ===> R2) ((abs1 ---> rep2) a) ((abs1 ---> rep2) a)"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   206
    using q1 q2 
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   207
    unfolding Quotient_def
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   208
    by (simp (no_asm)) (metis)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   209
  moreover
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   210
  have "\<forall>r s. (R1 ===> R2) r s = ((R1 ===> R2) r r \<and> (R1 ===> R2) s s \<and> 
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   211
        (rep1 ---> abs2) r  = (rep1 ---> abs2) s)"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   212
    unfolding expand_fun_eq
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   213
    apply(auto)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   214
    using q1 q2 unfolding Quotient_def
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   215
    apply(metis)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   216
    using q1 q2 unfolding Quotient_def
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   217
    apply(metis)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   218
    using q1 q2 unfolding Quotient_def
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   219
    apply(metis)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   220
    using q1 q2 unfolding Quotient_def
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   221
    apply(metis)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   222
    done
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   223
  ultimately
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   224
  show "Quotient (R1 ===> R2) (rep1 ---> abs2) (abs1 ---> rep2)"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   225
    unfolding Quotient_def by blast
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   226
qed
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   227
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   228
lemma abs_o_rep:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   229
  assumes a: "Quotient R Abs Rep"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   230
  shows "Abs o Rep = id"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   231
  unfolding expand_fun_eq
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   232
  by (simp add: Quotient_abs_rep[OF a])
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   233
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   234
lemma equals_rsp:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   235
  assumes q: "Quotient R Abs Rep"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   236
  and     a: "R xa xb" "R ya yb"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   237
  shows "R xa ya = R xb yb"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   238
  using a Quotient_symp[OF q] Quotient_transp[OF q] 
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   239
  unfolding symp_def transp_def
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   240
  by blast
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   241
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   242
lemma lambda_prs:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   243
  assumes q1: "Quotient R1 Abs1 Rep1"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   244
  and     q2: "Quotient R2 Abs2 Rep2"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   245
  shows "(Rep1 ---> Abs2) (\<lambda>x. Rep2 (f (Abs1 x))) = (\<lambda>x. f x)"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   246
  unfolding expand_fun_eq
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   247
  using Quotient_abs_rep[OF q1] Quotient_abs_rep[OF q2]
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   248
  by simp
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   249
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   250
lemma lambda_prs1:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   251
  assumes q1: "Quotient R1 Abs1 Rep1"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   252
  and     q2: "Quotient R2 Abs2 Rep2"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   253
  shows "(Rep1 ---> Abs2) (\<lambda>x. (Abs1 ---> Rep2) f x) = (\<lambda>x. f x)"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   254
  unfolding expand_fun_eq
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   255
  using Quotient_abs_rep[OF q1] Quotient_abs_rep[OF q2]
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   256
  by simp
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   257
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   258
lemma rep_abs_rsp:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   259
  assumes q: "Quotient R Abs Rep"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   260
  and     a: "R x1 x2"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   261
  shows "R x1 (Rep (Abs x2))"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   262
  using a Quotient_rel[OF q] Quotient_abs_rep[OF q] Quotient_rep_reflp[OF q]
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   263
  by metis
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   264
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   265
lemma rep_abs_rsp_left:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   266
  assumes q: "Quotient R Abs Rep"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   267
  and     a: "R x1 x2"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   268
  shows "R (Rep (Abs x1)) x2"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   269
  using a Quotient_rel[OF q] Quotient_abs_rep[OF q] Quotient_rep_reflp[OF q]
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   270
  by metis
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   271
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   272
text{* 
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   273
  In the following theorem R1 can be instantiated with anything,
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   274
  but we know some of the types of the Rep and Abs functions;
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   275
  so by solving Quotient assumptions we can get a unique R1 that
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   276
  will be provable; which is why we need to use apply_rsp and
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   277
  not the primed version *}
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   278
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   279
lemma apply_rsp:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   280
  fixes f g::"'a \<Rightarrow> 'c"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   281
  assumes q: "Quotient R1 Abs1 Rep1"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   282
  and     a: "(R1 ===> R2) f g" "R1 x y"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   283
  shows "R2 (f x) (g y)"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   284
  using a by simp
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   285
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   286
lemma apply_rsp':
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   287
  assumes a: "(R1 ===> R2) f g" "R1 x y"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   288
  shows "R2 (f x) (g y)"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   289
  using a by simp
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   290
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   291
section {* lemmas for regularisation of ball and bex *}
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   292
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   293
lemma ball_reg_eqv:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   294
  fixes P :: "'a \<Rightarrow> bool"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   295
  assumes a: "equivp R"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   296
  shows "Ball (Respects R) P = (All P)"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   297
  using a 
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   298
  unfolding equivp_def
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   299
  by (auto simp add: in_respects)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   300
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   301
lemma bex_reg_eqv:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   302
  fixes P :: "'a \<Rightarrow> bool"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   303
  assumes a: "equivp R"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   304
  shows "Bex (Respects R) P = (Ex P)"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   305
  using a 
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   306
  unfolding equivp_def
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   307
  by (auto simp add: in_respects)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   308
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   309
lemma ball_reg_right:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   310
  assumes a: "\<And>x. R x \<Longrightarrow> P x \<longrightarrow> Q x"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   311
  shows "All P \<longrightarrow> Ball R Q"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   312
  using a by (metis COMBC_def Collect_def Collect_mem_eq)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   313
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   314
lemma bex_reg_left:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   315
  assumes a: "\<And>x. R x \<Longrightarrow> Q x \<longrightarrow> P x"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   316
  shows "Bex R Q \<longrightarrow> Ex P"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   317
  using a by (metis COMBC_def Collect_def Collect_mem_eq)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   318
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   319
lemma ball_reg_left:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   320
  assumes a: "equivp R"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   321
  shows "(\<And>x. (Q x \<longrightarrow> P x)) \<Longrightarrow> Ball (Respects R) Q \<longrightarrow> All P"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   322
  using a by (metis equivp_reflp in_respects)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   323
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   324
lemma bex_reg_right:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   325
  assumes a: "equivp R"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   326
  shows "(\<And>x. (Q x \<longrightarrow> P x)) \<Longrightarrow> Ex Q \<longrightarrow> Bex (Respects R) P"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   327
  using a by (metis equivp_reflp in_respects)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   328
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   329
lemma ball_reg_eqv_range:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   330
  fixes P::"'a \<Rightarrow> bool"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   331
  and x::"'a"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   332
  assumes a: "equivp R2"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   333
  shows   "(Ball (Respects (R1 ===> R2)) (\<lambda>f. P (f x)) = All (\<lambda>f. P (f x)))"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   334
  apply(rule iffI)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   335
  apply(rule allI)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   336
  apply(drule_tac x="\<lambda>y. f x" in bspec)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   337
  apply(simp add: in_respects)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   338
  apply(rule impI)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   339
  using a equivp_reflp_symp_transp[of "R2"]
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   340
  apply(simp add: reflp_def)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   341
  apply(simp)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   342
  apply(simp)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   343
  done
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   344
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   345
lemma bex_reg_eqv_range:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   346
  assumes a: "equivp R2"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   347
  shows   "(Bex (Respects (R1 ===> R2)) (\<lambda>f. P (f x)) = Ex (\<lambda>f. P (f x)))"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   348
  apply(auto)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   349
  apply(rule_tac x="\<lambda>y. f x" in bexI)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   350
  apply(simp)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   351
  apply(simp add: Respects_def in_respects)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   352
  apply(rule impI)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   353
  using a equivp_reflp_symp_transp[of "R2"]
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   354
  apply(simp add: reflp_def)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   355
  done
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   356
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   357
lemma all_reg:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   358
  assumes a: "!x :: 'a. (P x --> Q x)"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   359
  and     b: "All P"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   360
  shows "All Q"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   361
  using a b by (metis)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   362
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   363
lemma ex_reg:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   364
  assumes a: "!x :: 'a. (P x --> Q x)"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   365
  and     b: "Ex P"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   366
  shows "Ex Q"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   367
  using a b by metis
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   368
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   369
lemma ball_reg:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   370
  assumes a: "!x :: 'a. (R x --> P x --> Q x)"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   371
  and     b: "Ball R P"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   372
  shows "Ball R Q"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   373
  using a b by (metis COMBC_def Collect_def Collect_mem_eq)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   374
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   375
lemma bex_reg:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   376
  assumes a: "!x :: 'a. (R x --> P x --> Q x)"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   377
  and     b: "Bex R P"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   378
  shows "Bex R Q"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   379
  using a b by (metis COMBC_def Collect_def Collect_mem_eq)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   380
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   381
lemma ball_all_comm:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   382
  assumes "\<And>y. (\<forall>x\<in>P. A x y) \<longrightarrow> (\<forall>x. B x y)"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   383
  shows "(\<forall>x\<in>P. \<forall>y. A x y) \<longrightarrow> (\<forall>x. \<forall>y. B x y)"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   384
  using assms by auto
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   385
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   386
lemma bex_ex_comm:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   387
  assumes "(\<exists>y. \<exists>x. A x y) \<longrightarrow> (\<exists>y. \<exists>x\<in>P. B x y)"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   388
  shows "(\<exists>x. \<exists>y. A x y) \<longrightarrow> (\<exists>x\<in>P. \<exists>y. B x y)"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   389
  using assms by auto
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   390
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   391
section {* Bounded abstraction *}
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   392
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   393
definition
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   394
  Babs :: "('a \<Rightarrow> bool) \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'a \<Rightarrow> 'b"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   395
where
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   396
  "x \<in> p \<Longrightarrow> Babs p m x = m x"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   397
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   398
lemma babs_rsp:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   399
  assumes q: "Quotient R1 Abs1 Rep1"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   400
  and     a: "(R1 ===> R2) f g"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   401
  shows      "(R1 ===> R2) (Babs (Respects R1) f) (Babs (Respects R1) g)"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   402
  apply (auto simp add: Babs_def in_respects)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   403
  apply (subgoal_tac "x \<in> Respects R1 \<and> y \<in> Respects R1")
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   404
  using a apply (simp add: Babs_def)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   405
  apply (simp add: in_respects)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   406
  using Quotient_rel[OF q]
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   407
  by metis
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   408
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   409
lemma babs_prs:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   410
  assumes q1: "Quotient R1 Abs1 Rep1"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   411
  and     q2: "Quotient R2 Abs2 Rep2"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   412
  shows "((Rep1 ---> Abs2) (Babs (Respects R1) ((Abs1 ---> Rep2) f))) = f"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   413
  apply (rule ext)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   414
  apply (simp)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   415
  apply (subgoal_tac "Rep1 x \<in> Respects R1")
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   416
  apply (simp add: Babs_def Quotient_abs_rep[OF q1] Quotient_abs_rep[OF q2])
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   417
  apply (simp add: in_respects Quotient_rel_rep[OF q1])
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   418
  done
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   419
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   420
lemma babs_simp:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   421
  assumes q: "Quotient R1 Abs Rep"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   422
  shows "((R1 ===> R2) (Babs (Respects R1) f) (Babs (Respects R1) g)) = ((R1 ===> R2) f g)"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   423
  apply(rule iffI)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   424
  apply(simp_all only: babs_rsp[OF q])
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   425
  apply(auto simp add: Babs_def)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   426
  apply (subgoal_tac "x \<in> Respects R1 \<and> y \<in> Respects R1")
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   427
  apply(metis Babs_def)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   428
  apply (simp add: in_respects)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   429
  using Quotient_rel[OF q]
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   430
  by metis
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   431
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   432
(* If a user proves that a particular functional relation 
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   433
   is an equivalence this may be useful in regularising *)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   434
lemma babs_reg_eqv:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   435
  shows "equivp R \<Longrightarrow> Babs (Respects R) P = P"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   436
  by (simp add: expand_fun_eq Babs_def in_respects equivp_reflp)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   437
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   438
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   439
(* 3 lemmas needed for proving repabs_inj *)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   440
lemma ball_rsp:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   441
  assumes a: "(R ===> (op =)) f g"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   442
  shows "Ball (Respects R) f = Ball (Respects R) g"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   443
  using a by (simp add: Ball_def in_respects)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   444
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   445
lemma bex_rsp:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   446
  assumes a: "(R ===> (op =)) f g"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   447
  shows "(Bex (Respects R) f = Bex (Respects R) g)"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   448
  using a by (simp add: Bex_def in_respects)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   449
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   450
lemma bex1_rsp:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   451
  assumes a: "(R ===> (op =)) f g"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   452
  shows "Ex1 (\<lambda>x. x \<in> Respects R \<and> f x) = Ex1 (\<lambda>x. x \<in> Respects R \<and> g x)"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   453
  using a 
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   454
  by (simp add: Ex1_def in_respects) auto
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   455
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   456
(* 2 lemmas needed for cleaning of quantifiers *)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   457
lemma all_prs:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   458
  assumes a: "Quotient R absf repf"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   459
  shows "Ball (Respects R) ((absf ---> id) f) = All f"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   460
  using a unfolding Quotient_def Ball_def in_respects fun_map_def id_apply
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   461
  by metis
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   462
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   463
lemma ex_prs:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   464
  assumes a: "Quotient R absf repf"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   465
  shows "Bex (Respects R) ((absf ---> id) f) = Ex f"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   466
  using a unfolding Quotient_def Bex_def in_respects fun_map_def id_apply
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   467
  by metis
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   468
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   469
section {* Bex1_rel quantifier *}
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   470
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   471
definition
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   472
  Bex1_rel :: "('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> ('a \<Rightarrow> bool) \<Rightarrow> bool"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   473
where
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   474
  "Bex1_rel R P \<longleftrightarrow> (\<exists>x \<in> Respects R. P x) \<and> (\<forall>x \<in> Respects R. \<forall>y \<in> Respects R. ((P x \<and> P y) \<longrightarrow> (R x y)))"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   475
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   476
lemma bex1_rel_aux:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   477
  "\<lbrakk>\<forall>xa ya. R xa ya \<longrightarrow> x xa = y ya; Bex1_rel R x\<rbrakk> \<Longrightarrow> Bex1_rel R y"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   478
  unfolding Bex1_rel_def
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   479
  apply (erule conjE)+
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   480
  apply (erule bexE)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   481
  apply rule
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   482
  apply (rule_tac x="xa" in bexI)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   483
  apply metis
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   484
  apply metis
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   485
  apply rule+
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   486
  apply (erule_tac x="xaa" in ballE)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   487
  prefer 2
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   488
  apply (metis)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   489
  apply (erule_tac x="ya" in ballE)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   490
  prefer 2
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   491
  apply (metis)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   492
  apply (metis in_respects)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   493
  done
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   494
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   495
lemma bex1_rel_aux2:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   496
  "\<lbrakk>\<forall>xa ya. R xa ya \<longrightarrow> x xa = y ya; Bex1_rel R y\<rbrakk> \<Longrightarrow> Bex1_rel R x"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   497
  unfolding Bex1_rel_def
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   498
  apply (erule conjE)+
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   499
  apply (erule bexE)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   500
  apply rule
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   501
  apply (rule_tac x="xa" in bexI)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   502
  apply metis
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   503
  apply metis
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   504
  apply rule+
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   505
  apply (erule_tac x="xaa" in ballE)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   506
  prefer 2
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   507
  apply (metis)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   508
  apply (erule_tac x="ya" in ballE)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   509
  prefer 2
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   510
  apply (metis)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   511
  apply (metis in_respects)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   512
  done
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   513
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   514
lemma bex1_rel_rsp:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   515
  assumes a: "Quotient R absf repf"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   516
  shows "((R ===> op =) ===> op =) (Bex1_rel R) (Bex1_rel R)"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   517
  apply simp
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   518
  apply clarify
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   519
  apply rule
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   520
  apply (simp_all add: bex1_rel_aux bex1_rel_aux2)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   521
  apply (erule bex1_rel_aux2)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   522
  apply assumption
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   523
  done
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   524
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   525
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   526
lemma ex1_prs:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   527
  assumes a: "Quotient R absf repf"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   528
  shows "((absf ---> id) ---> id) (Bex1_rel R) f = Ex1 f"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   529
apply simp
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   530
apply (subst Bex1_rel_def)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   531
apply (subst Bex_def)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   532
apply (subst Ex1_def)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   533
apply simp
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   534
apply rule
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   535
 apply (erule conjE)+
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   536
 apply (erule_tac exE)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   537
 apply (erule conjE)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   538
 apply (subgoal_tac "\<forall>y. R y y \<longrightarrow> f (absf y) \<longrightarrow> R x y")
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   539
  apply (rule_tac x="absf x" in exI)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   540
  apply (simp)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   541
  apply rule+
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   542
  using a unfolding Quotient_def
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   543
  apply metis
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   544
 apply rule+
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   545
 apply (erule_tac x="x" in ballE)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   546
  apply (erule_tac x="y" in ballE)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   547
   apply simp
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   548
  apply (simp add: in_respects)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   549
 apply (simp add: in_respects)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   550
apply (erule_tac exE)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   551
 apply rule
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   552
 apply (rule_tac x="repf x" in exI)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   553
 apply (simp only: in_respects)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   554
  apply rule
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   555
 apply (metis Quotient_rel_rep[OF a])
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   556
using a unfolding Quotient_def apply (simp)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   557
apply rule+
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   558
using a unfolding Quotient_def in_respects
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   559
apply metis
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   560
done
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   561
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   562
lemma bex1_bexeq_reg: "(\<exists>!x\<in>Respects R. P x) \<longrightarrow> (Bex1_rel R (\<lambda>x. P x))"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   563
  apply (simp add: Ex1_def Bex1_rel_def in_respects)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   564
  apply clarify
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   565
  apply auto
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   566
  apply (rule bexI)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   567
  apply assumption
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   568
  apply (simp add: in_respects)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   569
  apply (simp add: in_respects)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   570
  apply auto
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   571
  done
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   572
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   573
section {* Various respects and preserve lemmas *}
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   574
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   575
lemma quot_rel_rsp:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   576
  assumes a: "Quotient R Abs Rep"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   577
  shows "(R ===> R ===> op =) R R"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   578
  apply(rule fun_rel_id)+
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   579
  apply(rule equals_rsp[OF a])
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   580
  apply(assumption)+
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   581
  done
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   582
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   583
lemma o_prs:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   584
  assumes q1: "Quotient R1 Abs1 Rep1"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   585
  and     q2: "Quotient R2 Abs2 Rep2"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   586
  and     q3: "Quotient R3 Abs3 Rep3"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   587
  shows "(Rep1 ---> Abs3) (((Abs2 ---> Rep3) f) o ((Abs1 ---> Rep2) g)) = f o g"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   588
  using Quotient_abs_rep[OF q1] Quotient_abs_rep[OF q2] Quotient_abs_rep[OF q3]
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   589
  unfolding o_def expand_fun_eq by simp
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   590
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   591
lemma o_rsp:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   592
  assumes q1: "Quotient R1 Abs1 Rep1"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   593
  and     q2: "Quotient R2 Abs2 Rep2"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   594
  and     q3: "Quotient R3 Abs3 Rep3"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   595
  and     a1: "(R2 ===> R3) f1 f2"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   596
  and     a2: "(R1 ===> R2) g1 g2"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   597
  shows "(R1 ===> R3) (f1 o g1) (f2 o g2)"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   598
  using a1 a2 unfolding o_def expand_fun_eq
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   599
  by (auto)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   600
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   601
lemma cond_prs:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   602
  assumes a: "Quotient R absf repf"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   603
  shows "absf (if a then repf b else repf c) = (if a then b else c)"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   604
  using a unfolding Quotient_def by auto
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   605
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   606
lemma if_prs:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   607
  assumes q: "Quotient R Abs Rep"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   608
  shows "Abs (If a (Rep b) (Rep c)) = If a b c"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   609
  using Quotient_abs_rep[OF q] by auto
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   610
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   611
(* q not used *)
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   612
lemma if_rsp:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   613
  assumes q: "Quotient R Abs Rep"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   614
  and     a: "a1 = a2" "R b1 b2" "R c1 c2"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   615
  shows "R (If a1 b1 c1) (If a2 b2 c2)"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   616
  using a by auto
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   617
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   618
lemma let_prs:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   619
  assumes q1: "Quotient R1 Abs1 Rep1"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   620
  and     q2: "Quotient R2 Abs2 Rep2"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   621
  shows "Abs2 (Let (Rep1 x) ((Abs1 ---> Rep2) f)) = Let x f"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   622
  using Quotient_abs_rep[OF q1] Quotient_abs_rep[OF q2] by auto
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   623
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   624
lemma let_rsp:
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   625
  assumes q1: "Quotient R1 Abs1 Rep1"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   626
  and     a1: "(R1 ===> R2) f g"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   627
  and     a2: "R1 x y"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   628
  shows "R2 ((Let x f)::'c) ((Let y g)::'c)"
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   629
  using apply_rsp[OF q1 a1] a2 by auto
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   630
1124
4a4c714ff795 lowercase locale
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1122
diff changeset
   631
locale quot_type =
597
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   632
  fixes R :: "'a \<Rightarrow> 'a \<Rightarrow> bool"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   633
  and   Abs :: "('a \<Rightarrow> bool) \<Rightarrow> 'b"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   634
  and   Rep :: "'b \<Rightarrow> ('a \<Rightarrow> bool)"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   635
  assumes equivp: "equivp R"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   636
  and     rep_prop: "\<And>y. \<exists>x. Rep y = R x"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   637
  and     rep_inverse: "\<And>x. Abs (Rep x) = x"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   638
  and     abs_inverse: "\<And>x. (Rep (Abs (R x))) = (R x)"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   639
  and     rep_inject: "\<And>x y. (Rep x = Rep y) = (x = y)"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   640
begin
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   641
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   642
definition
719
a9e55e1ef64c Renaming
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 715
diff changeset
   643
  abs::"'a \<Rightarrow> 'b"
597
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   644
where
719
a9e55e1ef64c Renaming
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 715
diff changeset
   645
  "abs x \<equiv> Abs (R x)"
597
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   646
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   647
definition
719
a9e55e1ef64c Renaming
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 715
diff changeset
   648
  rep::"'b \<Rightarrow> 'a"
597
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   649
where
719
a9e55e1ef64c Renaming
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 715
diff changeset
   650
  "rep a = Eps (Rep a)"
597
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   651
1122
d1eaed018e5d Changes from Makarius's code review + some noticed fixes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1116
diff changeset
   652
lemma homeier_lem9:
597
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   653
  shows "R (Eps (R x)) = R x"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   654
proof -
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   655
  have a: "R x x" using equivp by (simp add: equivp_reflp_symp_transp reflp_def)
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   656
  then have "R x (Eps (R x))" by (rule someI)
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   657
  then show "R (Eps (R x)) = R x"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   658
    using equivp unfolding equivp_def by simp
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   659
qed
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   660
1122
d1eaed018e5d Changes from Makarius's code review + some noticed fixes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1116
diff changeset
   661
theorem homeier_thm10:
930
68c1f378a70a All eq_reflections apart from the one of 'id_apply' can be removed.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 925
diff changeset
   662
  shows "abs (rep a) = a"
719
a9e55e1ef64c Renaming
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 715
diff changeset
   663
  unfolding abs_def rep_def
597
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   664
proof -
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   665
  from rep_prop
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   666
  obtain x where eq: "Rep a = R x" by auto
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   667
  have "Abs (R (Eps (Rep a))) = Abs (R (Eps (R x)))" using eq by simp
1122
d1eaed018e5d Changes from Makarius's code review + some noticed fixes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1116
diff changeset
   668
  also have "\<dots> = Abs (R x)" using homeier_lem9 by simp
597
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   669
  also have "\<dots> = Abs (Rep a)" using eq by simp
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   670
  also have "\<dots> = a" using rep_inverse by simp
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   671
  finally
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   672
  show "Abs (R (Eps (Rep a))) = a" by simp
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   673
qed
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   674
1122
d1eaed018e5d Changes from Makarius's code review + some noticed fixes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1116
diff changeset
   675
lemma homeier_lem7:
919
c46b6abad24b cleaned some theorems
Christian Urban <urbanc@in.tum.de>
parents: 911
diff changeset
   676
  shows "(R x = R y) = (Abs (R x) = Abs (R y))" (is "?LHS = ?RHS")
c46b6abad24b cleaned some theorems
Christian Urban <urbanc@in.tum.de>
parents: 911
diff changeset
   677
proof -
c46b6abad24b cleaned some theorems
Christian Urban <urbanc@in.tum.de>
parents: 911
diff changeset
   678
  have "?RHS = (Rep (Abs (R x)) = Rep (Abs (R y)))" by (simp add: rep_inject)
c46b6abad24b cleaned some theorems
Christian Urban <urbanc@in.tum.de>
parents: 911
diff changeset
   679
  also have "\<dots> = ?LHS" by (simp add: abs_inverse)
c46b6abad24b cleaned some theorems
Christian Urban <urbanc@in.tum.de>
parents: 911
diff changeset
   680
  finally show "?LHS = ?RHS" by simp
c46b6abad24b cleaned some theorems
Christian Urban <urbanc@in.tum.de>
parents: 911
diff changeset
   681
qed
597
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   682
1122
d1eaed018e5d Changes from Makarius's code review + some noticed fixes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1116
diff changeset
   683
theorem homeier_thm11:
719
a9e55e1ef64c Renaming
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 715
diff changeset
   684
  shows "R r r' = (abs r = abs r')"
1116
3acc7d25627a Some cleaning of proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1113
diff changeset
   685
  unfolding abs_def
1122
d1eaed018e5d Changes from Makarius's code review + some noticed fixes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1116
diff changeset
   686
  by (simp only: equivp[simplified equivp_def] homeier_lem7)
597
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   687
920
dae99175f584 renamed QuotScript to QuotBase
Christian Urban <urbanc@in.tum.de>
parents: 919
diff changeset
   688
lemma rep_refl:
dae99175f584 renamed QuotScript to QuotBase
Christian Urban <urbanc@in.tum.de>
parents: 919
diff changeset
   689
  shows "R (rep a) (rep a)"
1116
3acc7d25627a Some cleaning of proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1113
diff changeset
   690
  unfolding rep_def
3acc7d25627a Some cleaning of proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1113
diff changeset
   691
  by (simp add: equivp[simplified equivp_def])
920
dae99175f584 renamed QuotScript to QuotBase
Christian Urban <urbanc@in.tum.de>
parents: 919
diff changeset
   692
dae99175f584 renamed QuotScript to QuotBase
Christian Urban <urbanc@in.tum.de>
parents: 919
diff changeset
   693
719
a9e55e1ef64c Renaming
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 715
diff changeset
   694
lemma rep_abs_rsp:
a9e55e1ef64c Renaming
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 715
diff changeset
   695
  shows "R f (rep (abs g)) = R f g"
a9e55e1ef64c Renaming
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 715
diff changeset
   696
  and   "R (rep (abs g)) f = R g f"
1122
d1eaed018e5d Changes from Makarius's code review + some noticed fixes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1116
diff changeset
   697
  by (simp_all add: homeier_thm10 homeier_thm11)
597
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   698
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   699
lemma Quotient:
773
d6acae26d027 tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
parents: 768
diff changeset
   700
  shows "Quotient R abs rep"
1116
3acc7d25627a Some cleaning of proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1113
diff changeset
   701
  unfolding Quotient_def
1122
d1eaed018e5d Changes from Makarius's code review + some noticed fixes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1116
diff changeset
   702
  apply(simp add: homeier_thm10)
1116
3acc7d25627a Some cleaning of proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1113
diff changeset
   703
  apply(simp add: rep_refl)
1122
d1eaed018e5d Changes from Makarius's code review + some noticed fixes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1116
diff changeset
   704
  apply(subst homeier_thm11[symmetric])
1116
3acc7d25627a Some cleaning of proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1113
diff changeset
   705
  apply(simp add: equivp[simplified equivp_def])
3acc7d25627a Some cleaning of proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1113
diff changeset
   706
  done
597
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   707
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   708
end
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   709
773
d6acae26d027 tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
parents: 768
diff changeset
   710
section {* ML setup *}
d6acae26d027 tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
parents: 768
diff changeset
   711
919
c46b6abad24b cleaned some theorems
Christian Urban <urbanc@in.tum.de>
parents: 911
diff changeset
   712
text {* Auxiliary data for the quotient package *}
869
ce5f78f0eac5 Finished organising an efficient datastructure for qconst_info.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 854
diff changeset
   713
597
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   714
use "quotient_info.ML"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   715
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   716
declare [[map "fun" = (fun_map, fun_rel)]]
615
386a6b1a5203 the lift_tac produces a warning message if one of the three automatic proofs fails
Christian Urban <urbanc@in.tum.de>
parents: 614
diff changeset
   717
909
3e7a6ec549d1 Using Bexeq_rsp, and manually lifted lemma with Ex1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 907
diff changeset
   718
lemmas [quot_thm] = fun_quotient
911
95ee248b3832 Automatic injection of Bexeq
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 909
diff changeset
   719
lemmas [quot_respect] = quot_rel_rsp
648
830b58c2fa94 decoupled QuotProd from QuotMain and also started new cleaning strategy
Christian Urban <urbanc@in.tum.de>
parents: 643
diff changeset
   720
lemmas [quot_equiv] = identity_equivp
597
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   721
919
c46b6abad24b cleaned some theorems
Christian Urban <urbanc@in.tum.de>
parents: 911
diff changeset
   722
c46b6abad24b cleaned some theorems
Christian Urban <urbanc@in.tum.de>
parents: 911
diff changeset
   723
text {* Lemmas about simplifying id's. *}
773
d6acae26d027 tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
parents: 768
diff changeset
   724
lemmas [id_simps] =
925
8d51795ef54d ids *cannot* be object equalities
Christian Urban <urbanc@in.tum.de>
parents: 920
diff changeset
   725
  id_def[symmetric]
930
68c1f378a70a All eq_reflections apart from the one of 'id_apply' can be removed.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 925
diff changeset
   726
  fun_map_id
939
ce774af6b964 Changed the lambda_prs_simple_conv to use id_apply, now last eq_reflection can be removed from id_simps.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 930
diff changeset
   727
  id_apply
930
68c1f378a70a All eq_reflections apart from the one of 'id_apply' can be removed.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 925
diff changeset
   728
  id_o
68c1f378a70a All eq_reflections apart from the one of 'id_apply' can be removed.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 925
diff changeset
   729
  o_id
825
970e86082cd7 Modifictaions for new_relation.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 789
diff changeset
   730
  eq_comp_r
774
b4ffb8826105 moved get_fun into quotient_term; this simplifies the overall including structure of the package
Christian Urban <urbanc@in.tum.de>
parents: 773
diff changeset
   731
919
c46b6abad24b cleaned some theorems
Christian Urban <urbanc@in.tum.de>
parents: 911
diff changeset
   732
text {* Translation functions for the lifting process. *}
1127
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   733
use "quotient_term.ML"
774
b4ffb8826105 moved get_fun into quotient_term; this simplifies the overall including structure of the package
Christian Urban <urbanc@in.tum.de>
parents: 773
diff changeset
   734
b4ffb8826105 moved get_fun into quotient_term; this simplifies the overall including structure of the package
Christian Urban <urbanc@in.tum.de>
parents: 773
diff changeset
   735
919
c46b6abad24b cleaned some theorems
Christian Urban <urbanc@in.tum.de>
parents: 911
diff changeset
   736
text {* Definitions of the quotient types. *}
725
0d98a4c7f8dc renamed quotient.ML to quotient_typ.ML
Christian Urban <urbanc@in.tum.de>
parents: 720
diff changeset
   737
use "quotient_typ.ML"
597
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   738
773
d6acae26d027 tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
parents: 768
diff changeset
   739
919
c46b6abad24b cleaned some theorems
Christian Urban <urbanc@in.tum.de>
parents: 911
diff changeset
   740
text {* Definitions for quotient constants. *}
597
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   741
use "quotient_def.ML"
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   742
759
119f7d6a3556 minor cleaning
Christian Urban <urbanc@in.tum.de>
parents: 758
diff changeset
   743
1122
d1eaed018e5d Changes from Makarius's code review + some noticed fixes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1116
diff changeset
   744
text {*
d1eaed018e5d Changes from Makarius's code review + some noticed fixes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1116
diff changeset
   745
  An auxiliary constant for recording some information
d1eaed018e5d Changes from Makarius's code review + some noticed fixes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1116
diff changeset
   746
  about the lifted theorem in a tactic.
919
c46b6abad24b cleaned some theorems
Christian Urban <urbanc@in.tum.de>
parents: 911
diff changeset
   747
*}
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents: 752
diff changeset
   748
definition
773
d6acae26d027 tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
parents: 768
diff changeset
   749
  "Quot_True x \<equiv> True"
605
120e479ed367 first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents: 602
diff changeset
   750
1127
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   751
lemma
773
d6acae26d027 tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
parents: 768
diff changeset
   752
  shows QT_all: "Quot_True (All P) \<Longrightarrow> Quot_True P"
d6acae26d027 tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
parents: 768
diff changeset
   753
  and   QT_ex:  "Quot_True (Ex P) \<Longrightarrow> Quot_True P"
907
e576a97e9a3e The missing rule.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 896
diff changeset
   754
  and   QT_ex1: "Quot_True (Ex1 P) \<Longrightarrow> Quot_True P"
1113
9f6c606d5b59 more minor space and bracket modifications.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1077
diff changeset
   755
  and   QT_lam: "Quot_True (\<lambda>x. P x) \<Longrightarrow> (\<And>x. Quot_True (P x))"
773
d6acae26d027 tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
parents: 768
diff changeset
   756
  and   QT_ext: "(\<And>x. Quot_True (a x) \<Longrightarrow> f x = g x) \<Longrightarrow> (Quot_True a \<Longrightarrow> f = g)"
1116
3acc7d25627a Some cleaning of proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1113
diff changeset
   757
  by (simp_all add: Quot_True_def ext)
751
670131bcba4a some commenting
Christian Urban <urbanc@in.tum.de>
parents: 750
diff changeset
   758
773
d6acae26d027 tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
parents: 768
diff changeset
   759
lemma QT_imp: "Quot_True a \<equiv> Quot_True b"
1116
3acc7d25627a Some cleaning of proofs.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1113
diff changeset
   760
  by (simp add: Quot_True_def)
751
670131bcba4a some commenting
Christian Urban <urbanc@in.tum.de>
parents: 750
diff changeset
   761
1122
d1eaed018e5d Changes from Makarius's code review + some noticed fixes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1116
diff changeset
   762
919
c46b6abad24b cleaned some theorems
Christian Urban <urbanc@in.tum.de>
parents: 911
diff changeset
   763
text {* Tactics for proving the lifted theorems *}
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents: 752
diff changeset
   764
use "quotient_tacs.ML"
751
670131bcba4a some commenting
Christian Urban <urbanc@in.tum.de>
parents: 750
diff changeset
   765
689
Christian Urban <urbanc@in.tum.de>
parents: 688
diff changeset
   766
section {* Methods / Interface *}
Christian Urban <urbanc@in.tum.de>
parents: 688
diff changeset
   767
1122
d1eaed018e5d Changes from Makarius's code review + some noticed fixes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1116
diff changeset
   768
(* TODO inline *)
632
d23416464f62 added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents: 624
diff changeset
   769
ML {*
896
4e0b89d886ac liftin and lifing_tac can now lift several "and"-separated goals at once; the raw-theorems have to be given in the order of goals
Christian Urban <urbanc@in.tum.de>
parents: 870
diff changeset
   770
fun mk_method1 tac thms ctxt =
1127
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   771
  SIMPLE_METHOD (HEADGOAL (tac ctxt thms))
632
d23416464f62 added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents: 624
diff changeset
   772
d23416464f62 added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents: 624
diff changeset
   773
fun mk_method2 tac ctxt =
1127
243a5ceaa088 Merging QuotBase into QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1124
diff changeset
   774
  SIMPLE_METHOD (HEADGOAL (tac ctxt))
632
d23416464f62 added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents: 624
diff changeset
   775
*}
d23416464f62 added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents: 624
diff changeset
   776
d23416464f62 added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents: 624
diff changeset
   777
method_setup lifting =
896
4e0b89d886ac liftin and lifing_tac can now lift several "and"-separated goals at once; the raw-theorems have to be given in the order of goals
Christian Urban <urbanc@in.tum.de>
parents: 870
diff changeset
   778
  {* Attrib.thms >> (mk_method1 Quotient_Tacs.lift_tac) *}
1122
d1eaed018e5d Changes from Makarius's code review + some noticed fixes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1116
diff changeset
   779
  {* lifts theorems to quotient types *}
632
d23416464f62 added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents: 624
diff changeset
   780
d23416464f62 added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents: 624
diff changeset
   781
method_setup lifting_setup =
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents: 752
diff changeset
   782
  {* Attrib.thm >> (mk_method1 Quotient_Tacs.procedure_tac) *}
1122
d1eaed018e5d Changes from Makarius's code review + some noticed fixes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1116
diff changeset
   783
  {* sets up the three goals for the quotient lifting procedure *}
632
d23416464f62 added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents: 624
diff changeset
   784
d23416464f62 added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents: 624
diff changeset
   785
method_setup regularize =
1113
9f6c606d5b59 more minor space and bracket modifications.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1077
diff changeset
   786
  {* Scan.succeed (mk_method2 Quotient_Tacs.regularize_tac) *}
1122
d1eaed018e5d Changes from Makarius's code review + some noticed fixes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1116
diff changeset
   787
  {* proves the regularization goals from the quotient lifting procedure *}
632
d23416464f62 added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents: 624
diff changeset
   788
d23416464f62 added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents: 624
diff changeset
   789
method_setup injection =
773
d6acae26d027 tuned comments; renamed QUOT_TRUE to Quot_True; atomize_eqv seems to not be neccessary (has it been added to Isabelle)...it is now comented out and everything still works
Christian Urban <urbanc@in.tum.de>
parents: 768
diff changeset
   790
  {* Scan.succeed (mk_method2 Quotient_Tacs.all_injection_tac) *}
1122
d1eaed018e5d Changes from Makarius's code review + some noticed fixes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1116
diff changeset
   791
  {* proves the rep/abs injection goals from the quotient lifting procedure *}
632
d23416464f62 added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents: 624
diff changeset
   792
d23416464f62 added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents: 624
diff changeset
   793
method_setup cleaning =
758
3104d62e7a16 moved the QuotMain code into two ML-files
Christian Urban <urbanc@in.tum.de>
parents: 752
diff changeset
   794
  {* Scan.succeed (mk_method2 Quotient_Tacs.clean_tac) *}
1122
d1eaed018e5d Changes from Makarius's code review + some noticed fixes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1116
diff changeset
   795
  {* proves the cleaning goals from the quotient lifting procedure *}
632
d23416464f62 added methods for the lifting_tac and the other tacs
Christian Urban <urbanc@in.tum.de>
parents: 624
diff changeset
   796
1068
62e54830590f A proper version of the attribute
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 939
diff changeset
   797
attribute_setup quot_lifted =
1077
44461d5615eb some tuning
Christian Urban <urbanc@in.tum.de>
parents: 1068
diff changeset
   798
  {* Scan.succeed Quotient_Tacs.lifted_attrib *}
1122
d1eaed018e5d Changes from Makarius's code review + some noticed fixes.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1116
diff changeset
   799
  {* lifts theorems to quotient types *}
1068
62e54830590f A proper version of the attribute
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 939
diff changeset
   800
597
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   801
end
8a1c8dc72b5c directory re-arrangement
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   802