Nominal/FSet.thy
author Christian Urban <urbanc@in.tum.de>
Fri, 15 Oct 2010 14:11:23 +0100
changeset 2533 767161329839
parent 2532 22c37deb3dac
child 2534 f99578469d08
permissions -rw-r--r--
further cleaning
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
     1
(*  Title:      HOL/Quotient_Examples/FSet.thy
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
     2
    Author:     Cezary Kaliszyk, TU Munich
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
     3
    Author:     Christian Urban, TU Munich
1823
91ba55dba5e0 added header and more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1822
diff changeset
     4
2533
767161329839 further cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2532
diff changeset
     5
    Type of finite sets.
1823
91ba55dba5e0 added header and more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1822
diff changeset
     6
*)
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
     7
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     8
theory FSet
2528
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
     9
imports Quotient_List
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    10
begin
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    11
2533
767161329839 further cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2532
diff changeset
    12
text {* Definiton of the list equivalence relation *}
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    13
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    14
fun
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    15
  list_eq :: "'a list \<Rightarrow> 'a list \<Rightarrow> bool" (infix "\<approx>" 50)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    16
where
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
    17
  "list_eq xs ys = (set xs = set ys)"
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    18
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    19
lemma list_eq_equivp:
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    20
  shows "equivp list_eq"
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    21
  unfolding equivp_reflp_symp_transp
1889
6c5b5ec53a0b sub_list definition and respects
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1888
diff changeset
    22
  unfolding reflp_def symp_def transp_def
6c5b5ec53a0b sub_list definition and respects
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1888
diff changeset
    23
  by auto
6c5b5ec53a0b sub_list definition and respects
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1888
diff changeset
    24
2533
767161329839 further cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2532
diff changeset
    25
text {* Fset type *}
767161329839 further cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2532
diff changeset
    26
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    27
quotient_type
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    28
  'a fset = "'a list" / "list_eq"
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    29
  by (rule list_eq_equivp)
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    30
2533
767161329839 further cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2532
diff changeset
    31
text {* 
767161329839 further cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2532
diff changeset
    32
  Definitions of membership, sublist, cardinality,
767161329839 further cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2532
diff changeset
    33
  intersection etc over lists
2372
Christian Urban <urbanc@in.tum.de>
parents: 2371
diff changeset
    34
*}
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    35
1889
6c5b5ec53a0b sub_list definition and respects
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1888
diff changeset
    36
definition
6c5b5ec53a0b sub_list definition and respects
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1888
diff changeset
    37
  memb :: "'a \<Rightarrow> 'a list \<Rightarrow> bool"
6c5b5ec53a0b sub_list definition and respects
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1888
diff changeset
    38
where
6c5b5ec53a0b sub_list definition and respects
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1888
diff changeset
    39
  "memb x xs \<equiv> x \<in> set xs"
6c5b5ec53a0b sub_list definition and respects
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1888
diff changeset
    40
6c5b5ec53a0b sub_list definition and respects
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1888
diff changeset
    41
definition
6c5b5ec53a0b sub_list definition and respects
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1888
diff changeset
    42
  sub_list :: "'a list \<Rightarrow> 'a list \<Rightarrow> bool"
6c5b5ec53a0b sub_list definition and respects
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1888
diff changeset
    43
where
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
    44
  "sub_list xs ys \<equiv> set xs \<subseteq> set ys"
1889
6c5b5ec53a0b sub_list definition and respects
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1888
diff changeset
    45
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
    46
definition
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    47
  fcard_raw :: "'a list \<Rightarrow> nat"
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    48
where
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
    49
  "fcard_raw xs = card (set xs)"
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    50
2533
767161329839 further cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2532
diff changeset
    51
(*
767161329839 further cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2532
diff changeset
    52
definition
767161329839 further cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2532
diff changeset
    53
  finter_raw :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a list"
767161329839 further cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2532
diff changeset
    54
where
767161329839 further cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2532
diff changeset
    55
  "finter_raw xs ys \<equiv> [x \<leftarrow> xs. x\<notin>set ys]"
767161329839 further cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2532
diff changeset
    56
*)
767161329839 further cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2532
diff changeset
    57
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    58
primrec
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    59
  finter_raw :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a list"
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    60
where
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
    61
  "finter_raw [] ys = []"
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
    62
| "finter_raw (x # xs) ys =
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
    63
    (if x \<in> set ys then x # (finter_raw xs ys) else finter_raw xs ys)"
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
    64
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
    65
primrec
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
    66
  fminus_raw :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a list"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
    67
where
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
    68
  "fminus_raw ys [] = ys"
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
    69
| "fminus_raw ys (x # xs) = fminus_raw (removeAll x ys) xs"
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    70
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    71
definition
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    72
  rsp_fold
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    73
where
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    74
  "rsp_fold f = (\<forall>u v w. (f u (f v w) = f v (f u w)))"
1893
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
    75
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    76
primrec
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    77
  ffold_raw :: "('a \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> 'b \<Rightarrow> 'a list \<Rightarrow> 'b"
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    78
where
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    79
  "ffold_raw f z [] = z"
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
    80
| "ffold_raw f z (a # xs) =
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    81
     (if (rsp_fold f) then
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
    82
       if a \<in> set xs then ffold_raw f z xs
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
    83
       else f a (ffold_raw f z xs)
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    84
     else z)"
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    85
2533
767161329839 further cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2532
diff changeset
    86
767161329839 further cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2532
diff changeset
    87
767161329839 further cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2532
diff changeset
    88
lemma set_finter_raw[simp]:
767161329839 further cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2532
diff changeset
    89
  shows "set (finter_raw xs ys) = set xs \<inter> set ys"
767161329839 further cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2532
diff changeset
    90
  by (induct xs) (auto simp add: memb_def)
767161329839 further cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2532
diff changeset
    91
767161329839 further cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2532
diff changeset
    92
lemma set_fminus_raw[simp]: 
767161329839 further cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2532
diff changeset
    93
  shows "set (fminus_raw xs ys) = (set xs - set ys)"
767161329839 further cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2532
diff changeset
    94
  by (induct ys arbitrary: xs) (auto)
767161329839 further cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2532
diff changeset
    95
767161329839 further cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2532
diff changeset
    96
767161329839 further cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2532
diff changeset
    97
767161329839 further cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2532
diff changeset
    98
section {* Quotient composition lemmas *}
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
    99
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   100
lemma list_all2_refl1:
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   101
  shows "(list_all2 op \<approx>) r r"
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   102
  by (rule list_all2_refl) (metis equivp_def fset_equivp)
1938
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   103
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   104
lemma compose_list_refl:
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   105
  shows "(list_all2 op \<approx> OOO op \<approx>) r r"
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   106
proof
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   107
  have *: "r \<approx> r" by (rule equivp_reflp[OF fset_equivp])
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   108
  show "list_all2 op \<approx> r r" by (rule list_all2_refl1)
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   109
  with * show "(op \<approx> OO list_all2 op \<approx>) r r" ..
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   110
qed
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   111
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   112
lemma Quotient_fset_list:
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   113
  shows "Quotient (list_all2 op \<approx>) (map abs_fset) (map rep_fset)"
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   114
  by (fact list_quotient[OF Quotient_fset])
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   115
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   116
lemma map_rel_cong: "b \<approx> ba \<Longrightarrow> map f b \<approx> map f ba"
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   117
  unfolding list_eq.simps
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   118
  by (simp only: set_map)
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   119
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   120
lemma quotient_compose_list[quot_thm]:
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   121
  shows  "Quotient ((list_all2 op \<approx>) OOO (op \<approx>))
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   122
    (abs_fset \<circ> (map abs_fset)) ((map rep_fset) \<circ> rep_fset)"
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   123
  unfolding Quotient_def comp_def
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   124
proof (intro conjI allI)
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   125
  fix a r s
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   126
  show "abs_fset (map abs_fset (map rep_fset (rep_fset a))) = a"
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   127
    by (simp add: abs_o_rep[OF Quotient_fset] Quotient_abs_rep[OF Quotient_fset] map_id)
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   128
  have b: "list_all2 op \<approx> (map rep_fset (rep_fset a)) (map rep_fset (rep_fset a))"
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   129
    by (rule list_all2_refl1)
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   130
  have c: "(op \<approx> OO list_all2 op \<approx>) (map rep_fset (rep_fset a)) (map rep_fset (rep_fset a))"
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   131
    by (rule, rule equivp_reflp[OF fset_equivp]) (rule b)
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   132
  show "(list_all2 op \<approx> OOO op \<approx>) (map rep_fset (rep_fset a)) (map rep_fset (rep_fset a))"
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   133
    by (rule, rule list_all2_refl1) (rule c)
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   134
  show "(list_all2 op \<approx> OOO op \<approx>) r s = ((list_all2 op \<approx> OOO op \<approx>) r r \<and>
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   135
        (list_all2 op \<approx> OOO op \<approx>) s s \<and> abs_fset (map abs_fset r) = abs_fset (map abs_fset s))"
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   136
  proof (intro iffI conjI)
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   137
    show "(list_all2 op \<approx> OOO op \<approx>) r r" by (rule compose_list_refl)
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   138
    show "(list_all2 op \<approx> OOO op \<approx>) s s" by (rule compose_list_refl)
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   139
  next
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   140
    assume a: "(list_all2 op \<approx> OOO op \<approx>) r s"
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   141
    then have b: "map abs_fset r \<approx> map abs_fset s"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   142
    proof (elim pred_compE)
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   143
      fix b ba
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   144
      assume c: "list_all2 op \<approx> r b"
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   145
      assume d: "b \<approx> ba"
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   146
      assume e: "list_all2 op \<approx> ba s"
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   147
      have f: "map abs_fset r = map abs_fset b"
1938
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   148
        using Quotient_rel[OF Quotient_fset_list] c by blast
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   149
      have "map abs_fset ba = map abs_fset s"
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   150
        using Quotient_rel[OF Quotient_fset_list] e by blast
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   151
      then have g: "map abs_fset s = map abs_fset ba" by simp
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   152
      then show "map abs_fset r \<approx> map abs_fset s" using d f map_rel_cong by simp
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   153
    qed
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   154
    then show "abs_fset (map abs_fset r) = abs_fset (map abs_fset s)"
