Nominal/FSet.thy
author Cezary Kaliszyk <kaliszyk@in.tum.de>
Wed, 14 Apr 2010 08:36:54 +0200
changeset 1825 1d6a0aeef4a1
parent 1824 2ccc1b00377c
child 1826 faa7e6033f2e
permissions -rw-r--r--
merge part: delete_rsp
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1823
91ba55dba5e0 added header and more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1822
diff changeset
     1
(*  Title:      Quotient.thy
91ba55dba5e0 added header and more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1822
diff changeset
     2
    Author:     Cezary Kaliszyk 
91ba55dba5e0 added header and more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1822
diff changeset
     3
    Author:     Christian Urban
91ba55dba5e0 added header and more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1822
diff changeset
     4
91ba55dba5e0 added header and more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1822
diff changeset
     5
    provides a reasoning infrastructure for the type of finite sets
91ba55dba5e0 added header and more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1822
diff changeset
     6
*)
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     7
theory FSet
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     8
imports Quotient Quotient_List List
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     9
begin
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    10
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    11
fun
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    12
  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
    13
where
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    14
  "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
    15
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    16
lemma list_eq_equivp:
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    17
  shows "equivp list_eq"
1823
91ba55dba5e0 added header and more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1822
diff changeset
    18
unfolding equivp_reflp_symp_transp 
91ba55dba5e0 added header and more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1822
diff changeset
    19
unfolding reflp_def symp_def transp_def
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    20
by auto
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    21
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    22
quotient_type
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    23
  'a fset = "'a list" / "list_eq"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    24
by (rule list_eq_equivp)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    25
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    26
section {* empty fset, finsert and membership *}
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    27
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    28
quotient_definition
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    29
  fempty  ("{||}")
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    30
where
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    31
  "fempty :: 'a fset"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    32
is "[]::'a list"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    33
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    34
quotient_definition
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    35
  "finsert :: 'a \<Rightarrow> 'a fset \<Rightarrow> 'a fset" 
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    36
is "op #"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    37
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    38
syntax
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    39
  "@Finset"     :: "args => 'a fset"  ("{|(_)|}")
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    40
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    41
translations
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    42
  "{|x, xs|}" == "CONST finsert x {|xs|}"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    43
  "{|x|}"     == "CONST finsert x {||}"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    44
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    45
definition
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    46
  memb :: "'a \<Rightarrow> 'a list \<Rightarrow> bool"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    47
where
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    48
  "memb x xs \<equiv> x \<in> set xs"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    49
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    50
quotient_definition
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    51
  fin ("_ |\<in>| _" [50, 51] 50)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    52
where
1816
56cebe7f8e24 some small tunings (incompleted work in Lambda.thy)
Christian Urban <urbanc@in.tum.de>
parents: 1682
diff changeset
    53
  "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
    54
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    55
abbreviation
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    56
  fnotin :: "'a \<Rightarrow> 'a fset \<Rightarrow> bool" ("_ |\<notin>| _" [50, 51] 50)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    57
where
1823
91ba55dba5e0 added header and more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1822
diff changeset
    58
  "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
    59
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    60
lemma memb_rsp[quot_respect]:
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    61
  shows "(op = ===> op \<approx> ===> op =) memb memb"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    62
by (auto simp add: memb_def)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    63
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    64
lemma nil_rsp[quot_respect]:
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    65
  shows "[] \<approx> []"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    66
by simp
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    67
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    68
lemma cons_rsp[quot_respect]:
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    69
  shows "(op = ===> op \<approx> ===> op \<approx>) op # op #"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    70
by simp
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    71
1816
56cebe7f8e24 some small tunings (incompleted work in Lambda.thy)
Christian Urban <urbanc@in.tum.de>
parents: 1682
diff changeset
    72
section {* Augmenting an fset -- @{const finsert} *}
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    73
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    74
lemma nil_not_cons:
1533
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
    75
  shows
1823
91ba55dba5e0 added header and more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1822
diff changeset
    76
  "\<not> ([] \<approx> x # xs)"
