src/HOL/Quotient_Examples/FSet.thy
author haftmann
Tue, 30 Nov 2010 17:19:11 +0100
changeset 40822 98a5faa5aec0
parent 40688 a961ec75fc29
child 40952 580b1a30994c
permissions -rw-r--r--
adaptions to changes in Equiv_Relation.thy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36524
3909002beca5 Tuning the quotient examples
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36465
diff changeset
     1
(*  Title:      HOL/Quotient_Examples/FSet.thy
36465
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
     2
    Author:     Cezary Kaliszyk, TU Munich
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
     3
    Author:     Christian Urban, TU Munich
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     4
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
     5
    Type of finite sets.
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     6
*)
36465
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
     7
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     8
theory FSet
36465
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
     9
imports Quotient_List
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    10
begin
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    11
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
    12
text {* 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
    13
  The type of finite sets is created by a quotient construction
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
    14
  over lists. The definition of the equivalence:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
    15
*}
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    16
40467
dc0439fdd7c5 more appropriate specification packages; fun_rel_def is no simp rule by default
haftmann
parents: 40034
diff changeset
    17
definition
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    18
  list_eq :: "'a list \<Rightarrow> 'a list \<Rightarrow> bool" (infix "\<approx>" 50)
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    19
where
40467
dc0439fdd7c5 more appropriate specification packages; fun_rel_def is no simp rule by default
haftmann
parents: 40034
diff changeset
    20
  [simp]: "list_eq xs ys \<longleftrightarrow> set xs = set ys"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    21
40822
98a5faa5aec0 adaptions to changes in Equiv_Relation.thy
haftmann
parents: 40688
diff changeset
    22
lemma list_eq_reflp:
98a5faa5aec0 adaptions to changes in Equiv_Relation.thy
haftmann
parents: 40688
diff changeset
    23
  "reflp list_eq"
98a5faa5aec0 adaptions to changes in Equiv_Relation.thy
haftmann
parents: 40688
diff changeset
    24
  by (auto intro: reflpI)
98a5faa5aec0 adaptions to changes in Equiv_Relation.thy
haftmann
parents: 40688
diff changeset
    25
98a5faa5aec0 adaptions to changes in Equiv_Relation.thy
haftmann
parents: 40688
diff changeset
    26
lemma list_eq_symp:
98a5faa5aec0 adaptions to changes in Equiv_Relation.thy
haftmann
parents: 40688
diff changeset
    27
  "symp list_eq"
98a5faa5aec0 adaptions to changes in Equiv_Relation.thy
haftmann
parents: 40688
diff changeset
    28
  by (auto intro: sympI)
98a5faa5aec0 adaptions to changes in Equiv_Relation.thy
haftmann
parents: 40688
diff changeset
    29
98a5faa5aec0 adaptions to changes in Equiv_Relation.thy
haftmann
parents: 40688
diff changeset
    30
lemma list_eq_transp:
98a5faa5aec0 adaptions to changes in Equiv_Relation.thy
haftmann
parents: 40688
diff changeset
    31
  "transp list_eq"
98a5faa5aec0 adaptions to changes in Equiv_Relation.thy
haftmann
parents: 40688
diff changeset
    32
  by (auto intro: transpI)
98a5faa5aec0 adaptions to changes in Equiv_Relation.thy
haftmann
parents: 40688
diff changeset
    33
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    34
lemma list_eq_equivp:
40822
98a5faa5aec0 adaptions to changes in Equiv_Relation.thy
haftmann
parents: 40688
diff changeset
    35
  "equivp list_eq"
98a5faa5aec0 adaptions to changes in Equiv_Relation.thy
haftmann
parents: 40688
diff changeset
    36
  by (auto intro: equivpI list_eq_reflp list_eq_symp list_eq_transp)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    37
40688
a961ec75fc29 corrected abd4e7358847 where SOMEthing went utterly wrong
haftmann
parents: 40672
diff changeset
    38
text {* The @{text fset} type *}
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
    39
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    40
quotient_type
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    41
  'a fset = "'a list" / "list_eq"
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    42
  by (rule list_eq_equivp)
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    43
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
    44
text {* 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
    45
  Definitions for membership, sublist, cardinality, 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
    46
  intersection, difference and respectful fold over 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
    47
  lists.
39994
7bd8013b903f FSet: give names to respectfulness theorems, rename list_all2_refl to avoid clash
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 39302
diff changeset
    48
*}
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    49
40034
Christian Urban <urbanc@in.tum.de>
parents: 40030
diff changeset
    50
definition
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    51
  memb :: "'a \<Rightarrow> 'a list \<Rightarrow> bool"
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    52
where
40034
Christian Urban <urbanc@in.tum.de>
parents: 40030
diff changeset
    53
  [simp]: "memb x xs \<longleftrightarrow> x \<in> set xs"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    54
40034
Christian Urban <urbanc@in.tum.de>
parents: 40030
diff changeset
    55
definition
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    56
  sub_list :: "'a list \<Rightarrow> 'a list \<Rightarrow> bool"
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
    57
where 
40034
Christian Urban <urbanc@in.tum.de>
parents: 40030
diff changeset
    58
  [simp]: "sub_list xs ys \<longleftrightarrow> set xs \<subseteq> set ys"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    59
40034
Christian Urban <urbanc@in.tum.de>
parents: 40030
diff changeset
    60
definition
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
    61
  card_list :: "'a list \<Rightarrow> nat"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    62
where
40034
Christian Urban <urbanc@in.tum.de>
parents: 40030
diff changeset
    63
  [simp]: "card_list xs = card (set xs)"
36675
806ea6e282e4 fminus and some more theorems ported from Finite_Set.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36646
diff changeset
    64
40034
Christian Urban <urbanc@in.tum.de>
parents: 40030
diff changeset
    65
definition
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
    66
  inter_list :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a list"
36675
806ea6e282e4 fminus and some more theorems ported from Finite_Set.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36646
diff changeset
    67
where
40034
Christian Urban <urbanc@in.tum.de>
parents: 40030
diff changeset
    68
  [simp]: "inter_list xs ys = [x \<leftarrow> xs. x \<in> set xs \<and> x \<in> set ys]"
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
    69
40034
Christian Urban <urbanc@in.tum.de>
parents: 40030
diff changeset
    70
definition
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
    71
  diff_list :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a list"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
    72
where
40034
Christian Urban <urbanc@in.tum.de>
parents: 40030
diff changeset
    73
  [simp]: "diff_list xs ys = [x \<leftarrow> xs. x \<notin> set ys]"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    74
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    75
definition
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    76
  rsp_fold
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    77
where
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
    78
  "rsp_fold f \<equiv> \<forall>u v w. (f u (f v w) = f v (f u w))"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    79
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    80
primrec
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
    81
  fold_list :: "('a \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> 'b \<Rightarrow> 'a list \<Rightarrow> 'b"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    82
where
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
    83
  "fold_list f z [] = z"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
    84
| "fold_list f z (a # xs) =
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    85
     (if (rsp_fold f) then
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
    86
       if a \<in> set xs then fold_list f z xs
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
    87
       else f a (fold_list f z xs)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    88
     else z)"
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    89
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
    90
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
    91
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
    92
section {* Quotient composition lemmas *}
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    93
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
    94
lemma list_all2_refl':
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
    95
  assumes q: "equivp R"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
    96
  shows "(list_all2 R) r r"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
    97
  by (rule list_all2_refl) (metis equivp_def q)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    98
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    99
lemma compose_list_refl:
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   100
  assumes q: "equivp R"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   101
  shows "(list_all2 R OOO op \<approx>) r r"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   102