1938
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   155
      using Quotient_rel[OF Quotient_fset] by blast
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   156
  next
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   157
    assume a: "(list_all2 op \<approx> OOO op \<approx>) r r \<and> (list_all2 op \<approx> OOO op \<approx>) s s
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   158
      \<and> abs_fset (map abs_fset r) = abs_fset (map abs_fset s)"
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   159
    then have s: "(list_all2 op \<approx> OOO op \<approx>) s s" by simp
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   160
    have d: "map abs_fset r \<approx> map abs_fset s"
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   161
      by (subst Quotient_rel[OF Quotient_fset]) (simp add: a)
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   162
    have b: "map rep_fset (map abs_fset r) \<approx> map rep_fset (map abs_fset s)"
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   163
      by (rule map_rel_cong[OF d])
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   164
    have y: "list_all2 op \<approx> (map rep_fset (map abs_fset s)) s"
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   165
      by (fact rep_abs_rsp_left[OF Quotient_fset_list, OF list_all2_refl1[of s]])
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   166
    have c: "(op \<approx> OO list_all2 op \<approx>) (map rep_fset (map abs_fset r)) s"
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   167
      by (rule pred_compI) (rule b, rule y)
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   168
    have z: "list_all2 op \<approx> r (map rep_fset (map abs_fset r))"
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   169
      by (fact rep_abs_rsp[OF Quotient_fset_list, OF list_all2_refl1[of r]])
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   170
    then show "(list_all2 op \<approx> OOO op \<approx>) r s"
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   171
      using a c pred_compI by simp
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   172
  qed
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   173
qed
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   174
2525
c848f93807b9 deleted some unused lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2524
diff changeset
   175
2532
Christian Urban <urbanc@in.tum.de>
parents: 2531
diff changeset
   176
text {* Respectfulness *}
1893
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   177
2187
f9cc69b432ff Name some respectfullness
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2084
diff changeset
   178
lemma append_rsp[quot_respect]:
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   179
  shows "(op \<approx> ===> op \<approx> ===> op \<approx>) append append"
2533
767161329839 further cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2532
diff changeset
   180
  by simp
1895
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   181
2525
c848f93807b9 deleted some unused lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2524
diff changeset
   182
lemma sub_list_rsp[quot_respect]:
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   183
  shows "(op \<approx> ===> op \<approx> ===> op =) sub_list sub_list"
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   184
  by (auto simp add: sub_list_def)
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   185
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   186
lemma memb_rsp[quot_respect]:
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   187
  shows "(op = ===> op \<approx> ===> op =) memb memb"
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   188
  by (auto simp add: memb_def)
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   189
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   190
lemma nil_rsp[quot_respect]:
2525
c848f93807b9 deleted some unused lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2524
diff changeset
   191
  shows "(op \<approx>) Nil Nil"
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   192
  by simp
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   193
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   194
lemma cons_rsp[quot_respect]:
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   195
  shows "(op = ===> op \<approx> ===> op \<approx>) Cons Cons"
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   196
  by simp
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   197
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   198
lemma map_rsp[quot_respect]:
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   199
  shows "(op = ===> op \<approx> ===> op \<approx>) map map"
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   200
  by auto
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   201
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   202
lemma set_rsp[quot_respect]:
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   203
  "(op \<approx> ===> op =) set set"
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   204
  by auto
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   205
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   206
lemma list_equiv_rsp[quot_respect]:
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   207
  shows "(op \<approx> ===> op \<approx> ===> op =) op \<approx> op \<approx>"
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   208
  by auto
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   209
2525
c848f93807b9 deleted some unused lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2524
diff changeset
   210
lemma finter_raw_rsp[quot_respect]:
c848f93807b9 deleted some unused lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2524
diff changeset
   211
  shows "(op \<approx> ===> op \<approx> ===> op \<approx>) finter_raw finter_raw"
c848f93807b9 deleted some unused lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2524
diff changeset
   212
  by simp
c848f93807b9 deleted some unused lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2524
diff changeset
   213
c848f93807b9 deleted some unused lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2524
diff changeset
   214
lemma removeAll_rsp[quot_respect]:
c848f93807b9 deleted some unused lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2524
diff changeset
   215
  shows "(op = ===> op \<approx> ===> op \<approx>) removeAll removeAll"
c848f93807b9 deleted some unused lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2524
diff changeset
   216
  by simp
c848f93807b9 deleted some unused lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2524
diff changeset
   217
c848f93807b9 deleted some unused lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2524
diff changeset
   218
lemma fminus_raw_rsp[quot_respect]:
c848f93807b9 deleted some unused lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2524
diff changeset
   219
  shows "(op \<approx> ===> op \<approx> ===> op \<approx>) fminus_raw fminus_raw"
c848f93807b9 deleted some unused lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2524
diff changeset
   220
  by simp
c848f93807b9 deleted some unused lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2524
diff changeset
   221
c848f93807b9 deleted some unused lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2524
diff changeset
   222
lemma fcard_raw_rsp[quot_respect]:
c848f93807b9 deleted some unused lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2524
diff changeset
   223
  shows "(op \<approx> ===> op =) fcard_raw fcard_raw"
c848f93807b9 deleted some unused lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2524
diff changeset
   224
  by (simp add: fcard_raw_def)
c848f93807b9 deleted some unused lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2524
diff changeset
   225
c848f93807b9 deleted some unused lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2524
diff changeset
   226
c848f93807b9 deleted some unused lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2524
diff changeset
   227
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   228
lemma memb_commute_ffold_raw:
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   229
  "rsp_fold f \<Longrightarrow> h \<in> set b \<Longrightarrow> ffold_raw f z b = f h (ffold_raw f z (removeAll h b))"
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   230
  apply (induct b)
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   231
  apply (auto simp add: rsp_fold_def)
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   232
  done
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   233
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   234
lemma ffold_raw_rsp_pre:
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   235
  "set a = set b \<Longrightarrow> ffold_raw f z a = ffold_raw f z b"
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   236
  apply (induct a arbitrary: b)
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   237
  apply (simp)
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   238
  apply (simp (no_asm_use))
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   239
  apply (rule conjI)
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   240
  apply (rule_tac [!] impI)
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   241
  apply (rule_tac [!] conjI)
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   242
  apply (rule_tac [!] impI)
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   243
  apply (metis insert_absorb)
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   244
  apply (metis List.insert_def List.set.simps(2) List.set_insert ffold_raw.simps(2))
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   245
  apply (metis Diff_insert_absorb insertI1 memb_commute_ffold_raw set_removeAll)
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   246
  apply(drule_tac x="removeAll a1 b" in meta_spec)
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   247
  apply(auto)
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   248
  apply(drule meta_mp)
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   249
  apply(blast)
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   250
  by (metis List.set.simps(2) emptyE ffold_raw.simps(2) in_listsp_conv_set listsp.simps mem_def)
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   251
2525
c848f93807b9 deleted some unused lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2524
diff changeset
   252
lemma ffold_raw_rsp[quot_respect]:
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   253
  shows "(op = ===> op = ===> op \<approx> ===> op =) ffold_raw ffold_raw"
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   254
  unfolding fun_rel_def
2529
775d0bfd99fd Synchronizing FSet further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2528
diff changeset
   255
  by(auto intro: ffold_raw_rsp_pre)
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   256
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   257
lemma concat_rsp_pre:
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   258
  assumes a: "list_all2 op \<approx> x x'"
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   259
  and     b: "x' \<approx> y'"
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   260
  and     c: "list_all2 op \<approx> y' y"
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   261
  and     d: "\<exists>x\<in>set x. xa \<in> set x"
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   262
  shows "\<exists>x\<in>set y. xa \<in> set x"
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   263
proof -
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   264
  obtain xb where e: "xb \<in> set x" and f: "xa \<in> set xb" using d by auto
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   265
  have "\<exists>y. y \<in> set x' \<and> xb \<approx> y" by (rule list_all2_find_element[OF e a])
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   266
  then obtain ya where h: "ya \<in> set x'" and i: "xb \<approx> ya" by auto
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   267
  have "ya \<in> set y'" using b h by simp
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   268
  then have "\<exists>yb. yb \<in> set y \<and> ya \<approx> yb" using c by (rule list_all2_find_element)
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   269
  then show ?thesis using f i by auto
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   270
qed
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   271
2187
f9cc69b432ff Name some respectfullness
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2084
diff changeset
   272