91ba55dba5e0 added header and more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1822
diff changeset
    77
  "\<not> (x # xs \<approx> [])"
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    78
  by auto
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    79
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
    80
lemma not_memb_nil:
1823
91ba55dba5e0 added header and more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1822
diff changeset
    81
  "\<not> memb x []"
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
    82
  by (simp add: memb_def)
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
    83
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    84
lemma memb_cons_iff:
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    85
  shows "memb x (y # xs) = (x = y \<or> memb x xs)"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    86
  by (induct xs) (auto simp add: memb_def)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    87
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    88
lemma memb_consI1:
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    89
  shows "memb x (x # xs)"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    90
  by (simp add: memb_def)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    91
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    92
lemma memb_consI2:
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    93
  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
    94
  by (simp add: memb_def)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    95
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    96
lemma memb_absorb:
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    97
  shows "memb x xs \<Longrightarrow> x # xs \<approx> xs"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    98
  by (induct xs) (auto simp add: memb_def id_simps)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    99
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   100
section {* Singletons *}
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   101
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   102
lemma singleton_list_eq:
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   103
  shows "[x] \<approx> [y] \<longleftrightarrow> x = y"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   104
  by (simp add: id_simps) auto
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   105
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   106
section {* Union *}
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   107
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   108
quotient_definition
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   109
  funion  (infixl "|\<union>|" 65)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   110
where
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   111
  "funion :: 'a fset \<Rightarrow> 'a fset \<Rightarrow> 'a fset"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   112
is
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   113
  "op @"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   114
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   115
section {* Cardinality of finite sets *}
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   116
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   117
fun
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   118
  fcard_raw :: "'a list \<Rightarrow> nat"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   119
where
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   120
  fcard_raw_nil:  "fcard_raw [] = 0"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   121
| fcard_raw_cons: "fcard_raw (x # xs) = (if memb x xs then fcard_raw xs else Suc (fcard_raw xs))"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   122
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   123
quotient_definition
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   124
  "fcard :: 'a fset \<Rightarrow> nat" 
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   125
is
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   126
  "fcard_raw"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   127
1813
69fff336dd18 Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1682
diff changeset
   128
lemma fcard_raw_0:
1821
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   129
  fixes xs :: "'a list"
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   130
  shows "(fcard_raw xs = 0) = (xs \<approx> [])"
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   131
  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
   132
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   133
lemma fcard_raw_gt_0:
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   134
  assumes a: "x \<in> set xs"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   135
  shows "0 < fcard_raw xs"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   136
  using a
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   137
  by (induct xs) (auto simp add: memb_def)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   138
1813
69fff336dd18 Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1682
diff changeset
   139
lemma fcard_raw_not_memb:
69fff336dd18 Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1682
diff changeset
   140
  fixes x :: "'a"
1823
91ba55dba5e0 added header and more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1822
diff changeset
   141
  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
   142
  by auto
69fff336dd18 Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1682
diff changeset
   143
69fff336dd18 Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1682
diff changeset
   144
lemma fcard_raw_suc:
69fff336dd18 Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1682
diff changeset
   145
  fixes xs :: "'a list"
69fff336dd18 Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1682
diff changeset
   146
  assumes c: "fcard_raw xs = Suc n"
1821
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   147
  shows "\<exists>x ys. \<not>(memb x ys) \<and> xs \<approx> (x # ys) \<and> fcard_raw ys = n"
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   148
  unfolding memb_def
1813
69fff336dd18 Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1682
diff changeset
   149
  using c
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   150
  proof (induct xs)
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   151
    case Nil
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   152
    then show ?case by simp
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   153
  next
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   154
    case (Cons a xs)
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   155
    have f1: "fcard_raw xs = Suc n \<Longrightarrow> \<exists>a ys. a \<notin> set ys \<and> xs \<approx> a # ys \<and> fcard_raw ys = n" by fact
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   156
    have f2: "fcard_raw (a # xs) = Suc n" by fact
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   157
    then show ?case proof (cases "a \<in> set xs")
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   158
      case True
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   159
      then show ?thesis using f1 f2 apply -
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   160
        apply (simp add: memb_def)
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   161
        apply clarify
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   162
        by metis
