Nominal/FSet.thy
author Christian Urban <urbanc@in.tum.de>
Sun, 17 Oct 2010 21:40:23 +0100
changeset 2543 8537493c039f
parent 2542 1f5c8e85c41f
child 2544 3b24b5d2b68c
permissions -rw-r--r--
fixed typo
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
2543
8537493c039f fixed typo
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
    12
text {* Definition of the equivalence relation over lists *}
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 {* 
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
    32
  Definitions for membership, sublist, cardinality, 
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
    33
  intersection, difference and respectful fold over 
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
    34
  lists.
2372
Christian Urban <urbanc@in.tum.de>
parents: 2371
diff changeset
    35
*}
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    36
1889
6c5b5ec53a0b sub_list definition and respects
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1888
diff changeset
    37
definition
6c5b5ec53a0b sub_list definition and respects
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1888
diff changeset
    38
  "memb x xs \<equiv> x \<in> set xs"
6c5b5ec53a0b sub_list definition and respects
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1888
diff changeset
    39
6c5b5ec53a0b sub_list definition and respects
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1888
diff changeset
    40
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
    41
  "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
    42
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
    43
definition
2536
98e84b56543f renamed fcard_raw to card_list
Christian Urban <urbanc@in.tum.de>
parents: 2534
diff changeset
    44
  "card_list xs = card (set xs)"
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    45
2538
c9deccd12476 further tuning
Christian Urban <urbanc@in.tum.de>
parents: 2537
diff changeset
    46
definition
c9deccd12476 further tuning
Christian Urban <urbanc@in.tum.de>
parents: 2537
diff changeset
    47
  "inter_list xs ys = [x \<leftarrow> xs. x \<in> set xs \<and> x \<in> set ys]"
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
    48
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
    49
definition
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
    50
  "diff_list xs ys \<equiv> [x \<leftarrow> xs. x \<notin> set ys]"
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
    51
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    52
definition
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    53
  rsp_fold
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    54
where
2538
c9deccd12476 further tuning
Christian Urban <urbanc@in.tum.de>
parents: 2537
diff changeset
    55
  "rsp_fold f \<equiv> \<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
    56
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    57
primrec
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
    58
  fold_list :: "('a \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> 'b \<Rightarrow> 'a list \<Rightarrow> 'b"
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    59
where
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
    60
  "fold_list f z [] = z"
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
    61
| "fold_list f z (a # xs) =
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    62
     (if (rsp_fold f) then
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
    63
       if a \<in> set xs then fold_list f z xs
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
    64
       else f a (fold_list f z xs)
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    65
     else z)"
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    66
2533
767161329839 further cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2532
diff changeset
    67
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
    68
2533
767161329839 further cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2532
diff changeset
    69
section {* Quotient composition lemmas *}
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
    70
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
    71
lemma list_all2_refl':
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
    72
  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
    73
  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
    74
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
    75
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
    76
  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
    77
