Skip to content
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

Conversation

Alizter
Copy link
Collaborator

@Alizter Alizter commented Aug 27, 2024

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.

Signed-off-by: Ali Caglayan <[email protected]>

<!-- ps-id: f7ec52e0-1ac5-471d-862f-55f08635cac0 -->
theories/Spaces/Nat/Division.v Outdated Show resolved Hide resolved
Comment on lines 371 to 372
Definition nat_div_cancel_mul_l n m k
: 0 < k -> 0 < m -> (m | n) -> (k * n) / (k * m) = n / m.
Copy link
Collaborator

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?

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, this LGTM!

@Alizter Alizter merged commit 4b06edc into HoTT:master Aug 29, 2024
22 checks passed
@Alizter Alizter deleted the ps/rr/add_quotient_cancelling_and_nat_mul_divisibility_monotonicty branch August 29, 2024 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants