Nominal/FSet.thy
author Christian Urban <urbanc@in.tum.de>
Mon, 19 Jul 2010 07:49:10 +0100
changeset 2372 06574b438b8f
parent 2371 86c73a06ba4b
child 2378 2f13fe48c877
permissions -rw-r--r--
minor
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
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
     5
A reasoning infrastructure for the 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
2238
8ddf1330f2ed completed proof and started section about respectfulness and preservation
Christian Urban <urbanc@in.tum.de>
parents: 2234
diff changeset
     9
imports Quotient_List Quotient_Product
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
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    12
text {* Definiton of List relation and the quotient type *}
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
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    17
  "list_eq xs ys = (\<forall>x. x \<in> set xs \<longleftrightarrow> x \<in> set ys)"
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
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    25
quotient_type
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    26
  'a fset = "'a list" / "list_eq"
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    27
  by (rule list_eq_equivp)
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    28
2372
Christian Urban <urbanc@in.tum.de>
parents: 2371
diff changeset
    29
text {* Raw definitions of membership, sublist, cardinality, 
Christian Urban <urbanc@in.tum.de>
parents: 2371
diff changeset
    30
  intersection
Christian Urban <urbanc@in.tum.de>
parents: 2371
diff changeset
    31
*}
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    32
1889
6c5b5ec53a0b sub_list definition and respects
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1888
diff changeset
    33
definition
6c5b5ec53a0b sub_list definition and respects
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1888
diff changeset
    34
  memb :: "'a \<Rightarrow> 'a list \<Rightarrow> bool"
6c5b5ec53a0b sub_list definition and respects
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1888
diff changeset
    35
where
6c5b5ec53a0b sub_list definition and respects
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1888
diff changeset
    36
  "memb x xs \<equiv> x \<in> set xs"
6c5b5ec53a0b sub_list definition and respects
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1888
diff changeset
    37
6c5b5ec53a0b sub_list definition and respects
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1888
diff changeset
    38
definition
6c5b5ec53a0b sub_list definition and respects
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1888
diff changeset
    39
  sub_list :: "'a list \<Rightarrow> 'a list \<Rightarrow> bool"
6c5b5ec53a0b sub_list definition and respects
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1888
diff changeset
    40
where
6c5b5ec53a0b sub_list definition and respects
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1888
diff changeset
    41
  "sub_list xs ys \<equiv> (\<forall>x. x \<in> set xs \<longrightarrow> x \<in> set ys)"
6c5b5ec53a0b sub_list definition and respects
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1888
diff changeset
    42
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    43
fun
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    44
  fcard_raw :: "'a list \<Rightarrow> nat"
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    45
where
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    46
  fcard_raw_nil:  "fcard_raw [] = 0"
2372
Christian Urban <urbanc@in.tum.de>
parents: 2371
diff changeset
    47
