Definition empty := Leaf.Fixpoint is_empty (m:map) :=
  match m with
  | Leaf => true
  | _ => false
  end.Fixpoint get (m: map) (i: positive) {struct i} : option A :=
  match m with
  | Leaf => None
  | Node l o r =>
      match i with
      | xH => o
      | xO ii => get l ii
      | xI ii => get r ii
      end
  end.Fixpoint unset (m:map) (i:positive) { struct i } : map :=
  match m with
  | Leaf => Leaf
  | Node l o r =>
     match i with
     | xH => Node l None r
     | xO ii => Node (unset l ii) o r
     | xI ii => Node l o (unset r ii)
     end
  end.Fixpoint set (m: map) (i: positive) (v: A) {struct i} : map :=
  match m with
  | Leaf =>
      match i with
      | xH => Node Leaf (Some v) Leaf
      | xO ii => Node (set Leaf ii v) None Leaf
      | xI ii => Node Leaf None (set Leaf ii v)
      end
  | Node l o r =>
      match i with
      | xH => Node l (Some v) r
      | xO ii => Node (set l ii v) o r
      | xI ii => Node l o (set r ii v)
      end
  end.

Lemma get_set_same: forall (n: positive) (m: map) (x: A), get (set m n x) n = Some x.