Quot/QuotScript.thy
author Christian Urban <urbanc@in.tum.de>
Fri, 11 Dec 2009 06:58:31 +0100
changeset 703 8b2c46e11674
parent 700 91b079db7380
child 721 19032e71fb1c
permissions -rw-r--r--
reformulated the lemma lifting_procedure as ML value; gave better warning message for injection case
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
theory QuotScript
530
5e92ce8f306d smaller theory footprint
Christian Urban <urbanc@in.tum.de>
parents: 528
diff changeset
     2
imports Plain ATP_Linkup
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
begin
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
543
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
     5
definition
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
     6
  "equivp E \<equiv> \<forall>x y. E x y = (E x = E y)"
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
definition
528
f51e2b3e3149 Naming changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 527
diff changeset
     9
  "reflp E \<equiv> \<forall>x. E x x"
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
543
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
    11
definition
528
f51e2b3e3149 Naming changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 527
diff changeset
    12
  "symp E \<equiv> \<forall>x y. E x y \<longrightarrow> E y x"
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
definition
528
f51e2b3e3149 Naming changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 527
diff changeset
    15
  "transp E \<equiv> \<forall>x y z. E x y \<and> E y z \<longrightarrow> E x z"
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
528
f51e2b3e3149 Naming changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 527
diff changeset
    17
lemma equivp_reflp_symp_transp:
f51e2b3e3149 Naming changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 527
diff changeset
    18
  shows "equivp E = (reflp E \<and> symp E \<and> transp E)"
543
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
    19
  unfolding equivp_def reflp_def symp_def transp_def expand_fun_eq
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
    20
  by (blast)
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
528
f51e2b3e3149 Naming changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 527
diff changeset
    22
lemma equivp_reflp:
f51e2b3e3149 Naming changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 527
diff changeset
    23
  shows "equivp E \<Longrightarrow> (\<And>x. E x x)"
593
18eac4596ef1 QuotProd with product_quotient and a 3 respects and preserves lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 554
diff changeset
    24
  by (simp only: equivp_reflp_symp_transp reflp_def)
18eac4596ef1 QuotProd with product_quotient and a 3 respects and preserves lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 554
diff changeset
    25
18eac4596ef1 QuotProd with product_quotient and a 3 respects and preserves lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 554
diff changeset
    26
lemma equivp_symp:
18eac4596ef1 QuotProd with product_quotient and a 3 respects and preserves lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 554
diff changeset
    27
  shows "equivp E \<Longrightarrow> (\<And>x y. E x y \<Longrightarrow> E y x)"
18eac4596ef1 QuotProd with product_quotient and a 3 respects and preserves lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 554
diff changeset
    28
  by (metis equivp_reflp_symp_transp symp_def)
18eac4596ef1 QuotProd with product_quotient and a 3 respects and preserves lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 554
diff changeset
    29
18eac4596ef1 QuotProd with product_quotient and a 3 respects and preserves lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 554
diff changeset
    30
lemma equivp_transp:
18eac4596ef1 QuotProd with product_quotient and a 3 respects and preserves lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 554
diff changeset
    31
  shows "equivp E \<Longrightarrow> (\<And>x y z. E x y \<Longrightarrow> E y z \<Longrightarrow> E x z)"
18eac4596ef1 QuotProd with product_quotient and a 3 respects and preserves lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 554
diff changeset
    32
by (metis equivp_reflp_symp_transp transp_def)
217
9cc87d02190a First experiments with Lambda
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 188
diff changeset
    33
700
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents: 697
diff changeset
    34
lemma equivpI:
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents: 697
diff changeset
    35
  assumes "reflp R" "symp R" "transp R"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents: 697
diff changeset
    36
  shows "equivp R"
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents: 697
diff changeset
    37
using assms by (simp add: equivp_reflp_symp_transp)
91b079db7380 added Larry's theory; introduced lemma equivpI; added something to the TODO about error messages
Christian Urban <urbanc@in.tum.de>
parents: 697
diff changeset
    38
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    39
definition
541
94deffed619d more name cleaning and removing
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 540
diff changeset
    40
  "part_equivp E \<equiv> (\<exists>x. E x x) \<and> (\<forall>x y. E x y = (E x x \<and> E y y \<and> (E x = E y)))"
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    41
541
94deffed619d more name cleaning and removing
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 540
diff changeset
    42
lemma equivp_IMP_part_equivp:
528
f51e2b3e3149 Naming changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 527
diff changeset
    43
  assumes a: "equivp E"
541
94deffed619d more name cleaning and removing
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 540
diff changeset
    44
  shows "part_equivp E"
543
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
    45
  using a unfolding equivp_def part_equivp_def
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
    46
  by auto
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    47
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    48
definition
543
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
    49
  "Quotient E Abs Rep \<equiv> (\<forall>a. Abs (Rep a) = a) \<and>
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
    50
                        (\<forall>a. E (Rep a) (Rep a)) \<and>
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    51
                        (\<forall>r s. E r s = (E r r \<and> E s s \<and> (Abs r = Abs s)))"
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    52
540
c0b13fb70d6d More code cleaning and renaming: moved rsp and prs lemmas from Int to QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 539
diff changeset
    53
lemma Quotient_abs_rep:
528
f51e2b3e3149 Naming changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 527
diff changeset
    54
  assumes a: "Quotient E Abs Rep"
546
8a1f4227dff9 abs_rep as ==
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 543
diff changeset
    55
  shows "Abs (Rep a) \<equiv> a"
543
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
    56
  using a unfolding Quotient_def
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
    57
  by simp
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    58
541
94deffed619d more name cleaning and removing
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 540
diff changeset
    59
lemma Quotient_rep_reflp:
528
f51e2b3e3149 Naming changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 527
diff changeset
    60
  assumes a: "Quotient E Abs Rep"
541
94deffed619d more name cleaning and removing
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 540
diff changeset
    61
  shows "E (Rep a) (Rep a)"
543
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
    62
  using a unfolding Quotient_def
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
    63
  by blast
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    64
539
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
    65
lemma Quotient_rel:
528
f51e2b3e3149 Naming changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 527
diff changeset
    66
  assumes a: "Quotient E Abs Rep"
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    67
  shows " E r s = (E r r \<and> E s s \<and> (Abs r = Abs s))"
543
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
    68
  using a unfolding Quotient_def
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
    69
  by blast
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    70
541
94deffed619d more name cleaning and removing
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 540
diff changeset
    71
lemma Quotient_rel_rep:
528
f51e2b3e3149 Naming changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 527
diff changeset
    72
  assumes a: "Quotient R Abs Rep"
541
94deffed619d more name cleaning and removing
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 540
diff changeset
    73
  shows "R (Rep a) (Rep b) \<equiv> (a = b)"