lemma concat_rsp[quot_respect]:
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   273
  shows "(list_all2 op \<approx> OOO op \<approx> ===> op \<approx>) concat concat"
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   274
proof (rule fun_relI, elim pred_compE)
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   275
  fix a b ba bb
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   276
  assume a: "list_all2 op \<approx> a ba"
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   277
  assume b: "ba \<approx> bb"
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   278
  assume c: "list_all2 op \<approx> bb b"
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   279
  have "\<forall>x. (\<exists>xa\<in>set a. x \<in> set xa) = (\<exists>xa\<in>set b. x \<in> set xa)" 
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   280
  proof
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   281
    fix x
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   282
    show "(\<exists>xa\<in>set a. x \<in> set xa) = (\<exists>xa\<in>set b. x \<in> set xa)" 
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   283
    proof
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   284
      assume d: "\<exists>xa\<in>set a. x \<in> set xa"
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   285
      show "\<exists>xa\<in>set b. x \<in> set xa" by (rule concat_rsp_pre[OF a b c d])
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   286
    next
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   287
      assume e: "\<exists>xa\<in>set b. x \<in> set xa"
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   288
      have a': "list_all2 op \<approx> ba a" by (rule list_all2_symp[OF list_eq_equivp, OF a])
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   289
      have b': "bb \<approx> ba" by (rule equivp_symp[OF list_eq_equivp, OF b])
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   290
      have c': "list_all2 op \<approx> b bb" by (rule list_all2_symp[OF list_eq_equivp, OF c])
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   291
      show "\<exists>xa\<in>set a. x \<in> set xa" by (rule concat_rsp_pre[OF c' b' a' e])
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   292
    qed
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   293
  qed
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   294
  then show "concat a \<approx> concat b" by auto
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   295
qed
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   296
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   297
lemma [quot_respect]:
2532
Christian Urban <urbanc@in.tum.de>
parents: 2531
diff changeset
   298
  shows "(op = ===> op \<approx> ===> op \<approx>) filter filter"
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   299
  by auto
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   300
1905
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   301
2528
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
   302
instantiation fset :: (type) "{bounded_lattice_bot, distrib_lattice, minus}"
1893
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   303
begin
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   304
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   305
quotient_definition
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   306
  "bot :: 'a fset" is "[] :: 'a list"
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   307
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   308
abbreviation
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   309
  fempty  ("{||}")
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   310
where
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   311
  "{||} \<equiv> bot :: 'a fset"
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   312
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   313
quotient_definition
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   314
  "less_eq_fset \<Colon> ('a fset \<Rightarrow> 'a fset \<Rightarrow> bool)"
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   315
is
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   316
  "sub_list \<Colon> ('a list \<Rightarrow> 'a list \<Rightarrow> bool)"
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   317
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   318
abbreviation
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   319
  f_subset_eq :: "'a fset \<Rightarrow> 'a fset \<Rightarrow> bool" (infix "|\<subseteq>|" 50)
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   320
where
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   321
  "xs |\<subseteq>| ys \<equiv> xs \<le> ys"
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   322
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   323
definition
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   324
  less_fset :: "'a fset \<Rightarrow> 'a fset \<Rightarrow> bool"
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   325
where  
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   326
  "xs < ys \<equiv> xs \<le> ys \<and> xs \<noteq> (ys::'a fset)"
1893
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   327
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   328
abbreviation
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   329
  fsubset :: "'a fset \<Rightarrow> 'a fset \<Rightarrow> bool" (infix "|\<subset>|" 50)
1893
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   330
where
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   331
  "xs |\<subset>| ys \<equiv> xs < ys"
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   332
1895
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   333
quotient_definition
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   334
  "sup :: 'a fset \<Rightarrow> 'a fset \<Rightarrow> 'a fset"
1895
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   335
is
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   336
  "append :: 'a list \<Rightarrow> 'a list \<Rightarrow> 'a list"
1895
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   337
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   338
abbreviation
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   339
  funion (infixl "|\<union>|" 65)
1895
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   340
where
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   341
  "xs |\<union>| ys \<equiv> sup xs (ys::'a fset)"
1895
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   342
1905
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   343
quotient_definition
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   344
  "inf :: 'a fset \<Rightarrow> 'a fset \<Rightarrow> 'a fset"
1905
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   345
is
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   346
  "finter_raw :: 'a list \<Rightarrow> 'a list \<Rightarrow> 'a list"
1905
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   347
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   348
abbreviation
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   349
  finter (infixl "|\<inter>|" 65)
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   350
where
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   351
  "xs |\<inter>| ys \<equiv> inf xs (ys::'a fset)"
1905
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   352
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   353
quotient_definition
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   354
  "minus :: 'a fset \<Rightarrow> 'a fset \<Rightarrow> 'a fset"
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   355
is
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   356
  "fminus_raw :: 'a list \<Rightarrow> 'a list \<Rightarrow> 'a list"
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   357
2533
767161329839 further cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2532
diff changeset
   358
lemma append_finter_raw_distrib:
767161329839 further cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2532
diff changeset
   359
  "x @ (finter_raw y z) \<approx> finter_raw (x @ y) (x @ z)"
767161329839 further cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2532
diff changeset
   360
  apply (induct x)
767161329839 further cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2532
diff changeset
   361
  apply (auto)
767161329839 further cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2532
diff changeset
   362
  done
767161329839 further cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2532
diff changeset
   363
1895
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   364
instance
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   365
proof
1905
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   366
  fix x y z :: "'a fset"
2528
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
   367
  show "x |\<subset>| y \<longleftrightarrow> x |\<subseteq>| y \<and> \<not> y |\<subseteq>| x"
2530
3b8741ecfda3 FSet synchronizing
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2529
diff changeset
   368
    unfolding less_fset_def 
3b8741ecfda3 FSet synchronizing
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2529
diff changeset
   369
    by (descending) (auto simp add: sub_list_def)
2528
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
   370
  show "x |\<subseteq>| x"  by (descending) (simp add: sub_list_def)
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
   371
  show "{||} |\<subseteq>| x" by (descending) (simp add: sub_list_def)
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
   372
  show "x |\<subseteq>| x |\<union>| y" by (descending) (simp add: sub_list_def)
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
   373
  show "y |\<subseteq>| x |\<union>| y" by (descending) (simp add: sub_list_def)
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
   374
  show "x |\<inter>| y |\<subseteq>| x"
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
   375
    by (descending) (simp add: sub_list_def memb_def[symmetric])
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
   376
  show "x |\<inter>| y |\<subseteq>| y" 
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
   377
    by (descending) (simp add: sub_list_def memb_def[symmetric])
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
   378
  show "x |\<union>| (y |\<inter>| z) = x |\<union>| y |\<inter>| (x |\<union>| z)" 
2533
767161329839 further cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2532
diff changeset
   379
    by (descending) (rule append_finter_raw_distrib)
1905
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   380
next
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   381
  fix x y z :: "'a fset"
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   382
  assume a: "x |\<subseteq>| y"
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   383
  assume b: "y |\<subseteq>| z"
2528
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
   384
  show "x |\<subseteq>| z" using a b 
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
   385
    by (descending) (simp add: sub_list_def)
1895
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   386
next
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   387
  fix x y :: "'a fset"
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   388
  assume a: "x |\<subseteq>| y"
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   389
  assume b: "y |\<subseteq>| x"
2528
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
   390
  show "x = y" using a b 
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
   391
    by (descending) (unfold sub_list_def list_eq.simps, blast)
1895
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   392
next
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   393
  fix x y z :: "'a fset"
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   394
  assume a: "y |\<subseteq>| x"
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   395
  assume b: "z |\<subseteq>| x"
2528
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
   396
  show "y |\<union>| z |\<subseteq>| x" using a b 
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
   397
    by (descending) (simp add: sub_list_def)
1905
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   398
next
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   399
  fix x y z :: "'a fset"
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   400
  assume a: "x |\<subseteq>| y"
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   401
  assume b: "x |\<subseteq>| z"
2528
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
   402
  show "x |\<subseteq>| y |\<inter>| z" using a b 
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
   403
    by (descending) (simp add: sub_list_def memb_def[symmetric])
1895
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   404
qed
1905
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   405
1893
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   406
end
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   407
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   408
section {* Finsert and Membership *}
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   409
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   410
quotient_definition
1893
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   411
  "finsert :: 'a \<Rightarrow> 'a fset \<Rightarrow> 'a fset"
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   412
is "Cons"
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   413
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   414
syntax
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   415
  "@Finset"     :: "args => 'a fset"  ("{|(_)|}")
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   416
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   417
translations
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   418
  "{|x, xs|}" == "CONST finsert x {|xs|}"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   419
  "{|x|}"     == "CONST finsert x {||}"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   420
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   421
quotient_definition
1938
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   422
  fin (infix "|\<in>|" 50)
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   423
where
1816
56cebe7f8e24 some small tunings (incompleted work in Lambda.thy)
Christian Urban <urbanc@in.tum.de>
parents: 1682
diff changeset
   424
  "fin :: 'a \<Rightarrow> 'a fset \<Rightarrow> bool" is "memb"
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   425
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   426
abbreviation
1938
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   427
  fnotin :: "'a \<Rightarrow> 'a fset \<Rightarrow> bool" (infix "|\<notin>|" 50)
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   428
where
1860
d3fe17786640 some tuning of proofs
Christian Urban <urbanc@in.tum.de>
parents: 1826
diff changeset
   429
  "x |\<notin>| S \<equiv> \<not> (x |\<in>| S)"
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   430
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   431
section {* Other constants on the Quotient Type *}
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   432
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   433
quotient_definition
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   434
  "fcard :: 'a fset \<Rightarrow> nat"
2529
775d0bfd99fd Synchronizing FSet further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2528
diff changeset
   435
is
775d0bfd99fd Synchronizing FSet further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2528
diff changeset
   436
  fcard_raw
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   437
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   438
quotient_definition
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   439
  "fmap :: ('a \<Rightarrow> 'b) \<Rightarrow> 'a fset \<Rightarrow> 'b fset"
2529
775d0bfd99fd Synchronizing FSet further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2528
diff changeset
   440
is
775d0bfd99fd Synchronizing FSet further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2528
diff changeset
   441
  map
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   442
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   443
quotient_definition
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   444
  "fdelete :: 'a \<Rightarrow> 'a fset \<Rightarrow> 'a fset"
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   445
  is removeAll
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   446
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   447
quotient_definition
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   448
  "fset :: 'a fset \<Rightarrow> 'a set"
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   449
  is "set"
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   450
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   451
quotient_definition
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   452
  "ffold :: ('a \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> 'b \<Rightarrow> 'a fset \<Rightarrow> 'b"
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   453
  is "ffold_raw"
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   454
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   455
quotient_definition
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   456
  "fconcat :: ('a fset) fset \<Rightarrow> 'a fset"
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   457
is
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   458
  "concat"
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   459
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   460
quotient_definition
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   461
  "ffilter :: ('a \<Rightarrow> bool) \<Rightarrow> 'a fset \<Rightarrow> 'a fset"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   462
is
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   463
  "filter"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   464
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   465
text {* Compositional Respectfullness and Preservation *}
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   466
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   467
lemma [quot_respect]: "(list_all2 op \<approx> OOO op \<approx>) [] []"
1938
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   468
  by (fact compose_list_refl)
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   469
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   470
lemma [quot_preserve]: "(abs_fset \<circ> map f) [] = abs_fset []"
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   471
  by simp
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   472
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   473
lemma [quot_respect]:
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   474
  shows "(op \<approx> ===> list_all2 op \<approx> OOO op \<approx> ===> list_all2 op \<approx> OOO op \<approx>) Cons Cons"
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   475
  apply auto
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   476
  apply (rule_tac b="x # b" in pred_compI)
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   477
  apply auto
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   478
  apply (rule_tac b="x # ba" in pred_compI)
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   479
  apply auto
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   480
  done
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   481
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   482
lemma [quot_preserve]:
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   483
  "(rep_fset ---> (map rep_fset \<circ> rep_fset) ---> (abs_fset \<circ> map abs_fset)) op # = finsert"
2479
a9b6a00b1ba0 updated to Isabelle Sept 16
Christian Urban <urbanc@in.tum.de>
parents: 2378
diff changeset
   484
  by (simp add: fun_eq_iff Quotient_abs_rep[OF Quotient_fset]
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   485
      abs_o_rep[OF Quotient_fset] map_id finsert_def)
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   486
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   487
lemma [quot_preserve]:
1938
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   488
  "((map rep_fset \<circ> rep_fset) ---> (map rep_fset \<circ> rep_fset) ---> (abs_fset \<circ> map abs_fset)) op @ = funion"
2479
a9b6a00b1ba0 updated to Isabelle Sept 16
Christian Urban <urbanc@in.tum.de>
parents: 2378
diff changeset
   489
  by (simp add: fun_eq_iff Quotient_abs_rep[OF Quotient_fset]
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   490
      abs_o_rep[OF Quotient_fset] map_id sup_fset_def)
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   491
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   492
lemma list_all2_app_l:
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   493
  assumes a: "reflp R"
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   494
  and b: "list_all2 R l r"
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   495
  shows "list_all2 R (z @ l) (z @ r)"
1938
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   496
  by (induct z) (simp_all add: b rev_iffD1[OF a meta_eq_to_obj_eq[OF reflp_def]])
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   497
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   498
lemma append_rsp2_pre0:
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   499
  assumes a:"list_all2 op \<approx> x x'"
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   500
  shows "list_all2 op \<approx> (x @ z) (x' @ z)"
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   501
  using a apply (induct x x' rule: list_induct2')
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   502
  by simp_all (rule list_all2_refl1)
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   503
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   504
lemma append_rsp2_pre1:
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   505
  assumes a:"list_all2 op \<approx> x x'"
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   506
  shows "list_all2 op \<approx> (z @ x) (z @ x')"
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   507
  using a apply (induct x x' arbitrary: z rule: list_induct2')
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   508
  apply (rule list_all2_refl1)
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   509
  apply (simp_all del: list_eq.simps)
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   510
  apply (rule list_all2_app_l)
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   511
  apply (simp_all add: reflp_def)
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   512
  done
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   513
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   514
lemma append_rsp2_pre:
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   515
  assumes a:"list_all2 op \<approx> x x'"
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   516
  and     b: "list_all2 op \<approx> z z'"
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   517
  shows "list_all2 op \<approx> (x @ z) (x' @ z')"
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   518
  apply (rule list_all2_transp[OF fset_equivp])
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   519
  apply (rule append_rsp2_pre0)
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   520
  apply (rule a)
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   521
  using b apply (induct z z' rule: list_induct2')
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   522
  apply (simp_all only: append_Nil2)
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   523
  apply (rule list_all2_refl1)
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   524
  apply simp_all
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   525
  apply (rule append_rsp2_pre1)
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   526
  apply simp
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   527
  done
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   528
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   529
lemma [quot_respect]:
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   530
  "(list_all2 op \<approx> OOO op \<approx> ===> list_all2 op \<approx> OOO op \<approx> ===> list_all2 op \<approx> OOO op \<approx>) op @ op @"
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   531
proof (intro fun_relI, elim pred_compE)
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   532
  fix x y z w x' z' y' w' :: "'a list list"
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   533
  assume a:"list_all2 op \<approx> x x'"
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   534
  and b:    "x' \<approx> y'"
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   535
  and c:    "list_all2 op \<approx> y' y"
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   536
  assume aa: "list_all2 op \<approx> z z'"
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   537
  and bb:   "z' \<approx> w'"
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   538
  and cc:   "list_all2 op \<approx> w' w"
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   539
  have a': "list_all2 op \<approx> (x @ z) (x' @ z')" using a aa append_rsp2_pre by auto
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   540
  have b': "x' @ z' \<approx> y' @ w'" using b bb by simp
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   541
  have c': "list_all2 op \<approx> (y' @ w') (y @ w)" using c cc append_rsp2_pre by auto
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   542
  have d': "(op \<approx> OO list_all2 op \<approx>) (x' @ z') (y @ w)"
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   543
    by (rule pred_compI) (rule b', rule c')
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   544
  show "(list_all2 op \<approx> OOO op \<approx>) (x @ z) (y @ w)"
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   545
    by (rule pred_compI) (rule a', rule d')
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   546
qed
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   547
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   548
text {* Raw theorems. Finsert, memb, singleron, sub_list *}
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   549
1892
4df853f5879f reorder
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1889
diff changeset
   550
lemma nil_not_cons:
4df853f5879f reorder
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1889
diff changeset
   551
  shows "\<not> ([] \<approx> x # xs)"
4df853f5879f reorder
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1889
diff changeset
   552
  and   "\<not> (x # xs \<approx> [])"
4df853f5879f reorder
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1889
diff changeset
   553
  by auto
4df853f5879f reorder
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1889
diff changeset
   554
1878
c22947214948 2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1860
diff changeset
   555
lemma no_memb_nil:
c22947214948 2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1860
diff changeset
   556
  "(\<forall>x. \<not> memb x xs) = (xs = [])"
c22947214948 2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1860
diff changeset
   557
  by (simp add: memb_def)
c22947214948 2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1860
diff changeset
   558
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   559
lemma memb_consI1:
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   560
  shows "memb x (x # xs)"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   561
  by (simp add: memb_def)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   562
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   563
lemma memb_consI2:
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   564
  shows "memb x xs \<Longrightarrow> memb x (y # xs)"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   565
  by (simp add: memb_def)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   566
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   567
lemma singleton_list_eq:
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   568
  shows "[x] \<approx> [y] \<longleftrightarrow> x = y"
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   569
  by (simp)
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   570
1892
4df853f5879f reorder
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1889
diff changeset
   571
lemma sub_list_cons:
4df853f5879f reorder
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1889
diff changeset
   572
  "sub_list (x # xs) ys = (memb x ys \<and> sub_list xs ys)"
4df853f5879f reorder
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1889
diff changeset
   573
  by (auto simp add: memb_def sub_list_def)
4df853f5879f reorder
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1889
diff changeset
   574
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   575
lemma fminus_raw_red: 
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   576
  "fminus_raw (x # xs) ys = (if x \<in> set ys then fminus_raw xs ys else x # (fminus_raw xs ys))"
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   577
  by (induct ys arbitrary: xs x) (simp_all)
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   578
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   579
text {* Cardinality of finite sets *}
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   580
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   581
(* used in memb_card_not_0 *)
1813
69fff336dd18 Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1682
diff changeset
   582
lemma fcard_raw_0:
1860
d3fe17786640 some tuning of proofs
Christian Urban <urbanc@in.tum.de>
parents: 1826
diff changeset
   583
  shows "fcard_raw xs = 0 \<longleftrightarrow> xs \<approx> []"
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   584
  unfolding fcard_raw_def
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   585
  by (induct xs) (auto)
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   586
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   587
(* used in list_eq2_equiv *)
1884
5fd2ed815144 more metis cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1883
diff changeset
   588
lemma memb_card_not_0:
1878
c22947214948 2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1860
diff changeset
   589
  assumes a: "memb a A"
c22947214948 2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1860
diff changeset
   590
  shows "\<not>(fcard_raw A = 0)"
1883
b2fa5de30a73 Getting rid of 'metis'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1881
diff changeset
   591
proof -
b2fa5de30a73 Getting rid of 'metis'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1881
diff changeset
   592
  have "\<not>(\<forall>x. \<not> memb x A)" using a by auto
2533
767161329839 further cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2532
diff changeset
   593
  then have "\<not>A \<approx> []" by (simp add: memb_def)
1883
b2fa5de30a73 Getting rid of 'metis'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1881
diff changeset
   594
  then show ?thesis using fcard_raw_0[of A] by simp
b2fa5de30a73 Getting rid of 'metis'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1881
diff changeset
   595
qed
1878
c22947214948 2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1860
diff changeset
   596
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   597
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   598
2533
767161329839 further cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2532
diff changeset
   599
section {* ? *}
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   600
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   601
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   602
lemma fset_raw_strong_cases:
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   603
  obtains "xs = []"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   604
    | x ys where "\<not> memb x ys" and "xs \<approx> x # ys"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   605
proof (induct xs arbitrary: x ys)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   606
  case Nil
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   607
  then show thesis by simp
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   608
next
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   609
  case (Cons a xs)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   610
  have a: "\<lbrakk>xs = [] \<Longrightarrow> thesis; \<And>x ys. \<lbrakk>\<not> memb x ys; xs \<approx> x # ys\<rbrakk> \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis" by fact
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   611
  have b: "\<And>x' ys'. \<lbrakk>\<not> memb x' ys'; a # xs \<approx> x' # ys'\<rbrakk> \<Longrightarrow> thesis" by fact
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   612
  have c: "xs = [] \<Longrightarrow> thesis" by (metis no_memb_nil singleton_list_eq b)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   613
  have "\<And>x ys. \<lbrakk>\<not> memb x ys; xs \<approx> x # ys\<rbrakk> \<Longrightarrow> thesis"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   614
  proof -
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   615
    fix x :: 'a
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   616
    fix ys :: "'a list"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   617
    assume d:"\<not> memb x ys"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   618
    assume e:"xs \<approx> x # ys"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   619
    show thesis
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   620
    proof (cases "x = a")
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   621
      assume h: "x = a"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   622
      then have f: "\<not> memb a ys" using d by simp
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   623
      have g: "a # xs \<approx> a # ys" using e h by auto
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   624
      show thesis using b f g by simp
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   625
    next
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   626
      assume h: "x \<noteq> a"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   627
      then have f: "\<not> memb x (a # ys)" using d unfolding memb_def by auto
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   628
      have g: "a # xs \<approx> x # (a # ys)" using e h by auto
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   629
      show thesis using b f g by simp
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   630
    qed
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   631
  qed
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   632
  then show thesis using a c by blast
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   633
qed
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   634
1860
d3fe17786640 some tuning of proofs
Christian Urban <urbanc@in.tum.de>
parents: 1826
diff changeset
   635
section {* deletion *}
d3fe17786640 some tuning of proofs
Christian Urban <urbanc@in.tum.de>
parents: 1826
diff changeset
   636
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   637
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   638
lemma fset_raw_removeAll_cases:
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   639
  "xs = [] \<or> (\<exists>x. memb x xs \<and> xs \<approx> x # removeAll x xs)"
1821
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   640
  by (induct xs) (auto simp add: memb_def)
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   641
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   642
lemma fremoveAll_filter:
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   643
  "removeAll y xs = [x \<leftarrow> xs. x \<noteq> y]"
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   644
  by (induct xs) simp_all
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   645
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   646
lemma fcard_raw_delete:
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   647
  "fcard_raw (removeAll y xs) = (if memb y xs then fcard_raw xs - 1 else fcard_raw xs)"
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   648
  by (auto simp add: fcard_raw_def memb_def)
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   649
1533
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   650
lemma inj_map_eq_iff:
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   651
  "inj f \<Longrightarrow> (map f l \<approx> map f m) = (l \<approx> m)"
2479
a9b6a00b1ba0 updated to Isabelle Sept 16
Christian Urban <urbanc@in.tum.de>
parents: 2378
diff changeset
   652
  by (simp add: set_eq_iff[symmetric] inj_image_eq_iff)
1533
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   653
1888
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   654
text {* alternate formulation with a different decomposition principle
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   655
  and a proof of equivalence *}
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   656
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   657
inductive
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   658
  list_eq2
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   659
where
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   660
  "list_eq2 (a # b # xs) (b # a # xs)"
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   661
| "list_eq2 [] []"
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   662
| "list_eq2 xs ys \<Longrightarrow> list_eq2 ys xs"
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   663
| "list_eq2 (a # a # xs) (a # xs)"
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   664
| "list_eq2 xs ys \<Longrightarrow> list_eq2 (a # xs) (a # ys)"
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   665
| "\<lbrakk>list_eq2 xs1 xs2; list_eq2 xs2 xs3\<rbrakk> \<Longrightarrow> list_eq2 xs1 xs3"
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   666
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   667
lemma list_eq2_refl:
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   668
  shows "list_eq2 xs xs"
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   669
  by (induct xs) (auto intro: list_eq2.intros)
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   670
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   671
lemma cons_delete_list_eq2:
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   672
  shows "list_eq2 (a # (removeAll a A)) (if memb a A then A else a # A)"
1888
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   673
  apply (induct A)
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   674
  apply (simp add: memb_def list_eq2_refl)
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   675
  apply (case_tac "memb a (aa # A)")
2533
767161329839 further cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2532
diff changeset
   676
  apply (simp_all only: memb_def)
1888
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   677
  apply (case_tac [!] "a = aa")
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   678
  apply (simp_all)
1888
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   679
  apply (case_tac "memb a A")
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   680
  apply (auto simp add: memb_def)[2]
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   681
  apply (metis list_eq2.intros(3) list_eq2.intros(4) list_eq2.intros(5) list_eq2.intros(6))
1895
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   682
  apply (metis list_eq2.intros(1) list_eq2.intros(5) list_eq2.intros(6))
2525
c848f93807b9 deleted some unused lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2524
diff changeset
   683
  apply (auto simp add: list_eq2_refl memb_def)
1888
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   684
  done
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   685
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   686
lemma memb_delete_list_eq2:
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   687
  assumes a: "memb e r"
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   688
  shows "list_eq2 (e # removeAll e r) r"
1888
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   689
  using a cons_delete_list_eq2[of e r]
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   690
  by simp
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   691
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   692
lemma list_eq2_equiv:
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   693
  "(l \<approx> r) \<longleftrightarrow> (list_eq2 l r)"
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   694
proof
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   695
  show "list_eq2 l r \<Longrightarrow> l \<approx> r" by (induct rule: list_eq2.induct) auto
1938
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   696
next
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   697
  {
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   698
    fix n
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   699
    assume a: "fcard_raw l = n" and b: "l \<approx> r"
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   700
    have "list_eq2 l r"
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   701
      using a b
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   702
    proof (induct n arbitrary: l r)
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   703
      case 0
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   704
      have "fcard_raw l = 0" by fact
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   705
      then have "\<forall>x. \<not> memb x l" using memb_card_not_0[of _ l] by auto
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   706
      then have z: "l = []" using no_memb_nil by auto
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   707
      then have "r = []" using `l \<approx> r` by simp
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   708
      then show ?case using z list_eq2_refl by simp
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   709
    next
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   710
      case (Suc m)
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   711
      have b: "l \<approx> r" by fact
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   712
      have d: "fcard_raw l = Suc m" by fact
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   713
      then have "\<exists>a. memb a l" 
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   714
	apply(simp add: fcard_raw_def memb_def)
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   715
	apply(drule card_eq_SucD)
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   716
	apply(blast)
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   717
	done
1938
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   718
      then obtain a where e: "memb a l" by auto
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   719
      then have e': "memb a r" using list_eq.simps[simplified memb_def[symmetric], of l r] b 
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   720
	unfolding memb_def by auto
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   721
      have f: "fcard_raw (removeAll a l) = m" using fcard_raw_delete[of a l] e d by simp
2525
c848f93807b9 deleted some unused lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2524
diff changeset
   722
      have g: "removeAll a l \<approx> removeAll a r" using removeAll_rsp b by simp
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   723
      have "list_eq2 (removeAll a l) (removeAll a r)" by (rule Suc.hyps[OF f g])
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   724
      then have h: "list_eq2 (a # removeAll a l) (a # removeAll a r)" by (rule list_eq2.intros(5))
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   725
      have i: "list_eq2 l (a # removeAll a l)"
1938
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   726
        by (rule list_eq2.intros(3)[OF memb_delete_list_eq2[OF e]])
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   727
      have "list_eq2 l (a # removeAll a r)" by (rule list_eq2.intros(6)[OF i h])
1938
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   728
      then show ?case using list_eq2.intros(6)[OF _ memb_delete_list_eq2[OF e']] by simp
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   729
    qed
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   730
    }
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   731
  then show "l \<approx> r \<Longrightarrow> list_eq2 l r" by blast
1888
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   732
qed
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   733
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   734
text {* Lifted theorems *}
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   735
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   736
lemma not_fin_fnil: "x |\<notin>| {||}"
2529
775d0bfd99fd Synchronizing FSet further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2528
diff changeset
   737
  by (descending) (simp add: memb_def)
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   738
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   739
lemma fin_finsert_iff[simp]:
2528
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
   740
  "x |\<in>| finsert y S \<longleftrightarrow> x = y \<or> x |\<in>| S"
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
   741
  by (descending) (simp add: memb_def)
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   742
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   743
lemma
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   744
  shows finsertI1: "x |\<in>| finsert x S"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   745
  and   finsertI2: "x |\<in>| S \<Longrightarrow> x |\<in>| finsert y S"
2528
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
   746
  by (lifting memb_consI1 memb_consI2)
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   747
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   748
lemma finsert_absorb[simp]:
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   749
  shows "x |\<in>| S \<Longrightarrow> finsert x S = S"
2528
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
   750
  by (descending) (auto simp add: memb_def)
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   751
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   752
lemma fempty_not_finsert[simp]:
1533
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   753
  "{||} \<noteq> finsert x S"
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   754
  "finsert x S \<noteq> {||}"
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   755
  by (lifting nil_not_cons)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   756
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   757
lemma finsert_left_comm:
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
   758
  "finsert x (finsert y S) = finsert y (finsert x S)"
2528
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
   759
  by (descending) (auto)
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   760
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   761
lemma finsert_left_idem:
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
   762
  "finsert x (finsert x S) = finsert x S"
2528
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
   763
  by (descending) (auto)
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   764
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   765
lemma fsingleton_eq[simp]:
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   766
  shows "{|x|} = {|y|} \<longleftrightarrow> x = y"
2528
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
   767
  by (descending) (auto)
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   768
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   769
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   770
text {* fset *}
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   771
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   772
lemma fset_simps[simp]:
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   773
  "fset {||} = ({} :: 'a set)"
2533
767161329839 further cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2532
diff changeset
   774
  "fset (finsert (x :: 'a) S) = insert x (fset S)"
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   775
  by (lifting set.simps)
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   776
2533
767161329839 further cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2532
diff changeset
   777
lemma fin_fset:
767161329839 further cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2532
diff changeset
   778
  "x \<in> fset S \<longleftrightarrow> x |\<in>| S"
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   779
  by (lifting memb_def[symmetric])
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   780
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   781
lemma none_fin_fempty:
2530
3b8741ecfda3 FSet synchronizing
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2529
diff changeset
   782
  "(\<forall>x. x |\<notin>| S) \<longleftrightarrow> S = {||}"
2533
767161329839 further cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2532
diff changeset
   783
  by (descending) (simp add: memb_def)
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   784
1533
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   785
lemma fset_cong:
2530
3b8741ecfda3 FSet synchronizing
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2529
diff changeset
   786
  "S = T \<longleftrightarrow> fset S = fset T"
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   787
  by (lifting list_eq.simps)
1533
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   788
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   789
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   790
section {* fcard *}
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   791
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   792
lemma fcard_finsert_if [simp]:
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   793
  shows "fcard (finsert x S) = (if x |\<in>| S then fcard S else Suc (fcard S))"
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   794
  by (descending) (auto simp add: fcard_raw_def memb_def insert_absorb)
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   795
2530
3b8741ecfda3 FSet synchronizing
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2529
diff changeset
   796
lemma fcard_0[simp]:
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   797
  shows "fcard S = 0 \<longleftrightarrow> S = {||}"
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   798
  by (descending) (simp add: fcard_raw_def)
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   799
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   800
lemma fcard_fempty[simp]:
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   801
  shows "fcard {||} = 0"
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   802
  by (simp add: fcard_0)
1813
69fff336dd18 Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1682
diff changeset
   803
1821
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   804
lemma fcard_1:
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   805
  shows "fcard S = 1 \<longleftrightarrow> (\<exists>x. S = {|x|})"
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   806
  by (descending) (auto simp add: fcard_raw_def card_Suc_eq)
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   807
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   808
lemma fcard_gt_0:
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   809
  shows "x \<in> fset S \<Longrightarrow> 0 < fcard S"
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   810
  by (descending) (auto simp add: fcard_raw_def card_gt_0_iff)
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   811
  
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   812
lemma fcard_not_fin:
2531
8054f4988672 FSet: stronger fact in Isabelle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2530
diff changeset
   813
  shows "(x |\<notin>| S) = (fcard (finsert x S) = Suc (fcard S))"
8054f4988672 FSet: stronger fact in Isabelle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2530
diff changeset
   814
  by (descending) (auto simp add: memb_def fcard_raw_def insert_absorb)
1813
69fff336dd18 Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1682
diff changeset
   815
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   816
lemma fcard_suc: 
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   817
  shows "fcard S = Suc n \<Longrightarrow> \<exists>x T. x |\<notin>| T \<and> S = finsert x T \<and> fcard T = n"
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   818
  apply(descending)
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   819
  apply(simp add: fcard_raw_def memb_def)
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   820
  apply(drule card_eq_SucD)
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   821
  apply(auto)
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   822
  apply(rule_tac x="b" in exI)
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   823
  apply(rule_tac x="removeAll b S" in exI)
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   824
  apply(auto)
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   825
  done
1813
69fff336dd18 Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1682
diff changeset
   826
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   827
lemma fcard_delete:
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   828
  "fcard (fdelete y S) = (if y |\<in>| S then fcard S - 1 else fcard S)"
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   829
  by (lifting fcard_raw_delete)
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   830
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   831
lemma fcard_suc_memb: 
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   832
  shows "fcard A = Suc n \<Longrightarrow> \<exists>a. a |\<in>| A"
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   833
  apply(descending)
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   834
  apply(simp add: fcard_raw_def memb_def)
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   835
  apply(drule card_eq_SucD)
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   836
  apply(auto)
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   837
  done
1878
c22947214948 2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1860
diff changeset
   838
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   839
lemma fin_fcard_not_0: 
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   840
  shows "a |\<in>| A \<Longrightarrow> fcard A \<noteq> 0"
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   841
  by (descending) (auto simp add: fcard_raw_def memb_def)
1878
c22947214948 2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1860
diff changeset
   842
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   843
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   844
section {* funion *}
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   845
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   846
lemmas [simp] =
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   847
  sup_bot_left[where 'a="'a fset", standard]
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   848
  sup_bot_right[where 'a="'a fset", standard]
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   849
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   850
lemma funion_finsert[simp]:
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   851
  shows "finsert x S |\<union>| T = finsert x (S |\<union>| T)"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   852
  by (lifting append.simps(2))
1887
7abd8c1d9f4b Some new lemmas
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1886
diff changeset
   853
7abd8c1d9f4b Some new lemmas
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1886
diff changeset
   854
lemma singleton_union_left:
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   855
  shows "{|a|} |\<union>| S = finsert a S"
1887
7abd8c1d9f4b Some new lemmas
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1886
diff changeset
   856
  by simp
7abd8c1d9f4b Some new lemmas
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1886
diff changeset
   857
7abd8c1d9f4b Some new lemmas
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1886
diff changeset
   858
lemma singleton_union_right:
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   859
  shows "S |\<union>| {|a|} = finsert a S"
1907
7b74cf843942 lattice properties.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1905
diff changeset
   860
  by (subst sup.commute) simp
1887
7abd8c1d9f4b Some new lemmas
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1886
diff changeset
   861
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   862
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   863
section {* Induction and Cases rules for fsets *}
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   864
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   865
lemma fset_strong_cases:
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   866
  obtains "xs = {||}"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   867
    | x ys where "x |\<notin>| ys" and "xs = finsert x ys"
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   868
  by (lifting fset_raw_strong_cases)
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   869
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   870
lemma fset_exhaust[case_names fempty finsert, cases type: fset]:
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   871
  shows "\<lbrakk>S = {||} \<Longrightarrow> P; \<And>x S'. S = finsert x S' \<Longrightarrow> P\<rbrakk> \<Longrightarrow> P"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   872
  by (lifting list.exhaust)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   873
1533
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   874
lemma fset_induct_weak[case_names fempty finsert]:
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   875
  shows "\<lbrakk>P {||}; \<And>x S. P S \<Longrightarrow> P (finsert x S)\<rbrakk> \<Longrightarrow> P S"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   876
  by (lifting list.induct)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   877
1533
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   878
lemma fset_induct[case_names fempty finsert, induct type: fset]:
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   879
  assumes prem1: "P {||}"
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   880
  and     prem2: "\<And>x S. \<lbrakk>x |\<notin>| S; P S\<rbrakk> \<Longrightarrow> P (finsert x S)"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   881
  shows "P S"
1533
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   882
proof(induct S rule: fset_induct_weak)
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   883
  case fempty
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   884
  show "P {||}" by (rule prem1)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   885
next
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   886
  case (finsert x S)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   887
  have asm: "P S" by fact
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   888
  show "P (finsert x S)"
1938
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   889
    by (cases "x |\<in>| S") (simp_all add: asm prem2)
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   890
qed
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   891
1533
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   892
lemma fset_induct2:
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   893
  "P {||} {||} \<Longrightarrow>
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   894
  (\<And>x xs. x |\<notin>| xs \<Longrightarrow> P (finsert x xs) {||}) \<Longrightarrow>
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   895
  (\<And>y ys. y |\<notin>| ys \<Longrightarrow> P {||} (finsert y ys)) \<Longrightarrow>
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   896
  (\<And>x xs y ys. \<lbrakk>P xs ys; x |\<notin>| xs; y |\<notin>| ys\<rbrakk> \<Longrightarrow> P (finsert x xs) (finsert y ys)) \<Longrightarrow>
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   897
  P xsa ysa"
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   898
  apply (induct xsa arbitrary: ysa)
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   899
  apply (induct_tac x rule: fset_induct)
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   900
  apply simp_all
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   901
  apply (induct_tac xa rule: fset_induct)
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   902
  apply simp_all
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   903
  done
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   904
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   905
lemma fset_fcard_induct:
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   906
  assumes a: "P {||}"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   907
  and     b: "\<And>xs ys. Suc (fcard xs) = (fcard ys) \<Longrightarrow> P xs \<Longrightarrow> P ys"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   908
  shows "P zs"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   909
proof (induct zs)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   910
  show "P {||}" by (rule a)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   911
next
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   912
  fix x :: 'a and zs :: "'a fset"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   913
  assume h: "P zs"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   914
  assume "x |\<notin>| zs"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   915
  then have H1: "Suc (fcard zs) = fcard (finsert x zs)" using fcard_suc by auto
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   916
  then show "P (finsert x zs)" using b h by simp
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   917
qed
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   918
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   919
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   920
section {* fmap *}
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   921
1533
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   922
lemma fmap_simps[simp]:
2528
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
   923
  fixes f::"'a \<Rightarrow> 'b"
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
   924
  shows "fmap f {||} = {||}"
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
   925
  and   "fmap f (finsert x S) = finsert (f x) (fmap f S)"
1533
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   926
  by (lifting map.simps)
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   927
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   928
lemma fmap_set_image:
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   929
  "fset (fmap f S) = f ` (fset S)"
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   930
  by (induct S) simp_all
1533
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   931
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   932
lemma inj_fmap_eq_iff:
2529
775d0bfd99fd Synchronizing FSet further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2528
diff changeset
   933
  "inj f \<Longrightarrow> fmap f S = fmap f T \<longleftrightarrow> S = T"
1533
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   934
  by (lifting inj_map_eq_iff)
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   935
2528
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
   936
lemma fmap_funion: 
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
   937
  shows "fmap f (S |\<union>| T) = fmap f S |\<union>| fmap f T"
2533
767161329839 further cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2532
diff changeset
   938
  by (descending) (simp)
1813
69fff336dd18 Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1682
diff changeset
   939
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   940
lemma fin_funion:
2528
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
   941
  shows "x |\<in>| S |\<union>| T \<longleftrightarrow> x |\<in>| S \<or> x |\<in>| T"
2533
767161329839 further cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2532
diff changeset
   942
  by (descending) (simp add: memb_def)
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   943
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   944
section {* fset *}
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   945
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   946
lemma fin_set: 
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   947
  shows "x |\<in>| xs \<longleftrightarrow> x \<in> fset xs"
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   948
  by (lifting memb_def)
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   949
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   950
lemma fnotin_set: 
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   951
  shows "x |\<notin>| xs \<longleftrightarrow> x \<notin> fset xs"
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   952
  by (simp add: fin_set)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   953
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   954
lemma fcard_set: 
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   955
  shows "fcard xs = card (fset xs)"
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   956
  by (lifting fcard_raw_def)
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   957
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   958
lemma fsubseteq_set: 
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   959
  shows "xs |\<subseteq>| ys \<longleftrightarrow> fset xs \<subseteq> fset ys"
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   960
  by (lifting sub_list_def)
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   961
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   962
lemma fsubset_set: 
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   963
  shows "xs |\<subset>| ys \<longleftrightarrow> fset xs \<subset> fset ys"
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   964
  unfolding less_fset_def 
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   965
  by (descending) (auto simp add: sub_list_def)
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   966
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   967
lemma ffilter_set [simp]: 
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   968
  shows "fset (ffilter P xs) = P \<inter> fset xs"
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   969
  by (descending) (auto simp add: mem_def)
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   970
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   971
lemma fdelete_set [simp]: 
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   972
  shows "fset (fdelete x xs) = fset xs - {x}"
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   973
  by (lifting set_removeAll)
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   974
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   975
lemma finter_set [simp]: 
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   976
  shows "fset (xs |\<inter>| ys) = fset xs \<inter> fset ys"
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   977
  by (lifting set_finter_raw)
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   978
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   979
lemma funion_set [simp]: 
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   980
  shows "fset (xs |\<union>| ys) = fset xs \<union> fset ys"
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   981
  by (lifting set_append)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   982
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   983
lemma fminus_set [simp]: 
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   984
  shows "fset (xs - ys) = fset xs - fset ys"
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   985
  by (lifting set_fminus_raw)
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   986
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   987
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   988
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   989
section {* ffold *}
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   990
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   991
lemma ffold_nil: 
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   992
  shows "ffold f z {||} = z"
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   993
  by (lifting ffold_raw.simps(1)[where 'a="'b" and 'b="'a"])
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   994
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   995
lemma ffold_finsert: "ffold f z (finsert a A) =
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   996
  (if rsp_fold f then if a |\<in>| A then ffold f z A else f a (ffold f z A) else z)"
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
   997
  by (descending) (simp add: memb_def)
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   998
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   999
lemma fin_commute_ffold:
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1000
  "\<lbrakk>rsp_fold f; h |\<in>| b\<rbrakk> \<Longrightarrow> ffold f z b = f h (ffold f z (fdelete h b))"
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1001
  by (descending) (simp add: memb_def memb_commute_ffold_raw)
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1002
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1003
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1004
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1005
section {* fdelete *}
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1006
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1007
lemma fin_fdelete:
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1008
  shows "x |\<in>| fdelete y S \<longleftrightarrow> x |\<in>| S \<and> x \<noteq> y"
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1009
  by (descending) (simp add: memb_def)
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1010
2525
c848f93807b9 deleted some unused lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2524
diff changeset
  1011
lemma fnotin_fdelete:
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1012
  shows "x |\<notin>| fdelete x S"
2525
c848f93807b9 deleted some unused lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2524
diff changeset
  1013
  by (descending) (simp add: memb_def)
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1014
2525
c848f93807b9 deleted some unused lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2524
diff changeset
  1015
lemma fnotin_fdelete_ident:
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1016
  shows "x |\<notin>| S \<Longrightarrow> fdelete x S = S"
2525
c848f93807b9 deleted some unused lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2524
diff changeset
  1017
  by (descending) (simp add: memb_def)
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1018
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1019
lemma fset_fdelete_cases:
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1020
  shows "S = {||} \<or> (\<exists>x. x |\<in>| S \<and> S = finsert x (fdelete x S))"
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1021
  by (lifting fset_raw_removeAll_cases)
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1022
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1023
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1024
section {* finter *}
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1025
2530
3b8741ecfda3 FSet synchronizing
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2529
diff changeset
  1026
lemma finter_empty_l:
3b8741ecfda3 FSet synchronizing
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2529
diff changeset
  1027
  shows "{||} |\<inter>| S = {||}"
3b8741ecfda3 FSet synchronizing
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2529
diff changeset
  1028
  by simp
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1029
2530
3b8741ecfda3 FSet synchronizing
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2529
diff changeset
  1030
lemma finter_empty_r:
3b8741ecfda3 FSet synchronizing
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2529
diff changeset
  1031
  shows "S |\<inter>| {||} = {||}"
3b8741ecfda3 FSet synchronizing
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2529
diff changeset
  1032
  by simp
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1033
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1034
lemma finter_finsert:
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1035
  shows "finsert x S |\<inter>| T = (if x |\<in>| T then finsert x (S |\<inter>| T) else S |\<inter>| T)"
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1036
  by (descending) (simp add: memb_def)
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1037
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1038
lemma fin_finter:
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1039
  shows "x |\<in>| (S |\<inter>| T) \<longleftrightarrow> x |\<in>| S \<and> x |\<in>| T"
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1040
  by (descending) (simp add: memb_def)
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1041
1893
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
  1042
lemma fsubset_finsert:
2530
3b8741ecfda3 FSet synchronizing
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2529
diff changeset
  1043
  shows "finsert x xs |\<subseteq>| ys \<longleftrightarrow> x |\<in>| ys \<and> xs |\<subseteq>| ys"
1893
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
  1044
  by (lifting sub_list_cons)
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
  1045
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1046
lemma 
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1047
  shows "xs |\<subseteq>| ys \<equiv> \<forall>x. x |\<in>| xs \<longrightarrow> x |\<in>| ys"
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1048
  by (descending) (auto simp add: sub_list_def memb_def)
1893
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
  1049
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1050
lemma fsubset_fin: 
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1051
  shows "xs |\<subseteq>| ys = (\<forall>x. x |\<in>| xs \<longrightarrow> x |\<in>| ys)"
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1052
  by (descending) (auto simp add: sub_list_def memb_def)
1893
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
  1053
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1054
lemma fminus_fin: 
2530
3b8741ecfda3 FSet synchronizing
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2529
diff changeset
  1055
  shows "x |\<in>| xs - ys \<longleftrightarrow> x |\<in>| xs \<and> x |\<notin>| ys"
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1056
  by (descending) (simp add: memb_def)
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1057
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1058
lemma fminus_red: 
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1059
  shows "finsert x xs - ys = (if x |\<in>| ys then xs - ys else finsert x (xs - ys))"
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1060
  by (descending) (auto simp add: memb_def)
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1061
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1062
lemma fminus_red_fin[simp]: 
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1063
  shows "x |\<in>| ys \<Longrightarrow> finsert x xs - ys = xs - ys"
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1064
  by (simp add: fminus_red)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1065
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1066
lemma fminus_red_fnotin[simp]: 
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1067
  shows "x |\<notin>| ys \<Longrightarrow> finsert x xs - ys = finsert x (xs - ys)"
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1068
  by (simp add: fminus_red)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1069
2479
a9b6a00b1ba0 updated to Isabelle Sept 16
Christian Urban <urbanc@in.tum.de>
parents: 2378
diff changeset
  1070
lemma fset_eq_iff:
2528
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
  1071
  shows "S = T \<longleftrightarrow> (\<forall>x. (x |\<in>| S) = (x |\<in>| T))"
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1072
  by (descending) (auto simp add: memb_def)
1820
de28a91eaca3 Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1819
diff changeset
  1073
1888
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1074
(* We cannot write it as "assumes .. shows" since Isabelle changes
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1075
   the quantifiers to schematic variables and reintroduces them in
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1076
   a different order *)
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1077
lemma fset_eq_cases:
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1078
 "\<lbrakk>a1 = a2;
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1079
   \<And>a b xs. \<lbrakk>a1 = finsert a (finsert b xs); a2 = finsert b (finsert a xs)\<rbrakk> \<Longrightarrow> P;
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1080
   \<lbrakk>a1 = {||}; a2 = {||}\<rbrakk> \<Longrightarrow> P; \<And>xs ys. \<lbrakk>a1 = ys; a2 = xs; xs = ys\<rbrakk> \<Longrightarrow> P;
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1081
   \<And>a xs. \<lbrakk>a1 = finsert a (finsert a xs); a2 = finsert a xs\<rbrakk> \<Longrightarrow> P;
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1082
   \<And>xs ys a. \<lbrakk>a1 = finsert a xs; a2 = finsert a ys; xs = ys\<rbrakk> \<Longrightarrow> P;
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1083
   \<And>xs1 xs2 xs3. \<lbrakk>a1 = xs1; a2 = xs3; xs1 = xs2; xs2 = xs3\<rbrakk> \<Longrightarrow> P\<rbrakk>
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1084
  \<Longrightarrow> P"
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1085
  by (lifting list_eq2.cases[simplified list_eq2_equiv[symmetric]])
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1086
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1087
lemma fset_eq_induct:
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1088
  assumes "x1 = x2"
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1089
  and "\<And>a b xs. P (finsert a (finsert b xs)) (finsert b (finsert a xs))"
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1090
  and "P {||} {||}"
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1091
  and "\<And>xs ys. \<lbrakk>xs = ys; P xs ys\<rbrakk> \<Longrightarrow> P ys xs"
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1092
  and "\<And>a xs. P (finsert a (finsert a xs)) (finsert a xs)"
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1093
  and "\<And>xs ys a. \<lbrakk>xs = ys; P xs ys\<rbrakk> \<Longrightarrow> P (finsert a xs) (finsert a ys)"
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1094
  and "\<And>xs1 xs2 xs3. \<lbrakk>xs1 = xs2; P xs1 xs2; xs2 = xs3; P xs2 xs3\<rbrakk> \<Longrightarrow> P xs1 xs3"
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1095
  shows "P x1 x2"
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1096
  using assms
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1097
  by (lifting list_eq2.induct[simplified list_eq2_equiv[symmetric]])
1820
de28a91eaca3 Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1819
diff changeset
  1098
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1099
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1100
section {* fconcat *}
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
  1101
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
  1102
lemma fconcat_empty:
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
  1103
  shows "fconcat {||} = {||}"
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
  1104
  by (lifting concat.simps(1))
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
  1105
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
  1106
lemma fconcat_insert:
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
  1107
  shows "fconcat (finsert x S) = x |\<union>| fconcat S"
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
  1108
  by (lifting concat.simps(2))
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
  1109
2528
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
  1110
lemma 
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
  1111
  shows "fconcat (xs |\<union>| ys) = fconcat xs |\<union>| fconcat ys"
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
  1112
  by (lifting concat_append)
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
  1113
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1114
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1115
section {* ffilter *}
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1116
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1117
lemma subseteq_filter: 
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1118
  shows "ffilter P xs <= ffilter Q xs = (\<forall> x. x |\<in>| xs \<longrightarrow> P x \<longrightarrow> Q x)"
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1119
  by  (descending) (auto simp add: memb_def sub_list_def)
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1120
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1121
lemma eq_ffilter: 
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1122
  shows "(ffilter P xs = ffilter Q xs) = (\<forall>x. x |\<in>| xs \<longrightarrow> P x = Q x)"
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1123
  by (descending) (auto simp add: memb_def)
2529
775d0bfd99fd Synchronizing FSet further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2528
diff changeset
  1124
775d0bfd99fd Synchronizing FSet further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2528
diff changeset
  1125
lemma subset_ffilter:
775d0bfd99fd Synchronizing FSet further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2528
diff changeset
  1126
  shows "(\<And>x. x |\<in>| xs \<Longrightarrow> P x \<Longrightarrow> Q x) \<Longrightarrow> (x |\<in>| xs & \<not> P x & Q x) \<Longrightarrow> ffilter P xs < ffilter Q xs"
775d0bfd99fd Synchronizing FSet further.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2528
diff changeset
  1127
  unfolding less_fset_def by (auto simp add: subseteq_filter eq_ffilter)
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1128
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1129
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1130
section {* lemmas transferred from Finite_Set theory *}
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1131
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1132
text {* finiteness for finite sets holds *}
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1133
lemma finite_fset [simp]: 
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1134
  shows "finite (fset S)"
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1135
  by (induct S) auto
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1136
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1137
lemma fset_choice: 
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1138
  shows "\<forall>x. x |\<in>| A \<longrightarrow> (\<exists>y. P x y) \<Longrightarrow> \<exists>f. \<forall>x. x |\<in>| A \<longrightarrow> P x (f x)"
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1139
  apply(descending)
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1140
  apply(simp add: memb_def)
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1141
  apply(rule finite_set_choice[simplified Ball_def])
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1142
  apply(simp_all)
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1143
  done
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1144
2530
3b8741ecfda3 FSet synchronizing
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2529
diff changeset
  1145
lemma fsubseteq_fempty:
3b8741ecfda3 FSet synchronizing
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2529
diff changeset
  1146
  shows "xs |\<subseteq>| {||} \<longleftrightarrow> xs = {||}"
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1147
  by (metis finter_empty_r le_iff_inf)
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1148
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1149
lemma not_fsubset_fnil: 
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1150
  shows "\<not> xs |\<subset>| {||}"
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1151
  by (metis fset_simps(1) fsubset_set not_psubset_empty)
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1152
  
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1153
lemma fcard_mono: 
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1154
  shows "xs |\<subseteq>| ys \<Longrightarrow> fcard xs \<le> fcard ys"
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1155
  unfolding fcard_set fsubseteq_set
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1156
  by (rule card_mono[OF finite_fset])
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1157
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1158
lemma fcard_fseteq: 
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1159
  shows "xs |\<subseteq>| ys \<Longrightarrow> fcard ys \<le> fcard xs \<Longrightarrow> xs = ys"
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1160
  unfolding fcard_set fsubseteq_set
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1161
  by (simp add: card_seteq[OF finite_fset] fset_cong)
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1162
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1163
lemma psubset_fcard_mono: 
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1164
  shows "xs |\<subset>| ys \<Longrightarrow> fcard xs < fcard ys"
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1165
  unfolding fcard_set fsubset_set
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1166
  by (rule psubset_card_mono[OF finite_fset])
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1167
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1168
lemma fcard_funion_finter: 
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1169
  shows "fcard xs + fcard ys = fcard (xs |\<union>| ys) + fcard (xs |\<inter>| ys)"
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1170
  unfolding fcard_set funion_set finter_set
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1171
  by (rule card_Un_Int[OF finite_fset finite_fset])
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1172
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1173
lemma fcard_funion_disjoint: 
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1174
  shows "xs |\<inter>| ys = {||} \<Longrightarrow> fcard (xs |\<union>| ys) = fcard xs + fcard ys"
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1175
  unfolding fcard_set funion_set 
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1176
  apply (rule card_Un_disjoint[OF finite_fset finite_fset])
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1177
  by (metis finter_set fset_simps(1))
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1178
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1179
lemma fcard_delete1_less: 
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1180
  shows "x |\<in>| xs \<Longrightarrow> fcard (fdelete x xs) < fcard xs"
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1181
  unfolding fcard_set fin_set fdelete_set 
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1182
  by (rule card_Diff1_less[OF finite_fset])
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1183
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1184
lemma fcard_delete2_less: 
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1185
  shows "x |\<in>| xs \<Longrightarrow> y |\<in>| xs \<Longrightarrow> fcard (fdelete y (fdelete x xs)) < fcard xs"
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1186
  unfolding fcard_set fdelete_set fin_set
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1187
  by (rule card_Diff2_less[OF finite_fset])
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1188
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1189
lemma fcard_delete1_le: 
2531
8054f4988672 FSet: stronger fact in Isabelle.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2530
diff changeset
  1190
  shows "fcard (fdelete x xs) \<le> fcard xs"
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1191
  unfolding fdelete_set fcard_set
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1192
  by (rule card_Diff1_le[OF finite_fset])
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1193
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1194
lemma fcard_psubset: 
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1195
  shows "ys |\<subseteq>| xs \<Longrightarrow> fcard ys < fcard xs \<Longrightarrow> ys |\<subset>| xs"
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1196
  unfolding fcard_set fsubseteq_set fsubset_set
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1197
  by (rule card_psubset[OF finite_fset])
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1198
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1199
lemma fcard_fmap_le: 
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1200
  shows "fcard (fmap f xs) \<le> fcard xs"
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1201
  unfolding fcard_set  fmap_set_image
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1202
  by (rule card_image_le[OF finite_fset])
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1203
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1204
lemma fin_fminus_fnotin: 
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1205
  shows "x |\<in>| F - S \<Longrightarrow> x |\<notin>| S"
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1206
  unfolding fin_set fminus_set
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1207
  by blast
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1208
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1209
lemma fin_fnotin_fminus: 
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1210
  shows "x |\<in>| S \<Longrightarrow> x |\<notin>| F - S"
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1211
  unfolding fin_set fminus_set
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1212
  by blast
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1213
2530
3b8741ecfda3 FSet synchronizing
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2529
diff changeset
  1214
lemma fin_mdef:
3b8741ecfda3 FSet synchronizing
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2529
diff changeset
  1215
  shows "x |\<in>| F \<longleftrightarrow> x |\<notin>| (F - {|x|}) \<and> F = finsert x (F - {|x|})"
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1216
  unfolding fin_set fset_simps fset_cong fminus_set
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1217
  by blast
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1218
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1219
lemma fcard_fminus_finsert[simp]:
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1220
  assumes "a |\<in>| A" and "a |\<notin>| B"
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1221
  shows "fcard (A - finsert a B) = fcard (A - B) - 1"
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1222
  using assms 
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1223
  unfolding fin_set fcard_set fminus_set
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1224
  by (simp add: card_Diff_insert[OF finite_fset])
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1225
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1226
lemma fcard_fminus_fsubset:
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1227
  assumes "B |\<subseteq>| A"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1228
  shows "fcard (A - B) = fcard A - fcard B"
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1229
  using assms 
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1230
  unfolding fsubseteq_set fcard_set fminus_set
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1231
  by (rule card_Diff_subset[OF finite_fset])
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1232
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1233
lemma fcard_fminus_subset_finter:
2524
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1234
  shows "fcard (A - B) = fcard A - fcard (A |\<inter>| B)"
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1235
  unfolding finter_set fcard_set fminus_set
693562f03eee major reorganisation of fset (renamed fset_to_set to fset, changed the definition of list_eq and fcard_raw)
Christian Urban <urbanc@in.tum.de>
parents: 2479
diff changeset
  1236
  by (rule card_Diff_subset_Int) (simp)
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1237
2234
8035515bbbc6 something about the quotient ype definitions
Christian Urban <urbanc@in.tum.de>
parents: 2222
diff changeset
  1238
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
  1239
lemma list_all2_refl:
2266
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1240
  assumes q: "equivp R"
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
  1241
  shows "(list_all2 R) r r"
2378
2f13fe48c877 updated to new Isabelle; made FSet more "quiet"
Christian Urban <urbanc@in.tum.de>
parents: 2372
diff changeset
  1242
  by (rule list_all2_refl) (metis equivp_def q)
2266
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1243
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1244
lemma compose_list_refl2:
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1245
  assumes q: "equivp R"
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
  1246
  shows "(list_all2 R OOO op \<approx>) r r"
2266
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1247
proof
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1248
  have *: "r \<approx> r" by (rule equivp_reflp[OF fset_equivp])
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
  1249
  show "list_all2 R r r" by (rule list_all2_refl[OF q])
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
  1250
  with * show "(op \<approx> OO list_all2 R) r r" ..
2266
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1251
qed
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1252
2285
965ee8f08d4c eliminated a quot_thm flag
Christian Urban <urbanc@in.tum.de>
parents: 2278
diff changeset
  1253
lemma quotient_compose_list_g:
2266
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1254
  assumes q: "Quotient R Abs Rep"
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1255
  and     e: "equivp R"
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
  1256
  shows  "Quotient ((list_all2 R) OOO (op \<approx>))
2266
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1257
    (abs_fset \<circ> (map Abs)) ((map Rep) \<circ> rep_fset)"
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1258
  unfolding Quotient_def comp_def
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1259
proof (intro conjI allI)
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1260
  fix a r s
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1261
  show "abs_fset (map Abs (map Rep (rep_fset a))) = a"
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1262
    by (simp add: abs_o_rep[OF q] Quotient_abs_rep[OF Quotient_fset] map_id)
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
  1263
  have b: "list_all2 R (map Rep (rep_fset a)) (map Rep (rep_fset a))"
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
  1264
    by (rule list_all2_refl[OF e])
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
  1265
  have c: "(op \<approx> OO list_all2 R) (map Rep (rep_fset a)) (map Rep (rep_fset a))"
2266
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1266
    by (rule, rule equivp_reflp[OF fset_equivp]) (rule b)
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
  1267
  show "(list_all2 R OOO op \<approx>) (map Rep (rep_fset a)) (map Rep (rep_fset a))"
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
  1268
    by (rule, rule list_all2_refl[OF e]) (rule c)
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
  1269
  show "(list_all2 R OOO op \<approx>) r s = ((list_all2 R OOO op \<approx>) r r \<and>
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
  1270
        (list_all2 R OOO op \<approx>) s s \<and> abs_fset (map Abs r) = abs_fset (map Abs s))"
2266
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1271
  proof (intro iffI conjI)
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
  1272
    show "(list_all2 R OOO op \<approx>) r r" by (rule compose_list_refl2[OF e])
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
  1273
    show "(list_all2 R OOO op \<approx>) s s" by (rule compose_list_refl2[OF e])
2266
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1274
  next
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
  1275
    assume a: "(list_all2 R OOO op \<approx>) r s"
2266
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1276
    then have b: "map Abs r \<approx> map Abs s"
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1277
    proof (elim pred_compE)
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1278
      fix b ba
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
  1279
      assume c: "list_all2 R r b"
2266
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1280
      assume d: "b \<approx> ba"
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
  1281
      assume e: "list_all2 R ba s"
2266
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1282
      have f: "map Abs r = map Abs b"
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1283
        using Quotient_rel[OF list_quotient[OF q]] c by blast
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1284
      have "map Abs ba = map Abs s"
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1285
        using Quotient_rel[OF list_quotient[OF q]] e by blast
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1286
      then have g: "map Abs s = map Abs ba" by simp
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1287
      then show "map Abs r \<approx> map Abs s" using d f map_rel_cong by simp
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1288
    qed
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1289
    then show "abs_fset (map Abs r) = abs_fset (map Abs s)"
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1290
      using Quotient_rel[OF Quotient_fset] by blast
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1291
  next
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
  1292
    assume a: "(list_all2 R OOO op \<approx>) r r \<and> (list_all2 R OOO op \<approx>) s s
2266
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1293
      \<and> abs_fset (map Abs r) = abs_fset (map Abs s)"
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
  1294
    then have s: "(list_all2 R OOO op \<approx>) s s" by simp
2266
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1295
    have d: "map Abs r \<approx> map Abs s"
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1296
      by (subst Quotient_rel[OF Quotient_fset]) (simp add: a)
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1297
    have b: "map Rep (map Abs r) \<approx> map Rep (map Abs s)"
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1298
      by (rule map_rel_cong[OF d])
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
  1299
    have y: "list_all2 R (map Rep (map Abs s)) s"
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
  1300
      by (fact rep_abs_rsp_left[OF list_quotient[OF q], OF list_all2_refl[OF e, of s]])
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
  1301
    have c: "(op \<approx> OO list_all2 R) (map Rep (map Abs r)) s"
2266
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1302
      by (rule pred_compI) (rule b, rule y)
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
  1303
    have z: "list_all2 R r (map Rep (map Abs r))"
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
  1304
      by (fact rep_abs_rsp[OF list_quotient[OF q], OF list_all2_refl[OF e, of r]])
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
  1305
    then show "(list_all2 R OOO op \<approx>) r s"
2266
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1306
      using a c pred_compI by simp
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1307
  qed
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1308
qed
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1309
2528
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
  1310
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
  1311
ML {*
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
  1312
fun dest_fsetT (Type (@{type_name fset}, [T])) = T
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
  1313
  | dest_fsetT T = raise TYPE ("dest_fsetT: fset type expected", [T], []);
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
  1314
*}
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
  1315
2266
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1316
no_notation
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1317
  list_eq (infix "\<approx>" 50)
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1318
2234
8035515bbbc6 something about the quotient ype definitions
Christian Urban <urbanc@in.tum.de>
parents: 2222
diff changeset
  1319
end