| fcard_raw_cons: "fcard_raw (x # xs) = 
Christian Urban <urbanc@in.tum.de>
parents: 2371
diff changeset
    48
    (if memb x xs then fcard_raw xs else Suc (fcard_raw xs))"
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    49
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    50
primrec
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    51
  finter_raw :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a list"
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    52
where
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    53
  "finter_raw [] l = []"
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    54
| "finter_raw (h # t) l =
2372
Christian Urban <urbanc@in.tum.de>
parents: 2371
diff changeset
    55
    (if memb h l then h # (finter_raw t l) else finter_raw t l)"
1893
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
    56
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
    57
primrec
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    58
  delete_raw :: "'a list \<Rightarrow> 'a \<Rightarrow> 'a list"
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    59
where
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    60
  "delete_raw [] x = []"
2372
Christian Urban <urbanc@in.tum.de>
parents: 2371
diff changeset
    61
| "delete_raw (a # xs) x = 
Christian Urban <urbanc@in.tum.de>
parents: 2371
diff changeset
    62
    (if (a = x) then delete_raw xs x else a # (delete_raw xs x))"
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
    63
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
    64
primrec
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
    65
  fminus_raw :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a list"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
    66
where
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
    67
  "fminus_raw l [] = l"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
    68
| "fminus_raw l (h # t) = fminus_raw (delete_raw l h) t"
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    69
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    70
definition
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    71
  rsp_fold
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    72
where
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    73
  "rsp_fold f = (\<forall>u v w. (f u (f v w) = f v (f u w)))"
1893
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
    74
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    75
primrec
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    76
  ffold_raw :: "('a \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> 'b \<Rightarrow> 'a list \<Rightarrow> 'b"
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    77
where
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    78
  "ffold_raw f z [] = z"
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
    79
| "ffold_raw f z (a # xs) =
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    80
     (if (rsp_fold f) then
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
    81
       if memb a xs then ffold_raw f z xs
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
    82
       else f a (ffold_raw f z xs)
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    83
     else z)"
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
    84
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
    85
text {* Composition Quotient *}
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
    86
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
    87
lemma list_all2_refl1:
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
    88
  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
    89
  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
    90
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
    91
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
    92
  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
    93
proof
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
    94
  have *: "r \<approx> r" by (rule equivp_reflp[OF fset_equivp])
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
    95
  show "list_all2 op \<approx> r r" by (rule list_all2_refl1)
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
    96
  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
    97
qed
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
    98
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
    99
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
   100
  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
   101
  by (fact list_quotient[OF Quotient_fset])
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   102
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   103
lemma set_in_eq: "(\<forall>e. ((e \<in> xs) \<longleftrightarrow> (e \<in> ys))) \<equiv> xs = ys"
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   104
  by (rule eq_reflection) auto
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   105
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   106
lemma map_rel_cong: "b \<approx> ba \<Longrightarrow> map f b \<approx> map f ba"
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   107
  unfolding list_eq.simps
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   108
  by (simp only: set_map set_in_eq)
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   109
2368
d7dfe272b4f8 some test with quotient
Christian Urban <urbanc@in.tum.de>
parents: 2330
diff changeset
   110
text {* Peter *}
d7dfe272b4f8 some test with quotient
Christian Urban <urbanc@in.tum.de>
parents: 2330
diff changeset
   111
ML {* Quotient_Info.quotient_rules_get @{context} *}
d7dfe272b4f8 some test with quotient
Christian Urban <urbanc@in.tum.de>
parents: 2330
diff changeset
   112
d7dfe272b4f8 some test with quotient
Christian Urban <urbanc@in.tum.de>
parents: 2330
diff changeset
   113
lemma 
d7dfe272b4f8 some test with quotient
Christian Urban <urbanc@in.tum.de>
parents: 2330
diff changeset
   114
  assumes "Quotient R1 abs1 rep1"
d7dfe272b4f8 some test with quotient
Christian Urban <urbanc@in.tum.de>
parents: 2330
diff changeset
   115
  and     "Quotient R2 abs2 rep2"
d7dfe272b4f8 some test with quotient
Christian Urban <urbanc@in.tum.de>
parents: 2330
diff changeset
   116
  shows   "Quotient (R1 OOO R2) (abs1 o ab2) (rep1 o rep2)"
d7dfe272b4f8 some test with quotient
Christian Urban <urbanc@in.tum.de>
parents: 2330
diff changeset
   117
using assms
d7dfe272b4f8 some test with quotient
Christian Urban <urbanc@in.tum.de>
parents: 2330
diff changeset
   118
sorry
d7dfe272b4f8 some test with quotient
Christian Urban <urbanc@in.tum.de>
parents: 2330
diff changeset
   119
d7dfe272b4f8 some test with quotient
Christian Urban <urbanc@in.tum.de>
parents: 2330
diff changeset
   120
lemma 
d7dfe272b4f8 some test with quotient
Christian Urban <urbanc@in.tum.de>
parents: 2330
diff changeset
   121
  assumes "Quotient R1 abs1 rep1"
d7dfe272b4f8 some test with quotient
Christian Urban <urbanc@in.tum.de>
parents: 2330
diff changeset
   122
  and     "Quotient R2 abs2 rep2"
d7dfe272b4f8 some test with quotient
Christian Urban <urbanc@in.tum.de>
parents: 2330
diff changeset
   123
  shows   "Quotient (R3) (abs1 o ab2) (rep1 o rep2)"
d7dfe272b4f8 some test with quotient
Christian Urban <urbanc@in.tum.de>
parents: 2330
diff changeset
   124
using assms
d7dfe272b4f8 some test with quotient
Christian Urban <urbanc@in.tum.de>
parents: 2330
diff changeset
   125
sorry
2266
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
   126
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   127
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
   128
  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
   129
    (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
   130
  unfolding Quotient_def comp_def
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   131
proof (intro conjI allI)
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   132
  fix a r s
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   133
  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
   134
    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
   135
  have b: "list_all2 op \<approx> (map rep_fset (rep_fset a)) (map rep_fset (rep_fset a))"
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   136
    by (rule list_all2_refl1)
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   137
  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
   138
    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
   139
  show "(list_all2 op \<approx> OOO op \<approx>) (map rep_fset (rep_fset a)) (map rep_fset (rep_fset a))"
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   140
    by (rule, rule list_all2_refl1) (rule c)
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   141
  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
   142
        (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
   143
  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
   144
    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
   145
    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
   146
  next
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   147
    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
   148
    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
   149
    proof (elim pred_compE)
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   150
      fix b ba
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   151
      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
   152
      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
   153
      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
   154
      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
   155
        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
   156
      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
   157
        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
   158
      then have g: "map abs_fset s = map abs_fset ba" by simp
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   159
      then show "map abs_fset r \<approx> map abs_fset s" using d f map_rel_cong by simp
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   160
    qed
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   161
    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
   162
      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
   163
  next
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   164
    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
   165
      \<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
   166
    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
   167
    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
   168
      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
   169
    have b: "map rep_fset (map abs_fset r) \<approx> map rep_fset (map abs_fset s)"
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   170
      by (rule map_rel_cong[OF d])
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   171
    have y: "list_all2 op \<approx> (map rep_fset (map abs_fset s)) s"
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   172
      by (fact rep_abs_rsp_left[OF Quotient_fset_list, OF list_all2_refl1[of s]])
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   173
    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
   174
      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
   175
    have z: "list_all2 op \<approx> r (map rep_fset (map abs_fset r))"
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   176
      by (fact rep_abs_rsp[OF Quotient_fset_list, OF list_all2_refl1[of r]])
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   177
    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
   178
      using a c pred_compI by simp
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   179
  qed
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   180
qed
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   181
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   182
text {* Respectfullness *}
1893
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   183
2187
f9cc69b432ff Name some respectfullness
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2084
diff changeset
   184
lemma append_rsp[quot_respect]:
1895
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   185
  shows "(op \<approx> ===> op \<approx> ===> op \<approx>) op @ op @"
2278
337569f85398 conclusion done
Christian Urban <urbanc@in.tum.de>
parents: 2266
diff changeset
   186
  apply(simp del: list_eq.simps)
2368
d7dfe272b4f8 some test with quotient
Christian Urban <urbanc@in.tum.de>
parents: 2330
diff changeset
   187
  by auto 
1895
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   188
2190
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2187
diff changeset
   189
lemma append_rsp_unfolded:
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2187
diff changeset
   190
  "\<lbrakk>x \<approx> y; v \<approx> w\<rbrakk> \<Longrightarrow> x @ v \<approx> y @ w"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2187
diff changeset
   191
  by auto
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2187
diff changeset
   192
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   193
lemma [quot_respect]:
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   194
  shows "(op \<approx> ===> op \<approx> ===> op =) sub_list sub_list"
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   195
  by (auto simp add: sub_list_def)
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   196
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   197
lemma memb_rsp[quot_respect]:
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   198
  shows "(op = ===> op \<approx> ===> op =) memb memb"
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   199
  by (auto simp add: memb_def)
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   200
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   201
lemma nil_rsp[quot_respect]:
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   202
  shows "[] \<approx> []"
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   203
  by simp
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   204
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   205
lemma cons_rsp[quot_respect]:
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   206
  shows "(op = ===> op \<approx> ===> op \<approx>) op # op #"
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   207
  by simp
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   208
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   209
lemma map_rsp[quot_respect]:
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   210
  shows "(op = ===> op \<approx> ===> op \<approx>) map map"
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   211
  by auto
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   212
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   213
lemma set_rsp[quot_respect]:
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   214
  "(op \<approx> ===> op =) set set"
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   215
  by auto
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   216
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   217
lemma list_equiv_rsp[quot_respect]:
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   218
  shows "(op \<approx> ===> op \<approx> ===> op =) op \<approx> op \<approx>"
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   219
  by auto
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   220
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   221
lemma not_memb_nil:
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   222
  shows "\<not> memb x []"
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   223
  by (simp add: memb_def)
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   224
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   225
lemma memb_cons_iff:
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   226
  shows "memb x (y # xs) = (x = y \<or> memb x xs)"
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   227
  by (induct xs) (auto simp add: memb_def)
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   228
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   229
lemma memb_finter_raw:
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   230
  "memb x (finter_raw xs ys) \<longleftrightarrow> memb x xs \<and> memb x ys"
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   231
  by (induct xs) (auto simp add: not_memb_nil memb_cons_iff)
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   232
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   233
lemma [quot_respect]:
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   234
  "(op \<approx> ===> op \<approx> ===> op \<approx>) finter_raw finter_raw"
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   235
  by (simp add: memb_def[symmetric] memb_finter_raw)
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   236
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   237
lemma memb_delete_raw:
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   238
  "memb x (delete_raw xs y) = (memb x xs \<and> x \<noteq> y)"
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   239
  by (induct xs arbitrary: x y) (auto simp add: memb_def)
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   240
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   241
lemma [quot_respect]:
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   242
  "(op \<approx> ===> op = ===> op \<approx>) delete_raw delete_raw"
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   243
  by (simp add: memb_def[symmetric] memb_delete_raw)
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   244
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   245
lemma fminus_raw_memb: "memb x (fminus_raw xs ys) = (memb x xs \<and> \<not> memb x ys)"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   246
  by (induct ys arbitrary: xs)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   247
     (simp_all add: not_memb_nil memb_delete_raw memb_cons_iff)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   248
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   249
lemma [quot_respect]:
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   250
  "(op \<approx> ===> op \<approx> ===> op \<approx>) fminus_raw fminus_raw"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   251
  by (simp add: memb_def[symmetric] fminus_raw_memb)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   252
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   253
lemma fcard_raw_gt_0:
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   254
  assumes a: "x \<in> set xs"
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   255
  shows "0 < fcard_raw xs"
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   256
  using a by (induct xs) (auto simp add: memb_def)
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   257
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   258
lemma fcard_raw_delete_one:
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   259
  shows "fcard_raw ([x \<leftarrow> xs. x \<noteq> y]) = (if memb y xs then fcard_raw xs - 1 else fcard_raw xs)"
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   260
  by (induct xs) (auto dest: fcard_raw_gt_0 simp add: memb_def)
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   261
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   262
lemma fcard_raw_rsp_aux:
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   263
  assumes a: "xs \<approx> ys"
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   264
  shows "fcard_raw xs = fcard_raw ys"
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   265
  using a
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   266
  proof (induct xs arbitrary: ys)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   267
    case Nil
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   268
    show ?case using Nil.prems by simp
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   269
  next
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   270
    case (Cons a xs)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   271
    have a: "a # xs \<approx> ys" by fact
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   272
    have b: "\<And>ys. xs \<approx> ys \<Longrightarrow> fcard_raw xs = fcard_raw ys" by fact
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   273
    show ?case proof (cases "a \<in> set xs")
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   274
      assume c: "a \<in> set xs"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   275
      have "\<forall>x. (x \<in> set xs) = (x \<in> set ys)"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   276
      proof (intro allI iffI)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   277
        fix x
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   278
        assume "x \<in> set xs"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   279
        then show "x \<in> set ys" using a by auto
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   280
      next
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   281
        fix x
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   282
        assume d: "x \<in> set ys"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   283
        have e: "(x \<in> set (a # xs)) = (x \<in> set ys)" using a by simp
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   284
        show "x \<in> set xs" using c d e unfolding list_eq.simps by simp blast
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   285
      qed
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   286
      then show ?thesis using b c by (simp add: memb_def)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   287
    next
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   288
      assume c: "a \<notin> set xs"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   289
      have d: "xs \<approx> [x\<leftarrow>ys . x \<noteq> a] \<Longrightarrow> fcard_raw xs = fcard_raw [x\<leftarrow>ys . x \<noteq> a]" using b by simp
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   290
      have "Suc (fcard_raw xs) = fcard_raw ys"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   291
      proof (cases "a \<in> set ys")
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   292
        assume e: "a \<in> set ys"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   293
        have f: "\<forall>x. (x \<in> set xs) = (x \<in> set ys \<and> x \<noteq> a)" using a c
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   294
          by (auto simp add: fcard_raw_delete_one)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   295
        have "fcard_raw ys = Suc (fcard_raw ys - 1)" by (rule Suc_pred'[OF fcard_raw_gt_0]) (rule e)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   296
        then show ?thesis using d e f by (simp_all add: fcard_raw_delete_one memb_def)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   297
      next
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   298
        case False then show ?thesis using a c d by auto
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   299
      qed
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   300
      then show ?thesis using a c d by (simp add: memb_def)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   301
  qed
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   302
qed
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   303
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   304
lemma fcard_raw_rsp[quot_respect]:
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   305
  shows "(op \<approx> ===> op =) fcard_raw fcard_raw"
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   306
  by (simp add: fcard_raw_rsp_aux)
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   307
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   308
lemma memb_absorb:
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   309
  shows "memb x xs \<Longrightarrow> x # xs \<approx> xs"
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   310
  by (induct xs) (auto simp add: memb_def)
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   311
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   312
lemma none_memb_nil:
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   313
  "(\<forall>x. \<not> memb x xs) = (xs \<approx> [])"
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   314
  by (simp add: memb_def)
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   315
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   316
lemma not_memb_delete_raw_ident:
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   317
  shows "\<not> memb x xs \<Longrightarrow> delete_raw xs x = xs"
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   318
  by (induct xs) (auto simp add: memb_def)
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   319
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   320
lemma memb_commute_ffold_raw:
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   321
  "rsp_fold f \<Longrightarrow> memb h b \<Longrightarrow> ffold_raw f z b = f h (ffold_raw f z (delete_raw b h))"
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   322
  apply (induct b)
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   323
  apply (simp_all add: not_memb_nil)
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   324
  apply (auto)
1938
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   325
  apply (simp_all add: memb_delete_raw not_memb_delete_raw_ident rsp_fold_def  memb_cons_iff)
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   326
  done
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   327
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   328
lemma ffold_raw_rsp_pre:
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   329
  "\<forall>e. memb e a = memb e b \<Longrightarrow> ffold_raw f z a = ffold_raw f z b"
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   330
  apply (induct a arbitrary: b)
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   331
  apply (simp add: memb_absorb memb_def none_memb_nil)
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   332
  apply (simp)
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   333
  apply (rule conjI)
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   334
  apply (rule_tac [!] impI)
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   335
  apply (rule_tac [!] conjI)
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   336
  apply (rule_tac [!] impI)
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   337
  apply (subgoal_tac "\<forall>e. memb e a2 = memb e b")
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   338
  apply (simp)
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   339
  apply (simp add: memb_cons_iff memb_def)
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   340
  apply (auto)[1]
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   341
  apply (drule_tac x="e" in spec)
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   342
  apply (blast)
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   343
  apply (case_tac b)
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   344
  apply (simp_all)
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   345
  apply (subgoal_tac "ffold_raw f z b = f a1 (ffold_raw f z (delete_raw b a1))")
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   346
  apply (simp only:)
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   347
  apply (rule_tac f="f a1" in arg_cong)
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   348
  apply (subgoal_tac "\<forall>e. memb e a2 = memb e (delete_raw b a1)")
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   349
  apply (simp)
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   350
  apply (simp add: memb_delete_raw)
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   351
  apply (auto simp add: memb_cons_iff)[1]
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   352
  apply (erule memb_commute_ffold_raw)
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   353
  apply (drule_tac x="a1" in spec)
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   354
  apply (simp add: memb_cons_iff)
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   355
  apply (simp add: memb_cons_iff)
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   356
  apply (case_tac b)
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   357
  apply (simp_all)
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   358
  done
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   359
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   360
lemma [quot_respect]:
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   361
  "(op = ===> op = ===> op \<approx> ===> op =) ffold_raw ffold_raw"
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   362
  by (simp add: memb_def[symmetric] ffold_raw_rsp_pre)
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   363
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   364
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
   365
  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
   366
  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
   367
  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
   368
  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
   369
  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
   370
proof -
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   371
  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
   372
  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
   373
  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
   374
  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
   375
  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
   376
  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
   377
qed
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   378
2187
f9cc69b432ff Name some respectfullness
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2084
diff changeset
   379
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
   380
  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
   381
proof (rule fun_relI, elim pred_compE)
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   382
  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
   383
  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
   384
  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
   385
  assume c: "list_all2 op \<approx> bb b"
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   386
  have "\<forall>x. (\<exists>xa\<in>set a. x \<in> set xa) = (\<exists>xa\<in>set b. x \<in> set xa)" proof
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   387
    fix x
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   388
    show "(\<exists>xa\<in>set a. x \<in> set xa) = (\<exists>xa\<in>set b. x \<in> set xa)" proof
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   389
      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
   390
      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
   391
    next
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   392
      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
   393
      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
   394
      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
   395
      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
   396
      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
   397
    qed
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   398
  qed
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   399
  then show "concat a \<approx> concat b" by simp
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   400
qed
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   401
2190
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2187
diff changeset
   402
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2187
diff changeset
   403
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2187
diff changeset
   404
lemma concat_rsp_unfolded:
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   405
  "\<lbrakk>list_all2 op \<approx> a ba; ba \<approx> bb; list_all2 op \<approx> bb b\<rbrakk> \<Longrightarrow> concat a \<approx> concat b"
2190
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2187
diff changeset
   406
proof -
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2187
diff changeset
   407
  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
   408
  assume a: "list_all2 op \<approx> a ba"
2190
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2187
diff changeset
   409
  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
   410
  assume c: "list_all2 op \<approx> bb b"
2190
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2187
diff changeset
   411
  have "\<forall>x. (\<exists>xa\<in>set a. x \<in> set xa) = (\<exists>xa\<in>set b. x \<in> set xa)" proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2187
diff changeset
   412
    fix x
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2187
diff changeset
   413
    show "(\<exists>xa\<in>set a. x \<in> set xa) = (\<exists>xa\<in>set b. x \<in> set xa)" proof
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2187
diff changeset
   414
      assume d: "\<exists>xa\<in>set a. x \<in> set xa"
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2187
diff changeset
   415
      show "\<exists>xa\<in>set b. x \<in> set xa" by (rule concat_rsp_pre[OF a b c d])
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2187
diff changeset
   416
    next
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2187
diff changeset
   417
      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
   418
      have a': "list_all2 op \<approx> ba a" by (rule list_all2_symp[OF list_eq_equivp, OF a])
2190
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2187
diff changeset
   419
      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
   420
      have c': "list_all2 op \<approx> b bb" by (rule list_all2_symp[OF list_eq_equivp, OF c])
2190
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2187
diff changeset
   421
      show "\<exists>xa\<in>set a. x \<in> set xa" by (rule concat_rsp_pre[OF c' b' a' e])
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2187
diff changeset
   422
    qed
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2187
diff changeset
   423
  qed
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2187
diff changeset
   424
  then show "concat a \<approx> concat b" by simp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2187
diff changeset
   425
qed
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2187
diff changeset
   426
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   427
lemma [quot_respect]:
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   428
  "((op =) ===> op \<approx> ===> op \<approx>) filter filter"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   429
  by auto
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   430
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   431
text {* Distributive lattice with bot *}
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   432
1893
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   433
lemma sub_list_not_eq:
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   434
  "(sub_list x y \<and> \<not> list_eq x y) = (sub_list x y \<and> \<not> sub_list y x)"
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   435
  by (auto simp add: sub_list_def)
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   436
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   437
lemma sub_list_refl:
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   438
  "sub_list x x"
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   439
  by (simp add: sub_list_def)
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   440
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   441
lemma sub_list_trans:
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   442
  "sub_list x y \<Longrightarrow> sub_list y z \<Longrightarrow> sub_list x z"
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   443
  by (simp add: sub_list_def)
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   444
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   445
lemma sub_list_empty:
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   446
  "sub_list [] x"
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   447
  by (simp add: sub_list_def)
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   448
1905
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   449
lemma sub_list_append_left:
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   450
  "sub_list x (x @ y)"
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   451
  by (simp add: sub_list_def)
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   452
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   453
lemma sub_list_append_right:
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   454
  "sub_list y (x @ y)"
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   455
  by (simp add: sub_list_def)
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   456
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   457
lemma sub_list_inter_left:
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   458
  shows "sub_list (finter_raw x y) x"
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   459
  by (simp add: sub_list_def memb_def[symmetric] memb_finter_raw)
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   460
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   461
lemma sub_list_inter_right:
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   462
  shows "sub_list (finter_raw x y) y"
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   463
  by (simp add: sub_list_def memb_def[symmetric] memb_finter_raw)
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   464
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   465
lemma sub_list_list_eq:
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   466
  "sub_list x y \<Longrightarrow> sub_list y x \<Longrightarrow> list_eq x y"
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   467
  unfolding sub_list_def list_eq.simps by blast
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   468
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   469
lemma sub_list_append:
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   470
  "sub_list y x \<Longrightarrow> sub_list z x \<Longrightarrow> sub_list (y @ z) x"
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   471
  unfolding sub_list_def by auto
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   472
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   473
lemma sub_list_inter:
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   474
  "sub_list x y \<Longrightarrow> sub_list x z \<Longrightarrow> sub_list x (finter_raw y z)"
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   475
  by (simp add: sub_list_def memb_def[symmetric] memb_finter_raw)
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   476
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   477
lemma append_inter_distrib:
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   478
  "x @ (finter_raw y z) \<approx> finter_raw (x @ y) (x @ z)"
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   479
  apply (induct x)
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   480
  apply (simp_all add: memb_def)
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   481
  apply (simp add: memb_def[symmetric] memb_finter_raw)
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   482
  apply (auto simp add: memb_def)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   483
  done
1905
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   484
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   485
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
   486
begin
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   487
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   488
quotient_definition
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   489
  "bot :: 'a fset" is "[] :: 'a list"
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   490
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   491
abbreviation
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   492
  fempty  ("{||}")
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   493
where
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   494
  "{||} \<equiv> bot :: 'a fset"
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   495
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   496
quotient_definition
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   497
  "less_eq_fset \<Colon> ('a fset \<Rightarrow> 'a fset \<Rightarrow> bool)"
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   498
is
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   499
  "sub_list \<Colon> ('a list \<Rightarrow> 'a list \<Rightarrow> bool)"
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   500
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   501
abbreviation
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   502
  f_subset_eq :: "'a fset \<Rightarrow> 'a fset \<Rightarrow> bool" (infix "|\<subseteq>|" 50)
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   503
where
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   504
  "xs |\<subseteq>| ys \<equiv> xs \<le> ys"
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   505
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   506
definition
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   507
  less_fset:
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   508
  "(xs :: 'a fset) < ys \<equiv> xs \<le> ys \<and> xs \<noteq> ys"
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   509
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   510
abbreviation
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   511
  f_subset :: "'a fset \<Rightarrow> 'a fset \<Rightarrow> bool" (infix "|\<subset>|" 50)
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   512
where
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   513
  "xs |\<subset>| ys \<equiv> xs < ys"
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   514
1895
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   515
quotient_definition
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   516
  "sup  \<Colon> ('a fset \<Rightarrow> 'a fset \<Rightarrow> 'a fset)"
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   517
is
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   518
  "(op @) \<Colon> ('a list \<Rightarrow> 'a list \<Rightarrow> 'a list)"
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   519
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   520
abbreviation
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   521
  funion (infixl "|\<union>|" 65)
1895
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   522
where
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   523
  "xs |\<union>| ys \<equiv> sup (xs :: 'a fset) ys"
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   524
1905
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   525
quotient_definition
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   526
  "inf \<Colon> ('a fset \<Rightarrow> 'a fset \<Rightarrow> 'a fset)"
1905
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   527
is
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   528
  "finter_raw \<Colon> ('a list \<Rightarrow> 'a list \<Rightarrow> 'a list)"
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   529
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   530
abbreviation
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   531
  finter (infixl "|\<inter>|" 65)
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   532
where
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   533
  "xs |\<inter>| ys \<equiv> inf (xs :: 'a fset) ys"
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   534
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   535
quotient_definition
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   536
  "minus \<Colon> ('a fset \<Rightarrow> 'a fset \<Rightarrow> 'a fset)"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   537
is
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   538
  "fminus_raw \<Colon> ('a list \<Rightarrow> 'a list \<Rightarrow> 'a list)"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   539
1895
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   540
instance
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   541
proof
1905
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   542
  fix x y z :: "'a fset"
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   543
  show "(x |\<subset>| y) = (x |\<subseteq>| y \<and> \<not> y |\<subseteq>| x)"
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   544
    unfolding less_fset by (lifting sub_list_not_eq)
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   545
  show "x |\<subseteq>| x" by (lifting sub_list_refl)
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   546
  show "{||} |\<subseteq>| x" by (lifting sub_list_empty)
1895
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   547
  show "x |\<subseteq>| x |\<union>| y" by (lifting sub_list_append_left)
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   548
  show "y |\<subseteq>| x |\<union>| y" by (lifting sub_list_append_right)
1905
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   549
  show "x |\<inter>| y |\<subseteq>| x" by (lifting sub_list_inter_left)
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   550
  show "x |\<inter>| y |\<subseteq>| y" by (lifting sub_list_inter_right)
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   551
  show "x |\<union>| (y |\<inter>| z) = x |\<union>| y |\<inter>| (x |\<union>| z)" by (lifting append_inter_distrib)
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   552
next
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   553
  fix x y z :: "'a fset"
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   554
  assume a: "x |\<subseteq>| y"
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   555
  assume b: "y |\<subseteq>| z"
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   556
  show "x |\<subseteq>| z" using a b by (lifting sub_list_trans)
1895
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   557
next
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   558
  fix x y :: "'a fset"
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   559
  assume a: "x |\<subseteq>| y"
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   560
  assume b: "y |\<subseteq>| x"
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   561
  show "x = y" using a b by (lifting sub_list_list_eq)
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   562
next
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   563
  fix x y z :: "'a fset"
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   564
  assume a: "y |\<subseteq>| x"
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   565
  assume b: "z |\<subseteq>| x"
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   566
  show "y |\<union>| z |\<subseteq>| x" using a b by (lifting sub_list_append)
1905
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   567
next
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   568
  fix x y z :: "'a fset"
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   569
  assume a: "x |\<subseteq>| y"
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   570
  assume b: "x |\<subseteq>| z"
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   571
  show "x |\<subseteq>| y |\<inter>| z" using a b by (lifting sub_list_inter)
1895
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   572
qed
1905
dbc9e88c44da fsets are distributive lattices.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1895
diff changeset
   573
1893
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   574
end
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   575
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   576
section {* Finsert and Membership *}
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   577
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   578
quotient_definition
1893
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
   579
  "finsert :: 'a \<Rightarrow> 'a fset \<Rightarrow> 'a fset"
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   580
is "op #"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   581
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   582
syntax
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   583
  "@Finset"     :: "args => 'a fset"  ("{|(_)|}")
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   584
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   585
translations
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   586
  "{|x, xs|}" == "CONST finsert x {|xs|}"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   587
  "{|x|}"     == "CONST finsert x {||}"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   588
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   589
quotient_definition
1938
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   590
  fin (infix "|\<in>|" 50)
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   591
where
1816
56cebe7f8e24 some small tunings (incompleted work in Lambda.thy)
Christian Urban <urbanc@in.tum.de>
parents: 1682
diff changeset
   592
  "fin :: 'a \<Rightarrow> 'a fset \<Rightarrow> bool" is "memb"
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   593
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   594
abbreviation
1938
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   595
  fnotin :: "'a \<Rightarrow> 'a fset \<Rightarrow> bool" (infix "|\<notin>|" 50)
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   596
where
1860
d3fe17786640 some tuning of proofs
Christian Urban <urbanc@in.tum.de>
parents: 1826
diff changeset
   597
  "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
   598
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   599
section {* Other constants on the Quotient Type *}
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   600
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   601
quotient_definition
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   602
  "fcard :: 'a fset \<Rightarrow> nat"
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   603
is
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   604
  "fcard_raw"
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   605
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   606
quotient_definition
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   607
  "fmap :: ('a \<Rightarrow> 'b) \<Rightarrow> 'a fset \<Rightarrow> 'b fset"
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   608
is
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   609
 "map"
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   610
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   611
quotient_definition
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   612
  "fdelete :: 'a fset \<Rightarrow> 'a \<Rightarrow> 'a fset"
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   613
  is "delete_raw"
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   614
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   615
quotient_definition
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   616
  "fset_to_set :: 'a fset \<Rightarrow> 'a set"
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   617
  is "set"
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   618
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   619
quotient_definition
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   620
  "ffold :: ('a \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> 'b \<Rightarrow> 'a fset \<Rightarrow> 'b"
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   621
  is "ffold_raw"
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   622
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   623
quotient_definition
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   624
  "fconcat :: ('a fset) fset \<Rightarrow> 'a fset"
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   625
is
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   626
  "concat"
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   627
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   628
quotient_definition
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   629
  "ffilter :: ('a \<Rightarrow> bool) \<Rightarrow> 'a fset \<Rightarrow> 'a fset"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   630
is
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   631
  "filter"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   632
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   633
text {* Compositional Respectfullness and Preservation *}
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   634
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   635
lemma [quot_respect]: "(list_all2 op \<approx> OOO op \<approx>) [] []"
1938
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   636
  by (fact compose_list_refl)
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   637
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   638
lemma [quot_preserve]: "(abs_fset \<circ> map f) [] = abs_fset []"
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   639
  by simp
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   640
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   641
lemma [quot_respect]:
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   642
  "(op \<approx> ===> list_all2 op \<approx> OOO op \<approx> ===> list_all2 op \<approx> OOO op \<approx>) op # op #"
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   643
  apply auto
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   644
  apply (simp add: set_in_eq)
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   645
  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
   646
  apply auto
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   647
  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
   648
  apply auto
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   649
  done
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   650
2196
74637f186af7 qpaper / a bit about prs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2190
diff changeset
   651
lemma insert_preserve2:
74637f186af7 qpaper / a bit about prs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2190
diff changeset
   652
  shows "((rep_fset ---> (map rep_fset \<circ> rep_fset) ---> (abs_fset \<circ> map abs_fset)) op #) =
74637f186af7 qpaper / a bit about prs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2190
diff changeset
   653
         (id ---> rep_fset ---> abs_fset) op #"
74637f186af7 qpaper / a bit about prs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2190
diff changeset
   654
  by (simp add: expand_fun_eq abs_o_rep[OF Quotient_fset] map_id Quotient_abs_rep[OF Quotient_fset])
74637f186af7 qpaper / a bit about prs
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2190
diff changeset
   655
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   656
lemma [quot_preserve]:
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   657
  "(rep_fset ---> (map rep_fset \<circ> rep_fset) ---> (abs_fset \<circ> map abs_fset)) op # = finsert"
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   658
  by (simp add: expand_fun_eq Quotient_abs_rep[OF Quotient_fset]
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   659
      abs_o_rep[OF Quotient_fset] map_id finsert_def)
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   660
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   661
lemma [quot_preserve]:
1938
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   662
  "((map rep_fset \<circ> rep_fset) ---> (map rep_fset \<circ> rep_fset) ---> (abs_fset \<circ> map abs_fset)) op @ = funion"
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   663
  by (simp add: expand_fun_eq Quotient_abs_rep[OF Quotient_fset]
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   664
      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
   665
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   666
lemma list_all2_app_l:
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   667
  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
   668
  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
   669
  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
   670
  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
   671
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   672
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
   673
  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
   674
  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
   675
  using a apply (induct x x' rule: list_induct2')
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   676
  by simp_all (rule list_all2_refl1)
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   677
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   678
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
   679
  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
   680
  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
   681
  using a apply (induct x x' arbitrary: z rule: list_induct2')
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   682
  apply (rule list_all2_refl1)
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   683
  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
   684
  apply (rule list_all2_app_l)
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   685
  apply (simp_all add: reflp_def)
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   686
  done
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   687
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   688
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
   689
  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
   690
  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
   691
  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
   692
  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
   693
  apply (rule append_rsp2_pre0)
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   694
  apply (rule a)
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   695
  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
   696
  apply (simp_all only: append_Nil2)
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   697
  apply (rule list_all2_refl1)
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   698
  apply simp_all
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   699
  apply (rule append_rsp2_pre1)
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   700
  apply simp
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   701
  done
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   702
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   703
lemma [quot_respect]:
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
   704
  "(list_all2 op \<approx> OOO op \<approx> ===> list_all2 op \<approx> OOO op \<approx> ===> list_all2 op \<approx> OOO op \<approx>) op @ op @"
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   705
proof (intro fun_relI, elim pred_compE)
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   706
  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
   707
  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
   708
  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
   709
  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
   710
  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
   711
  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
   712
  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
   713
  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
   714
  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
   715
  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
   716
  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
   717
    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
   718
  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
   719
    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
   720
qed
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   721
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   722
text {* Raw theorems. Finsert, memb, singleron, sub_list *}
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   723
1892
4df853f5879f reorder
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1889
diff changeset
   724
lemma nil_not_cons:
4df853f5879f reorder
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1889
diff changeset
   725
  shows "\<not> ([] \<approx> x # xs)"
4df853f5879f reorder
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1889
diff changeset
   726
  and   "\<not> (x # xs \<approx> [])"
4df853f5879f reorder
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1889
diff changeset
   727
  by auto
4df853f5879f reorder
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1889
diff changeset
   728
1878
c22947214948 2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1860
diff changeset
   729
lemma no_memb_nil:
c22947214948 2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1860
diff changeset
   730
  "(\<forall>x. \<not> memb x xs) = (xs = [])"
c22947214948 2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1860
diff changeset
   731
  by (simp add: memb_def)
c22947214948 2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1860
diff changeset
   732
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   733
lemma memb_consI1:
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   734
  shows "memb x (x # xs)"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   735
  by (simp add: memb_def)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   736
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   737
lemma memb_consI2:
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   738
  shows "memb x xs \<Longrightarrow> memb x (y # xs)"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   739
  by (simp add: memb_def)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   740
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   741
lemma singleton_list_eq:
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   742
  shows "[x] \<approx> [y] \<longleftrightarrow> x = y"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   743
  by (simp add: id_simps) auto
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   744
1892
4df853f5879f reorder
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1889
diff changeset
   745
lemma sub_list_cons:
4df853f5879f reorder
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1889
diff changeset
   746
  "sub_list (x # xs) ys = (memb x ys \<and> sub_list xs ys)"
4df853f5879f reorder
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1889
diff changeset
   747
  by (auto simp add: memb_def sub_list_def)
4df853f5879f reorder
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1889
diff changeset
   748
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   749
lemma fminus_raw_red: "fminus_raw (x # xs) ys = (if memb x ys then fminus_raw xs ys else x # (fminus_raw xs ys))"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   750
  by (induct ys arbitrary: xs x)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   751
     (simp_all add: not_memb_nil memb_delete_raw memb_cons_iff)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   752
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   753
text {* Cardinality of finite sets *}
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   754
1813
69fff336dd18 Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1682
diff changeset
   755
lemma fcard_raw_0:
1860
d3fe17786640 some tuning of proofs
Christian Urban <urbanc@in.tum.de>
parents: 1826
diff changeset
   756
  shows "fcard_raw xs = 0 \<longleftrightarrow> xs \<approx> []"
1821
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   757
  by (induct xs) (auto simp add: memb_def)
1813
69fff336dd18 Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1682
diff changeset
   758
69fff336dd18 Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1682
diff changeset
   759
lemma fcard_raw_not_memb:
1860
d3fe17786640 some tuning of proofs
Christian Urban <urbanc@in.tum.de>
parents: 1826
diff changeset
   760
  shows "\<not> memb x xs \<longleftrightarrow> fcard_raw (x # xs) = Suc (fcard_raw xs)"
1813
69fff336dd18 Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1682
diff changeset
   761
  by auto
69fff336dd18 Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1682
diff changeset
   762
69fff336dd18 Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1682
diff changeset
   763
lemma fcard_raw_suc:
1860
d3fe17786640 some tuning of proofs
Christian Urban <urbanc@in.tum.de>
parents: 1826
diff changeset
   764
  assumes a: "fcard_raw xs = Suc n"
d3fe17786640 some tuning of proofs
Christian Urban <urbanc@in.tum.de>
parents: 1826
diff changeset
   765
  shows "\<exists>x ys. \<not> (memb x ys) \<and> xs \<approx> (x # ys) \<and> fcard_raw ys = n"
d3fe17786640 some tuning of proofs
Christian Urban <urbanc@in.tum.de>
parents: 1826
diff changeset
   766
  using a
d3fe17786640 some tuning of proofs
Christian Urban <urbanc@in.tum.de>
parents: 1826
diff changeset
   767
  by (induct xs) (auto simp add: memb_def split: if_splits)
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   768
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   769
lemma singleton_fcard_1:
1860
d3fe17786640 some tuning of proofs
Christian Urban <urbanc@in.tum.de>
parents: 1826
diff changeset
   770
  shows "set xs = {x} \<Longrightarrow> fcard_raw xs = 1"
d3fe17786640 some tuning of proofs
Christian Urban <urbanc@in.tum.de>
parents: 1826
diff changeset
   771
  by (induct xs) (auto simp add: memb_def subset_insert)
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   772
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   773
lemma fcard_raw_1:
1823
91ba55dba5e0 added header and more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1822
diff changeset
   774
  shows "fcard_raw xs = 1 \<longleftrightarrow> (\<exists>x. xs \<approx> [x])"
91ba55dba5e0 added header and more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1822
diff changeset
   775
  apply (auto dest!: fcard_raw_suc)
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   776
  apply (simp add: fcard_raw_0)
1821
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   777
  apply (rule_tac x="x" in exI)
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   778
  apply simp
1821
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   779
  apply (subgoal_tac "set xs = {x}")
1860
d3fe17786640 some tuning of proofs
Christian Urban <urbanc@in.tum.de>
parents: 1826
diff changeset
   780
  apply (drule singleton_fcard_1)
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   781
  apply auto
1813
69fff336dd18 Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1682
diff changeset
   782
  done
69fff336dd18 Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1682
diff changeset
   783
1878
c22947214948 2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1860
diff changeset
   784
lemma fcard_raw_suc_memb:
c22947214948 2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1860
diff changeset
   785
  assumes a: "fcard_raw A = Suc n"
c22947214948 2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1860
diff changeset
   786
  shows "\<exists>a. memb a A"
c22947214948 2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1860
diff changeset
   787
  using a
1938
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   788
  by (induct A) (auto simp add: memb_def)
1878
c22947214948 2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1860
diff changeset
   789
1884
5fd2ed815144 more metis cleaning
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1883
diff changeset
   790
lemma memb_card_not_0:
1878
c22947214948 2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1860
diff changeset
   791
  assumes a: "memb a A"
c22947214948 2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1860
diff changeset
   792
  shows "\<not>(fcard_raw A = 0)"
1883
b2fa5de30a73 Getting rid of 'metis'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1881
diff changeset
   793
proof -
b2fa5de30a73 Getting rid of 'metis'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1881
diff changeset
   794
  have "\<not>(\<forall>x. \<not> memb x A)" using a by auto
b2fa5de30a73 Getting rid of 'metis'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1881
diff changeset
   795
  then have "\<not>A \<approx> []" using none_memb_nil[of A] by simp
b2fa5de30a73 Getting rid of 'metis'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1881
diff changeset
   796
  then show ?thesis using fcard_raw_0[of A] by simp
b2fa5de30a73 Getting rid of 'metis'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1881
diff changeset
   797
qed
1878
c22947214948 2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1860
diff changeset
   798
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   799
text {* fmap *}
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   800
1813
69fff336dd18 Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1682
diff changeset
   801
lemma map_append:
1821
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   802
  "map f (xs @ ys) \<approx> (map f xs) @ (map f ys)"
1813
69fff336dd18 Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1682
diff changeset
   803
  by simp
69fff336dd18 Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1682
diff changeset
   804
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   805
lemma memb_append:
1823
91ba55dba5e0 added header and more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1822
diff changeset
   806
  "memb x (xs @ ys) \<longleftrightarrow> memb x xs \<or> memb x ys"
1821
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   807
  by (induct xs) (simp_all add: not_memb_nil memb_cons_iff)
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   808
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   809
lemma cons_left_comm:
1821
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   810
  "x # y # xs \<approx> y # x # xs"
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   811
  by auto
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   812
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   813
lemma cons_left_idem:
1821
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   814
  "x # x # xs \<approx> x # xs"
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   815
  by auto
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   816
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   817
lemma fset_raw_strong_cases:
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   818
  obtains "xs = []"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   819
    | x ys where "\<not> memb x ys" and "xs \<approx> x # ys"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   820
proof (induct xs arbitrary: x ys)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   821
  case Nil
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   822
  then show thesis by simp
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   823
next
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   824
  case (Cons a xs)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   825
  have a: "\<lbrakk>xs = [] \<Longrightarrow> thesis; \<And>x ys. \<lbrakk>\<not> memb x ys; xs \<approx> x # ys\<rbrakk> \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis" by fact
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   826
  have b: "\<And>x' ys'. \<lbrakk>\<not> memb x' ys'; a # xs \<approx> x' # ys'\<rbrakk> \<Longrightarrow> thesis" by fact
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   827
  have c: "xs = [] \<Longrightarrow> thesis" by (metis no_memb_nil singleton_list_eq b)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   828
  have "\<And>x ys. \<lbrakk>\<not> memb x ys; xs \<approx> x # ys\<rbrakk> \<Longrightarrow> thesis"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   829
  proof -
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   830
    fix x :: 'a
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   831
    fix ys :: "'a list"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   832
    assume d:"\<not> memb x ys"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   833
    assume e:"xs \<approx> x # ys"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   834
    show thesis
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   835
    proof (cases "x = a")
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   836
      assume h: "x = a"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   837
      then have f: "\<not> memb a ys" using d by simp
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   838
      have g: "a # xs \<approx> a # ys" using e h by auto
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   839
      show thesis using b f g by simp
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   840
    next
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   841
      assume h: "x \<noteq> a"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   842
      then have f: "\<not> memb x (a # ys)" using d unfolding memb_def by auto
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   843
      have g: "a # xs \<approx> x # (a # ys)" using e h by auto
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   844
      show thesis using b f g by simp
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   845
    qed
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   846
  qed
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   847
  then show thesis using a c by blast
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   848
qed
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   849
1860
d3fe17786640 some tuning of proofs
Christian Urban <urbanc@in.tum.de>
parents: 1826
diff changeset
   850
section {* deletion *}
d3fe17786640 some tuning of proofs
Christian Urban <urbanc@in.tum.de>
parents: 1826
diff changeset
   851
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   852
lemma memb_delete_raw_ident:
1860
d3fe17786640 some tuning of proofs
Christian Urban <urbanc@in.tum.de>
parents: 1826
diff changeset
   853
  shows "\<not> memb x (delete_raw xs x)"
1821
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   854
  by (induct xs) (auto simp add: memb_def)
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   855
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   856
lemma fset_raw_delete_raw_cases:
1821
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   857
  "xs = [] \<or> (\<exists>x. memb x xs \<and> xs \<approx> x # delete_raw xs x)"
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   858
  by (induct xs) (auto simp add: memb_def)
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   859
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   860
lemma fdelete_raw_filter:
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   861
  "delete_raw xs y = [x \<leftarrow> xs. x \<noteq> y]"
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   862
  by (induct xs) simp_all
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   863
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   864
lemma fcard_raw_delete:
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   865
  "fcard_raw (delete_raw xs y) = (if memb y xs then fcard_raw xs - 1 else fcard_raw xs)"
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   866
  by (simp add: fdelete_raw_filter fcard_raw_delete_one)
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   867
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   868
lemma finter_raw_empty:
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   869
  "finter_raw l [] = []"
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   870
  by (induct l) (simp_all add: not_memb_nil)
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   871
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   872
lemma set_cong:
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   873
  shows "(x \<approx> y) = (set x = set y)"
1821
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   874
  by auto
1533
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   875
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   876
lemma inj_map_eq_iff:
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   877
  "inj f \<Longrightarrow> (map f l \<approx> map f m) = (l \<approx> m)"
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   878
  by (simp add: expand_set_eq[symmetric] inj_image_eq_iff)
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   879
1888
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   880
text {* alternate formulation with a different decomposition principle
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   881
  and a proof of equivalence *}
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   882
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   883
inductive
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   884
  list_eq2
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   885
where
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   886
  "list_eq2 (a # b # xs) (b # a # xs)"
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   887
| "list_eq2 [] []"
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   888
| "list_eq2 xs ys \<Longrightarrow> list_eq2 ys xs"
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   889
| "list_eq2 (a # a # xs) (a # xs)"
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   890
| "list_eq2 xs ys \<Longrightarrow> list_eq2 (a # xs) (a # ys)"
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   891
| "\<lbrakk>list_eq2 xs1 xs2; list_eq2 xs2 xs3\<rbrakk> \<Longrightarrow> list_eq2 xs1 xs3"
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   892
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   893
lemma list_eq2_refl:
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   894
  shows "list_eq2 xs xs"
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   895
  by (induct xs) (auto intro: list_eq2.intros)
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   896
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   897
lemma cons_delete_list_eq2:
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   898
  shows "list_eq2 (a # (delete_raw A a)) (if memb a A then A else a # A)"
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   899
  apply (induct A)
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   900
  apply (simp add: memb_def list_eq2_refl)
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   901
  apply (case_tac "memb a (aa # A)")
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   902
  apply (simp_all only: memb_cons_iff)
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   903
  apply (case_tac [!] "a = aa")
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   904
  apply (simp_all)
1888
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   905
  apply (case_tac "memb a A")
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   906
  apply (auto simp add: memb_def)[2]
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   907
  apply (metis list_eq2.intros(3) list_eq2.intros(4) list_eq2.intros(5) list_eq2.intros(6))
1895
91d67240c9c1 FSet is a semi-lattice
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1893
diff changeset
   908
  apply (metis list_eq2.intros(1) list_eq2.intros(5) list_eq2.intros(6))
1888
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   909
  apply (auto simp add: list_eq2_refl not_memb_delete_raw_ident)
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   910
  done
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   911
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   912
lemma memb_delete_list_eq2:
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   913
  assumes a: "memb e r"
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   914
  shows "list_eq2 (e # delete_raw r e) r"
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   915
  using a cons_delete_list_eq2[of e r]
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   916
  by simp
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   917
1909
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   918
lemma delete_raw_rsp:
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   919
  "xs \<approx> ys \<Longrightarrow> delete_raw xs x \<approx> delete_raw ys x"
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   920
  by (simp add: memb_def[symmetric] memb_delete_raw)
9972dc5bd7ad Reorder FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1907
diff changeset
   921
1888
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   922
lemma list_eq2_equiv:
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   923
  "(l \<approx> r) \<longleftrightarrow> (list_eq2 l r)"
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   924
proof
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   925
  show "list_eq2 l r \<Longrightarrow> l \<approx> r" by (induct rule: list_eq2.induct) auto
1938
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   926
next
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   927
  {
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   928
    fix n
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   929
    assume a: "fcard_raw l = n" and b: "l \<approx> r"
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   930
    have "list_eq2 l r"
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   931
      using a b
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   932
    proof (induct n arbitrary: l r)
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   933
      case 0
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   934
      have "fcard_raw l = 0" by fact
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   935
      then have "\<forall>x. \<not> memb x l" using memb_card_not_0[of _ l] by auto
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   936
      then have z: "l = []" using no_memb_nil by auto
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   937
      then have "r = []" using `l \<approx> r` by simp
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   938
      then show ?case using z list_eq2_refl by simp
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   939
    next
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   940
      case (Suc m)
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   941
      have b: "l \<approx> r" by fact
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   942
      have d: "fcard_raw l = Suc m" by fact
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   943
      then have "\<exists>a. memb a l" by (rule fcard_raw_suc_memb)
1938
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   944
      then obtain a where e: "memb a l" by auto
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   945
      then have e': "memb a r" using list_eq.simps[simplified memb_def[symmetric], of l r] b by auto
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   946
      have f: "fcard_raw (delete_raw l a) = m" using fcard_raw_delete[of l a] e d by simp
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   947
      have g: "delete_raw l a \<approx> delete_raw r a" using delete_raw_rsp[OF b] by simp
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   948
      have "list_eq2 (delete_raw l a) (delete_raw r a)" by (rule Suc.hyps[OF f g])
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   949
      then have h: "list_eq2 (a # delete_raw l a) (a # delete_raw r a)" by (rule list_eq2.intros(5))
1938
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   950
      have i: "list_eq2 l (a # delete_raw l a)"
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   951
        by (rule list_eq2.intros(3)[OF memb_delete_list_eq2[OF e]])
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   952
      have "list_eq2 l (a # delete_raw r a)" by (rule list_eq2.intros(6)[OF i h])
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   953
      then show ?case using list_eq2.intros(6)[OF _ memb_delete_list_eq2[OF e']] by simp
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   954
    qed
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   955
    }
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
   956
  then show "l \<approx> r \<Longrightarrow> list_eq2 l r" by blast
1888
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   957
qed
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
   958
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   959
text {* Set *}
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   960
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   961
lemma sub_list_set: "sub_list xs ys = (set xs \<subseteq> set ys)"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   962
  by (metis rev_append set_append set_cong set_rev sub_list_append sub_list_append_left sub_list_def sub_list_not_eq subset_Un_eq)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   963
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   964
lemma sub_list_neq_set: "(sub_list xs ys \<and> \<not> list_eq xs ys) = (set xs \<subset> set ys)"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   965
  by (auto simp add: sub_list_set)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   966
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   967
lemma fcard_raw_set: "fcard_raw xs = card (set xs)"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   968
  by (induct xs) (auto simp add: insert_absorb memb_def card_insert_disjoint finite_set)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   969
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   970
lemma memb_set: "memb x xs = (x \<in> set xs)"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   971
  by (simp only: memb_def)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   972
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   973
lemma filter_set: "set (filter P xs) = P \<inter> (set xs)"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   974
  by (induct xs, simp)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   975
     (metis Int_insert_right_if0 Int_insert_right_if1 List.set.simps(2) filter.simps(2) mem_def)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   976
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   977
lemma delete_raw_set: "set (delete_raw xs x) = set xs - {x}"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   978
  by (induct xs) auto
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   979
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   980
lemma inter_raw_set: "set (finter_raw xs ys) = set xs \<inter> set ys"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   981
  by (induct xs) (simp_all add: memb_def)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   982
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   983
lemma fminus_raw_set: "set (fminus_raw xs ys) = set xs - set ys"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   984
  by (induct ys arbitrary: xs)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   985
     (simp_all add: fminus_raw.simps delete_raw_set, blast)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   986
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   987
text {* Raw theorems of ffilter *}
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   988
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   989
lemma sub_list_filter: "sub_list (filter P xs) (filter Q xs) = (\<forall> x. memb x xs \<longrightarrow> P x \<longrightarrow> Q x)"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   990
unfolding sub_list_def memb_def by auto
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   991
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   992
lemma list_eq_filter: "list_eq (filter P xs) (filter Q xs) = (\<forall>x. memb x xs \<longrightarrow> P x = Q x)"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   993
unfolding memb_def by auto
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
   994
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
   995
text {* Lifted theorems *}
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   996
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   997
lemma not_fin_fnil: "x |\<notin>| {||}"
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   998
  by (lifting not_memb_nil)
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   999
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1000
lemma fin_finsert_iff[simp]:
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1001
  "x |\<in>| finsert y S = (x = y \<or> x |\<in>| S)"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1002
  by (lifting memb_cons_iff)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1003
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1004
lemma
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1005
  shows finsertI1: "x |\<in>| finsert x S"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1006
  and   finsertI2: "x |\<in>| S \<Longrightarrow> x |\<in>| finsert y S"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1007
  by (lifting memb_consI1, lifting memb_consI2)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1008
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1009
lemma finsert_absorb[simp]:
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1010
  shows "x |\<in>| S \<Longrightarrow> finsert x S = S"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1011
  by (lifting memb_absorb)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1012
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1013
lemma fempty_not_finsert[simp]:
1533
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
  1014
  "{||} \<noteq> finsert x S"
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
  1015
  "finsert x S \<noteq> {||}"
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1016
  by (lifting nil_not_cons)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1017
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1018
lemma finsert_left_comm:
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
  1019
  "finsert x (finsert y S) = finsert y (finsert x S)"
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1020
  by (lifting cons_left_comm)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1021
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1022
lemma finsert_left_idem:
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
  1023
  "finsert x (finsert x S) = finsert x S"
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1024
  by (lifting cons_left_idem)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1025
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1026
lemma fsingleton_eq[simp]:
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1027
  shows "{|x|} = {|y|} \<longleftrightarrow> x = y"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1028
  by (lifting singleton_list_eq)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1029
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1030
text {* fset_to_set *}
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1031
1533
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
  1032
lemma fset_to_set_simps[simp]:
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1033
  "fset_to_set {||} = ({} :: 'a set)"
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1034
  "fset_to_set (finsert (h :: 'a) t) = insert h (fset_to_set t)"
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1035
  by (lifting set.simps)
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1036
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1037
lemma in_fset_to_set:
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
  1038
  "x \<in> fset_to_set S \<equiv> x |\<in>| S"
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1039
  by (lifting memb_def[symmetric])
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1040
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1041
lemma none_fin_fempty:
1824
2ccc1b00377c merge part1: none_memb_nil
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1823
diff changeset
  1042
  "(\<forall>x. x |\<notin>| S) = (S = {||})"
2ccc1b00377c merge part1: none_memb_nil
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1823
diff changeset
  1043
  by (lifting none_memb_nil)
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1044
1533
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
  1045
lemma fset_cong:
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1046
  "(S = T) = (fset_to_set S = fset_to_set T)"
1533
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
  1047
  by (lifting set_cong)
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
  1048
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1049
text {* fcard *}
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1050
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1051
lemma fcard_fempty [simp]:
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1052
  shows "fcard {||} = 0"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1053
  by (lifting fcard_raw_nil)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1054
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1055
lemma fcard_finsert_if [simp]:
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1056
  shows "fcard (finsert x S) = (if x |\<in>| S then fcard S else Suc (fcard S))"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1057
  by (lifting fcard_raw_cons)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1058
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
  1059
lemma fcard_0: "(fcard S = 0) = (S = {||})"
1813
69fff336dd18 Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1682
diff changeset
  1060
  by (lifting fcard_raw_0)
69fff336dd18 Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1682
diff changeset
  1061
1821
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
  1062
lemma fcard_1:
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
  1063
  shows "(fcard S = 1) = (\<exists>x. S = {|x|})"
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1064
  by (lifting fcard_raw_1)
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1065
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1066
lemma fcard_gt_0:
1860
d3fe17786640 some tuning of proofs
Christian Urban <urbanc@in.tum.de>
parents: 1826
diff changeset
  1067
  shows "x \<in> fset_to_set S \<Longrightarrow> 0 < fcard S"
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1068
  by (lifting fcard_raw_gt_0)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1069
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1070
lemma fcard_not_fin:
1860
d3fe17786640 some tuning of proofs
Christian Urban <urbanc@in.tum.de>
parents: 1826
diff changeset
  1071
  shows "(x |\<notin>| S) = (fcard (finsert x S) = Suc (fcard S))"
1813
69fff336dd18 Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1682
diff changeset
  1072
  by (lifting fcard_raw_not_memb)
69fff336dd18 Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1682
diff changeset
  1073
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
  1074
lemma fcard_suc: "fcard S = Suc n \<Longrightarrow> \<exists>x T. x |\<notin>| T \<and> S = finsert x T \<and> fcard T = n"
1813
69fff336dd18 Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1682
diff changeset
  1075
  by (lifting fcard_raw_suc)
69fff336dd18 Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1682
diff changeset
  1076
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1077
lemma fcard_delete:
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
  1078
  "fcard (fdelete S y) = (if y |\<in>| S then fcard S - 1 else fcard S)"
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1079
  by (lifting fcard_raw_delete)
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1080
1878
c22947214948 2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1860
diff changeset
  1081
lemma fcard_suc_memb: "fcard A = Suc n \<Longrightarrow> \<exists>a. a |\<in>| A"
c22947214948 2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1860
diff changeset
  1082
  by (lifting fcard_raw_suc_memb)
c22947214948 2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1860
diff changeset
  1083
c22947214948 2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1860
diff changeset
  1084
lemma fin_fcard_not_0: "a |\<in>| A \<Longrightarrow> fcard A \<noteq> 0"
1887
7abd8c1d9f4b Some new lemmas
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1886
diff changeset
  1085
  by (lifting memb_card_not_0)
1878
c22947214948 2 more lifted lemmas needed for second representation
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1860
diff changeset
  1086
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1087
text {* funion *}
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1088
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1089
lemmas [simp] =
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1090
  sup_bot_left[where 'a="'a fset", standard]
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1091
  sup_bot_right[where 'a="'a fset", standard]
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1092
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1093
lemma funion_finsert[simp]:
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1094
  shows "finsert x S |\<union>| T = finsert x (S |\<union>| T)"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1095
  by (lifting append.simps(2))
1887
7abd8c1d9f4b Some new lemmas
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1886
diff changeset
  1096
7abd8c1d9f4b Some new lemmas
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1886
diff changeset
  1097
lemma singleton_union_left:
7abd8c1d9f4b Some new lemmas
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1886
diff changeset
  1098
  "{|a|} |\<union>| S = finsert a S"
7abd8c1d9f4b Some new lemmas
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1886
diff changeset
  1099
  by simp
7abd8c1d9f4b Some new lemmas
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1886
diff changeset
  1100
7abd8c1d9f4b Some new lemmas
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1886
diff changeset
  1101
lemma singleton_union_right:
7abd8c1d9f4b Some new lemmas
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1886
diff changeset
  1102
  "S |\<union>| {|a|} = finsert a S"
1907
7b74cf843942 lattice properties.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1905
diff changeset
  1103
  by (subst sup.commute) simp
1887
7abd8c1d9f4b Some new lemmas
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1886
diff changeset
  1104
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1105
section {* Induction and Cases rules for finite sets *}
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1106
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1107
lemma fset_strong_cases:
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1108
  obtains "xs = {||}"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1109
    | x ys where "x |\<notin>| ys" and "xs = finsert x ys"
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1110
  by (lifting fset_raw_strong_cases)
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1111
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1112
lemma fset_exhaust[case_names fempty finsert, cases type: fset]:
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1113
  shows "\<lbrakk>S = {||} \<Longrightarrow> P; \<And>x S'. S = finsert x S' \<Longrightarrow> P\<rbrakk> \<Longrightarrow> P"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1114
  by (lifting list.exhaust)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1115
1533
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
  1116
lemma fset_induct_weak[case_names fempty finsert]:
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1117
  shows "\<lbrakk>P {||}; \<And>x S. P S \<Longrightarrow> P (finsert x S)\<rbrakk> \<Longrightarrow> P S"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1118
  by (lifting list.induct)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1119
1533
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
  1120
lemma fset_induct[case_names fempty finsert, induct type: fset]:
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1121
  assumes prem1: "P {||}"
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1122
  and     prem2: "\<And>x S. \<lbrakk>x |\<notin>| S; P S\<rbrakk> \<Longrightarrow> P (finsert x S)"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1123
  shows "P S"
1533
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
  1124
proof(induct S rule: fset_induct_weak)
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1125
  case fempty
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1126
  show "P {||}" by (rule prem1)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1127
next
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1128
  case (finsert x S)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1129
  have asm: "P S" by fact
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1130
  show "P (finsert x S)"
1938
3641d055b260 Further cleaning of proofs in FSet
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1936
diff changeset
  1131
    by (cases "x |\<in>| S") (simp_all add: asm prem2)
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1132
qed
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1133
1533
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
  1134
lemma fset_induct2:
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
  1135
  "P {||} {||} \<Longrightarrow>
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
  1136
  (\<And>x xs. x |\<notin>| xs \<Longrightarrow> P (finsert x xs) {||}) \<Longrightarrow>
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
  1137
  (\<And>y ys. y |\<notin>| ys \<Longrightarrow> P {||} (finsert y ys)) \<Longrightarrow>
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
  1138
  (\<And>x xs y ys. \<lbrakk>P xs ys; x |\<notin>| xs; y |\<notin>| ys\<rbrakk> \<Longrightarrow> P (finsert x xs) (finsert y ys)) \<Longrightarrow>
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
  1139
  P xsa ysa"
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
  1140
  apply (induct xsa arbitrary: ysa)
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
  1141
  apply (induct_tac x rule: fset_induct)
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
  1142
  apply simp_all
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
  1143
  apply (induct_tac xa rule: fset_induct)
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
  1144
  apply simp_all
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
  1145
  done
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
  1146
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1147
lemma fset_fcard_induct:
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1148
  assumes a: "P {||}"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1149
  and     b: "\<And>xs ys. Suc (fcard xs) = (fcard ys) \<Longrightarrow> P xs \<Longrightarrow> P ys"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1150
  shows "P zs"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1151
proof (induct zs)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1152
  show "P {||}" by (rule a)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1153
next
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1154
  fix x :: 'a and zs :: "'a fset"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1155
  assume h: "P zs"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1156
  assume "x |\<notin>| zs"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1157
  then have H1: "Suc (fcard zs) = fcard (finsert x zs)" using fcard_suc by auto
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1158
  then show "P (finsert x zs)" using b h by simp
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1159
qed
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1160
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1161
text {* fmap *}
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1162
1533
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
  1163
lemma fmap_simps[simp]:
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
  1164
  "fmap (f :: 'a \<Rightarrow> 'b) {||} = {||}"
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
  1165
  "fmap f (finsert x S) = finsert (f x) (fmap f S)"
1533
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
  1166
  by (lifting map.simps)
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
  1167
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
  1168
lemma fmap_set_image:
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
  1169
  "fset_to_set (fmap f S) = f ` (fset_to_set S)"
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1170
  by (induct S) simp_all
1533
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
  1171
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
  1172
lemma inj_fmap_eq_iff:
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
  1173
  "inj f \<Longrightarrow> (fmap f S = fmap f T) = (S = T)"
1533
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
  1174
  by (lifting inj_map_eq_iff)
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
  1175
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
  1176
lemma fmap_funion: "fmap f (S |\<union>| T) = fmap f S |\<union>| fmap f T"
1813
69fff336dd18 Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1682
diff changeset
  1177
  by (lifting map_append)
69fff336dd18 Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1682
diff changeset
  1178
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1179
lemma fin_funion:
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
  1180
  "x |\<in>| S |\<union>| T \<longleftrightarrow> x |\<in>| S \<or> x |\<in>| T"
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1181
  by (lifting memb_append)
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1182
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1183
text {* to_set *}
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1184
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1185
lemma fin_set: "(x |\<in>| xs) = (x \<in> fset_to_set xs)"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1186
  by (lifting memb_set)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1187
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1188
lemma fnotin_set: "(x |\<notin>| xs) = (x \<notin> fset_to_set xs)"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1189
  by (simp add: fin_set)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1190
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1191
lemma fcard_set: "fcard xs = card (fset_to_set xs)"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1192
  by (lifting fcard_raw_set)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1193
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1194
lemma fsubseteq_set: "(xs |\<subseteq>| ys) = (fset_to_set xs \<subseteq> fset_to_set ys)"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1195
  by (lifting sub_list_set)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1196
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1197
lemma fsubset_set: "(xs |\<subset>| ys) = (fset_to_set xs \<subset> fset_to_set ys)"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1198
  unfolding less_fset by (lifting sub_list_neq_set)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1199
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1200
lemma ffilter_set: "fset_to_set (ffilter P xs) = P \<inter> fset_to_set xs"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1201
  by (lifting filter_set)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1202
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1203
lemma fdelete_set: "fset_to_set (fdelete xs x) = fset_to_set xs - {x}"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1204
  by (lifting delete_raw_set)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1205
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1206
lemma inter_set: "fset_to_set (xs |\<inter>| ys) = fset_to_set xs \<inter> fset_to_set ys"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1207
  by (lifting inter_raw_set)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1208
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1209
lemma union_set: "fset_to_set (xs |\<union>| ys) = fset_to_set xs \<union> fset_to_set ys"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1210
  by (lifting set_append)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1211
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1212
lemma fminus_set: "fset_to_set (xs - ys) = fset_to_set xs - fset_to_set ys"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1213
  by (lifting fminus_raw_set)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1214
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1215
lemmas fset_to_set_trans =
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1216
  fin_set fnotin_set fcard_set fsubseteq_set fsubset_set
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1217
  inter_set union_set ffilter_set fset_to_set_simps
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1218
  fset_cong fdelete_set fmap_set_image fminus_set
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1219
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1220
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1221
text {* ffold *}
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1222
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1223
lemma ffold_nil: "ffold f z {||} = z"
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1224
  by (lifting ffold_raw.simps(1)[where 'a="'b" and 'b="'a"])
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1225
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1226
lemma ffold_finsert: "ffold f z (finsert a A) =
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1227
  (if rsp_fold f then if a |\<in>| A then ffold f z A else f a (ffold f z A) else z)"
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1228
  by (lifting ffold_raw.simps(2)[where 'a="'b" and 'b="'a"])
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1229
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1230
lemma fin_commute_ffold:
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1231
  "\<lbrakk>rsp_fold f; h |\<in>| b\<rbrakk> \<Longrightarrow> ffold f z b = f h (ffold f z (fdelete b h))"
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1232
  by (lifting memb_commute_ffold_raw)
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1233
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1234
text {* fdelete *}
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1235
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1236
lemma fin_fdelete:
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
  1237
  shows "x |\<in>| fdelete S y \<longleftrightarrow> x |\<in>| S \<and> x \<noteq> y"
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1238
  by (lifting memb_delete_raw)
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1239
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1240
lemma fin_fdelete_ident:
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
  1241
  shows "x |\<notin>| fdelete S x"
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1242
  by (lifting memb_delete_raw_ident)
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1243
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1244
lemma not_memb_fdelete_ident:
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
  1245
  shows "x |\<notin>| S \<Longrightarrow> fdelete S x = S"
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1246
  by (lifting not_memb_delete_raw_ident)
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1247
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1248
lemma fset_fdelete_cases:
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
  1249
  shows "S = {||} \<or> (\<exists>x. x |\<in>| S \<and> S = finsert x (fdelete S x))"
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1250
  by (lifting fset_raw_delete_raw_cases)
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1251
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1252
text {* inter *}
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1253
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
  1254
lemma finter_empty_l: "({||} |\<inter>| S) = {||}"
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1255
  by (lifting finter_raw.simps(1))
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1256
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
  1257
lemma finter_empty_r: "(S |\<inter>| {||}) = {||}"
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1258
  by (lifting finter_raw_empty)
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1259
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1260
lemma finter_finsert:
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
  1261
  "finsert x S |\<inter>| T = (if x |\<in>| T then finsert x (S |\<inter>| T) else S |\<inter>| T)"
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1262
  by (lifting finter_raw.simps(2))
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1263
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1264
lemma fin_finter:
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
  1265
  "x |\<in>| (S |\<inter>| T) \<longleftrightarrow> x |\<in>| S \<and> x |\<in>| T"
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1266
  by (lifting memb_finter_raw)
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
  1267
1893
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
  1268
lemma fsubset_finsert:
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
  1269
  "(finsert x xs |\<subseteq>| ys) = (x |\<in>| ys \<and> xs |\<subseteq>| ys)"
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
  1270
  by (lifting sub_list_cons)
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
  1271
1936
99367d481f78 Converted 'thm' to a lemma.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1935
diff changeset
  1272
lemma "xs |\<subseteq>| ys \<equiv> \<forall>x. x |\<in>| xs \<longrightarrow> x |\<in>| ys"
99367d481f78 Converted 'thm' to a lemma.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1935
diff changeset
  1273
  by (lifting sub_list_def[simplified memb_def[symmetric]])
1893
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
  1274
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
  1275
lemma fsubset_fin: "xs |\<subseteq>| ys = (\<forall>x. x |\<in>| xs \<longrightarrow> x |\<in>| ys)"
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
  1276
by (rule meta_eq_to_obj_eq)
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
  1277
   (lifting sub_list_def[simplified memb_def[symmetric]])
464dd13efff6 Putting FSet in bot typeclass.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1892
diff changeset
  1278
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1279
lemma fminus_fin: "(x |\<in>| xs - ys) = (x |\<in>| xs \<and> x |\<notin>| ys)"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1280
  by (lifting fminus_raw_memb)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1281
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1282
lemma fminus_red: "finsert x xs - ys = (if x |\<in>| ys then xs - ys else finsert x (xs - ys))"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1283
  by (lifting fminus_raw_red)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1284
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1285
lemma fminus_red_fin[simp]: "x |\<in>| ys \<Longrightarrow> finsert x xs - ys = xs - ys"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1286
  by (simp add: fminus_red)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1287
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1288
lemma fminus_red_fnotin[simp]: "x |\<notin>| ys \<Longrightarrow> finsert x xs - ys = finsert x (xs - ys)"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1289
  by (simp add: fminus_red)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1290
1820
de28a91eaca3 Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1819
diff changeset
  1291
lemma expand_fset_eq:
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
  1292
  "(S = T) = (\<forall>x. (x |\<in>| S) = (x |\<in>| T))"
1820
de28a91eaca3 Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1819
diff changeset
  1293
  by (lifting list_eq.simps[simplified memb_def[symmetric]])
de28a91eaca3 Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1819
diff changeset
  1294
1888
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1295
(* 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
  1296
   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
  1297
   a different order *)
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1298
lemma fset_eq_cases:
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1299
 "\<lbrakk>a1 = a2;
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1300
   \<And>a b xs. \<lbrakk>a1 = finsert a (finsert b xs); a2 = finsert b (finsert a xs)\<rbrakk> \<Longrightarrow> P;
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1301
   \<lbrakk>a1 = {||}; a2 = {||}\<rbrakk> \<Longrightarrow> P; \<And>xs ys. \<lbrakk>a1 = ys; a2 = xs; xs = ys\<rbrakk> \<Longrightarrow> P;
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1302
   \<And>a xs. \<lbrakk>a1 = finsert a (finsert a xs); a2 = finsert a xs\<rbrakk> \<Longrightarrow> P;
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1303
   \<And>xs ys a. \<lbrakk>a1 = finsert a xs; a2 = finsert a ys; xs = ys\<rbrakk> \<Longrightarrow> P;
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1304
   \<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
  1305
  \<Longrightarrow> P"
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1306
  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
  1307
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1308
lemma fset_eq_induct:
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1309
  assumes "x1 = x2"
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1310
  and "\<And>a b xs. P (finsert a (finsert b xs)) (finsert b (finsert a xs))"
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1311
  and "P {||} {||}"
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1312
  and "\<And>xs ys. \<lbrakk>xs = ys; P xs ys\<rbrakk> \<Longrightarrow> P ys xs"
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1313
  and "\<And>a xs. P (finsert a (finsert a xs)) (finsert a xs)"
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1314
  and "\<And>xs ys a. \<lbrakk>xs = ys; P xs ys\<rbrakk> \<Longrightarrow> P (finsert a xs) (finsert a ys)"
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1315
  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
  1316
  shows "P x1 x2"
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1317
  using assms
59f41804b3f8 Alternate list_eq and equivalence
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1887
diff changeset
  1318
  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
  1319
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
  1320
text {* concat *}
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
  1321
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
  1322
lemma fconcat_empty:
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
  1323
  shows "fconcat {||} = {||}"
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
  1324
  by (lifting concat.simps(1))
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
  1325
2368
d7dfe272b4f8 some test with quotient
Christian Urban <urbanc@in.tum.de>
parents: 2330
diff changeset
  1326
text {* Peter *}
d7dfe272b4f8 some test with quotient
Christian Urban <urbanc@in.tum.de>
parents: 2330
diff changeset
  1327
lemma test: "equivp R ==> a = b --> R a b"
d7dfe272b4f8 some test with quotient
Christian Urban <urbanc@in.tum.de>
parents: 2330
diff changeset
  1328
by (simp add: equivp_def)
d7dfe272b4f8 some test with quotient
Christian Urban <urbanc@in.tum.de>
parents: 2330
diff changeset
  1329
d7dfe272b4f8 some test with quotient
Christian Urban <urbanc@in.tum.de>
parents: 2330
diff changeset
  1330
lemma 
d7dfe272b4f8 some test with quotient
Christian Urban <urbanc@in.tum.de>
parents: 2330
diff changeset
  1331
  shows "fconcat {||} = {||}"
d7dfe272b4f8 some test with quotient
Christian Urban <urbanc@in.tum.de>
parents: 2330
diff changeset
  1332
apply(lifting_setup concat.simps(1))
d7dfe272b4f8 some test with quotient
Christian Urban <urbanc@in.tum.de>
parents: 2330
diff changeset
  1333
apply(rule test)
d7dfe272b4f8 some test with quotient
Christian Urban <urbanc@in.tum.de>
parents: 2330
diff changeset
  1334
apply(tactic {* resolve_tac (Quotient_Info.equiv_rules_get @{context}) 1 *})
2371
86c73a06ba4b minor things on the paper
Christian Urban <urbanc@in.tum.de>
parents: 2368
diff changeset
  1335
2368
d7dfe272b4f8 some test with quotient
Christian Urban <urbanc@in.tum.de>
parents: 2330
diff changeset
  1336
sorry
d7dfe272b4f8 some test with quotient
Christian Urban <urbanc@in.tum.de>
parents: 2330
diff changeset
  1337
1935
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
  1338
lemma fconcat_insert:
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
  1339
  shows "fconcat (finsert x S) = x |\<union>| fconcat S"
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
  1340
  by (lifting concat.simps(2))
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
  1341
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
  1342
lemma "fconcat (xs |\<union>| ys) = fconcat xs |\<union>| fconcat ys"
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
  1343
  by (lifting concat_append)
266abc3ee228 Moved working Fset3 properties to FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1927
diff changeset
  1344
2084
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1345
text {* ffilter *}
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1346
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1347
lemma subseteq_filter: "ffilter P xs <= ffilter Q xs = (\<forall> x. x |\<in>| xs \<longrightarrow> P x \<longrightarrow> Q x)"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1348
by (lifting sub_list_filter)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1349
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1350
lemma eq_ffilter: "(ffilter P xs = ffilter Q xs) = (\<forall>x. x |\<in>| xs \<longrightarrow> P x = Q x)"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1351
by (lifting list_eq_filter)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1352
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1353
lemma subset_ffilter: "(\<And>x. x |\<in>| xs \<Longrightarrow> P x \<Longrightarrow> Q x) \<Longrightarrow> (x |\<in>| xs & \<not> P x & Q x) \<Longrightarrow> ffilter P xs < ffilter Q xs"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1354
unfolding less_fset by (auto simp add: subseteq_filter eq_ffilter)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1355
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1356
section {* lemmas transferred from Finite_Set theory *}
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1357
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1358
text {* finiteness for finite sets holds *}
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1359
lemma finite_fset: "finite (fset_to_set S)"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1360
  by (induct S) auto
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1361
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1362
lemma fset_choice: "\<forall>x. x |\<in>| A \<longrightarrow> (\<exists>y. P x y) \<Longrightarrow> \<exists>f. \<forall>x. x |\<in>| A \<longrightarrow> P x (f x)"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1363
  unfolding fset_to_set_trans
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1364
  by (rule finite_set_choice[simplified Ball_def, OF finite_fset])
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1365
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1366
lemma fsubseteq_fnil: "xs |\<subseteq>| {||} = (xs = {||})"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1367
  unfolding fset_to_set_trans
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1368
  by (rule subset_empty)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1369
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1370
lemma not_fsubset_fnil: "\<not> xs |\<subset>| {||}"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1371
  unfolding fset_to_set_trans
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1372
  by (rule not_psubset_empty)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1373
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1374
lemma fcard_mono: "xs |\<subseteq>| ys \<Longrightarrow> fcard xs \<le> fcard ys"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1375
  unfolding fset_to_set_trans
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1376
  by (rule card_mono[OF finite_fset])
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1377
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1378
lemma fcard_fseteq: "xs |\<subseteq>| ys \<Longrightarrow> fcard ys \<le> fcard xs \<Longrightarrow> xs = ys"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1379
  unfolding fset_to_set_trans
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1380
  by (rule card_seteq[OF finite_fset])
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1381
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1382
lemma psubset_fcard_mono: "xs |\<subset>| ys \<Longrightarrow> fcard xs < fcard ys"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1383
  unfolding fset_to_set_trans
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1384
  by (rule psubset_card_mono[OF finite_fset])
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1385
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1386
lemma fcard_funion_finter: "fcard xs + fcard ys = fcard (xs |\<union>| ys) + fcard (xs |\<inter>| ys)"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1387
  unfolding fset_to_set_trans
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1388
  by (rule card_Un_Int[OF finite_fset finite_fset])
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1389
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1390
lemma fcard_funion_disjoint: "xs |\<inter>| ys = {||} \<Longrightarrow> fcard (xs |\<union>| ys) = fcard xs + fcard ys"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1391
  unfolding fset_to_set_trans
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1392
  by (rule card_Un_disjoint[OF finite_fset finite_fset])
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1393
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1394
lemma fcard_delete1_less: "x |\<in>| xs \<Longrightarrow> fcard (fdelete xs x) < fcard xs"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1395
  unfolding fset_to_set_trans
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1396
  by (rule card_Diff1_less[OF finite_fset])
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1397
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1398
lemma fcard_delete2_less: "x |\<in>| xs \<Longrightarrow> y |\<in>| xs \<Longrightarrow> fcard (fdelete (fdelete xs x) y) < fcard xs"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1399
  unfolding fset_to_set_trans
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1400
  by (rule card_Diff2_less[OF finite_fset])
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1401
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1402
lemma fcard_delete1_le: "fcard (fdelete xs x) <= fcard xs"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1403
  unfolding fset_to_set_trans
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1404
  by (rule card_Diff1_le[OF finite_fset])
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1405
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1406
lemma fcard_psubset: "ys |\<subseteq>| xs \<Longrightarrow> fcard ys < fcard xs \<Longrightarrow> ys |\<subset>| xs"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1407
  unfolding fset_to_set_trans
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1408
  by (rule card_psubset[OF finite_fset])
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1409
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1410
lemma fcard_fmap_le: "fcard (fmap f xs) \<le> fcard xs"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1411
  unfolding fset_to_set_trans
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1412
  by (rule card_image_le[OF finite_fset])
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1413
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1414
lemma fin_fminus_fnotin: "x |\<in>| F - S \<Longrightarrow> x |\<notin>| S"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1415
  unfolding fset_to_set_trans
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1416
  by blast
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1417
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1418
lemma fin_fnotin_fminus: "x |\<in>| S \<Longrightarrow> x |\<notin>| F - S"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1419
  unfolding fset_to_set_trans
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1420
  by blast
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1421
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1422
lemma fin_mdef: "x |\<in>| F = ((x |\<notin>| (F - {|x|})) & (F = finsert x (F - {|x|})))"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1423
  unfolding fset_to_set_trans
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1424
  by blast
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1425
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1426
lemma fcard_fminus_finsert[simp]:
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1427
  assumes "a |\<in>| A" and "a |\<notin>| B"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1428
  shows "fcard(A - finsert a B) = fcard(A - B) - 1"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1429
  using assms unfolding fset_to_set_trans
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1430
  by (rule card_Diff_insert[OF finite_fset])
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1431
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1432
lemma fcard_fminus_fsubset:
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1433
  assumes "B |\<subseteq>| A"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1434
  shows "fcard (A - B) = fcard A - fcard B"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1435
  using assms unfolding fset_to_set_trans
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1436
  by (rule card_Diff_subset[OF finite_fset])
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1437
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1438
lemma fcard_fminus_subset_finter:
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1439
  "fcard (A - B) = fcard A - fcard (A |\<inter>| B)"
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1440
  unfolding fset_to_set_trans
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1441
  by (rule card_Diff_subset_Int) (fold inter_set, rule finite_fset)
72b777cc5479 Synchronize FSet with repository
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1952
diff changeset
  1442
2249
1476c26d4310 qpaper/unfold the ball_reg_right statement
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2238
diff changeset
  1443
lemma ball_reg_right_unfolded: "(\<forall>x. R x \<longrightarrow> P x \<longrightarrow> Q x) \<longrightarrow> (All P \<longrightarrow> Ball R Q)"
1476c26d4310 qpaper/unfold the ball_reg_right statement
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2238
diff changeset
  1444
apply rule
1476c26d4310 qpaper/unfold the ball_reg_right statement
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2238
diff changeset
  1445
apply (rule ball_reg_right)
1476c26d4310 qpaper/unfold the ball_reg_right statement
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2238
diff changeset
  1446
apply auto
1476c26d4310 qpaper/unfold the ball_reg_right statement
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2238
diff changeset
  1447
done
2234
8035515bbbc6 something about the quotient ype definitions
Christian Urban <urbanc@in.tum.de>
parents: 2222
diff changeset
  1448
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
  1449
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
  1450
  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
  1451
  shows "(list_all2 R) r r"
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
  1452
  by (rule list_all2_refl) (metis equivp_def fset_equivp q)
2266
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1453
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1454
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
  1455
  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
  1456
  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
  1457
proof
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1458
  have *: "r \<approx> r" by (rule equivp_reflp[OF fset_equivp])
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
  1459
  show "list_all2 R r r" by (rule list_all2_refl[OF q])
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
  1460
  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
  1461
qed
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1462
2285
965ee8f08d4c eliminated a quot_thm flag
Christian Urban <urbanc@in.tum.de>
parents: 2278
diff changeset
  1463
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
  1464
  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
  1465
  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
  1466
  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
  1467
    (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
  1468
  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
  1469
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
  1470
  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
  1471
  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
  1472
    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
  1473
  have b: "list_all2 R (map Rep (rep_fset a)) (map Rep (rep_fset a))"
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
  1474
    by (rule list_all2_refl[OF e])
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
  1475
  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
  1476
    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
  1477
  show "(list_all2 R OOO op \<approx>) (map Rep (rep_fset a)) (map Rep (rep_fset a))"
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
  1478
    by (rule, rule list_all2_refl[OF e]) (rule c)
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
  1479
  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
  1480
        (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
  1481
  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
  1482
    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
  1483
    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
  1484
  next
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
  1485
    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
  1486
    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
  1487
    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
  1488
      fix b ba
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
  1489
      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
  1490
      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
  1491
      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
  1492
      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
  1493
        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
  1494
      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
  1495
        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
  1496
      then have g: "map Abs s = map Abs ba" by simp
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1497
      then show "map Abs r \<approx> map Abs s" using d f map_rel_cong by simp
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1498
    qed
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1499
    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
  1500
      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
  1501
  next
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
  1502
    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
  1503
      \<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
  1504
    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
  1505
    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
  1506
      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
  1507
    have b: "map Rep (map Abs r) \<approx> map Rep (map Abs s)"
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1508
      by (rule map_rel_cong[OF d])
2326
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
  1509
    have y: "list_all2 R (map Rep (map Abs s)) s"
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
  1510
      by (fact rep_abs_rsp_left[OF list_quotient[OF q], OF list_all2_refl[OF e, of s]])
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
  1511
    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
  1512
      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
  1513
    have z: "list_all2 R r (map Rep (map Abs r))"
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
  1514
      by (fact rep_abs_rsp[OF list_quotient[OF q], OF list_all2_refl[OF e, of r]])
b51532dd5689 Changes for PER and list_all2 committed to Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2278
diff changeset
  1515
    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
  1516
      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
  1517
  qed
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1518
qed
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1519
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1520
no_notation
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1521
  list_eq (infix "\<approx>" 50)
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1522
dcffc2f132c9 Qpaper / Clarify the typing system and composition of quotients issue.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2250
diff changeset
  1523
2234
8035515bbbc6 something about the quotient ype definitions
Christian Urban <urbanc@in.tum.de>
parents: 2222
diff changeset
  1524
end