543
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
    74
  apply (rule eq_reflection)
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
    75
  using a unfolding Quotient_def
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
    76
  by metis
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    77
540
c0b13fb70d6d More code cleaning and renaming: moved rsp and prs lemmas from Int to QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 539
diff changeset
    78
lemma Quotient_rep_abs:
528
f51e2b3e3149 Naming changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 527
diff changeset
    79
  assumes a: "Quotient R Abs Rep"
459
020e27417b59 More code cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 458
diff changeset
    80
  shows "R r r \<Longrightarrow> R (Rep (Abs r)) r"
543
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
    81
  using a unfolding Quotient_def
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
    82
  by blast
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    83
542
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
    84
lemma identity_equivp:
528
f51e2b3e3149 Naming changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 527
diff changeset
    85
  shows "equivp (op =)"
543
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
    86
  unfolding equivp_def
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
    87
  by auto
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    88
542
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
    89
lemma identity_quotient:
528
f51e2b3e3149 Naming changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 527
diff changeset
    90
  shows "Quotient (op =) id id"
543
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
    91
  unfolding Quotient_def id_def
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
    92
  by blast
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    93
528
f51e2b3e3149 Naming changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 527
diff changeset
    94
lemma Quotient_symp:
f51e2b3e3149 Naming changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 527
diff changeset
    95
  assumes a: "Quotient E Abs Rep"
f51e2b3e3149 Naming changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 527
diff changeset
    96
  shows "symp E"
543
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
    97
  using a unfolding Quotient_def symp_def
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
    98
  by metis
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    99
528
f51e2b3e3149 Naming changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 527
diff changeset
   100
lemma Quotient_transp:
f51e2b3e3149 Naming changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 527
diff changeset
   101
  assumes a: "Quotient E Abs Rep"
f51e2b3e3149 Naming changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 527
diff changeset
   102
  shows "transp E"
543
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   103
  using a unfolding Quotient_def transp_def
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   104
  by metis
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   105
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   106
fun
112
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 96
diff changeset
   107
  fun_map
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   108
where
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   109
  "fun_map f g h x = g (h (f x))"
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   110
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   111
abbreviation
112
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 96
diff changeset
   112
  fun_map_syn (infixr "--->" 55)
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   113
where
112
0d6d37d0589d Progressing with the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 96
diff changeset
   114
  "f ---> g \<equiv> fun_map f g"
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   115
537
57073b0b8fac Even more name changes and cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 536
diff changeset
   116
lemma fun_map_id:
126
9cb8f9a59402 Partial simplification of the proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 113
diff changeset
   117
  shows "(id ---> id) = id"
543
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   118
  by (simp add: expand_fun_eq id_def)
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   119
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   120
fun
536
44fa9df44e6f More code cleaning and name changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 530
diff changeset
   121
  fun_rel
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   122
where
536
44fa9df44e6f More code cleaning and name changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 530
diff changeset
   123
  "fun_rel E1 E2 f g = (\<forall>x y. E1 x y \<longrightarrow> E2 (f x) (g y))"
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   124
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   125
abbreviation
536
44fa9df44e6f More code cleaning and name changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 530
diff changeset
   126
  fun_rel_syn (infixr "===>" 55)
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   127
where
536
44fa9df44e6f More code cleaning and name changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 530
diff changeset
   128
  "E1 ===> E2 \<equiv> fun_rel E1 E2"
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   129
536
44fa9df44e6f More code cleaning and name changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 530
diff changeset
   130
lemma fun_rel_eq:
511
28bb34eeedc5 Changing = to \<equiv> in case if we want to use simp.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 459
diff changeset
   131
  "(op =) ===> (op =) \<equiv> (op =)"
515
b00a9b58264d Fixes after big merge.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 511
diff changeset
   132
by (rule eq_reflection) (simp add: expand_fun_eq)
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   133
537
57073b0b8fac Even more name changes and cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 536
diff changeset
   134
lemma fun_quotient:
528
f51e2b3e3149 Naming changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 527
diff changeset
   135
  assumes q1: "Quotient R1 abs1 rep1"
f51e2b3e3149 Naming changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 527
diff changeset
   136
  and     q2: "Quotient R2 abs2 rep2"
f51e2b3e3149 Naming changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 527
diff changeset
   137
  shows "Quotient (R1 ===> R2) (rep1 ---> abs2) (abs1 ---> rep2)"
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   138
proof -
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   139
  have "\<forall>a. (rep1 ---> abs2) ((abs1 ---> rep2) a) = a"
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   140
    apply(simp add: expand_fun_eq)
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   141
    using q1 q2
528
f51e2b3e3149 Naming changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 527
diff changeset
   142
    apply(simp add: Quotient_def)
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   143
    done
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   144
  moreover
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   145
  have "\<forall>a. (R1 ===> R2) ((abs1 ---> rep2) a) ((abs1 ---> rep2) a)"
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   146
    apply(auto)
528
f51e2b3e3149 Naming changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 527
diff changeset
   147
    using q1 q2 unfolding Quotient_def
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   148
    apply(metis)
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   149
    done
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   150
  moreover
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   151
  have "\<forall>r s. (R1 ===> R2) r s = ((R1 ===> R2) r r \<and> (R1 ===> R2) s s \<and> 
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   152
        (rep1 ---> abs2) r  = (rep1 ---> abs2) s)"
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   153
    apply(auto simp add: expand_fun_eq)
528
f51e2b3e3149 Naming changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 527
diff changeset
   154
    using q1 q2 unfolding Quotient_def
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   155
    apply(metis)
528
f51e2b3e3149 Naming changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 527
diff changeset
   156
    using q1 q2 unfolding Quotient_def
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   157
    apply(metis)
528
f51e2b3e3149 Naming changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 527
diff changeset
   158
    using q1 q2 unfolding Quotient_def
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   159
    apply(metis)
528
f51e2b3e3149 Naming changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 527
diff changeset
   160
    using q1 q2 unfolding Quotient_def
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   161
    apply(metis)
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   162
    done
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   163
  ultimately
528
f51e2b3e3149 Naming changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 527
diff changeset
   164
  show "Quotient (R1 ===> R2) (rep1 ---> abs2) (abs1 ---> rep2)"
f51e2b3e3149 Naming changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 527
diff changeset
   165
    unfolding Quotient_def by blast
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   166
qed
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   167
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   168
definition
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   169
  Respects
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   170
where
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   171
  "Respects R x \<equiv> (R x x)"
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   172
542
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   173
lemma in_respects:
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   174
  shows "(x \<in> Respects R) = R x x"
543
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   175
  unfolding mem_def Respects_def by simp
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   176
527
9b1ad366827f code cleaning and renaming
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 519
diff changeset
   177
lemma equals_rsp:
528
f51e2b3e3149 Naming changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 527
diff changeset
   178
  assumes q: "Quotient R Abs Rep"
