diff -r 2ffda850f844 -r c4531ddafe72 src/HOL/Library/Tree.thy --- a/src/HOL/Library/Tree.thy Thu Mar 23 17:20:47 2017 +0100 +++ b/src/HOL/Library/Tree.thy Fri Mar 31 17:21:36 2017 +0200 @@ -93,6 +93,15 @@ (heap l \ heap r \ (\x \ set_tree l \ set_tree r. m \ x))" +subsection \@{const map_tree}\ + +lemma map_tree_Leaf[simp]: "map_tree f t = Leaf \ t = Leaf" +by (rule tree.map_disc_iff) + +lemma Leaf_map_tree[simp]: "Leaf = map_tree f t \ t = Leaf" +by (cases t) auto + + subsection \@{const size}\ lemma size1_simps[simp]: @@ -103,15 +112,15 @@ lemma size1_ge0[simp]: "0 < size1 t" by (simp add: size1_def) -lemma size_0_iff_Leaf: "size t = 0 \ t = Leaf" +lemma size_0_iff_Leaf[simp]: "size t = 0 \ t = Leaf" +by(cases t) auto + +lemma Z_size_iff_Leaf[simp]: "0 = size t \ t = Leaf" by(cases t) auto lemma neq_Leaf_iff: "(t \ \\) = (\l a r. t = \l, a, r\)" by (cases t) auto -lemma finite_set_tree[simp]: "finite(set_tree t)" -by(induction t) auto - lemma size_map_tree[simp]: "size (map_tree f t) = size t" by (induction t) auto @@ -119,6 +128,18 @@ by (simp add: size1_def) +subsection \@{const set_tree}\ + +lemma set_tree_empty[simp]: "set_tree t = {} \ t = Leaf" +by (cases t) auto + +lemma empty_set_tree[simp]: "{} = set_tree t \ t = Leaf" +by (cases t) auto + +lemma finite_set_tree[simp]: "finite(set_tree t)" +by(induction t) auto + + subsection \@{const subtrees}\ lemma set_treeE: "a \ set_tree t \ \l r. \l, a, r\ \ subtrees t" @@ -133,7 +154,10 @@ subsection \@{const height} and @{const min_height}\ -lemma height_0_iff_Leaf: "height t = 0 \ t = Leaf" +lemma height_0_iff_Leaf[simp]: "height t = 0 \ t = Leaf" +by(cases t) auto + +lemma Z_height_iff_Leaf[simp]: "0 = height t \ t = Leaf" by(cases t) auto lemma height_map_tree[simp]: "height (map_tree f t) = height t" @@ -370,6 +394,12 @@ subsection "List of entries" +lemma inorder_Nil_iff[simp]: "inorder t = [] \ t = Leaf" +by (cases t) auto + +lemma Nil_inorder_iff[simp]: "[] = inorder t \ t = Leaf" +by (cases t) auto + lemma set_inorder[simp]: "set (inorder t) = set_tree t" by (induction t) auto @@ -432,6 +462,9 @@ lemma mirror_Leaf[simp]: "mirror t = \\ \ t = \\" by (induction t) simp_all +lemma Leaf_mirror[simp]: "\\ = mirror t \ t = \\" +using mirror_Leaf by fastforce + lemma size_mirror[simp]: "size(mirror t) = size t" by (induction t) simp_all