# HG changeset patch # User nipkow # Date 1541067998 -3600 # Node ID 59aefb3b9e95570f3bd37e32ae37c8258f20aaa3 # Parent a8c707352ccc36e7c3881d41bbed1a72b13a48f5 added and renamed functions diff -r a8c707352ccc -r 59aefb3b9e95 src/HOL/Library/Tree.thy --- a/src/HOL/Library/Tree.thy Thu Nov 01 09:25:58 2018 +0100 +++ b/src/HOL/Library/Tree.thy Thu Nov 01 11:26:38 2018 +0100 @@ -9,9 +9,17 @@ datatype 'a tree = Leaf ("\\") | - Node "'a tree" (root_val: 'a) "'a tree" ("(1\_,/ _,/ _\)") + Node "'a tree" (root: 'a) "'a tree" ("(1\_,/ _,/ _\)") datatype_compat tree +primrec left :: "'a tree \ 'a tree" where +"left (Node l v r) = l" | +"left Leaf = Leaf" + +primrec right :: "'a tree \ 'a tree" where +"right (Node l v r) = r" | +"right Leaf = Leaf" + text\Counting the number of leaves rather than nodes:\ fun size1 :: "'a tree \ nat" where diff -r a8c707352ccc -r 59aefb3b9e95 src/HOL/Probability/Tree_Space.thy --- a/src/HOL/Probability/Tree_Space.thy Thu Nov 01 09:25:58 2018 +0100 +++ b/src/HOL/Probability/Tree_Space.thy Thu Nov 01 11:26:38 2018 +0100 @@ -22,16 +22,6 @@ thus ?thesis using cont by(simp add: sup_continuous_lfp) qed -primrec left :: "'a tree \ 'a tree" -where - "left (Node l v r) = l" -| "left Leaf = Leaf" - -primrec right :: "'a tree \ 'a tree" -where - "right (Node l v r) = r" -| "right Leaf = Leaf" - inductive_set trees :: "'a set \ 'a tree set" for S :: "'a set" where [intro!]: "Leaf \ trees S" | "l \ trees S \ r \ trees S \ v \ S \ Node l v r \ trees S" @@ -241,18 +231,18 @@ unfolding * using A by (intro sets.Un Node_in_tree_sigma pair_measureI) auto qed -lemma measurable_root_val': "root_val \ restrict_space (tree_sigma M) (-{Leaf}) \\<^sub>M M" +lemma measurable_root': "root \ restrict_space (tree_sigma M) (-{Leaf}) \\<^sub>M M" proof (rule measurableI) - show "t \ space (restrict_space (tree_sigma M) (- {Leaf})) \ root_val t \ space M" for t + show "t \ space (restrict_space (tree_sigma M) (- {Leaf})) \ root t \ space M" for t by (cases t) (auto simp: space_restrict_space space_tree_sigma) fix A assume A: "A \ sets M" from sets.sets_into_space[OF this] - have "root_val -` A \ space (restrict_space (tree_sigma M) (- {Leaf})) = + have "root -` A \ space (restrict_space (tree_sigma M) (- {Leaf})) = {Node l a r | l a r. (a, l, r) \ A \ space (tree_sigma M) \ space (tree_sigma M)}" by (auto simp: space_tree_sigma space_restrict_space elim: trees.cases) also have "\ \ sets (tree_sigma M)" using A by (intro sets.Un Node_in_tree_sigma pair_measureI) auto - finally show "root_val -` A \ space (restrict_space (tree_sigma M) (- {Leaf})) \ + finally show "root -` A \ space (restrict_space (tree_sigma M) (- {Leaf})) \ sets (restrict_space (tree_sigma M) (- {Leaf}))" by (auto simp: sets_restrict_space_iff space_restrict_space) qed @@ -264,14 +254,14 @@ (insert \B \ A\, auto) -lemma measurable_root_val[measurable (raw)]: +lemma measurable_root[measurable (raw)]: assumes "f \ X \\<^sub>M tree_sigma M" and "\x. x \ space X \ f x \ Leaf" - shows "(\\. root_val (f \)) \ X \\<^sub>M M" + shows "(\\. root (f \)) \ X \\<^sub>M M" proof - from assms have "f \ X \\<^sub>M restrict_space (tree_sigma M) (- {Leaf})" by (intro measurable_restrict_space2) auto - from this and measurable_root_val' show ?thesis by (rule measurable_compose) + from this and measurable_root' show ?thesis by (rule measurable_compose) qed @@ -354,7 +344,7 @@ qed next case (Node ls u rs) - let ?F = "\\. ?N (\, left (t \), root_val (t \), right (t \), + let ?F = "\\. ?N (\, left (t \), root (t \), right (t \), rec_tree (l \) (n \) (left (t \)), rec_tree (l \) (n \) (right (t \)))" show ?case proof (rule measurable_cong[THEN iffD2]) @@ -376,7 +366,7 @@ by (rule measurable_restrict_space1) (rule measurable_compose[OF Node(3) measurable_right]) subgoal - apply (rule measurable_compose[OF _ measurable_root_val']) + apply (rule measurable_compose[OF _ measurable_root']) apply (rule measurable_restrict_space3[OF Node(3)]) by auto subgoal