1820
de28a91eaca3 Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1819
diff changeset
   163
    next
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   164
      case False
1820
de28a91eaca3 Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1819
diff changeset
   165
      then show ?thesis using f1 f2 apply -
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   166
        apply (rule_tac x="a" in exI)
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   167
        apply (rule_tac x="xs" in exI)
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   168
        apply (simp add: memb_def)
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   169
        done
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   170
    qed
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   171
  qed
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   172
1821
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   173
lemma singleton_fcard_1: 
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   174
  shows "set xs = {x} \<Longrightarrow> fcard_raw xs = Suc 0"
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   175
  apply (induct xs)
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   176
  apply simp_all
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   177
  apply auto
1821
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   178
  apply (subgoal_tac "set xs = {x}")
1813
69fff336dd18 Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1682
diff changeset
   179
  apply simp
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   180
  apply (simp add: memb_def)
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   181
  apply auto
1821
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   182
  apply (subgoal_tac "set xs = {}")
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   183
  apply simp
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   184
  by (metis memb_def subset_empty subset_insert)
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   185
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   186
lemma fcard_raw_1:
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   187
  fixes a :: "'a list"
1823
91ba55dba5e0 added header and more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1822
diff changeset
   188
  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
   189
  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
   190
  apply (simp add: fcard_raw_0)
1821
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   191
  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
   192
  apply simp
1821
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   193
  apply (subgoal_tac "set xs = {x}")
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   194
  apply (erule singleton_fcard_1)
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   195
  apply auto
1813
69fff336dd18 Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1682
diff changeset
   196
  done
69fff336dd18 Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1682
diff changeset
   197
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   198
lemma fcard_raw_delete_one:
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   199
  "fcard_raw ([x \<leftarrow> xs. x \<noteq> y]) = (if memb y xs then fcard_raw xs - 1 else fcard_raw xs)"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   200
  by (induct xs) (auto dest: fcard_raw_gt_0 simp add: memb_def)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   201
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   202
lemma fcard_raw_rsp_aux:
1821
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   203
  assumes a: "xs \<approx> ys"
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   204
  shows "fcard_raw xs = fcard_raw ys"
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   205
  using a
1821
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   206
  apply(induct xs arbitrary: ys)
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   207
  apply(auto simp add: memb_def)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   208
  apply(metis)
1821
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   209
  apply(drule_tac x="[x \<leftarrow> ys. x \<noteq> a]" in meta_spec)
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   210
  apply(simp add: fcard_raw_delete_one)
