(*********************************************************)
(*		Definition is_balanced		  	 *)


Inductive is_balanced_avl (l r : avl_tree) : bal -> Prop :=
  | Is_Left_Balanced_Avl :
      height_avl l = S (height_avl r) -> is_balanced_avl l r Left_Balanced
  | Is_Fully_Balanced_Avl :
      height_avl l = height_avl r -> is_balanced_avl l r Balanced
  | Is_Right_Balanced_Avl :
      S (height_avl l) = height_avl r -> is_balanced_avl l r Right_Balanced.(*********************************************************)
(*		Definition is_balanced		  	 *)


Inductive is_balanced_avl (l r : avl_tree) : bal -> Prop :=
  | Is_Left_Balanced_Avl :
      height_avl l = S (height_avl r) -> is_balanced_avl l r Left_Balanced
  | Is_Fully_Balanced_Avl :
      height_avl l = height_avl r -> is_balanced_avl l r Balanced
  | Is_Right_Balanced_Avl :
      S (height_avl l) = height_avl r -> is_balanced_avl l r Right_Balanced.(*********************************************************)
(*		Definition is_balanced		  	 *)


Inductive is_balanced_avl (l r : avl_tree) : bal -> Prop :=
  | Is_Left_Balanced_Avl :
      height_avl l = S (height_avl r) -> is_balanced_avl l r Left_Balanced
  | Is_Fully_Balanced_Avl :
      height_avl l = height_avl r -> is_balanced_avl l r Balanced
  | Is_Right_Balanced_Avl :
      S (height_avl l) = height_avl r -> is_balanced_avl l r Right_Balanced.(*********************************************************)
(*		Definition is_balanced		  	 *)


Inductive is_balanced_avl (l r : avl_tree) : bal -> Prop :=
  | Is_Left_Balanced_Avl :
      height_avl l = S (height_avl r) -> is_balanced_avl l r Left_Balanced
  | Is_Fully_Balanced_Avl :
      height_avl l = height_avl r -> is_balanced_avl l r Balanced
  | Is_Right_Balanced_Avl :
      S (height_avl l) = height_avl r -> is_balanced_avl l r Right_Balanced.

(* Specifications: *)
Lemma inv_left_balanced_avl : forall l r : avl_tree, is_balanced_avl l r Left_Balanced -> height_avl l = S (height_avl r).
Lemma inv_fully_balanced_avl : forall l r : avl_tree, is_balanced_avl l r Balanced -> height_avl l = height_avl r.
Lemma inv_right_balanced_avl : forall l r : avl_tree, is_balanced_avl l r Right_Balanced -> S (height_avl l) = height_avl r.
Lemma hasnot_grown_left__preserves_is_balanced_avl : forall (l l0 r0 : avl_tree) (b0 : bal), is_balanced_avl l0 r0 b0 -> height_avl l = height_avl l0 -> is_balanced_avl l r0 b0.
Lemma hasnot_grown_right__preserves_is_balanced_avl : forall (l0 r r0 : avl_tree) (b0 : bal), is_balanced_avl l0 r0 b0 -> height_avl r = height_avl r0 -> is_balanced_avl l0 r b0.