Skip to content

Commit

Permalink
Merge pull request #2049 from Alizter/ps/rr/nat__distributivity_of_mu…
Browse files Browse the repository at this point in the history
…ltiplication_over_subtraction

Nat: distributivity of multiplication over subtraction
  • Loading branch information
Alizter authored Aug 6, 2024
2 parents f367ba9 + 5cad8d0 commit 6e70545
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 6e70545

Please sign in to comment.