proof
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
    78
  have *: "r \<approx> r" by (rule equivp_reflp[OF fset_equivp])
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
    79
  show "list_all2 op \<approx> r r" by (rule list_all2_refl')
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
    80
  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
    81
qed
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
    82
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
    83
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
    84
  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
    85
  by (fact list_quotient[OF Quotient_fset])
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
    86
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
    87
lemma map_list_eq_cong: "b \<approx> ba \<Longrightarrow> map f b \<approx> map f ba"
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
    88
  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
    89
  by (simp only: set_map)
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
    90
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
    91
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
    92
  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
    93
    (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
    94
  unfolding Quotient_def comp_def
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
    95
proof (intro conjI allI)
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
    96
  fix a r s
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
    97
  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
    98
    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
    99
  have b: "list_all2 op \<approx> (map rep_fset (rep_fset a)) (map rep_fset (rep_fset a))"
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   100
    by (rule list_all2_refl')
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   101
  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
   102
    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
   103
  show "(list_all2 op \<approx> OOO op \<approx>) (map rep_fset (rep_fset a)) (map rep_fset (rep_fset a))"
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   104
    by (rule, rule list_all2_refl') (rule c)
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   105
  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
   106
        (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
   107
  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
   108
    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
   109
    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
   110
  next
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   111
    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
   112
    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
   113
    proof (elim pred_compE)
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   114
      fix b ba
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   115
      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
   116
      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
   117
      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
   118
      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
   119
        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
   120
      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
   121
        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
   122
      then have g: "map abs_fset s = map abs_fset ba" by simp
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   123
      then show "map abs_fset r \<approx> map abs_fset s" using d f map_list_eq_cong by simp
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   124
    qed
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   125
    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
   126
      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
   127
  next
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   128
    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
   129
      \<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
   130
    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
   131
    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
   132
      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
   133
    have b: "map rep_fset (map abs_fset r) \<approx> map rep_fset (map abs_fset s)"
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   134
      by (rule map_list_eq_cong[OF d])
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   135
    have y: "list_all2 op \<approx> (map rep_fset (map abs_fset s)) s"
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   136
      by (fact rep_abs_rsp_left[OF Quotient_fset_list, OF list_all2_refl'[of s]])
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   137
    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
   138
      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
   139
    have z: "list_all2 op \<approx> r (map rep_fset (map abs_fset r))"
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   140
      by (fact rep_abs_rsp[OF Quotient_fset_list, OF list_all2_refl'[of r]])
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   141
    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
   142
      using a c pred_compI by simp
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   143
  qed
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   144
qed
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   145
2525
c848f93807b9 deleted some unused lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2524
diff changeset
   146
2538
c9deccd12476 further tuning
Christian Urban <urbanc@in.tum.de>
parents: 2537
diff changeset
   147
subsection {* Respectfulness lemmas for list operations *}
1893
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   148
2538
c9deccd12476 further tuning
Christian Urban <urbanc@in.tum.de>
parents: 2537
diff changeset
   149
lemma list_equiv_rsp [quot_respect]:
c9deccd12476 further tuning
Christian Urban <urbanc@in.tum.de>
parents: 2537
diff changeset
   150
  shows "(op \<approx> ===> op \<approx> ===> op =) op \<approx> op \<approx>"
c9deccd12476 further tuning
Christian Urban <urbanc@in.tum.de>
parents: 2537
diff changeset
   151
  by auto
c9deccd12476 further tuning
Christian Urban <urbanc@in.tum.de>
parents: 2537
diff changeset
   152
c9deccd12476 further tuning
Christian Urban <urbanc@in.tum.de>
parents: 2537
diff changeset
   153
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
   154
  shows "(op \<approx> ===> op \<approx> ===> op \<approx>) append append"
2533
767161329839 further cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2532
diff changeset
   155
  by simp
1895
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   156
2538
c9deccd12476 further tuning
Christian Urban <urbanc@in.tum.de>
parents: 2537
diff changeset
   157
lemma sub_list_rsp [quot_respect]:
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   158
  shows "(op \<approx> ===> op \<approx> ===> op =) sub_list sub_list"
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   159
  by (auto simp add: sub_list_def)
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   160
2538
c9deccd12476 further tuning
Christian Urban <urbanc@in.tum.de>
parents: 2537
diff changeset
   161
lemma memb_rsp [quot_respect]:
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   162
  shows "(op = ===> op \<approx> ===> op =) memb memb"
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   163
  by (auto simp add: memb_def)
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   164
2538
c9deccd12476 further tuning
Christian Urban <urbanc@in.tum.de>
parents: 2537
diff changeset
   165
lemma nil_rsp [quot_respect]:
2525
c848f93807b9 deleted some unused lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2524
diff changeset
   166
  shows "(op \<approx>) Nil Nil"
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   167
  by simp
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   168
2538
c9deccd12476 further tuning
Christian Urban <urbanc@in.tum.de>
parents: 2537
diff changeset
   169
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
   170
  shows "(op = ===> op \<approx> ===> op \<approx>) Cons Cons"
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   171
  by simp
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   172
2538
c9deccd12476 further tuning
Christian Urban <urbanc@in.tum.de>
parents: 2537
diff changeset
   173
lemma map_rsp [quot_respect]:
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   174
  shows "(op = ===> op \<approx> ===> op \<approx>) map map"
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   175
  by auto
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   176
2538
c9deccd12476 further tuning
Christian Urban <urbanc@in.tum.de>
parents: 2537
diff changeset
   177
lemma set_rsp [quot_respect]:
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   178
  "(op \<approx> ===> op =) set set"
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   179
  by auto
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   180
2538
c9deccd12476 further tuning
Christian Urban <urbanc@in.tum.de>
parents: 2537
diff changeset
   181
lemma inter_list_rsp [quot_respect]:
c9deccd12476 further tuning
Christian Urban <urbanc@in.tum.de>
parents: 2537
diff changeset
   182
  shows "(op \<approx> ===> op \<approx> ===> op \<approx>) inter_list inter_list"
c9deccd12476 further tuning
Christian Urban <urbanc@in.tum.de>
parents: 2537
diff changeset
   183
  by (simp add: inter_list_def)
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   184
2538
c9deccd12476 further tuning
Christian Urban <urbanc@in.tum.de>
parents: 2537
diff changeset
   185
lemma removeAll_rsp [quot_respect]:
2525
c848f93807b9 deleted some unused lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2524
diff changeset
   186
  shows "(op = ===> op \<approx> ===> op \<approx>) removeAll removeAll"
c848f93807b9 deleted some unused lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2524
diff changeset
   187
  by simp
c848f93807b9 deleted some unused lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2524
diff changeset
   188
2538
c9deccd12476 further tuning
Christian Urban <urbanc@in.tum.de>
parents: 2537
diff changeset
   189
lemma diff_list_rsp [quot_respect]:
2537
d73fa7a3e04b renamed fminus_raw to diff_list
Christian Urban <urbanc@in.tum.de>
parents: 2536
diff changeset
   190
  shows "(op \<approx> ===> op \<approx> ===> op \<approx>) diff_list diff_list"
2538
c9deccd12476 further tuning
Christian Urban <urbanc@in.tum.de>
parents: 2537
diff changeset
   191
  by (simp add: diff_list_def)
2525
c848f93807b9 deleted some unused lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2524
diff changeset
   192
2538
c9deccd12476 further tuning
Christian Urban <urbanc@in.tum.de>
parents: 2537
diff changeset
   193
lemma card_list_rsp [quot_respect]:
2536
98e84b56543f renamed fcard_raw to card_list
Christian Urban <urbanc@in.tum.de>
parents: 2534
diff changeset
   194
  shows "(op \<approx> ===> op =) card_list card_list"
98e84b56543f renamed fcard_raw to card_list
Christian Urban <urbanc@in.tum.de>
parents: 2534
diff changeset
   195
  by (simp add: card_list_def)
2525
c848f93807b9 deleted some unused lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2524
diff changeset
   196
2538
c9deccd12476 further tuning
Christian Urban <urbanc@in.tum.de>
parents: 2537
diff changeset
   197
lemma filter_rsp [quot_respect]:
c9deccd12476 further tuning
Christian Urban <urbanc@in.tum.de>
parents: 2537
diff changeset
   198
  shows "(op = ===> op \<approx> ===> op \<approx>) filter filter"
c9deccd12476 further tuning
Christian Urban <urbanc@in.tum.de>
parents: 2537
diff changeset
   199
  by simp
2525
c848f93807b9 deleted some unused lemmas
Christian Urban <urbanc@in.tum.de>
parents: 2524
diff changeset
   200
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   201
lemma memb_commute_fold_list:
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   202
  assumes a: "rsp_fold f"
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   203
  and     b: "x \<in> set xs"
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   204
  shows "fold_list f y xs = f x (fold_list f y (removeAll x xs))"
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   205
  using a b by (induct xs) (auto simp add: rsp_fold_def)
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   206
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   207
lemma fold_list_rsp_pre:
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   208
  assumes a: "set xs = set ys"
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   209
  shows "fold_list f z xs = fold_list f z ys"
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   210
  using a
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   211
  apply (induct xs arbitrary: ys)
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   212
  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
   213
  apply (simp (no_asm_use))
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   214
  apply (rule conjI)
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   215
  apply (rule_tac [!] impI)
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   216
  apply (rule_tac [!] conjI)
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   217
  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
   218
  apply (metis insert_absorb)
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   219
  apply (metis List.insert_def List.set.simps(2) List.set_insert fold_list.simps(2))
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   220
  apply (metis Diff_insert_absorb insertI1 memb_commute_fold_list set_removeAll)
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   221
  apply(drule_tac x="removeAll a ys" in meta_spec)
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
   222
  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
   223
  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
   224
  apply(blast)
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   225
  by (metis List.set.simps(2) emptyE fold_list.simps(2) in_listsp_conv_set listsp.simps mem_def)
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   226
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   227
lemma fold_list_rsp [quot_respect]:
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   228
  shows "(op = ===> op = ===> op \<approx> ===> op =) fold_list fold_list"
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
  unfolding fun_rel_def
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   230
  by(auto intro: fold_list_rsp_pre)
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   231
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   232
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
   233
  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
   234
  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
   235
  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
   236
  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
   237
  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
   238
proof -
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   239
  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
   240
  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
   241
  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
   242
  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
   243
  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
   244
  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
   245
qed
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   246
2538
c9deccd12476 further tuning
Christian Urban <urbanc@in.tum.de>
parents: 2537
diff changeset
   247
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
   248
  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
   249
proof (rule fun_relI, elim pred_compE)
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   250
  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
   251
  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
   252
  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
   253
  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
   254
  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
   255
  proof
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   256
    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
   257
    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
   258
    proof
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   259
      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
   260
      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
   261
    next
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   262
      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
   263
      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
   264
      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
   265
      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
   266
      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
   267
    qed
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   268
  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
   269
  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
   270
qed
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   271
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   272
2539
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
   273
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
   274
section {* Quotient definitions for fsets *}
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
   275
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
   276
2538
c9deccd12476 further tuning
Christian Urban <urbanc@in.tum.de>
parents: 2537
diff changeset
   277
subsection {* Finite sets are a bounded, distributive lattice with minus *}
1905
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   278
2528
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
   279
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
   280
begin
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   281
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   282
quotient_definition
2538
c9deccd12476 further tuning
Christian Urban <urbanc@in.tum.de>
parents: 2537
diff changeset
   283
  "bot :: 'a fset" 
c9deccd12476 further tuning
Christian Urban <urbanc@in.tum.de>
parents: 2537
diff changeset
   284
  is "Nil :: 'a list"
1893
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   285
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   286
abbreviation
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   287
  empty_fset  ("{||}")
1893
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   288
where
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   289
  "{||} \<equiv> bot :: 'a fset"
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   290
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   291
quotient_definition
2538
c9deccd12476 further tuning
Christian Urban <urbanc@in.tum.de>
parents: 2537
diff changeset
   292
  "less_eq_fset :: ('a fset \<Rightarrow> 'a fset \<Rightarrow> bool)"
c9deccd12476 further tuning
Christian Urban <urbanc@in.tum.de>
parents: 2537
diff changeset
   293
  is "sub_list :: ('a list \<Rightarrow> 'a list \<Rightarrow> bool)"
1893
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   294
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   295
abbreviation
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   296
  subset_fset :: "'a fset \<Rightarrow> 'a fset \<Rightarrow> bool" (infix "|\<subseteq>|" 50)
1893
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   297
where
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   298
  "xs |\<subseteq>| ys \<equiv> xs \<le> ys"
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   299
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   300
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
   301
  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
   302
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
   303
  "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
   304
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   305
abbreviation
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   306
  psubset_fset :: "'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
   307
where
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   308
  "xs |\<subset>| ys \<equiv> xs < ys"
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   309
1895
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   310
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
   311
  "sup :: 'a fset \<Rightarrow> 'a fset \<Rightarrow> 'a fset"
2538
c9deccd12476 further tuning
Christian Urban <urbanc@in.tum.de>
parents: 2537
diff changeset
   312
  is "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
   313
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   314
abbreviation
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   315
  union_fset (infixl "|\<union>|" 65)
1895
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   316
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
   317
  "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
   318
1905
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   319
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
   320
  "inf :: 'a fset \<Rightarrow> 'a fset \<Rightarrow> 'a fset"
2538
c9deccd12476 further tuning
Christian Urban <urbanc@in.tum.de>
parents: 2537
diff changeset
   321
  is "inter_list :: 'a list \<Rightarrow> 'a list \<Rightarrow> 'a list"
1905
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   322
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   323
abbreviation
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   324
  inter_fset (infixl "|\<inter>|" 65)
1905
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   325
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
   326
  "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
   327
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   328
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
   329
  "minus :: 'a fset \<Rightarrow> 'a fset \<Rightarrow> 'a fset"
2538
c9deccd12476 further tuning
Christian Urban <urbanc@in.tum.de>
parents: 2537
diff changeset
   330
  is "diff_list :: 'a list \<Rightarrow> 'a list \<Rightarrow> 'a list"
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   331
2533
767161329839 further cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2532
diff changeset
   332
1895
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   333
instance
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   334
proof
1905
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   335
  fix x y z :: "'a fset"
2528
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
   336
  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
   337
    unfolding less_fset_def 
3b8741ecfda3 FSet synchronizing
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2529
diff changeset
   338
    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
   339
  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
   340
  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
   341
  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
   342
  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
   343
  show "x |\<inter>| y |\<subseteq>| x"
2538
c9deccd12476 further tuning
Christian Urban <urbanc@in.tum.de>
parents: 2537
diff changeset
   344
    by (descending) (auto simp add: inter_list_def sub_list_def memb_def)
2528
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
   345
  show "x |\<inter>| y |\<subseteq>| y" 
2538
c9deccd12476 further tuning
Christian Urban <urbanc@in.tum.de>
parents: 2537
diff changeset
   346
    by (descending) (auto simp add: inter_list_def sub_list_def memb_def)
2528
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
   347
  show "x |\<union>| (y |\<inter>| z) = x |\<union>| y |\<inter>| (x |\<union>| z)" 
2538
c9deccd12476 further tuning
Christian Urban <urbanc@in.tum.de>
parents: 2537
diff changeset
   348
    by (descending) (auto simp add: inter_list_def)
1905
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   349
next
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   350
  fix x y z :: "'a fset"
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   351
  assume a: "x |\<subseteq>| y"
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   352
  assume b: "y |\<subseteq>| z"
2528
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
   353
  show "x |\<subseteq>| z" using a b 
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
   354
    by (descending) (simp add: sub_list_def)
1895
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   355
next
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   356
  fix x y :: "'a fset"
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   357
  assume a: "x |\<subseteq>| y"
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   358
  assume b: "y |\<subseteq>| x"
2528
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
   359
  show "x = y" using a b 
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
   360
    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
   361
next
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   362
  fix x y z :: "'a fset"
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   363
  assume a: "y |\<subseteq>| x"
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   364
  assume b: "z |\<subseteq>| x"
2528
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
   365
  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
   366
    by (descending) (simp add: sub_list_def)
1905
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   367
next
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   368
  fix x y z :: "'a fset"
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   369
  assume a: "x |\<subseteq>| y"
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   370
  assume b: "x |\<subseteq>| z"
2528
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
   371
  show "x |\<subseteq>| y |\<inter>| z" using a b 
2538
c9deccd12476 further tuning
Christian Urban <urbanc@in.tum.de>
parents: 2537
diff changeset
   372
    by (descending) (auto simp add: inter_list_def sub_list_def memb_def)
1895
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   373
qed
1905
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   374
1893
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   375
end
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   376
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   377
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   378
subsection {* Other constants for fsets *}
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   379
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   380
quotient_definition
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   381
  "insert_fset :: 'a \<Rightarrow> 'a fset \<Rightarrow> 'a fset"
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   382
  is "Cons"
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   383
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   384
syntax
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   385
  "@Insert_fset"     :: "args => 'a fset"  ("{|(_)|}")
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   386
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   387
translations
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   388
  "{|x, xs|}" == "CONST insert_fset x {|xs|}"
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   389
  "{|x|}"     == "CONST insert_fset x {||}"
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   390
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   391
quotient_definition
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   392
  in_fset (infix "|\<in>|" 50)
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   393
where
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   394
  "in_fset :: '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
   395
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   396
abbreviation
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   397
  notin_fset :: "'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
   398
where
1860
d3fe17786640 some tuning of proofs
Christian Urban <urbanc@in.tum.de>
parents: 1826
diff changeset
   399
  "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
   400
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   401
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   402
subsection {* Other constants on the Quotient Type *}
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   403
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   404
quotient_definition
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   405
  "card_fset :: 'a fset \<Rightarrow> nat"
2536
98e84b56543f renamed fcard_raw to card_list
Christian Urban <urbanc@in.tum.de>
parents: 2534
diff changeset
   406
  is card_list
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   407
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   408
quotient_definition
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   409
  "map_fset :: ('a \<Rightarrow> 'b) \<Rightarrow> 'a fset \<Rightarrow> 'b fset"
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   410
  is map
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   411
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   412
quotient_definition
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   413
  "remove_fset :: '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
   414
  is removeAll
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   415
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   416
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
   417
  "fset :: 'a fset \<Rightarrow> 'a set"
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   418
  is "set"
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   419
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   420
quotient_definition
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   421
  "fold_fset :: ('a \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> 'b \<Rightarrow> 'a fset \<Rightarrow> 'b"
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   422
  is fold_list
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   423
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   424
quotient_definition
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   425
  "concat_fset :: ('a fset) fset \<Rightarrow> 'a fset"
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   426
  is concat
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   427
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   428
quotient_definition
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   429
  "filter_fset :: ('a \<Rightarrow> bool) \<Rightarrow> 'a fset \<Rightarrow> 'a fset"
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   430
  is filter
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   431
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   432
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   433
subsection {* Compositional respectfulness and preservation lemmas *}
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   434
2539
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
   435
lemma Nil_rsp2 [quot_respect]: 
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
   436
  shows "(list_all2 op \<approx> OOO op \<approx>) Nil Nil"
1938
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   437
  by (fact compose_list_refl)
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   438
2539
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
   439
lemma Cons_rsp2 [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
   440
  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
   441
  apply auto
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   442
  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
   443
  apply auto
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   444
  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
   445
  apply auto
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   446
  done
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   447
2539
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
   448
lemma map_prs [quot_preserve]: 
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
   449
  shows "(abs_fset \<circ> map f) [] = abs_fset []"
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
   450
  by simp
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
   451
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   452
lemma insert_fset_rsp [quot_preserve]:
2541
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   453
  "(rep_fset ---> (map rep_fset \<circ> rep_fset) ---> (abs_fset \<circ> map abs_fset)) Cons = insert_fset"
2479
a9b6a00b1ba0 updated to Isabelle Sept 16
Christian Urban <urbanc@in.tum.de>
parents: 2378
diff changeset
   454
  by (simp add: fun_eq_iff Quotient_abs_rep[OF Quotient_fset]
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   455
      abs_o_rep[OF Quotient_fset] map_id insert_fset_def)
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   456
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   457
lemma union_fset_rsp [quot_preserve]:
2541
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   458
  "((map rep_fset \<circ> rep_fset) ---> (map rep_fset \<circ> rep_fset) ---> (abs_fset \<circ> map abs_fset)) 
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   459
  append = union_fset"
2479
a9b6a00b1ba0 updated to Isabelle Sept 16
Christian Urban <urbanc@in.tum.de>
parents: 2378
diff changeset
   460
  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
   461
      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
   462
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   463
lemma list_all2_app_l:
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   464
  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
   465
  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
   466
  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
   467
  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
   468
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   469
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
   470
  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
   471
  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
   472
  using a apply (induct x x' rule: list_induct2')
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   473
  by simp_all (rule list_all2_refl')
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   474
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   475
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
   476
  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
   477
  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
   478
  using a apply (induct x x' arbitrary: z rule: list_induct2')
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   479
  apply (rule list_all2_refl')
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   480
  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
   481
  apply (rule list_all2_app_l)
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   482
  apply (simp_all add: reflp_def)
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   483
  done
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   484
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   485
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
   486
  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
   487
  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
   488
  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
   489
  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
   490
  apply (rule append_rsp2_pre0)
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   491
  apply (rule a)
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   492
  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
   493
  apply (simp_all only: append_Nil2)
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   494
  apply (rule list_all2_refl')
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   495
  apply simp_all
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   496
  apply (rule append_rsp2_pre1)
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   497
  apply simp
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   498
  done
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   499
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   500
lemma [quot_respect]:
2539
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
   501
  "(list_all2 op \<approx> OOO op \<approx> ===> list_all2 op \<approx> OOO op \<approx> ===> list_all2 op \<approx> OOO op \<approx>) append append"
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   502
proof (intro fun_relI, elim pred_compE)
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   503
  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
   504
  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
   505
  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
   506
  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
   507
  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
   508
  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
   509
  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
   510
  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
   511
  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
   512
  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
   513
  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
   514
    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
   515
  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
   516
    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
   517
qed
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   518
1878
c22947214948 2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1860
diff changeset
   519
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
   520
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   521
section {* Lifted theorems *}
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   522
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   523
subsection {* fset *}
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   524
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   525
lemma fset_simps [simp]:
2543
8537493c039f fixed typo
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   526
  shows "fset {||} = {}"
8537493c039f fixed typo
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   527
  and   "fset (insert_fset x S) = insert x (fset S)"
8537493c039f fixed typo
Christian Urban <urbanc@in.tum.de>
parents: 2542
diff changeset
   528
  by (descending, simp)+
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   529
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   530
lemma finite_fset [simp]: 
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   531
  shows "finite (fset S)"
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   532
  by (descending) (simp)
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   533
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   534
lemma fset_cong:
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   535
  shows "fset S = fset T \<longleftrightarrow> S = T"
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   536
  by (descending) (simp)
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   537
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   538
lemma filter_fset [simp]: 
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   539
  shows "fset (filter_fset P xs) = P \<inter> fset xs"
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   540
  by (descending) (auto simp add: mem_def)
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   541
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   542
lemma remove_fset [simp]: 
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   543
  shows "fset (remove_fset x xs) = fset xs - {x}"
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   544
  by (descending) (simp)
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   545
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   546
lemma inter_fset [simp]: 
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   547
  shows "fset (xs |\<inter>| ys) = fset xs \<inter> fset ys"
2538
c9deccd12476 further tuning
Christian Urban <urbanc@in.tum.de>
parents: 2537
diff changeset
   548
  by (descending) (auto simp add: inter_list_def)
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   549
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   550
lemma union_fset [simp]: 
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   551
  shows "fset (xs |\<union>| ys) = fset xs \<union> fset ys"
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   552
  by (lifting set_append)
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   553
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   554
lemma minus_fset [simp]: 
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   555
  shows "fset (xs - ys) = fset xs - fset ys"
2538
c9deccd12476 further tuning
Christian Urban <urbanc@in.tum.de>
parents: 2537
diff changeset
   556
  by (descending) (auto simp add: diff_list_def)
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   557
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   558
2541
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   559
subsection {* in_fset *}
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   560
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   561
lemma in_fset: 
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   562
  shows "x |\<in>| S \<longleftrightarrow> x \<in> fset S"
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   563
  by (descending) (simp add: memb_def)
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   564
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   565
lemma notin_fset: 
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   566
  shows "x |\<notin>| S \<longleftrightarrow> x \<notin> fset S"
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   567
  by (simp add: in_fset)
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   568
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   569
lemma notin_empty_fset: 
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   570
  shows "x |\<notin>| {||}"
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   571
  by (simp add: in_fset)
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   572
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   573
lemma fset_eq_iff:
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   574
  shows "S = T \<longleftrightarrow> (\<forall>x. (x |\<in>| S) = (x |\<in>| T))"
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   575
  by (descending) (auto simp add: memb_def)
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   576
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   577
lemma none_in_empty_fset:
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   578
  shows "(\<forall>x. x |\<notin>| S) \<longleftrightarrow> S = {||}"
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   579
  by (descending) (simp add: memb_def)
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   580
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   581
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   582
subsection {* insert_fset *}
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   583
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   584
lemma in_insert_fset_iff [simp]:
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   585
  shows "x |\<in>| insert_fset y S \<longleftrightarrow> x = y \<or> x |\<in>| S"
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   586
  by (descending) (simp add: memb_def)
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   587
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   588
lemma
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   589
  shows insert_fsetI1: "x |\<in>| insert_fset x S"
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   590
  and   insert_fsetI2: "x |\<in>| S \<Longrightarrow> x |\<in>| insert_fset y S"
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   591
  by simp_all
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   592
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   593
lemma insert_absorb_fset [simp]:
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   594
  shows "x |\<in>| S \<Longrightarrow> insert_fset x S = S"
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   595
  by (descending) (auto simp add: memb_def)
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   596
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   597
lemma empty_not_insert_fset[simp]:
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   598
  shows "{||} \<noteq> insert_fset x S"
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   599
  and   "insert_fset x S \<noteq> {||}"
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   600
  by (descending, simp)+
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   601
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   602
lemma insert_fset_left_comm:
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   603
  shows "insert_fset x (insert_fset y S) = insert_fset y (insert_fset x S)"
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   604
  by (descending) (auto)
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   605
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   606
lemma insert_fset_left_idem:
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   607
  shows "insert_fset x (insert_fset x S) = insert_fset x S"
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   608
  by (descending) (auto)
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   609
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   610
lemma singleton_fset_eq[simp]:
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   611
  shows "{|x|} = {|y|} \<longleftrightarrow> x = y"
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   612
  by (descending) (auto)
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   613
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   614
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   615
(* FIXME: is this a useful lemma ? *)
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   616
lemma in_fset_mdef:
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   617
  shows "x |\<in>| F \<longleftrightarrow> x |\<notin>| (F - {|x|}) \<and> F = insert_fset x (F - {|x|})"
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   618
  by (descending) (auto simp add: memb_def diff_list_def)
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   619
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   620
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   621
subsection {* union_fset *}
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   622
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   623
lemmas [simp] =
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   624
  sup_bot_left[where 'a="'a fset", standard]
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   625
  sup_bot_right[where 'a="'a fset", standard]
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   626
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   627
lemma union_insert_fset [simp]:
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   628
  shows "insert_fset x S |\<union>| T = insert_fset x (S |\<union>| T)"
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   629
  by (lifting append.simps(2))
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   630
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   631
lemma singleton_union_fset_left:
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   632
  shows "{|a|} |\<union>| S = insert_fset a S"
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   633
  by simp
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   634
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   635
lemma singleton_union_fset_right:
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   636
  shows "S |\<union>| {|a|} = insert_fset a S"
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   637
  by (subst sup.commute) simp
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   638
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   639
lemma in_union_fset:
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   640
  shows "x |\<in>| S |\<union>| T \<longleftrightarrow> x |\<in>| S \<or> x |\<in>| T"
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   641
  by (descending) (simp add: memb_def)
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   642
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   643
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   644
subsection {* minus_fset *}
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   645
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   646
lemma minus_in_fset: 
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   647
  shows "x |\<in>| (xs - ys) \<longleftrightarrow> x |\<in>| xs \<and> x |\<notin>| ys"
2538
c9deccd12476 further tuning
Christian Urban <urbanc@in.tum.de>
parents: 2537
diff changeset
   648
  by (descending) (simp add: diff_list_def memb_def)
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   649
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   650
lemma minus_insert_fset: 
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   651
  shows "insert_fset x xs - ys = (if x |\<in>| ys then xs - ys else insert_fset x (xs - ys))"
2538
c9deccd12476 further tuning
Christian Urban <urbanc@in.tum.de>
parents: 2537
diff changeset
   652
  by (descending) (auto simp add: diff_list_def memb_def)
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   653
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   654
lemma minus_insert_in_fset[simp]: 
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   655
  shows "x |\<in>| ys \<Longrightarrow> insert_fset x xs - ys = xs - ys"
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   656
  by (simp add: minus_insert_fset)
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   657
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   658
lemma minus_insert_notin_fset[simp]: 
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   659
  shows "x |\<notin>| ys \<Longrightarrow> insert_fset x xs - ys = insert_fset x (xs - ys)"
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   660
  by (simp add: minus_insert_fset)
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   661
2541
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   662
lemma in_minus_fset: 
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   663
  shows "x |\<in>| F - S \<Longrightarrow> x |\<notin>| S"
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   664
  unfolding in_fset minus_fset
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   665
  by blast
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   666
2541
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   667
lemma notin_minus_fset: 
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   668
  shows "x |\<in>| S \<Longrightarrow> x |\<notin>| F - S"
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   669
  unfolding in_fset minus_fset
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   670
  by blast
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   671
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   672
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   673
subsection {* remove_fset *}
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   674
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   675
lemma in_remove_fset:
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   676
  shows "x |\<in>| remove_fset y S \<longleftrightarrow> x |\<in>| S \<and> x \<noteq> y"
2533
767161329839 further cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2532
diff changeset
   677
  by (descending) (simp add: memb_def)
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   678
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   679
lemma notin_remove_fset:
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   680
  shows "x |\<notin>| remove_fset x S"
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   681
  by (descending) (simp add: memb_def)
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   682
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   683
lemma notin_remove_ident_fset:
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   684
  shows "x |\<notin>| S \<Longrightarrow> remove_fset x S = S"
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   685
  by (descending) (simp add: memb_def)
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   686
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   687
lemma remove_fset_cases:
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   688
  shows "S = {||} \<or> (\<exists>x. x |\<in>| S \<and> S = insert_fset x (remove_fset x S))"
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   689
  by (descending) (auto simp add: memb_def insert_absorb)
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   690
  
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   691
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   692
subsection {* inter_fset *}
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   693
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   694
lemma inter_empty_fset_l:
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   695
  shows "{||} |\<inter>| S = {||}"
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   696
  by simp
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   697
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   698
lemma inter_empty_fset_r:
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   699
  shows "S |\<inter>| {||} = {||}"
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   700
  by simp
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   701
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   702
lemma inter_insert_fset:
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   703
  shows "insert_fset x S |\<inter>| T = (if x |\<in>| T then insert_fset x (S |\<inter>| T) else S |\<inter>| T)"
2538
c9deccd12476 further tuning
Christian Urban <urbanc@in.tum.de>
parents: 2537
diff changeset
   704
  by (descending) (auto simp add: inter_list_def memb_def)
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   705
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   706
lemma in_inter_fset:
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   707
  shows "x |\<in>| (S |\<inter>| T) \<longleftrightarrow> x |\<in>| S \<and> x |\<in>| T"
2538
c9deccd12476 further tuning
Christian Urban <urbanc@in.tum.de>
parents: 2537
diff changeset
   708
  by (descending) (simp add: inter_list_def memb_def)
1533
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   709
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   710
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   711
subsection {* subset_fset and psubset_fset *}
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   712
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   713
lemma subset_fset: 
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   714
  shows "xs |\<subseteq>| ys \<longleftrightarrow> fset xs \<subseteq> fset ys"
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   715
  by (descending) (simp add: sub_list_def)
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   716
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   717
lemma psubset_fset: 
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   718
  shows "xs |\<subset>| ys \<longleftrightarrow> fset xs \<subset> fset ys"
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   719
  unfolding less_fset_def 
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   720
  by (descending) (auto simp add: sub_list_def)
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   721
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   722
lemma subset_insert_fset:
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   723
  shows "(insert_fset x xs) |\<subseteq>| ys \<longleftrightarrow> x |\<in>| ys \<and> xs |\<subseteq>| ys"
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   724
  by (descending) (simp add: sub_list_def memb_def)
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   725
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   726
lemma subset_in_fset: 
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   727
  shows "xs |\<subseteq>| ys = (\<forall>x. x |\<in>| xs \<longrightarrow> x |\<in>| ys)"
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   728
  by (descending) (auto simp add: sub_list_def memb_def)
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   729
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   730
lemma subset_empty_fset:
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   731
  shows "xs |\<subseteq>| {||} \<longleftrightarrow> xs = {||}"
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   732
  by (descending) (simp add: sub_list_def)
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   733
2541
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   734
lemma not_psubset_empty_fset: 
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   735
  shows "\<not> xs |\<subset>| {||}"
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   736
  by (metis fset_simps(1) psubset_fset not_psubset_empty)
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   737
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   738
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   739
subsection {* map_fset *}
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   740
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   741
lemma map_fset_simps [simp]:
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   742
   shows "map_fset f {||} = {||}"
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   743
  and   "map_fset f (insert_fset x S) = insert_fset (f x) (map_fset f S)"
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   744
  by (descending, simp)+
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   745
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   746
lemma map_fset_image [simp]:
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   747
  shows "fset (map_fset f S) = f ` (fset S)"
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   748
  by (descending) (simp)
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   749
2542
1f5c8e85c41f all tests work again
Christian Urban <urbanc@in.tum.de>
parents: 2541
diff changeset
   750
lemma inj_map_fset_cong:
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   751
  shows "inj f \<Longrightarrow> map_fset f S = map_fset f T \<longleftrightarrow> S = T"
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   752
  by (descending) (metis inj_vimage_image_eq list_eq.simps set_map)
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   753
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   754
lemma map_union_fset: 
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   755
  shows "map_fset f (S |\<union>| T) = map_fset f S |\<union>| map_fset f T"
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   756
  by (descending) (simp)
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   757
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   758
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   759
subsection {* card_fset *}
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   760
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   761
lemma card_fset: 
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   762
  shows "card_fset xs = card (fset xs)"
2536
98e84b56543f renamed fcard_raw to card_list
Christian Urban <urbanc@in.tum.de>
parents: 2534
diff changeset
   763
  by (lifting card_list_def)
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   764
2541
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   765
lemma card_insert_fset_iff [simp]:
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   766
  shows "card_fset (insert_fset x S) = (if x |\<in>| S then card_fset S else Suc (card_fset S))"
2536
98e84b56543f renamed fcard_raw to card_list
Christian Urban <urbanc@in.tum.de>
parents: 2534
diff changeset
   767
  by (descending) (auto simp add: card_list_def memb_def insert_absorb)
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   768
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   769
lemma card_fset_0[simp]:
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   770
  shows "card_fset S = 0 \<longleftrightarrow> S = {||}"
2536
98e84b56543f renamed fcard_raw to card_list
Christian Urban <urbanc@in.tum.de>
parents: 2534
diff changeset
   771
  by (descending) (simp add: card_list_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
   772
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   773
lemma card_empty_fset[simp]:
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   774
  shows "card_fset {||} = 0"
2541
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   775
  by (simp add: card_fset)
1813
69fff336dd18 Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1682
diff changeset
   776
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   777
lemma card_fset_1:
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   778
  shows "card_fset S = 1 \<longleftrightarrow> (\<exists>x. S = {|x|})"
2536
98e84b56543f renamed fcard_raw to card_list
Christian Urban <urbanc@in.tum.de>
parents: 2534
diff changeset
   779
  by (descending) (auto simp add: card_list_def card_Suc_eq)
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   780
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   781
lemma card_fset_gt_0:
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   782
  shows "x \<in> fset S \<Longrightarrow> 0 < card_fset S"
2536
98e84b56543f renamed fcard_raw to card_list
Christian Urban <urbanc@in.tum.de>
parents: 2534
diff changeset
   783
  by (descending) (auto simp add: card_list_def card_gt_0_iff)
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
   784
  
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   785
lemma card_notin_fset:
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   786
  shows "(x |\<notin>| S) = (card_fset (insert_fset x S) = Suc (card_fset S))"
2541
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   787
  by simp
1813
69fff336dd18 Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1682
diff changeset
   788
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   789
lemma card_fset_Suc: 
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   790
  shows "card_fset S = Suc n \<Longrightarrow> \<exists>x T. x |\<notin>| T \<and> S = insert_fset x T \<and> card_fset T = n"
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
   791
  apply(descending)
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   792
  apply(auto simp add: card_list_def memb_def dest!: card_eq_SucD)
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   793
  by (metis Diff_insert_absorb set_removeAll)
1813
69fff336dd18 Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1682
diff changeset
   794
2541
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   795
lemma card_remove_fset_iff [simp]:
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   796
  shows "card_fset (remove_fset y S) = (if y |\<in>| S then card_fset S - 1 else card_fset S)"
2536
98e84b56543f renamed fcard_raw to card_list
Christian Urban <urbanc@in.tum.de>
parents: 2534
diff changeset
   797
  by (descending) (simp add: card_list_def memb_def)
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   798
2541
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   799
lemma card_Suc_exists_in_fset: 
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   800
  shows "card_fset S = Suc n \<Longrightarrow> \<exists>a. a |\<in>| S"
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   801
  by (drule card_fset_Suc) (auto)
1878
c22947214948 2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1860
diff changeset
   802
2541
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   803
lemma in_card_fset_not_0: 
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   804
  shows "a |\<in>| A \<Longrightarrow> card_fset A \<noteq> 0"
2536
98e84b56543f renamed fcard_raw to card_list
Christian Urban <urbanc@in.tum.de>
parents: 2534
diff changeset
   805
  by (descending) (auto simp add: card_list_def memb_def)
1878
c22947214948 2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1860
diff changeset
   806
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   807
lemma card_fset_mono: 
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   808
  shows "xs |\<subseteq>| ys \<Longrightarrow> card_fset xs \<le> card_fset ys"
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   809
  unfolding card_fset psubset_fset
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   810
  by (simp add:  card_mono subset_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
   811
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   812
lemma card_subset_fset_eq: 
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   813
  shows "xs |\<subseteq>| ys \<Longrightarrow> card_fset ys \<le> card_fset xs \<Longrightarrow> xs = ys"
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   814
  unfolding card_fset subset_fset
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   815
  by (auto dest: card_seteq[OF finite_fset] simp add: fset_cong)
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   816
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   817
lemma psubset_card_fset_mono: 
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   818
  shows "xs |\<subset>| ys \<Longrightarrow> card_fset xs < card_fset ys"
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   819
  unfolding card_fset subset_fset
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   820
  by (metis finite_fset psubset_fset psubset_card_mono)
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   821
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   822
lemma card_union_inter_fset: 
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   823
  shows "card_fset xs + card_fset ys = card_fset (xs |\<union>| ys) + card_fset (xs |\<inter>| ys)"
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   824
  unfolding card_fset union_fset inter_fset
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   825
  by (rule card_Un_Int[OF finite_fset finite_fset])
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   826
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   827
lemma card_union_disjoint_fset: 
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   828
  shows "xs |\<inter>| ys = {||} \<Longrightarrow> card_fset (xs |\<union>| ys) = card_fset xs + card_fset ys"
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   829
  unfolding card_fset union_fset 
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   830
  apply (rule card_Un_disjoint[OF finite_fset finite_fset])
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   831
  by (metis inter_fset fset_simps(1))
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   832
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   833
lemma card_remove_fset_less1: 
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   834
  shows "x |\<in>| xs \<Longrightarrow> card_fset (remove_fset x xs) < card_fset xs"
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   835
  unfolding card_fset in_fset remove_fset 
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   836
  by (rule card_Diff1_less[OF finite_fset])
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   837
2541
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   838
lemma card_remove_fset_less2: 
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   839
  shows "x |\<in>| xs \<Longrightarrow> y |\<in>| xs \<Longrightarrow> card_fset (remove_fset y (remove_fset x xs)) < card_fset xs"
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   840
  unfolding card_fset remove_fset in_fset
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   841
  by (rule card_Diff2_less[OF finite_fset])
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   842
2541
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   843
lemma card_remove_fset_le1: 
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   844
  shows "card_fset (remove_fset x xs) \<le> card_fset xs"
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   845
  unfolding remove_fset card_fset
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   846
  by (rule card_Diff1_le[OF finite_fset])
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   847
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   848
lemma card_psubset_fset: 
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   849
  shows "ys |\<subseteq>| xs \<Longrightarrow> card_fset ys < card_fset xs \<Longrightarrow> ys |\<subset>| xs"
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   850
  unfolding card_fset psubset_fset subset_fset
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   851
  by (rule card_psubset[OF finite_fset])
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   852
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   853
lemma card_map_fset_le: 
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   854
  shows "card_fset (map_fset f xs) \<le> card_fset xs"
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   855
  unfolding card_fset map_fset_image
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   856
  by (rule card_image_le[OF finite_fset])
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   857
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   858
lemma card_minus_insert_fset[simp]:
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   859
  assumes "a |\<in>| A" and "a |\<notin>| B"
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   860
  shows "card_fset (A - insert_fset a B) = card_fset (A - B) - 1"
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   861
  using assms 
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   862
  unfolding in_fset card_fset minus_fset
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   863
  by (simp add: card_Diff_insert[OF finite_fset])
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   864
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   865
lemma card_minus_subset_fset:
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   866
  assumes "B |\<subseteq>| A"
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   867
  shows "card_fset (A - B) = card_fset A - card_fset B"
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   868
  using assms 
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   869
  unfolding subset_fset card_fset minus_fset
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   870
  by (rule card_Diff_subset[OF finite_fset])
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   871
2541
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   872
lemma card_minus_fset:
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   873
  shows "card_fset (A - B) = card_fset A - card_fset (A |\<inter>| B)"
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   874
  unfolding inter_fset card_fset minus_fset
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   875
  by (rule card_Diff_subset_Int) (simp)
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   876
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   877
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   878
subsection {* concat_fset *}
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   879
2541
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   880
lemma concat_empty_fset [simp]:
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   881
  shows "concat_fset {||} = {||}"
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   882
  by (lifting concat.simps(1))
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   883
2541
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   884
lemma concat_insert_fset [simp]:
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   885
  shows "concat_fset (insert_fset x S) = x |\<union>| concat_fset S"
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   886
  by (lifting concat.simps(2))
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   887
2541
d7269488c4b5 some tuning
Christian Urban <urbanc@in.tum.de>
parents: 2540
diff changeset
   888
lemma concat_inter_fset [simp]:
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   889
  shows "concat_fset (xs |\<union>| ys) = concat_fset xs |\<union>| concat_fset ys"
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   890
  by (lifting concat_append)
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   891
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   892
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   893
subsection {* filter_fset *}
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   894
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   895
lemma subset_filter_fset: 
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   896
  shows "filter_fset P xs |\<subseteq>| filter_fset Q xs = (\<forall> x. x |\<in>| xs \<longrightarrow> P x \<longrightarrow> Q x)"
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   897
  by  (descending) (auto simp add: memb_def sub_list_def)
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   898
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   899
lemma eq_filter_fset: 
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   900
  shows "(filter_fset P xs = filter_fset Q xs) = (\<forall>x. x |\<in>| xs \<longrightarrow> P x = Q x)"
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   901
  by (descending) (auto simp add: memb_def)
1887
7abd8c1d9f4b Some new lemmas
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1886
diff changeset
   902
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   903
lemma psubset_filter_fset:
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   904
  shows "(\<And>x. x |\<in>| xs \<Longrightarrow> P x \<Longrightarrow> Q x) \<Longrightarrow> (x |\<in>| xs & \<not> P x & Q x) \<Longrightarrow> 
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   905
    filter_fset P xs |\<subset>| filter_fset Q xs"
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   906
  unfolding less_fset_def by (auto simp add: subset_filter_fset eq_filter_fset)
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   907
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   908
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   909
subsection {* fold_fset *}
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   910
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   911
lemma fold_empty_fset: 
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   912
  shows "fold_fset f z {||} = z"
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   913
  by (descending) (simp)
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   914
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   915
lemma fold_insert_fset: "fold_fset f z (insert_fset a A) =
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   916
  (if rsp_fold f then if a |\<in>| A then fold_fset f z A else f a (fold_fset f z A) else z)"
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   917
  by (descending) (simp add: memb_def)
1887
7abd8c1d9f4b Some new lemmas
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1886
diff changeset
   918
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   919
lemma in_commute_fold_fset:
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   920
  "\<lbrakk>rsp_fold f; h |\<in>| b\<rbrakk> \<Longrightarrow> fold_fset f z b = f h (fold_fset f z (remove_fset h b))"
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   921
  by (descending) (simp add: memb_def memb_commute_fold_list)
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   922
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   923
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   924
subsection {* Choice in fsets *}
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   925
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   926
lemma fset_choice: 
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   927
  assumes a: "\<forall>x. x |\<in>| A \<longrightarrow> (\<exists>y. P x y)"
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   928
  shows "\<exists>f. \<forall>x. x |\<in>| A \<longrightarrow> P x (f x)"
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   929
  using a
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   930
  apply(descending)
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   931
  using finite_set_choice
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   932
  by (auto simp add: memb_def Ball_def)
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   933
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   934
2539
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
   935
section {* Induction and Cases rules for fsets *}
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
   936
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   937
lemma fset_exhaust [case_names empty_fset insert_fset, cases type: fset]:
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   938
  assumes empty_fset_case: "S = {||} \<Longrightarrow> P" 
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   939
  and     insert_fset_case: "\<And>x S'. S = insert_fset x S' \<Longrightarrow> P"
2539
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
   940
  shows "P"
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
   941
  using assms by (lifting list.exhaust)
2534
f99578469d08 Further reorganisation and cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2533
diff changeset
   942
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   943
lemma fset_induct [case_names empty_fset insert_fset]:
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   944
  assumes empty_fset_case: "P {||}"
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   945
  and     insert_fset_case: "\<And>x S. P S \<Longrightarrow> P (insert_fset x S)"
2539
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
   946
  shows "P S"
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
   947
  using assms 
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
   948
  by (descending) (blast intro: list.induct)
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
   949
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   950
lemma fset_induct_stronger [case_names empty_fset insert_fset, induct type: fset]:
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   951
  assumes empty_fset_case: "P {||}"
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   952
  and     insert_fset_case: "\<And>x S. \<lbrakk>x |\<notin>| S; P S\<rbrakk> \<Longrightarrow> P (insert_fset x S)"
2539
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
   953
  shows "P S"
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
   954
proof(induct S rule: fset_induct)
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   955
  case empty_fset
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   956
  show "P {||}" using empty_fset_case by simp
2539
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
   957
next
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   958
  case (insert_fset x S)
2539
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
   959
  have "P S" by fact
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   960
  then show "P (insert_fset x S)" using insert_fset_case 
2539
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
   961
    by (cases "x |\<in>| S") (simp_all)
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
   962
qed
1887
7abd8c1d9f4b Some new lemmas
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1886
diff changeset
   963
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   964
lemma fset_card_induct:
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   965
  assumes empty_fset_case: "P {||}"
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   966
  and     card_fset_Suc_case: "\<And>S T. Suc (card_fset S) = (card_fset T) \<Longrightarrow> P S \<Longrightarrow> P T"
2539
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
   967
  shows "P S"
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
   968
proof (induct S)
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   969
  case empty_fset
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   970
  show "P {||}" by (rule empty_fset_case)
2539
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
   971
next
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   972
  case (insert_fset x S)
2539
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
   973
  have h: "P S" by fact
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
   974
  have "x |\<notin>| S" by fact
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   975
  then have "Suc (card_fset S) = card_fset (insert_fset x S)" 
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   976
    using card_fset_Suc by auto
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   977
  then show "P (insert_fset x S)" 
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
   978
    using h card_fset_Suc_case by simp
2539
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
   979
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
   980
2539
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
   981
lemma fset_raw_strong_cases:
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
   982
  obtains "xs = []"
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
   983
    | x ys where "\<not> memb x ys" and "xs \<approx> x # ys"
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
   984
proof (induct xs arbitrary: x ys)
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
   985
  case Nil
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
   986
  then show thesis by simp
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
   987
next
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
   988
  case (Cons a xs)
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
   989
  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
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
   990
  have b: "\<And>x' ys'. \<lbrakk>\<not> memb x' ys'; a # xs \<approx> x' # ys'\<rbrakk> \<Longrightarrow> thesis" by fact
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
   991
  have c: "xs = [] \<Longrightarrow> thesis" using b unfolding memb_def
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
   992
    by (metis in_set_conv_nth less_zeroE list.size(3) list_eq.simps member_set)
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
   993
  have "\<And>x ys. \<lbrakk>\<not> memb x ys; xs \<approx> x # ys\<rbrakk> \<Longrightarrow> thesis"
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
   994
  proof -
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
   995
    fix x :: 'a
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
   996
    fix ys :: "'a list"
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
   997
    assume d:"\<not> memb x ys"
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
   998
    assume e:"xs \<approx> x # ys"
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
   999
    show thesis
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1000
    proof (cases "x = a")
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1001
      assume h: "x = a"
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1002
      then have f: "\<not> memb a ys" using d by simp
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1003
      have g: "a # xs \<approx> a # ys" using e h by auto
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1004
      show thesis using b f g by simp
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1005
    next
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1006
      assume h: "x \<noteq> a"
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1007
      then have f: "\<not> memb x (a # ys)" using d unfolding memb_def by auto
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1008
      have g: "a # xs \<approx> x # (a # ys)" using e h by auto
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1009
      show thesis using b f g by simp
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1010
    qed
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1011
  qed
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1012
  then show thesis using a c by blast
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1013
qed
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1014
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1015
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1016
lemma fset_strong_cases:
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1017
  obtains "xs = {||}"
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
  1018
    | x ys where "x |\<notin>| ys" and "xs = insert_fset x ys"
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1019
  by (lifting fset_raw_strong_cases)
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1020
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1021
1533
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
  1022
lemma fset_induct2:
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
  1023
  "P {||} {||} \<Longrightarrow>
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
  1024
  (\<And>x xs. x |\<notin>| xs \<Longrightarrow> P (insert_fset x xs) {||}) \<Longrightarrow>
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
  1025
  (\<And>y ys. y |\<notin>| ys \<Longrightarrow> P {||} (insert_fset y ys)) \<Longrightarrow>
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
  1026
  (\<And>x xs y ys. \<lbrakk>P xs ys; x |\<notin>| xs; y |\<notin>| ys\<rbrakk> \<Longrightarrow> P (insert_fset x xs) (insert_fset y ys)) \<Longrightarrow>
1533
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
  1027
  P xsa ysa"
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
  1028
  apply (induct xsa arbitrary: ysa)
2539
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1029
  apply (induct_tac x rule: fset_induct_stronger)
1533
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
  1030
  apply simp_all
2539
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1031
  apply (induct_tac xa rule: fset_induct_stronger)
1533
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
  1032
  apply simp_all
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
  1033
  done
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1034
2539
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1035
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1036
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1037
subsection {* alternate formulation with a different decomposition principle
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1038
  and a proof of equivalence *}
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1039
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1040
inductive
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1041
  list_eq2 ("_ \<approx>2 _")
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1042
where
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1043
  "(a # b # xs) \<approx>2 (b # a # xs)"
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1044
| "[] \<approx>2 []"
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1045
| "xs \<approx>2 ys \<Longrightarrow>  ys \<approx>2 xs"
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1046
| "(a # a # xs) \<approx>2 (a # xs)"
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1047
| "xs \<approx>2 ys \<Longrightarrow>  (a # xs) \<approx>2 (a # ys)"
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1048
| "\<lbrakk>xs1 \<approx>2 xs2;  xs2 \<approx>2 xs3\<rbrakk> \<Longrightarrow> xs1 \<approx>2 xs3"
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1049
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1050
lemma list_eq2_refl:
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1051
  shows "xs \<approx>2 xs"
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1052
  by (induct xs) (auto intro: list_eq2.intros)
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1053
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1054
lemma cons_delete_list_eq2:
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1055
  shows "(a # (removeAll a A)) \<approx>2 (if memb a A then A else a # A)"
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1056
  apply (induct A)
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1057
  apply (simp add: memb_def list_eq2_refl)
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1058
  apply (case_tac "memb a (aa # A)")
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1059
  apply (simp_all only: memb_def)
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1060
  apply (case_tac [!] "a = aa")
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1061
  apply (simp_all)
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1062
  apply (case_tac "memb a A")
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1063
  apply (auto simp add: memb_def)[2]
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1064
  apply (metis list_eq2.intros(3) list_eq2.intros(4) list_eq2.intros(5) list_eq2.intros(6))
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1065
  apply (metis list_eq2.intros(1) list_eq2.intros(5) list_eq2.intros(6))
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1066
  apply (auto simp add: list_eq2_refl memb_def)
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1067
  done
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1068
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1069
lemma memb_delete_list_eq2:
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1070
  assumes a: "memb e r"
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1071
  shows "(e # removeAll e r) \<approx>2 r"
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1072
  using a cons_delete_list_eq2[of e r]
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1073
  by simp
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1074
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1075
lemma list_eq2_equiv:
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1076
  "(l \<approx> r) \<longleftrightarrow> (list_eq2 l r)"
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1077
proof
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1078
  show "list_eq2 l r \<Longrightarrow> l \<approx> r" by (induct rule: list_eq2.induct) auto
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1079
next
2539
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1080
  {
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1081
    fix n
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1082
    assume a: "card_list l = n" and b: "l \<approx> r"
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1083
    have "l \<approx>2 r"
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1084
      using a b
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1085
    proof (induct n arbitrary: l r)
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1086
      case 0
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1087
      have "card_list l = 0" by fact
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1088
      then have "\<forall>x. \<not> memb x l" unfolding card_list_def memb_def by auto
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1089
      then have z: "l = []" unfolding memb_def by auto
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1090
      then have "r = []" using `l \<approx> r` by simp
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1091
      then show ?case using z list_eq2_refl by simp
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1092
    next
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1093
      case (Suc m)
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1094
      have b: "l \<approx> r" by fact
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1095
      have d: "card_list l = Suc m" by fact
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1096
      then have "\<exists>a. memb a l" 
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1097
	apply(simp add: card_list_def memb_def)
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1098
	apply(drule card_eq_SucD)
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1099
	apply(blast)
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1100
	done
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1101
      then obtain a where e: "memb a l" by auto
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1102
      then have e': "memb a r" using list_eq.simps[simplified memb_def[symmetric], of l r] b 
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1103
	unfolding memb_def by auto
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1104
      have f: "card_list (removeAll a l) = m" using e d by (simp add: card_list_def memb_def)
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1105
      have g: "removeAll a l \<approx> removeAll a r" using removeAll_rsp b by simp
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
  1106
      have "(removeAll a l) \<approx>2 (removeAll a r)" by (rule Suc.hyps[OF f g])
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
  1107
      then have h: "(a # removeAll a l) \<approx>2 (a # removeAll a r)" by (rule list_eq2.intros(5))
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
  1108
      have i: "l \<approx>2 (a # removeAll a l)"	
2539
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1109
        by (rule list_eq2.intros(3)[OF memb_delete_list_eq2[OF e]])
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
  1110
      have "l \<approx>2 (a # removeAll a r)" by (rule list_eq2.intros(6)[OF i h])
2539
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1111
      then show ?case using list_eq2.intros(6)[OF _ memb_delete_list_eq2[OF e']] by simp
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1112
    qed
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1113
    }
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
  1114
  then show "l \<approx> r \<Longrightarrow> l \<approx>2 r" by blast
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1115
qed
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
1888
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1118
(* 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
  1119
   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
  1120
   a different order *)
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1121
lemma fset_eq_cases:
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1122
 "\<lbrakk>a1 = a2;
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
  1123
   \<And>a b xs. \<lbrakk>a1 = insert_fset a (insert_fset b xs); a2 = insert_fset b (insert_fset a xs)\<rbrakk> \<Longrightarrow> P;
1888
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1124
   \<lbrakk>a1 = {||}; a2 = {||}\<rbrakk> \<Longrightarrow> P; \<And>xs ys. \<lbrakk>a1 = ys; a2 = xs; xs = ys\<rbrakk> \<Longrightarrow> P;
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
  1125
   \<And>a xs. \<lbrakk>a1 = insert_fset a (insert_fset a xs); a2 = insert_fset a xs\<rbrakk> \<Longrightarrow> P;
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
  1126
   \<And>xs ys a. \<lbrakk>a1 = insert_fset a xs; a2 = insert_fset a ys; xs = ys\<rbrakk> \<Longrightarrow> P;
1888
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1127
   \<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
  1128
  \<Longrightarrow> P"
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1129
  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
  1130
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1131
lemma fset_eq_induct:
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1132
  assumes "x1 = x2"
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
  1133
  and "\<And>a b xs. P (insert_fset a (insert_fset b xs)) (insert_fset b (insert_fset a xs))"
1888
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1134
  and "P {||} {||}"
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1135
  and "\<And>xs ys. \<lbrakk>xs = ys; P xs ys\<rbrakk> \<Longrightarrow> P ys xs"
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
  1136
  and "\<And>a xs. P (insert_fset a (insert_fset a xs)) (insert_fset a xs)"
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
  1137
  and "\<And>xs ys a. \<lbrakk>xs = ys; P xs ys\<rbrakk> \<Longrightarrow> P (insert_fset a xs) (insert_fset a ys)"
1888
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1138
  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
  1139
  shows "P x1 x2"
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1140
  using assms
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1141
  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
  1142
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
  1143
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
  1144
  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
  1145
  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
  1146
  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
  1147
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1148
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
  1149
  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
  1150
  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
  1151
proof
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1152
  have *: "r \<approx> r" by (rule equivp_reflp[OF fset_equivp])
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
  1153
  show "list_all2 R r r" by (rule list_all2_refl''[OF q])
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
  1154
  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
  1155
qed
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1156
2285
965ee8f08d4c eliminated a quot_thm flag
Christian Urban <urbanc@in.tum.de>
parents: 2278
diff changeset
  1157
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
  1158
  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
  1159
  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
  1160
  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
  1161
    (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
  1162
  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
  1163
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
  1164
  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
  1165
  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
  1166
    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
  1167
  have b: "list_all2 R (map Rep (rep_fset a)) (map Rep (rep_fset a))"
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
  1168
    by (rule list_all2_refl''[OF e])
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
  1169
  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
  1170
    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
  1171
  show "(list_all2 R OOO op \<approx>) (map Rep (rep_fset a)) (map Rep (rep_fset a))"
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
  1172
    by (rule, rule list_all2_refl''[OF e]) (rule c)
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
  1173
  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
  1174
        (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
  1175
  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
  1176
    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
  1177
    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
  1178
  next
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
  1179
    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
  1180
    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
  1181
    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
  1182
      fix b ba
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
  1183
      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
  1184
      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
  1185
      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
  1186
      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
  1187
        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
  1188
      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
  1189
        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
  1190
      then have g: "map Abs s = map Abs ba" by simp
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
  1191
      then show "map Abs r \<approx> map Abs s" using d f map_list_eq_cong by simp
2266
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1192
    qed
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1193
    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
  1194
      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
  1195
  next
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
  1196
    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
  1197
      \<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
  1198
    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
  1199
    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
  1200
      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
  1201
    have b: "map Rep (map Abs r) \<approx> map Rep (map Abs s)"
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
  1202
      by (rule map_list_eq_cong[OF d])
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
  1203
    have y: "list_all2 R (map Rep (map Abs s)) s"
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
  1204
      by (fact rep_abs_rsp_left[OF list_quotient[OF q], OF list_all2_refl''[OF e, of s]])
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
  1205
    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
  1206
      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
  1207
    have z: "list_all2 R r (map Rep (map Abs r))"
2540
135ac0fb2686 naming scheme is now *_fset (not f*_)
Christian Urban <urbanc@in.tum.de>
parents: 2539
diff changeset
  1208
      by (fact rep_abs_rsp[OF list_quotient[OF q], OF list_all2_refl''[OF e, of r]])
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
  1209
    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
  1210
      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
  1211
  qed
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1212
qed
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1213
2528
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
  1214
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
  1215
ML {*
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
  1216
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
  1217
  | 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
  1218
*}
9bde8a508594 Partially merging changes from Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2525
diff changeset
  1219
2266
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1220
no_notation
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1221
  list_eq (infix "\<approx>" 50)
2539
a8f5611dbd65 more cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2538
diff changeset
  1222
and list_eq2 (infix "\<approx>2" 50)
2266
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1223
2234
8035515bbbc6 something about the quotient ype definitions
Christian Urban <urbanc@in.tum.de>
parents: 2222
diff changeset
  1224
end