QuotList.thy
author Cezary Kaliszyk <kaliszyk@in.tum.de>
Fri, 04 Dec 2009 16:12:40 +0100
changeset 539 8287fb5b8d7a
parent 537 57073b0b8fac
child 540 c0b13fb70d6d
permissions -rw-r--r--
Cleaning & Renaming coming from QuotList
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 QuotList
533
4318ab0df27b smaller theory footprint
Christian Urban <urbanc@in.tum.de>
parents: 529
diff changeset
     2
imports QuotScript List
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
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
fun
537
57073b0b8fac Even more name changes and cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 533
diff changeset
     6
  list_rel
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
where
537
57073b0b8fac Even more name changes and cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 533
diff changeset
     8
  "list_rel R [] [] = True"
57073b0b8fac Even more name changes and cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 533
diff changeset
     9
| "list_rel R (x#xs) [] = False"
57073b0b8fac Even more name changes and cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 533
diff changeset
    10
| "list_rel R [] (x#xs) = False"
57073b0b8fac Even more name changes and cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 533
diff changeset
    11
| "list_rel R (x#xs) (y#ys) = (R x y \<and> list_rel R xs ys)"
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
539
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
    13
lemma list_equivp:
529
6348c2a57ec2 More name changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 515
diff changeset
    14
  assumes a: "equivp R"
537
57073b0b8fac Even more name changes and cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 533
diff changeset
    15
  shows "equivp (list_rel R)"
539
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
    16
  unfolding equivp_def
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
    17
  apply(rule allI)+
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
    18
  apply(induct_tac x y rule: list_induct2')
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
    19
  apply(simp_all add: expand_fun_eq)
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
    20
  apply(metis list_rel.simps(1) list_rel.simps(2))
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
    21
  apply(metis list_rel.simps(1) list_rel.simps(2))
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
    22
  apply(rule iffI)
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
    23
  apply(rule allI)
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
    24
  apply(case_tac x)
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
    25
  apply(simp_all)
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
    26
  using a
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
    27
  apply(unfold equivp_def)
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
    28
  apply(auto)[1]
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
    29
  apply(metis list_rel.simps(4))
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
    30
  done
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    31
539
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
    32
lemma list_rel_rel:
529
6348c2a57ec2 More name changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 515
diff changeset
    33
  assumes q: "Quotient R Abs Rep"
537
57073b0b8fac Even more name changes and cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 533
diff changeset
    34
  shows "list_rel R r s = (list_rel R r r \<and> list_rel R s s \<and> (map Abs r = map Abs s))"
539
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
    35
  apply(induct r s rule: list_induct2')
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
    36
  apply(simp_all)
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
    37
  using Quotient_rel[OF q]
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
    38
  apply(metis)
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
    39
  done
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    40
537
57073b0b8fac Even more name changes and cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 533
diff changeset
    41
lemma list_quotient:
529
6348c2a57ec2 More name changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 515
diff changeset
    42
  assumes q: "Quotient R Abs Rep"
537
57073b0b8fac Even more name changes and cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 533
diff changeset
    43
  shows "Quotient (list_rel R) (map Abs) (map Rep)"
539
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
    44
  unfolding Quotient_def
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
    45
  apply(rule conjI)
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
    46
  apply(rule allI)
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
    47
  apply(induct_tac a)
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
    48
  apply(simp)
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
    49
  apply(simp add: Quotient_ABS_REP[OF q])
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
    50
  apply(rule conjI)
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
    51
  apply(rule allI)
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
    52
  apply(induct_tac a)
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
    53
  apply(simp)
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
    54
  apply(simp)
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
    55
  apply(simp add: Quotient_REP_reflp[OF q])
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
    56
  apply(rule allI)+
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
    57
  apply(rule list_rel_rel[OF q])
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
    58
  done
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
    59
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
    60
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
    61
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
    62
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
    63
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
    64
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
    65
(* Rest is not used *)
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
    66
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    67
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    68
lemma CONS_PRS:
529
6348c2a57ec2 More name changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 515
diff changeset
    69
  assumes q: "Quotient R Abs Rep"
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    70
  shows "(h#t) = (map Abs) ((Rep h)#(map Rep t))"
529
6348c2a57ec2 More name changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 515
diff changeset
    71
by (induct t) (simp_all add: Quotient_ABS_REP[OF q])
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    72
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    73
lemma CONS_RSP:
529
6348c2a57ec2 More name changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 515
diff changeset
    74
  assumes q: "Quotient R Abs Rep"
537
57073b0b8fac Even more name changes and cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 533
diff changeset
    75
  and     a: "R h1 h2" "list_rel R t1 t2"
57073b0b8fac Even more name changes and cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 533
diff changeset
    76
  shows "list_rel R (h1#t1) (h2#t2)"
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    77
using a by (auto)
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    78
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    79
lemma NIL_PRS:
529
6348c2a57ec2 More name changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 515
diff changeset
    80
  assumes q: "Quotient R Abs Rep"
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    81
  shows "[] = (map Abs [])"
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    82
by (simp)
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    83
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    84
lemma NIL_RSP:
529
6348c2a57ec2 More name changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 515
diff changeset
    85
  assumes q: "Quotient R Abs Rep"
537
57073b0b8fac Even more name changes and cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 533
diff changeset
    86
  shows "list_rel R [] []"
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    87
by simp
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    88
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    89
lemma MAP_PRS:
529
6348c2a57ec2 More name changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 515
diff changeset
    90
  assumes q1: "Quotient R1 Abs1 Rep1"
6348c2a57ec2 More name changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 515
diff changeset
    91
  and     q2: "Quotient R2 Abs2 Rep2"
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    92
  shows "map f l = (map Abs2) (map ((Abs1 ---> Rep2) f) (map Rep1 l))"
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    93
by (induct l)
529
6348c2a57ec2 More name changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 515
diff changeset
    94
   (simp_all add: Quotient_ABS_REP[OF q1] Quotient_ABS_REP[OF q2])
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    95
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    96
lemma MAP_RSP:
529
6348c2a57ec2 More name changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 515
diff changeset
    97
  assumes q1: "Quotient R1 Abs1 Rep1"
6348c2a57ec2 More name changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 515
diff changeset
    98
  and     q2: "Quotient R2 Abs2 Rep2"
537
57073b0b8fac Even more name changes and cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 533
diff changeset
    99
  and     a: "(R1 ===> R2) f1 f2"
57073b0b8fac Even more name changes and cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 533
diff changeset
   100
  and     b: "list_rel R1 l1 l2"
57073b0b8fac Even more name changes and cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 533
diff changeset
   101
  shows "list_rel R2 (map f1 l1) (map f2 l2)"
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   102
using b a
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   103
by (induct l1 l2 rule: list_induct2')
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   104
   (simp_all)
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
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   107
539
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
   108
lemma LIST_map_id:
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
   109
  shows "map (\<lambda>x. x) = (\<lambda>x. x)"
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
   110
  by simp
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   111
539
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
   112
lemma list_rel_EQ:
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
   113
  shows "list_rel (op =) \<equiv> (op =)"
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
   114
apply(rule eq_reflection)
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
   115
unfolding expand_fun_eq
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
   116
apply(rule allI)+
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
   117
apply(induct_tac x xa rule: list_induct2')
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
   118
apply(simp_all)
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
   119
done
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   120
539
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
   121
lemma list_rel_REFL:
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
   122
  assumes a: "\<And>x y. R x y = (R x = R y)"
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
   123
  shows "list_rel R x x"
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
   124
by (induct x) (auto simp add: a)
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   125
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   126
539
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
   127
end