Quot/Examples/FSet2.thy
author Christian Urban <urbanc@in.tum.de>
Sun, 20 Dec 2009 00:26:53 +0100
changeset 766 df053507edba
parent 705 f51c6069cd17
child 767 37285ec4387d
permissions -rw-r--r--
renamed "quotient" command to "quotient_type"; needs new keyword file to be installed
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
684
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
theory FSet2
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
imports "../QuotMain" List
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
begin
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
inductive
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
  list_eq (infix "\<approx>" 50)
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
where
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
  "a#b#xs \<approx> b#a#xs"
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
| "[] \<approx> []"
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
| "xs \<approx> ys \<Longrightarrow> ys \<approx> xs"
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
| "a#a#xs \<approx> a#xs"
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
| "xs \<approx> ys \<Longrightarrow> a#xs \<approx> a#ys"
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
| "\<lbrakk>xs1 \<approx> xs2; xs2 \<approx> xs3\<rbrakk> \<Longrightarrow> xs1 \<approx> xs3"
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
lemma list_eq_refl:
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
  shows "xs \<approx> xs"
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
by (induct xs) (auto intro: list_eq.intros)
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
lemma equivp_list_eq:
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
  shows "equivp list_eq"
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
unfolding equivp_reflp_symp_transp reflp_def symp_def transp_def
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
by (auto intro: list_eq.intros list_eq_refl)
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    23
766
df053507edba renamed "quotient" command to "quotient_type"; needs new keyword file to be installed
Christian Urban <urbanc@in.tum.de>
parents: 705
diff changeset
    24
quotient_type fset = "'a list" / "list_eq"
684
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
  by (rule equivp_list_eq)
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    26
705
f51c6069cd17 New syntax for definitions.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 684
diff changeset
    27
quotient_def
f51c6069cd17 New syntax for definitions.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 684
diff changeset
    28
  "fempty :: 'a fset" ("{||}")
f51c6069cd17 New syntax for definitions.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 684
diff changeset
    29
as
684
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    30
  "[]"
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    31
705
f51c6069cd17 New syntax for definitions.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 684
diff changeset
    32
quotient_def
f51c6069cd17 New syntax for definitions.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 684
diff changeset
    33
  "finsert :: 'a \<Rightarrow> 'a fset \<Rightarrow> 'a fset"
f51c6069cd17 New syntax for definitions.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 684
diff changeset
    34
as
684
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    35
  "(op #)"
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    36
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    37
lemma finsert_rsp[quot_respect]:
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    38
  shows "(op = ===> op \<approx> ===> op \<approx>) (op #) (op #)"
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    39
by (auto intro: list_eq.intros)
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    40
705
f51c6069cd17 New syntax for definitions.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 684
diff changeset
    41
quotient_def
f51c6069cd17 New syntax for definitions.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 684
diff changeset
    42
  "funion :: 'a fset \<Rightarrow> 'a fset \<Rightarrow> 'a fset" ("_ \<union>f _" [65,66] 65)
f51c6069cd17 New syntax for definitions.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 684
diff changeset
    43
as
684
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    44
  "(op @)"
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    45
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    46
lemma append_rsp_aux1:
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    47
  assumes a : "l2 \<approx> r2 "
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    48
  shows "(h @ l2) \<approx> (h @ r2)"
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    49
using a
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    50
apply(induct h)
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    51
apply(auto intro: list_eq.intros(5))
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    52
done
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    53
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    54
lemma append_rsp_aux2:
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    55
  assumes a : "l1 \<approx> r1" "l2 \<approx> r2 "
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    56
  shows "(l1 @ l2) \<approx> (r1 @ r2)"
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    57
using a
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    58
apply(induct arbitrary: l2 r2)
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    59
apply(simp_all)
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    60
apply(blast intro: list_eq.intros append_rsp_aux1)+
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    61
done
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    62
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    63
lemma append_rsp[quot_respect]:
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    64
  shows "(op \<approx> ===> op \<approx> ===> op \<approx>) op @ op @"
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    65
  by (auto simp add: append_rsp_aux2)
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    66
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    67
705
f51c6069cd17 New syntax for definitions.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 684
diff changeset
    68
quotient_def
f51c6069cd17 New syntax for definitions.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 684
diff changeset
    69
  "fmem :: 'a \<Rightarrow> 'a fset \<Rightarrow> bool" ("_ \<in>f _" [50, 51] 50)
f51c6069cd17 New syntax for definitions.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 684
diff changeset
    70
as
684
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    71
  "(op mem)"
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    72
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    73
lemma memb_rsp_aux:
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    74
  assumes a: "x \<approx> y"
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    75
  shows "(z mem x) = (z mem y)"
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    76
  using a by induct auto
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    77
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    78
lemma memb_rsp[quot_respect]:
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    79
  shows "(op = ===> (op \<approx> ===> op =)) (op mem) (op mem)"
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    80
  by (simp add: memb_rsp_aux)
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    81
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    82
definition 
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    83
  fnot_mem :: "'a \<Rightarrow> 'a fset \<Rightarrow> bool" ("_ \<notin>f _" [50, 51] 50)
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    84
where
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    85
  "x \<notin>f S \<equiv> \<not>(x \<in>f S)"
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    86
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    87
definition
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    88
  "inter_list" :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a list"
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    89
where
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    90
  "inter_list X Y \<equiv> [x \<leftarrow> X. x\<in>set Y]"
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    91
705
f51c6069cd17 New syntax for definitions.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 684
diff changeset
    92
quotient_def
f51c6069cd17 New syntax for definitions.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 684
diff changeset
    93
  "finter::'a fset \<Rightarrow> 'a fset \<Rightarrow> 'a fset" ("_ \<inter>f _" [70, 71] 70)
f51c6069cd17 New syntax for definitions.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 684
diff changeset
    94
as
684
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    95
  "inter_list"
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    96
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    97
no_syntax
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    98
  "@Finset"     :: "args => 'a fset"                       ("{|(_)|}")
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    99
syntax
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   100
  "@Finfset"     :: "args => 'a fset"                       ("{|(_)|}")
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   101
translations
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   102
  "{|x, xs|}"     == "CONST finsert x {|xs|}"
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   103
  "{|x|}"         == "CONST finsert x {||}"
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   104
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   105
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   106
subsection {* Empty sets *}
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   107
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   108
lemma test:
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   109
  shows "\<not>(x # xs \<approx> [])"
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   110
sorry
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   111
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   112
lemma finsert_not_empty[simp]: 
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   113
  shows "finsert x S \<noteq> {||}"
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   114
  by (lifting test)
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   115
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   116
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   117
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   118
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   119
end;