QuotList.thy
author Christian Urban <urbanc@in.tum.de>
Mon, 07 Dec 2009 02:34:24 +0100
changeset 590 951681538e3f
parent 566 4eca2c3e59f7
permissions -rw-r--r--
simplified the regularize simproc
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)
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
    49
  apply(simp add: Quotient_abs_rep[OF q])
539
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)
541
94deffed619d more name cleaning and removing
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 540
diff changeset
    55
  apply(simp add: Quotient_rep_reflp[OF q])
539
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
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
    61
lemma cons_prs:
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
    62
  assumes q: "Quotient R Abs Rep"
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
    63
  shows "(map Abs) ((Rep h) # (map Rep t)) = h # t"
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
    64
by (induct t) (simp_all add: Quotient_abs_rep[OF q])
539
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
    65
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
    66
lemma cons_rsp:
529
6348c2a57ec2 More name changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 515
diff changeset
    67
  assumes q: "Quotient R Abs Rep"
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
    68
  shows "(R ===> list_rel R ===> list_rel R) op # op #"
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
    69
by (auto)
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    70
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
    71
lemma nil_prs:
529
6348c2a57ec2 More name changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 515
diff changeset
    72
  assumes q: "Quotient R Abs Rep"
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
    73
  shows "map Abs [] \<equiv> []"
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    74
by (simp)
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    75
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
    76
lemma nil_rsp:
529
6348c2a57ec2 More name changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 515
diff changeset
    77
  assumes q: "Quotient R Abs Rep"
537
57073b0b8fac Even more name changes and cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 533
diff changeset
    78
  shows "list_rel R [] []"
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    79
by simp
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    80
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
    81
lemma map_prs:
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
    82
  assumes a: "Quotient R1 abs1 rep1"
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
    83
  and     b: "Quotient R2 abs2 rep2"
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
    84
  shows "(map abs2) (map ((abs1 ---> rep2) f) (map rep1 l)) = map f l"
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
    85
by (induct l) (simp_all add: Quotient_abs_rep[OF a] Quotient_abs_rep[OF b])
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    86
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
    87
lemma map_rsp:
529
6348c2a57ec2 More name changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 515
diff changeset
    88
  assumes q1: "Quotient R1 Abs1 Rep1"
6348c2a57ec2 More name changes
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 515
diff changeset
    89
  and     q2: "Quotient R2 Abs2 Rep2"
565
baff284c6fcc Proved foldl_rsp and ho_map_rsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
    90
  shows "((R1 ===> R2) ===> (list_rel R1) ===> list_rel R2) map map"
baff284c6fcc Proved foldl_rsp and ho_map_rsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
    91
apply(simp)
baff284c6fcc Proved foldl_rsp and ho_map_rsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
    92
apply(rule allI)+
baff284c6fcc Proved foldl_rsp and ho_map_rsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
    93
apply(rule impI)
baff284c6fcc Proved foldl_rsp and ho_map_rsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
    94
apply(rule allI)+
baff284c6fcc Proved foldl_rsp and ho_map_rsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
    95