1533
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   211
  apply(metis Suc_pred'[OF fcard_raw_gt_0] fcard_raw_delete_one memb_def)
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   212
  done
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   213
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   214
lemma fcard_raw_rsp[quot_respect]:
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   215
  "(op \<approx> ===> op =) fcard_raw fcard_raw"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   216
  by (simp add: fcard_raw_rsp_aux)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   217
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   218
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   219
section {* fmap and fset comprehension *}
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   220
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   221
quotient_definition
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   222
  "fmap :: ('a \<Rightarrow> 'b) \<Rightarrow> 'a fset \<Rightarrow> 'b fset"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   223
is
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   224
 "map"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   225
1813
69fff336dd18 Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1682
diff changeset
   226
lemma map_append:
1821
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   227
  "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
   228
  by simp
69fff336dd18 Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1682
diff changeset
   229
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   230
lemma memb_append:
1823
91ba55dba5e0 added header and more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1822
diff changeset
   231
  "memb x (xs @ ys) \<longleftrightarrow> memb x xs \<or> memb x ys"
1821
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   232
  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
   233
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   234
text {* raw section *}
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   235
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   236
lemma map_rsp[quot_respect]:
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   237
  shows "(op = ===> op \<approx> ===> op \<approx>) map map"
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
   238
  by auto
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   239
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   240
lemma cons_left_comm:
1821
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   241
  "x # y # xs \<approx> y # x # xs"
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   242
  by auto
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   243
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   244
lemma cons_left_idem:
1821
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   245
  "x # x # xs \<approx> x # xs"
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   246
  by auto
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   247
1824
2ccc1b00377c merge part1: none_memb_nil
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1823
diff changeset
   248
lemma none_memb_nil:
2ccc1b00377c merge part1: none_memb_nil
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1823
diff changeset
   249
  "(\<forall>x. \<not> memb x xs) = (xs \<approx> [])"
2ccc1b00377c merge part1: none_memb_nil
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1823
diff changeset
   250
  by (simp add: memb_def)
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   251
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   252
lemma fset_raw_strong_cases:
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
   253
  "(xs = []) \<or> (\<exists>x ys. ((\<not> memb x ys) \<and> (xs \<approx> x # ys)))"
1821
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   254
  apply (induct xs)
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   255
  apply (simp)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   256
  apply (rule disjI2)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   257
  apply (erule disjE)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   258
  apply (rule_tac x="a" in exI)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   259
  apply (rule_tac x="[]" in exI)
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
   260
  apply (simp add: memb_def)
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   261
  apply (erule exE)+
1821
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   262
  apply (case_tac "x = a")
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   263
  apply (rule_tac x="a" in exI)
1821
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   264
  apply (rule_tac x="ys" in exI)
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   265
  apply (simp)
1821
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   266
  apply (rule_tac x="x" in exI)
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   267
  apply (rule_tac x="a # ys" in exI)
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
   268
  apply (auto simp add: memb_def)
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   269
  done
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   270
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   271
fun
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   272
  delete_raw :: "'a list \<Rightarrow> 'a \<Rightarrow> 'a list"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   273
where
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   274
  "delete_raw [] x = []"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   275
| "delete_raw (a # A) x = (if (a = x) then delete_raw A x else a # (delete_raw A x))"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   276
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   277
lemma memb_delete_raw:
1821
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   278
  "memb x (delete_raw xs y) = (memb x xs \<and> x \<noteq> y)"
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   279
  by (induct xs arbitrary: x y) (auto simp add: memb_def)
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   280
1825
1d6a0aeef4a1 merge part: delete_rsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1824
diff changeset
   281
lemma delete_raw_rsp:
1d6a0aeef4a1 merge part: delete_rsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1824
diff changeset
   282
  "l \<approx> r \<Longrightarrow> delete_raw l x \<approx> delete_raw r x"
1d6a0aeef4a1 merge part: delete_rsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1824
diff changeset
   283
  by (simp add: memb_def[symmetric] memb_delete_raw)
1d6a0aeef4a1 merge part: delete_rsp
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1824
diff changeset
   284
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   285
lemma [quot_respect]:
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   286
  "(op \<approx> ===> op = ===> op \<approx>) delete_raw delete_raw"
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   287
  by (simp add: memb_def[symmetric] memb_delete_raw)
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   288
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   289
lemma memb_delete_raw_ident:
1821
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   290
  "\<not> memb x (delete_raw xs x)"
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   291
  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
   292
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   293
lemma not_memb_delete_raw_ident:
1821
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   294
  "\<not> memb x xs \<Longrightarrow> delete_raw xs x = xs"
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   295
  by (induct xs) (auto simp add: memb_def)
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   296
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   297
lemma fset_raw_delete_raw_cases:
1821
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   298
  "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
   299
  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
   300
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   301
lemma fdelete_raw_filter:
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   302
  "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
   303
  by (induct xs) simp_all
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   304
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   305
lemma fcard_raw_delete:
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   306
  "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
   307
  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
   308
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   309
lemma set_rsp[quot_respect]:
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   310
  "(op \<approx> ===> op =) set set"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   311
  by auto
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   312
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   313
definition
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   314
  rsp_fold
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   315
where
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   316
  "rsp_fold f = (\<forall>u v w. (f u (f v w) = f v (f u w)))"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   317
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   318
primrec
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   319
  ffold_raw :: "('a \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> 'b \<Rightarrow> 'a list \<Rightarrow> 'b"
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   320
where
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   321
  "ffold_raw f z [] = z"
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   322
| "ffold_raw f z (a # A) =
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   323
     (if (rsp_fold f) then
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   324
       if memb a A then ffold_raw f z A
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   325
       else f a (ffold_raw f z A)
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   326
     else z)"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   327
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   328
lemma memb_commute_ffold_raw:
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   329
  "rsp_fold f \<Longrightarrow> memb h b \<Longrightarrow> ffold_raw f z b = f h (ffold_raw f z (delete_raw b h))"
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   330
  apply (induct b)
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   331
  apply (simp add: not_memb_nil)
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   332
  apply (simp add: ffold_raw.simps)
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   333
  apply (rule conjI)
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   334
  apply (rule_tac [!] impI)
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   335
  apply (rule_tac [!] conjI)
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   336
  apply (rule_tac [!] impI)
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   337
  apply (simp_all add: memb_delete_raw)
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   338
  apply (simp add: memb_cons_iff)
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   339
  apply (simp add: not_memb_delete_raw_ident)
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   340
  apply (simp add: memb_cons_iff rsp_fold_def)
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   341
  done
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   342
1820
de28a91eaca3 Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1819
diff changeset
   343
lemma ffold_raw_rsp_pre:
de28a91eaca3 Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1819
diff changeset
   344
  "\<forall>e. memb e a = memb e b \<Longrightarrow> ffold_raw f z a = ffold_raw f z b"
de28a91eaca3 Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1819
diff changeset
   345
  apply (induct a arbitrary: b)
1824
2ccc1b00377c merge part1: none_memb_nil
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1823
diff changeset
   346
  apply (simp add: hd_in_set memb_absorb memb_def none_memb_nil)
1820
de28a91eaca3 Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1819
diff changeset
   347
  apply (simp add: ffold_raw.simps)
de28a91eaca3 Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1819
diff changeset
   348
  apply (rule conjI)
de28a91eaca3 Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1819
diff changeset
   349
  apply (rule_tac [!] impI)
de28a91eaca3 Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1819
diff changeset
   350
  apply (rule_tac [!] conjI)
de28a91eaca3 Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1819
diff changeset
   351
  apply (rule_tac [!] impI)
de28a91eaca3 Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1819
diff changeset
   352
  apply (simp add: in_set_code memb_cons_iff memb_def)
de28a91eaca3 Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1819
diff changeset
   353
  apply (metis)
1821
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   354
  apply (metis Nitpick.list_size_simp(2) ffold_raw.simps(2) 
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   355
    length_Suc_conv memb_absorb memb_cons_iff nil_not_cons(2))
1820
de28a91eaca3 Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1819
diff changeset
   356
  defer
1821
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   357
  apply (metis Nitpick.list_size_simp(2) ffold_raw.simps(2) 
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   358
    length_Suc_conv memb_absorb memb_cons_iff nil_not_cons(2))
1820
de28a91eaca3 Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1819
diff changeset
   359
  apply (subgoal_tac "ffold_raw f z b = f a1 (ffold_raw f z (delete_raw b a1))")
de28a91eaca3 Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1819
diff changeset
   360
  apply (simp only:)
de28a91eaca3 Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1819
diff changeset
   361
  apply (rule_tac f="f a1" in arg_cong)
de28a91eaca3 Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1819
diff changeset
   362
  apply (subgoal_tac "\<forall>e. memb e a2 = memb e (delete_raw b a1)")
de28a91eaca3 Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1819
diff changeset
   363
  apply simp
de28a91eaca3 Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1819
diff changeset
   364
  apply (simp add: memb_delete_raw)
de28a91eaca3 Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1819
diff changeset
   365
  apply (metis memb_cons_iff)
de28a91eaca3 Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1819
diff changeset
   366
  apply (erule memb_commute_ffold_raw)
de28a91eaca3 Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1819
diff changeset
   367
  apply (drule_tac x="a1" in spec)
de28a91eaca3 Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1819
diff changeset
   368
  apply (simp add: memb_cons_iff)
de28a91eaca3 Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1819
diff changeset
   369
  done
de28a91eaca3 Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1819
diff changeset
   370
de28a91eaca3 Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1819
diff changeset
   371
lemma [quot_respect]:
de28a91eaca3 Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1819
diff changeset
   372
  "(op = ===> op = ===> op \<approx> ===> op =) ffold_raw ffold_raw"
de28a91eaca3 Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1819
diff changeset
   373
  by (simp add: memb_def[symmetric] ffold_raw_rsp_pre)
de28a91eaca3 Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1819
diff changeset
   374
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   375
primrec
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   376
  finter_raw :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a list"
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   377
where
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   378
  "finter_raw [] l = []"
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   379
| "finter_raw (h # t) l =
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   380
     (if memb h l then h # (finter_raw t l) else finter_raw t l)"
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   381
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   382
lemma finter_raw_empty:
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   383
  "finter_raw l [] = []"
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   384
  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
   385
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   386
lemma memb_finter_raw:
1823
91ba55dba5e0 added header and more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1822
diff changeset
   387
  "memb x (finter_raw xs ys) \<longleftrightarrow> memb x xs \<and> memb x ys"
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
   388
  apply (induct xs)
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   389
  apply (simp add: not_memb_nil)
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   390
  apply (simp add: finter_raw.simps)
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   391
  apply (simp add: memb_cons_iff)
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   392
  apply auto
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   393
  done
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   394
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   395
lemma [quot_respect]:
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   396
  "(op \<approx> ===> op \<approx> ===> op \<approx>) finter_raw finter_raw"
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   397
  by (simp add: memb_def[symmetric] memb_finter_raw)
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   398
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   399
section {* Constants on the Quotient Type *} 
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   400
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   401
quotient_definition
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   402
  "fdelete :: 'a fset \<Rightarrow> 'a \<Rightarrow> 'a fset" 
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   403
  is "delete_raw"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   404
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   405
quotient_definition
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   406
  "fset_to_set :: 'a fset \<Rightarrow> 'a set" 
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   407
  is "set"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   408
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   409
quotient_definition
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   410
  "ffold :: ('a \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> 'b \<Rightarrow> 'a fset \<Rightarrow> 'b"
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   411
  is "ffold_raw"
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   412
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   413
quotient_definition
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   414
  finter (infix "|\<inter>|" 50)
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   415
where
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   416
  "finter :: 'a fset \<Rightarrow> 'a fset \<Rightarrow> 'a fset"
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   417
is "finter_raw"
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   418
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   419
lemma funion_sym_pre:
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
   420
  "xs @ ys \<approx> ys @ xs"
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   421
  by auto
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   422
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   423
lemma append_rsp[quot_respect]:
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   424
  shows "(op \<approx> ===> op \<approx> ===> op \<approx>) op @ op @"
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
   425
  by auto
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   426
1821
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   427
lemma set_cong: 
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   428
  shows "(set x = set y) = (x \<approx> y)"
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   429
  by auto
1533
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   430
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   431
lemma inj_map_eq_iff:
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   432
  "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
   433
  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
   434
1813
69fff336dd18 Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1682
diff changeset
   435
quotient_definition
69fff336dd18 Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1682
diff changeset
   436
  "fconcat :: ('a fset) fset \<Rightarrow> 'a fset"
69fff336dd18 Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1682
diff changeset
   437
is
69fff336dd18 Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1682
diff changeset
   438
  "concat"
1533
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   439
1813
69fff336dd18 Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1682
diff changeset
   440
lemma list_equiv_rsp[quot_respect]:
69fff336dd18 Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1682
diff changeset
   441
  shows "(op \<approx> ===> op \<approx> ===> op =) op \<approx> op \<approx>"
69fff336dd18 Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1682
diff changeset
   442
  by auto
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   443
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   444
section {* lifted part *}
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   445
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   446
lemma not_fin_fnil: "x |\<notin>| {||}"
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   447
  by (lifting not_memb_nil)
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   448
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   449
lemma fin_finsert_iff[simp]:
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   450
  "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
   451
  by (lifting memb_cons_iff)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   452
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   453
lemma
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   454
  shows finsertI1: "x |\<in>| finsert x S"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   455
  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
   456
  by (lifting memb_consI1, lifting memb_consI2)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   457
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   458
lemma finsert_absorb[simp]:
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   459
  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
   460
  by (lifting memb_absorb)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   461
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   462
lemma fempty_not_finsert[simp]:
1533
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   463
  "{||} \<noteq> finsert x S"
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   464
  "finsert x S \<noteq> {||}"
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   465
  by (lifting nil_not_cons)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   466
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   467
lemma finsert_left_comm:
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
   468
  "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
   469
  by (lifting cons_left_comm)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   470
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   471
lemma finsert_left_idem:
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
   472
  "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
   473
  by (lifting cons_left_idem)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   474
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   475
lemma fsingleton_eq[simp]:
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   476
  shows "{|x|} = {|y|} \<longleftrightarrow> x = y"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   477
  by (lifting singleton_list_eq)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   478
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   479
text {* fset_to_set *}
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   480
1533
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   481
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
   482
  "fset_to_set {||} = ({} :: 'a set)"
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   483
  "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
   484
  by (lifting set.simps)
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   485
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
   486
thm memb_def[symmetric, THEN meta_eq_to_obj_eq]
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
   487
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   488
lemma in_fset_to_set:
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
   489
  "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
   490
  by (lifting memb_def[symmetric])
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   491
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   492
lemma none_fin_fempty:
1824
2ccc1b00377c merge part1: none_memb_nil
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1823
diff changeset
   493
  "(\<forall>x. x |\<notin>| S) = (S = {||})"
2ccc1b00377c merge part1: none_memb_nil
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1823
diff changeset
   494
  by (lifting none_memb_nil)
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   495
1533
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   496
lemma fset_cong:
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
   497
  "(fset_to_set S = fset_to_set T) = (S = T)"
1533
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   498
  by (lifting set_cong)
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   499
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   500
text {* fcard *}
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   501
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   502
lemma fcard_fempty [simp]:
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   503
  shows "fcard {||} = 0"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   504
  by (lifting fcard_raw_nil)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   505
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   506
lemma fcard_finsert_if [simp]:
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   507
  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
   508
  by (lifting fcard_raw_cons)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   509
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
   510
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
   511
  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
   512
1821
Christian Urban <urbanc@in.tum.de>
parents: 1820
diff changeset
   513
lemma fcard_1:
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
   514
  fixes S::"'b fset"
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
   515
  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
   516
  by (lifting fcard_raw_1)
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   517
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
   518
lemma fcard_gt_0: "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
   519
  by (lifting fcard_raw_gt_0)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   520
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
   521
lemma fcard_not_fin: "(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
   522
  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
   523
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
   524
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
   525
  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
   526
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   527
lemma fcard_delete:
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
   528
  "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
   529
  by (lifting fcard_raw_delete)
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   530
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   531
text {* funion *}
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   532
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   533
lemma funion_simps[simp]:
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
   534
  "{||} |\<union>| S = S"
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
   535
  "finsert x S |\<union>| T = finsert x (S |\<union>| T)"
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   536
  by (lifting append.simps)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   537
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   538
lemma funion_sym:
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
   539
  "S |\<union>| T = T |\<union>| S"
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   540
  by (lifting funion_sym_pre)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   541
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   542
lemma funion_assoc:
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
   543
 "S |\<union>| T |\<union>| U = S |\<union>| (T |\<union>| U)"
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   544
  by (lifting append_assoc)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   545
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   546
section {* Induction and Cases rules for finite sets *}
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   547
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   548
lemma fset_strong_cases:
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
   549
  "S = {||} \<or> (\<exists>x T. x |\<notin>| T \<and> S = finsert x T)"
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   550
  by (lifting fset_raw_strong_cases)
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   551
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   552
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
   553
  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
   554
  by (lifting list.exhaust)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   555
1533
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   556
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
   557
  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
   558
  by (lifting list.induct)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   559
1533
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   560
lemma fset_induct[case_names fempty finsert, induct type: fset]:
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   561
  assumes prem1: "P {||}" 
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   562
  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
   563
  shows "P S"
1533
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   564
proof(induct S rule: fset_induct_weak)
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   565
  case fempty
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   566
  show "P {||}" by (rule prem1)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   567
next
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   568
  case (finsert x S)
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   569
  have asm: "P S" by fact
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   570
  show "P (finsert x S)"
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   571
  proof(cases "x |\<in>| S")
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   572
    case True
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   573
    have "x |\<in>| S" by fact
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   574
    then show "P (finsert x S)" using asm by simp
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   575
  next
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   576
    case False
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   577
    have "x |\<notin>| S" by fact
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   578
    then show "P (finsert x S)" using prem2 asm by simp
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   579
  qed
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   580
qed
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   581
1533
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   582
lemma fset_induct2:
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   583
  "P {||} {||} \<Longrightarrow>
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   584
  (\<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
   585
  (\<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
   586
  (\<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
   587
  P xsa ysa"
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   588
  apply (induct xsa arbitrary: ysa)
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   589
  apply (induct_tac x rule: fset_induct)
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   590
  apply simp_all
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   591
  apply (induct_tac xa rule: fset_induct)
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   592
  apply simp_all
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   593
  done
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   594
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   595
text {* fmap *}
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   596
1533
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   597
lemma fmap_simps[simp]:
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   598
  "fmap (f :: 'a \<Rightarrow> 'b) {||} = {||}"
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
   599
  "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
   600
  by (lifting map.simps)
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   601
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   602
lemma fmap_set_image:
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
   603
  "fset_to_set (fmap f S) = f ` (fset_to_set S)"
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
   604
  by (induct S) (simp_all)
1533
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   605
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   606
lemma inj_fmap_eq_iff:
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
   607
  "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
   608
  by (lifting inj_map_eq_iff)
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   609
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
   610
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
   611
  by (lifting map_append)
69fff336dd18 Porting lemmas from Quotient package FSet to new FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1682
diff changeset
   612
1819
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   613
lemma fin_funion:
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
   614
  "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
   615
  by (lifting memb_append)
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   616
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   617
text {* ffold *}
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   618
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   619
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
   620
  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
   621
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   622
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
   623
  (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
   624
  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
   625
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   626
lemma fin_commute_ffold:
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   627
  "\<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
   628
  by (lifting memb_commute_ffold_raw)
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   629
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   630
text {* fdelete *}
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   631
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
   632
lemma fin_fdelete: 
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
   633
  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
   634
  by (lifting memb_delete_raw)
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   635
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
   636
lemma fin_fdelete_ident: 
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
   637
  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
   638
  by (lifting memb_delete_raw_ident)
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   639
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
   640
lemma not_memb_fdelete_ident: 
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
   641
  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
   642
  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
   643
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   644
lemma fset_fdelete_cases:
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
   645
  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
   646
  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
   647
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   648
text {* inter *}
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   649
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
   650
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
   651
  by (lifting finter_raw.simps(1))
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   652
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
   653
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
   654
  by (lifting finter_raw_empty)
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   655
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   656
lemma finter_finsert:
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
   657
  "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
   658
  by (lifting finter_raw.simps(2))
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   659
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   660
lemma fin_finter:
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
   661
  "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
   662
  by (lifting memb_finter_raw)
63dd459dbc0d Much more in FSet (currently non-working)
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1817
diff changeset
   663
1820
de28a91eaca3 Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1819
diff changeset
   664
lemma expand_fset_eq:
1822
4465723e35e7 more tuning
Christian Urban <urbanc@in.tum.de>
parents: 1821
diff changeset
   665
  "(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
   666
  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
   667
de28a91eaca3 Working FSet with additional lemmas.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1819
diff changeset
   668
1533
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   669
ML {*
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   670
fun dest_fsetT (Type ("FSet.fset", [T])) = T
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   671
  | dest_fsetT T = raise TYPE ("dest_fsetT: fset type expected", [T], []);
5f5e99a11f66 A few more theorems in FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1518
diff changeset
   672
*}
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   673
1682
ae54ce4cde54 Remove list_eq notation.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1533
diff changeset
   674
no_notation
ae54ce4cde54 Remove list_eq notation.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1533
diff changeset
   675
  list_eq (infix "\<approx>" 50)
ae54ce4cde54 Remove list_eq notation.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1533
diff changeset
   676
1518
212629c90971 Added a cleaned version of FSet.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   677
end