519
ebfd747b47ab Change equiv_trans2 to EQUALS_RSP, since we can prove it for any quotient type, not only for eqv relations.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 516
diff changeset
   179
  and     a: "R xa xb" "R ya yb"
ebfd747b47ab Change equiv_trans2 to EQUALS_RSP, since we can prove it for any quotient type, not only for eqv relations.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 516
diff changeset
   180
  shows "R xa ya = R xb yb"
543
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   181
  using Quotient_symp[OF q] Quotient_transp[OF q] unfolding symp_def transp_def
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   182
  using a by blast
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   183
527
9b1ad366827f code cleaning and renaming
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 519
diff changeset
   184
lemma lambda_prs:
528
f51e2b3e3149 Naming changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 527
diff changeset
   185
  assumes q1: "Quotient R1 Abs1 Rep1"
f51e2b3e3149 Naming changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 527
diff changeset
   186
  and     q2: "Quotient R2 Abs2 Rep2"
253
e169a99c6ada Automatic computation of application preservation and manually finished "alpha.induct". Slow...
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 252
diff changeset
   187
  shows "(Rep1 ---> Abs2) (\<lambda>x. Rep2 (f (Abs1 x))) = (\<lambda>x. f x)"
543
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   188
  unfolding expand_fun_eq
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   189
  using Quotient_abs_rep[OF q1] Quotient_abs_rep[OF q2]
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   190
  by simp
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   191
527
9b1ad366827f code cleaning and renaming
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 519
diff changeset
   192
lemma lambda_prs1:
528
f51e2b3e3149 Naming changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 527
diff changeset
   193
  assumes q1: "Quotient R1 Abs1 Rep1"
f51e2b3e3149 Naming changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 527
diff changeset
   194
  and     q2: "Quotient R2 Abs2 Rep2"
527
9b1ad366827f code cleaning and renaming
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 519
diff changeset
   195
  shows "(Rep1 ---> Abs2) (\<lambda>x. (Abs1 ---> Rep2) f x) = (\<lambda>x. f x)"
543
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   196
  unfolding expand_fun_eq
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   197
  using Quotient_abs_rep[OF q1] Quotient_abs_rep[OF q2]
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   198
  by simp
253
e169a99c6ada Automatic computation of application preservation and manually finished "alpha.induct". Slow...
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 252
diff changeset
   199
542
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   200
lemma rep_abs_rsp:
528
f51e2b3e3149 Naming changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 527
diff changeset
   201
  assumes q: "Quotient R Abs Rep"
459
020e27417b59 More code cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 458
diff changeset
   202
  and     a: "R x1 x2"
020e27417b59 More code cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 458
diff changeset
   203
  shows "R x1 (Rep (Abs x2))"
543
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   204
  using q a by (metis Quotient_rel[OF q] Quotient_abs_rep[OF q] Quotient_rep_reflp[OF q])
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   205
527
9b1ad366827f code cleaning and renaming
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 519
diff changeset
   206
(* In the following theorem R1 can be instantiated with anything,
516
bed81795848c Using APPLY_RSP1; again a little bit faster.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 515
diff changeset
   207
   but we know some of the types of the Rep and Abs functions;
543
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   208
   so by solving Quotient assumptions we can get a unique R1 that
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   209
   will be provable; which is why we need to use apply_rsp and
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   210
   not the primed version *)
527
9b1ad366827f code cleaning and renaming
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 519
diff changeset
   211
lemma apply_rsp:
528
f51e2b3e3149 Naming changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 527
diff changeset
   212
  assumes q: "Quotient R1 Abs1 Rep1"
516
bed81795848c Using APPLY_RSP1; again a little bit faster.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 515
diff changeset
   213
  and     a: "(R1 ===> R2) f g" "R1 x y"
bed81795848c Using APPLY_RSP1; again a little bit faster.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 515
diff changeset
   214
  shows "R2 ((f::'a\<Rightarrow>'c) x) ((g::'a\<Rightarrow>'c) y)"
543
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   215
  using a by simp
516
bed81795848c Using APPLY_RSP1; again a little bit faster.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 515
diff changeset
   216
527
9b1ad366827f code cleaning and renaming
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 519
diff changeset
   217
lemma apply_rsp':
317
d3c7f6d19c7f Still don't know how to do the proof automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 253
diff changeset
   218
  assumes a: "(R1 ===> R2) f g" "R1 x y"
d3c7f6d19c7f Still don't know how to do the proof automatically.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 253
diff changeset
   219
  shows "R2 (f x) (g y)"
543
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   220
  using a by simp
458
44a70e69ef92 Code cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 432
diff changeset
   221
427
5a3965aa4d80 Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 416
diff changeset
   222
(* Set of lemmas for regularisation of ball and bex *)
543
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   223
427
5a3965aa4d80 Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 416
diff changeset
   224
lemma ball_reg_eqv:
5a3965aa4d80 Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 416
diff changeset
   225
  fixes P :: "'a \<Rightarrow> bool"
528
f51e2b3e3149 Naming changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 527
diff changeset
   226
  assumes a: "equivp R"
427
5a3965aa4d80 Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 416
diff changeset
   227
  shows "Ball (Respects R) P = (All P)"
542
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   228
  by (metis equivp_def in_respects a)
427
5a3965aa4d80 Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 416
diff changeset
   229
5a3965aa4d80 Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 416
diff changeset
   230
lemma bex_reg_eqv:
93
ec29be471518 Manually regularized list_induct2
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 0
diff changeset
   231
  fixes P :: "'a \<Rightarrow> bool"
528
f51e2b3e3149 Naming changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 527
diff changeset
   232
  assumes a: "equivp R"
427
5a3965aa4d80 Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 416
diff changeset
   233
  shows "Bex (Respects R) P = (Ex P)"
542
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   234
  by (metis equivp_def in_respects a)
427
5a3965aa4d80 Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 416
diff changeset
   235
5a3965aa4d80 Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 416
diff changeset
   236
lemma ball_reg_right:
5a3965aa4d80 Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 416
diff changeset
   237
  assumes a: "\<And>x. R x \<Longrightarrow> P x \<longrightarrow> Q x"
5a3965aa4d80 Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 416
diff changeset
   238
  shows "All P \<longrightarrow> Ball R Q"
5a3965aa4d80 Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 416
diff changeset
   239
  by (metis COMBC_def Collect_def Collect_mem_eq a)
5a3965aa4d80 Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 416
diff changeset
   240
5a3965aa4d80 Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 416
diff changeset
   241
lemma bex_reg_left:
5a3965aa4d80 Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 416
diff changeset
   242
  assumes a: "\<And>x. R x \<Longrightarrow> Q x \<longrightarrow> P x"
5a3965aa4d80 Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 416
diff changeset
   243
  shows "Bex R Q \<longrightarrow> Ex P"
