Attic/UnusedQuotBase.thy
author Cezary Kaliszyk <kaliszyk@in.tum.de>
Tue, 20 Dec 2011 16:49:03 +0900
changeset 3081 660a4f5adee8
parent 1123 41f89d4f9548
permissions -rw-r--r--
Remove 'HERE1' and 'HERE3'.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1123
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     1
lemma in_fun:
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     2
  shows "x \<in> ((f ---> g) s) = g (f x \<in> s)"
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     3
  by (simp add: mem_def)
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     4
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     5
lemma respects_thm:
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     6
  shows "Respects (R1 ===> R2) f = (\<forall>x y. R1 x y \<longrightarrow> R2 (f x) (f y))"
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     7
  unfolding Respects_def
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     8
  by (simp add: expand_fun_eq)
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     9
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    10
lemma respects_rep_abs:
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    11
  assumes a: "Quotient R1 Abs1 Rep1"
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    12
  and     b: "Respects (R1 ===> R2) f"
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    13
  and     c: "R1 x x"
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    14
  shows "R2 (f (Rep1 (Abs1 x))) (f x)"
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    15
  using a b[simplified respects_thm] c unfolding Quotient_def
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    16
  by blast
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    17
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    18
lemma respects_mp:
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    19
  assumes a: "Respects (R1 ===> R2) f"
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    20
  and     b: "R1 x y"
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    21
  shows "R2 (f x) (f y)"
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    22
  using a b unfolding Respects_def
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    23
  by simp
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    24
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    25
lemma respects_o:
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    26
  assumes a: "Respects (R2 ===> R3) f"
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    27
  and     b: "Respects (R1 ===> R2) g"
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    28
  shows "Respects (R1 ===> R3) (f o g)"
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    29
  using a b unfolding Respects_def
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    30
  by simp
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    31
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    32
lemma fun_rel_eq_rel:
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    33
  assumes q1: "Quotient R1 Abs1 Rep1"
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    34
  and     q2: "Quotient R2 Abs2 Rep2"
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    35
  shows "(R1 ===> R2) f g = ((Respects (R1 ===> R2) f) \<and> (Respects (R1 ===> R2) g)
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    36
                             \<and> ((Rep1 ---> Abs2) f = (Rep1 ---> Abs2) g))"
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    37
  using fun_quotient[OF q1 q2] unfolding Respects_def Quotient_def expand_fun_eq
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    38
  by blast
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    39
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    40
lemma let_babs:
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    41
  "v \<in> r \<Longrightarrow> Let v (Babs r lam) = Let v lam"
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    42
  by (simp add: Babs_def)
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    43
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    44
lemma fun_rel_equals:
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    45
  assumes q1: "Quotient R1 Abs1 Rep1"
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    46
  and     q2: "Quotient R2 Abs2 Rep2"
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    47
  and     r1: "Respects (R1 ===> R2) f"
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    48
  and     r2: "Respects (R1 ===> R2) g"
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    49
  shows "((Rep1 ---> Abs2) f = (Rep1 ---> Abs2) g) = (\<forall>x y. R1 x y \<longrightarrow> R2 (f x) (g y))"
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    50
  apply(rule_tac iffI)
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    51
  apply(rule)+
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    52
  apply (rule apply_rsp'[of "R1" "R2"])
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    53
  apply(subst Quotient_rel[OF fun_quotient[OF q1 q2]])
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    54
  apply auto
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    55
  using fun_quotient[OF q1 q2] r1 r2 unfolding Quotient_def Respects_def
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    56
  apply (metis let_rsp q1)
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    57
  apply (metis fun_rel_eq_rel let_rsp q1 q2 r2)
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    58
  using r1 unfolding Respects_def expand_fun_eq
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    59
  apply(simp (no_asm_use))
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    60
  apply(metis Quotient_rel[OF q2] Quotient_rel_rep[OF q1])
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    61
  done
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    62
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    63
(* ask Peter: fun_rel_IMP used twice *)
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    64
lemma fun_rel_IMP2:
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    65
  assumes q1: "Quotient R1 Abs1 Rep1"
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    66
  and     q2: "Quotient R2 Abs2 Rep2"
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    67
  and     r1: "Respects (R1 ===> R2) f"
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    68
  and     r2: "Respects (R1 ===> R2) g"
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    69
  and     a:  "(Rep1 ---> Abs2) f = (Rep1 ---> Abs2) g"
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    70
  shows "R1 x y \<Longrightarrow> R2 (f x) (g y)"
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    71
  using q1 q2 r1 r2 a
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    72
  by (simp add: fun_rel_equals)
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    73
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    74
lemma lambda_rep_abs_rsp:
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    75
  assumes r1: "\<And>r r'. R1 r r' \<Longrightarrow>R1 r (Rep1 (Abs1 r'))"
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    76
  and     r2: "\<And>r r'. R2 r r' \<Longrightarrow>R2 r (Rep2 (Abs2 r'))"
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    77
  shows "(R1 ===> R2) f1 f2 \<Longrightarrow> (R1 ===> R2) f1 ((Abs1 ---> Rep2) ((Rep1 ---> Abs2) f2))"
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    78
  using r1 r2 by auto
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    79
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    80
(* We use id_simps which includes id_apply; so these 2 theorems can be removed *)
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    81
lemma id_prs:
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    82
  assumes q: "Quotient R Abs Rep"
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    83
  shows "Abs (id (Rep e)) = id e"
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    84
  using Quotient_abs_rep[OF q] by auto
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    85
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    86
lemma id_rsp:
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    87
  assumes q: "Quotient R Abs Rep"
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    88
  and     a: "R e1 e2"
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    89
  shows "R (id e1) (id e2)"
41f89d4f9548 hg-added the added file.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    90
  using a by auto