Inductive tree X : Type :=
  | leaf
  | node (data: X) (o_l o_r : tree X).Inductive tree X : Type :=
  | leaf
  | node (data: X) (o_l o_r : tree X).Inductive tree X : Type :=
  | leaf
  | node (data: X) (o_l o_r : tree X).Fixpoint is_p_b_tr {X} (o : tree X) (l : nat) : Prop :=
  match o, l with
  | leaf, O => True
  | node _ o_l o_r, S l' =>
      is_p_b_tr o_l l' /\ is_p_b_tr o_r l'
  | _, _ => False
  end.Definition path := list bool.Fixpoint coord_in_bound {X} (o : tree X) (p : path) (stop: nat) : Prop :=
  match o with
  | leaf => False 
  | node d_o o_l o_r =>
      match stop with
      | 0%nat => True 
      | S stop' =>
          match p with
          | [] => False 
          | true :: xs => coord_in_bound o_l xs stop' 
          | false :: xs => coord_in_bound o_r xs stop'
          end
      end
  end.

Lemma pb_coord_in_bound {X} : forall (o : tree X) (p : path) (k lvl : nat), is_p_b_tr o (S k) -> (length p) = k -> lvl <= k -> coord_in_bound o p lvl.