src/HOL/Data_Structures/Isin2.thy
author nipkow
Sun, 13 May 2018 13:15:50 +0200
changeset 68159 620ca44d8b7d
parent 67967 5a4280946a25
child 68413 b56ed5010e69
permissions -rw-r--r--
removed unused lemma
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
67965
aaa31cd0caef more name tuning
nipkow
parents: 67964
diff changeset
     9
  Set_Specs
61224
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
67967
5a4280946a25 moved and renamed lemmas
nipkow
parents: 67965
diff changeset
    20
lemma isin_set_inorder: "sorted(inorder t) \<Longrightarrow> isin t x = (x \<in> set(inorder t))"
67929
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
67967
5a4280946a25 moved and renamed lemmas
nipkow
parents: 67965
diff changeset
    23
lemma isin_set_tree: "bst t \<Longrightarrow> isin t x \<longleftrightarrow> x \<in> set_tree t"
5a4280946a25 moved and renamed lemmas
nipkow
parents: 67965
diff changeset
    24
by(induction t) auto
5a4280946a25 moved and renamed lemmas
nipkow
parents: 67965
diff changeset
    25
62390
842917225d56 more canonical names
nipkow
parents: 61692
diff changeset
    26
end