5a3965aa4d80 Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 416
diff changeset
   244
  by (metis COMBC_def Collect_def Collect_mem_eq a)
5a3965aa4d80 Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 416
diff changeset
   245
5a3965aa4d80 Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 416
diff changeset
   246
lemma ball_reg_left:
528
f51e2b3e3149 Naming changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 527
diff changeset
   247
  assumes a: "equivp R"
427
5a3965aa4d80 Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 416
diff changeset
   248
  shows "(\<And>x. (Q x \<longrightarrow> P x)) \<Longrightarrow> Ball (Respects R) Q \<longrightarrow> All P"
542
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   249
  by (metis equivp_reflp in_respects a)
93
ec29be471518 Manually regularized list_induct2
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 0
diff changeset
   250
427
5a3965aa4d80 Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 416
diff changeset
   251
lemma bex_reg_right:
528
f51e2b3e3149 Naming changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 527
diff changeset
   252
  assumes a: "equivp R"
427
5a3965aa4d80 Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 416
diff changeset
   253
  shows "(\<And>x. (Q x \<longrightarrow> P x)) \<Longrightarrow> Ex Q \<longrightarrow> Bex (Respects R) P"
542
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   254
  by (metis equivp_reflp in_respects a)
93
ec29be471518 Manually regularized list_induct2
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 0
diff changeset
   255
427
5a3965aa4d80 Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 416
diff changeset
   256
lemma ball_reg_eqv_range:
5a3965aa4d80 Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 416
diff changeset
   257
  fixes P::"'a \<Rightarrow> bool"
5a3965aa4d80 Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 416
diff changeset
   258
  and x::"'a"
528
f51e2b3e3149 Naming changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 527
diff changeset
   259
  assumes a: "equivp R2"
427
5a3965aa4d80 Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 416
diff changeset
   260
  shows   "(Ball (Respects (R1 ===> R2)) (\<lambda>f. P (f x)) = All (\<lambda>f. P (f x)))"
5a3965aa4d80 Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 416
diff changeset
   261
  apply(rule iffI)
5a3965aa4d80 Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 416
diff changeset
   262
  apply(rule allI)
5a3965aa4d80 Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 416
diff changeset
   263
  apply(drule_tac x="\<lambda>y. f x" in bspec)
605
120e479ed367 first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents: 597
diff changeset
   264
  apply(simp add: in_respects)
427
5a3965aa4d80 Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 416
diff changeset
   265
  apply(rule impI)
528
f51e2b3e3149 Naming changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 527
diff changeset
   266
  using a equivp_reflp_symp_transp[of "R2"]
f51e2b3e3149 Naming changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 527
diff changeset
   267
  apply(simp add: reflp_def)
427
5a3965aa4d80 Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 416
diff changeset
   268
  apply(simp)
5a3965aa4d80 Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 416
diff changeset
   269
  apply(simp)
5a3965aa4d80 Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 416
diff changeset
   270
  done
5a3965aa4d80 Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 416
diff changeset
   271
5a3965aa4d80 Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 416
diff changeset
   272
lemma bex_reg_eqv_range:
5a3965aa4d80 Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 416
diff changeset
   273
  fixes P::"'a \<Rightarrow> bool"
5a3965aa4d80 Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 416
diff changeset
   274
  and x::"'a"
528
f51e2b3e3149 Naming changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 527
diff changeset
   275
  assumes a: "equivp R2"
427
5a3965aa4d80 Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 416
diff changeset
   276
  shows   "(Bex (Respects (R1 ===> R2)) (\<lambda>f. P (f x)) = Ex (\<lambda>f. P (f x)))"
5a3965aa4d80 Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 416
diff changeset
   277
  apply(auto)
5a3965aa4d80 Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 416
diff changeset
   278
  apply(rule_tac x="\<lambda>y. f x" in bexI)
5a3965aa4d80 Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 416
diff changeset
   279
  apply(simp)
542
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   280
  apply(simp add: Respects_def in_respects)
427
5a3965aa4d80 Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 416
diff changeset
   281
  apply(rule impI)
528
f51e2b3e3149 Naming changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 527
diff changeset
   282
  using a equivp_reflp_symp_transp[of "R2"]
f51e2b3e3149 Naming changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 527
diff changeset
   283
  apply(simp add: reflp_def)
427
5a3965aa4d80 Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 416
diff changeset
   284
  done
5a3965aa4d80 Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 416
diff changeset
   285
5a3965aa4d80 Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 416
diff changeset
   286
lemma all_reg:
96
4da714704611 A number of lemmas for REGULARIZE_TAC and regularizing card1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 95
diff changeset
   287
  assumes a: "!x :: 'a. (P x --> Q x)"
4da714704611 A number of lemmas for REGULARIZE_TAC and regularizing card1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 95
diff changeset
   288
  and     b: "All P"
4da714704611 A number of lemmas for REGULARIZE_TAC and regularizing card1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 95
diff changeset
   289
  shows "All Q"
4da714704611 A number of lemmas for REGULARIZE_TAC and regularizing card1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 95
diff changeset
   290
  using a b by (metis)
4da714704611 A number of lemmas for REGULARIZE_TAC and regularizing card1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 95
diff changeset
   291
427
5a3965aa4d80 Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 416
diff changeset
   292
lemma ex_reg:
96
4da714704611 A number of lemmas for REGULARIZE_TAC and regularizing card1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 95
diff changeset
   293
  assumes a: "!x :: 'a. (P x --> Q x)"
4da714704611 A number of lemmas for REGULARIZE_TAC and regularizing card1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 95
diff changeset
   294
  and     b: "Ex P"
4da714704611 A number of lemmas for REGULARIZE_TAC and regularizing card1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 95
diff changeset
   295
  shows "Ex Q"
4da714704611 A number of lemmas for REGULARIZE_TAC and regularizing card1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 95
diff changeset
   296
  using a b by (metis)
4da714704611 A number of lemmas for REGULARIZE_TAC and regularizing card1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 95
diff changeset
   297
427
5a3965aa4d80 Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 416
diff changeset
   298
lemma ball_reg:
96
4da714704611 A number of lemmas for REGULARIZE_TAC and regularizing card1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 95
diff changeset
   299
  assumes a: "!x :: 'a. (R x --> P x --> Q x)"
4da714704611 A number of lemmas for REGULARIZE_TAC and regularizing card1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 95
diff changeset
   300
  and     b: "Ball R P"
4da714704611 A number of lemmas for REGULARIZE_TAC and regularizing card1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 95
diff changeset
   301
  shows "Ball R Q"
4da714704611 A number of lemmas for REGULARIZE_TAC and regularizing card1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 95
diff changeset
   302
  using a b by (metis COMBC_def Collect_def Collect_mem_eq)
4da714704611 A number of lemmas for REGULARIZE_TAC and regularizing card1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 95
diff changeset
   303
