Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

feat(zmod/basic) #18953

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

feat(zmod/basic) #18953

wants to merge 9 commits into from

Conversation

laughinggas
Copy link
Collaborator

@laughinggas laughinggas commented May 6, 2023

Adding some properties regarding zmod n and its units. In particular, we make zmod n a discrete space and obtain a discrete topology on its units. There are some arithmetic properties regarding zmod.val. Finally, we add some lemmas regarding coercion with respect to the Chinese Remainder Theorem.


Open in Gitpod

@github-actions github-actions bot added the modifies-synchronized-file This PR touches a files that has already been ported to mathlib4, and may need a synchronization PR. label May 6, 2023
Comment on lines 31 to 32
lemma coe_map_of_dvd {a b : ℕ} (h : a ∣ b) (x : units (zmod b)) :
is_unit (x : zmod a) :=
Copy link
Collaborator

Choose a reason for hiding this comment

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

Either have a lemma is_unit _ → is_unit _ or a function (zmod b)ˣ → (zmod a)ˣ (possibly we want both!), but not a mix of them like this.

Copy link
Member

Choose a reason for hiding this comment

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

Its true that a ∣ b → (zmod b → zmod a)? I think this follows trivially from that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is a single line proof, yes. Shall I remove it? I possibly need it for future work but I can add it then.

Copy link
Member

@kbuzzard kbuzzard May 9, 2023

Choose a reason for hiding this comment

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

It's true that a ∣ b → (zmod b →+* zmod a). It wouldn't surprise me if mathlib already had a coercion zmod b -> zmod a for arbitrary a and b :-/

src/data/zmod/units.lean Outdated Show resolved Hide resolved
src/topology/maps.lean Outdated Show resolved Hide resolved
src/topology/algebra/constructions.lean Outdated Show resolved Hide resolved
Comment on lines 148 to 153
begin
apply @embedding.discrete_topology _ _ _ _ prod.discrete_topology (units.embed_product _)
(units.embedding_embed_product),
{ apply_instance, },
{ refine inducing.discrete_topology (mul_opposite.unop_injective) rfl, },
end
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this works, no?

Suggested change
begin
apply @embedding.discrete_topology _ _ _ _ prod.discrete_topology (units.embed_product _)
(units.embedding_embed_product),
{ apply_instance, },
{ refine inducing.discrete_topology (mul_opposite.unop_injective) rfl, },
end
by apply_instance

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, it does not. The topology is not canonical.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure I understand. The canonical topology on (X × Y)ˣ is the one coming from the embedding into (X × Y) × (X × Y). If X, Y have the discrete topology, then so does (X × Y)ˣ. This is exactly what you're proving here. What's your non-canonical topology doing if it agrees with the canonical one in your use case?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The embedding is from (X × Y)ˣ to (X × Y) × (X × Y)ᵐᵒᵖ . I don't think (X × Y)ᵐᵒᵖ has the discrete topology as an instance

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah then can you add it? That seems like an obvious omission.

Copy link
Collaborator

@YaelDillies YaelDillies May 8, 2023

Choose a reason for hiding this comment

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

Does apply_instance now work?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes

Copy link
Collaborator

Choose a reason for hiding this comment

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

Then can you remove it entirely?

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 am now getting an error in src/topology/algebra/group/basic.lean on line 1338 :
invalid 'open' command, unknown declaration 'units.mul_opposite.continuous_op'

however, I did not touch any of that code..

Copy link
Member

@kbuzzard kbuzzard May 9, 2023

Choose a reason for hiding this comment

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

embedding.discrete_topology is not known to the typeclass system. This works:

instance foo {X : Type*} [topological_space X] [discrete_topology X] :
  discrete_topology Xᵐᵒᵖ := sorry

lemma discrete_topology_of_discrete {X : Type*} [_root_.topological_space X] [discrete_topology X]
  [monoid X] : discrete_topology Xˣ :=
begin
  apply embedding.discrete_topology units.embedding_embed_product,
  apply_instance,
end

Copy link
Collaborator

@YaelDillies YaelDillies left a comment

Choose a reason for hiding this comment

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

l

Comment on lines +34 to +35
lemma is_unit_of_is_coprime_dvd {a b : ℕ} (h : a ∣ b) {x : ℕ} (hx : x.coprime b) :
is_unit (x : zmod a) :=
Copy link
Collaborator

Choose a reason for hiding this comment

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

This sounds like you're mixing two steps at once.

Suggested change
lemma is_unit_of_is_coprime_dvd {a b : ℕ} (h : a ∣ b) {x : ℕ} (hx : x.coprime b) :
is_unit (x : zmod a) :=
lemma is_unit_of_is_coprime {a x : ℕ} (hx : x.coprime a) :
is_unit (x : zmod a) :=

and in fact that shows you can actually get an iff:

Suggested change
lemma is_unit_of_is_coprime_dvd {a b : ℕ} (h : a ∣ b) {x : ℕ} (hx : x.coprime b) :
is_unit (x : zmod a) :=
@[simp] lemma is_unit_iff_is_coprime {a x : ℕ} :
is_unit (x : zmod a) \iff x.coprime a :=

Note this is not the topology used by default in mathlib.-/
@[continuity]
lemma induced_top_cont_inv {X : Type*} [topological_space X] [discrete_topology X] [monoid X] :
@continuous _ _ (topological_space.induced (units.coe_hom X) infer_instance) _
Copy link
Collaborator

Choose a reason for hiding this comment

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

The question now is: What makes you need that non-canonical topology?

-- { refine λ a b h, units.eq_iff.1 h, }, }
end

lemma discrete_topology_of_discrete {X : Type*} [_root_.topological_space X] [discrete_topology X]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you make that an instance and make sure the name is units.discrete_topology (probably you just need to remove the explicit name)?

-- { refine λ a b h, units.eq_iff.1 h, }, }
end

lemma discrete_topology_of_discrete {X : Type*} [_root_.topological_space X] [discrete_topology X]
Copy link
Collaborator

Choose a reason for hiding this comment

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

This _root_ is fishy. Can you mark protected whatever declaration topological_space could refer to here?

Comment on lines +151 to +153
lemma discrete_prod_units {X Y : Type*} [monoid X] [monoid Y] [topological_space X]
[discrete_topology X] [topological_space Y] [discrete_topology Y] : discrete_topology (X × Y)ˣ :=
embedding.discrete_topology (units.embedding_embed_product)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Once you've made the above an instance,

Suggested change
lemma discrete_prod_units {X Y : Type*} [monoid X] [monoid Y] [topological_space X]
[discrete_topology X] [topological_space Y] [discrete_topology Y] : discrete_topology (X × Y)ˣ :=
embedding.discrete_topology (units.embedding_embed_product)

@kim-em kim-em added the too-late This PR was ready too late for inclusion in mathlib3 label Jul 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
modifies-synchronized-file This PR touches a files that has already been ported to mathlib4, and may need a synchronization PR. too-late This PR was ready too late for inclusion in mathlib3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants