src/HOL/Data_Structures/Binomial_Heap.thy
changeset 79969 4aeb25ba90f3
parent 79666 65223730d7e1
equal deleted inserted replaced
79968:f1c29e366c09 79969:4aeb25ba90f3
   470   then show ?thesis using le_log2_of_power by blast
   470   then show ?thesis using le_log2_of_power by blast
   471 qed
   471 qed
   472 
   472 
   473 subsubsection \<open>Timing Functions\<close>
   473 subsubsection \<open>Timing Functions\<close>
   474 
   474 
   475 define_time_fun link
   475 time_fun link
   476 
   476 
   477 lemma T_link[simp]: "T_link t\<^sub>1 t\<^sub>2 = 0"
   477 lemma T_link[simp]: "T_link t\<^sub>1 t\<^sub>2 = 0"
   478 by(cases t\<^sub>1; cases t\<^sub>2, auto)
   478 by(cases t\<^sub>1; cases t\<^sub>2, auto)
   479 
   479 
   480 define_time_fun rank
   480 time_fun rank
   481 
   481 
   482 lemma T_rank[simp]: "T_rank t = 0"
   482 lemma T_rank[simp]: "T_rank t = 0"
   483 by(cases t, auto)
   483 by(cases t, auto)
   484 
   484 
   485 define_time_fun ins_tree
   485 time_fun ins_tree
   486 
   486 
   487 define_time_fun insert
   487 time_fun insert
   488 
   488 
   489 lemma T_ins_tree_simple_bound: "T_ins_tree t ts \<le> length ts + 1"
   489 lemma T_ins_tree_simple_bound: "T_ins_tree t ts \<le> length ts + 1"
   490 by (induction t ts rule: T_ins_tree.induct) auto
   490 by (induction t ts rule: T_ins_tree.induct) auto
   491 
   491 
   492 subsubsection \<open>\<open>T_insert\<close>\<close>
   492 subsubsection \<open>\<open>T_insert\<close>\<close>
   502   finally show ?thesis by simp
   502   finally show ?thesis by simp
   503 qed
   503 qed
   504 
   504 
   505 subsubsection \<open>\<open>T_merge\<close>\<close>
   505 subsubsection \<open>\<open>T_merge\<close>\<close>
   506 
   506 
   507 define_time_fun merge
   507 time_fun merge
   508 
   508 
   509 (* Warning: \<open>T_merge.induct\<close> is less convenient than the equivalent \<open>merge.induct\<close>,
   509 (* Warning: \<open>T_merge.induct\<close> is less convenient than the equivalent \<open>merge.induct\<close>,
   510 apparently because of the \<open>let\<close> clauses introduced by pattern_aliases; should be investigated.
   510 apparently because of the \<open>let\<close> clauses introduced by pattern_aliases; should be investigated.
   511 *)
   511 *)
   512 
   512 
   545   finally show ?thesis by (simp add: algebra_simps)
   545   finally show ?thesis by (simp add: algebra_simps)
   546 qed
   546 qed
   547 
   547 
   548 subsubsection \<open>\<open>T_get_min\<close>\<close>
   548 subsubsection \<open>\<open>T_get_min\<close>\<close>
   549 
   549 
   550 define_time_fun root
   550 time_fun root
   551 
   551 
   552 lemma T_root[simp]: "T_root t = 0"
   552 lemma T_root[simp]: "T_root t = 0"
   553 by(cases t)(simp_all)
   553 by(cases t)(simp_all)
   554 
   554 
   555 define_time_fun min
   555 time_fun min
   556 
   556 
   557 define_time_fun get_min
   557 time_fun get_min
   558 
   558 
   559 lemma T_get_min_estimate: "ts\<noteq>[] \<Longrightarrow> T_get_min ts = length ts"
   559 lemma T_get_min_estimate: "ts\<noteq>[] \<Longrightarrow> T_get_min ts = length ts"
   560 by (induction ts rule: T_get_min.induct) auto
   560 by (induction ts rule: T_get_min.induct) auto
   561 
   561 
   562 lemma T_get_min_bound:
   562 lemma T_get_min_bound:
   569   finally show ?thesis .
   569   finally show ?thesis .
   570 qed
   570 qed
   571 
   571 
   572 subsubsection \<open>\<open>T_del_min\<close>\<close>
   572 subsubsection \<open>\<open>T_del_min\<close>\<close>
   573 
   573 
   574 define_time_fun get_min_rest
   574 time_fun get_min_rest
   575 (*fun T_get_min_rest :: "'a::linorder trees \<Rightarrow> nat" where
   575 (*fun T_get_min_rest :: "'a::linorder trees \<Rightarrow> nat" where
   576   "T_get_min_rest [t] = 1"
   576   "T_get_min_rest [t] = 1"
   577 | "T_get_min_rest (t#ts) = 1 + T_get_min_rest ts"*)
   577 | "T_get_min_rest (t#ts) = 1 + T_get_min_rest ts"*)
   578 
   578 
   579 lemma T_get_min_rest_estimate: "ts\<noteq>[] \<Longrightarrow> T_get_min_rest ts = length ts"
   579 lemma T_get_min_rest_estimate: "ts\<noteq>[] \<Longrightarrow> T_get_min_rest ts = length ts"
   593 it can and is implemented (via suitable code lemmas) as a linear time function.
   593 it can and is implemented (via suitable code lemmas) as a linear time function.
   594 Thus the following definition is justified:\<close>
   594 Thus the following definition is justified:\<close>
   595 
   595 
   596 definition "T_rev xs = length xs + 1"
   596 definition "T_rev xs = length xs + 1"
   597 
   597 
   598 define_time_fun del_min
   598 time_fun del_min
   599 
   599 
   600 lemma T_del_min_bound:
   600 lemma T_del_min_bound:
   601   fixes ts
   601   fixes ts
   602   defines "n \<equiv> size (mset_trees ts)"
   602   defines "n \<equiv> size (mset_trees ts)"
   603   assumes "invar ts" and "ts\<noteq>[]"
   603   assumes "invar ts" and "ts\<noteq>[]"