src/HOL/Library/Quotient_List.thy
author haftmann
Tue, 09 Nov 2010 14:02:12 +0100
changeset 40463 75e544159549
parent 40032 5f78dfb2fa7d
child 40820 fd9c98ead9a9
permissions -rw-r--r--
fun_rel_def is no simp rule by default
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
35788
f1deaca15ca3 observe standard header format;
wenzelm
parents: 35222
diff changeset
     1
(*  Title:      HOL/Library/Quotient_List.thy
35222
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     2
    Author:     Cezary Kaliszyk and Christian Urban
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     3
*)
35788
f1deaca15ca3 observe standard header format;
wenzelm
parents: 35222
diff changeset
     4
f1deaca15ca3 observe standard header format;
wenzelm
parents: 35222
diff changeset
     5
header {* Quotient infrastructure for the list type *}
f1deaca15ca3 observe standard header format;
wenzelm
parents: 35222
diff changeset
     6
35222
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     7
theory Quotient_List
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     8
imports Main Quotient_Syntax
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     9
begin
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    10
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
    11
declare [[map list = (map, list_all2)]]
35222
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    12
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    13
lemma split_list_all:
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    14
  shows "(\<forall>x. P x) \<longleftrightarrow> P [] \<and> (\<forall>x xs. P (x#xs))"
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    15
  apply(auto)
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    16
  apply(case_tac x)
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    17
  apply(simp_all)
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    18
  done
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    19
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    20
lemma map_id[id_simps]:
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    21
  shows "map id = id"
39302
d7728f65b353 renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents: 39198
diff changeset
    22
  apply(simp add: fun_eq_iff)
35222
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    23
  apply(rule allI)
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    24
  apply(induct_tac x)
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    25
  apply(simp_all)
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    26
  done
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    27
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
    28
lemma list_all2_reflp:
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
    29
  shows "equivp R \<Longrightarrow> list_all2 R xs xs"
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
    30
  by (induct xs, simp_all add: equivp_reflp)
35222
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    31
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
    32
lemma list_all2_symp:
35222
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    33
  assumes a: "equivp R"
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
    34
  and b: "list_all2 R xs ys"
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
    35
  shows "list_all2 R ys xs"
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
    36
  using list_all2_lengthD[OF b] b
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
    37
  apply(induct xs ys rule: list_induct2)
35222
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    38
  apply(simp_all)
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    39
  apply(rule equivp_symp[OF a])
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    40
  apply(simp)
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    41
  done
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    42
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
    43
lemma list_all2_transp:
35222
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    44
  assumes a: "equivp R"
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
    45
  and b: "list_all2 R xs1 xs2"
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
    46
  and c: "list_all2 R xs2 xs3"
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
    47
  shows "list_all2 R xs1 xs3"
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
    48
  using list_all2_lengthD[OF b] list_all2_lengthD[OF c] b c
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
    49
  apply(induct rule: list_induct3)
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
    50
  apply(simp_all)
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
    51
  apply(auto intro: equivp_transp[OF a])
35222
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    52
  done
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    53
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    54
lemma list_equivp[quot_equiv]:
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    55
  assumes a: "equivp R"
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
    56
  shows "equivp (list_all2 R)"
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
    57
  apply (intro equivpI)
35222
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    58
  unfolding reflp_def symp_def transp_def
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
    59
  apply(simp add: list_all2_reflp[OF a])
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
    60
  apply(blast intro: list_all2_symp[OF a])
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
    61
  apply(blast intro: list_all2_transp[OF a])
35222
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    62
  done
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    63
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
    64
lemma list_all2_rel:
35222
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    65
  assumes q: "Quotient R Abs Rep"
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
    66
  shows "list_all2 R r s = (list_all2 R r r \<and> list_all2 R s s \<and> (map Abs r = map Abs s))"