proof
36465
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
   103
  have *: "r \<approx> r" by (rule equivp_reflp[OF fset_equivp])
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   104
  show "list_all2 R r r" by (rule list_all2_refl'[OF q])
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   105
  with * show "(op \<approx> OO list_all2 R) r r" ..
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   106
qed
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   107
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   108
lemma map_list_eq_cong: "b \<approx> ba \<Longrightarrow> map f b \<approx> map f ba"
40467
dc0439fdd7c5 more appropriate specification packages; fun_rel_def is no simp rule by default
haftmann
parents: 40034
diff changeset
   109
  by (simp only: list_eq_def set_map)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   110
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   111
lemma quotient_compose_list_g:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   112
  assumes q: "Quotient R Abs Rep"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   113
  and     e: "equivp R"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   114
  shows  "Quotient ((list_all2 R) OOO (op \<approx>))
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   115
    (abs_fset \<circ> (map Abs)) ((map Rep) \<circ> rep_fset)"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   116
  unfolding Quotient_def comp_def
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   117
proof (intro conjI allI)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   118
  fix a r s
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   119
  show "abs_fset (map Abs (map Rep (rep_fset a))) = a"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   120
    by (simp add: abs_o_rep[OF q] Quotient_abs_rep[OF Quotient_fset] map_id)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   121
  have b: "list_all2 R (map Rep (rep_fset a)) (map Rep (rep_fset a))"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   122
    by (rule list_all2_refl'[OF e])
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   123
  have c: "(op \<approx> OO list_all2 R) (map Rep (rep_fset a)) (map Rep (rep_fset a))"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   124
    by (rule, rule equivp_reflp[OF fset_equivp]) (rule b)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   125
  show "(list_all2 R OOO op \<approx>) (map Rep (rep_fset a)) (map Rep (rep_fset a))"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   126
    by (rule, rule list_all2_refl'[OF e]) (rule c)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   127
  show "(list_all2 R OOO op \<approx>) r s = ((list_all2 R OOO op \<approx>) r r \<and>
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   128
        (list_all2 R OOO op \<approx>) s s \<and> abs_fset (map Abs r) = abs_fset (map Abs s))"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   129
  proof (intro iffI conjI)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   130
    show "(list_all2 R OOO op \<approx>) r r" by (rule compose_list_refl[OF e])
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   131
    show "(list_all2 R OOO op \<approx>) s s" by (rule compose_list_refl[OF e])
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   132
  next
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   133
    assume a: "(list_all2 R OOO op \<approx>) r s"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   134
    then have b: "map Abs r \<approx> map Abs s"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   135
    proof (elim pred_compE)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   136
      fix b ba
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   137
      assume c: "list_all2 R r b"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   138
      assume d: "b \<approx> ba"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   139
      assume e: "list_all2 R ba s"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   140
      have f: "map Abs r = map Abs b"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   141
        using Quotient_rel[OF list_quotient[OF q]] c by blast
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   142
      have "map Abs ba = map Abs s"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   143
        using Quotient_rel[OF list_quotient[OF q]] e by blast
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   144
      then have g: "map Abs s = map Abs ba" by simp
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   145
      then show "map Abs r \<approx> map Abs s" using d f map_list_eq_cong by simp
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   146
    qed
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   147
    then show "abs_fset (map Abs r) = abs_fset (map Abs s)"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   148
      using Quotient_rel[OF Quotient_fset] by blast
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   149
  next
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   150
    assume a: "(list_all2 R OOO op \<approx>) r r \<and> (list_all2 R OOO op \<approx>) s s
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   151
      \<and> abs_fset (map Abs r) = abs_fset (map Abs s)"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   152
    then have s: "(list_all2 R OOO op \<approx>) s s" by simp
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   153
    have d: "map Abs r \<approx> map Abs s"
40822
98a5faa5aec0 adaptions to changes in Equiv_Relation.thy
haftmann
parents: 40688
diff changeset
   154
      by (subst Quotient_rel [OF Quotient_fset, symmetric]) (simp add: a)
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   155
    have b: "map Rep (map Abs r) \<approx> map Rep (map Abs s)"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   156
      by (rule map_list_eq_cong[OF d])
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   157
    have y: "list_all2 R (map Rep (map Abs s)) s"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   158
      by (fact rep_abs_rsp_left[OF list_quotient[OF q], OF list_all2_refl'[OF e, of s]])
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   159
    have c: "(op \<approx> OO list_all2 R) (map Rep (map Abs r)) s"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   160
      by (rule pred_compI) (rule b, rule y)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   161
    have z: "list_all2 R r (map Rep (map Abs r))"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   162
      by (fact rep_abs_rsp[OF list_quotient[OF q], OF list_all2_refl'[OF e, of r]])
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   163
    then show "(list_all2 R OOO op \<approx>) r s"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   164
      using a c pred_compI by simp
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   165
  qed
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   166
qed
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   167
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   168
lemma quotient_compose_list[quot_thm]:
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36675
diff changeset
   169
  shows  "Quotient ((list_all2 op \<approx>) OOO (op \<approx>))
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   170
    (abs_fset \<circ> (map abs_fset)) ((map rep_fset) \<circ> rep_fset)"
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   171
  by (rule quotient_compose_list_g, rule Quotient_fset, rule list_eq_equivp)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   172
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   173
39996
c02078ff8691 FSet: definition changes propagated from Nominal and more use of 'descending' tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 39995
diff changeset
   174
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   175
subsection {* Respectfulness lemmas for list operations *}
39996
c02078ff8691 FSet: definition changes propagated from Nominal and more use of 'descending' tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 39995
diff changeset
   176
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   177
lemma list_equiv_rsp [quot_respect]:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   178
  shows "(op \<approx> ===> op \<approx> ===> op =) op \<approx> op \<approx>"
40467
dc0439fdd7c5 more appropriate specification packages; fun_rel_def is no simp rule by default
haftmann
parents: 40034
diff changeset
   179
  by (auto intro!: fun_relI)
39996
c02078ff8691 FSet: definition changes propagated from Nominal and more use of 'descending' tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 39995
diff changeset
   180
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   181
lemma append_rsp [quot_respect]:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   182
  shows "(op \<approx> ===> op \<approx> ===> op \<approx>) append append"
40467
dc0439fdd7c5 more appropriate specification packages; fun_rel_def is no simp rule by default
haftmann
parents: 40034
diff changeset
   183
  by (auto intro!: fun_relI)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   184
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   185
lemma sub_list_rsp [quot_respect]:
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   186
  shows "(op \<approx> ===> op \<approx> ===> op =) sub_list sub_list"
40467
dc0439fdd7c5 more appropriate specification packages; fun_rel_def is no simp rule by default
haftmann
parents: 40034
diff changeset
   187
  by (auto intro!: fun_relI)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   188
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   189
lemma memb_rsp [quot_respect]:
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   190
  shows "(op = ===> op \<approx> ===> op =) memb memb"
40467
dc0439fdd7c5 more appropriate specification packages; fun_rel_def is no simp rule by default
haftmann
parents: 40034
diff changeset
   191
  by (auto intro!: fun_relI)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   192
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   193
lemma nil_rsp [quot_respect]:
39994
7bd8013b903f FSet: give names to respectfulness theorems, rename list_all2_refl to avoid clash
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 39302
diff changeset
   194
  shows "(op \<approx>) Nil Nil"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   195
  by simp
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   196
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   197
lemma cons_rsp [quot_respect]:
39994
7bd8013b903f FSet: give names to respectfulness theorems, rename list_all2_refl to avoid clash
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 39302
diff changeset
   198
  shows "(op = ===> op \<approx> ===> op \<approx>) Cons Cons"
40467
dc0439fdd7c5 more appropriate specification packages; fun_rel_def is no simp rule by default
haftmann
parents: 40034
diff changeset
   199
  by (auto intro!: fun_relI)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   200
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   201
lemma map_rsp [quot_respect]:
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   202
  shows "(op = ===> op \<approx> ===> op \<approx>) map map"
40467
dc0439fdd7c5 more appropriate specification packages; fun_rel_def is no simp rule by default
haftmann
parents: 40034
diff changeset
   203
  by (auto intro!: fun_relI)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   204
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   205
lemma set_rsp [quot_respect]:
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   206
  "(op \<approx> ===> op =) set set"
40467
dc0439fdd7c5 more appropriate specification packages; fun_rel_def is no simp rule by default
haftmann
parents: 40034
diff changeset
   207
  by (auto intro!: fun_relI)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   208
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   209
lemma inter_list_rsp [quot_respect]:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   210
  shows "(op \<approx> ===> op \<approx> ===> op \<approx>) inter_list inter_list"
40467
dc0439fdd7c5 more appropriate specification packages; fun_rel_def is no simp rule by default
haftmann
parents: 40034
diff changeset
   211
  by (auto intro!: fun_relI)
39996
c02078ff8691 FSet: definition changes propagated from Nominal and more use of 'descending' tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 39995
diff changeset
   212
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   213
lemma removeAll_rsp [quot_respect]:
39996
c02078ff8691 FSet: definition changes propagated from Nominal and more use of 'descending' tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 39995
diff changeset
   214
  shows "(op = ===> op \<approx> ===> op \<approx>) removeAll removeAll"
40467
dc0439fdd7c5 more appropriate specification packages; fun_rel_def is no simp rule by default
haftmann
parents: 40034
diff changeset
   215
  by (auto intro!: fun_relI)
39996
c02078ff8691 FSet: definition changes propagated from Nominal and more use of 'descending' tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 39995
diff changeset
   216
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   217
lemma diff_list_rsp [quot_respect]:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   218
  shows "(op \<approx> ===> op \<approx> ===> op \<approx>) diff_list diff_list"
40467
dc0439fdd7c5 more appropriate specification packages; fun_rel_def is no simp rule by default
haftmann
parents: 40034
diff changeset
   219
  by (auto intro!: fun_relI)
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   220
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   221
lemma card_list_rsp [quot_respect]:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   222
  shows "(op \<approx> ===> op =) card_list card_list"
40467
dc0439fdd7c5 more appropriate specification packages; fun_rel_def is no simp rule by default
haftmann
parents: 40034
diff changeset
   223
  by (auto intro!: fun_relI)
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   224
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   225
lemma filter_rsp [quot_respect]:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   226
  shows "(op = ===> op \<approx> ===> op \<approx>) filter filter"
40467
dc0439fdd7c5 more appropriate specification packages; fun_rel_def is no simp rule by default
haftmann
parents: 40034
diff changeset
   227
  by (auto intro!: fun_relI)
39996
c02078ff8691 FSet: definition changes propagated from Nominal and more use of 'descending' tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 39995
diff changeset
   228
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   229
lemma memb_commute_fold_list:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   230
  assumes a: "rsp_fold f"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   231
  and     b: "x \<in> set xs"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   232
  shows "fold_list f y xs = f x (fold_list f y (removeAll x xs))"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   233
  using a b by (induct xs) (auto simp add: rsp_fold_def)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   234
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   235
lemma fold_list_rsp_pre:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   236
  assumes a: "set xs = set ys"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   237
  shows "fold_list f z xs = fold_list f z ys"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   238
  using a
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   239
  apply (induct xs arbitrary: ys)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   240
  apply (simp)
39996
c02078ff8691 FSet: definition changes propagated from Nominal and more use of 'descending' tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 39995
diff changeset
   241
  apply (simp (no_asm_use))
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   242
  apply (rule conjI)
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   243
  apply (rule_tac [!] impI)
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   244
  apply (rule_tac [!] conjI)
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   245
  apply (rule_tac [!] impI)
39996
c02078ff8691 FSet: definition changes propagated from Nominal and more use of 'descending' tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 39995
diff changeset
   246
  apply (metis insert_absorb)
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   247
  apply (metis List.insert_def List.set.simps(2) List.set_insert fold_list.simps(2))
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   248
  apply (metis Diff_insert_absorb insertI1 memb_commute_fold_list set_removeAll)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   249
  apply(drule_tac x="removeAll a ys" in meta_spec)
39996
c02078ff8691 FSet: definition changes propagated from Nominal and more use of 'descending' tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 39995
diff changeset
   250
  apply(auto)
c02078ff8691 FSet: definition changes propagated from Nominal and more use of 'descending' tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 39995
diff changeset
   251
  apply(drule meta_mp)
c02078ff8691 FSet: definition changes propagated from Nominal and more use of 'descending' tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 39995
diff changeset
   252
  apply(blast)
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   253
  by (metis List.set.simps(2) emptyE fold_list.simps(2) in_listsp_conv_set listsp.simps mem_def)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   254
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   255
lemma fold_list_rsp [quot_respect]:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   256
  shows "(op = ===> op = ===> op \<approx> ===> op =) fold_list fold_list"
39996
c02078ff8691 FSet: definition changes propagated from Nominal and more use of 'descending' tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 39995
diff changeset
   257
  unfolding fun_rel_def
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   258
  by(auto intro: fold_list_rsp_pre)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   259
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   260
lemma concat_rsp_pre:
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36675
diff changeset
   261
  assumes a: "list_all2 op \<approx> x x'"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   262
  and     b: "x' \<approx> y'"
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36675
diff changeset
   263
  and     c: "list_all2 op \<approx> y' y"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   264
  and     d: "\<exists>x\<in>set x. xa \<in> set x"
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   265
  shows "\<exists>x\<in>set y. xa \<in> set x"
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   266
proof -
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   267
  obtain xb where e: "xb \<in> set x" and f: "xa \<in> set xb" using d by auto
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36675
diff changeset
   268
  have "\<exists>y. y \<in> set x' \<and> xb \<approx> y" by (rule list_all2_find_element[OF e a])
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   269
  then obtain ya where h: "ya \<in> set x'" and i: "xb \<approx> ya" by auto
36465
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
   270
  have "ya \<in> set y'" using b h by simp
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36675
diff changeset
   271
  then have "\<exists>yb. yb \<in> set y \<and> ya \<approx> yb" using c by (rule list_all2_find_element)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   272
  then show ?thesis using f i by auto
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   273
qed
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   274
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   275
lemma concat_rsp [quot_respect]:
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36675
diff changeset
   276
  shows "(list_all2 op \<approx> OOO op \<approx> ===> op \<approx>) concat concat"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   277
proof (rule fun_relI, elim pred_compE)
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   278
  fix a b ba bb
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36675
diff changeset
   279
  assume a: "list_all2 op \<approx> a ba"
40822
98a5faa5aec0 adaptions to changes in Equiv_Relation.thy
haftmann
parents: 40688
diff changeset
   280
  with list_symp [OF list_eq_symp] have a': "list_all2 op \<approx> ba a" by (rule sympE)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   281
  assume b: "ba \<approx> bb"
40822
98a5faa5aec0 adaptions to changes in Equiv_Relation.thy
haftmann
parents: 40688
diff changeset
   282
  with list_eq_symp have b': "bb \<approx> ba" by (rule sympE)
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36675
diff changeset
   283
  assume c: "list_all2 op \<approx> bb b"
40822
98a5faa5aec0 adaptions to changes in Equiv_Relation.thy
haftmann
parents: 40688
diff changeset
   284
  with list_symp [OF list_eq_symp] have c': "list_all2 op \<approx> b bb" by (rule sympE)
39996
c02078ff8691 FSet: definition changes propagated from Nominal and more use of 'descending' tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 39995
diff changeset
   285
  have "\<forall>x. (\<exists>xa\<in>set a. x \<in> set xa) = (\<exists>xa\<in>set b. x \<in> set xa)" 
c02078ff8691 FSet: definition changes propagated from Nominal and more use of 'descending' tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 39995
diff changeset
   286
  proof
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   287
    fix x
39996
c02078ff8691 FSet: definition changes propagated from Nominal and more use of 'descending' tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 39995
diff changeset
   288
    show "(\<exists>xa\<in>set a. x \<in> set xa) = (\<exists>xa\<in>set b. x \<in> set xa)" 
c02078ff8691 FSet: definition changes propagated from Nominal and more use of 'descending' tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 39995
diff changeset
   289
    proof
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   290
      assume d: "\<exists>xa\<in>set a. x \<in> set xa"
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   291
      show "\<exists>xa\<in>set b. x \<in> set xa" by (rule concat_rsp_pre[OF a b c d])
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   292
    next
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   293
      assume e: "\<exists>xa\<in>set b. x \<in> set xa"
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   294
      show "\<exists>xa\<in>set a. x \<in> set xa" by (rule concat_rsp_pre[OF c' b' a' e])
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   295
    qed
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   296
  qed
39996
c02078ff8691 FSet: definition changes propagated from Nominal and more use of 'descending' tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 39995
diff changeset
   297
  then show "concat a \<approx> concat b" by auto
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   298
qed
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   299
36639
6243b49498ea added function ffilter and some lemmas from Finite_Set to the FSet theory
bulwahn
parents: 36524
diff changeset
   300
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   301
section {* Quotient definitions for fsets *}
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   302
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   303
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   304
subsection {* Finite sets are a bounded, distributive lattice with minus *}
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   305
37634
2116425cebc8 cleaned by using descending instead of lifting
Christian Urban <urbanc@in.tum.de>
parents: 37492
diff changeset
   306
instantiation fset :: (type) "{bounded_lattice_bot, distrib_lattice, minus}"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   307
begin
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   308
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   309
quotient_definition
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   310
  "bot :: 'a fset" 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   311
  is "Nil :: 'a list"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   312
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   313
abbreviation
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   314
  empty_fset  ("{||}")
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   315
where
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   316
  "{||} \<equiv> bot :: 'a fset"
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   317
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   318
quotient_definition
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   319
  "less_eq_fset :: ('a fset \<Rightarrow> 'a fset \<Rightarrow> bool)"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   320
  is "sub_list :: ('a list \<Rightarrow> 'a list \<Rightarrow> bool)"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   321
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   322
abbreviation
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   323
  subset_fset :: "'a fset \<Rightarrow> 'a fset \<Rightarrow> bool" (infix "|\<subseteq>|" 50)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   324
where
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   325
  "xs |\<subseteq>| ys \<equiv> xs \<le> ys"
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   326
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   327
definition
39995
849578dd6127 FSet tuned
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 39994
diff changeset
   328
  less_fset :: "'a fset \<Rightarrow> 'a fset \<Rightarrow> bool"
849578dd6127 FSet tuned
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 39994
diff changeset
   329
where  
849578dd6127 FSet tuned
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 39994
diff changeset
   330
  "xs < ys \<equiv> xs \<le> ys \<and> xs \<noteq> (ys::'a fset)"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   331
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   332
abbreviation
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   333
  psubset_fset :: "'a fset \<Rightarrow> 'a fset \<Rightarrow> bool" (infix "|\<subset>|" 50)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   334
where
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   335
  "xs |\<subset>| ys \<equiv> xs < ys"
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   336
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   337
quotient_definition
39995
849578dd6127 FSet tuned
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 39994
diff changeset
   338
  "sup :: 'a fset \<Rightarrow> 'a fset \<Rightarrow> 'a fset"
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   339
  is "append :: 'a list \<Rightarrow> 'a list \<Rightarrow> 'a list"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   340
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   341
abbreviation
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   342
  union_fset (infixl "|\<union>|" 65)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   343
where
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   344
  "xs |\<union>| ys \<equiv> sup xs (ys::'a fset)"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   345
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   346
quotient_definition
39995
849578dd6127 FSet tuned
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 39994
diff changeset
   347
  "inf :: 'a fset \<Rightarrow> 'a fset \<Rightarrow> 'a fset"
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   348
  is "inter_list :: 'a list \<Rightarrow> 'a list \<Rightarrow> 'a list"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   349
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   350
abbreviation
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   351
  inter_fset (infixl "|\<inter>|" 65)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   352
where
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   353
  "xs |\<inter>| ys \<equiv> inf xs (ys::'a fset)"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   354
36675
806ea6e282e4 fminus and some more theorems ported from Finite_Set.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36646
diff changeset
   355
quotient_definition
37634
2116425cebc8 cleaned by using descending instead of lifting
Christian Urban <urbanc@in.tum.de>
parents: 37492
diff changeset
   356
  "minus :: 'a fset \<Rightarrow> 'a fset \<Rightarrow> 'a fset"
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   357
  is "diff_list :: 'a list \<Rightarrow> 'a list \<Rightarrow> 'a list"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   358
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   359
instance
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   360
proof
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   361
  fix x y z :: "'a fset"
37634
2116425cebc8 cleaned by using descending instead of lifting
Christian Urban <urbanc@in.tum.de>
parents: 37492
diff changeset
   362
  show "x |\<subset>| y \<longleftrightarrow> x |\<subseteq>| y \<and> \<not> y |\<subseteq>| x"
40467
dc0439fdd7c5 more appropriate specification packages; fun_rel_def is no simp rule by default
haftmann
parents: 40034
diff changeset
   363
    by (unfold less_fset_def, descending) auto
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   364
  show "x |\<subseteq>| x"  by (descending) (simp)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   365
  show "{||} |\<subseteq>| x" by (descending) (simp)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   366
  show "x |\<subseteq>| x |\<union>| y" by (descending) (simp)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   367
  show "y |\<subseteq>| x |\<union>| y" by (descending) (simp)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   368
  show "x |\<inter>| y |\<subseteq>| x" by (descending) (auto)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   369
  show "x |\<inter>| y |\<subseteq>| y" by (descending) (auto)
37634
2116425cebc8 cleaned by using descending instead of lifting
Christian Urban <urbanc@in.tum.de>
parents: 37492
diff changeset
   370
  show "x |\<union>| (y |\<inter>| z) = x |\<union>| y |\<inter>| (x |\<union>| z)" 
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   371
    by (descending) (auto)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   372
next
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   373
  fix x y z :: "'a fset"
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   374
  assume a: "x |\<subseteq>| y"
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   375
  assume b: "y |\<subseteq>| z"
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   376
  show "x |\<subseteq>| z" using a b by (descending) (simp)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   377
next
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   378
  fix x y :: "'a fset"
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   379
  assume a: "x |\<subseteq>| y"
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   380
  assume b: "y |\<subseteq>| x"
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   381
  show "x = y" using a b by (descending) (auto)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   382
next
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   383
  fix x y z :: "'a fset"
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   384
  assume a: "y |\<subseteq>| x"
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   385
  assume b: "z |\<subseteq>| x"
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   386
  show "y |\<union>| z |\<subseteq>| x" using a b by (descending) (simp)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   387
next
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   388
  fix x y z :: "'a fset"
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   389
  assume a: "x |\<subseteq>| y"
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   390
  assume b: "x |\<subseteq>| z"
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   391
  show "x |\<subseteq>| y |\<inter>| z" using a b by (descending) (auto)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   392
qed
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   393
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   394
end
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   395
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   396
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   397
subsection {* Other constants for fsets *}
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   398
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   399
quotient_definition
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   400
  "insert_fset :: 'a \<Rightarrow> 'a fset \<Rightarrow> 'a fset"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   401
  is "Cons"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   402
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   403
syntax
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   404
  "@Insert_fset"     :: "args => 'a fset"  ("{|(_)|}")
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   405
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   406
translations
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   407
  "{|x, xs|}" == "CONST insert_fset x {|xs|}"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   408
  "{|x|}"     == "CONST insert_fset x {||}"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   409
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   410
quotient_definition
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   411
  in_fset (infix "|\<in>|" 50)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   412
where
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   413
  "in_fset :: 'a \<Rightarrow> 'a fset \<Rightarrow> bool" is "memb"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   414
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   415
abbreviation
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   416
  notin_fset :: "'a \<Rightarrow> 'a fset \<Rightarrow> bool" (infix "|\<notin>|" 50)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   417
where
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   418
  "x |\<notin>| S \<equiv> \<not> (x |\<in>| S)"
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   419
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   420
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   421
subsection {* Other constants on the Quotient Type *}
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   422
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   423
quotient_definition
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   424
  "card_fset :: 'a fset \<Rightarrow> nat"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   425
  is card_list
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   426
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   427
quotient_definition
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   428
  "map_fset :: ('a \<Rightarrow> 'b) \<Rightarrow> 'a fset \<Rightarrow> 'b fset"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   429
  is map
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   430
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   431
quotient_definition
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   432
  "remove_fset :: 'a \<Rightarrow> 'a fset \<Rightarrow> 'a fset"
39996
c02078ff8691 FSet: definition changes propagated from Nominal and more use of 'descending' tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 39995
diff changeset
   433
  is removeAll
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   434
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   435
quotient_definition
39996
c02078ff8691 FSet: definition changes propagated from Nominal and more use of 'descending' tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 39995
diff changeset
   436
  "fset :: 'a fset \<Rightarrow> 'a set"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   437
  is "set"
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   438
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   439
quotient_definition
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   440
  "fold_fset :: ('a \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> 'b \<Rightarrow> 'a fset \<Rightarrow> 'b"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   441
  is fold_list
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   442
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   443
quotient_definition
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   444
  "concat_fset :: ('a fset) fset \<Rightarrow> 'a fset"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   445
  is concat
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   446
36639
6243b49498ea added function ffilter and some lemmas from Finite_Set to the FSet theory
bulwahn
parents: 36524
diff changeset
   447
quotient_definition
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   448
  "filter_fset :: ('a \<Rightarrow> bool) \<Rightarrow> 'a fset \<Rightarrow> 'a fset"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   449
  is filter
36639
6243b49498ea added function ffilter and some lemmas from Finite_Set to the FSet theory
bulwahn
parents: 36524
diff changeset
   450
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   451
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   452
subsection {* Compositional respectfulness and preservation lemmas *}
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   453
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   454
lemma Nil_rsp2 [quot_respect]: 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   455
  shows "(list_all2 op \<approx> OOO op \<approx>) Nil Nil"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   456
  by (rule compose_list_refl, rule list_eq_equivp)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   457
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   458
lemma Cons_rsp2 [quot_respect]:
39994
7bd8013b903f FSet: give names to respectfulness theorems, rename list_all2_refl to avoid clash
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 39302
diff changeset
   459
  shows "(op \<approx> ===> list_all2 op \<approx> OOO op \<approx> ===> list_all2 op \<approx> OOO op \<approx>) Cons Cons"
40467
dc0439fdd7c5 more appropriate specification packages; fun_rel_def is no simp rule by default
haftmann
parents: 40034
diff changeset
   460
  apply (auto intro!: fun_relI)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   461
  apply (rule_tac b="x # b" in pred_compI)
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   462
  apply auto
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   463
  apply (rule_tac b="x # ba" in pred_compI)
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   464
  apply auto
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   465
  done
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   466
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   467
lemma map_prs [quot_preserve]: 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   468
  shows "(abs_fset \<circ> map f) [] = abs_fset []"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   469
  by simp
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   470
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   471
lemma insert_fset_rsp [quot_preserve]:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   472
  "(rep_fset ---> (map rep_fset \<circ> rep_fset) ---> (abs_fset \<circ> map abs_fset)) Cons = insert_fset"
39302
d7728f65b353 renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents: 39198
diff changeset
   473
  by (simp add: fun_eq_iff Quotient_abs_rep[OF Quotient_fset]
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   474
      abs_o_rep[OF Quotient_fset] map_id insert_fset_def)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   475
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   476
lemma union_fset_rsp [quot_preserve]:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   477
  "((map rep_fset \<circ> rep_fset) ---> (map rep_fset \<circ> rep_fset) ---> (abs_fset \<circ> map abs_fset)) 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   478
  append = union_fset"
39302
d7728f65b353 renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents: 39198
diff changeset
   479
  by (simp add: fun_eq_iff Quotient_abs_rep[OF Quotient_fset]
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   480
      abs_o_rep[OF Quotient_fset] map_id sup_fset_def)
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   481
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36675
diff changeset
   482
lemma list_all2_app_l:
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   483
  assumes a: "reflp R"
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36675
diff changeset
   484
  and b: "list_all2 R l r"
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36675
diff changeset
   485
  shows "list_all2 R (z @ l) (z @ r)"
40822
98a5faa5aec0 adaptions to changes in Equiv_Relation.thy
haftmann
parents: 40688
diff changeset
   486
  using a b by (induct z) (auto elim: reflpE)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   487
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   488
lemma append_rsp2_pre0:
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36675
diff changeset
   489
  assumes a:"list_all2 op \<approx> x x'"
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36675
diff changeset
   490
  shows "list_all2 op \<approx> (x @ z) (x' @ z)"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   491
  using a apply (induct x x' rule: list_induct2')
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   492
  by simp_all (rule list_all2_refl'[OF list_eq_equivp])
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   493
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   494
lemma append_rsp2_pre1:
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36675
diff changeset
   495
  assumes a:"list_all2 op \<approx> x x'"
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36675
diff changeset
   496
  shows "list_all2 op \<approx> (z @ x) (z @ x')"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   497
  using a apply (induct x x' arbitrary: z rule: list_induct2')
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   498
  apply (rule list_all2_refl'[OF list_eq_equivp])
40467
dc0439fdd7c5 more appropriate specification packages; fun_rel_def is no simp rule by default
haftmann
parents: 40034
diff changeset
   499
  apply (simp_all del: list_eq_def)
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36675
diff changeset
   500
  apply (rule list_all2_app_l)
40822
98a5faa5aec0 adaptions to changes in Equiv_Relation.thy
haftmann
parents: 40688
diff changeset
   501
  apply (simp_all add: reflpI)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   502
  done
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   503
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   504
lemma append_rsp2_pre:
40822
98a5faa5aec0 adaptions to changes in Equiv_Relation.thy
haftmann
parents: 40688
diff changeset
   505
  assumes "list_all2 op \<approx> x x'"
98a5faa5aec0 adaptions to changes in Equiv_Relation.thy
haftmann
parents: 40688
diff changeset
   506
    and "list_all2 op \<approx> z z'"
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36675
diff changeset
   507
  shows "list_all2 op \<approx> (x @ z) (x' @ z')"
40822
98a5faa5aec0 adaptions to changes in Equiv_Relation.thy
haftmann
parents: 40688
diff changeset
   508
  using assms by (rule list_all2_appendI)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   509
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   510
lemma append_rsp2 [quot_respect]:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   511
  "(list_all2 op \<approx> OOO op \<approx> ===> list_all2 op \<approx> OOO op \<approx> ===> list_all2 op \<approx> OOO op \<approx>) append append"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   512
proof (intro fun_relI, elim pred_compE)
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   513
  fix x y z w x' z' y' w' :: "'a list list"
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36675
diff changeset
   514
  assume a:"list_all2 op \<approx> x x'"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   515
  and b:    "x' \<approx> y'"
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36675
diff changeset
   516
  and c:    "list_all2 op \<approx> y' y"
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36675
diff changeset
   517
  assume aa: "list_all2 op \<approx> z z'"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   518
  and bb:   "z' \<approx> w'"
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36675
diff changeset
   519
  and cc:   "list_all2 op \<approx> w' w"
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36675
diff changeset
   520
  have a': "list_all2 op \<approx> (x @ z) (x' @ z')" using a aa append_rsp2_pre by auto
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   521
  have b': "x' @ z' \<approx> y' @ w'" using b bb by simp
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36675
diff changeset
   522
  have c': "list_all2 op \<approx> (y' @ w') (y @ w)" using c cc append_rsp2_pre by auto
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36675
diff changeset
   523
  have d': "(op \<approx> OO list_all2 op \<approx>) (x' @ z') (y @ w)"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   524
    by (rule pred_compI) (rule b', rule c')
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36675
diff changeset
   525
  show "(list_all2 op \<approx> OOO op \<approx>) (x @ z) (y @ w)"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   526
    by (rule pred_compI) (rule a', rule d')
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   527
qed
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   528
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   529
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   530
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   531
section {* Lifted theorems *}
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   532
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   533
subsection {* fset *}
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   534
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   535
lemma fset_simps [simp]:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   536
  shows "fset {||} = {}"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   537
  and   "fset (insert_fset x S) = insert x (fset S)"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   538
  by (descending, simp)+
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   539
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   540
lemma finite_fset [simp]: 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   541
  shows "finite (fset S)"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   542
  by (descending) (simp)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   543
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   544
lemma fset_cong:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   545
  shows "fset S = fset T \<longleftrightarrow> S = T"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   546
  by (descending) (simp)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   547
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   548
lemma filter_fset [simp]: 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   549
  shows "fset (filter_fset P xs) = P \<inter> fset xs"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   550
  by (descending) (auto simp add: mem_def)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   551
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   552
lemma remove_fset [simp]: 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   553
  shows "fset (remove_fset x xs) = fset xs - {x}"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   554
  by (descending) (simp)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   555
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   556
lemma inter_fset [simp]: 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   557
  shows "fset (xs |\<inter>| ys) = fset xs \<inter> fset ys"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   558
  by (descending) (auto)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   559
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   560
lemma union_fset [simp]: 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   561
  shows "fset (xs |\<union>| ys) = fset xs \<union> fset ys"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   562
  by (lifting set_append)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   563
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   564
lemma minus_fset [simp]: 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   565
  shows "fset (xs - ys) = fset xs - fset ys"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   566
  by (descending) (auto)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   567
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   568
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   569
subsection {* in_fset *}
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   570
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   571
lemma in_fset: 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   572
  shows "x |\<in>| S \<longleftrightarrow> x \<in> fset S"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   573
  by (descending) (simp)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   574
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   575
lemma notin_fset: 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   576
  shows "x |\<notin>| S \<longleftrightarrow> x \<notin> fset S"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   577
  by (simp add: in_fset)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   578
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   579
lemma notin_empty_fset: 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   580
  shows "x |\<notin>| {||}"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   581
  by (simp add: in_fset)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   582
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   583
lemma fset_eq_iff:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   584
  shows "S = T \<longleftrightarrow> (\<forall>x. (x |\<in>| S) = (x |\<in>| T))"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   585
  by (descending) (auto)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   586
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   587
lemma none_in_empty_fset:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   588
  shows "(\<forall>x. x |\<notin>| S) \<longleftrightarrow> S = {||}"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   589
  by (descending) (simp)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   590
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   591
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   592
subsection {* insert_fset *}
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   593
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   594
lemma in_insert_fset_iff [simp]:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   595
  shows "x |\<in>| insert_fset y S \<longleftrightarrow> x = y \<or> x |\<in>| S"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   596
  by (descending) (simp)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   597
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   598
lemma
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   599
  shows insert_fsetI1: "x |\<in>| insert_fset x S"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   600
  and   insert_fsetI2: "x |\<in>| S \<Longrightarrow> x |\<in>| insert_fset y S"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   601
  by simp_all
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   602
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   603
lemma insert_absorb_fset [simp]:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   604
  shows "x |\<in>| S \<Longrightarrow> insert_fset x S = S"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   605
  by (descending) (auto)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   606
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   607
lemma empty_not_insert_fset[simp]:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   608
  shows "{||} \<noteq> insert_fset x S"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   609
  and   "insert_fset x S \<noteq> {||}"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   610
  by (descending, simp)+
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   611
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   612
lemma insert_fset_left_comm:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   613
  shows "insert_fset x (insert_fset y S) = insert_fset y (insert_fset x S)"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   614
  by (descending) (auto)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   615
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   616
lemma insert_fset_left_idem:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   617
  shows "insert_fset x (insert_fset x S) = insert_fset x S"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   618
  by (descending) (auto)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   619
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   620
lemma singleton_fset_eq[simp]:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   621
  shows "{|x|} = {|y|} \<longleftrightarrow> x = y"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   622
  by (descending) (auto)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   623
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   624
lemma in_fset_mdef:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   625
  shows "x |\<in>| F \<longleftrightarrow> x |\<notin>| (F - {|x|}) \<and> F = insert_fset x (F - {|x|})"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   626
  by (descending) (auto)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   627
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   628
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   629
subsection {* union_fset *}
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   630
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   631
lemmas [simp] =
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   632
  sup_bot_left[where 'a="'a fset", standard]
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   633
  sup_bot_right[where 'a="'a fset", standard]
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   634
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   635
lemma union_insert_fset [simp]:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   636
  shows "insert_fset x S |\<union>| T = insert_fset x (S |\<union>| T)"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   637
  by (lifting append.simps(2))
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   638
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   639
lemma singleton_union_fset_left:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   640
  shows "{|a|} |\<union>| S = insert_fset a S"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   641
  by simp
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   642
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   643
lemma singleton_union_fset_right:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   644
  shows "S |\<union>| {|a|} = insert_fset a S"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   645
  by (subst sup.commute) simp
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   646
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   647
lemma in_union_fset:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   648
  shows "x |\<in>| S |\<union>| T \<longleftrightarrow> x |\<in>| S \<or> x |\<in>| T"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   649
  by (descending) (simp)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   650
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   651
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   652
subsection {* minus_fset *}
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   653
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   654
lemma minus_in_fset: 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   655
  shows "x |\<in>| (xs - ys) \<longleftrightarrow> x |\<in>| xs \<and> x |\<notin>| ys"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   656
  by (descending) (simp)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   657
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   658
lemma minus_insert_fset: 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   659
  shows "insert_fset x xs - ys = (if x |\<in>| ys then xs - ys else insert_fset x (xs - ys))"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   660
  by (descending) (auto)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   661
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   662
lemma minus_insert_in_fset[simp]: 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   663
  shows "x |\<in>| ys \<Longrightarrow> insert_fset x xs - ys = xs - ys"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   664
  by (simp add: minus_insert_fset)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   665
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   666
lemma minus_insert_notin_fset[simp]: 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   667
  shows "x |\<notin>| ys \<Longrightarrow> insert_fset x xs - ys = insert_fset x (xs - ys)"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   668
  by (simp add: minus_insert_fset)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   669
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   670
lemma in_minus_fset: 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   671
  shows "x |\<in>| F - S \<Longrightarrow> x |\<notin>| S"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   672
  unfolding in_fset minus_fset
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   673
  by blast
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   674
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   675
lemma notin_minus_fset: 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   676
  shows "x |\<in>| S \<Longrightarrow> x |\<notin>| F - S"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   677
  unfolding in_fset minus_fset
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   678
  by blast
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   679
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   680
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   681
subsection {* remove_fset *}
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   682
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   683
lemma in_remove_fset:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   684
  shows "x |\<in>| remove_fset y S \<longleftrightarrow> x |\<in>| S \<and> x \<noteq> y"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   685
  by (descending) (simp)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   686
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   687
lemma notin_remove_fset:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   688
  shows "x |\<notin>| remove_fset x S"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   689
  by (descending) (simp)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   690
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   691
lemma notin_remove_ident_fset:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   692
  shows "x |\<notin>| S \<Longrightarrow> remove_fset x S = S"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   693
  by (descending) (simp)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   694
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   695
lemma remove_fset_cases:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   696
  shows "S = {||} \<or> (\<exists>x. x |\<in>| S \<and> S = insert_fset x (remove_fset x S))"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   697
  by (descending) (auto simp add: insert_absorb)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   698
  
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   699
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   700
subsection {* inter_fset *}
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   701
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   702
lemma inter_empty_fset_l:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   703
  shows "{||} |\<inter>| S = {||}"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   704
  by simp
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   705
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   706
lemma inter_empty_fset_r:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   707
  shows "S |\<inter>| {||} = {||}"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   708
  by simp
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   709
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   710
lemma inter_insert_fset:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   711
  shows "insert_fset x S |\<inter>| T = (if x |\<in>| T then insert_fset x (S |\<inter>| T) else S |\<inter>| T)"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   712
  by (descending) (auto)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   713
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   714
lemma in_inter_fset:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   715
  shows "x |\<in>| (S |\<inter>| T) \<longleftrightarrow> x |\<in>| S \<and> x |\<in>| T"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   716
  by (descending) (simp)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   717
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   718
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   719
subsection {* subset_fset and psubset_fset *}
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   720
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   721
lemma subset_fset: 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   722
  shows "xs |\<subseteq>| ys \<longleftrightarrow> fset xs \<subseteq> fset ys"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   723
  by (descending) (simp)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   724
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   725
lemma psubset_fset: 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   726
  shows "xs |\<subset>| ys \<longleftrightarrow> fset xs \<subset> fset ys"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   727
  unfolding less_fset_def 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   728
  by (descending) (auto)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   729
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   730
lemma subset_insert_fset:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   731
  shows "(insert_fset x xs) |\<subseteq>| ys \<longleftrightarrow> x |\<in>| ys \<and> xs |\<subseteq>| ys"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   732
  by (descending) (simp)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   733
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   734
lemma subset_in_fset: 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   735
  shows "xs |\<subseteq>| ys = (\<forall>x. x |\<in>| xs \<longrightarrow> x |\<in>| ys)"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   736
  by (descending) (auto)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   737
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   738
lemma subset_empty_fset:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   739
  shows "xs |\<subseteq>| {||} \<longleftrightarrow> xs = {||}"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   740
  by (descending) (simp)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   741
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   742
lemma not_psubset_empty_fset: 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   743
  shows "\<not> xs |\<subset>| {||}"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   744
  by (metis fset_simps(1) psubset_fset not_psubset_empty)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   745
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   746
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   747
subsection {* map_fset *}
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   748
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   749
lemma map_fset_simps [simp]:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   750
   shows "map_fset f {||} = {||}"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   751
  and   "map_fset f (insert_fset x S) = insert_fset (f x) (map_fset f S)"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   752
  by (descending, simp)+
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   753
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   754
lemma map_fset_image [simp]:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   755
  shows "fset (map_fset f S) = f ` (fset S)"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   756
  by (descending) (simp)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   757
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   758
lemma inj_map_fset_cong:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   759
  shows "inj f \<Longrightarrow> map_fset f S = map_fset f T \<longleftrightarrow> S = T"
40467
dc0439fdd7c5 more appropriate specification packages; fun_rel_def is no simp rule by default
haftmann
parents: 40034
diff changeset
   760
  by (descending) (metis inj_vimage_image_eq list_eq_def set_map)
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   761
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   762
lemma map_union_fset: 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   763
  shows "map_fset f (S |\<union>| T) = map_fset f S |\<union>| map_fset f T"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   764
  by (descending) (simp)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   765
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   766
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   767
subsection {* card_fset *}
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   768
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   769
lemma card_fset: 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   770
  shows "card_fset xs = card (fset xs)"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   771
  by (descending) (simp)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   772
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   773
lemma card_insert_fset_iff [simp]:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   774
  shows "card_fset (insert_fset x S) = (if x |\<in>| S then card_fset S else Suc (card_fset S))"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   775
  by (descending) (simp add: insert_absorb)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   776
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   777
lemma card_fset_0[simp]:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   778
  shows "card_fset S = 0 \<longleftrightarrow> S = {||}"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   779
  by (descending) (simp)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   780
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   781
lemma card_empty_fset[simp]:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   782
  shows "card_fset {||} = 0"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   783
  by (simp add: card_fset)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   784
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   785
lemma card_fset_1:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   786
  shows "card_fset S = 1 \<longleftrightarrow> (\<exists>x. S = {|x|})"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   787
  by (descending) (auto simp add: card_Suc_eq)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   788
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   789
lemma card_fset_gt_0:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   790
  shows "x \<in> fset S \<Longrightarrow> 0 < card_fset S"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   791
  by (descending) (auto simp add: card_gt_0_iff)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   792
  
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   793
lemma card_notin_fset:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   794
  shows "(x |\<notin>| S) = (card_fset (insert_fset x S) = Suc (card_fset S))"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   795
  by simp
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   796
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   797
lemma card_fset_Suc: 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   798
  shows "card_fset S = Suc n \<Longrightarrow> \<exists>x T. x |\<notin>| T \<and> S = insert_fset x T \<and> card_fset T = n"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   799
  apply(descending)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   800
  apply(auto dest!: card_eq_SucD)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   801
  by (metis Diff_insert_absorb set_removeAll)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   802
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   803
lemma card_remove_fset_iff [simp]:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   804
  shows "card_fset (remove_fset y S) = (if y |\<in>| S then card_fset S - 1 else card_fset S)"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   805
  by (descending) (simp)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   806
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   807
lemma card_Suc_exists_in_fset: 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   808
  shows "card_fset S = Suc n \<Longrightarrow> \<exists>a. a |\<in>| S"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   809
  by (drule card_fset_Suc) (auto)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   810
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   811
lemma in_card_fset_not_0: 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   812
  shows "a |\<in>| A \<Longrightarrow> card_fset A \<noteq> 0"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   813
  by (descending) (auto)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   814
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   815
lemma card_fset_mono: 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   816
  shows "xs |\<subseteq>| ys \<Longrightarrow> card_fset xs \<le> card_fset ys"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   817
  unfolding card_fset psubset_fset
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   818
  by (simp add: card_mono subset_fset)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   819
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   820
lemma card_subset_fset_eq: 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   821
  shows "xs |\<subseteq>| ys \<Longrightarrow> card_fset ys \<le> card_fset xs \<Longrightarrow> xs = ys"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   822
  unfolding card_fset subset_fset
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   823
  by (auto dest: card_seteq[OF finite_fset] simp add: fset_cong)
36675
806ea6e282e4 fminus and some more theorems ported from Finite_Set.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36646
diff changeset
   824
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   825
lemma psubset_card_fset_mono: 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   826
  shows "xs |\<subset>| ys \<Longrightarrow> card_fset xs < card_fset ys"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   827
  unfolding card_fset subset_fset
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   828
  by (metis finite_fset psubset_fset psubset_card_mono)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   829
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   830
lemma card_union_inter_fset: 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   831
  shows "card_fset xs + card_fset ys = card_fset (xs |\<union>| ys) + card_fset (xs |\<inter>| ys)"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   832
  unfolding card_fset union_fset inter_fset
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   833
  by (rule card_Un_Int[OF finite_fset finite_fset])
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   834
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   835
lemma card_union_disjoint_fset: 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   836
  shows "xs |\<inter>| ys = {||} \<Longrightarrow> card_fset (xs |\<union>| ys) = card_fset xs + card_fset ys"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   837
  unfolding card_fset union_fset 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   838
  apply (rule card_Un_disjoint[OF finite_fset finite_fset])
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   839
  by (metis inter_fset fset_simps(1))
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   840
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   841
lemma card_remove_fset_less1: 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   842
  shows "x |\<in>| xs \<Longrightarrow> card_fset (remove_fset x xs) < card_fset xs"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   843
  unfolding card_fset in_fset remove_fset 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   844
  by (rule card_Diff1_less[OF finite_fset])
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   845
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   846
lemma card_remove_fset_less2: 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   847
  shows "x |\<in>| xs \<Longrightarrow> y |\<in>| xs \<Longrightarrow> card_fset (remove_fset y (remove_fset x xs)) < card_fset xs"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   848
  unfolding card_fset remove_fset in_fset
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   849
  by (rule card_Diff2_less[OF finite_fset])
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   850
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   851
lemma card_remove_fset_le1: 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   852
  shows "card_fset (remove_fset x xs) \<le> card_fset xs"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   853
  unfolding remove_fset card_fset
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   854
  by (rule card_Diff1_le[OF finite_fset])
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   855
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   856
lemma card_psubset_fset: 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   857
  shows "ys |\<subseteq>| xs \<Longrightarrow> card_fset ys < card_fset xs \<Longrightarrow> ys |\<subset>| xs"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   858
  unfolding card_fset psubset_fset subset_fset
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   859
  by (rule card_psubset[OF finite_fset])
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   860
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   861
lemma card_map_fset_le: 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   862
  shows "card_fset (map_fset f xs) \<le> card_fset xs"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   863
  unfolding card_fset map_fset_image
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   864
  by (rule card_image_le[OF finite_fset])
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   865
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   866
lemma card_minus_insert_fset[simp]:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   867
  assumes "a |\<in>| A" and "a |\<notin>| B"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   868
  shows "card_fset (A - insert_fset a B) = card_fset (A - B) - 1"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   869
  using assms 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   870
  unfolding in_fset card_fset minus_fset
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   871
  by (simp add: card_Diff_insert[OF finite_fset])
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   872
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   873
lemma card_minus_subset_fset:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   874
  assumes "B |\<subseteq>| A"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   875
  shows "card_fset (A - B) = card_fset A - card_fset B"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   876
  using assms 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   877
  unfolding subset_fset card_fset minus_fset
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   878
  by (rule card_Diff_subset[OF finite_fset])
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   879
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   880
lemma card_minus_fset:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   881
  shows "card_fset (A - B) = card_fset A - card_fset (A |\<inter>| B)"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   882
  unfolding inter_fset card_fset minus_fset
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   883
  by (rule card_Diff_subset_Int) (simp)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   884
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   885
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   886
subsection {* concat_fset *}
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   887
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   888
lemma concat_empty_fset [simp]:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   889
  shows "concat_fset {||} = {||}"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   890
  by (lifting concat.simps(1))
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   891
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   892
lemma concat_insert_fset [simp]:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   893
  shows "concat_fset (insert_fset x S) = x |\<union>| concat_fset S"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   894
  by (lifting concat.simps(2))
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   895
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   896
lemma concat_inter_fset [simp]:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   897
  shows "concat_fset (xs |\<union>| ys) = concat_fset xs |\<union>| concat_fset ys"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   898
  by (lifting concat_append)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   899
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   900
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   901
subsection {* filter_fset *}
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   902
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   903
lemma subset_filter_fset: 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   904
  shows "filter_fset P xs |\<subseteq>| filter_fset Q xs = (\<forall> x. x |\<in>| xs \<longrightarrow> P x \<longrightarrow> Q x)"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   905
  by  (descending) (auto)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   906
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   907
lemma eq_filter_fset: 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   908
  shows "(filter_fset P xs = filter_fset Q xs) = (\<forall>x. x |\<in>| xs \<longrightarrow> P x = Q x)"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   909
  by (descending) (auto)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   910
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   911
lemma psubset_filter_fset:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   912
  shows "(\<And>x. x |\<in>| xs \<Longrightarrow> P x \<Longrightarrow> Q x) \<Longrightarrow> (x |\<in>| xs & \<not> P x & Q x) \<Longrightarrow> 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   913
    filter_fset P xs |\<subset>| filter_fset Q xs"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   914
  unfolding less_fset_def by (auto simp add: subset_filter_fset eq_filter_fset)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   915
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   916
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   917
subsection {* fold_fset *}
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   918
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   919
lemma fold_empty_fset: 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   920
  shows "fold_fset f z {||} = z"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   921
  by (descending) (simp)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   922
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   923
lemma fold_insert_fset: "fold_fset f z (insert_fset a A) =
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   924
  (if rsp_fold f then if a |\<in>| A then fold_fset f z A else f a (fold_fset f z A) else z)"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   925
  by (descending) (simp)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   926
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   927
lemma in_commute_fold_fset:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   928
  "\<lbrakk>rsp_fold f; h |\<in>| b\<rbrakk> \<Longrightarrow> fold_fset f z b = f h (fold_fset f z (remove_fset h b))"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   929
  by (descending) (simp add: memb_commute_fold_list)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   930
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   931
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   932
subsection {* Choice in fsets *}
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   933
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   934
lemma fset_choice: 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   935
  assumes a: "\<forall>x. x |\<in>| A \<longrightarrow> (\<exists>y. P x y)"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   936
  shows "\<exists>f. \<forall>x. x |\<in>| A \<longrightarrow> P x (f x)"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   937
  using a
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   938
  apply(descending)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   939
  using finite_set_choice
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   940
  by (auto simp add: Ball_def)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   941
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   942
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   943
section {* Induction and Cases rules for fsets *}
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   944
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   945
lemma fset_exhaust [case_names empty_fset insert_fset, cases type: fset]:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   946
  assumes empty_fset_case: "S = {||} \<Longrightarrow> P" 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   947
  and     insert_fset_case: "\<And>x S'. S = insert_fset x S' \<Longrightarrow> P"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   948
  shows "P"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   949
  using assms by (lifting list.exhaust)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   950
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   951
lemma fset_induct [case_names empty_fset insert_fset]:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   952
  assumes empty_fset_case: "P {||}"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   953
  and     insert_fset_case: "\<And>x S. P S \<Longrightarrow> P (insert_fset x S)"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   954
  shows "P S"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   955
  using assms 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   956
  by (descending) (blast intro: list.induct)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   957
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   958
lemma fset_induct_stronger [case_names empty_fset insert_fset, induct type: fset]:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   959
  assumes empty_fset_case: "P {||}"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   960
  and     insert_fset_case: "\<And>x S. \<lbrakk>x |\<notin>| S; P S\<rbrakk> \<Longrightarrow> P (insert_fset x S)"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   961
  shows "P S"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   962
proof(induct S rule: fset_induct)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   963
  case empty_fset
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   964
  show "P {||}" using empty_fset_case by simp
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   965
next
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   966
  case (insert_fset x S)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   967
  have "P S" by fact
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   968
  then show "P (insert_fset x S)" using insert_fset_case 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   969
    by (cases "x |\<in>| S") (simp_all)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   970
qed
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   971
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   972
lemma fset_card_induct:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   973
  assumes empty_fset_case: "P {||}"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   974
  and     card_fset_Suc_case: "\<And>S T. Suc (card_fset S) = (card_fset T) \<Longrightarrow> P S \<Longrightarrow> P T"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   975
  shows "P S"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   976
proof (induct S)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   977
  case empty_fset
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   978
  show "P {||}" by (rule empty_fset_case)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   979
next
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   980
  case (insert_fset x S)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   981
  have h: "P S" by fact
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   982
  have "x |\<notin>| S" by fact
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   983
  then have "Suc (card_fset S) = card_fset (insert_fset x S)" 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   984
    using card_fset_Suc by auto
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   985
  then show "P (insert_fset x S)" 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   986
    using h card_fset_Suc_case by simp
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   987
qed
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   988
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   989
lemma fset_raw_strong_cases:
36465
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
   990
  obtains "xs = []"
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
   991
    | x ys where "\<not> memb x ys" and "xs \<approx> x # ys"
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
   992
proof (induct xs arbitrary: x ys)
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
   993
  case Nil
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
   994
  then show thesis by simp
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
   995
next
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
   996
  case (Cons a xs)
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
   997
  have a: "\<lbrakk>xs = [] \<Longrightarrow> thesis; \<And>x ys. \<lbrakk>\<not> memb x ys; xs \<approx> x # ys\<rbrakk> \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis" by fact
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
   998
  have b: "\<And>x' ys'. \<lbrakk>\<not> memb x' ys'; a # xs \<approx> x' # ys'\<rbrakk> \<Longrightarrow> thesis" by fact
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   999
  have c: "xs = [] \<Longrightarrow> thesis" using b 
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1000
    apply(simp)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1001
    by (metis List.set.simps(1) emptyE empty_subsetI)
36465
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
  1002
  have "\<And>x ys. \<lbrakk>\<not> memb x ys; xs \<approx> x # ys\<rbrakk> \<Longrightarrow> thesis"
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
  1003
  proof -
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
  1004
    fix x :: 'a
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
  1005
    fix ys :: "'a list"
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
  1006
    assume d:"\<not> memb x ys"
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
  1007
    assume e:"xs \<approx> x # ys"
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
  1008
    show thesis
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
  1009
    proof (cases "x = a")
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
  1010
      assume h: "x = a"
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
  1011
      then have f: "\<not> memb a ys" using d by simp
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
  1012
      have g: "a # xs \<approx> a # ys" using e h by auto
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
  1013
      show thesis using b f g by simp
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
  1014
    next
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
  1015
      assume h: "x \<noteq> a"
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1016
      then have f: "\<not> memb x (a # ys)" using d by auto
36465
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
  1017
      have g: "a # xs \<approx> x # (a # ys)" using e h by auto
40034
Christian Urban <urbanc@in.tum.de>
parents: 40030
diff changeset
  1018
      show thesis using b f g by (simp del: memb_def) 
36465
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
  1019
    qed
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
  1020
  qed
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
  1021
  then show thesis using a c by blast
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
  1022
qed
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1023
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1024
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1025
lemma fset_strong_cases:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1026
  obtains "xs = {||}"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1027
    | x ys where "x |\<notin>| ys" and "xs = insert_fset x ys"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1028
  by (lifting fset_raw_strong_cases)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1029
39996
c02078ff8691 FSet: definition changes propagated from Nominal and more use of 'descending' tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 39995
diff changeset
  1030
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1031
lemma fset_induct2:
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1032
  "P {||} {||} \<Longrightarrow>
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1033
  (\<And>x xs. x |\<notin>| xs \<Longrightarrow> P (insert_fset x xs) {||}) \<Longrightarrow>
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1034
  (\<And>y ys. y |\<notin>| ys \<Longrightarrow> P {||} (insert_fset y ys)) \<Longrightarrow>
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1035
  (\<And>x xs y ys. \<lbrakk>P xs ys; x |\<notin>| xs; y |\<notin>| ys\<rbrakk> \<Longrightarrow> P (insert_fset x xs) (insert_fset y ys)) \<Longrightarrow>
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1036
  P xsa ysa"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1037
  apply (induct xsa arbitrary: ysa)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1038
  apply (induct_tac x rule: fset_induct_stronger)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1039
  apply simp_all
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1040
  apply (induct_tac xa rule: fset_induct_stronger)
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1041
  apply simp_all
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1042
  done
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1043
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1044
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1045
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1046
subsection {* alternate formulation with a different decomposition principle
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1047
  and a proof of equivalence *}
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1048
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1049
inductive
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1050
  list_eq2 ("_ \<approx>2 _")
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1051
where
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1052
  "(a # b # xs) \<approx>2 (b # a # xs)"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1053
| "[] \<approx>2 []"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1054
| "xs \<approx>2 ys \<Longrightarrow>  ys \<approx>2 xs"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1055
| "(a # a # xs) \<approx>2 (a # xs)"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1056
| "xs \<approx>2 ys \<Longrightarrow>  (a # xs) \<approx>2 (a # ys)"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1057
| "\<lbrakk>xs1 \<approx>2 xs2;  xs2 \<approx>2 xs3\<rbrakk> \<Longrightarrow> xs1 \<approx>2 xs3"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1058
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1059
lemma list_eq2_refl:
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1060
  shows "xs \<approx>2 xs"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1061
  by (induct xs) (auto intro: list_eq2.intros)
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1062
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1063
lemma cons_delete_list_eq2:
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1064
  shows "(a # (removeAll a A)) \<approx>2 (if memb a A then A else a # A)"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1065
  apply (induct A)
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1066
  apply (simp add: list_eq2_refl)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1067
  apply (case_tac "memb a (aa # A)")
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1068
  apply (simp_all)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1069
  apply (case_tac [!] "a = aa")
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1070
  apply (simp_all)
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1071
  apply (case_tac "memb a A")
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1072
  apply (auto)[2]
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1073
  apply (metis list_eq2.intros(3) list_eq2.intros(4) list_eq2.intros(5) list_eq2.intros(6))
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1074
  apply (metis list_eq2.intros(1) list_eq2.intros(5) list_eq2.intros(6))
39996
c02078ff8691 FSet: definition changes propagated from Nominal and more use of 'descending' tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 39995
diff changeset
  1075
  apply (auto simp add: list_eq2_refl memb_def)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1076
  done
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1077
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1078
lemma memb_delete_list_eq2:
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1079
  assumes a: "memb e r"
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1080
  shows "(e # removeAll e r) \<approx>2 r"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1081
  using a cons_delete_list_eq2[of e r]
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1082
  by simp
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1083
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1084
lemma list_eq2_equiv:
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1085
  "(l \<approx> r) \<longleftrightarrow> (list_eq2 l r)"
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1086
proof
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1087
  show "list_eq2 l r \<Longrightarrow> l \<approx> r" by (induct rule: list_eq2.induct) auto
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1088
next
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1089
  {
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1090
    fix n
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1091
    assume a: "card_list l = n" and b: "l \<approx> r"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1092
    have "l \<approx>2 r"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1093
      using a b
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1094
    proof (induct n arbitrary: l r)
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1095
      case 0
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1096
      have "card_list l = 0" by fact
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1097
      then have "\<forall>x. \<not> memb x l" by auto
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1098
      then have z: "l = []" by auto
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1099
      then have "r = []" using `l \<approx> r` by simp
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1100
      then show ?case using z list_eq2_refl by simp
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1101
    next
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1102
      case (Suc m)
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1103
      have b: "l \<approx> r" by fact
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1104
      have d: "card_list l = Suc m" by fact
39996
c02078ff8691 FSet: definition changes propagated from Nominal and more use of 'descending' tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 39995
diff changeset
  1105
      then have "\<exists>a. memb a l" 
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1106
	apply(simp)
39996
c02078ff8691 FSet: definition changes propagated from Nominal and more use of 'descending' tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 39995
diff changeset
  1107
	apply(drule card_eq_SucD)
c02078ff8691 FSet: definition changes propagated from Nominal and more use of 'descending' tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 39995
diff changeset
  1108
	apply(blast)
c02078ff8691 FSet: definition changes propagated from Nominal and more use of 'descending' tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 39995
diff changeset
  1109
	done
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1110
      then obtain a where e: "memb a l" by auto
40467
dc0439fdd7c5 more appropriate specification packages; fun_rel_def is no simp rule by default
haftmann
parents: 40034
diff changeset
  1111
      then have e': "memb a r" using list_eq_def [simplified memb_def [symmetric], of l r] b 
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1112
	by auto
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1113
      have f: "card_list (removeAll a l) = m" using e d by (simp)
39996
c02078ff8691 FSet: definition changes propagated from Nominal and more use of 'descending' tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 39995
diff changeset
  1114
      have g: "removeAll a l \<approx> removeAll a r" using removeAll_rsp b by simp
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1115
      have "(removeAll a l) \<approx>2 (removeAll a r)" by (rule Suc.hyps[OF f g])
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1116
      then have h: "(a # removeAll a l) \<approx>2 (a # removeAll a r)" by (rule list_eq2.intros(5))
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1117
      have i: "l \<approx>2 (a # removeAll a l)"	
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1118
        by (rule list_eq2.intros(3)[OF memb_delete_list_eq2[OF e]])
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1119
      have "l \<approx>2 (a # removeAll a r)" by (rule list_eq2.intros(6)[OF i h])
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1120
      then show ?case using list_eq2.intros(6)[OF _ memb_delete_list_eq2[OF e']] by simp
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1121
    qed
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1122
    }
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1123
  then show "l \<approx> r \<Longrightarrow> l \<approx>2 r" by blast
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1124
qed
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1125
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1126
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1127
(* We cannot write it as "assumes .. shows" since Isabelle changes
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1128
   the quantifiers to schematic variables and reintroduces them in
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1129
   a different order *)
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1130
lemma fset_eq_cases:
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1131
 "\<lbrakk>a1 = a2;
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1132
   \<And>a b xs. \<lbrakk>a1 = insert_fset a (insert_fset b xs); a2 = insert_fset b (insert_fset a xs)\<rbrakk> \<Longrightarrow> P;
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1133
   \<lbrakk>a1 = {||}; a2 = {||}\<rbrakk> \<Longrightarrow> P; \<And>xs ys. \<lbrakk>a1 = ys; a2 = xs; xs = ys\<rbrakk> \<Longrightarrow> P;
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1134
   \<And>a xs. \<lbrakk>a1 = insert_fset a (insert_fset a xs); a2 = insert_fset a xs\<rbrakk> \<Longrightarrow> P;
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1135
   \<And>xs ys a. \<lbrakk>a1 = insert_fset a xs; a2 = insert_fset a ys; xs = ys\<rbrakk> \<Longrightarrow> P;
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1136
   \<And>xs1 xs2 xs3. \<lbrakk>a1 = xs1; a2 = xs3; xs1 = xs2; xs2 = xs3\<rbrakk> \<Longrightarrow> P\<rbrakk>
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1137
  \<Longrightarrow> P"
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1138
  by (lifting list_eq2.cases[simplified list_eq2_equiv[symmetric]])
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1139
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1140
lemma fset_eq_induct:
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1141
  assumes "x1 = x2"
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1142
  and "\<And>a b xs. P (insert_fset a (insert_fset b xs)) (insert_fset b (insert_fset a xs))"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1143
  and "P {||} {||}"
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1144
  and "\<And>xs ys. \<lbrakk>xs = ys; P xs ys\<rbrakk> \<Longrightarrow> P ys xs"
40030
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1145
  and "\<And>a xs. P (insert_fset a (insert_fset a xs)) (insert_fset a xs)"
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1146
  and "\<And>xs ys a. \<lbrakk>xs = ys; P xs ys\<rbrakk> \<Longrightarrow> P (insert_fset a xs) (insert_fset a ys)"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1147
  and "\<And>xs1 xs2 xs3. \<lbrakk>xs1 = xs2; P xs1 xs2; xs2 = xs3; P xs2 xs3\<rbrakk> \<Longrightarrow> P xs1 xs3"
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1148
  shows "P x1 x2"
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1149
  using assms
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1150
  by (lifting list_eq2.induct[simplified list_eq2_equiv[symmetric]])
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1151
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1152
ML {*
36465
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
  1153
fun dest_fsetT (Type (@{type_name fset}, [T])) = T
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1154
  | dest_fsetT T = raise TYPE ("dest_fsetT: fset type expected", [T], []);
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1155
*}
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1156
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1157
no_notation
40034
Christian Urban <urbanc@in.tum.de>
parents: 40030
diff changeset
  1158
  list_eq (infix "\<approx>" 50) and 
Christian Urban <urbanc@in.tum.de>
parents: 40030
diff changeset
  1159
  list_eq2 (infix "\<approx>2" 50)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1160
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1161
end