427
5a3965aa4d80 Cleaned all lemmas about regularisation of Ball and Bex and moved in one place. Second Ball simprox.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 416
diff changeset
   304
lemma bex_reg:
96
4da714704611 A number of lemmas for REGULARIZE_TAC and regularizing card1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 95
diff changeset
   305
  assumes a: "!x :: 'a. (R x --> P x --> Q x)"
4da714704611 A number of lemmas for REGULARIZE_TAC and regularizing card1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 95
diff changeset
   306
  and     b: "Bex R P"
4da714704611 A number of lemmas for REGULARIZE_TAC and regularizing card1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 95
diff changeset
   307
  shows "Bex R Q"
4da714704611 A number of lemmas for REGULARIZE_TAC and regularizing card1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 95
diff changeset
   308
  using a b by (metis COMBC_def Collect_def Collect_mem_eq)
4da714704611 A number of lemmas for REGULARIZE_TAC and regularizing card1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 95
diff changeset
   309
432
9c33c0809733 Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 427
diff changeset
   310
lemma ball_all_comm:
9c33c0809733 Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 427
diff changeset
   311
  "(\<And>y. (\<forall>x\<in>P. A x y) \<longrightarrow> (\<forall>x. B x y)) \<Longrightarrow> ((\<forall>x\<in>P. \<forall>y. A x y) \<longrightarrow> (\<forall>x. \<forall>y. B x y))"
9c33c0809733 Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 427
diff changeset
   312
by auto
9c33c0809733 Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 427
diff changeset
   313
9c33c0809733 Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 427
diff changeset
   314
lemma bex_ex_comm:
9c33c0809733 Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 427
diff changeset
   315
  "((\<exists>y. \<exists>x. A x y) \<longrightarrow> (\<exists>y. \<exists>x\<in>P. B x y)) \<Longrightarrow> ((\<exists>x. \<exists>y. A x y) \<longrightarrow> (\<exists>x\<in>P. \<exists>y. B x y))"
9c33c0809733 Finished and tested the new regularize
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 427
diff changeset
   316
by auto
96
4da714704611 A number of lemmas for REGULARIZE_TAC and regularizing card1.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 95
diff changeset
   317
595
a2f2214dc881 Fix of regularize for babs and proof of babs_rsp.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 593
diff changeset
   318
(* Bounded abstraction *)
a2f2214dc881 Fix of regularize for babs and proof of babs_rsp.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 593
diff changeset
   319
definition
a2f2214dc881 Fix of regularize for babs and proof of babs_rsp.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 593
diff changeset
   320
  Babs :: "('a \<Rightarrow> bool) \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'a \<Rightarrow> 'b"
a2f2214dc881 Fix of regularize for babs and proof of babs_rsp.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 593
diff changeset
   321
where
a2f2214dc881 Fix of regularize for babs and proof of babs_rsp.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 593
diff changeset
   322
  "(x \<in> p) \<Longrightarrow> (Babs p m x = m x)"
a2f2214dc881 Fix of regularize for babs and proof of babs_rsp.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 593
diff changeset
   323
a2f2214dc881 Fix of regularize for babs and proof of babs_rsp.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 593
diff changeset
   324
(* 3 lemmas needed for proving repabs_inj *)
458
44a70e69ef92 Code cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 432
diff changeset
   325
lemma ball_rsp:
44a70e69ef92 Code cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 432
diff changeset
   326
  assumes a: "(R ===> (op =)) f g"
44a70e69ef92 Code cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 432
diff changeset
   327
  shows "Ball (Respects R) f = Ball (Respects R) g"
542
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   328
  using a by (simp add: Ball_def in_respects)
153
0288dd5b7ed4 The problems with 'abs' term.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 126
diff changeset
   329
458
44a70e69ef92 Code cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 432
diff changeset
   330
lemma bex_rsp:
44a70e69ef92 Code cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 432
diff changeset
   331
  assumes a: "(R ===> (op =)) f g"
44a70e69ef92 Code cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 432
diff changeset
   332
  shows "(Bex (Respects R) f = Bex (Respects R) g)"
542
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   333
  using a by (simp add: Bex_def in_respects)
171
13aab4c59096 More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 166
diff changeset
   334
595
a2f2214dc881 Fix of regularize for babs and proof of babs_rsp.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 593
diff changeset
   335
lemma babs_rsp:
a2f2214dc881 Fix of regularize for babs and proof of babs_rsp.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 593
diff changeset
   336
  assumes q: "Quotient R1 Abs1 Rep1"
a2f2214dc881 Fix of regularize for babs and proof of babs_rsp.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 593
diff changeset
   337
  and     a: "(R1 ===> R2) f g"
a2f2214dc881 Fix of regularize for babs and proof of babs_rsp.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 593
diff changeset
   338
  shows      "(R1 ===> R2) (Babs (Respects R1) f) (Babs (Respects R1) g)"
a2f2214dc881 Fix of regularize for babs and proof of babs_rsp.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 593
diff changeset
   339
  apply (auto simp add: Babs_def)
a2f2214dc881 Fix of regularize for babs and proof of babs_rsp.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 593
diff changeset
   340
  apply (subgoal_tac "x \<in> Respects R1 \<and> y \<in> Respects R1")
a2f2214dc881 Fix of regularize for babs and proof of babs_rsp.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 593
diff changeset
   341
  using a apply (simp add: Babs_def)
a2f2214dc881 Fix of regularize for babs and proof of babs_rsp.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 593
diff changeset
   342
  apply (simp add: in_respects)
a2f2214dc881 Fix of regularize for babs and proof of babs_rsp.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 593
diff changeset
   343
  using Quotient_rel[OF q]
a2f2214dc881 Fix of regularize for babs and proof of babs_rsp.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 593
diff changeset
   344
  by metis
a2f2214dc881 Fix of regularize for babs and proof of babs_rsp.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 593
diff changeset
   345
607
a8c3fa5c4015 babs_prs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 605
diff changeset
   346
lemma babs_prs:
a8c3fa5c4015 babs_prs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 605
diff changeset
   347
  assumes q1: "Quotient R1 Abs1 Rep1"
a8c3fa5c4015 babs_prs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 605
diff changeset
   348
  and     q2: "Quotient R2 Abs2 Rep2"
a8c3fa5c4015 babs_prs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 605
diff changeset
   349
  shows "(Rep1 ---> Abs2) (Babs (Respects R1) ((Abs1 ---> Rep2) f)) \<equiv> f"
a8c3fa5c4015 babs_prs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 605
diff changeset
   350
  apply(rule eq_reflection)
a8c3fa5c4015 babs_prs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 605
diff changeset
   351
  apply(rule ext)
a8c3fa5c4015 babs_prs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 605
diff changeset
   352
  apply simp
a8c3fa5c4015 babs_prs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 605
diff changeset
   353
  apply (subgoal_tac "Rep1 x \<in> Respects R1")
