(******************************************************************)



Definition rebalance_right_spec (k : Int) (d : B) (l r : avl_tree) 
(b : bal) : Set :=
  { t : avl_tree | 
      is_avl t /\
      lin_avl t = lin_avl (Avl_Node k d l r b) /\
      equiv t (Avl_Node k d l r b) /\
      match r with
      | Avl_Nil => True
      | Avl_Node _ _ _ _ Left_Balanced => height_avl t = height_avl r
      | Avl_Node _ _ _ _ Balanced => height_avl t = S (height_avl r)
      | Avl_Node _ _ _ _ Right_Balanced => height_avl t = height_avl r
      end }.

(* Specifications: *)
Lemma rebalance_right : forall (k : Int) (d : B) (l r : avl_tree) (b : bal), is_avl l -> is_below_avl l k -> is_avl r -> is_above_avl r k -> S (S (height_avl l)) = height_avl r -> rebalance_right_spec k d l r b.