35222
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    67
  apply(induct r s rule: list_induct2')
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    68
  apply(simp_all)
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    69
  using Quotient_rel[OF q]
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    70
  apply(metis)
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    71
  done
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    72
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    73
lemma list_quotient[quot_thm]:
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    74
  assumes q: "Quotient R Abs Rep"
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
    75
  shows "Quotient (list_all2 R) (map Abs) (map Rep)"
35222
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    76
  unfolding Quotient_def
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    77
  apply(subst split_list_all)
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    78
  apply(simp add: Quotient_abs_rep[OF q] abs_o_rep[OF q] map_id)
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
    79
  apply(intro conjI allI)
35222
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    80
  apply(induct_tac a)
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
    81
  apply(simp_all add: Quotient_rep_reflp[OF q])
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
    82
  apply(rule list_all2_rel[OF q])
35222
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    83
  done
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    84
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    85
lemma cons_prs[quot_preserve]:
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    86
  assumes q: "Quotient R Abs Rep"
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    87
  shows "(Rep ---> (map Rep) ---> (map Abs)) (op #) = (op #)"
40463
75e544159549 fun_rel_def is no simp rule by default
haftmann
parents: 40032
diff changeset
    88
  by (auto simp add: fun_eq_iff comp_def Quotient_abs_rep [OF q])
35222
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    89
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    90
lemma cons_rsp[quot_respect]:
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    91
  assumes q: "Quotient R Abs Rep"
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
    92
  shows "(R ===> list_all2 R ===> list_all2 R) (op #) (op #)"
40463
75e544159549 fun_rel_def is no simp rule by default
haftmann
parents: 40032
diff changeset
    93
  by auto
35222
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    94
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    95
lemma nil_prs[quot_preserve]:
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    96
  assumes q: "Quotient R Abs Rep"
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    97
  shows "map Abs [] = []"
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    98
  by simp
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    99
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   100
lemma nil_rsp[quot_respect]:
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   101
  assumes q: "Quotient R Abs Rep"
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
   102
  shows "list_all2 R [] []"
35222
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   103
  by simp
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   104
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   105
lemma map_prs_aux:
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   106
  assumes a: "Quotient R1 abs1 rep1"
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   107
  and     b: "Quotient R2 abs2 rep2"
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   108
  shows "(map abs2) (map ((abs1 ---> rep2) f) (map rep1 l)) = map f l"
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   109
  by (induct l)
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   110
     (simp_all add: Quotient_abs_rep[OF a] Quotient_abs_rep[OF b])
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   111
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   112
lemma map_prs[quot_preserve]:
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   113
  assumes a: "Quotient R1 abs1 rep1"
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   114
  and     b: "Quotient R2 abs2 rep2"
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   115
  shows "((abs1 ---> rep2) ---> (map rep1) ---> (map abs2)) map = map"
36216
8fb6cc6f3b94 respectfullness and preservation of map for identity quotients
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36154
diff changeset
   116
  and   "((abs1 ---> id) ---> map rep1 ---> id) map = map"
40463
75e544159549 fun_rel_def is no simp rule by default
haftmann
parents: 40032
diff changeset
   117
  by (simp_all only: fun_eq_iff map_prs_aux[OF a b] comp_def)
75e544159549 fun_rel_def is no simp rule by default
haftmann
parents: 40032
diff changeset
   118
    (simp_all add: Quotient_abs_rep[OF a] Quotient_abs_rep[OF b])
75e544159549 fun_rel_def is no simp rule by default
haftmann
parents: 40032
diff changeset
   119
35222
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   120
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   121
lemma map_rsp[quot_respect]:
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   122
  assumes q1: "Quotient R1 Abs1 Rep1"
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   123
  and     q2: "Quotient R2 Abs2 Rep2"
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
   124
  shows "((R1 ===> R2) ===> (list_all2 R1) ===> list_all2 R2) map map"
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
   125
  and   "((R1 ===> op =) ===> (list_all2 R1) ===> op =) map map"
40463
75e544159549 fun_rel_def is no simp rule by default
haftmann
parents: 40032
diff changeset
   126
  apply (simp_all add: fun_rel_def)
36216
8fb6cc6f3b94 respectfullness and preservation of map for identity quotients
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36154
diff changeset
   127
  apply(rule_tac [!] allI)+
8fb6cc6f3b94 respectfullness and preservation of map for identity quotients
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36154
diff changeset
   128
  apply(rule_tac [!] impI)
8fb6cc6f3b94 respectfullness and preservation of map for identity quotients
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36154
diff changeset
   129
  apply(rule_tac [!] allI)+
8fb6cc6f3b94 respectfullness and preservation of map for identity quotients
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36154
diff changeset
   130
  apply (induct_tac [!] xa ya rule: list_induct2')
35222
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   131
  apply simp_all
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   132
  done
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   133
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   134
lemma foldr_prs_aux:
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   135
  assumes a: "Quotient R1 abs1 rep1"
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   136
  and     b: "Quotient R2 abs2 rep2"
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   137
  shows "abs2 (foldr ((abs1 ---> abs2 ---> rep2) f) (map rep1 l) (rep2 e)) = foldr f l e"
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   138
  by (induct l) (simp_all add: Quotient_abs_rep[OF a] Quotient_abs_rep[OF b])
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   139
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   140
lemma foldr_prs[quot_preserve]:
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   141
  assumes a: "Quotient R1 abs1 rep1"
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   142
  and     b: "Quotient R2 abs2 rep2"
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   143
  shows "((abs1 ---> abs2 ---> rep2) ---> (map rep1) ---> rep2 ---> abs2) foldr = foldr"
40463
75e544159549 fun_rel_def is no simp rule by default
haftmann
parents: 40032
diff changeset
   144
  apply (simp add: fun_eq_iff)
75e544159549 fun_rel_def is no simp rule by default
haftmann
parents: 40032
diff changeset
   145
  by (simp only: fun_eq_iff foldr_prs_aux[OF a b])
35222
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   146
     (simp)
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   147
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   148
lemma foldl_prs_aux:
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   149
  assumes a: "Quotient R1 abs1 rep1"
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   150
  and     b: "Quotient R2 abs2 rep2"
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   151
  shows "abs1 (foldl ((abs1 ---> abs2 ---> rep1) f) (rep1 e) (map rep2 l)) = foldl f e l"
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   152
  by (induct l arbitrary:e) (simp_all add: Quotient_abs_rep[OF a] Quotient_abs_rep[OF b])
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   153
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   154
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   155
lemma foldl_prs[quot_preserve]:
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   156
  assumes a: "Quotient R1 abs1 rep1"
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   157
  and     b: "Quotient R2 abs2 rep2"
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   158
  shows "((abs1 ---> abs2 ---> rep1) ---> rep1 ---> (map rep2) ---> abs1) foldl = foldl"
40463
75e544159549 fun_rel_def is no simp rule by default
haftmann
parents: 40032
diff changeset
   159
  by (simp add: fun_eq_iff foldl_prs_aux [OF a b])
35222
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   160
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
   161
lemma list_all2_empty:
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
   162
  shows "list_all2 R [] b \<Longrightarrow> length b = 0"
35222
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   163
  by (induct b) (simp_all)
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   164
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   165
(* induct_tac doesn't accept 'arbitrary', so we manually 'spec' *)
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   166
lemma foldl_rsp[quot_respect]:
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   167
  assumes q1: "Quotient R1 Abs1 Rep1"
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   168
  and     q2: "Quotient R2 Abs2 Rep2"
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
   169
  shows "((R1 ===> R2 ===> R1) ===> R1 ===> list_all2 R2 ===> R1) foldl foldl"
40463
75e544159549 fun_rel_def is no simp rule by default
haftmann
parents: 40032
diff changeset
   170
  apply(auto simp add: fun_rel_def)
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
   171
  apply (subgoal_tac "R1 xa ya \<longrightarrow> list_all2 R2 xb yb \<longrightarrow> R1 (foldl x xa xb) (foldl y ya yb)")
35222
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   172
  apply simp
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   173
  apply (rule_tac x="xa" in spec)
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   174
  apply (rule_tac x="ya" in spec)
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   175
  apply (rule_tac xs="xb" and ys="yb" in list_induct2)
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
   176
  apply (rule list_all2_lengthD)
35222
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   177
  apply (simp_all)
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   178
  done
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   179
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   180
lemma foldr_rsp[quot_respect]:
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   181
  assumes q1: "Quotient R1 Abs1 Rep1"
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   182
  and     q2: "Quotient R2 Abs2 Rep2"
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
   183
  shows "((R1 ===> R2 ===> R2) ===> list_all2 R1 ===> R2 ===> R2) foldr foldr"
40463
75e544159549 fun_rel_def is no simp rule by default
haftmann
parents: 40032
diff changeset
   184
  apply (auto simp add: fun_rel_def)
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
   185
  apply(subgoal_tac "R2 xb yb \<longrightarrow> list_all2 R1 xa ya \<longrightarrow> R2 (foldr x xa xb) (foldr y ya yb)")
35222
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   186
  apply simp
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   187
  apply (rule_tac xs="xa" and ys="ya" in list_induct2)
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
   188
  apply (rule list_all2_lengthD)
35222
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   189
  apply (simp_all)
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   190
  done
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   191
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
   192
lemma list_all2_rsp:
36154
11c6106d7787 Respectfullness and preservation of list_rel
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 35788
diff changeset
   193
  assumes r: "\<forall>x y. R x y \<longrightarrow> (\<forall>a b. R a b \<longrightarrow> S x a = T y b)"
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
   194
  and l1: "list_all2 R x y"
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
   195
  and l2: "list_all2 R a b"
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
   196
  shows "list_all2 S x a = list_all2 T y b"
36154
11c6106d7787 Respectfullness and preservation of list_rel
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 35788
diff changeset
   197
  proof -
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
   198
    have a: "length y = length x" by (rule list_all2_lengthD[OF l1, symmetric])
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
   199
    have c: "length a = length b" by (rule list_all2_lengthD[OF l2])
36154
11c6106d7787 Respectfullness and preservation of list_rel
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 35788
diff changeset
   200
    show ?thesis proof (cases "length x = length a")
11c6106d7787 Respectfullness and preservation of list_rel
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 35788
diff changeset
   201
      case True
11c6106d7787 Respectfullness and preservation of list_rel
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 35788
diff changeset
   202
      have b: "length x = length a" by fact
11c6106d7787 Respectfullness and preservation of list_rel
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 35788
diff changeset
   203
      show ?thesis using a b c r l1 l2 proof (induct rule: list_induct4)
11c6106d7787 Respectfullness and preservation of list_rel
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 35788
diff changeset
   204
        case Nil
11c6106d7787 Respectfullness and preservation of list_rel
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 35788
diff changeset
   205
        show ?case using assms by simp
11c6106d7787 Respectfullness and preservation of list_rel
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 35788
diff changeset
   206
      next
11c6106d7787 Respectfullness and preservation of list_rel
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 35788
diff changeset
   207
        case (Cons h t)
11c6106d7787 Respectfullness and preservation of list_rel
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 35788
diff changeset
   208
        then show ?case by auto
11c6106d7787 Respectfullness and preservation of list_rel
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 35788
diff changeset
   209
      qed
11c6106d7787 Respectfullness and preservation of list_rel
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 35788
diff changeset
   210
    next
11c6106d7787 Respectfullness and preservation of list_rel
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 35788
diff changeset
   211
      case False
11c6106d7787 Respectfullness and preservation of list_rel
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 35788
diff changeset
   212
      have d: "length x \<noteq> length a" by fact
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
   213
      then have e: "\<not>list_all2 S x a" using list_all2_lengthD by auto
36154
11c6106d7787 Respectfullness and preservation of list_rel
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 35788
diff changeset
   214
      have "length y \<noteq> length b" using d a c by simp
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
   215
      then have "\<not>list_all2 T y b" using list_all2_lengthD by auto
36154
11c6106d7787 Respectfullness and preservation of list_rel
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 35788
diff changeset
   216
      then show ?thesis using e by simp
11c6106d7787 Respectfullness and preservation of list_rel
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 35788
diff changeset
   217
    qed
11c6106d7787 Respectfullness and preservation of list_rel
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 35788
diff changeset
   218
  qed
11c6106d7787 Respectfullness and preservation of list_rel
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 35788
diff changeset
   219
11c6106d7787 Respectfullness and preservation of list_rel
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 35788
diff changeset
   220
lemma[quot_respect]:
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
   221
  "((R ===> R ===> op =) ===> list_all2 R ===> list_all2 R ===> op =) list_all2 list_all2"
40463
75e544159549 fun_rel_def is no simp rule by default
haftmann
parents: 40032
diff changeset
   222
  by (simp add: list_all2_rsp fun_rel_def)
36154
11c6106d7787 Respectfullness and preservation of list_rel
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 35788
diff changeset
   223
11c6106d7787 Respectfullness and preservation of list_rel
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 35788
diff changeset
   224
lemma[quot_preserve]:
11c6106d7787 Respectfullness and preservation of list_rel
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 35788
diff changeset
   225
  assumes a: "Quotient R abs1 rep1"
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
   226
  shows "((abs1 ---> abs1 ---> id) ---> map rep1 ---> map rep1 ---> id) list_all2 = list_all2"
39302
d7728f65b353 renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents: 39198
diff changeset
   227
  apply (simp add: fun_eq_iff)
36154
11c6106d7787 Respectfullness and preservation of list_rel
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 35788
diff changeset
   228
  apply clarify
11c6106d7787 Respectfullness and preservation of list_rel
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 35788
diff changeset
   229
  apply (induct_tac xa xb rule: list_induct2')
11c6106d7787 Respectfullness and preservation of list_rel
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 35788
diff changeset
   230
  apply (simp_all add: Quotient_abs_rep[OF a])
11c6106d7787 Respectfullness and preservation of list_rel
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 35788
diff changeset
   231
  done
11c6106d7787 Respectfullness and preservation of list_rel
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 35788
diff changeset
   232
11c6106d7787 Respectfullness and preservation of list_rel
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 35788
diff changeset
   233
lemma[quot_preserve]:
11c6106d7787 Respectfullness and preservation of list_rel
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 35788
diff changeset
   234
  assumes a: "Quotient R abs1 rep1"
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
   235
  shows "(list_all2 ((rep1 ---> rep1 ---> id) R) l m) = (l = m)"
36154
11c6106d7787 Respectfullness and preservation of list_rel
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 35788
diff changeset
   236
  by (induct l m rule: list_induct2') (simp_all add: Quotient_rel_rep[OF a])
11c6106d7787 Respectfullness and preservation of list_rel
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 35788
diff changeset
   237
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
   238
lemma list_all2_eq[id_simps]:
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
   239
  shows "(list_all2 (op =)) = (op =)"
39302
d7728f65b353 renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents: 39198
diff changeset
   240
  unfolding fun_eq_iff
35222
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   241
  apply(rule allI)+
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   242
  apply(induct_tac x xa rule: list_induct2')
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   243
  apply(simp_all)
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   244
  done
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   245
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
   246
lemma list_all2_find_element:
36276
92011cc923f5 fun_rel introduction and list_rel elimination for quotient package
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36216
diff changeset
   247
  assumes a: "x \<in> set a"
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
   248
  and b: "list_all2 R a b"
36276
92011cc923f5 fun_rel introduction and list_rel elimination for quotient package
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36216
diff changeset
   249
  shows "\<exists>y. (y \<in> set b \<and> R x y)"
92011cc923f5 fun_rel introduction and list_rel elimination for quotient package
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36216
diff changeset
   250
proof -
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
   251
  have "length a = length b" using b by (rule list_all2_lengthD)
36276
92011cc923f5 fun_rel introduction and list_rel elimination for quotient package
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36216
diff changeset
   252
  then show ?thesis using a b by (induct a b rule: list_induct2) auto
92011cc923f5 fun_rel introduction and list_rel elimination for quotient package
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36216
diff changeset
   253
qed
92011cc923f5 fun_rel introduction and list_rel elimination for quotient package
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36216
diff changeset
   254
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
   255
lemma list_all2_refl:
35222
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   256
  assumes a: "\<And>x y. R x y = (R x = R y)"
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36812
diff changeset
   257
  shows "list_all2 R x x"
35222
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   258
  by (induct x) (auto simp add: a)
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   259
4f1fba00f66d Initial version of HOL quotient package.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   260
end