apply (induct_tac xa ya rule: list_induct2')
baff284c6fcc Proved foldl_rsp and ho_map_rsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
    96
apply simp_all
baff284c6fcc Proved foldl_rsp and ho_map_rsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
    97
done
baff284c6fcc Proved foldl_rsp and ho_map_rsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
    98
baff284c6fcc Proved foldl_rsp and ho_map_rsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
    99
(* TODO: if the above is correct, we can remove this one *)
baff284c6fcc Proved foldl_rsp and ho_map_rsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   100
lemma map_rsp_lo:
baff284c6fcc Proved foldl_rsp and ho_map_rsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   101
  assumes q1: "Quotient R1 Abs1 Rep1"
baff284c6fcc Proved foldl_rsp and ho_map_rsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   102
  and     q2: "Quotient R2 Abs2 Rep2"
537
57073b0b8fac Even more name changes and cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 533
diff changeset
   103
  and     a: "(R1 ===> R2) f1 f2"
57073b0b8fac Even more name changes and cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 533
diff changeset
   104
  and     b: "list_rel R1 l1 l2"
57073b0b8fac Even more name changes and cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 533
diff changeset
   105
  shows "list_rel R2 (map f1 l1) (map f2 l2)"
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   106
using b a
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
   107
by (induct l1 l2 rule: list_induct2') (simp_all)
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
   108
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
   109
lemma foldr_prs:
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
   110
  assumes a: "Quotient R1 abs1 rep1"
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
   111
  and     b: "Quotient R2 abs2 rep2"
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
   112
  shows "abs2 (foldr ((abs1 ---> abs2 ---> rep2) f) (map rep1 l) (rep2 e)) = foldr f l e"
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
   113
by (induct l) (simp_all add: Quotient_abs_rep[OF a] Quotient_abs_rep[OF b])
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
   114
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
   115
lemma foldl_prs:
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
   116
  assumes a: "Quotient R1 abs1 rep1"
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
   117
  and     b: "Quotient R2 abs2 rep2"
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
   118
  shows "abs1 (foldl ((abs1 ---> abs2 ---> rep1) f) (rep1 e) (map rep2 l)) = foldl f e l"
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
   119
by (induct l arbitrary:e) (simp_all add: Quotient_abs_rep[OF a] Quotient_abs_rep[OF b])
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   120
565
baff284c6fcc Proved foldl_rsp and ho_map_rsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   121
lemma list_rel_empty: "list_rel R [] b \<Longrightarrow> length b = 0"
baff284c6fcc Proved foldl_rsp and ho_map_rsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   122
by (induct b) (simp_all)
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   123
565
baff284c6fcc Proved foldl_rsp and ho_map_rsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   124
lemma list_rel_len: "list_rel R a b \<Longrightarrow> length a = length b"
baff284c6fcc Proved foldl_rsp and ho_map_rsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   125
apply (induct a arbitrary: b)
baff284c6fcc Proved foldl_rsp and ho_map_rsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   126
apply (simp add: list_rel_empty)
baff284c6fcc Proved foldl_rsp and ho_map_rsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   127
apply (case_tac b)
baff284c6fcc Proved foldl_rsp and ho_map_rsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   128
apply simp_all
baff284c6fcc Proved foldl_rsp and ho_map_rsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   129
done
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   130
565
baff284c6fcc Proved foldl_rsp and ho_map_rsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   131
(* TODO: induct_tac doesn't accept 'arbitrary'.
baff284c6fcc Proved foldl_rsp and ho_map_rsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   132
         induct     doesn't accept 'rule'.
baff284c6fcc Proved foldl_rsp and ho_map_rsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   133
   that's why the proof uses manual generalisation and needs assumptions
baff284c6fcc Proved foldl_rsp and ho_map_rsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   134
   both in conclusion for induction and in assumptions. *)
566
4eca2c3e59f7 Used symmetric definitions. Moved quotient_rsp to QuotMain.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 565
diff changeset
   135
lemma foldl_rsp:
565
baff284c6fcc Proved foldl_rsp and ho_map_rsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   136
  assumes q1: "Quotient R1 Abs1 Rep1"
baff284c6fcc Proved foldl_rsp and ho_map_rsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   137
  and     q2: "Quotient R2 Abs2 Rep2"
baff284c6fcc Proved foldl_rsp and ho_map_rsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   138
  shows "((R1 ===> R2 ===> R1) ===> R1 ===> list_rel R2 ===> R1) foldl foldl"
baff284c6fcc Proved foldl_rsp and ho_map_rsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   139
apply auto
baff284c6fcc Proved foldl_rsp and ho_map_rsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   140
apply (subgoal_tac "R1 xa ya \<longrightarrow> list_rel R2 xb yb \<longrightarrow> R1 (foldl x xa xb) (foldl y ya yb)")
baff284c6fcc Proved foldl_rsp and ho_map_rsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   141
apply simp
baff284c6fcc Proved foldl_rsp and ho_map_rsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   142
apply (rule_tac x="xa" in spec)
baff284c6fcc Proved foldl_rsp and ho_map_rsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   143
apply (rule_tac x="ya" in spec)
baff284c6fcc Proved foldl_rsp and ho_map_rsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   144
apply (rule_tac xs="xb" and ys="yb" in list_induct2)
baff284c6fcc Proved foldl_rsp and ho_map_rsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   145
apply (rule list_rel_len)
baff284c6fcc Proved foldl_rsp and ho_map_rsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   146
apply (simp_all)
baff284c6fcc Proved foldl_rsp and ho_map_rsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   147
done
baff284c6fcc Proved foldl_rsp and ho_map_rsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   148
baff284c6fcc Proved foldl_rsp and ho_map_rsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 541
diff changeset
   149
(* TODO: foldr_rsp should be similar *)
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
   150
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
   151
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
   152
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
   153
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
   154
(* TODO: Rest are unused *)
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
   155
541
94deffed619d more name cleaning and removing
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 540
diff changeset
   156
lemma list_map_id:
539
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
   157
  shows "map (\<lambda>x. x) = (\<lambda>x. x)"
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
   158
  by simp
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   159
541
94deffed619d more name cleaning and removing
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 540
diff changeset
   160
lemma list_rel_eq:
539
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
   161
  shows "list_rel (op =) \<equiv> (op =)"
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
   162
apply(rule eq_reflection)
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
   163
unfolding expand_fun_eq
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
   164
apply(rule allI)+
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
   165
apply(induct_tac x xa rule: list_induct2')
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
   166
apply(simp_all)
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
   167
done
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   168
541
94deffed619d more name cleaning and removing
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 540
diff changeset
   169
lemma list_rel_refl:
539
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
   170
  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
   171
  shows "list_rel R x x"
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
   172
by (induct x) (auto simp add: a)
0
ebe0ea8fe247 initial commit
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   173
539
8287fb5b8d7a Cleaning & Renaming coming from QuotList
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 537
diff changeset
   174
end