a8c3fa5c4015 babs_prs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 605
diff changeset
   354
  apply (simp add: Babs_def Quotient_abs_rep[OF q1] Quotient_abs_rep[OF q2])
a8c3fa5c4015 babs_prs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 605
diff changeset
   355
  apply (simp add: in_respects Quotient_rel_rep[OF q1])
a8c3fa5c4015 babs_prs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 605
diff changeset
   356
  done
a8c3fa5c4015 babs_prs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 605
diff changeset
   357
696
fd718dde1d61 Simplification of Babses for regularize; will probably become injection
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 674
diff changeset
   358
lemma babs_simp:
fd718dde1d61 Simplification of Babses for regularize; will probably become injection
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 674
diff changeset
   359
  assumes q: "Quotient R1 Abs Rep"
fd718dde1d61 Simplification of Babses for regularize; will probably become injection
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 674
diff changeset
   360
  shows "((R1 ===> R2) (Babs (Respects R1) f) (Babs (Respects R1) g)) = ((R1 ===> R2) f g)"
fd718dde1d61 Simplification of Babses for regularize; will probably become injection
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 674
diff changeset
   361
apply(rule iffI)
fd718dde1d61 Simplification of Babses for regularize; will probably become injection
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 674
diff changeset
   362
apply(simp_all only: babs_rsp[OF q])
fd718dde1d61 Simplification of Babses for regularize; will probably become injection
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 674
diff changeset
   363
apply(auto simp add: Babs_def)
fd718dde1d61 Simplification of Babses for regularize; will probably become injection
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 674
diff changeset
   364
apply (subgoal_tac "x \<in> Respects R1 \<and> y \<in> Respects R1")
fd718dde1d61 Simplification of Babses for regularize; will probably become injection
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 674
diff changeset
   365
apply(metis Babs_def)
fd718dde1d61 Simplification of Babses for regularize; will probably become injection
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 674
diff changeset
   366
apply (simp add: in_respects)
fd718dde1d61 Simplification of Babses for regularize; will probably become injection
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 674
diff changeset
   367
using Quotient_rel[OF q]
fd718dde1d61 Simplification of Babses for regularize; will probably become injection
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 674
diff changeset
   368
by metis
fd718dde1d61 Simplification of Babses for regularize; will probably become injection
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 674
diff changeset
   369
fd718dde1d61 Simplification of Babses for regularize; will probably become injection
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 674
diff changeset
   370
605
120e479ed367 first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents: 597
diff changeset
   371
(* needed for regularising? *)
120e479ed367 first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents: 597
diff changeset
   372
lemma babs_reg_eqv:
120e479ed367 first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents: 597
diff changeset
   373
  shows "equivp R \<Longrightarrow> Babs (Respects R) P = P"
120e479ed367 first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents: 597
diff changeset
   374
by (simp add: expand_fun_eq Babs_def in_respects equivp_reflp)
120e479ed367 first attempt to deal with Babs in regularise and cleaning (not yet working)
Christian Urban <urbanc@in.tum.de>
parents: 597
diff changeset
   375
458
44a70e69ef92 Code cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 432
diff changeset
   376
(* 2 lemmas needed for cleaning of quantifiers *)
44a70e69ef92 Code cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 432
diff changeset
   377
lemma all_prs:
528
f51e2b3e3149 Naming changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 527
diff changeset
   378
  assumes a: "Quotient R absf repf"
458
44a70e69ef92 Code cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 432
diff changeset
   379
  shows "Ball (Respects R) ((absf ---> id) f) = All f"
528
f51e2b3e3149 Naming changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 527
diff changeset
   380
  using a unfolding Quotient_def
542
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   381
  by (metis in_respects fun_map.simps id_apply)
162
20f0b148cfe2 eqsubst_tac
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 155
diff changeset
   382
458
44a70e69ef92 Code cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 432
diff changeset
   383
lemma ex_prs:
528
f51e2b3e3149 Naming changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 527
diff changeset
   384
  assumes a: "Quotient R absf repf"
458
44a70e69ef92 Code cleaning.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 432
diff changeset
   385
  shows "Bex (Respects R) ((absf ---> id) f) = Ex f"
528
f51e2b3e3149 Naming changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 527
diff changeset
   386
  using a unfolding Quotient_def
542
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   387
  by (metis COMBC_def Collect_def Collect_mem_eq in_respects fun_map.simps id_apply)
171
13aab4c59096 More infrastructure for automatic lifting of theorems lifted before
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 166
diff changeset
   388
554
8395fc6a6945 Solutions to IntEx tests.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 546
diff changeset
   389
lemma fun_rel_id:
8395fc6a6945 Solutions to IntEx tests.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 546
diff changeset
   390
  assumes a: "\<And>x y. R1 x y \<Longrightarrow> R2 (f x) (g y)"
8395fc6a6945 Solutions to IntEx tests.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 546
diff changeset
   391
  shows "(R1 ===> R2) f g"
8395fc6a6945 Solutions to IntEx tests.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 546
diff changeset
   392
using a by simp
8395fc6a6945 Solutions to IntEx tests.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 546
diff changeset
   393
697
57944c1ef728 Regularized the hard lemma.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 696
diff changeset
   394
lemma fun_rel_id_asm:
57944c1ef728 Regularized the hard lemma.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 696
diff changeset
   395
  assumes a: "\<And>x y. R1 x y \<Longrightarrow> (A \<longrightarrow> R2 (f x) (g y))"
57944c1ef728 Regularized the hard lemma.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 696
diff changeset
   396
  shows "A \<longrightarrow> (R1 ===> R2) f g"
57944c1ef728 Regularized the hard lemma.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 696
diff changeset
   397
using a by auto
57944c1ef728 Regularized the hard lemma.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 696
diff changeset
   398
554
8395fc6a6945 Solutions to IntEx tests.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 546
diff changeset
   399
lemma quot_rel_rsp:
8395fc6a6945 Solutions to IntEx tests.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 546
diff changeset
   400
  assumes a: "Quotient R Abs Rep"
8395fc6a6945 Solutions to IntEx tests.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 546
diff changeset
   401
  shows "(R ===> R ===> op =) R R"
8395fc6a6945 Solutions to IntEx tests.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 546
diff changeset
   402
  apply(rule fun_rel_id)+
8395fc6a6945 Solutions to IntEx tests.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 546
diff changeset
   403
  apply(rule equals_rsp[OF a])
8395fc6a6945 Solutions to IntEx tests.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 546
diff changeset
   404
  apply(assumption)+
8395fc6a6945 Solutions to IntEx tests.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 546
diff changeset
   405
  done
8395fc6a6945 Solutions to IntEx tests.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 546
diff changeset
   406
541
94deffed619d more name cleaning and removing
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 540
diff changeset
   407
