-
Notifications
You must be signed in to change notification settings - Fork 194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add quotient cancelling and nat_mul divisibility monotonicty #2063
add quotient cancelling and nat_mul divisibility monotonicty #2063
Conversation
Signed-off-by: Ali Caglayan <[email protected]> <!-- ps-id: f7ec52e0-1ac5-471d-862f-55f08635cac0 -->
theories/Spaces/Nat/Division.v
Outdated
Definition nat_div_cancel_mul_l n m k | ||
: 0 < k -> 0 < m -> (m | n) -> (k * n) / (k * m) = n / m. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is also true when m = 0
, easily. In fact, it is also true without the hypothesis that (m | n)
. Here's a proof that uses nat_zero_or_gt_zero
from #2062.
Definition nat_div_cancel_mul_l n m k
: 0 < k -> (k * n) / (k * m) = n / m.
Proof.
intro kp.
destruct (nat_zero_or_gt_zero m) as [[] | mp].
1: by rewrite nat_mul_zero_r.
symmetry; nrapply (nat_div_unique _ _ _ (k * (n mod m))).
1: rapply nat_mul_l_strictly_monotone.
rewrite <- nat_mul_assoc.
rewrite <- nat_dist_l.
apply ap.
symmetry; apply nat_div_mod_spec.
Defined.
While I'm at it, here's a similar fact about mod:
Definition nat_mod_mul_l n m k
: (k * n) mod (k * m) = k * (n mod m).
Proof.
destruct (nat_zero_or_gt_zero k) as [[] | kp].
1: reflexivity.
destruct (nat_zero_or_gt_zero m) as [[] | mp].
1: by rewrite nat_mul_zero_r.
symmetry; apply (nat_mod_unique _ _ (n / m)).
1: rapply nat_mul_l_strictly_monotone.
rewrite <- nat_mul_assoc.
rewrite <- nat_dist_l.
apply ap.
symmetry; apply nat_div_mod_spec.
Defined.
Maybe the two proofs can even be combined, using nat_div_mod_spec
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good point. I'll wait until #2062 is merged and have a go at combining these two facts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't see a way to combine both lemmas in the end, partly because the assumptions on k
are different.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, this LGTM!
Co-authored-by: Dan Christensen <[email protected]>
…divisibility_monotonicty
Signed-off-by: Ali Caglayan <[email protected]>
In this PR we add a lemma showing that multiplication is monotone with respect to divisibility as an order.
We also give two lemmas allow us to cancel common factors in quotients, given suitable conditions.