(** Properties of bitwise complement.*)

(* Specifications: *)
Theorem not_involutive:
forall (x: int), not (not x) = x.
Theorem not_zero:
not zero = mone.
Theorem not_mone:
not mone = zero.
Theorem not_or_and_not:
forall x y, not (or x y) = and (not x) (not y).
Theorem not_and_or_not:
forall x y, not (and x y) = or (not x) (not y).
Theorem and_not_self:
forall x, and x (not x) = zero.
Theorem or_not_self:
forall x, or x (not x) = mone.
Theorem xor_not_self:
forall x, xor x (not x) = mone.
Lemma unsigned_not:
forall x, unsigned (not x) = max_unsigned - unsigned x.
Theorem not_neg:
forall x, not x = add (neg x) mone.
Theorem neg_not:
forall x, neg x = add (not x) one.
Theorem sub_add_not:
forall x y, sub x y = add (add x (not y)) one.
Theorem sub_add_not_3:
forall x y b,
b = zero \/ b = one ->
sub (sub x y) b = add (add x (not y)) (xor b one).
Theorem sub_borrow_add_carry:
forall x y b,
b = zero \/ b = one ->
sub_borrow x y b = xor (add_carry x (not y) (xor b one)) one.
Theorem not_involutive:
forall (x: int), not (not x) = x.
Theorem not_zero:
not zero = mone.
Theorem not_mone:
not mone = zero.
Theorem not_or_and_not:
forall x y, not (or x y) = and (not x) (not y).
Theorem not_and_or_not:
forall x y, not (and x y) = or (not x) (not y).
Theorem and_not_self:
forall x, and x (not x) = zero.
Theorem or_not_self:
forall x, or x (not x) = mone.
Theorem xor_not_self:
forall x, xor x (not x) = mone.
Lemma unsigned_not:
forall x, unsigned (not x) = max_unsigned - unsigned x.
Theorem not_neg:
forall x, not x = add (neg x) mone.
Theorem neg_not:
forall x, neg x = add (not x) one.
Theorem sub_add_not:
forall x y, sub x y = add (add x (not y)) one.
Theorem sub_add_not_3:
forall x y b,
b = zero \/ b = one ->
sub (sub x y) b = add (add x (not y)) (xor b one).
Theorem sub_borrow_add_carry:
forall x y b,
b = zero \/ b = one ->
sub_borrow x y b = xor (add_carry x (not y) (xor b one)) one.