src/HOL/Data_Structures/Isin2.thy
author Manuel Eberl <eberlm@in.tum.de>
Mon, 26 Mar 2018 16:12:55 +0200
changeset 67950 99eaa5cedbb7
parent 67929 30486b96274d
child 67964 08cc5ab18c84
permissions -rw-r--r--
Added some simple facts about limits
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
61224
759b5299a9f2 added red black trees
nipkow
parents:
diff changeset
     1
(* Author: Tobias Nipkow *)
759b5299a9f2 added red black trees
nipkow
parents:
diff changeset
     2
759b5299a9f2 added red black trees
nipkow
parents:
diff changeset
     3
section \<open>Function \textit{isin} for Tree2\<close>
759b5299a9f2 added red black trees
nipkow
parents:
diff changeset
     4
759b5299a9f2 added red black trees
nipkow
parents:
diff changeset
     5
theory Isin2
759b5299a9f2 added red black trees
nipkow
parents:
diff changeset
     6
imports
759b5299a9f2 added red black trees
nipkow
parents:
diff changeset
     7
  Tree2
61692
cb595e12451d removed lemmas that were only needed for old version of isin.
nipkow
parents: 61229
diff changeset
     8
  Cmp
61224
759b5299a9f2 added red black trees
nipkow
parents:
diff changeset
     9
  Set_by_Ordered
759b5299a9f2 added red black trees
nipkow
parents:
diff changeset
    10
begin
759b5299a9f2 added red black trees
nipkow
parents:
diff changeset
    11
63411
e051eea34990 got rid of class cmp; added height-size proofs by Daniel Stuewe
nipkow
parents: 62390
diff changeset
    12
fun isin :: "('a::linorder,'b) tree \<Rightarrow> 'a \<Rightarrow> bool" where
61224
759b5299a9f2 added red black trees
nipkow
parents:
diff changeset
    13
"isin Leaf x = False" |
61692
cb595e12451d removed lemmas that were only needed for old version of isin.
nipkow
parents: 61229
diff changeset
    14
"isin (Node _ l a r) x =
cb595e12451d removed lemmas that were only needed for old version of isin.
nipkow
parents: 61229
diff changeset
    15
  (case cmp x a of
cb595e12451d removed lemmas that were only needed for old version of isin.
nipkow
parents: 61229
diff changeset
    16
     LT \<Rightarrow> isin l x |
cb595e12451d removed lemmas that were only needed for old version of isin.
nipkow
parents: 61229
diff changeset
    17
     EQ \<Rightarrow> True |
cb595e12451d removed lemmas that were only needed for old version of isin.
nipkow
parents: 61229
diff changeset
    18
     GT \<Rightarrow> isin r x)"
61224
759b5299a9f2 added red black trees
nipkow
parents:
diff changeset
    19
67929
30486b96274d eliminated "elems"
nipkow
parents: 63411
diff changeset
    20
lemma isin_set: "sorted(inorder t) \<Longrightarrow> isin t x = (x \<in> set(inorder t))"
30486b96274d eliminated "elems"
nipkow
parents: 63411
diff changeset
    21
by (induction t) (auto simp: isin_simps)
61224
759b5299a9f2 added red black trees
nipkow
parents:
diff changeset
    22
62390
842917225d56 more canonical names
nipkow
parents: 61692
diff changeset
    23
end