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

Normalize #668

Merged
merged 1 commit into from Feb 10, 2019
Merged

Normalize #668

merged 1 commit into from Feb 10, 2019

Conversation

kckennylau
Copy link
Collaborator

https://leanprover.zulipchat.com/#narrow/stream/113488-general/topic/normalize

TO CONTRIBUTORS:

Make sure you have:

  • reviewed and applied the coding style: coding, naming
  • for tactics:
  • make sure definitions and lemmas are put in the right files
  • make sure definitions and lemmas are not redundant

If this PR is related to a discussion on Zulip, please include a link in the discussion.

For reviewers: code review check list

@ChrisHughes24
Copy link
Member

Can you summarise the changes that have been made here? It takes a while to tell what is new code, and what is stuff that has just been moved.

@kckennylau
Copy link
Collaborator Author

old import tree: ring_theory.associated imports data.int.gcd which imports algebra.gcd_domain

new import tree: algebra.gcd_domain imports algebra.associated and data.int.gcd

  • moved ring_theory.associatedalgebra.associated; relocated theorems about nat and int and normalization_domain to algebra.gcd_domain
  • made norm_unit_mul arguments implicit
  • defined normalize and refactor theorems with norm_unit to use normalize, including definition of gcd_domain
  • relocated theorems about integer being normalization domain and gcd domain from data.int.gcd to algebra.gcd_domain

@[simp] theorem norm_unit_one : norm_unit (1:α) = 1 :=
norm_unit_coe_units 1

variables (α)
Copy link
Member

Choose a reason for hiding this comment

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

This should be implicit

Copy link
Collaborator Author

@kckennylau kckennylau Feb 9, 2019

Choose a reason for hiding this comment

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

But it creates metavariables which makes it impossible to use with \t.

Copy link
Member

Choose a reason for hiding this comment

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

I agree with chris. Use rw if \t gives you trouble

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done


@[simp] lemma normalize_eq_one {x : α} : normalize x = 1 ↔ is_unit x :=
⟨λ hx, is_unit_iff_exists_inv.2 ⟨_, hx⟩, λ ⟨u, hu⟩, hu.symm ▸ normalize_coe_units u⟩

Copy link
Member

Choose a reason for hiding this comment

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

debatable whether this should be simp. Equalities are good.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done


lemma normalize_nat_coe (n : ℕ) : normalize (n : ℤ) = n :=
normalize_of_nonneg (coe_nat_le_coe_nat_of_le $ nat.zero_le n)

Copy link
Member

Choose a reason for hiding this comment

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

normalize_coe_nat

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@@ -3,7 +3,7 @@ Copyright (c) 2018 Robert Y. Lewis. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Robert Y. Lewis, Chris Hughes
-/
import data.nat.enat ring_theory.associated
import algebra.gcd_domain data.nat.enat
Copy link
Member

Choose a reason for hiding this comment

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

Does this use anything from gcd_domain or is a weaker import possible?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

calc a * ↑(norm_unit a) = a * ↑(norm_unit a) * ↑u * ↑u⁻¹:
(units.mul_inv_cancel_right _ _).symm
... = a * ↑u * ↑(norm_unit a) * ↑u⁻¹ : by rw mul_right_comm a
end

theorem dvd_antisymm_of_norm {a b : α}
(ha : norm_unit a = 1) (hb : norm_unit b = 1) (hab : a ∣ b) (hba : b ∣ a) :
@[simp] lemma normalize_eq_normalize_iff {x y : α} : normalize x = normalize y ↔ x ∣ y ∧ y ∣ x :=
Copy link
Member

Choose a reason for hiding this comment

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

this doesn't look like it should be a simp lemma either

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@kckennylau kckennylau force-pushed the normalize branch 2 times, most recently from 0b62a9b to 14e360e Compare February 10, 2019 14:31
@kckennylau kckennylau closed this Feb 10, 2019
@kckennylau
Copy link
Collaborator Author

Updated summary: I just added normalize x to replace x * norm_unit x, including in the definition of gcd_domain.

@ChrisHughes24 ChrisHughes24 merged commit 091cad7 into master Feb 10, 2019
@ChrisHughes24 ChrisHughes24 deleted the normalize branch February 10, 2019 21:50
cipher1024 pushed a commit that referenced this pull request Feb 12, 2019
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.

None yet

3 participants