Inductive SubMaskSpec (p q : positive) : mask -> Prop :=
| SubIsNul : p = q -> SubMaskSpec p q IsNul
| SubIsPos : forall r, q + r = p -> SubMaskSpec p q (IsPos r)
| SubIsNeg : forall r, p + r = q -> SubMaskSpec p q IsNeg.

(* Specifications: *)
Theorem sub_mask_spec p q : SubMaskSpec p q (sub_mask p q).
Theorem sub_mask_nul_iff p q : sub_mask p q = IsNul <-> p = q.
Theorem sub_mask_diag p : sub_mask p p = IsNul.
Lemma sub_mask_add p q r : sub_mask p q = IsPos r -> q + r = p.
Lemma sub_mask_add_diag_l p q : sub_mask (p+q) p = IsPos q.
Lemma sub_mask_pos_iff p q r : sub_mask p q = IsPos r <-> q + r = p.
Lemma sub_mask_add_diag_r p q : sub_mask p (p+q) = IsNeg.
Lemma sub_mask_neg_iff p q : sub_mask p q = IsNeg <-> exists r, p + r = q.
(*********************************************************************)
(** * Properties of boolean comparisons *)
Theorem eqb_eq p q : (p =? q) = true <-> p=q.
Theorem ltb_lt p q : (p <? q) = true <-> p < q.
Theorem leb_le p q : (p <=? q) = true <-> p <= q.
Include BoolEqualityFacts.