src/HOL/Data_Structures/AA_Set.thy
changeset 68431 b294e095f64c
parent 68413 b56ed5010e69
child 68440 6826718f732d
equal deleted inserted replaced
68423:c1db7503dbaa 68431:b294e095f64c
     9   Isin2
     9   Isin2
    10   Cmp
    10   Cmp
    11 begin
    11 begin
    12 
    12 
    13 type_synonym 'a aa_tree = "('a,nat) tree"
    13 type_synonym 'a aa_tree = "('a,nat) tree"
       
    14 
       
    15 definition empty :: "'a aa_tree" where
       
    16 "empty = Leaf"
    14 
    17 
    15 fun lvl :: "'a aa_tree \<Rightarrow> nat" where
    18 fun lvl :: "'a aa_tree \<Rightarrow> nat" where
    16 "lvl Leaf = 0" |
    19 "lvl Leaf = 0" |
    17 "lvl (Node _ _ lv _) = lv"
    20 "lvl (Node _ _ lv _) = lv"
    18 
    21 
   481 by(induction t)
   484 by(induction t)
   482   (auto simp: del_list_simps inorder_adjust pre_adj_if_postL pre_adj_if_postR 
   485   (auto simp: del_list_simps inorder_adjust pre_adj_if_postL pre_adj_if_postR 
   483               post_split_max post_delete split_maxD split: prod.splits)
   486               post_split_max post_delete split_maxD split: prod.splits)
   484 
   487 
   485 interpretation I: Set_by_Ordered
   488 interpretation I: Set_by_Ordered
   486 where empty = Leaf and isin = isin and insert = insert and delete = delete
   489 where empty = empty and isin = isin and insert = insert and delete = delete
   487 and inorder = inorder and inv = invar
   490 and inorder = inorder and inv = invar
   488 proof (standard, goal_cases)
   491 proof (standard, goal_cases)
   489   case 1 show ?case by simp
   492   case 1 show ?case by (simp add: empty_def)
   490 next
   493 next
   491   case 2 thus ?case by(simp add: isin_set_inorder)
   494   case 2 thus ?case by(simp add: isin_set_inorder)
   492 next
   495 next
   493   case 3 thus ?case by(simp add: inorder_insert)
   496   case 3 thus ?case by(simp add: inorder_insert)
   494 next
   497 next
   495   case 4 thus ?case by(simp add: inorder_delete)
   498   case 4 thus ?case by(simp add: inorder_delete)
   496 next
   499 next
   497   case 5 thus ?case by(simp)
   500   case 5 thus ?case by(simp add: empty_def)
   498 next
   501 next
   499   case 6 thus ?case by(simp add: invar_insert)
   502   case 6 thus ?case by(simp add: invar_insert)
   500 next
   503 next
   501   case 7 thus ?case using post_delete by(auto simp: post_del_def)
   504   case 7 thus ?case using post_delete by(auto simp: post_del_def)
   502 qed
   505 qed