543
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   408
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   409
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   410
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   411
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   412
(******************************************)
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   413
(* REST OF THE FILE IS UNUSED (until now) *)
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   414
(******************************************)
656
c86a47d4966e Temporarily repeated fun_map_tac 4 times. Cleaning for all examples work.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 607
diff changeset
   415
c86a47d4966e Temporarily repeated fun_map_tac 4 times. Cleaning for all examples work.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 607
diff changeset
   416
(* Always safe to apply, but not too helpful *)
c86a47d4966e Temporarily repeated fun_map_tac 4 times. Cleaning for all examples work.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 607
diff changeset
   417
lemma app_prs2:
c86a47d4966e Temporarily repeated fun_map_tac 4 times. Cleaning for all examples work.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 607
diff changeset
   418
  assumes q1: "Quotient R1 abs1 rep1"
c86a47d4966e Temporarily repeated fun_map_tac 4 times. Cleaning for all examples work.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 607
diff changeset
   419
  and     q2: "Quotient R2 abs2 rep2"
c86a47d4966e Temporarily repeated fun_map_tac 4 times. Cleaning for all examples work.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 607
diff changeset
   420
  shows  "((abs1 ---> rep2) ((rep1 ---> abs2) f) (rep1 x)) = rep2 (((rep1 ---> abs2) f) x)"
c86a47d4966e Temporarily repeated fun_map_tac 4 times. Cleaning for all examples work.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 607
diff changeset
   421
unfolding expand_fun_eq
c86a47d4966e Temporarily repeated fun_map_tac 4 times. Cleaning for all examples work.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 607
diff changeset
   422
using Quotient_abs_rep[OF q1] Quotient_abs_rep[OF q2]
c86a47d4966e Temporarily repeated fun_map_tac 4 times. Cleaning for all examples work.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 607
diff changeset
   423
by simp
c86a47d4966e Temporarily repeated fun_map_tac 4 times. Cleaning for all examples work.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 607
diff changeset
   424
541
94deffed619d more name cleaning and removing
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 540
diff changeset
   425
lemma Quotient_rel_abs:
94deffed619d more name cleaning and removing
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 540
diff changeset
   426
  assumes a: "Quotient E Abs Rep"
94deffed619d more name cleaning and removing
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 540
diff changeset
   427
  shows "E r s \<Longrightarrow> Abs r = Abs s"
94deffed619d more name cleaning and removing
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 540
diff changeset
   428
using a unfolding Quotient_def
94deffed619d more name cleaning and removing
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 540
diff changeset
   429
by blast
94deffed619d more name cleaning and removing
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 540
diff changeset
   430
94deffed619d more name cleaning and removing
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 540
diff changeset
   431
lemma Quotient_rel_abs_eq:
94deffed619d more name cleaning and removing
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 540
diff changeset
   432
  assumes a: "Quotient E Abs Rep"
94deffed619d more name cleaning and removing
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 540
diff changeset
   433
  shows "E r r \<Longrightarrow> E s s \<Longrightarrow> E r s = (Abs r = Abs s)"
94deffed619d more name cleaning and removing
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 540
diff changeset
   434
using a unfolding Quotient_def
94deffed619d more name cleaning and removing
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 540
diff changeset
   435
by blast
94deffed619d more name cleaning and removing
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 540
diff changeset
   436
