src/HOL/Quotient_Examples/Quotient_FSet.thy
author nipkow
Wed, 06 Jun 2018 11:12:37 +0200
changeset 68386 98cf1c823c48
parent 68249 949d93804740
child 69597 ff784d5a5bfb
permissions -rw-r--r--
Keep filter input syntax
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
63920
003622e08379 resolve the name clash of HOL/Library/FSet and HOL/Quotient_Examples/FSet
kuncar
parents: 63167
diff changeset
     1
(*  Title:      HOL/Quotient_Examples/Quotient_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
41467
8fc17c5e11c0 tuned headers;
wenzelm
parents: 41413
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
54336
9a21e5c6e5d9 declare Quotient_Examples/FSet.thy as almost obsolete
kuncar
parents: 53374
diff changeset
     8
(********************************************************************
9a21e5c6e5d9 declare Quotient_Examples/FSet.thy as almost obsolete
kuncar
parents: 53374
diff changeset
     9
  WARNING: There is a formalization of 'a fset as a subtype of sets in
9a21e5c6e5d9 declare Quotient_Examples/FSet.thy as almost obsolete
kuncar
parents: 53374
diff changeset
    10
  HOL/Library/FSet.thy using Lifting/Transfer. The user should use
9a21e5c6e5d9 declare Quotient_Examples/FSet.thy as almost obsolete
kuncar
parents: 53374
diff changeset
    11
  that file rather than this file unless there are some very specific
9a21e5c6e5d9 declare Quotient_Examples/FSet.thy as almost obsolete
kuncar
parents: 53374
diff changeset
    12
  reasons.
9a21e5c6e5d9 declare Quotient_Examples/FSet.thy as almost obsolete
kuncar
parents: 53374
diff changeset
    13
*********************************************************************)
9a21e5c6e5d9 declare Quotient_Examples/FSet.thy as almost obsolete
kuncar
parents: 53374
diff changeset
    14
63920
003622e08379 resolve the name clash of HOL/Library/FSet and HOL/Quotient_Examples/FSet
kuncar
parents: 63167
diff changeset
    15
theory Quotient_FSet
66453
cc19f7ca2ed6 session-qualified theory imports: isabelle imports -U -i -d '~~/src/Benchmarks' -a;
wenzelm
parents: 63920
diff changeset
    16
imports "HOL-Library.Multiset" "HOL-Library.Quotient_List"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    17
begin
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    18
63167
0909deb8059b isabelle update_cartouches -c -t;
wenzelm
parents: 60515
diff changeset
    19
text \<open>
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
    20
  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
    21
  over lists. The definition of the equivalence:
63167
0909deb8059b isabelle update_cartouches -c -t;
wenzelm
parents: 60515
diff changeset
    22
\<close>
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    23
40467
dc0439fdd7c5 more appropriate specification packages; fun_rel_def is no simp rule by default
haftmann
parents: 40034
diff changeset
    24
definition
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    25
  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
    26
where
40952
580b1a30994c explicit type constraint;
haftmann
parents: 40822
diff changeset
    27
  [simp]: "xs \<approx> ys \<longleftrightarrow> set xs = set ys"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    28
40822
98a5faa5aec0 adaptions to changes in Equiv_Relation.thy
haftmann
parents: 40688
diff changeset
    29
lemma list_eq_reflp:
98a5faa5aec0 adaptions to changes in Equiv_Relation.thy
haftmann
parents: 40688
diff changeset
    30
  "reflp list_eq"
98a5faa5aec0 adaptions to changes in Equiv_Relation.thy
haftmann
parents: 40688
diff changeset
    31
  by (auto intro: reflpI)
98a5faa5aec0 adaptions to changes in Equiv_Relation.thy
haftmann
parents: 40688
diff changeset
    32
98a5faa5aec0 adaptions to changes in Equiv_Relation.thy
haftmann
parents: 40688
diff changeset
    33
lemma list_eq_symp:
98a5faa5aec0 adaptions to changes in Equiv_Relation.thy
haftmann
parents: 40688
diff changeset
    34
  "symp list_eq"
98a5faa5aec0 adaptions to changes in Equiv_Relation.thy
haftmann
parents: 40688
diff changeset
    35
  by (auto intro: sympI)
98a5faa5aec0 adaptions to changes in Equiv_Relation.thy
haftmann
parents: 40688
diff changeset
    36
98a5faa5aec0 adaptions to changes in Equiv_Relation.thy
haftmann
parents: 40688
diff changeset
    37
lemma list_eq_transp:
98a5faa5aec0 adaptions to changes in Equiv_Relation.thy
haftmann
parents: 40688
diff changeset
    38
  "transp list_eq"
98a5faa5aec0 adaptions to changes in Equiv_Relation.thy
haftmann
parents: 40688
diff changeset
    39
  by (auto intro: transpI)
98a5faa5aec0 adaptions to changes in Equiv_Relation.thy
haftmann
parents: 40688
diff changeset
    40
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    41
lemma list_eq_equivp:
40822
98a5faa5aec0 adaptions to changes in Equiv_Relation.thy
haftmann
parents: 40688
diff changeset
    42
  "equivp list_eq"
98a5faa5aec0 adaptions to changes in Equiv_Relation.thy
haftmann
parents: 40688
diff changeset
    43
  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
    44
63167
0909deb8059b isabelle update_cartouches -c -t;
wenzelm
parents: 60515
diff changeset
    45
text \<open>The \<open>fset\<close> type\<close>
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
    46
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    47
quotient_type
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    48
  'a fset = "'a list" / "list_eq"
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    49
  by (rule list_eq_equivp)
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    50
63167
0909deb8059b isabelle update_cartouches -c -t;
wenzelm
parents: 60515
diff changeset
    51
text \<open>
40953
d13bcb42e479 replaced memb by existing List.member
haftmann
parents: 40952
diff changeset
    52
  Definitions for sublist, cardinality, 
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
    53
  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
    54
  lists.
63167
0909deb8059b isabelle update_cartouches -c -t;
wenzelm
parents: 60515
diff changeset
    55
\<close>
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    56
40953
d13bcb42e479 replaced memb by existing List.member
haftmann
parents: 40952
diff changeset
    57
declare List.member_def [simp]
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    58
40034
Christian Urban <urbanc@in.tum.de>
parents: 40030
diff changeset
    59
definition
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    60
  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
    61
where 
40034
Christian Urban <urbanc@in.tum.de>
parents: 40030
diff changeset
    62
  [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
    63
40034
Christian Urban <urbanc@in.tum.de>
parents: 40030
diff changeset
    64
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
    65
  card_list :: "'a list \<Rightarrow> nat"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    66
where
40034
Christian Urban <urbanc@in.tum.de>
parents: 40030
diff changeset
    67
  [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
    68
40034
Christian Urban <urbanc@in.tum.de>
parents: 40030
diff changeset
    69
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
    70
  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
    71
where
68386
98cf1c823c48 Keep filter input syntax
nipkow
parents: 68249
diff changeset
    72
  [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
    73
40034
Christian Urban <urbanc@in.tum.de>
parents: 40030
diff changeset
    74
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
    75
  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
    76
where
68386
98cf1c823c48 Keep filter input syntax
nipkow
parents: 68249
diff changeset
    77
  [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
    78
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    79
definition
40954
ecca598474dd conventional point-free characterization of rsp_fold
haftmann
parents: 40953
diff changeset
    80
  rsp_fold :: "('a \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> bool"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    81
where
40954
ecca598474dd conventional point-free characterization of rsp_fold
haftmann
parents: 40953
diff changeset
    82
  "rsp_fold f \<longleftrightarrow> (\<forall>u v. f u \<circ> f v = f v \<circ> f u)"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    83
40961
3afec5adee35 canonical fold signature
haftmann
parents: 40954
diff changeset
    84
lemma rsp_foldI:
3afec5adee35 canonical fold signature
haftmann
parents: 40954
diff changeset
    85
  "(\<And>u v. f u \<circ> f v = f v \<circ> f u) \<Longrightarrow> rsp_fold f"
3afec5adee35 canonical fold signature
haftmann
parents: 40954
diff changeset
    86
  by (simp add: rsp_fold_def)
3afec5adee35 canonical fold signature
haftmann
parents: 40954
diff changeset
    87
3afec5adee35 canonical fold signature
haftmann
parents: 40954
diff changeset
    88
lemma rsp_foldE:
3afec5adee35 canonical fold signature
haftmann
parents: 40954
diff changeset
    89
  assumes "rsp_fold f"
3afec5adee35 canonical fold signature
haftmann
parents: 40954
diff changeset
    90
  obtains "f u \<circ> f v = f v \<circ> f u"
3afec5adee35 canonical fold signature
haftmann
parents: 40954
diff changeset
    91
  using assms by (simp add: rsp_fold_def)
3afec5adee35 canonical fold signature
haftmann
parents: 40954
diff changeset
    92
40962
069cd1c1f39b more intimate definition of fold_list / fold_once in terms of fold
haftmann
parents: 40961
diff changeset
    93
definition
069cd1c1f39b more intimate definition of fold_list / fold_once in terms of fold
haftmann
parents: 40961
diff changeset
    94
  fold_once :: "('a \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> 'a list \<Rightarrow> 'b \<Rightarrow> 'b"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    95
where
40962
069cd1c1f39b more intimate definition of fold_list / fold_once in terms of fold
haftmann
parents: 40961
diff changeset
    96
  "fold_once f xs = (if rsp_fold f then fold f (remdups xs) else id)"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    97
40962
069cd1c1f39b more intimate definition of fold_list / fold_once in terms of fold
haftmann
parents: 40961
diff changeset
    98
lemma fold_once_default [simp]:
069cd1c1f39b more intimate definition of fold_list / fold_once in terms of fold
haftmann
parents: 40961
diff changeset
    99
  "\<not> rsp_fold f \<Longrightarrow> fold_once f xs = id"
069cd1c1f39b more intimate definition of fold_list / fold_once in terms of fold
haftmann
parents: 40961
diff changeset
   100
  by (simp add: fold_once_def)
40961
3afec5adee35 canonical fold signature
haftmann
parents: 40954
diff changeset
   101
40962
069cd1c1f39b more intimate definition of fold_list / fold_once in terms of fold
haftmann
parents: 40961
diff changeset
   102
lemma fold_once_fold_remdups:
069cd1c1f39b more intimate definition of fold_list / fold_once in terms of fold
haftmann
parents: 40961
diff changeset
   103
  "rsp_fold f \<Longrightarrow> fold_once f xs = fold f (remdups xs)"
069cd1c1f39b more intimate definition of fold_list / fold_once in terms of fold
haftmann
parents: 40961
diff changeset
   104
  by (simp add: fold_once_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
   105
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   106
63167
0909deb8059b isabelle update_cartouches -c -t;
wenzelm
parents: 60515
diff changeset
   107
section \<open>Quotient composition lemmas\<close>
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   108
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
   109
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
   110
  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
   111
  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
   112
  by (rule list_all2_refl) (metis equivp_def q)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   113
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   114
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
   115
  assumes q: "equivp R"
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 66453
diff changeset
   116
  shows "(list_all2 R OOO (\<approx>)) r r"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   117
proof
36465
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
   118
  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
   119
  show "list_all2 R r r" by (rule list_all2_refl'[OF q])
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 66453
diff changeset
   120
  with * show "((\<approx>) OO list_all2 R) r r" ..
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   121
qed
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   122
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
   123
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
   124
  by (simp only: list_eq_def set_map)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   125
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
   126
lemma quotient_compose_list_g:
47308
9caab698dbe4 new package Lifting - initial commit
kuncar
parents: 47198
diff changeset
   127
  assumes q: "Quotient3 R Abs Rep"
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
   128
  and     e: "equivp R"
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 66453
diff changeset
   129
  shows  "Quotient3 ((list_all2 R) OOO (\<approx>))
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
   130
    (abs_fset \<circ> (map Abs)) ((map Rep) \<circ> rep_fset)"
47308
9caab698dbe4 new package Lifting - initial commit
kuncar
parents: 47198
diff changeset
   131
  unfolding Quotient3_def comp_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
   132
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
   133
  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
   134
  show "abs_fset (map Abs (map Rep (rep_fset a))) = a"
47308
9caab698dbe4 new package Lifting - initial commit
kuncar
parents: 47198
diff changeset
   135
    by (simp add: abs_o_rep[OF q] Quotient3_abs_rep[OF Quotient3_fset] List.map.id)
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
   136
  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
   137
    by (rule list_all2_refl'[OF e])
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 66453
diff changeset
   138
  have c: "((\<approx>) OO list_all2 R) (map Rep (rep_fset a)) (map Rep (rep_fset 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
   139
    by (rule, rule equivp_reflp[OF fset_equivp]) (rule b)
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 66453
diff changeset
   140
  show "(list_all2 R OOO (\<approx>)) (map Rep (rep_fset a)) (map Rep (rep_fset 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
   141
    by (rule, rule list_all2_refl'[OF e]) (rule c)
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 66453
diff changeset
   142
  show "(list_all2 R OOO (\<approx>)) r s = ((list_all2 R OOO (\<approx>)) r r \<and>
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 66453
diff changeset
   143
        (list_all2 R OOO (\<approx>)) s s \<and> abs_fset (map Abs r) = abs_fset (map Abs s))"
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
   144
  proof (intro iffI conjI)
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 66453
diff changeset
   145
    show "(list_all2 R OOO (\<approx>)) r r" by (rule compose_list_refl[OF e])
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 66453
diff changeset
   146
    show "(list_all2 R OOO (\<approx>)) s s" by (rule compose_list_refl[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
   147
  next
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 66453
diff changeset
   148
    assume a: "(list_all2 R OOO (\<approx>)) r s"
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
   149
    then have b: "map Abs r \<approx> map Abs s"
47434
b75ce48a93ee dropped abbreviation "pred_comp"; introduced infix notation "P OO Q" for "relcompp P Q"
griff
parents: 47198
diff changeset
   150
    proof (elim relcomppE)
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
   151
      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
   152
      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
   153
      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
   154
      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
   155
      have f: "map Abs r = map Abs b"
47308
9caab698dbe4 new package Lifting - initial commit
kuncar
parents: 47198
diff changeset
   156
        using Quotient3_rel[OF list_quotient3[OF q]] c by 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
   157
      have "map Abs ba = map Abs s"
47308
9caab698dbe4 new package Lifting - initial commit
kuncar
parents: 47198
diff changeset
   158
        using Quotient3_rel[OF list_quotient3[OF q]] e by 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
   159
      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
   160
      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
   161
    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
   162
    then show "abs_fset (map Abs r) = abs_fset (map Abs s)"
47308
9caab698dbe4 new package Lifting - initial commit
kuncar
parents: 47198
diff changeset
   163
      using Quotient3_rel[OF Quotient3_fset] by 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
   164
  next
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 66453
diff changeset
   165
    assume a: "(list_all2 R OOO (\<approx>)) r r \<and> (list_all2 R OOO (\<approx>)) s s
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
   166
      \<and> abs_fset (map Abs r) = abs_fset (map Abs s)"
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 66453
diff changeset
   167
    then have s: "(list_all2 R OOO (\<approx>)) s s" 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
   168
    have d: "map Abs r \<approx> map Abs s"
47308
9caab698dbe4 new package Lifting - initial commit
kuncar
parents: 47198
diff changeset
   169
      by (subst Quotient3_rel [OF Quotient3_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
   170
    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
   171
      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
   172
    have y: "list_all2 R (map Rep (map Abs s)) s"
47308
9caab698dbe4 new package Lifting - initial commit
kuncar
parents: 47198
diff changeset
   173
      by (fact rep_abs_rsp_left[OF list_quotient3[OF q], OF list_all2_refl'[OF e, of s]])
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 66453
diff changeset
   174
    have c: "((\<approx>) OO list_all2 R) (map Rep (map Abs r)) s"
47434
b75ce48a93ee dropped abbreviation "pred_comp"; introduced infix notation "P OO Q" for "relcompp P Q"
griff
parents: 47198
diff changeset
   175
      by (rule relcomppI) (rule b, rule y)
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
   176
    have z: "list_all2 R r (map Rep (map Abs r))"
47308
9caab698dbe4 new package Lifting - initial commit
kuncar
parents: 47198
diff changeset
   177
      by (fact rep_abs_rsp[OF list_quotient3[OF q], OF list_all2_refl'[OF e, of r]])
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 66453
diff changeset
   178
    then show "(list_all2 R OOO (\<approx>)) r s"
47434
b75ce48a93ee dropped abbreviation "pred_comp"; introduced infix notation "P OO Q" for "relcompp P Q"
griff
parents: 47198
diff changeset
   179
      using a c relcomppI 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
   180
  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
   181
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
   182
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   183
lemma quotient_compose_list[quot_thm]:
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 66453
diff changeset
   184
  shows  "Quotient3 ((list_all2 (\<approx>)) OOO (\<approx>))
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   185
    (abs_fset \<circ> (map abs_fset)) ((map rep_fset) \<circ> rep_fset)"
47308
9caab698dbe4 new package Lifting - initial commit
kuncar
parents: 47198
diff changeset
   186
  by (rule quotient_compose_list_g, rule Quotient3_fset, rule list_eq_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
   187
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   188
63167
0909deb8059b isabelle update_cartouches -c -t;
wenzelm
parents: 60515
diff changeset
   189
section \<open>Quotient definitions for fsets\<close>
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
   190
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   191
63167
0909deb8059b isabelle update_cartouches -c -t;
wenzelm
parents: 60515
diff changeset
   192
subsection \<open>Finite sets are a bounded, distributive lattice with minus\<close>
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   193
37634
2116425cebc8 cleaned by using descending instead of lifting
Christian Urban <urbanc@in.tum.de>
parents: 37492
diff changeset
   194
instantiation fset :: (type) "{bounded_lattice_bot, distrib_lattice, minus}"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   195
begin
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   196
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   197
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
   198
  "bot :: 'a fset" 
47092
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   199
  is "Nil :: 'a list" done
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   200
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   201
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
   202
  empty_fset  ("{||}")
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   203
where
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   204
  "{||} \<equiv> bot :: 'a fset"
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   205
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   206
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
   207
  "less_eq_fset :: ('a fset \<Rightarrow> 'a fset \<Rightarrow> bool)"
47092
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   208
  is "sub_list :: ('a list \<Rightarrow> 'a list \<Rightarrow> bool)" by simp
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   209
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   210
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
   211
  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
   212
where
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   213
  "xs |\<subseteq>| ys \<equiv> xs \<le> ys"
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   214
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   215
definition
39995
849578dd6127 FSet tuned
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 39994
diff changeset
   216
  less_fset :: "'a fset \<Rightarrow> 'a fset \<Rightarrow> bool"
849578dd6127 FSet tuned
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 39994
diff changeset
   217
where  
849578dd6127 FSet tuned
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 39994
diff changeset
   218
  "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
   219
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   220
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
   221
  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
   222
where
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   223
  "xs |\<subset>| ys \<equiv> xs < ys"
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   224
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   225
quotient_definition
39995
849578dd6127 FSet tuned
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 39994
diff changeset
   226
  "sup :: 'a fset \<Rightarrow> 'a fset \<Rightarrow> 'a fset"
47092
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   227
  is "append :: 'a list \<Rightarrow> 'a list \<Rightarrow> 'a list" by simp
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   228
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   229
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
   230
  union_fset (infixl "|\<union>|" 65)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   231
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
   232
  "xs |\<union>| ys \<equiv> sup xs (ys::'a fset)"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   233
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   234
quotient_definition
39995
849578dd6127 FSet tuned
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 39994
diff changeset
   235
  "inf :: 'a fset \<Rightarrow> 'a fset \<Rightarrow> 'a fset"
47092
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   236
  is "inter_list :: 'a list \<Rightarrow> 'a list \<Rightarrow> 'a list" by simp
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   237
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   238
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
   239
  inter_fset (infixl "|\<inter>|" 65)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   240
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
   241
  "xs |\<inter>| ys \<equiv> inf xs (ys::'a fset)"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   242
36675
806ea6e282e4 fminus and some more theorems ported from Finite_Set.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36646
diff changeset
   243
quotient_definition
37634
2116425cebc8 cleaned by using descending instead of lifting
Christian Urban <urbanc@in.tum.de>
parents: 37492
diff changeset
   244
  "minus :: 'a fset \<Rightarrow> 'a fset \<Rightarrow> 'a fset"
47092
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   245
  is "diff_list :: 'a list \<Rightarrow> 'a list \<Rightarrow> 'a list" by fastforce
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
   246
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   247
instance
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   248
proof
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   249
  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
   250
  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
   251
    by (unfold less_fset_def, descending) auto
46441
992a1688303f Generalize the compositional preservation theorems
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 46416
diff changeset
   252
  show "x |\<subseteq>| x" by (descending) (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
   253
  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
   254
  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
   255
  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
   256
  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
   257
  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
   258
  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
   259
    by (descending) (auto)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   260
next
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   261
  fix x y z :: "'a fset"
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   262
  assume a: "x |\<subseteq>| y"
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   263
  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
   264
  show "x |\<subseteq>| z" using a b by (descending) (simp)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   265
next
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   266
  fix x y :: "'a fset"
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   267
  assume a: "x |\<subseteq>| y"
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   268
  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
   269
  show "x = y" using a b by (descending) (auto)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   270
next
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   271
  fix x y z :: "'a fset"
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   272
  assume a: "y |\<subseteq>| x"
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   273
  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
   274
  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
   275
next
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   276
  fix x y z :: "'a fset"
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   277
  assume a: "x |\<subseteq>| y"
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   278
  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
   279
  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
   280
qed
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   281
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   282
end
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   283
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
   284
63167
0909deb8059b isabelle update_cartouches -c -t;
wenzelm
parents: 60515
diff changeset
   285
subsection \<open>Other constants for fsets\<close>
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   286
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   287
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
   288
  "insert_fset :: 'a \<Rightarrow> 'a fset \<Rightarrow> 'a fset"
47092
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   289
  is "Cons" by auto
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   290
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   291
syntax
45343
873e9c0ca37d more conventional syntax const;
wenzelm
parents: 45129
diff changeset
   292
  "_insert_fset"     :: "args => 'a fset"  ("{|(_)|}")
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   293
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   294
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
   295
  "{|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
   296
  "{|x|}"     == "CONST insert_fset x {||}"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   297
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   298
quotient_definition
40953
d13bcb42e479 replaced memb by existing List.member
haftmann
parents: 40952
diff changeset
   299
  fset_member
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   300
where
47092
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   301
  "fset_member :: 'a fset \<Rightarrow> 'a \<Rightarrow> bool" is "List.member" by fastforce
40953
d13bcb42e479 replaced memb by existing List.member
haftmann
parents: 40952
diff changeset
   302
d13bcb42e479 replaced memb by existing List.member
haftmann
parents: 40952
diff changeset
   303
abbreviation
d13bcb42e479 replaced memb by existing List.member
haftmann
parents: 40952
diff changeset
   304
  in_fset :: "'a \<Rightarrow> 'a fset \<Rightarrow> bool" (infix "|\<in>|" 50)
d13bcb42e479 replaced memb by existing List.member
haftmann
parents: 40952
diff changeset
   305
where
d13bcb42e479 replaced memb by existing List.member
haftmann
parents: 40952
diff changeset
   306
  "x |\<in>| S \<equiv> fset_member S x"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   307
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   308
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
   309
  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
   310
where
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   311
  "x |\<notin>| S \<equiv> \<not> (x |\<in>| S)"
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   312
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
   313
63167
0909deb8059b isabelle update_cartouches -c -t;
wenzelm
parents: 60515
diff changeset
   314
subsection \<open>Other constants on the Quotient Type\<close>
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   315
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   316
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
   317
  "card_fset :: 'a fset \<Rightarrow> nat"
47092
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   318
  is card_list by simp
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   319
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   320
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
   321
  "map_fset :: ('a \<Rightarrow> 'b) \<Rightarrow> 'a fset \<Rightarrow> 'b fset"
47092
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   322
  is map by simp
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   323
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   324
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
   325
  "remove_fset :: 'a \<Rightarrow> 'a fset \<Rightarrow> 'a fset"
47092
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   326
  is removeAll by simp
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   327
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   328
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
   329
  "fset :: 'a fset \<Rightarrow> 'a set"
47092
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   330
  is "set" by simp
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   331
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   332
lemma fold_once_set_equiv:
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   333
  assumes "xs \<approx> ys"
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   334
  shows "fold_once f xs = fold_once f ys"
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   335
proof (cases "rsp_fold f")
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   336
  case False then show ?thesis by simp
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   337
next
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   338
  case True
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   339
  then have "\<And>x y. x \<in> set (remdups xs) \<Longrightarrow> y \<in> set (remdups xs) \<Longrightarrow> f x \<circ> f y = f y \<circ> f x"
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   340
    by (rule rsp_foldE)
60515
484559628038 renamed multiset_of -> mset
nipkow
parents: 57816
diff changeset
   341
  moreover from assms have "mset (remdups xs) = mset (remdups ys)"
484559628038 renamed multiset_of -> mset
nipkow
parents: 57816
diff changeset
   342
    by (simp add: set_eq_iff_mset_remdups_eq)
47092
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   343
  ultimately have "fold f (remdups xs) = fold f (remdups ys)"
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   344
    by (rule fold_multiset_equiv)
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   345
  with True show ?thesis by (simp add: fold_once_fold_remdups)
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   346
qed
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   347
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   348
quotient_definition
40961
3afec5adee35 canonical fold signature
haftmann
parents: 40954
diff changeset
   349
  "fold_fset :: ('a \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> 'a fset \<Rightarrow> 'b \<Rightarrow> 'b"
47092
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   350
  is fold_once by (rule fold_once_set_equiv)
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   351
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   352
lemma concat_rsp_pre:
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 66453
diff changeset
   353
  assumes a: "list_all2 (\<approx>) x x'"
47092
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   354
  and     b: "x' \<approx> y'"
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 66453
diff changeset
   355
  and     c: "list_all2 (\<approx>) y' y"
47092
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   356
  and     d: "\<exists>x\<in>set x. xa \<in> set x"
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   357
  shows "\<exists>x\<in>set y. xa \<in> set x"
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   358
proof -
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   359
  obtain xb where e: "xb \<in> set x" and f: "xa \<in> set xb" using d by auto
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   360
  have "\<exists>y. y \<in> set x' \<and> xb \<approx> y" by (rule list_all2_find_element[OF e a])
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   361
  then obtain ya where h: "ya \<in> set x'" and i: "xb \<approx> ya" by auto
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   362
  have "ya \<in> set y'" using b h by simp
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   363
  then have "\<exists>yb. yb \<in> set y \<and> ya \<approx> yb" using c by (rule list_all2_find_element)
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   364
  then show ?thesis using f i by auto
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   365
qed
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   366
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   367
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
   368
  "concat_fset :: ('a fset) fset \<Rightarrow> 'a fset"
47092
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   369
  is concat 
47434
b75ce48a93ee dropped abbreviation "pred_comp"; introduced infix notation "P OO Q" for "relcompp P Q"
griff
parents: 47198
diff changeset
   370
proof (elim relcomppE)
47092
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   371
fix a b ba bb
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 66453
diff changeset
   372
  assume a: "list_all2 (\<approx>) a ba"
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 66453
diff changeset
   373
  with list_symp [OF list_eq_symp] have a': "list_all2 (\<approx>) ba a" by (rule sympE)
47092
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   374
  assume b: "ba \<approx> bb"
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   375
  with list_eq_symp have b': "bb \<approx> ba" by (rule sympE)
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 66453
diff changeset
   376
  assume c: "list_all2 (\<approx>) bb b"
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 66453
diff changeset
   377
  with list_symp [OF list_eq_symp] have c': "list_all2 (\<approx>) b bb" by (rule sympE)
47092
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   378
  have "\<forall>x. (\<exists>xa\<in>set a. x \<in> set xa) = (\<exists>xa\<in>set b. x \<in> set xa)" 
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   379
  proof
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   380
    fix x
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   381
    show "(\<exists>xa\<in>set a. x \<in> set xa) = (\<exists>xa\<in>set b. x \<in> set xa)" 
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   382
    proof
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   383
      assume d: "\<exists>xa\<in>set a. x \<in> set xa"
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   384
      show "\<exists>xa\<in>set b. x \<in> set xa" by (rule concat_rsp_pre[OF a b c d])
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   385
    next
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   386
      assume e: "\<exists>xa\<in>set b. x \<in> set xa"
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   387
      show "\<exists>xa\<in>set a. x \<in> set xa" by (rule concat_rsp_pre[OF c' b' a' e])
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   388
    qed
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   389
  qed
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   390
  then show "concat a \<approx> concat b" by auto
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   391
qed
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   392
36639
6243b49498ea added function ffilter and some lemmas from Finite_Set to the FSet theory
bulwahn
parents: 36524
diff changeset
   393
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
   394
  "filter_fset :: ('a \<Rightarrow> bool) \<Rightarrow> 'a fset \<Rightarrow> 'a fset"
47092
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   395
  is filter by force
36639
6243b49498ea added function ffilter and some lemmas from Finite_Set to the FSet theory
bulwahn
parents: 36524
diff changeset
   396
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
   397
63167
0909deb8059b isabelle update_cartouches -c -t;
wenzelm
parents: 60515
diff changeset
   398
subsection \<open>Compositional respectfulness and preservation lemmas\<close>
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   399
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
lemma Nil_rsp2 [quot_respect]: 
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 66453
diff changeset
   401
  shows "(list_all2 (\<approx>) OOO (\<approx>)) Nil Nil"
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
   402
  by (rule compose_list_refl, rule list_eq_equivp)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   403
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
lemma Cons_rsp2 [quot_respect]:
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 66453
diff changeset
   405
  shows "((\<approx>) ===> list_all2 (\<approx>) OOO (\<approx>) ===> list_all2 (\<approx>) OOO (\<approx>)) Cons Cons"
55945
e96383acecf9 renamed 'fun_rel' to 'rel_fun'
blanchet
parents: 55584
diff changeset
   406
  apply (auto intro!: rel_funI)
47434
b75ce48a93ee dropped abbreviation "pred_comp"; introduced infix notation "P OO Q" for "relcompp P Q"
griff
parents: 47198
diff changeset
   407
  apply (rule_tac b="x # b" in relcomppI)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   408
  apply auto
47434
b75ce48a93ee dropped abbreviation "pred_comp"; introduced infix notation "P OO Q" for "relcompp P Q"
griff
parents: 47198
diff changeset
   409
  apply (rule_tac b="x # ba" in relcomppI)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   410
  apply auto
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   411
  done
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   412
46441
992a1688303f Generalize the compositional preservation theorems
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 46416
diff changeset
   413
lemma Nil_prs2 [quot_preserve]:
47308
9caab698dbe4 new package Lifting - initial commit
kuncar
parents: 47198
diff changeset
   414
  assumes "Quotient3 R Abs Rep"
46441
992a1688303f Generalize the compositional preservation theorems
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 46416
diff changeset
   415
  shows "(Abs \<circ> map f) [] = Abs []"
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
  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
   417
46441
992a1688303f Generalize the compositional preservation theorems
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 46416
diff changeset
   418
lemma Cons_prs2 [quot_preserve]:
47308
9caab698dbe4 new package Lifting - initial commit
kuncar
parents: 47198
diff changeset
   419
  assumes q: "Quotient3 R1 Abs1 Rep1"
9caab698dbe4 new package Lifting - initial commit
kuncar
parents: 47198
diff changeset
   420
  and     r: "Quotient3 R2 Abs2 Rep2"
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 66453
diff changeset
   421
  shows "(Rep1 ---> (map Rep1 \<circ> Rep2) ---> (Abs2 \<circ> map Abs1)) (#) = (id ---> Rep2 ---> Abs2) (#)"
47308
9caab698dbe4 new package Lifting - initial commit
kuncar
parents: 47198
diff changeset
   422
  by (auto simp add: fun_eq_iff comp_def Quotient3_abs_rep [OF q])
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   423
46441
992a1688303f Generalize the compositional preservation theorems
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 46416
diff changeset
   424
lemma append_prs2 [quot_preserve]:
47308
9caab698dbe4 new package Lifting - initial commit
kuncar
parents: 47198
diff changeset
   425
  assumes q: "Quotient3 R1 Abs1 Rep1"
9caab698dbe4 new package Lifting - initial commit
kuncar
parents: 47198
diff changeset
   426
  and     r: "Quotient3 R2 Abs2 Rep2"
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 66453
diff changeset
   427
  shows "((map Rep1 \<circ> Rep2) ---> (map Rep1 \<circ> Rep2) ---> (Abs2 \<circ> map Abs1)) (@) =
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 66453
diff changeset
   428
    (Rep2 ---> Rep2 ---> Abs2) (@)"
46663
7fe029e818c2 explicit is better than implicit
haftmann
parents: 46441
diff changeset
   429
  by (simp add: fun_eq_iff abs_o_rep[OF q] List.map.id)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   430
37492
ab36b1a50ca8 Replace 'list_rel' by 'list_all2'; they are equivalent.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36675
diff changeset
   431
lemma list_all2_app_l:
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   432
  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
   433
  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
   434
  shows "list_all2 R (z @ l) (z @ r)"
40822
98a5faa5aec0 adaptions to changes in Equiv_Relation.thy
haftmann
parents: 40688
diff changeset
   435
  using a b by (induct z) (auto elim: reflpE)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   436
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   437
lemma append_rsp2_pre0:
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 66453
diff changeset
   438
  assumes a:"list_all2 (\<approx>) x x'"
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 66453
diff changeset
   439
  shows "list_all2 (\<approx>) (x @ z) (x' @ z)"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   440
  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
   441
  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
   442
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   443
lemma append_rsp2_pre1:
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 66453
diff changeset
   444
  assumes a:"list_all2 (\<approx>) x x'"
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 66453
diff changeset
   445
  shows "list_all2 (\<approx>) (z @ x) (z @ x')"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   446
  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
   447
  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
   448
  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
   449
  apply (rule list_all2_app_l)
40822
98a5faa5aec0 adaptions to changes in Equiv_Relation.thy
haftmann
parents: 40688
diff changeset
   450
  apply (simp_all add: reflpI)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   451
  done
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   452
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   453
lemma append_rsp2_pre:
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 66453
diff changeset
   454
  assumes "list_all2 (\<approx>) x x'"
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 66453
diff changeset
   455
    and "list_all2 (\<approx>) z z'"
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 66453
diff changeset
   456
  shows "list_all2 (\<approx>) (x @ z) (x' @ z')"
40822
98a5faa5aec0 adaptions to changes in Equiv_Relation.thy
haftmann
parents: 40688
diff changeset
   457
  using assms by (rule list_all2_appendI)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   458
46441
992a1688303f Generalize the compositional preservation theorems
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 46416
diff changeset
   459
lemma compositional_rsp3:
992a1688303f Generalize the compositional preservation theorems
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 46416
diff changeset
   460
  assumes "(R1 ===> R2 ===> R3) C C" and "(R4 ===> R5 ===> R6) C C"
992a1688303f Generalize the compositional preservation theorems
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 46416
diff changeset
   461
  shows "(R1 OOO R4 ===> R2 OOO R5 ===> R3 OOO R6) C C"
55945
e96383acecf9 renamed 'fun_rel' to 'rel_fun'
blanchet
parents: 55584
diff changeset
   462
  by (auto intro!: rel_funI)
e96383acecf9 renamed 'fun_rel' to 'rel_fun'
blanchet
parents: 55584
diff changeset
   463
     (metis (full_types) assms rel_funE relcomppI)
46441
992a1688303f Generalize the compositional preservation theorems
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 46416
diff changeset
   464
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
   465
lemma append_rsp2 [quot_respect]:
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 66453
diff changeset
   466
  "(list_all2 (\<approx>) OOO (\<approx>) ===> list_all2 (\<approx>) OOO (\<approx>) ===> list_all2 (\<approx>) OOO (\<approx>)) append append"
47092
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   467
  by (intro compositional_rsp3)
55945
e96383acecf9 renamed 'fun_rel' to 'rel_fun'
blanchet
parents: 55584
diff changeset
   468
     (auto intro!: rel_funI simp add: append_rsp2_pre)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   469
46404
7736068b9f56 Quotient FSet: Add compositional respectfulness and preservation for map and lift map_concat
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 46133
diff changeset
   470
lemma map_rsp2 [quot_respect]:
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 66453
diff changeset
   471
  "(((\<approx>) ===> (\<approx>)) ===> list_all2 (\<approx>) OOO (\<approx>) ===> list_all2 (\<approx>) OOO (\<approx>)) map map"
55945
e96383acecf9 renamed 'fun_rel' to 'rel_fun'
blanchet
parents: 55584
diff changeset
   472
proof (auto intro!: rel_funI)
46404
7736068b9f56 Quotient FSet: Add compositional respectfulness and preservation for map and lift map_concat
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 46133
diff changeset
   473
  fix f f' :: "'a list \<Rightarrow> 'b list"
7736068b9f56 Quotient FSet: Add compositional respectfulness and preservation for map and lift map_concat
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 46133
diff changeset
   474
  fix xa ya x y :: "'a list list"
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 66453
diff changeset
   475
  assume fs: "((\<approx>) ===> (\<approx>)) f f'" and x: "list_all2 (\<approx>) xa x" and xy: "set x = set y" and y: "list_all2 (\<approx>) y ya"
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 66453
diff changeset
   476
  have a: "(list_all2 (\<approx>)) (map f xa) (map f x)"
46404
7736068b9f56 Quotient FSet: Add compositional respectfulness and preservation for map and lift map_concat
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 46133
diff changeset
   477
    using x
7736068b9f56 Quotient FSet: Add compositional respectfulness and preservation for map and lift map_concat
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 46133
diff changeset
   478
    by (induct xa x rule: list_induct2')
55945
e96383acecf9 renamed 'fun_rel' to 'rel_fun'
blanchet
parents: 55584
diff changeset
   479
       (simp_all, metis fs rel_funE list_eq_def)
46404
7736068b9f56 Quotient FSet: Add compositional respectfulness and preservation for map and lift map_concat
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 46133
diff changeset
   480
  have b: "set (map f x) = set (map f y)"
7736068b9f56 Quotient FSet: Add compositional respectfulness and preservation for map and lift map_concat
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 46133
diff changeset
   481
    using xy fs
7736068b9f56 Quotient FSet: Add compositional respectfulness and preservation for map and lift map_concat
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 46133
diff changeset
   482
    by (induct x y rule: list_induct2')
7736068b9f56 Quotient FSet: Add compositional respectfulness and preservation for map and lift map_concat
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 46133
diff changeset
   483
       (simp_all, metis image_insert)
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 66453
diff changeset
   484
  have c: "(list_all2 (\<approx>)) (map f y) (map f' ya)"
46404
7736068b9f56 Quotient FSet: Add compositional respectfulness and preservation for map and lift map_concat
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 46133
diff changeset
   485
    using y fs
7736068b9f56 Quotient FSet: Add compositional respectfulness and preservation for map and lift map_concat
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 46133
diff changeset
   486
    by (induct y ya rule: list_induct2')
7736068b9f56 Quotient FSet: Add compositional respectfulness and preservation for map and lift map_concat
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 46133
diff changeset
   487
       (simp_all, metis apply_rsp' list_eq_def)
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 66453
diff changeset
   488
  show "(list_all2 (\<approx>) OOO (\<approx>)) (map f xa) (map f' ya)"
47434
b75ce48a93ee dropped abbreviation "pred_comp"; introduced infix notation "P OO Q" for "relcompp P Q"
griff
parents: 47198
diff changeset
   489
    by (metis a b c list_eq_def relcomppI)
46404
7736068b9f56 Quotient FSet: Add compositional respectfulness and preservation for map and lift map_concat
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 46133
diff changeset
   490
qed
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
   491
46404
7736068b9f56 Quotient FSet: Add compositional respectfulness and preservation for map and lift map_concat
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 46133
diff changeset
   492
lemma map_prs2 [quot_preserve]:
46441
992a1688303f Generalize the compositional preservation theorems
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 46416
diff changeset
   493
  shows "((abs_fset ---> rep_fset) ---> (map rep_fset \<circ> rep_fset) ---> abs_fset \<circ> map abs_fset) map = (id ---> rep_fset ---> abs_fset) map"
992a1688303f Generalize the compositional preservation theorems
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 46416
diff changeset
   494
  by (auto simp add: fun_eq_iff)
47308
9caab698dbe4 new package Lifting - initial commit
kuncar
parents: 47198
diff changeset
   495
     (simp only: map_map[symmetric] map_prs_aux[OF Quotient3_fset Quotient3_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
   496
63167
0909deb8059b isabelle update_cartouches -c -t;
wenzelm
parents: 60515
diff changeset
   497
section \<open>Lifted theorems\<close>
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
63167
0909deb8059b isabelle update_cartouches -c -t;
wenzelm
parents: 60515
diff changeset
   499
subsection \<open>fset\<close>
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
   500
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   501
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
   502
  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
   503
  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
   504
  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
   505
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   506
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
   507
  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
   508
  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
   509
9f8dcf6ef563 reorganisation of 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 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
   511
  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
   512
  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
   513
44204
3cdc4176638c Quotient Package: make quotient_type work with separate set type
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 41467
diff changeset
   514
lemma filter_fset [simp]:
3cdc4176638c Quotient Package: make quotient_type work with separate set type
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 41467
diff changeset
   515
  shows "fset (filter_fset P xs) = Collect P \<inter> fset xs"
3cdc4176638c Quotient Package: make quotient_type work with separate set type
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 41467
diff changeset
   516
  by (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
   517
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   518
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
   519
  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
   520
  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
   521
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   522
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
   523
  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
   524
  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
   525
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   526
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
   527
  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
   528
  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
   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
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
   531
  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
   532
  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
   533
9f8dcf6ef563 reorganisation of 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
63167
0909deb8059b isabelle update_cartouches -c -t;
wenzelm
parents: 60515
diff changeset
   535
subsection \<open>in_fset\<close>
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
   536
9f8dcf6ef563 reorganisation of 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
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
   538
  shows "x |\<in>| S \<longleftrightarrow> x \<in> fset S"
40953
d13bcb42e479 replaced memb by existing List.member
haftmann
parents: 40952
diff changeset
   539
  by descending 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
   540
9f8dcf6ef563 reorganisation of 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
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
   542
  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
   543
  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
   544
9f8dcf6ef563 reorganisation of 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
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
   546
  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
   547
  by (simp add: in_fset)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   548
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
   549
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
   550
  shows "S = T \<longleftrightarrow> (\<forall>x. (x |\<in>| S) = (x |\<in>| T))"
40953
d13bcb42e479 replaced memb by existing List.member
haftmann
parents: 40952
diff changeset
   551
  by 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
   552
9f8dcf6ef563 reorganisation of 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
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
   554
  shows "(\<forall>x. x |\<notin>| S) \<longleftrightarrow> S = {||}"
40953
d13bcb42e479 replaced memb by existing List.member
haftmann
parents: 40952
diff changeset
   555
  by descending 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
   556
9f8dcf6ef563 reorganisation of 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
63167
0909deb8059b isabelle update_cartouches -c -t;
wenzelm
parents: 60515
diff changeset
   558
subsection \<open>insert_fset\<close>
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
   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 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
   561
  shows "x |\<in>| insert_fset y S \<longleftrightarrow> x = y \<or> x |\<in>| S"
40953
d13bcb42e479 replaced memb by existing List.member
haftmann
parents: 40952
diff changeset
   562
  by descending 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
   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
9f8dcf6ef563 reorganisation of 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 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
   566
  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
   567
  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
   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
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
   570
  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
   571
  by (descending) (auto)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   572
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
   573
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
   574
  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
   575
  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
   576
  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
   577
9f8dcf6ef563 reorganisation of 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
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
   579
  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
   580
  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
   581
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
   582
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
   583
  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
   584
  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
   585
9f8dcf6ef563 reorganisation of 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
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
   587
  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
   588
  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
   589
9f8dcf6ef563 reorganisation of 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
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
   591
  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
   592
  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
   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
63167
0909deb8059b isabelle update_cartouches -c -t;
wenzelm
parents: 60515
diff changeset
   595
subsection \<open>union_fset\<close>
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
   596
9f8dcf6ef563 reorganisation of 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
lemmas [simp] =
45605
a89b4bc311a5 eliminated obsolete "standard";
wenzelm
parents: 45343
diff changeset
   598
  sup_bot_left[where 'a="'a fset"]
a89b4bc311a5 eliminated obsolete "standard";
wenzelm
parents: 45343
diff changeset
   599
  sup_bot_right[where 'a="'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
   600
9f8dcf6ef563 reorganisation of 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
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
   602
  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
   603
  by (lifting append.simps(2))
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   604
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
   605
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
   606
  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
   607
  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
   608
9f8dcf6ef563 reorganisation of 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
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
   610
  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
   611
  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
   612
9f8dcf6ef563 reorganisation of 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
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
   614
  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
   615
  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
   616
9f8dcf6ef563 reorganisation of 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
63167
0909deb8059b isabelle update_cartouches -c -t;
wenzelm
parents: 60515
diff changeset
   618
subsection \<open>minus_fset\<close>
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
   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 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
   621
  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
   622
  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
   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 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
   625
  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
   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
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
   629
  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
   630
  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
   631
9f8dcf6ef563 reorganisation of 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
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
   633
  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
   634
  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
   635
9f8dcf6ef563 reorganisation of 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
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
   637
  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
   638
  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
   639
  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
   640
9f8dcf6ef563 reorganisation of 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
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
   642
  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
   643
  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
   644
  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
   645
9f8dcf6ef563 reorganisation of 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
63167
0909deb8059b isabelle update_cartouches -c -t;
wenzelm
parents: 60515
diff changeset
   647
subsection \<open>remove_fset\<close>
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
   648
9f8dcf6ef563 reorganisation of 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
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
   650
  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
   651
  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
   652
9f8dcf6ef563 reorganisation of 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
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
   654
  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
   655
  by (descending) (simp)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   656
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
   657
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
   658
  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
   659
  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
   660
9f8dcf6ef563 reorganisation of 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
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
   662
  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
   663
  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
   664
  
9f8dcf6ef563 reorganisation of 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
63167
0909deb8059b isabelle update_cartouches -c -t;
wenzelm
parents: 60515
diff changeset
   666
subsection \<open>inter_fset\<close>
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
   667
9f8dcf6ef563 reorganisation of 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
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
   669
  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
   670
  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
   671
9f8dcf6ef563 reorganisation of 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
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
   673
  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
   674
  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
   675
9f8dcf6ef563 reorganisation of 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
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
   677
  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
   678
  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
   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
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
   681
  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
   682
  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
   683
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   684
63167
0909deb8059b isabelle update_cartouches -c -t;
wenzelm
parents: 60515
diff changeset
   685
subsection \<open>subset_fset and psubset_fset\<close>
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
   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 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
   688
  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
   689
  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
   690
9f8dcf6ef563 reorganisation of 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 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
   692
  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
   693
  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
   694
  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
   695
9f8dcf6ef563 reorganisation of 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
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
   697
  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
   698
  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
   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
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
   701
  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
   702
  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
   703
9f8dcf6ef563 reorganisation of 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
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
   705
  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
   706
  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
   707
9f8dcf6ef563 reorganisation of 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
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
   709
  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
   710
  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
   711
9f8dcf6ef563 reorganisation of 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
63167
0909deb8059b isabelle update_cartouches -c -t;
wenzelm
parents: 60515
diff changeset
   713
subsection \<open>map_fset\<close>
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   714
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
   715
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
   716
   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
   717
  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
   718
  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
   719
9f8dcf6ef563 reorganisation of 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
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
   721
  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
   722
  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
   723
9f8dcf6ef563 reorganisation of 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
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
   725
  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
   726
  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
   727
9f8dcf6ef563 reorganisation of 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
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
   729
  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
   730
  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
   731
51371
197ad6b8f763 some simp rules for fset
traytel
parents: 47455
diff changeset
   732
lemma in_fset_map_fset[simp]: "a |\<in>| map_fset f X = (\<exists>b. b |\<in>| X \<and> a = f b)"
197ad6b8f763 some simp rules for fset
traytel
parents: 47455
diff changeset
   733
  by descending auto
197ad6b8f763 some simp rules for fset
traytel
parents: 47455
diff changeset
   734
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
   735
63167
0909deb8059b isabelle update_cartouches -c -t;
wenzelm
parents: 60515
diff changeset
   736
subsection \<open>card_fset\<close>
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
   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 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
   739
  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
   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 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
   743
  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
   744
  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
   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
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
   747
  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
   748
  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
   749
9f8dcf6ef563 reorganisation of 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
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
   751
  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
   752
  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
   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 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
   755
  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
   756
  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
   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 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
   759
  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
   760
  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
   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 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
   763
  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
   764
  by simp
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   765
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
   766
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
   767
  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
   768
  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
   769
  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
   770
  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
   771
9f8dcf6ef563 reorganisation of 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
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
   773
  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
   774
  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
   775
9f8dcf6ef563 reorganisation of 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
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
   777
  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
   778
  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
   779
9f8dcf6ef563 reorganisation of 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
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
   781
  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
   782
  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
   783
9f8dcf6ef563 reorganisation of 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
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
   785
  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
   786
  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
   787
  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
   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_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
   790
  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
   791
  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
   792
  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
   793
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
   794
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
   795
  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
   796
  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
   797
  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
   798
9f8dcf6ef563 reorganisation of 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
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
   800
  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
   801
  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
   802
  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
   803
9f8dcf6ef563 reorganisation of 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
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
   805
  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
   806
  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
   807
  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
   808
  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
   809
9f8dcf6ef563 reorganisation of 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
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
   811
  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
   812
  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
   813
  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
   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_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
   816
  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
   817
  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
   818
  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
   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_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
   821
  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
   822
  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
   823
  by (rule card_Diff1_le[OF finite_fset])
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
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 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
   826
  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
   827
  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
   828
  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
   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_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
   831
  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
   832
  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
   833
  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
   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_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
   836
  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
   837
  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
   838
  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
   839
  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
   840
  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
   841
9f8dcf6ef563 reorganisation of 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
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
   843
  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
   844
  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
   845
  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
   846
  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
   847
  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
   848
9f8dcf6ef563 reorganisation of 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
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
   850
  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
   851
  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
   852
  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
   853
9f8dcf6ef563 reorganisation of 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
63167
0909deb8059b isabelle update_cartouches -c -t;
wenzelm
parents: 60515
diff changeset
   855
subsection \<open>concat_fset\<close>
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
9f8dcf6ef563 reorganisation of 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
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
   858
  shows "concat_fset {||} = {||}"
46416
5f5665a0b973 Make automatic derivation of raw/quotient types more greedy to allow descending and quot_lifted for compound quotients.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 46404
diff changeset
   859
  by descending 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
   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 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
   862
  shows "concat_fset (insert_fset x S) = x |\<union>| concat_fset S"
46416
5f5665a0b973 Make automatic derivation of raw/quotient types more greedy to allow descending and quot_lifted for compound quotients.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 46404
diff changeset
   863
  by descending 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
   864
46441
992a1688303f Generalize the compositional preservation theorems
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 46416
diff changeset
   865
lemma concat_union_fset [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
   866
  shows "concat_fset (xs |\<union>| ys) = concat_fset xs |\<union>| concat_fset ys"
46416
5f5665a0b973 Make automatic derivation of raw/quotient types more greedy to allow descending and quot_lifted for compound quotients.
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 46404
diff changeset
   867
  by descending 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
   868
46404
7736068b9f56 Quotient FSet: Add compositional respectfulness and preservation for map and lift map_concat
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 46133
diff changeset
   869
lemma map_concat_fset:
7736068b9f56 Quotient FSet: Add compositional respectfulness and preservation for map and lift map_concat
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 46133
diff changeset
   870
  shows "map_fset f (concat_fset xs) = concat_fset (map_fset (map_fset f) xs)"
7736068b9f56 Quotient FSet: Add compositional respectfulness and preservation for map and lift map_concat
Cezary Kaliszyk <cezarykaliszyk@gmail.com>
parents: 46133
diff changeset
   871
  by (lifting map_concat)
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
   872
63167
0909deb8059b isabelle update_cartouches -c -t;
wenzelm
parents: 60515
diff changeset
   873
subsection \<open>filter_fset\<close>
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
   874
9f8dcf6ef563 reorganisation of 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
lemma subset_filter_fset: 
40961
3afec5adee35 canonical fold signature
haftmann
parents: 40954
diff changeset
   876
  "filter_fset P xs |\<subseteq>| filter_fset Q xs = (\<forall> x. x |\<in>| xs \<longrightarrow> P x \<longrightarrow> Q x)"
3afec5adee35 canonical fold signature
haftmann
parents: 40954
diff changeset
   877
  by 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
   878
9f8dcf6ef563 reorganisation of 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
lemma eq_filter_fset: 
40961
3afec5adee35 canonical fold signature
haftmann
parents: 40954
diff changeset
   880
  "(filter_fset P xs = filter_fset Q xs) = (\<forall>x. x |\<in>| xs \<longrightarrow> P x = Q x)"
3afec5adee35 canonical fold signature
haftmann
parents: 40954
diff changeset
   881
  by descending auto
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   882
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
   883
lemma psubset_filter_fset:
40961
3afec5adee35 canonical fold signature
haftmann
parents: 40954
diff changeset
   884
  "(\<And>x. x |\<in>| xs \<Longrightarrow> P x \<Longrightarrow> Q x) \<Longrightarrow> (x |\<in>| xs & \<not> P x & Q x) \<Longrightarrow> 
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
   885
    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
   886
  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
   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
63167
0909deb8059b isabelle update_cartouches -c -t;
wenzelm
parents: 60515
diff changeset
   889
subsection \<open>fold_fset\<close>
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
   890
9f8dcf6ef563 reorganisation of 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
lemma fold_empty_fset: 
40961
3afec5adee35 canonical fold signature
haftmann
parents: 40954
diff changeset
   892
  "fold_fset f {||} = id"
40962
069cd1c1f39b more intimate definition of fold_list / fold_once in terms of fold
haftmann
parents: 40961
diff changeset
   893
  by descending (simp add: fold_once_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
   894
40961
3afec5adee35 canonical fold signature
haftmann
parents: 40954
diff changeset
   895
lemma fold_insert_fset: "fold_fset f (insert_fset a A) =
40962
069cd1c1f39b more intimate definition of fold_list / fold_once in terms of fold
haftmann
parents: 40961
diff changeset
   896
  (if rsp_fold f then if a |\<in>| A then fold_fset f A else fold_fset f A \<circ> f a else id)"
069cd1c1f39b more intimate definition of fold_list / fold_once in terms of fold
haftmann
parents: 40961
diff changeset
   897
  by descending (simp add: fold_once_fold_remdups)
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
   898
47092
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   899
lemma remdups_removeAll:
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   900
  "remdups (removeAll x xs) = remove1 x (remdups xs)"
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   901
  by (induct xs) auto
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   902
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   903
lemma member_commute_fold_once:
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   904
  assumes "rsp_fold f"
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   905
    and "x \<in> set xs"
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   906
  shows "fold_once f xs = fold_once f (removeAll x xs) \<circ> f x"
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   907
proof -
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   908
  from assms have "fold f (remdups xs) = fold f (remove1 x (remdups xs)) \<circ> f x"
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   909
    by (auto intro!: fold_remove1_split elim: rsp_foldE)
63167
0909deb8059b isabelle update_cartouches -c -t;
wenzelm
parents: 60515
diff changeset
   910
  then show ?thesis using \<open>rsp_fold f\<close> by (simp add: fold_once_fold_remdups remdups_removeAll)
47092
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   911
qed
fa3538d6004b fix Quotient_Examples
kuncar
parents: 46752
diff changeset
   912
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
   913
lemma in_commute_fold_fset:
40962
069cd1c1f39b more intimate definition of fold_list / fold_once in terms of fold
haftmann
parents: 40961
diff changeset
   914
  "rsp_fold f \<Longrightarrow> h |\<in>| b \<Longrightarrow> fold_fset f b = fold_fset f (remove_fset h b) \<circ> f h"
069cd1c1f39b more intimate definition of fold_list / fold_once in terms of fold
haftmann
parents: 40961
diff changeset
   915
  by descending (simp add: member_commute_fold_once)
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
   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
63167
0909deb8059b isabelle update_cartouches -c -t;
wenzelm
parents: 60515
diff changeset
   918
subsection \<open>Choice in fsets\<close>
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
   919
9f8dcf6ef563 reorganisation of 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
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
   921
  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
   922
  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
   923
  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
   924
  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
   925
  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
   926
  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
   927
9f8dcf6ef563 reorganisation of 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
63167
0909deb8059b isabelle update_cartouches -c -t;
wenzelm
parents: 60515
diff changeset
   929
section \<open>Induction and Cases rules for fsets\<close>
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
   930
41070
36cec0e3491f more concise case names; proved extensionality
haftmann
parents: 40962
diff changeset
   931
lemma fset_exhaust [case_names empty insert, cases type: 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
   932
  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
   933
  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
   934
  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
   935
  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
   936
41070
36cec0e3491f more concise case names; proved extensionality
haftmann
parents: 40962
diff changeset
   937
lemma fset_induct [case_names empty insert]:
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
   938
  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
   939
  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
   940
  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
   941
  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
   942
  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
   943
41070
36cec0e3491f more concise case names; proved extensionality
haftmann
parents: 40962
diff changeset
   944
lemma fset_induct_stronger [case_names empty insert, induct type: 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
   945
  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
   946
  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
   947
  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
   948
proof(induct S rule: fset_induct)
41070
36cec0e3491f more concise case names; proved extensionality
haftmann
parents: 40962
diff changeset
   949
  case empty
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
   950
  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
   951
next
41070
36cec0e3491f more concise case names; proved extensionality
haftmann
parents: 40962
diff changeset
   952
  case (insert x S)
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
   953
  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
   954
  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
   955
    by (cases "x |\<in>| S") (simp_all)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   956
qed
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   957
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
   958
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
   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     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
   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)
41070
36cec0e3491f more concise case names; proved extensionality
haftmann
parents: 40962
diff changeset
   963
  case empty
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
   964
  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
   965
next
41070
36cec0e3491f more concise case names; proved extensionality
haftmann
parents: 40962
diff changeset
   966
  case (insert x S)
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
   967
  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
   968
  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
   969
  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
   970
    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
   971
  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
   972
    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
   973
qed
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   974
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   975
lemma fset_raw_strong_cases:
36465
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
   976
  obtains "xs = []"
40953
d13bcb42e479 replaced memb by existing List.member
haftmann
parents: 40952
diff changeset
   977
    | ys x where "\<not> List.member ys x" and "xs \<approx> x # ys"
45129
1fce03e3e8ad tuned proofs -- eliminated vacuous "induct arbitrary: ..." situations;
wenzelm
parents: 44512
diff changeset
   978
proof (induct xs)
36465
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
   979
  case Nil
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
   980
  then show thesis by simp
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
   981
next
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
   982
  case (Cons a xs)
40953
d13bcb42e479 replaced memb by existing List.member
haftmann
parents: 40952
diff changeset
   983
  have a: "\<lbrakk>xs = [] \<Longrightarrow> thesis; \<And>x ys. \<lbrakk>\<not> List.member ys x; xs \<approx> x # ys\<rbrakk> \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis"
d13bcb42e479 replaced memb by existing List.member
haftmann
parents: 40952
diff changeset
   984
    by (rule Cons(1))
d13bcb42e479 replaced memb by existing List.member
haftmann
parents: 40952
diff changeset
   985
  have b: "\<And>x' ys'. \<lbrakk>\<not> List.member ys' x'; 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
   986
  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
   987
    apply(simp)
57816
d8bbb97689d3 no need for 'set_simps' now that 'datatype_new' generates the desired 'set' property
blanchet
parents: 55945
diff changeset
   988
    by (metis list.set(1) emptyE empty_subsetI)
40953
d13bcb42e479 replaced memb by existing List.member
haftmann
parents: 40952
diff changeset
   989
  have "\<And>x ys. \<lbrakk>\<not> List.member ys x; xs \<approx> x # ys\<rbrakk> \<Longrightarrow> thesis"
36465
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
   990
  proof -
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
   991
    fix x :: 'a
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
   992
    fix ys :: "'a list"
40953
d13bcb42e479 replaced memb by existing List.member
haftmann
parents: 40952
diff changeset
   993
    assume d:"\<not> List.member ys x"
36465
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
   994
    assume e:"xs \<approx> x # ys"
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
   995
    show thesis
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
   996
    proof (cases "x = a")
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
   997
      assume h: "x = a"
40953
d13bcb42e479 replaced memb by existing List.member
haftmann
parents: 40952
diff changeset
   998
      then have f: "\<not> List.member ys a" using d by simp
36465
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
   999
      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
  1000
      show thesis using b f g by simp
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
  1001
    next
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
  1002
      assume h: "x \<noteq> a"
40953
d13bcb42e479 replaced memb by existing List.member
haftmann
parents: 40952
diff changeset
  1003
      then have f: "\<not> List.member (a # ys) x" using d by auto
36465
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
  1004
      have g: "a # xs \<approx> x # (a # ys)" using e h by auto
40953
d13bcb42e479 replaced memb by existing List.member
haftmann
parents: 40952
diff changeset
  1005
      show thesis using b f g by (simp del: List.member_def) 
36465
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
  1006
    qed
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
  1007
  qed
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
  1008
  then show thesis using a c by blast
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
  1009
qed
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1010
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
  1011
9f8dcf6ef563 reorganisation of the FSet theory (changed the primary naming scheme of constants and theorems to *_fset)
Christian Urban <urbanc@in.tum.de>
parents: 39996
diff changeset
  1012
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
  1013
  obtains "xs = {||}"
40953
d13bcb42e479 replaced memb by existing List.member
haftmann
parents: 40952
diff changeset
  1014
    | ys x where "x |\<notin>| ys" and "xs = insert_fset x 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
  1015
  by (lifting fset_raw_strong_cases)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1016
39996
c02078ff8691 FSet: definition changes propagated from Nominal and more use of 'descending' tactic
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 39995
diff changeset
  1017
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
  1018
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
  1019
  "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
  1020
  (\<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
  1021
  (\<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
  1022
  (\<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
  1023
  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
  1024
  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
  1025
  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
  1026
  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
  1027
  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
  1028
  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
  1029
  done
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1030
63167
0909deb8059b isabelle update_cartouches -c -t;
wenzelm
parents: 60515
diff changeset
  1031
text \<open>Extensionality\<close>
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
  1032
41070
36cec0e3491f more concise case names; proved extensionality
haftmann
parents: 40962
diff changeset
  1033
lemma fset_eqI:
36cec0e3491f more concise case names; proved extensionality
haftmann
parents: 40962
diff changeset
  1034
  assumes "\<And>x. x \<in> fset A \<longleftrightarrow> x \<in> fset B"
36cec0e3491f more concise case names; proved extensionality
haftmann
parents: 40962
diff changeset
  1035
  shows "A = B"
36cec0e3491f more concise case names; proved extensionality
haftmann
parents: 40962
diff changeset
  1036
using assms proof (induct A arbitrary: B)
36cec0e3491f more concise case names; proved extensionality
haftmann
parents: 40962
diff changeset
  1037
  case empty then show ?case
36cec0e3491f more concise case names; proved extensionality
haftmann
parents: 40962
diff changeset
  1038
    by (auto simp add: in_fset none_in_empty_fset [symmetric] sym)
36cec0e3491f more concise case names; proved extensionality
haftmann
parents: 40962
diff changeset
  1039
next
36cec0e3491f more concise case names; proved extensionality
haftmann
parents: 40962
diff changeset
  1040
  case (insert x A)
36cec0e3491f more concise case names; proved extensionality
haftmann
parents: 40962
diff changeset
  1041
  from insert.prems insert.hyps(1) have "\<And>z. z \<in> fset A \<longleftrightarrow> z \<in> fset (B - {|x|})"
36cec0e3491f more concise case names; proved extensionality
haftmann
parents: 40962
diff changeset
  1042
    by (auto simp add: in_fset)
53374
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 51371
diff changeset
  1043
  then have A: "A = B - {|x|}" by (rule insert.hyps(2))
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 51371
diff changeset
  1044
  with insert.prems [symmetric, of x] have "x |\<in>| B" by (simp add: in_fset)
a14d2a854c02 tuned proofs -- clarified flow of facts wrt. calculation;
wenzelm
parents: 51371
diff changeset
  1045
  with A show ?case by (metis in_fset_mdef)
41070
36cec0e3491f more concise case names; proved extensionality
haftmann
parents: 40962
diff changeset
  1046
qed
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1047
63167
0909deb8059b isabelle update_cartouches -c -t;
wenzelm
parents: 60515
diff changeset
  1048
subsection \<open>alternate formulation with a different decomposition principle
0909deb8059b isabelle update_cartouches -c -t;
wenzelm
parents: 60515
diff changeset
  1049
  and a proof of equivalence\<close>
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1050
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1051
inductive
40952
580b1a30994c explicit type constraint;
haftmann
parents: 40822
diff changeset
  1052
  list_eq2 :: "'a list \<Rightarrow> 'a list \<Rightarrow> bool" ("_ \<approx>2 _")
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1053
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
  1054
  "(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
  1055
| "[] \<approx>2 []"
40952
580b1a30994c explicit type constraint;
haftmann
parents: 40822
diff changeset
  1056
| "xs \<approx>2 ys \<Longrightarrow> ys \<approx>2 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
  1057
| "(a # a # xs) \<approx>2 (a # xs)"
40952
580b1a30994c explicit type constraint;
haftmann
parents: 40822
diff changeset
  1058
| "xs \<approx>2 ys \<Longrightarrow> (a # xs) \<approx>2 (a # ys)"
580b1a30994c explicit type constraint;
haftmann
parents: 40822
diff changeset
  1059
| "xs1 \<approx>2 xs2 \<Longrightarrow> xs2 \<approx>2 xs3 \<Longrightarrow> xs1 \<approx>2 xs3"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1060
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1061
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
  1062
  shows "xs \<approx>2 xs"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1063
  by (induct xs) (auto intro: list_eq2.intros)
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1064
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1065
lemma cons_delete_list_eq2:
40953
d13bcb42e479 replaced memb by existing List.member
haftmann
parents: 40952
diff changeset
  1066
  shows "(a # (removeAll a A)) \<approx>2 (if List.member A a then A else a # A)"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1067
  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
  1068
  apply (simp add: list_eq2_refl)
40953
d13bcb42e479 replaced memb by existing List.member
haftmann
parents: 40952
diff changeset
  1069
  apply (case_tac "List.member (aa # 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
  1070
  apply (simp_all)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1071
  apply (case_tac [!] "a = aa")
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1072
  apply (simp_all)
40953
d13bcb42e479 replaced memb by existing List.member
haftmann
parents: 40952
diff changeset
  1073
  apply (case_tac "List.member 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
  1074
  apply (auto)[2]
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1075
  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
  1076
  apply (metis list_eq2.intros(1) list_eq2.intros(5) list_eq2.intros(6))
40953
d13bcb42e479 replaced memb by existing List.member
haftmann
parents: 40952
diff changeset
  1077
  apply (auto simp add: list_eq2_refl)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1078
  done
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1079
40953
d13bcb42e479 replaced memb by existing List.member
haftmann
parents: 40952
diff changeset
  1080
lemma member_delete_list_eq2:
d13bcb42e479 replaced memb by existing List.member
haftmann
parents: 40952
diff changeset
  1081
  assumes a: "List.member r 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
  1082
  shows "(e # removeAll e r) \<approx>2 r"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1083
  using a cons_delete_list_eq2[of e r]
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1084
  by simp
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1085
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1086
lemma list_eq2_equiv:
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1087
  "(l \<approx> r) \<longleftrightarrow> (list_eq2 l r)"
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1088
proof
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1089
  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
  1090
next
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1091
  {
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1092
    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
  1093
    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
  1094
    have "l \<approx>2 r"
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1095
      using a b
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1096
    proof (induct n arbitrary: l r)
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1097
      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
  1098
      have "card_list l = 0" by fact
40953
d13bcb42e479 replaced memb by existing List.member
haftmann
parents: 40952
diff changeset
  1099
      then have "\<forall>x. \<not> List.member l x" by 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
  1100
      then have z: "l = []" by auto
63167
0909deb8059b isabelle update_cartouches -c -t;
wenzelm
parents: 60515
diff changeset
  1101
      then have "r = []" using \<open>l \<approx> r\<close> by simp
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1102
      then show ?case using z list_eq2_refl by simp
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1103
    next
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1104
      case (Suc m)
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1105
      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
  1106
      have d: "card_list l = Suc m" by fact
40953
d13bcb42e479 replaced memb by existing List.member
haftmann
parents: 40952
diff changeset
  1107
      then have "\<exists>a. List.member l a" 
41067
c78a2d402736 eliminated some hard tabulators (deprecated);
wenzelm
parents: 40962
diff changeset
  1108
        apply(simp)
c78a2d402736 eliminated some hard tabulators (deprecated);
wenzelm
parents: 40962
diff changeset
  1109
        apply(drule card_eq_SucD)
c78a2d402736 eliminated some hard tabulators (deprecated);
wenzelm
parents: 40962
diff changeset
  1110
        apply(blast)
c78a2d402736 eliminated some hard tabulators (deprecated);
wenzelm
parents: 40962
diff changeset
  1111
        done
40953
d13bcb42e479 replaced memb by existing List.member
haftmann
parents: 40952
diff changeset
  1112
      then obtain a where e: "List.member l a" by auto
d13bcb42e479 replaced memb by existing List.member
haftmann
parents: 40952
diff changeset
  1113
      then have e': "List.member r a" using list_eq_def [simplified List.member_def [symmetric], of l r] b 
41067
c78a2d402736 eliminated some hard tabulators (deprecated);
wenzelm
parents: 40962
diff changeset
  1114
        by 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
  1115
      have f: "card_list (removeAll a l) = m" using e d by (simp)
47198
cfd8ff62eab1 use qualified names for rsp and rep_eq theorems in quotient_def
kuncar
parents: 47092
diff changeset
  1116
      have g: "removeAll a l \<approx> removeAll a r" using remove_fset.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
  1117
      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
  1118
      then have h: "(a # removeAll a l) \<approx>2 (a # removeAll a r)" by (rule list_eq2.intros(5))
41067
c78a2d402736 eliminated some hard tabulators (deprecated);
wenzelm
parents: 40962
diff changeset
  1119
      have i: "l \<approx>2 (a # removeAll a l)"
40953
d13bcb42e479 replaced memb by existing List.member
haftmann
parents: 40952
diff changeset
  1120
        by (rule list_eq2.intros(3)[OF member_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
  1121
      have "l \<approx>2 (a # removeAll a r)" by (rule list_eq2.intros(6)[OF i h])
40953
d13bcb42e479 replaced memb by existing List.member
haftmann
parents: 40952
diff changeset
  1122
      then show ?case using list_eq2.intros(6)[OF _ member_delete_list_eq2[OF e']] by simp
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1123
    qed
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1124
    }
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
  1125
  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
  1126
qed
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1127
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1128
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1129
(* We cannot write it as "assumes .. shows" since Isabelle changes
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1130
   the quantifiers to schematic variables and reintroduces them in
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1131
   a different order *)
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1132
lemma fset_eq_cases:
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1133
 "\<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
  1134
   \<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
  1135
   \<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
  1136
   \<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
  1137
   \<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
  1138
   \<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
  1139
  \<Longrightarrow> P"
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1140
  by (lifting list_eq2.cases[simplified list_eq2_equiv[symmetric]])
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1141
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1142
lemma fset_eq_induct:
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1143
  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
  1144
  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
  1145
  and "P {||} {||}"
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1146
  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
  1147
  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
  1148
  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
  1149
  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
  1150
  shows "P x1 x2"
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1151
  using assms
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1152
  by (lifting list_eq2.induct[simplified list_eq2_equiv[symmetric]])
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1153
63167
0909deb8059b isabelle update_cartouches -c -t;
wenzelm
parents: 60515
diff changeset
  1154
ML \<open>
36465
15e834a03509 Tuned FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 36352
diff changeset
  1155
fun dest_fsetT (Type (@{type_name fset}, [T])) = T
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1156
  | dest_fsetT T = raise TYPE ("dest_fsetT: fset type expected", [T], []);
63167
0909deb8059b isabelle update_cartouches -c -t;
wenzelm
parents: 60515
diff changeset
  1157
\<close>
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1158
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1159
no_notation
40034
Christian Urban <urbanc@in.tum.de>
parents: 40030
diff changeset
  1160
  list_eq (infix "\<approx>" 50) and 
Christian Urban <urbanc@in.tum.de>
parents: 40030
diff changeset
  1161
  list_eq2 (infix "\<approx>2" 50)
36280
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1162
c4f5823f282d Finite set theory
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1163
end