Quot/Examples/FSet2.thy
author Cezary Kaliszyk <kaliszyk@in.tum.de>
Mon, 15 Feb 2010 12:15:14 +0100
changeset 1144 538daee762e6
parent 1139 c4001cda9da3
permissions -rw-r--r--
Added a binding to the parser.
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
1128
17ca92ab4660 Main renaming + fixes for new Isabelle in IntEx2.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 787
diff changeset
     2
imports "../Quotient" "../Quotient_List" List
684
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
1144
538daee762e6 Added a binding to the parser.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1139
diff changeset
    24
quotient_type
787
5cf83fa5b36c made the quotient_type definition more like typedef; now type variables need to be explicitly given
Christian Urban <urbanc@in.tum.de>
parents: 768
diff changeset
    25
  'a 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
    26
  by (rule equivp_list_eq)
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    27
767
37285ec4387d on suggestion of Tobias renamed "quotient_def" to "quotient_definition"; needs new keyword file
Christian Urban <urbanc@in.tum.de>
parents: 766
diff changeset
    28
quotient_definition
1144
538daee762e6 Added a binding to the parser.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1139
diff changeset
    29
  fempty ("{||}")
538daee762e6 Added a binding to the parser.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1139
diff changeset
    30
where
538daee762e6 Added a binding to the parser.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1139
diff changeset
    31
  "fempty :: 'a fset"
1139
c4001cda9da3 renamed 'as' to 'is' everywhere.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1128
diff changeset
    32
is
684
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    33
  "[]"
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    34
767
37285ec4387d on suggestion of Tobias renamed "quotient_def" to "quotient_definition"; needs new keyword file
Christian Urban <urbanc@in.tum.de>
parents: 766
diff changeset
    35
quotient_definition
705
f51c6069cd17 New syntax for definitions.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 684
diff changeset
    36
  "finsert :: 'a \<Rightarrow> 'a fset \<Rightarrow> 'a fset"
1139
c4001cda9da3 renamed 'as' to 'is' everywhere.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1128
diff changeset
    37
is
684
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    38
  "(op #)"
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    39
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    40
lemma finsert_rsp[quot_respect]:
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    41
  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
    42
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
    43
767
37285ec4387d on suggestion of Tobias renamed "quotient_def" to "quotient_definition"; needs new keyword file
Christian Urban <urbanc@in.tum.de>
parents: 766
diff changeset
    44
quotient_definition
1144
538daee762e6 Added a binding to the parser.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1139
diff changeset
    45
  funion ("_ \<union>f _" [65,66] 65)
538daee762e6 Added a binding to the parser.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1139
diff changeset
    46
where
538daee762e6 Added a binding to the parser.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1139
diff changeset
    47
  "funion :: 'a fset \<Rightarrow> 'a fset \<Rightarrow> 'a fset"
1139
c4001cda9da3 renamed 'as' to 'is' everywhere.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1128
diff changeset
    48
is
684
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    49
  "(op @)"
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    50
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    51
lemma append_rsp_aux1:
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    52
  assumes a : "l2 \<approx> r2 "
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    53
  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
    54
using a
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    55
apply(induct h)
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    56
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
    57
done
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    58
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    59
lemma append_rsp_aux2:
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    60
  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
    61
  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
    62
using a
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    63
apply(induct arbitrary: l2 r2)
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    64
apply(simp_all)
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    65
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
    66
done
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    67
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    68
lemma append_rsp[quot_respect]:
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    69
  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
    70
  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
    71
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    72
767
37285ec4387d on suggestion of Tobias renamed "quotient_def" to "quotient_definition"; needs new keyword file
Christian Urban <urbanc@in.tum.de>
parents: 766
diff changeset
    73
quotient_definition
1144
538daee762e6 Added a binding to the parser.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1139
diff changeset
    74
  fmem ("_ \<in>f _" [50, 51] 50)
538daee762e6 Added a binding to the parser.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1139
diff changeset
    75
where
538daee762e6 Added a binding to the parser.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1139
diff changeset
    76
  "fmem :: 'a \<Rightarrow> 'a fset \<Rightarrow> bool"
1139
c4001cda9da3 renamed 'as' to 'is' everywhere.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1128
diff changeset
    77
is
684
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    78
  "(op mem)"
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    79
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    80
lemma memb_rsp_aux:
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    81
  assumes a: "x \<approx> y"
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    82
  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
    83
  using a by induct auto
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    84
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    85
lemma memb_rsp[quot_respect]:
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    86
  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
    87
  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
    88
1144
538daee762e6 Added a binding to the parser.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1139
diff changeset
    89
definition
684
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    90
  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
    91
where
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    92
  "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
    93
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    94
definition
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    95
  "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
    96
where
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    97
  "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
    98
767
37285ec4387d on suggestion of Tobias renamed "quotient_def" to "quotient_definition"; needs new keyword file
Christian Urban <urbanc@in.tum.de>
parents: 766
diff changeset
    99
quotient_definition
1144
538daee762e6 Added a binding to the parser.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1139
diff changeset
   100
  finter ("_ \<inter>f _" [70, 71] 70)
538daee762e6 Added a binding to the parser.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1139
diff changeset
   101
where
538daee762e6 Added a binding to the parser.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1139
diff changeset
   102
  "finter::'a fset \<Rightarrow> 'a fset \<Rightarrow> 'a fset"
1139
c4001cda9da3 renamed 'as' to 'is' everywhere.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 1128
diff changeset
   103
is
684
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   104
  "inter_list"
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
no_syntax
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   107
  "@Finset"     :: "args => 'a fset"                       ("{|(_)|}")
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   108
syntax
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   109
  "@Finfset"     :: "args => 'a fset"                       ("{|(_)|}")
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   110
translations
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   111
  "{|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
   112
  "{|x|}"         == "CONST finsert x {||}"
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   113
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   114
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   115
subsection {* Empty sets *}
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
lemma test:
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   118
  shows "\<not>(x # xs \<approx> [])"
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   119
sorry
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   120
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   121
lemma finsert_not_empty[simp]: 
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   122
  shows "finsert x S \<noteq> {||}"
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   123
  by (lifting test)
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   124
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   125
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   126
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   127
88094aa77026 added an attempt to get a finite set theory
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   128
end;