542
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   437
lemma in_fun:
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   438
  shows "x \<in> ((f ---> g) s) = g (f x \<in> s)"
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   439
by (simp add: mem_def)
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   440
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   441
lemma RESPECTS_THM:
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   442
  shows "Respects (R1 ===> R2) f = (\<forall>x y. R1 x y \<longrightarrow> R2 (f x) (f y))"
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   443
unfolding Respects_def
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   444
by (simp add: expand_fun_eq) 
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   445
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   446
lemma RESPECTS_REP_ABS:
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   447
  assumes a: "Quotient R1 Abs1 Rep1"
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   448
  and     b: "Respects (R1 ===> R2) f"
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   449
  and     c: "R1 x x"
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   450
  shows "R2 (f (Rep1 (Abs1 x))) (f x)"
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   451
using a b[simplified RESPECTS_THM] c unfolding Quotient_def
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   452
by blast
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   453
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   454
lemma RESPECTS_MP:
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   455
  assumes a: "Respects (R1 ===> R2) f"
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   456
  and     b: "R1 x y"
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   457
  shows "R2 (f x) (f y)"
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   458
using a b unfolding Respects_def
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   459
by simp
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   460
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   461
lemma RESPECTS_o:
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   462
  assumes a: "Respects (R2 ===> R3) f"
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   463
  and     b: "Respects (R1 ===> R2) g"
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   464
  shows "Respects (R1 ===> R3) (f o g)"
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   465
using a b unfolding Respects_def
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   466
by simp
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   467
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   468
lemma fun_rel_EQ_REL:
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   469
  assumes q1: "Quotient R1 Abs1 Rep1"
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   470
  and     q2: "Quotient R2 Abs2 Rep2"
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   471
  shows "(R1 ===> R2) f g = ((Respects (R1 ===> R2) f) \<and> (Respects (R1 ===> R2) g) 
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   472
                             \<and> ((Rep1 ---> Abs2) f = (Rep1 ---> Abs2) g))"
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   473
using fun_quotient[OF q1 q2] unfolding Respects_def Quotient_def expand_fun_eq
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   474
by blast
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   475
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   476
(* Not used since in the end we just unfold fun_map *)
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   477
lemma APP_PRS:
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   478
  assumes q1: "Quotient R1 abs1 rep1"
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   479
  and     q2: "Quotient R2 abs2 rep2"
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   480
  shows "abs2 ((abs1 ---> rep2) f (rep1 x)) = f x"
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   481
unfolding expand_fun_eq
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   482
using Quotient_abs_rep[OF q1] Quotient_abs_rep[OF q2]
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   483
by simp
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   484
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   485
(* Ask Peter: assumption q1 and q2 not used and lemma is the 'identity' *)
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   486
lemma LAMBDA_RSP:
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   487
  assumes q1: "Quotient R1 Abs1 Rep1"
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   488
  and     q2: "Quotient R2 Abs2 Rep2"
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   489
  and     a: "(R1 ===> R2) f1 f2"
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   490
  shows "(R1 ===> R2) (\<lambda>x. f1 x) (\<lambda>y. f2 y)"
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   491
by (rule a)
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   492
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   493
(* ASK Peter about next four lemmas in quotientScript
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   494
lemma ABSTRACT_PRS:
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   495
  assumes q1: "Quotient R1 Abs1 Rep1"
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   496
  and     q2: "Quotient R2 Abs2 Rep2"
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   497
  shows "f = (Rep1 ---> Abs2) ???"
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   498
*)
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   499
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   500
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   501
lemma fun_rel_EQUALS:
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   502
  assumes q1: "Quotient R1 Abs1 Rep1"
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   503
  and     q2: "Quotient R2 Abs2 Rep2"
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   504
  and     r1: "Respects (R1 ===> R2) f"
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   505
  and     r2: "Respects (R1 ===> R2) g" 
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   506
  shows "((Rep1 ---> Abs2) f = (Rep1 ---> Abs2) g) = (\<forall>x y. R1 x y \<longrightarrow> R2 (f x) (g y))"
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   507
apply(rule_tac iffI)
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   508
using fun_quotient[OF q1 q2] r1 r2 unfolding Quotient_def Respects_def
543
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   509
apply(metis apply_rsp')
542
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   510
using r1 unfolding Respects_def expand_fun_eq
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   511
apply(simp (no_asm_use))
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   512
apply(metis Quotient_rel[OF q2] Quotient_rel_rep[OF q1])
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   513
done
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   514
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   515
(* ask Peter: fun_rel_IMP used twice *) 
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   516
lemma fun_rel_IMP2:
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   517
  assumes q1: "Quotient R1 Abs1 Rep1"
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   518
  and     q2: "Quotient R2 Abs2 Rep2"
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   519
  and     r1: "Respects (R1 ===> R2) f"
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   520
  and     r2: "Respects (R1 ===> R2) g" 
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   521
  and     a:  "(Rep1 ---> Abs2) f = (Rep1 ---> Abs2) g"
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   522
  shows "R1 x y \<Longrightarrow> R2 (f x) (g y)"
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   523
using q1 q2 r1 r2 a
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   524
by (simp add: fun_rel_EQUALS)
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   525
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   526
lemma LAMBDA_REP_ABS_RSP:
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   527
  assumes r1: "\<And>r r'. R1 r r' \<Longrightarrow>R1 r (Rep1 (Abs1 r'))"
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   528
  and     r2: "\<And>r r'. R2 r r' \<Longrightarrow>R2 r (Rep2 (Abs2 r'))"
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   529
  shows "(R1 ===> R2) f1 f2 \<Longrightarrow> (R1 ===> R2) f1 ((Abs1 ---> Rep2) ((Rep1 ---> Abs2) f2))"
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   530
using r1 r2 by auto
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   531
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   532
(* Not used *)
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   533
lemma rep_abs_rsp_left:
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   534
  assumes q: "Quotient R Abs Rep"
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   535
  and     a: "R x1 x2"
674
bb276771d85c Finished one proof in IntEx2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 656
diff changeset
   536
  shows "R (Rep (Abs x1)) x2"
542
fe468f8723fc More cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   537
using q a by (metis Quotient_rel[OF q] Quotient_abs_rep[OF q] Quotient_rep_reflp[OF q])
541
94deffed619d more name cleaning and removing
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 540
diff changeset
   538
94deffed619d more name cleaning and removing
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 540
diff changeset
   539
543
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   540
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   541
(* bool theory: COND, LET *)
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   542
lemma IF_PRS:
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   543
  assumes q: "Quotient R Abs Rep"
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   544
  shows "If a b c = Abs (If a (Rep b) (Rep c))"
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   545
using Quotient_abs_rep[OF q] by auto
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   546
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   547
(* ask peter: no use of q *)
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   548
lemma IF_RSP:
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   549
  assumes q: "Quotient R Abs Rep"
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   550
  and     a: "a1 = a2" "R b1 b2" "R c1 c2"
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   551
  shows "R (If a1 b1 c1) (If a2 b2 c2)"
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   552
using a by auto
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   553
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   554
lemma LET_PRS:
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   555
  assumes q1: "Quotient R1 Abs1 Rep1"
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   556
  and     q2: "Quotient R2 Abs2 Rep2"
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   557
  shows "Let x f = Abs2 (Let (Rep1 x) ((Abs1 ---> Rep2) f))"
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   558
using Quotient_abs_rep[OF q1] Quotient_abs_rep[OF q2] by auto
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   559
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   560
lemma LET_RSP:
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   561
  assumes q1: "Quotient R1 Abs1 Rep1"
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   562
  and     a1: "(R1 ===> R2) f g"
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   563
  and     a2: "R1 x y"
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   564
  shows "R2 ((Let x f)::'c) ((Let y g)::'c)"
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   565
using apply_rsp[OF q1 a1] a2
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   566
by auto
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   567
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   568
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   569
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   570
(* ask peter what are literal_case *)
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   571
(* literal_case_PRS *)
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   572
(* literal_case_RSP *)
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   573
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   574
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   575
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   576
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   577
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   578
(* combinators: I, K, o, C, W *)
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   579
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   580
(* We use id_simps which includes id_apply; so these 2 theorems can be removed *)
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   581
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   582
lemma I_PRS:
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   583
  assumes q: "Quotient R Abs Rep"
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   584
  shows "id e = Abs (id (Rep e))"
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   585
using Quotient_abs_rep[OF q] by auto
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   586
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   587
lemma I_RSP:
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   588
  assumes q: "Quotient R Abs Rep"
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   589
  and     a: "R e1 e2"
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   590
  shows "R (id e1) (id e2)"
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   591
using a by auto
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   592
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   593
lemma o_PRS:
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   594
  assumes q1: "Quotient R1 Abs1 Rep1"
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   595
  and     q2: "Quotient R2 Abs2 Rep2"
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   596
  and     q3: "Quotient R3 Abs3 Rep3"
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   597
  shows "f o g = (Rep1 ---> Abs3) (((Abs2 ---> Rep3) f) o ((Abs1 ---> Rep2) g))"
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   598
using Quotient_abs_rep[OF q1] Quotient_abs_rep[OF q2] Quotient_abs_rep[OF q3]
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   599
unfolding o_def expand_fun_eq
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   600
by simp
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   601
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   602
lemma o_RSP:
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   603
  assumes q1: "Quotient R1 Abs1 Rep1"
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   604
  and     q2: "Quotient R2 Abs2 Rep2"
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   605
  and     q3: "Quotient R3 Abs3 Rep3"
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   606
  and     a1: "(R2 ===> R3) f1 f2"
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   607
  and     a2: "(R1 ===> R2) g1 g2"
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   608
  shows "(R1 ===> R3) (f1 o g1) (f2 o g2)"
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   609
using a1 a2 unfolding o_def expand_fun_eq
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   610
by (auto)
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   611
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   612
lemma COND_PRS:
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   613
  assumes a: "Quotient R absf repf"
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   614
  shows "(if a then b else c) = absf (if a then repf b else repf c)"
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   615
  using a unfolding Quotient_def by auto
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   616
d030c8e19465 Cleaning/review of QuotScript.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 542
diff changeset
   617
93
ec29be471518 Manually regularized list_induct2
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 0
diff changeset
   618
end
95
8c3a35da4560 Proving the proper RepAbs version
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 93
diff changeset
   619