Skip to content

Commit

Permalink
Nat: distributivity of multiplication over subtraction
Browse files Browse the repository at this point in the history
Signed-off-by: Ali Caglayan <[email protected]>

<!-- ps-id: af8adbae-9592-4c12-ad1e-1bf1df684d2c -->
  • Loading branch information
Alizter committed Aug 6, 2024
1 parent f367ba9 commit 5cad8d0
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions theories/Spaces/Nat/Core.v
Original file line number Diff line number Diff line change
Expand Up @@ -1174,6 +1174,33 @@ Proof.
exact IHleq.
Defined.

(** Multiplication on the left distributes over subtraction. *)
Definition nat_dist_sub_l n m k
: n * (m - k) = n * m - n * k.
Proof.
induction n as [|n IHn] in m, k |- *.
1: reflexivity.
destruct (leq_dichotomy k m) as [l|r].
- simpl; rewrite IHn, <- nat_sub_l_add_r, <- nat_sub_l_add_l,
nat_sub_r_add; trivial; exact _.
- apply leq_lt in r.
apply equiv_nat_sub_leq in r.
rewrite r.
rewrite nat_mul_zero_r.
symmetry.
apply equiv_nat_sub_leq.
apply nat_mul_l_monotone.
by apply equiv_nat_sub_leq.
Defined.

(** Multiplication on the right distributes over subtraction. *)
Definition nat_dist_sub_r n m k
: (n - m) * k = n * k - m * k.
Proof.
rewrite 3 (nat_mul_comm _ k).
apply nat_dist_sub_l.
Defined.

(** *** Monotonicity of subtraction *)

(** Subtraction is monotone in the left argument. *)
Expand Down

0 comments on commit 5cad8d0

Please sign in to comment.